From 07f216e851f79780522fd22eb6a29f71e2d3a799 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Feb 2024 15:25:38 -0800 Subject: [PATCH 1/9] bmc_installer: bump to 0.1.1 --- tp2bmc/package/bmc_installer/bmc_installer.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tp2bmc/package/bmc_installer/bmc_installer.mk b/tp2bmc/package/bmc_installer/bmc_installer.mk index f4734558..efdfc99f 100644 --- a/tp2bmc/package/bmc_installer/bmc_installer.mk +++ b/tp2bmc/package/bmc_installer/bmc_installer.mk @@ -4,7 +4,7 @@ # ########################################################### -BMC_INSTALLER_VERSION = 0.1.0 +BMC_INSTALLER_VERSION = 0.1.1 BMC_INSTALLER_SITE = $(call github,turing-machines,BMC-Installer,$(BMC_INSTALLER_VERSION)) BMC_INSTALLER_LICENSE = Apache-2.0 BMC_INSTALLER_LICENSE_FILES = LICENSE From 1247b528e0dfecd6487fcc1532b1f3c77cca4968 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Feb 2024 21:00:05 -0800 Subject: [PATCH 2/9] linux: begin upgrading to Linux 6.6 --- tp2bmc/board/tp2bmc/boot.scr | 7 +- tp2bmc/board/tp2bmc/install.scr | 6 +- tp2bmc/board/tp2bmc/linux_defconfig | 141 +- .../tp2bmc/overlay/etc/init.d/S11bmc-otg | 3 - tp2bmc/board/tp2bmc/post_build.sh | 4 +- tp2bmc/board/tp2bmc/post_image.sh | 4 +- .../sun8i-t113s-turingmachines-tp2-bmc.dts | 180 +- .../sun8iw20p1-t113-turingmachines-tp2bmc.dts | 747 ------- tp2bmc/board/tp2bmc/sun8iw20p1.dtsi | 1967 ----------------- tp2bmc/configs/tp2bmc_defconfig | 7 +- ...dd-devm_regulator_bulk_get_exclusive.patch | 210 -- ...002-Handle-regulator-output-DT-nodes.patch | 177 -- .../0010-Introduce-gpiod_set_config.patch | 109 - .../linux/0011-Add-GPIO-Aggregator.patch | 647 ------ ...acronix-Add-support-for-MX35LFxGE4AD.patch | 51 - ...-Add-turingmachines-tp2-nodes-compat.patch | 4 +- tp2bmc/patches/linux/backport-emc2305.patch | 1054 --------- 17 files changed, 229 insertions(+), 5089 deletions(-) delete mode 100644 tp2bmc/board/tp2bmc/sun8iw20p1-t113-turingmachines-tp2bmc.dts delete mode 100644 tp2bmc/board/tp2bmc/sun8iw20p1.dtsi delete mode 100644 tp2bmc/patches/linux/0001-Add-devm_regulator_bulk_get_exclusive.patch delete mode 100644 tp2bmc/patches/linux/0002-Handle-regulator-output-DT-nodes.patch delete mode 100644 tp2bmc/patches/linux/0010-Introduce-gpiod_set_config.patch delete mode 100644 tp2bmc/patches/linux/0011-Add-GPIO-Aggregator.patch delete mode 100644 tp2bmc/patches/linux/0012-mtd-spinand-macronix-Add-support-for-MX35LFxGE4AD.patch delete mode 100644 tp2bmc/patches/linux/backport-emc2305.patch diff --git a/tp2bmc/board/tp2bmc/boot.scr b/tp2bmc/board/tp2bmc/boot.scr index efb36c76..ed67026f 100644 --- a/tp2bmc/board/tp2bmc/boot.scr +++ b/tp2bmc/board/tp2bmc/boot.scr @@ -1,11 +1,10 @@ # SPDX-License-Identifier: GPL-2.0+ # Copyright (C) 2023 Sam Edwards -fdt_filename="FDT_FILENAME_HERE" +fdt_filename="sun8i-t113s-turingmachines-tp2-bmc.dtb" # Set bootargs: -setenv bootargs earlycon=uart8250,mmio32,0x02500c00 console=ttyS3,115200 \ - loglevel=8 cma=8M init=/sbin/preinit +setenv bootargs loglevel=8 cma=8M init=/sbin/preinit rootwait=5 if test ${devtype} = mmc; then setenv bootargs ${bootargs} root=PARTUUID=${distro_bootpart_uuid} @@ -14,7 +13,7 @@ if test ${devtype} = ubi; then setenv bootargs ${bootargs} ubi.mtd=ubi ubi.block=${devnum},${distro_bootpart} root=254:0 fi -setenv bootargs ${bootargs} sunxi_gmac.mac_str=${ethaddr} ${bootmode} +setenv bootargs ${bootargs} ${bootmode} # Load image, FDT load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} /boot/zImage diff --git a/tp2bmc/board/tp2bmc/install.scr b/tp2bmc/board/tp2bmc/install.scr index f275abaa..59a4d74b 100644 --- a/tp2bmc/board/tp2bmc/install.scr +++ b/tp2bmc/board/tp2bmc/install.scr @@ -12,7 +12,7 @@ if test "${bootmode}" != "safemode"; then if test -e ${devtype} ${devnum}:${distro_bootpart} ${installer_marker}; then echo ...exists: entering installer - fdt_filename="FDT_FILENAME_HERE" + fdt_filename="sun8i-t113s-turingmachines-tp2-bmc.dtb" linux_bootpart=2 # Load image, initramfs, and FDT @@ -22,9 +22,9 @@ if test "${bootmode}" != "safemode"; then then # Patch FDT to allow write access to the bootloader partition fdt addr ${fdt_addr_r} - fdt rm flash_partitions/partition@0 read-only + fdt rm flash0/partitions/partition@0 read-only - env set bootargs loglevel=4 console=ttyS3,115200 + env set bootargs loglevel=4 bootz ${loadaddr} ${ramdisk_addr_r} ${fdt_addr_r} fi else diff --git a/tp2bmc/board/tp2bmc/linux_defconfig b/tp2bmc/board/tp2bmc/linux_defconfig index 8cd6d53e..d9f35468 100644 --- a/tp2bmc/board/tp2bmc/linux_defconfig +++ b/tp2bmc/board/tp2bmc/linux_defconfig @@ -10,25 +10,17 @@ CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=14 CONFIG_BLK_DEV_INITRD=y CONFIG_CC_OPTIMIZE_FOR_SIZE=y -# CONFIG_SYSFS_SYSCALL is not set -CONFIG_KALLSYMS_ALL=y -CONFIG_EMBEDDED=y # CONFIG_PERF_EVENTS is not set -# CONFIG_COMPAT_BRK is not set CONFIG_PROFILING=y CONFIG_ARCH_SUNXI=y # CONFIG_MACH_SUN4I is not set # CONFIG_MACH_SUN5I is not set # CONFIG_MACH_SUN6I is not set # CONFIG_MACH_SUN7I is not set -# CONFIG_MACH_SUN8I is not set # CONFIG_MACH_SUN9I is not set -CONFIG_ARCH_SUN8IW20=y -CONFIG_EVB_PLATFORM=y -CONFIG_SUNXI_SOC_NAME="sun8iw20" -# CONFIG_VDSO is not set CONFIG_SMP=y CONFIG_SCHED_MC=y +CONFIG_HAVE_ARM_ARCH_TIMER=y CONFIG_ARM_PSCI=y CONFIG_OABI_COMPAT=y # CONFIG_ARM_MODULE_PLTS is not set @@ -44,6 +36,7 @@ CONFIG_JUMP_LABEL=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +# CONFIG_COMPAT_BRK is not set # CONFIG_COMPACTION is not set CONFIG_CMA=y CONFIG_NET=y @@ -64,7 +57,7 @@ CONFIG_UEVENT_HELPER=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y -CONFIG_SUNXI_MBUS=y +# CONFIG_SUNXI_RSB is not set CONFIG_MTD=y CONFIG_MTD_SPI_NAND=y CONFIG_MTD_UBI=y @@ -74,30 +67,36 @@ CONFIG_SCSI=y CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y # CONFIG_NET_VENDOR_ALACRITECH is not set -CONFIG_SUNXI_GMAC=y +# CONFIG_NET_VENDOR_ALLWINNER is not set # CONFIG_NET_VENDOR_AMAZON is not set # CONFIG_NET_VENDOR_AQUANTIA is not set # CONFIG_NET_VENDOR_ARC is not set -# CONFIG_NET_VENDOR_AURORA is not set +# CONFIG_NET_VENDOR_ASIX is not set # CONFIG_NET_VENDOR_BROADCOM is not set # CONFIG_NET_VENDOR_CADENCE is not set # CONFIG_NET_VENDOR_CAVIUM is not set # CONFIG_NET_VENDOR_CIRRUS is not set # CONFIG_NET_VENDOR_CORTINA is not set +# CONFIG_NET_VENDOR_DAVICOM is not set +# CONFIG_NET_VENDOR_ENGLEDER is not set # CONFIG_NET_VENDOR_EZCHIP is not set # CONFIG_NET_VENDOR_FARADAY is not set +# CONFIG_NET_VENDOR_FUNGIBLE is not set # CONFIG_NET_VENDOR_GOOGLE is not set # CONFIG_NET_VENDOR_HISILICON is not set # CONFIG_NET_VENDOR_HUAWEI is not set # CONFIG_NET_VENDOR_INTEL is not set +# CONFIG_NET_VENDOR_ADI is not set +# CONFIG_NET_VENDOR_LITEX is not set # CONFIG_NET_VENDOR_MARVELL is not set # CONFIG_NET_VENDOR_MELLANOX is not set # CONFIG_NET_VENDOR_MICREL is not set # CONFIG_NET_VENDOR_MICROCHIP is not set # CONFIG_NET_VENDOR_MICROSEMI is not set +# CONFIG_NET_VENDOR_MICROSOFT is not set +# CONFIG_NET_VENDOR_NI is not set # CONFIG_NET_VENDOR_NATSEMI is not set # CONFIG_NET_VENDOR_NETRONOME is not set -# CONFIG_NET_VENDOR_NI is not set # CONFIG_NET_VENDOR_PENSANDO is not set # CONFIG_NET_VENDOR_QUALCOMM is not set # CONFIG_NET_VENDOR_RENESAS is not set @@ -107,79 +106,70 @@ CONFIG_SUNXI_GMAC=y # CONFIG_NET_VENDOR_SOLARFLARE is not set # CONFIG_NET_VENDOR_SMSC is not set # CONFIG_NET_VENDOR_SOCIONEXT is not set -# CONFIG_NET_VENDOR_STMICRO is not set +CONFIG_STMMAC_ETH=y +# CONFIG_DWMAC_SUNXI is not set # CONFIG_NET_VENDOR_SYNOPSYS is not set +# CONFIG_NET_VENDOR_VERTEXCOM is not set # CONFIG_NET_VENDOR_VIA is not set +# CONFIG_NET_VENDOR_WANGXUN is not set # CONFIG_NET_VENDOR_WIZNET is not set # CONFIG_NET_VENDOR_XILINX is not set +CONFIG_REALTEK_PHY=y # CONFIG_USB_NET_DRIVERS is not set # CONFIG_WLAN is not set CONFIG_INPUT_EVDEV=y -CONFIG_INPUT_SENSORINIT=y CONFIG_KEYBOARD_GPIO=y # CONFIG_INPUT_MOUSE is not set -CONFIG_INPUT_SENSOR=y # CONFIG_LEGACY_PTYS is not set -# CONFIG_HW_RANDOM is not set -CONFIG_SUNXI_SYS_INFO=y -CONFIG_SUNXI_SMC=y +# CONFIG_LEGACY_TIOCSTI is not set +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=8 +CONFIG_SERIAL_8250_DW=y CONFIG_I2C=y CONFIG_I2C_CHARDEV=y CONFIG_I2C_GPIO=y +CONFIG_I2C_MV64XXX=y CONFIG_SPI=y -CONFIG_SPI_SUNXI=y +CONFIG_SPI_SUN6I=y CONFIG_SPI_SPIDEV=y +# CONFIG_PINCTRL_SUN4I_A10 is not set +# CONFIG_PINCTRL_SUN8I_A23 is not set +# CONFIG_PINCTRL_SUN8I_A33 is not set +# CONFIG_PINCTRL_SUN8I_A83T is not set +# CONFIG_PINCTRL_SUN8I_A83T_R is not set +# CONFIG_PINCTRL_SUN8I_A23_R is not set +# CONFIG_PINCTRL_SUN8I_H3 is not set +# CONFIG_PINCTRL_SUN8I_H3_R is not set +# CONFIG_PINCTRL_SUN8I_V3S is not set CONFIG_GPIO_AGGREGATOR=y -CONFIG_GPIO_SYSFS=y CONFIG_POWER_SUPPLY=y CONFIG_SENSORS_EMC2305=y -CONFIG_SUNXI_THERMAL=y +CONFIG_SUN8I_THERMAL=y CONFIG_WATCHDOG=y CONFIG_SUNXI_WATCHDOG=y CONFIG_REGULATOR=y -CONFIG_REGULATOR_USERSPACE_CONSUMER=y CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_USERSPACE_CONSUMER=y +CONFIG_REGULATOR_GPIO=y CONFIG_USB=y -CONFIG_USB_ACM=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_EHCI_HCD_SUNXI=y +CONFIG_USB_EHCI_HCD_PLATFORM=y CONFIG_USB_OHCI_HCD=y -CONFIG_USB_OHCI_HCD_SUNXI=y -CONFIG_USB_SUNXI_HCD=y -CONFIG_USB_SUNXI_HCI=y -CONFIG_USB_SUNXI_EHCI0=y -CONFIG_USB_SUNXI_EHCI1=y -CONFIG_USB_SUNXI_OHCI0=y -CONFIG_USB_SUNXI_OHCI1=y +CONFIG_USB_OHCI_HCD_PLATFORM=y +CONFIG_USB_ACM=y CONFIG_USB_STORAGE=y -CONFIG_USB_STORAGE_REALTEK=y -CONFIG_USB_STORAGE_DATAFAB=y -CONFIG_USB_STORAGE_FREECOM=y -CONFIG_USB_STORAGE_ISD200=y -CONFIG_USB_STORAGE_USBAT=y -CONFIG_USB_STORAGE_SDDR09=y -CONFIG_USB_STORAGE_SDDR55=y -CONFIG_USB_STORAGE_JUMPSHOT=y -CONFIG_USB_STORAGE_ALAUDA=y -CONFIG_USB_STORAGE_ONETOUCH=y -CONFIG_USB_STORAGE_KARMA=y -CONFIG_USB_STORAGE_CYPRESS_ATACB=y -CONFIG_USB_STORAGE_ENE_UB6250=y -CONFIG_USB_UAS=y +CONFIG_USB_MUSB_HDRC=y +CONFIG_USB_MUSB_SUNXI=y +CONFIG_NOP_USB_XCEIV=y CONFIG_USB_GADGET=y -CONFIG_USB_SUNXI_UDC0=y CONFIG_USB_CONFIGFS=y -CONFIG_USB_CONFIGFS_ACM=y -CONFIG_USB_CONFIGFS_UEVENT=y CONFIG_USB_CONFIGFS_SERIAL=y +CONFIG_USB_CONFIGFS_ACM=y CONFIG_USB_CONFIGFS_RNDIS=y CONFIG_USB_CONFIGFS_MASS_STORAGE=y CONFIG_USB_CONFIGFS_F_FS=y CONFIG_USB_CONFIGFS_F_HID=y -CONFIG_USB_SUNXI_USB=y -CONFIG_USB_SUNXI_USB_MANAGER=y -CONFIG_USB_SUNXI_USB_DEBUG=y -CONFIG_USB_SUNXI_USB_ADB=y CONFIG_USB_ROLE_SWITCH=y CONFIG_MMC=y CONFIG_MMC_SUNXI=y @@ -187,31 +177,28 @@ CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_GPIO=y CONFIG_RTC_CLASS=y -CONFIG_RTC_DRV_SUNXI=y -CONFIG_SUNXI_REBOOT_FLAG=y -CONFIG_SUNXI_RTC_BOOTCOUNT=y CONFIG_DMADEVICES=y CONFIG_DMA_SUN6I=y # CONFIG_VIRTIO_MENU is not set CONFIG_STAGING=y -CONFIG_ION=y -CONFIG_ION_SYSTEM_HEAP=y -CONFIG_ION_CMA_HEAP=y -CONFIG_EXFAT_FS=y -CONFIG_EXT4_FS=y -CONFIG_F2FS_FS=y -# CONFIG_COMMON_CLK_DEBUG is not set # CONFIG_CLK_SUNXI is not set -# CONFIG_ARM_ARCH_TIMER_EVTSTREAM is not set -CONFIG_SUNXI_IOMMU=y -CONFIG_SUNXI_IOMMU_DEBUG=y -CONFIG_SUNXI_IOMMU_TESTS=y -CONFIG_SUNXI_SID=y +# CONFIG_SUN8I_A23_CCU is not set +# CONFIG_SUN8I_A33_CCU is not set +# CONFIG_SUN8I_A83T_CCU is not set +# CONFIG_SUN8I_H3_CCU is not set +# CONFIG_SUN8I_V3S_CCU is not set +# CONFIG_SUN8I_DE2_CCU is not set +# CONFIG_SUN8I_R40_CCU is not set +CONFIG_SUN20I_PPU=y +CONFIG_PHY_SUN4I_USB=y CONFIG_NVMEM_SUNXI_SID=y +CONFIG_EXT4_FS=y +CONFIG_F2FS_FS=y # CONFIG_DNOTIFY is not set CONFIG_OVERLAY_FS=y CONFIG_MSDOS_FS=y CONFIG_VFAT_FS=y +CONFIG_EXFAT_FS=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y CONFIG_UBIFS_FS=y @@ -222,21 +209,13 @@ CONFIG_CRYPTO_USER_API_HASH=y CONFIG_CRYPTO_USER_API_SKCIPHER=y CONFIG_CRYPTO_USER_API_RNG=y CONFIG_CRYPTO_USER_API_AEAD=y -CONFIG_CRYPTO_DEV_SUNXI=y +CONFIG_CRYPTO_DEV_SUN8I_CE=y +CONFIG_CRYPTO_DEV_SUN8I_CE_HASH=y +CONFIG_CRYPTO_DEV_SUN8I_CE_PRNG=y +CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG=y CONFIG_DMA_CMA=y CONFIG_PRINTK_TIME=y -CONFIG_DEBUG_INFO=y CONFIG_FRAME_WARN=2048 -CONFIG_DEBUG_FS=y CONFIG_MAGIC_SYSRQ=y -CONFIG_SLUB_DEBUG_ON=y -CONFIG_DEBUG_VM=y -# CONFIG_SCHED_DEBUG is not set -CONFIG_DEBUG_MUTEXES=y -CONFIG_STACKTRACE=y -# CONFIG_FTRACE is not set +CONFIG_DEBUG_FS=y CONFIG_ATOMIC64_SELFTEST=y -CONFIG_DEBUG_LL=y -CONFIG_DEBUG_UART_PHYS=0x02500000 -CONFIG_DEBUG_UART_VIRT=0xf2500000 -CONFIG_EARLY_PRINTK=y diff --git a/tp2bmc/board/tp2bmc/overlay/etc/init.d/S11bmc-otg b/tp2bmc/board/tp2bmc/overlay/etc/init.d/S11bmc-otg index d53b878b..5a3b4b43 100755 --- a/tp2bmc/board/tp2bmc/overlay/etc/init.d/S11bmc-otg +++ b/tp2bmc/board/tp2bmc/overlay/etc/init.d/S11bmc-otg @@ -39,9 +39,6 @@ setup_configuration() { mkdir -p configs/c.1/strings/0x409 echo "$name" > configs/c.1/strings/0x409/configuration ln -s functions/acm.usb0 configs/c.1 - - # enable udc, set the correct OTG role - echo usb_device > /sys/bus/platform/devices/soc@3000000:usbc0@0/otg_role > /dev/null 2>&1 } case "$1" in diff --git a/tp2bmc/board/tp2bmc/post_build.sh b/tp2bmc/board/tp2bmc/post_build.sh index bfec62cf..66f544a7 100755 --- a/tp2bmc/board/tp2bmc/post_build.sh +++ b/tp2bmc/board/tp2bmc/post_build.sh @@ -3,9 +3,7 @@ set -euo pipefail cd "${0%/*}" -FDT_FILENAME=$(basename $TARGET_DIR/boot/*.dtb) -sed s/FDT_FILENAME_HERE/${FDT_FILENAME}/g < boot.scr > /tmp/boot.scr -mkimage -A arm -T script -d /tmp/boot.scr $TARGET_DIR/boot/boot.scr.uimg +mkimage -A arm -T script -d boot.scr $TARGET_DIR/boot/boot.scr.uimg if [ -e ${TARGET_DIR}/etc/inittab ]; then grep -qE '^GS0::' ${TARGET_DIR}/etc/inittab || \ diff --git a/tp2bmc/board/tp2bmc/post_image.sh b/tp2bmc/board/tp2bmc/post_image.sh index 86a4ad0a..6035e152 100755 --- a/tp2bmc/board/tp2bmc/post_image.sh +++ b/tp2bmc/board/tp2bmc/post_image.sh @@ -12,9 +12,7 @@ INITRAMFS_DIR=$STAGING_DIR/initramfs/install # Prepare the SD image's FAT32 filesystem mkdir -p sdcard-bootpart/boot -FDT_FILENAME=$(basename $TARGET_DIR/boot/*.dtb) -sed s/FDT_FILENAME_HERE/${FDT_FILENAME}/g < $BOARD_DIR/install.scr > /tmp/install.scr -mkimage -A arm -T script -d /tmp/install.scr sdcard-bootpart/boot/boot.scr.uimg +mkimage -A arm -T script -d $BOARD_DIR/install.scr sdcard-bootpart/boot/boot.scr.uimg mkimage -A arm -T ramdisk -d installer.cpio.gz sdcard-bootpart/boot/install.img cp -r $BOARD_DIR/sdcard_overlay/* sdcard-bootpart/ diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts index b273c30f..53275338 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts @@ -1,19 +1,32 @@ // SPDX-License-Identifier: GPL-2.0+ -// Copyright (C) 2023 Sam Edwards +// Copyright (C) 2023-2024 Sam Edwards /dts-v1/; +#ifdef __ASSEMBLY__ +#define IS_UBOOT +#endif + +#ifdef IS_UBOOT #include "sun8i-t113s.dtsi" +#else +#include "allwinner/sun8i-t113s.dtsi" +#endif #include #include / { - model = "Turing Machines Turing Pi 2 BMC"; - compatible = "turingmachines,tp2bmc", "allwinner,sun8i-t113s", "allwinner,r528"; + model = "Turing Pi 2"; + compatible = "turing,pi2", "allwinner,sun8i-t113s"; aliases { ethernet0 = &emac; + serial1 = &uart1; + serial2 = &uart2; serial3 = &uart3; + serial4 = &uart4; + serial5 = &uart5; + flash0 = &flash0; }; chosen { @@ -24,42 +37,72 @@ leds { compatible = "gpio-leds"; - sys { - label = "fp:sys"; + led-0 { + label = "fp::power"; gpios = <&pio 6 8 GPIO_ACTIVE_LOW>; /* PG8 */ }; - reset { - label = "fp:reset"; + led-1 { + label = "fp::status"; gpios = <&pio 6 9 GPIO_ACTIVE_LOW>; /* PG9 */ }; }; - // The keys are also GPIO lines. keys { compatible = "gpio-keys"; // Part of the front-panel connector - power { + button-power { label = "fp:power"; linux,code = ; gpios = <&pio 6 10 GPIO_ACTIVE_HIGH>; /* PG10 */ }; - reset { + button-reset { label = "fp:reset"; linux,code = ; gpios = <&pio 6 11 GPIO_ACTIVE_HIGH>; /* PG11 */ }; // Located on the board itself - key1 { + key-1 { label = "key1"; linux,code = ; gpios = <&pio 6 15 GPIO_ACTIVE_LOW>; /* PG15 */ }; }; + reg_atx_5vsb: regulator-5v { + compatible = "regulator-fixed"; + regulator-name = "atx-5vsb"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + reg_3v3: regulator-3v3 { + compatible = "regulator-fixed"; + regulator-name = "vcc-3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <®_atx_5vsb>; + }; + + reg_1v8: regulator-1v8 { + compatible = "regulator-fixed"; + regulator-name = "vcc-1v8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <®_atx_5vsb>; + }; + + reg_vcc_core: regulator-core { + compatible = "regulator-fixed"; + regulator-name = "vcc-core"; + regulator-min-microvolt = <880000>; + regulator-max-microvolt = <880000>; + vin-supply = <®_atx_5vsb>; + }; }; &dcxo { @@ -67,33 +110,80 @@ }; &cpu0 { - //cpu-supply = <®_vcc_core>; + clock-frequency = <1008000000>; + cpu-supply = <®_vcc_core>; }; &cpu1 { - //cpu-supply = <®_vcc_core>; + clock-frequency = <1008000000>; + cpu-supply = <®_vcc_core>; }; &pio { - i2c2_pe_pins: i2c2-pe-pins { + vcc-pb-supply = <®_3v3>; + vcc-pc-supply = <®_3v3>; + vcc-pd-supply = <®_1v8>; + vcc-pe-supply = <®_3v3>; + vcc-pf-supply = <®_3v3>; + vcc-pg-supply = <®_3v3>; + + i2c2_pe12_pins: i2c2-pe12-pins { pins = "PE12", "PE13"; function = "i2c2"; drive-strength = <10>; }; + + uart2_pd_pins: uart2-pd-pins { + pins = "PD1", "PD2"; + function = "uart2"; + bias-pull-up; + }; + + uart4_pb_pins: uart4-pb-pins { + pins = "PB2", "PB3"; + function = "uart4"; + bias-pull-up; + }; + + uart5_pb_pins: uart5-pb-pins { + pins = "PB4", "PB5"; + function = "uart5"; + bias-pull-up; + }; }; &mmc0 { status = "okay"; + vmmc-supply = <®_3v3>; pinctrl-names = "default"; pinctrl-0 = <&mmc0_pins>; bus-width = <4>; cd-gpios = <&pio 5 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PF6 */ - cd-used-24M; - cap-sd-highspeed; no-sdio; - no-mmc; +}; + +&uart1_pg6_pins { + bias-pull-up; +}; + +&uart1 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&uart1_pg6_pins>; +}; + +&uart2 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&uart2_pd_pins>; +}; + +&uart3_pb_pins { + bias-pull-up; }; &uart3 { @@ -103,11 +193,36 @@ pinctrl-0 = <&uart3_pb_pins>; }; +&uart4 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&uart4_pb_pins>; +}; + +&uart5 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&uart5_pb_pins>; +}; + &i2c2 { status = "okay"; pinctrl-names = "default"; - pinctrl-0 = <&i2c2_pe_pins>; + pinctrl-0 = <&i2c2_pe12_pins>; + + clock-frequency = <100000>; + + eeprom@50 { + compatible = "microchip,24c02", "atmel,24c02"; + reg = <0x50>; + + vcc-supply = <®_3v3>; + + pagesize = <16>; + }; }; &emac { @@ -118,30 +233,38 @@ phy-handle = <&rtl8201f>; phy-mode = "rmii"; + phy-supply = <®_3v3>; allwinner,tx-delay-ps = <300>; allwinner,rx-delay-ps = <0>; - phy-rst = <&pio 4 10 GPIO_ACTIVE_HIGH>; /* PE10 */ }; &mdio { rtl8201f: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; reg = <0>; + reset-gpios = <&pio 4 10 GPIO_ACTIVE_LOW>; /* PE10 */ }; }; +&spi0_pins { + pins = "PC2", "PC3", "PC4", "PC5", "PC6", "PC7"; +}; + &spi0 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi0_pins>; - spi-nand@0 { + flash0: flash@0 { compatible = "spi-nand"; reg = <0x0>; spi-max-frequency=<80000000>; - //spi-rx-bus-width=<4>; - //spi-tx-bus-width=<4>; +#ifndef IS_UBOOT + spi-rx-bus-width=<4>; + spi-tx-bus-width=<4>; +#endif partitions { compatible = "fixed-partitions"; @@ -163,9 +286,22 @@ }; &usb_otg { + dr_mode = "peripheral"; + status = "okay"; +}; + +&ehci1 { + status = "okay"; +}; + +&ohci1 { status = "okay"; }; &usbphy { status = "okay"; }; + +&wdt { + status = "okay"; +}; diff --git a/tp2bmc/board/tp2bmc/sun8iw20p1-t113-turingmachines-tp2bmc.dts b/tp2bmc/board/tp2bmc/sun8iw20p1-t113-turingmachines-tp2bmc.dts deleted file mode 100644 index 6ee71377..00000000 --- a/tp2bmc/board/tp2bmc/sun8iw20p1-t113-turingmachines-tp2bmc.dts +++ /dev/null @@ -1,747 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2023 Sam Edwards - -/dts-v1/; - -#include "sun8iw20p1.dtsi" -#include - -/{ - model = "Turing Machines Turing Pi 2 BMC"; - compatible = "turingmachines,tp2bmc", "allwinner,r528", "arm,sun8iw20p1"; - - // `sun8iw20p1.dtsi` adds these, but they should be added by the - // bootloader as needed, not at compile-time - /delete-node/ firmware; - /delete-node/ psci; - - aliases { - flash_partitions = &flash_partitions; - }; - - // The i2c-sunxi driver does not currently support NOSTART - // transactions, which are necessary to support the RTL8370MB's Realtek - // mode, so GPIO mode is used instead for now. This can be removed once - // NOSTART support is added to i2c-sunxi. - i2c_gpio: i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - - status = "disabled"; - compatible = "i2c-gpio"; - - sda-gpios = <&pio PE 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - scl-gpios = <&pio PE 12 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - i2c-gpio,delay-us = <2>; /* 100 KHz */ - }; - - // The LEDs are actually GPIO lines that go to the front-panel LEDs. - // This is currently disabled; userspace wants to manage the GPIOs - // directly for now. - leds { - compatible = "gpio-leds"; - - sys { - label = "fp:sys"; - gpios = <&pio PG 8 GPIO_ACTIVE_LOW>; - }; - - reset { - label = "fp:reset"; - gpios = <&pio PG 9 GPIO_ACTIVE_LOW>; - }; - }; - - // The keys are also GPIO lines. - // This is also disabled, for the same reason as above. - keys { - compatible = "gpio-keys"; - - // Part of the front-panel connector - power { - label = "fp:power"; - linux,code = ; - gpios = <&pio PG 10 GPIO_ACTIVE_HIGH>; - }; - - reset { - label = "fp:reset"; - linux,code = ; - gpios = <&pio PG 11 GPIO_ACTIVE_HIGH>; - }; - - // Located on the board itself - key1 { - label = "key1"; - linux,code = ; - gpios = <&pio PG 15 GPIO_ACTIVE_LOW>; - }; - - }; - - // Node-management GPIOs (x4) - // - // This node is intended to be bound to the Linux GPIO Aggregator - // driver - nodes { - compatible = "turingmachines,tp2-nodes"; - - gpios = <&pio PD 11 GPIO_ACTIVE_LOW>, /* node 1 */ - <&pio PD 0 GPIO_ACTIVE_LOW>, - <&pio PD 19 GPIO_ACTIVE_HIGH>, - <&pio PD 15 GPIO_ACTIVE_LOW>, - <&pio PD 10 GPIO_ACTIVE_LOW>, /* node 2 */ - <&pio PD 20 GPIO_ACTIVE_LOW>, - <&pio PD 18 GPIO_ACTIVE_HIGH>, - <&pio PD 14 GPIO_ACTIVE_LOW>, - <&pio PD 9 GPIO_ACTIVE_LOW>, /* node 3 */ - <&pio PD 21 GPIO_ACTIVE_LOW>, - <&pio PD 17 GPIO_ACTIVE_HIGH>, - <&pio PD 12 GPIO_ACTIVE_LOW>, - <&pio PD 8 GPIO_ACTIVE_LOW>, /* node 4 */ - <&pio PD 22 GPIO_ACTIVE_LOW>, - <&pio PD 16 GPIO_ACTIVE_HIGH>, - <&pio PD 13 GPIO_ACTIVE_LOW>; - - gpio-line-names = "node1-en", "node1-rst", - "node1-usbotg-dev", "node1-rpiboot", - "node2-en", "node2-rst", - "node2-usbotg-dev", "node2-rpiboot", - "node3-en", "node3-rst", - "node3-usbotg-dev", "node3-rpiboot", - "node4-en", "node4-rst", - "node4-usbotg-dev", "node4-rpiboot"; - }; - - // Voltage regulators (there are 7 main ones): - // - ATX PSU: - // - Node 1 VRM - // - Node 2 VRM - // - Node 3 VRM - // - Node 4 VRM - - // USB power supplies for: - // - External USB 5v supply - // - On-board micro-B OTG port - reg_atx: atx-vbus { - compatible = "regulator-fixed"; - - regulator-name = "atx-vbus"; - regulator-min-microvolt = <12000000>; - regulator-max-microvolt = <12000000>; - startup-delay-us = <250000>; - - gpio = <&pio PD 3 GPIO_ACTIVE_HIGH>; - enable-active-high; - }; - - reg_vrm1: vrm1-vbus { - compatible = "regulator-fixed"; - - regulator-name = "vrm1-vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - startup-delay-us = <100000>; - - enable-active-high; - gpio = <&pio PD 7 GPIO_ACTIVE_HIGH>; - - vin-supply = <®_atx>; - }; - - node1-power { - compatible = "regulator-output"; - vout-supply = <®_vrm1>; - }; - - reg_vrm2: vrm2-vbus { - compatible = "regulator-fixed"; - - regulator-name = "vrm2-vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - startup-delay-us = <100000>; - - enable-active-high; - gpio = <&pio PD 6 GPIO_ACTIVE_HIGH>; - - vin-supply = <®_atx>; - }; - - node2-power { - compatible = "regulator-output"; - vout-supply = <®_vrm2>; - }; - - reg_vrm3: vrm3-vbus { - compatible = "regulator-fixed"; - - regulator-name = "vrm3-vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - startup-delay-us = <100000>; - - enable-active-high; - gpio = <&pio PD 5 GPIO_ACTIVE_HIGH>; - - vin-supply = <®_atx>; - }; - - node3-power { - compatible = "regulator-output"; - vout-supply = <®_vrm3>; - }; - - reg_vrm4: vrm4-vbus { - compatible = "regulator-fixed"; - - regulator-name = "vrm4-vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - startup-delay-us = <100000>; - - enable-active-high; - gpio = <&pio PD 4 GPIO_ACTIVE_HIGH>; - - vin-supply = <®_atx>; - }; - - node4-power { - compatible = "regulator-output"; - vout-supply = <®_vrm4>; - }; - - reg_usb_port_vbus: usb-port-vbus { - compatible = "regulator-fixed"; - - regulator-name = "usb-port-vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - startup-delay-us = <50000>; - - gpio = <&pio PG 4 GPIO_ACTIVE_LOW>; - }; - - usb-port-power { - compatible = "regulator-output"; - vout-supply = <®_usb_port_vbus>; - }; - - reg_otg_vbus: otg-vbus { - compatible = "regulator-fixed"; - - regulator-name = "usb-otg"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - startup-delay-us = <50000>; - - gpio = <&pio PG 12 GPIO_ACTIVE_LOW>; - }; -}; - -/* --- Pin controller --- */ -&pio { - /* SDMMC Controller 0: microSD slot */ - sdc0_pins_a: sdc0@0 { - allwinner,pins = "PF0", "PF1", "PF2", - "PF3", "PF4", "PF5"; - allwinner,function = "sdc0"; - allwinner,muxsel = <2>; - allwinner,drive = <3>; - allwinner,pull = <1>; - pins = "PF0", "PF1", "PF2", - "PF3", "PF4", "PF5"; - function = "sdc0"; - drive-strength = <30>; - bias-pull-up; - power-source = <3300>; - }; - - sdc0_pins_b: sdc0@1 { - pins = "PF0", "PF1", "PF2", - "PF3", "PF4", "PF5"; - function = "sdc0"; - drive-strength = <30>; - bias-pull-up; - power-source = <1800>; - }; - - sdc0_pins_c: sdc0@2 { - pins = "PF0", "PF1", "PF2", - "PF3", "PF4", "PF5"; - function = "gpio_in"; - }; - - - - /* SDMMC Controller 2: SPI-NAND, for boot control */ - sdc2_pins_a: sdc2@0 { - allwinner,pins = "PC2", "PC3", "PC4", - "PC5", "PC6", "PC7"; - allwinner,function = "sdc2"; - allwinner,muxsel = <3>; - allwinner,drive = <3>; - allwinner,pull = <1>; - pins = "PC2", "PC3", "PC4", - "PC5", "PC6", "PC7"; - function = "sdc2"; - drive-strength = <30>; - bias-pull-up; - }; - - - - /* UARTs, as follows: - * UART0: Unused - * UART1: Node 2 - * UART2: Node 1 - * UART3: BMC console - * UART4: Node 3 - * UART5: Node 4 - */ - uart1_pins_a: uart1_pins@0 { - pins = "PG6", "PG7"; - function = "uart1"; - drive-strength = <10>; - bias-pull-up; - }; - - uart1_pins_b: uart1_pins { - pins = "PG6", "PG7"; - function = "gpio_in"; - }; - - uart2_pins_a: uart2_pins@0 { - pins = "PD1", "PD2"; - function = "uart2"; - drive-strength = <10>; - bias-pull-up; - }; - - uart2_pins_b: uart2_pins@1 { - pins = "PD1", "PD2"; - function = "gpio_in"; - }; - - uart3_pins_a: uart3_pins@0 { - pins = "PB6", "PB7"; - function = "uart3"; - drive-strength = <10>; - bias-pull-up; - }; - - uart3_pins_b: uart3_pins@1 { - pins = "PB6", "PB7"; - function = "gpio_in"; - }; - - uart4_pins_a: uart4_pins@0 { - pins = "PB2", "PB3"; - function = "uart4"; - drive-strength = <10>; - bias-pull-up; - }; - - uart4_pins_b: uart4_pins@1 { - pins = "PB2", "PB3"; - function = "gpio_in"; - }; - - uart5_pins_a: uart5_pins@0 { - pins = "PB4", "PB5"; - function = "uart5"; - drive-strength = <10>; - bias-pull-up; - }; - - uart5_pins_b: uart5_pins@1 { - pins = "PB4", "PB5"; - function = "gpio_in"; - }; - - - - /* TWI Controller 2: 24C02 and RTL8370MB-CG */ - twi2_pins_a: twi2@0 { - pins = "PE12", "PE13"; - function = "twi2"; - drive-strength = <10>; - }; - - twi2_pins_b: twi2@1 { - pins = "PE12", "PE13"; - function = "gpio_in"; - }; - - - - /* Ethernet MAC: RTL8201F in RMII mode */ - gmac0_pins_a: gmac@0 { - allwinner,pins = "PE0", "PE1", "PE2", "PE3", "PE4", - "PE5", "PE6", "PE7","PE8", "PE9"; - allwinner,function = "gmac0"; - allwinner,muxsel = <8>; - allwinner,drive = <1>; - allwinner,pull = <0>; - }; - - gmac0_pins_b: gmac@1 { - allwinner,pins = "PE0", "PE1", "PE2", "PE3", "PE4", - "PE5", "PE6", "PE7","PE8", "PE9"; - allwinner,function = "gpio_in"; - allwinner,muxsel = <0>; - allwinner,drive = <1>; - allwinner,pull = <0>; - }; - - - - /* SPI Controller 0: NAND flash */ - spi0_pins_a: spi0@0 { - pins = "PC2", "PC4", "PC5","PC7", "PC6"; - function = "spi0"; - drive-strength = <10>; - }; - - spi0_pins_b: spi0@1 { - pins = "PC3"; - function = "spi0"; - drive-strength = <10>; - bias-pull-up; /* only CS should be pulled up */ - }; - - spi0_pins_c: spi0@2 { - pins = "PC2", "PC3", "PC4", "PC5","PC6", "PC7"; - function = "gpio_in"; - drive-strength = <10>; - }; -}; - - - -/* --- SDMMC --- */ -&sdc0 { - status = "okay"; - - pinctrl-names = "default", "mmc_1v8", "sleep"; - pinctrl-0 = <&sdc0_pins_a>; - pinctrl-1 = <&sdc0_pins_b>; - pinctrl-2 = <&sdc0_pins_c>; - pinctrl-3; - - bus-width = <4>; - cd-gpios = <&pio PF 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; - cd-used-24M; - cap-sd-highspeed; - no-sdio; - no-mmc; - sunxi-power-save-mode; - max-frequency = <150000000>; - ctl-spec-caps = <0x8>; -}; - - - -/* --- UARTs --- */ -&uart1 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&uart1_pins_a>; - pinctrl-1 = <&uart1_pins_b>; -}; - -&uart2 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&uart2_pins_a>; - pinctrl-1 = <&uart2_pins_b>; -}; - -&uart3 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&uart3_pins_a>; - pinctrl-1 = <&uart3_pins_b>; -}; - -&uart4 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&uart4_pins_a>; - pinctrl-1 = <&uart4_pins_b>; -}; - -&uart5 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&uart5_pins_a>; - pinctrl-1 = <&uart5_pins_b>; -}; - - - -/* --- TWI --- */ -&twi2 { - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&twi2_pins_a>; - pinctrl-1 = <&twi2_pins_b>; - -#if 1 - status = "disabled"; -}; - -&i2c_gpio { -#endif - - status = "okay"; - - clock-frequency = <100000>; // RTL8370MB-CG not rated for 400KHz - - /* - * The TP2 board design includes a 4-pin fan header (J16) and - * SMBus-compatible fan speed controller (U109). They are not populated - * on current production boards, but some users may choose to solder - * a Molex 47053-1000 and Microchip EMC2301, respectively, to gain this - * functionality. This node is here to enable probing for the EMC2301 - * on boot, even though most boards lack it. - */ - hwmon@2f { - status = "okay"; - compatible = "microchip,emc2301"; - reg = <0x2f>; - }; - - eeprom@50 { - status = "okay"; - compatible = "atmel,24c02"; - reg = <0x50>; - - pagesize = <16>; - }; - - switch@5c { - status = "okay"; - compatible = "realtek,rtl83xx-i2c"; // This is made up. - reg = <0x5C>; - - realtek,i2c-mode = "realtek"; - }; -}; - - - -/* --- Ethernet --- */ -&gmac0 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&gmac0_pins_a>; - pinctrl-1 = <&gmac0_pins_b>; - - phy-mode = "rmii"; - use_ephy25m = <0>; - tx-delay = <3>; - rx-delay = <0>; - phy-rst = <&pio PE 10 GPIO_ACTIVE_HIGH>; -}; - - - -/* --- SPI --- */ -&spi0 { - status = "okay"; - - pinctrl-names = "default", "sleep"; - pinctrl-0 = <&spi0_pins_a &spi0_pins_b>; - pinctrl-1 = <&spi0_pins_c>; - - clock-frequency = <100000000>; - spi_slave_mode = <0>; - spi0_cs_number = <1>; - spi0_cs_bitmap = <1>; - - spi-nand@0 { - compatible = "spi-nand"; - reg = <0x0>; - - spi-max-frequency=<80000000>; - spi-rx-bus-width=<0x04>; - spi-tx-bus-width=<0x04>; - - flash_partitions: partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "boot"; - reg = <0x00000000 0x00100000>; - read-only; - }; - - partition@100000 { - label = "ubi"; - reg = <0x00100000 0x07f00000>; - }; - }; - }; -}; - - - -&soc { - platform@45000004 { - reg = <0x0 0x45000004 0x0 0x0>; - eraseflag = <1>; - next_work = <3>; - debug_mode = <8>; - }; - - target@45000008 { - reg = <0x0 0x45000008 0x0 0x0>; - boot_clock = <1008>; /*CPU boot frequency, Unit: MHz*/ - storage_type = <0xffffffff>; /*boot medium, 0-nand, 1-card0, 2-card2, -1(defualt)auto scan*/ - burn_key = <0>; /*1:support burn key; 0:not support burn key*/ - dragonboard_test = <0>; /*1:support card boot dragonboard; 0:not support card boot dragonboard*/ - }; - - card0_boot_para@2 { - /* - * Avoid dtc compiling warnings. - * @TODO: Developer should modify this to the actual value - */ - reg = <0x0 0x2 0x0 0x0>; - device_type = "card0_boot_para"; - card_ctrl = <0x0>; - card_high_speed = <0x1>; - card_line = <0x4>; - pinctrl-0 = <&sdc0_pins_a>; - }; - - card2_boot_para@3 { - /* - * Avoid dtc compiling warnings. - * @TODO: Developer should modify this to the actual value - */ - reg = <0x0 0x3 0x0 0x0>; - device_type = "card2_boot_para"; - card_ctrl = <0x2>; - card_high_speed = <0x1>; - card_line = <0x4>; - pinctrl-0 = <&sdc2_pins_a>; - /*pinctrl-0 = <&sdc0_pins_a>;*/ - /*sdc_ex_dly_used = <0x2>;*/ - sdc_io_1v8 = <0x1>; - /*sdc_type = "tm4";*/ - sdc_tm4_hs200_max_freq = <150>; - sdc_tm4_hs400_max_freq = <100>; - sdc_ex_dly_used = <2>; - /*sdc_tm4_win_th = <8>;*/ - /*sdc_dis_host_caps = <0x180>;*/ - }; -}; - - - -/* --- USB --- */ - -/* - *usb_port_type: usb mode. 0-device, 1-host, 2-otg. - *usb_detect_type: usb hotplug detect mode. 0-none, 1-vbus/id detect, 2-id/dpdm detect. - *usb_detect_mode: 0-thread scan, 1-id gpio interrupt. - *usb_id_gpio: gpio for id detect. - *usb_det_vbus_gpio: gpio for id detect. gpio or "axp_ctrl"; - *usb_wakeup_suspend:0-SUPER_STANDBY, 1-USB_STANDBY. - */ -&usbc0 { - status = "okay"; - - device_type = "usbc0"; - usb_port_type = <0x2>; - usb_detect_type = <0x1>; - usb_detect_mode = <0>; - usb_wakeup_suspend = <0>; - usb_serial_unique = <0>; - usb_serial_number = "20080411"; - rndis_wceis = <1>; -}; - -&ehci0 { - status = "okay"; - - drvvbus-supply = <®_otg_vbus>; -}; - -&ohci0 { - status = "okay"; - - drvvbus-supply = <®_otg_vbus>; -}; - -&usbc1 { - status = "okay"; - - device_type = "usbc1"; - usb_port_type = <0x1>; - sb_detect_type = <0x1>; - usb_regulator_io = "nocare"; - usb_wakeup_suspend = <0>; -}; - -&ehci1 { - status = "okay"; -}; - -&ohci1 { - status = "okay"; -}; - - - -/* --- Disable unused peripherals --- */ -&sdc1 { - status = "disabled"; - pinctrl-0; - pinctrl-1; -}; -&sdc2 { - status = "disabled"; - pinctrl-0; - pinctrl-1; -}; -#define DISABLE_DEV(dev) \ -&dev { \ - status = "disabled"; \ -} -DISABLE_DEV(rtp); -DISABLE_DEV(ve); -DISABLE_DEV(pwm); -DISABLE_DEV(pwm0); -DISABLE_DEV(pwm1); -DISABLE_DEV(pwm2); -DISABLE_DEV(pwm3); -DISABLE_DEV(pwm4); -DISABLE_DEV(pwm5); -DISABLE_DEV(pwm6); -DISABLE_DEV(pwm7); -DISABLE_DEV(lcd_fb0); -DISABLE_DEV(keyboard0); -DISABLE_DEV(gpadc); -DISABLE_DEV(vind0); -DISABLE_DEV(di); -DISABLE_DEV(g2d); -DISABLE_DEV(disp); -DISABLE_DEV(lcd0); -DISABLE_DEV(tv0); -DISABLE_DEV(hdmi); -DISABLE_DEV(codec); -DISABLE_DEV(dummy_cpudai); -DISABLE_DEV(sndcodec); -DISABLE_DEV(dmic_codec); -DISABLE_DEV(tvd); -DISABLE_DEV(tvd0); diff --git a/tp2bmc/board/tp2bmc/sun8iw20p1.dtsi b/tp2bmc/board/tp2bmc/sun8iw20p1.dtsi deleted file mode 100644 index 9a352aad..00000000 --- a/tp2bmc/board/tp2bmc/sun8iw20p1.dtsi +++ /dev/null @@ -1,1967 +0,0 @@ -/* - * Allwinner Technology CO., Ltd. sun8iw20p1 platform - * - * modify base on juno.dts - */ - /* optee used 7MB: SHM 2M: OS: 1M: TA:4M*/ -/memreserve/ 0x41900000 0x00700000; -/* DSP used 1MB */ -/memreserve/ 0x42000000 0x00100000; -/* DSP ARM share space 64K */ -/memreserve/ 0x42100000 0x00010000; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/ { - model = "sun8iw20"; - compatible = "allwinner,sun8iw20p1"; - interrupt-parent = <&gic>; - #address-cells = <2>; - #size-cells = <2>; - - aliases { - serial0 = &uart0; - serial1 = &uart1; - serial2 = &uart2; - serial3 = &uart3; - serial4 = &uart4; - serial5 = &uart5; - spi0 = &spi0; - spi1 = &spi1; - twi0 = &twi0; - twi1 = &twi1; - twi2 = &twi2; - twi3 = &twi3; - mmc0 = &sdc0; - mmc2 = &sdc2; - pwm = &pwm; - pwm0 = &pwm0; - pwm1 = &pwm1; - pwm2 = &pwm2; - pwm3 = &pwm3; - pwm4 = &pwm4; - pwm5 = &pwm5; - pwm6 = &pwm6; - pwm7 = &pwm7; - ir0 = &s_cir0; - tv0 = &tv0; - tvd = &tvd; - tvd0 = &tvd0; - share_space0 = &share_space0; - gmac0 = &gmac0; - }; - - chosen { - bootargs = "earlyprintk=sunxi-uart,0x2500000 loglevel=3 initcall_debug=0 console=ttyS0 init=/init"; - //bootargs = "loglevel=8 initcall_debug=0 console=ttyS0 init=/init"; - linux,initrd-start = <0x0 0x0>; - linux,initrd-end = <0x0 0x0>; - }; - - firmware { - optee { - compatible = "linaro,optee-tz"; - method = "smc"; - }; - }; - - cpus { - enable-method = "allwinner,sun8iw20p1"; - #address-cells = <1>; - #size-cells = <0>; - - cpu0: cpu@0 { - device_type = "cpu"; - compatible = "arm,cortex-a7","arm,armv7"; - reg = <0x0>; - enable-method = "psci"; - clocks = <&ccu CLK_CPUX>; - dynamic-power-coefficient = <156>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; - operating-points-v2 = <&cpu_opp_table>; - #cooling-cells = <2>; - }; - - cpu1: cpu@1 { - device_type = "cpu"; - compatible = "arm,cortex-a7","arm,armv7"; - reg = <0x1>; - enable-method = "psci"; - clocks = <&ccu CLK_CPUX>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; - operating-points-v2 = <&cpu_opp_table>; - #cooling-cells = <2>; - }; - - idle-states { - entry-method = "arm,psci"; - - CPU_SLEEP: cpu-sleep { - compatible = "arm,idle-state"; - arm,psci-suspend-param = <0x0010000>; - entry-latency-us = <46>; - exit-latency-us = <59>; - min-residency-us = <3570>; - local-timer-stop; - }; - - CLUSTER_SLEEP: cluster-sleep { - compatible = "arm,idle-state"; - arm,psci-suspend-param = <0x1010000>; - entry-latency-us = <47>; - exit-latency-us = <74>; - min-residency-us = <5000>; - local-timer-stop; - }; - }; - - }; - - psci { - compatible = "arm,psci-1.0"; - method = "smc"; - }; - - dump_reg: dump_reg@20000 { - compatible = "allwinner,sunxi-dump-reg"; - reg = <0x0 0x00020000 0x0 0x0004>; - /* 0x00020000: dump_reg test addr, 0x0004: dump_reg test size */ - }; - - cpu_opp_table: cpu-opp-table { - compatible = "allwinner,sun50i-operating-points"; - nvmem-cells = <&vf_table>; - nvmem-cell-names = "speed"; - opp-shared; - - opp@480000000 { - opp-hz = /bits/ 64 <480000000>; - clock-latency-ns = <244144>; /* 8 32k periods */ - opp-microvolt-a0 = <950000>; - }; - - opp@720000000 { - opp-hz = /bits/ 64 <720000000>; - clock-latency-ns = <244144>; /* 8 32k periods */ - opp-microvolt-a0 = <950000>; - }; - - opp@912000000 { - opp-hz = /bits/ 64 <912000000>; - clock-latency-ns = <244144>; /* 8 32k periods */ - opp-microvolt-a0 = <950000>; - }; - - opp@1008000000 { - opp-hz = /bits/ 64 <1008000000>; - clock-latency-ns = <244144>; /* 8 32k periods */ - opp-microvolt-a0 = <950000>; - }; - - opp@1104000000 { - opp-hz = /bits/ 64 <1104000000>; - clock-latency-ns = <244144>; /* 8 32k periods */ - opp-microvolt-a0 = <950000>; - }; - }; - - - dcxo24M: dcxo24M_clk { - #clock-cells = <0>; - compatible = "fixed-clock"; - clock-frequency = <24000000>; - clock-output-names = "dcxo24M"; - }; - - rc_16m: rc16m_clk { - #clock-cells = <0>; - compatible = "fixed-clock"; - clock-frequency = <16000000>; - clock-accuracy = <300000000>; - clock-output-names = "rc-16m"; - }; - - ext_32k: ext32k_clk { - #clock-cells = <0>; - compatible = "fixed-clock"; - clock-frequency = <32768>; - clock-output-names = "ext-32k"; - }; - - dram: dram { - compatible = "allwinner,dram"; - clocks = <&ccu CLK_PLL_DDR0>; - clock-names = "pll_ddr"; - }; - - memory@40000000 { - device_type = "memory"; - reg = <0x00000000 0x40000000 0x00000000 0x20000000>; - }; - - share_space0: share_space@0x42100000 { - #address-cells = <1>; - #size-cells = <1>; - deice_tpye = "share_space0"; - /* dsp write addr and len */ - /* arm write addr and len */ - /* dsp log addr and len */ - /* reserve */ - reg = < 0x42100000 0x00001000 - 0x42101000 0x00002000 - 0x42102000 0x0000E000 - 0x00000000 0x00000000>; - }; - - gic: interrupt-controller@3020000 { - compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic"; - #interrupt-cells = <3>; - #address-cells = <0>; - device_type = "gic"; - interrupt-controller; - reg = <0x0 0x03021000 0 0x1000>, /* GIC Dist */ - <0x0 0x03022000 0 0x2000>, /* GIC CPU */ - <0x0 0x03024000 0 0x2000>, /* GIC VCPU Control */ - <0x0 0x03026000 0 0x2000>; /* GIC VCPU */ - interrupts = ; /* GIC Maintenence IRQ */ - }; - - timer_arch { - compatible = "arm,armv7-timer"; - interrupts = , - , - , - ; - clock-frequency = <24000000>; - arm,cpu-registers-not-fw-configured; - interrupt-parent = <&gic>; - arm,no-tick-in-suspend; - }; - - pmu { - compatible = "arm,cortex-a7-pmu"; - interrupts = , - ; - }; - - power: power-management@ff000000 { - compatible = "allwinner,r528-pmu", "syscon", "simple-mfd"; - reg = <0x0 0x07001000 0x0 0x400>; - - pd: power-controller { - compatible = "allwinner,r528-power-controller"; - clocks = <&r_ccu CLK_R_PPU>; - clock-names = "ppu"; - resets = <&r_ccu RST_R_PPU>; - reset-names = "ppu_rst"; - #power-domain-cells = <1>; - #address-cells = <1>; - #size-cells = <0>; - - /* These power domains are grouped by VD_SYS */ - pd_ve@R528_PD_VE { - reg = ; - }; - }; - }; - - mmu_aw: iommu@2010000 { - compatible = "allwinner,sunxi-iommu"; - reg = <0x0 0x02010000 0x0 0x1000>; - interrupts = ; - interrupt-names = "iommu-irq"; - clocks = <&ccu CLK_BUS_IOMMU>; - clock-names = "iommu"; - #iommu-cells = <2>; - status = "okay"; - }; - - reg_pio1_8: pio-18 { - compatible = "regulator-fixed"; - regulator-name = "pio-18"; - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <1800000>; - }; - - reg_pio3_3: pio-33 { - compatible = "regulator-fixed"; - regulator-name = "pio-33"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - }; - - thermal-zones { - cpu_thermal_zone { - polling-delay-passive = <500>; - polling-delay = <1000>; - thermal-sensors = <&ths 0>; - sustainable-power = <589>; - - cpu_trips: trips { - cpu_threshold: trip-point@0 { - temperature = <70000>; - type = "passive"; - hysteresis = <0>; - }; - cpu_target: trip-point@1 { - temperature = <90000>; - type = "passive"; - hysteresis = <0>; - }; - cpu_crit: cpu_crit@0 { - temperature = <115000>; - type = "critical"; - hysteresis = <0>; - }; - }; - - cooling-maps { - map0 { - trip = <&cpu_target>; - cooling-device = <&cpu0 - THERMAL_NO_LIMIT - THERMAL_NO_LIMIT>; - contribution = <1024>; - }; - }; - }; - }; - - soc: soc@3000000 { - compatible = "simple-bus"; - #address-cells = <2>; - #size-cells = <2>; - ranges; - device_type = "soc"; - - sram_ctrl: sram_ctrl@3000000 { - compatible = "allwinner,sram_ctrl"; - reg = <0x0 0x3000000 0 0x16C>; - soc_ver { - offset = <0x24>; - mask = <0x7>; - shift = <0>; - ver_a = <0x18590000>; - ver_b = <0x18590002>; - }; - - soc_id { - offset = <0x200>; - mask = <0x1>; - shift = <22>; - }; - - soc_bin { - offset = <0x0>; - mask = <0x3ff>; - shift = <0x0>; - }; - - }; - - rtc_ccu: rtc_ccu@7090000 { - compatible = "allwinner,sun8iw20-rtc-ccu"; - device_type = "rtc-ccu"; - reg = <0x0 0x07090000 0x0 0x320>; /* The same as rtc */ - #clock-cells = <1>; - }; - - ccu: ccu@2001000 { - compatible = "allwinner,sun8iw20-ccu"; - reg = <0x0 0x02001000 0x0 0x1000>; - clocks = <&dcxo24M>, <&rtc_ccu CLK_OSC32K>, <&rtc_ccu CLK_IOSC>; - clock-names = "hosc", "losc", "iosc"; - #clock-cells = <1>; - #reset-cells = <1>; - }; - - r_ccu: r_ccu@7010000 { - compatible = "allwinner,sun8iw20-r-ccu"; - reg = <0x0 0x07010000 0x0 0x240>; - clocks = <&dcxo24M>, <&rtc_ccu CLK_OSC32K>, <&rtc_ccu CLK_IOSC>, - <&ccu CLK_PLL_PERIPH0>; - clock-names = "hosc", "losc", "iosc", "pll-periph0"; - #clock-cells = <1>; - #reset-cells = <1>; - }; - - rtc: rtc@7090000 { - compatible = "allwinner,sun8iw20-rtc"; - device_type = "rtc"; - wakeup-source; - reg = <0x0 0x07090000 0x0 0x320>; - interrupts = ; - clocks = <&r_ccu CLK_R_AHB_BUS_RTC>, <&rtc_ccu CLK_RTC_1K>, <&rtc_ccu CLK_RTC_SPI>; - clock-names = "r-ahb-rtc", "rtc-1k", "rtc-spi"; - resets = <&r_ccu RST_R_AHB_BUS_RTC>; - gpr_cur_pos = <6>; - }; - - dma:dma-controller@3002000 { - compatible = "allwinner,sun8iw20-dma"; - reg = <0x0 0x03002000 0x0 0x1000>; - interrupts = ; - clocks = <&ccu CLK_BUS_DMA>, <&ccu CLK_MBUS_DMA>; - clock-names = "bus", "mbus"; - dma-channels = <8>; - dma-requests = <48>; - resets = <&ccu RST_BUS_DMA>; - #dma-cells = <1>; - }; - - soc_timer0: timer@2050000 { - compatible = "allwinner,sun4i-a10-timer"; - device_type = "soc_timer"; - reg = <0x0 0x02050000 0x0 0xA0>; - interrupt-parent = <&gic>; - interrupts = ; - clocks = <&dcxo24M>; - }; - - wdt: watchdog@20500A0 { - compatible = "allwinner,sun6i-a31-wdt"; - reg = <0x0 0x020500A0 0x0 0x20>; /* In Timers Spec */ - interrupts = ; /* In GIC Spec */ - }; - - mbus0: mbus-controller@3102000 { - compatible = "allwinner,sun8i-mbus"; - reg = <0x0 0x03102000 0x0 0x1000>; /* In SDRAM Controller Spec: DRAMC Common Register */ - #mbus-cells = <1>; - }; - - pio: pinctrl@2000000 { - compatible = "allwinner,sun8iw20-pinctrl"; - reg = <0x0 0x02000000 0x0 0x500>; - interrupts = , /* AW1859_GIC_Spec: GPIOB: 101-32=69 */ - , - , - , - , - ; - device_type = "pio"; - clocks = <&ccu CLK_APB0>, <&dcxo24M>, <&rtc_ccu CLK_OSC32K>; - clock-names = "apb", "hosc", "losc"; - gpio-controller; - #gpio-cells = <3>; - interrupt-controller; - #interrupt-cells = <3>; - #size-cells = <0>; - vcc-pf-supply = <®_pio1_8>; - vcc-pfo-supply = <®_pio3_3>; - - test_pins_a: test_pins@0 { - allwinner,pins = "PB0", "PB1"; - allwinner,function = "test"; - allwinner,muxsel = <0x9>; - allwinner,drive = <1>; - allwinner,pull = <1>; - }; - test_pins_b: test_pins@1 { - pins = "PB0", "PB1"; - function = "io_disabled"; - allwinner,muxsel = <0xF>; - allwinner,drive = <1>; - allwinner,pull = <1>; - }; - - csi_mclk0_pins_a: csi_mclk0@0 { - pins = "PE3"; - function = "csi0"; - drive-strength = <10>; - }; - csi_mclk0_pins_b: csi_mclk0@1 { - pins = "PE3"; - function = "gpio_in"; - }; - csi0_pins_a: csi0@0 { - pins = "PE2", "PE0", "PE1", "PE4", "PE5", - "PE6", "PE7", "PE8", "PE9", "PE10", "PE11"; - function = "ncsi0"; - drive-strength = <10>; - }; - csi0_pins_b: csi0@1 { - pins = "PE2", "PE0", "PE1", "PE4", "PE5", - "PE6", "PE7", "PE8", "PE9", "PE10", "PE11"; - function = "io_disabled"; - drive-strength = <10>; - }; - - lvds0_pins_a: lvds0@0 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9"; - function = "lvds0"; - drive-strength = <30>; - bias-disable; - }; - - lvds0_pins_b: lvds0@1 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9"; - function = "io_disabled"; - drive-strength = <30>; - bias-disable; - }; - - rgb24_pins_a: rgb24@0 { - pins = "PB2", "PB3", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", \ - "PB4", "PB5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", \ - "PB6", "PB7", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", \ - "PD18", "PD19", "PD20", "PD21"; - function = "lcd0"; - drive-strength = <30>; - bias-disable; - }; - - rgb24_pins_b: rgb24@1 { - pins = "PB2", "PB3", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", \ - "PB4", "PB5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", \ - "PB6", "PB7", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", \ - "PD18", "PD19", "PD20", "PD21"; - function = "io_disabled"; - bias-disable; - }; - - rgb18_pins_a: rgb18@0 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", \ - "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", \ - "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", \ - "PD18", "PD19", "PD20", "PD21"; - function = "lcd0"; - drive-strength = <30>; - bias-disable; - }; - - rgb18_pins_b: rgb18@1 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", \ - "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", \ - "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", \ - "PD18", "PD19", "PD20", "PD21"; - function = "io_disabled"; - bias-disable; - }; - - dsi2lane_pins_a: dsi2lane@0 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5"; - function = "dsi"; - drive-strength = <30>; - bias-disable; - }; - - dsi2lane_pins_b: dsi2lane@1 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5"; - function = "io_disabled"; - bias-disable; - }; - - dsi4lane_pins_a: dsi4lane@0 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9"; - function = "dsi"; - drive-strength = <30>; - bias-disable; - }; - - dsi4lane_pins_b: dsi4lane@1 { - pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9"; - function = "io_disabled"; - bias-disable; - }; - - }; - - pinctrl_test: pinctrl_test@0 { - reg = <0x0 0x0 0x0 0x0>; - compatible = "allwinner,sunxi-pinctrl-test"; - device_type = "pinctrl-test"; - /* For pin state selecting test */ - pinctrl-0 = <&test_pins_a>; - pinctrl-1 = <&test_pins_b>; - pinctrl-names = "default", "sleep"; - /* For pin basic_function/irq test */ - test-gpios = <&pio PB 0 GPIO_ACTIVE_LOW>; - interrupt-parent = <&pio>; - interrupts = ; - }; - - uart0: uart@2500000 { - compatible = "allwinner,sun8i-uart"; - device_type = "uart0"; - reg = <0x0 0x02500000 0x0 0x400>; - interrupts = ; - sunxi,uart-fifosize = <64>; - clocks = <&ccu CLK_BUS_UART0>; - clock-names = "uart0"; - resets = <&ccu RST_BUS_UART0>; - uart0_port = <0>; - uart0_type = <2>; - status = "disabled"; - }; -#if 1 - uart1: uart@2500400 { - compatible = "allwinner,sun8i-uart"; - device_type = "uart1"; - reg = <0x0 0x02500400 0x0 0x400>; - interrupts = ; - sunxi,uart-fifosize = <256>; - clocks = <&ccu CLK_BUS_UART1>; - clock-names = "uart1"; - resets = <&ccu RST_BUS_UART1>; - uart1_port = <1>; - uart1_type = <4>; - status = "disabled"; /* modify by wenyi 0820*/ - }; -#endif - uart2: uart@2500800 { - compatible = "allwinner,sun8i-uart"; - device_type = "uart2"; - reg = <0x0 0x02500800 0x0 0x400>; - interrupts = ; - sunxi,uart-fifosize = <256>; - clocks = <&ccu CLK_BUS_UART2>; - clock-names = "uart2"; - resets = <&ccu RST_BUS_UART2>; - uart2_port = <2>; - uart2_type = <4>; - status = "disabled"; - }; - - uart3: uart@2500c00 { - compatible = "allwinner,sun8i-uart"; - device_type = "uart3"; - reg = <0x0 0x02500c00 0x0 0x400>; - interrupts = ; - sunxi,uart-fifosize = <256>; - clocks = <&ccu CLK_BUS_UART3>; - clock-names = "uart3"; - resets = <&ccu RST_BUS_UART3>; - uart3_port = <3>; - uart3_type = <4>; - status = "disabled"; - }; - - uart4: uart@2501000 { - compatible = "allwinner,sun8i-uart"; - device_type = "uart4"; - reg = <0x0 0x02501000 0x0 0x400>; - interrupts = ; - sunxi,uart-fifosize = <256>; - clocks = <&ccu CLK_BUS_UART4>; - clock-names = "uart4"; - resets = <&ccu RST_BUS_UART4>; - uart4_port = <4>; - uart4_type = <2>; - status = "disabled"; - }; - - uart5: uart@2501400 { - compatible = "allwinner,sun8i-uart"; - device_type = "uart5"; - reg = <0x0 0x02501400 0x0 0x400>; - interrupts = ; - sunxi,uart-fifosize = <256>; - clocks = <&ccu CLK_BUS_UART5>; - clock-names = "uart5"; - resets = <&ccu RST_BUS_UART5>; - uart5_port = <5>; - uart5_type = <2>; - status = "disabled"; - }; - cryptoengine: ce@03040000 { - compatible = "allwinner,sunxi-ce"; - device_name = "ce"; - reg = <0x0 0x03040000 0x0 0xa0>, /* non-secure space */ - <0x0 0x03040800 0x0 0xa0>; /* secure space */ - interrupts = , /*non-secure*/ - ; /* secure*/ - clock-frequency = <400000000>; /* 400MHz */ - clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>, <&ccu CLK_MBUS_CE>, - <&ccu CLK_PLL_PERIPH0_2X>; - clock-names = "bus_ce", "ce_clk", "mbus_ce", "pll_periph0_2x"; - resets = <&ccu RST_BUS_CE>; - status = "okay"; - }; - - gmac0: eth@4500000 { - compatible = "allwinner,sunxi-gmac"; - reg = <0x0 0x04500000 0x0 0x10000>, - <0x0 0x03000030 0x0 0x4>; - interrupts = ; - interrupt-names = "gmacirq"; - clocks = <&ccu CLK_BUS_EMAC0>, <&ccu CLK_EMAC0_25M>; - clock-names = "gmac", "ephy"; - resets = <&ccu RST_BUS_EMAC0>; - device_type = "gmac0"; - gmac-power0; - gmac-power1; - gmac-power2; - status = "disabled"; - }; - - sdc2: sdmmc@4022000 { - compatible = "allwinner,sunxi-mmc-v4p6x"; - device_type = "sdc2"; - reg = <0x0 0x04022000 0x0 0x1000>; - interrupts = ; - clocks = <&dcxo24M>, - <&ccu CLK_PLL_PERIPH0_2X>, - <&ccu CLK_MMC2>, - <&ccu CLK_BUS_MMC2>; - clock-names = "osc24m","pll_periph","mmc","ahb"; - resets = <&ccu RST_BUS_MMC2>; - reset-names = "rst"; - pinctrl-names = "default","sleep"; - pinctrl-0 = <&sdc2_pins_a>; - pinctrl-1 = <&sdc2_pins_b>; - bus-width = <4>; - req-page-count = <2>; - cap-mmc-highspeed; - cap-cmd23; - mmc-cache-ctrl; - non-removable; - /*max-frequency = <200000000>;*/ - max-frequency = <50000000>; - cap-erase; - mmc-high-capacity-erase-size; - no-sdio; - no-sd; - /*-- speed mode --*/ - /*sm0: DS26_SDR12*/ - /*sm1: HSSDR52_SDR25*/ - /*sm2: HSDDR52_DDR50*/ - /*sm3: HS200_SDR104*/ - /*sm4: HS400*/ - /*-- frequency point --*/ - /*f0: CLK_400K*/ - /*f1: CLK_25M*/ - /*f2: CLK_50M*/ - /*f3: CLK_100M*/ - /*f4: CLK_150M*/ - /*f5: CLK_200M*/ - - sdc_tm4_sm0_freq0 = <0>; - sdc_tm4_sm0_freq1 = <0>; - sdc_tm4_sm1_freq0 = <0x00000000>; - sdc_tm4_sm1_freq1 = <0>; - sdc_tm4_sm2_freq0 = <0x00000000>; - sdc_tm4_sm2_freq1 = <0>; - sdc_tm4_sm3_freq0 = <0x05000000>; - sdc_tm4_sm3_freq1 = <0x00000005>; - sdc_tm4_sm4_freq0 = <0x00050000>; - sdc_tm4_sm4_freq1 = <0x00000004>; - sdc_tm4_sm4_freq0_cmd = <0>; - sdc_tm4_sm4_freq1_cmd = <0>; - - /*vmmc-supply = <®_3p3v>;*/ - /*vqmc-supply = <®_3p3v>;*/ - /*vdmc-supply = <®_3p3v>;*/ - /*vmmc = "vcc-card";*/ - /*vqmc = "";*/ - /*vdmc = "";*/ - /*sunxi-power-save-mode;*/ - }; - - sdc0: sdmmc@4020000 { - compatible = "allwinner,sunxi-mmc-v5p3x"; - device_type = "sdc0"; - reg = <0x0 0x04020000 0x0 0x1000>; - interrupts = ; - clocks = <&dcxo24M>, - <&ccu CLK_PLL_PERIPH0_2X>, - <&ccu CLK_MMC0>, - <&ccu CLK_BUS_MMC0>; - clock-names = "osc24m","pll_periph","mmc","ahb"; - resets = <&ccu RST_BUS_MMC0>; - reset-names = "rst"; - pinctrl-names = "default","mmc_1v8","sleep","uart_jtag"; - pinctrl-0 = <&sdc0_pins_a>; - pinctrl-1 = <&sdc0_pins_b>; - pinctrl-2 = <&sdc0_pins_c>; - pinctrl-3 = <&sdc0_pins_d &sdc0_pins_e>; - max-frequency = <50000000>; - bus-width = <4>; - req-page-count = <2>; - /*non-removable;*/ - /*broken-cd;*/ - /*cd-inverted*/ - /*cd-gpios = <&pio PF 6 GPIO_ACTIVE_LOW>;*/ - /* vmmc-supply = <®_3p3v>;*/ - /* vqmc-supply = <®_3p3v>;*/ - /* vdmc-supply = <®_3p3v>;*/ - /*vmmc = "vcc-card";*/ - /*vqmc = "";*/ - /*vdmc = "";*/ - cap-sd-highspeed; - cap-wait-while-busy; - no-sdio; - no-mmc; - /*sd-uhs-sdr50;*/ - /*sd-uhs-ddr50;*/ - /*cap-sdio-irq;*/ - /*keep-power-in-suspend;*/ - /*ignore-pm-notify;*/ - /*sunxi-power-save-mode;*/ - /*sunxi-dly-400k = <1 0 0 0>; */ - /*sunxi-dly-26M = <1 0 0 0>;*/ - /*sunxi-dly-52M = <1 0 0 0>;*/ - /*sunxi-dly-52M-ddr4 = <1 0 0 0>;*/ - /*sunxi-dly-52M-ddr8 = <1 0 0 0>;*/ - /*sunxi-dly-104M = <1 0 0 0>;*/ - /*sunxi-dly-208M = <1 0 0 0>;*/ - /*sunxi-dly-104M-ddr = <1 0 0 0>;*/ - /*sunxi-dly-208M-ddr = <1 0 0 0>;*/ - }; - - sdc1: sdmmc@4021000 { - compatible = "allwinner,sunxi-mmc-v5p3x"; - device_type = "sdc1"; - reg = <0x0 0x04021000 0x0 0x1000>; - interrupts = ; - clocks = <&dcxo24M>, - <&ccu CLK_PLL_PERIPH0_2X>, - <&ccu CLK_MMC1>, - <&ccu CLK_BUS_MMC1>; - clock-names = "osc24m","pll_periph","mmc","ahb"; - resets = <&ccu RST_BUS_MMC1>; - reset-names = "rst"; - pinctrl-names = "default","sleep"; - pinctrl-0 = <&sdc1_pins_a>; - pinctrl-1 = <&sdc1_pins_b>; - max-frequency = <50000000>; - bus-width = <4>; - /*broken-cd;*/ - /*cd-inverted*/ - /*cd-gpios = <&pio PG 6 6 1 2 0>;*/ - /* vmmc-supply = <®_3p3v>;*/ - /* vqmc-supply = <®_3p3v>;*/ - /* vdmc-supply = <®_3p3v>;*/ - /*vmmc = "vcc-card";*/ - /*vqmc = "";*/ - /*vdmc = "";*/ - cap-sd-highspeed; - no-mmc; - /*sd-uhs-sdr50;*/ - /*sd-uhs-ddr50;*/ - /*sd-uhs-sdr104;*/ - /*cap-sdio-irq;*/ - keep-power-in-suspend; - /*ignore-pm-notify;*/ - /*sunxi-power-save-mode;*/ - /*sunxi-dly-400k = <1 0 0 0 0>; */ - /*sunxi-dly-26M = <1 0 0 0 0>;*/ - /*sunxi-dly-52M = <1 0 0 0 0>;*/ - sunxi-dly-52M-ddr4 = <1 0 0 0 2>; - /*sunxi-dly-52M-ddr8 = <1 0 0 0 0>;*/ - sunxi-dly-104M = <1 0 0 0 1>; - /*sunxi-dly-208M = <1 1 0 0 0>;*/ - sunxi-dly-208M = <1 0 0 0 1>; - /*sunxi-dly-104M-ddr = <1 0 0 0 0>;*/ - /*sunxi-dly-208M-ddr = <1 0 0 0 0>;*/ - - status = "disabled"; //modify by wenyi 0828 修改为disabled - }; - - rtp:rtp@2009c00 { - compatible = "allwinner,sun8i-ts"; - reg = <0x0 0x02009c00 0x0 0x400>; - clocks = <&ccu CLK_TPADC>, <&ccu CLK_BUS_TPADC>; - clock-names = "mod", "bus"; - clock-frequency = <1000000>; - resets = <&ccu RST_BUS_TPADC>; - interrupts = ; - }; - - spi0: spi@4025000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sun8i-spi"; - device_type = "spi0"; - reg = <0x0 0x04025000 0x0 0x1000>; - interrupts = ; - clocks = <&ccu CLK_PLL_PERIPH0>, <&ccu CLK_SPI0>, <&ccu CLK_BUS_SPI0>; - clock-names = "pll", "mod", "bus"; - resets = <&ccu RST_BUS_SPI0>; - clock-frequency = <100000000>; - spi0_cs_number = <1>; - spi0_cs_bitmap = <1>; - dmas = <&dma 22>, <&dma 22>; - dma-names = "tx", "rx"; - status = "disabled"; - }; - - spi1: spi@4026000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sun8i-spi"; - device_type = "spi1"; - reg = <0x0 0x04026000 0x0 0x1000>; - interrupts = ; - clocks = <&ccu CLK_PLL_PERIPH0>, <&ccu CLK_SPI1>, <&ccu CLK_BUS_SPI1>; - clock-names = "pll", "mod", "bus"; - resets = <&ccu RST_BUS_SPI1>; - clock-frequency = <100000000>; - spi1_cs_number = <1>; - spi1_cs_bitmap = <1>; - dmas = <&dma 23>, <&dma 23>; - dma-names = "tx", "rx"; - status = "disabled"; - }; - - ve: ve@1c0e000 { - compatible = "allwinner,sunxi-cedar-ve"; - reg = <0x0 0x01c0e000 0x0 0x1000>, - <0x0 0x03000000 0x0 0x10>, - <0x0 0x03001000 0x0 0x1000>; - interrupts = ; - clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>, <&ccu CLK_MBUS_VE>; - clock-names = "bus_ve", "ve", "mbus_ve"; - resets = <&ccu RST_BUS_VE>; - iommus = <&mmu_aw 0 1>; - status = "okay"; - }; - - twi0: twi@2502000{ - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sun8i-twi"; - device_type = "twi0"; - reg = <0x0 0x02502000 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_I2C0>; - resets = <&ccu RST_BUS_I2C0>; - clock-names = "bus"; - clock-frequency = <400000>; - status = "disabled"; - }; - - twi1: twi@2502400{ - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sun8i-twi"; - device_type = "twi1"; - reg = <0x0 0x02502400 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_I2C1>; - resets = <&ccu RST_BUS_I2C1>; - clock-names = "bus"; - clock-frequency = <200000>; - status = "disabled"; - }; - - twi2: twi@2502800{ - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sun8i-twi"; - device_type = "twi2"; - reg = <0x0 0x02502800 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_I2C2>; - resets = <&ccu RST_BUS_I2C2>; - clock-names = "bus"; - clock-frequency = <100000>; - status = "okay"; - }; - - twi3: twi@2502c00{ - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sun8i-twi"; - device_type = "twi3"; - reg = <0x0 0x02502c00 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_I2C3>; - resets = <&ccu RST_BUS_I2C3>; - clock-names = "bus"; - clock-frequency = <100000>; - status = "disabled"; - }; - - ledc: ledc@2008000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "allwinner,sunxi-leds"; - reg = <0x0 0x02008000 0x0 0x400>; - interrupts = ; - interrupt-names = "ledcirq"; - clocks = <&ccu CLK_LEDC>, <&ccu CLK_BUS_LEDC>; - clock-names = "clk_ledc", "clk_cpuapb"; - dmas = <&dma 42>, <&dma 42>; - dma-names = "rx", "tx"; - resets = <&ccu RST_BUS_LEDC>; - reset-names = "ledc_reset"; - status = "disable"; - }; - - pwm: pwm@2000c00 { - #pwm-cells = <0x3>; - compatible = "allwinner,sunxi-pwm"; - reg = <0x0 0x02000c00 0x0 0x400>; - clocks = <&ccu CLK_BUS_PWM>; - resets = <&ccu RST_BUS_PWM>; - pwm-number = <8>; - pwm-base = <0x0>; - sunxi-pwms = <&pwm0>, <&pwm1>, <&pwm2>, <&pwm3>, <&pwm4>, - <&pwm5>, <&pwm6>, <&pwm7>; - }; - - pwm0: pwm0@2000c10 { - compatible = "allwinner,sunxi-pwm0"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c10 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm1: pwm1@2000c11 { - compatible = "allwinner,sunxi-pwm1"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c11 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm2: pwm2@2000c12 { - compatible = "allwinner,sunxi-pwm2"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c12 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm3: pwm3@2000c13 { - compatible = "allwinner,sunxi-pwm3"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c13 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm4: pwm4@2000c14 { - compatible = "allwinner,sunxi-pwm4"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c14 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm5: pwm5@2000c15 { - compatible = "allwinner,sunxi-pwm5"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c15 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm6: pwm6@2000c16 { - compatible = "allwinner,sunxi-pwm6"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c16 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - pwm7: pwm7@2000c17 { - compatible = "allwinner,sunxi-pwm7"; - pinctrl-names = "active", "sleep"; - reg = <0x0 0x02000c17 0x0 0x4>; - reg_base = <0x02000c00>; - }; - - lcd_fb0: lcd_fb0@0 { - compatible = "allwinner,sunxi-lcd_fb0"; - pinctrl-names = "active","sleep"; - - status = "okay"; - }; - - keyboard0: keyboard@2009800 { - compatible = "allwinner,keyboard_1350mv"; - reg = <0x0 0x02009800 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_LRADC>; - clock-names = "mclk"; - resets = <&ccu RST_BUS_LRADC>; - key_cnt = <5>; - key0 = <210 115>; - key1 = <410 114>; - key2 = <590 139>; - key3 = <750 28>; - key4 = <880 172>; - wakeup-source; - status = "okay"; - }; - - sid@3006000 { - compatible = "allwinner,sun8iw20p1-sid", "allwinner,sunxi-sid"; - reg = <0x0 0x03006000 0 0x1000>; - #address-cells = <1>; - #size-cells = <1>; - - secure_status { - reg = <0x0 0>; - offset = <0xa0>; - size = <0x4>; - }; - - chipid { - reg = <0x0 0>; - offset = <0x200>; - size = <0x10>; - }; - - rotpk { - reg = <0x0 0>; - offset = <0x140>; - size = <0x4>; - }; - - vf_table: vf-table@00 { - reg = <0x00 2>; - }; - - ths_calib: calib@14 { - reg = <0x14 8>; - }; - }; - - gpadc: gpadc@2009000 { - compatible = "allwinner,sunxi-gpadc"; - reg = <0x0 0x02009000 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_GPADC>; - clock-names = "bus"; - resets = <&ccu RST_BUS_GPADC>; - status = "okay"; - }; - - vind0: vind@5800800 { - compatible = "allwinner,sunxi-vin-media", "simple-bus"; - #address-cells = <2>; - #size-cells = <2>; - ranges; - device_id = <0>; - csi_top = <336000000>; - csi_isp = <327000000>; - reg = <0x0 0x05800800 0x0 0x200>, - <0x0 0x05800000 0x0 0x800>; - clocks = <&ccu CLK_CSI_TOP>, <&ccu CLK_PLL_VIDEO1_2X>, - <&ccu CLK_CSI0_MCLK>, <&dcxo24M>, <&ccu CLK_PLL_VIDEO1>, - <&ccu CLK_BUS_CSI>, <&ccu CLK_MBUS_CSI>; - clock-names = "csi_top", "csi_top_src", - "csi_mclk0", "csi_mclk0_24m", "csi_mclk0_pll", - "csi_bus", "csi_mbus"; - resets = <&ccu RST_BUS_CSI>; - reset-names = "csi_ret"; - pinctrl-names = "mclk0-default", "mclk0-sleep"; - pinctrl-0 = <&csi_mclk0_pins_a>; - pinctrl-1 = <&csi_mclk0_pins_b>; - status = "okay"; - - csi0: csi@5801000{ - compatible = "allwinner,sunxi-csi"; - reg = <0x0 0x05801000 0x0 0x1000>; - interrupts = ; - pinctrl-names = "default","sleep"; - pinctrl-0 = <&csi0_pins_a>; - pinctrl-1 = <&csi0_pins_b>; - device_id = <0>; - iommus = <&mmu_aw 1 1>; - status = "okay"; - }; - isp0: isp@5809410 { - compatible = "allwinner,sunxi-isp"; - reg = <0x0 0x05809410 0x0 0x10>; - device_id = <0xfe>; - - status = "okay"; - }; - isp1: isp@5809420 { - compatible = "allwinner,sunxi-isp"; - reg = <0x0 0x05809420 0x0 0x10>; - device_id = <0xff>; - status = "okay"; - }; - scaler0: scaler@5809430 { - compatible = "allwinner,sunxi-scaler"; - reg = <0x0 0x05809430 0x0 0x10>; - device_id = <0xfe>; - status = "okay"; - }; - scaler1: scaler@5809440 { - compatible = "allwinner,sunxi-scaler"; - reg = <0x0 0x05809440 0x0 0x10>; - device_id = <0xff>; - status = "okay"; - }; - actuator0: actuator@5809450 { - compatible = "allwinner,sunxi-actuator"; - device_type = "actuator0"; - reg = <0x0 0x05809450 0x0 0x10>; - actuator0_name = "ad5820_act"; - actuator0_slave = <0x18>; - actuator0_af_pwdn = <>; - actuator0_afvdd = "afvcc-csi"; - actuator0_afvdd_vol = <2800000>; - status = "disabled"; - }; - flash0: flash@5809460 { - device_type = "flash0"; - compatible = "allwinner,sunxi-flash"; - reg = <0x0 0x05809460 0x0 0x10>; - flash0_type = <2>; - flash0_en = <>; - flash0_mode = <>; - flash0_flvdd = ""; - flash0_flvdd_vol = <>; - device_id = <0>; - status = "disabled"; - }; - sensor0: sensor@5809470 { - reg = <0x0 0x05809470 0x0 0x10>; - device_type = "sensor0"; - compatible = "allwinner,sunxi-sensor"; - sensor0_mname = "ov5640"; - sensor0_twi_cci_id = <2>; - sensor0_twi_addr = <0x78>; - sensor0_mclk_id = <0>; - sensor0_pos = "rear"; - sensor0_isp_used = <0>; - sensor0_fmt = <0>; - sensor0_stby_mode = <0>; - sensor0_vflip = <0>; - sensor0_hflip = <0>; - sensor0_iovdd-supply = <>; - sensor0_iovdd_vol = <>; - sensor0_avdd-supply = <>; - sensor0_avdd_vol = <>; - sensor0_dvdd-supply = <>; - sensor0_dvdd_vol = <>; - sensor0_power_en = <>; - sensor0_reset = <&pio PE 9 GPIO_ACTIVE_LOW>; - sensor0_pwdn = <&pio PE 8 GPIO_ACTIVE_LOW>; - sensor0_sm_vs = <>; - flash_handle = <&flash0>; - act_handle = <&actuator0>; - device_id = <0>; - status = "okay"; - }; - sensor1: sensor@5809480 { - reg = <0x0 0x05809480 0x0 0x10>; - device_type = "sensor1"; - compatible = "allwinner,sunxi-sensor"; - sensor1_mname = "ov5647"; - sensor1_twi_cci_id = <3>; - sensor1_twi_addr = <0x6c>; - sensor1_mclk_id = <1>; - sensor1_pos = "front"; - sensor1_isp_used = <0>; - sensor1_fmt = <0>; - sensor1_stby_mode = <0>; - sensor1_vflip = <0>; - sensor1_hflip = <0>; - sensor1_iovdd-supply = <>; - sensor1_iovdd_vol = <>; - sensor1_avdd-supply = <>; - sensor1_avdd_vol = <>; - sensor1_dvdd-supply = <>; - sensor1_dvdd_vol = <>; - sensor1_power_en = <>; - sensor1_reset = <&pio PE 7 GPIO_ACTIVE_LOW>; - sensor1_pwdn = <&pio PE 6 GPIO_ACTIVE_LOW>; - sensor1_sm_vs = <>; - flash_handle = <>; - act_handle = <>; - device_id = <1>; - status = "okay"; - }; - vinc0: vinc@5809000 { - compatible = "allwinner,sunxi-vin-core"; - device_type = "vinc0"; - reg = <0x0 0x05809000 0x0 0x200>; - interrupts = ; - vinc0_csi_sel = <0>; - vinc0_mipi_sel = <0xff>; - vinc0_isp_sel = <0>; - vinc0_tdm_rx_sel = <0xff>; - vinc0_rear_sensor_sel = <0>; - vinc0_front_sensor_sel = <0>; - vinc0_sensor_list = <0>; - device_id = <0>; - iommus = <&mmu_aw 1 1>; - status = "okay"; - }; - vinc1: vinc@5809200 { - device_type = "vinc1"; - compatible = "allwinner,sunxi-vin-core"; - reg = <0x0 0x05809200 0x0 0x200>; - interrupts = ; - vinc1_csi_sel = <0>; - vinc1_mipi_sel = <0xff>; - vinc1_isp_sel = <1>; - vinc1_tdm_rx_sel = <0xff>; - vinc1_rear_sensor_sel = <0>; - vinc1_front_sensor_sel = <0>; - vinc1_sensor_list = <0>; - device_id = <1>; - iommus = <&mmu_aw 1 1>; - status = "okay"; - }; - - }; - s_cir0: s_cir@7040000 { - compatible = "allwinner,s_cir"; - reg = <0x0 0x07040000 0x0 0x400>; - interrupts = ; - clocks = <&r_ccu CLK_R_APB0_BUS_IRRX>, <&dcxo24M>, <&r_ccu CLK_R_APB0_IRRX>; - clock-names = "bus", "pclk", "mclk"; - resets = <&r_ccu RST_R_APB0_BUS_IRRX>; - supply = ""; - supply_vol = ""; - status = "disabled"; - }; - - ir1: ir@2003000 { - compatible = "allwinner,ir_tx"; - reg = <0x0 0x02003000 0x0 0x400>; - interrupts = ; - clocks = <&ccu CLK_BUS_IR_TX>, <&dcxo24M>, <&ccu CLK_IR_TX>; - clock-names = "bus", "pclk", "mclk"; - resets = <&ccu RST_BUS_IR_TX>; - status = "disabled"; - }; - - di: deinterlace@5400000 { - compatible = "allwinner,sunxi-deinterlace"; - reg = <0x0 0x05400000 0x0 0x0000ffff>; - interrupts = ; - clocks = <&ccu CLK_DI>, - <&ccu CLK_BUS_DI>, - <&ccu CLK_PLL_PERIPH0_2X>; - clock-names = "clk_di", - "pll_periph", - "clk_bus_di"; - resets = <&ccu RST_BUS_DI>; - reset-names = "rst_bus_di"; - - assigned-clocks = <&ccu CLK_DI>; - assigned-clock-parents = <&ccu CLK_PLL_PERIPH0_2X>; - assigned-clock-rates = <300000000>; - - iommus = <&mmu_aw 4 1>; - status = "okay"; - }; - - g2d: g2d@5410000 { - compatible = "allwinner,sunxi-g2d"; - reg = <0x0 0x05410000 0x0 0x3ffff>; - interrupts = ; - clocks = <&ccu CLK_BUS_G2D>, <&ccu CLK_G2D>, <&ccu CLK_MBUS_G2D>; - clock-names = "bus", "g2d", "mbus_g2d"; - resets = <&ccu RST_BUS_G2D>; - iommus = <&mmu_aw 3 1>; - status = "okay"; - }; - - disp: disp@5000000 { - compatible = "allwinner,sunxi-disp"; - reg = <0x0 0x05000000 0x0 0x3fffff>, /* de0 */ - <0x0 0x05460000 0x0 0xfff>, /*display_if_top*/ - <0x0 0x05461000 0x0 0xfff>, /* tcon-lcd0 */ - <0x0 0x05470000 0x0 0xfff>, /* tcon-tv */ - <0x0 0x05450000 0x0 0x1fff>; /* dsi0*/ - interrupts = ,/*tcon-lcd0*/ - ,/*tcon-tv */ - ;/*dsi*/ - clocks = <&ccu CLK_DE0>, - <&ccu CLK_DE0>, - <&ccu CLK_BUS_DE0>, - <&ccu CLK_BUS_DE0>, - <&ccu CLK_BUS_DPSS_TOP0>, - <&ccu CLK_BUS_DPSS_TOP0>, - <&ccu CLK_MIPI_DSI>, - <&ccu CLK_BUS_MIPI_DSI>, - <&ccu CLK_TCON_LCD0>, - <&ccu CLK_TCON_TV>, - <&ccu CLK_BUS_TCON_LCD0>, - <&ccu CLK_BUS_TCON_TV>, - <&ccu CLK_MIPI_DSI>, - <&ccu CLK_BUS_MIPI_DSI>; - clock-names = "clk_de0", - "clk_de1", - "clk_bus_de0", - "clk_bus_de1", - "clk_bus_dpss_top0", - "clk_bus_dpss_top1", - "clk_mipi_dsi0", - "clk_bus_mipi_dsi0", - "clk_tcon0", - "clk_tcon1",/*tcon-tv actually*/ - "clk_bus_tcon0", - "clk_bus_tcon1",/*tcon-tv actually*/ - "clk_mipi_dsi0", - "clk_bus_mipi_dsi0"; - resets = <&ccu RST_BUS_DE0>, - <&ccu RST_BUS_DE0>, - <&ccu RST_BUS_DPSS_TOP0>, - <&ccu RST_BUS_DPSS_TOP0>, - <&ccu RST_BUS_MIPI_DSI>, - <&ccu RST_BUS_TCON_LCD0>, - <&ccu RST_BUS_TCON_TV>, - <&ccu RST_BUS_LVDS0>; - reset-names = "rst_bus_de0", - "rst_bus_de1", - "rst_bus_dpss_top0", - "rst_bus_dpss_top1", - "rst_bus_mipi_dsi0", - "rst_bus_tcon0", - "rst_bus_tcon1", - "rst_bus_lvds0"; - - assigned-clocks = <&ccu CLK_DE0>, - <&ccu CLK_MIPI_DSI>, - <&ccu CLK_TCON_LCD0>, - <&ccu CLK_TCON_TV>; - assigned-clock-parents = <&ccu CLK_PLL_PERIPH0_2X>, - <&ccu CLK_PLL_PERIPH0>, - <&ccu CLK_PLL_VIDEO0_4X>, - <&ccu CLK_PLL_VIDEO1_4X>; - assigned-clock-rates = <300000000>, - <150000000>, - <0>, - <0>; - - boot_disp = <0>; - boot_disp1 = <0>; - boot_disp2 = <0>; - fb_base = <0>; - iommus = <&mmu_aw 2 0>; - status = "okay"; - }; - - lcd0: lcd0@5461000 { - compatible = "allwinner,sunxi-lcd0"; - reg = <0x0 0x05461000 0x0 0xfff>; - pinctrl-names = "active","sleep"; - status = "okay"; - }; - - tv0: tv0@5600000 { - compatible = "allwinner,sunxi-tv"; - reg = <0x0 0x05600000 0x0 0x3fff>, - <0x0 0x05604000 0x0 0x3fff>; - clocks = <&ccu CLK_BUS_TVE_TOP>, - <&ccu CLK_TVE>, - <&ccu CLK_BUS_TVE>; - clock-names = "clk_bus_tve_top", - "clk_tve", - "clk_bus_tve"; - resets = <&ccu RST_BUS_TVE_TOP>, - <&ccu RST_BUS_TVE>; - reset-names = "rst_bus_tve_top", "rst_bus_tve"; - - device_type = "tv0"; - pinctrl-names = "active","sleep"; - status = "okay"; - }; - - hwspinlock: hwspinlock@0x3005000 { - compatible = "allwinner,sunxi-hwspinlock"; - reg = <0x0 0x3005000 0x0 0x1000>; - #hwlock-cells = <1>; - clocks = <&ccu CLK_BUS_SPINLOCK>; - clock-names = "clk_hwspinlock_bus"; - resets = <&ccu RST_BUS_SPINLOCK>; - reset-names = "rst"; - num-locks = <32>; - status = "disabled"; - }; - - msgbox: msgbox@3003000 { - compatible = "sunxi,msgbox-amp"; - reg = <0x0 0x03003000 0x0 0x1000>, - <0x0 0x01701000 0x0 0x1000>, - <0x0 0x0601f000 0x0 0x1000>; - interrupts = , - , - ; - clocks = <&ccu CLK_BUS_MSGBOX0>; - rpmsg_id = "sunxi,dsp-msgbox","sunxi,dsp-power-msgbox"; - resets = <&ccu RST_BUS_MSGBOX0>; - reset-names = "rst"; - msgbox_amp_counts = <3>; - msgbox_amp_local = <0>; - rpmsg_amp_remote-0 = <1>; - rpmsg_read_channel-0 = <1>; - rpmsg_write_channel-0 = <1>; - rpmsg_amp_remote-1 = <1>; - rpmsg_read_channel-1 = <0>; - rpmsg_write_channel-1 = <0>; - }; - - hdmi: hdmi@5500000 { - compatible = "allwinner,sunxi-hdmi"; - reg = <0x0 0x05500000 0x0 0xfffff>; - interrupts = ; - clocks = <&ccu CLK_BUS_HDMI>, - <&ccu CLK_HDMI_24M>, - <&ccu CLK_HDMI_CEC>, - <&ccu CLK_TCON_TV>; - clock-names = "clk_bus_hdmi", - "clk_ddc", - "clk_cec", - "clk_tcon_tv"; - resets = <&ccu RST_BUS_HDMI_SUB>, - <&ccu RST_BUS_HDMI_MAIN>; - reset-names = "rst_bus_sub", - "rst_bus_main"; - assigned-clocks = <&ccu CLK_HDMI_CEC>; - assigned-clock-parents = <&ccu CLK_HDMI_CEC_32K>; - assigned-clock-rates = <0>; - status = "okay"; - }; - usbc0:usbc0@0 { - device_type = "usbc0"; - compatible = "allwinner,sunxi-otg-manager"; - usb_port_type = <2>; - usb_detect_type = <1>; - usb_id_gpio; - usb_det_vbus_gpio; - usb_regulator_io = "nocare"; - usb_wakeup_suspend = <0>; - usb_luns = <3>; - usb_serial_unique = <0>; - usb_serial_number = "20080411"; - rndis_wceis = <1>; - status = "okay"; - }; - - udc:udc-controller@0x04100000 { - compatible = "allwinner,sunxi-udc"; - reg = <0x0 0x04100000 0x0 0x1000>, /*udc base*/ - <0x0 0x00000000 0x0 0x100>; /*sram base*/ - interrupts = ; - clocks = <&ccu CLK_BUS_OTG>; - clock-names = "bus_otg"; - resets = <&ccu RST_BUS_OTG>, <&ccu RST_USB_PHY0>; - reset-names = "otg", "phy"; - status = "okay"; - }; - - ehci0:ehci0-controller@0x04101000 { - compatible = "allwinner,sunxi-ehci0"; - reg = <0x0 0x04101000 0x0 0xFFF>, /*hci0 base*/ - <0x0 0x00000000 0x0 0x100>, /*sram base*/ - <0x0 0x04100000 0x0 0x1000>; /*otg base*/ - interrupts = ; - clocks = <&ccu CLK_BUS_EHCI0>; - clock-names = "bus_hci"; - resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_USB_PHY0>; - reset-names = "hci", "phy"; - hci_ctrl_no = <0>; - status = "okay"; - }; - - ohci0:ohci0-controller@0x04101400 { - compatible = "allwinner,sunxi-ohci0"; - reg = <0x0 0x04101400 0x0 0xFFF>, /*hci0 base*/ - <0x0 0x00000000 0x0 0x100>, /*sram base*/ - <0x0 0x04100000 0x0 0x1000>; /*otg base*/ - interrupts = ; - clocks = <&ccu CLK_BUS_OHCI0>, <&ccu CLK_USB_OHCI0>; - clock-names = "bus_hci", "ohci"; - resets = <&ccu RST_BUS_OHCI0>, <&ccu RST_USB_PHY0>; - reset-names = "hci", "phy"; - hci_ctrl_no = <0>; - status = "okay"; - }; - - usbc1:usbc1@0 { - device_type = "usbc1"; - usb_regulator_io = "nocare"; - usb_wakeup_suspend = <0>; - status = "disable"; - }; - - ehci1:ehci1-controller@0x04200000 { - compatible = "allwinner,sunxi-ehci1"; - reg = <0x0 0x04200000 0x0 0xFFF>, /*ehci1 base*/ - <0x0 0x00000000 0x0 0x100>, /*sram base*/ - <0x0 0x04100000 0x0 0x1000>; /*otg base*/ - interrupts = ; - clocks = <&ccu CLK_BUS_EHCI1>; - clock-names = "bus_hci"; - resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_USB_PHY1>; - reset-names = "hci", "phy"; - hci_ctrl_no = <1>; - status = "disable"; - }; - - ohci1:ohci1-controller@0x04200400 { - compatible = "allwinner,sunxi-ohci1"; - reg = <0x0 0x04200400 0x0 0xFFF>, /*ohci1 base*/ - <0x0 0x00000000 0x0 0x100>, /*sram base*/ - <0x0 0x04100000 0x0 0x1000>; /*otg base*/ - interrupts = ; - clocks = <&ccu CLK_BUS_OHCI1>, <&ccu CLK_USB_OHCI1>; - clock-names = "bus_hci", "ohci"; - resets = <&ccu RST_BUS_OHCI1>, <&ccu RST_USB_PHY1>; - reset-names = "hci", "phy"; - hci_ctrl_no = <1>; - status = "disable"; - }; - - /* codec addr: 0x02030000, the others is invalid to avoid build warining */ - codec:codec@2030000 { - #sound-dai-cells = <0>; - compatible = "allwinner,sunxi-internal-codec"; - reg = <0x0 0x02030000 0x0 0x34c>; - clocks = <&ccu CLK_PLL_AUDIO0>, - <&ccu CLK_PLL_AUDIO1_DIV5>, - <&ccu CLK_AUDIO_DAC>, - <&ccu CLK_AUDIO_ADC>, - <&ccu CLK_BUS_AUDIO_CODEC>; - clock-names = "pll_audio0", "pll_audio1_div5", - "audio_clk_dac", "audio_clk_adc", - "audio_clk_bus"; - resets = <&ccu RST_BUS_AUDIO_CODEC>; - rx_sync_en = <0x00>; - device_type = "codec"; - status = "okay"; - }; - - dummy_cpudai:dummy_cpudai@203034c { - compatible = "allwinner,sunxi-dummy-cpudai"; - reg = <0x0 0x0203034c 0x0 0x4>; - tx_fifo_size = <128>; - rx_fifo_size = <256>; - dac_txdata = <0x02030020>; - adc_txdata = <0x02030040>; - playback_cma = <128>; - capture_cma = <256>; - device_type = "cpudai"; - dmas = <&dma 7>, <&dma 7>; - dma-names = "tx", "rx"; - status = "okay"; - }; - - sndcodec:sound@2030340 { - compatible = "allwinner,sunxi-codec-machine"; - reg = <0x0 0x02030340 0x0 0x4>; - interrupts = ; - sunxi,audio-codec = <&codec>; - sunxi,cpudai-controller = <&dummy_cpudai>; - device_type = "sndcodec"; - status = "okay"; - }; - - sunxi_rpaf_dsp0:rpaf-dsp@203034c { - compatible = "allwinner,rpaf-dsp0"; - device_type = "sunxi_rpaf_dsp0"; - dsp_id = <0x0>; - status = "okay"; - }; - - /* dmic addr: 0x02031000, the others is invalid to avoid build warining */ - dmic:dmic@2031000{ - #sound-dai-cells = <0>; - compatible = "allwinner,sunxi-dmic"; - reg = <0x0 0x02031000 0x0 0x50>; - clocks = <&ccu CLK_PLL_AUDIO0>, /* 98.304M / 90.3168M */ - <&ccu CLK_DMIC>, - <&ccu CLK_BUS_DMIC>; - clock-names = "pll_audio", "dmic", "dmic_bus"; - resets = <&ccu RST_BUS_DMIC>; - dmas = <&dma 8>; - dma-names = "rx"; - interrupts = ; - clk_parent = <0x1>; - capture_cma = <256>; - data_vol = <0xB0>; - rx_chmap = <0x76543210>; - rx_sync_en = <0x00>; - device_type = "dmic"; - status = "disabled"; - }; - - dmic_codec:sound@2031050{ - #sound-dai-cells = <0>; - compatible = "dmic-codec"; - reg = <0x0 0x02031050 0x0 0x4>; - num-channels = <8>; - }; - - sounddmic:sounddmic@2031060 { - reg = <0x0 0x02031060 0x0 0x4>; - compatible = "sunxi,simple-audio-card"; - simple-audio-card,name = "snddmic"; - simple-audio-card,capture_only; - status = "disabled"; - /* simple-audio-card,format = "i2s"; */ - simple-audio-card,cpu { - sound-dai = <&dmic>; - }; - simple-audio-card,codec { - sound-dai = <&dmic_codec>; - }; - }; - - /* daudio0 addr: 0x02032000, the others is invalid to avoid build warining */ - daudio0:daudio@2032000 { - #sound-dai-cells = <0>; - compatible = "allwinner,sunxi-daudio"; - reg = <0x0 0x02032000 0x0 0xa0>; - clocks = <&ccu CLK_PLL_AUDIO0>, /* 98.304M / 90.3168M */ - <&ccu CLK_I2S0>, - <&ccu CLK_BUS_I2S0>; - clock-names = "pll_audio", "i2s0", "i2s0_bus"; - resets = <&ccu RST_BUS_I2S0>; - dmas = <&dma 3>, <&dma 3>; - dma-names = "tx", "rx"; - interrupts = ; - pinctrl_used = <0x01>; - sign_extend = <0x00>; - tx_data_mode = <0x00>; - rx_data_mode = <0x00>; - msb_lsb_first = <0x00>; - pcm_lrck_period = <0x80>; - slot_width_select = <0x20>; - frametype = <0x00>; - tdm_config = <0x01>; - tdm_num = <0x00>; - mclk_div = <0x00>; - clk_parent = <0x00>; - capture_cma = <128>; - playback_cma = <128>; - tx_num = <4>; - tx_chmap1 = <0x76543210>; - tx_chmap0 = <0xFEDCBA98>; - rx_num = <4>; - rx_chmap3 = <0x03020100>; - rx_chmap2 = <0x07060504>; - rx_chmap1 = <0x0B0A0908>; - rx_chmap0 = <0x0F0E0D0C>; - asrc_function_en = <0x00>; - rx_sync_en = <0x00>; - device_type = "daudio0"; - status = "disabled"; - }; - - sounddaudio0: sounddaudio0@20320a0 { - reg = <0x0 0x020320a0 0x0 0x4>; - compatible = "sunxi,simple-audio-card"; - simple-audio-card,name = "snddaudio0"; - simple-audio-card,format = "i2s"; - status = "disabled"; - /* simple-audio-card,frame-master = <&daudio0_master>; */ - /* simple-audio-card,bitclock-master = <&daudio0_master>; */ - /* simple-audio-card,bitclock-inversion; */ - /* simple-audio-card,frame-inversion; */ - simple-audio-card,cpu { - sound-dai = <&daudio0>; - }; - }; - - /* daudio1 addr: 0x02033000, the others is invalid to avoid build warining */ - daudio1:daudio@2033000 { - #sound-dai-cells = <0>; - compatible = "allwinner,sunxi-daudio"; - reg = <0x0 0x02033000 0x0 0xa0>; - clocks = <&ccu CLK_PLL_AUDIO0>, /* 98.304M / 90.3168M */ - <&ccu CLK_I2S1>, - <&ccu CLK_BUS_I2S1>; - clock-names = "pll_audio", "i2s1", "i2s1_bus"; - resets = <&ccu RST_BUS_I2S1>; - dmas = <&dma 4>, <&dma 4>; - dma-names = "tx", "rx"; - interrupts = ; - pinctrl_used = <0x01>; - sign_extend = <0x00>; - tx_data_mode = <0x00>; - rx_data_mode = <0x00>; - msb_lsb_first = <0x00>; - pcm_lrck_period = <0x80>; - slot_width_select = <0x20>; - frametype = <0x00>; - tdm_config = <0x01>; - tdm_num = <0x01>; - mclk_div = <0x00>; - clk_parent = <0x00>; - capture_cma = <128>; - playback_cma = <128>; - tx_num = <4>; - tx_chmap1 = <0x76543210>; - tx_chmap0 = <0xFEDCBA98>; - rx_num = <4>; - rx_chmap3 = <0x03020100>; - rx_chmap2 = <0x07060504>; - rx_chmap1 = <0x0B0A0908>; - rx_chmap0 = <0x0F0E0D0C>; - asrc_function_en = <0x00>; - rx_sync_en = <0x00>; - device_type = "daudio1"; - status = "disabled"; - }; - - sounddaudio1: sounddaudio1@20330a0 { - reg = <0x0 0x020330a0 0x0 0x4>; - compatible = "sunxi,simple-audio-card"; - simple-audio-card,name = "snddaudio1"; - simple-audio-card,format = "i2s"; - status = "disabled"; - simple-audio-card,cpu { - sound-dai = <&daudio1>; - }; - }; - - /* daudio2 addr: 0x02034000, the others is invalid to avoid build warining */ - daudio2:daudio@2034000 { - #sound-dai-cells = <0>; - compatible = "allwinner,sunxi-daudio"; - reg = <0x0 0x02034000 0x0 0xa0>; - clocks = <&ccu CLK_PLL_AUDIO0>, /* 98.304M / 90.3168M */ - <&ccu CLK_I2S2>, - <&ccu CLK_BUS_I2S2>, - <&ccu CLK_PLL_AUDIO0_4X>, - <&ccu CLK_I2S2_ASRC>; - resets = <&ccu RST_BUS_I2S2>; - dmas = <&dma 5>, <&dma 5>; - dma-names = "tx", "rx"; - interrupts = ; - pinctrl_used = <0x01>; - daudio_type = <0x00>; - sign_extend = <0x00>; - tx_data_mode = <0x00>; - rx_data_mode = <0x00>; - msb_lsb_first = <0x00>; - pcm_lrck_period = <0x80>; - slot_width_select = <0x20>; - frametype = <0x00>; - tdm_config = <0x01>; - tdm_num = <0x02>; - mclk_div = <0x01>; - clk_parent = <0x00>; - capture_cma = <128>; - playback_cma = <128>; - tx_num = <4>; - tx_chmap1 = <0x76543210>; - tx_chmap0 = <0xFEDCBA98>; - rx_num = <4>; - rx_chmap3 = <0x03020100>; - rx_chmap2 = <0x07060504>; - rx_chmap1 = <0x0B0A0908>; - rx_chmap0 = <0x0F0E0D0C>; - asrc_function_en = <0x00>; - rx_sync_en = <0x00>; - device_type = "daudio2"; - status = "disabled"; - }; - - sounddaudio2: sounddaudio2@20340a0 { - reg = <0x0 0x020340a0 0x0 0x4>; - compatible = "sunxi,simple-audio-card"; - simple-audio-card,name = "snddaudio2"; - simple-audio-card,format = "i2s"; - status = "disabled"; - simple-audio-card,cpu { - sound-dai = <&daudio2>; - }; - }; - - hdmiaudio: hdmiaudio@20340a4 { - #sound-dai-cells = <0>; - reg = <0x0 0x020340a4 0x0 0x4>; - compatible = "allwinner,sunxi-hdmiaudio"; - status = "disabled"; - }; - - /* spdif addr: 0x02036000, the others is invalid to avoid build warining */ - spdif:spdif@2036000 { - #sound-dai-cells = <0>; - compatible = "allwinner,sunxi-spdif"; - reg = <0x0 0x02036000 0x0 0x58>; - clocks = <&ccu CLK_PLL_AUDIO0_4X>, /* 90.3168M */ - <&ccu CLK_SPDIF_TX>, - <&ccu CLK_BUS_SPDIF>, - <&ccu CLK_PLL_AUDIO1>, /* 98.304M */ - <&ccu CLK_PLL_AUDIO1_DIV5>, - <&ccu CLK_PLL_PERIPH0>, - <&ccu CLK_SPDIF_RX>; - clock-names = "pll_audio0", "spdif", "spdif_bus", - "pll_audio1", "pll_audio1_div5", - "pll_periph", "spdif_rx"; - resets = <&ccu RST_BUS_SPDIF>; - dmas = <&dma 2>, <&dma 2>; - dma-names = "tx", "rx"; - interrupts = ; - clk_parent = <0x1>; - playback_cma = <128>; - capture_cma = <128>; - rx_sync_en = <0>; - device_type = "spdif"; - status = "disabled"; - }; - - soundspdif:soundspdif@203605c { - reg = <0x0 0x0203605c 0x0 0x4>; - compatible = "sunxi,simple-audio-card"; - simple-audio-card,name = "sndspdif"; - status = "disabled"; - /* simple-audio-card,format = "i2s"; */ - simple-audio-card,cpu { - sound-dai = <&spdif>; - }; - simple-audio-card,codec { - /*snd-soc-dummy*/ - }; - }; - - ths: ths@02009400 { - compatible = "allwinner,sun8iw20p1-ths"; - reg = <0x0 0x02009400 0x0 0x400>; - clocks = <&ccu CLK_BUS_THS>; - clock-names = "bus"; - resets = <&ccu RST_BUS_THS>; - nvmem-cells = <&ths_calib>; - nvmem-cell-names = "calibration"; - #thermal-sensor-cells = <1>; - }; - - tvd: tvd@05c00000 { - compatible = "allwinner,sunxi-tvd"; - reg = <0x0 0x05c00000 0x0 0x00010000>;/*tvd_top*/ - interrupts = ; - - clocks = <&ccu CLK_BUS_TVD_TOP>, - <&ccu CLK_MBUS_TVIN>; - clock-names = "clk_bus_tvd_top", - "clk_mbus_tvd"; - - resets = <&ccu RST_BUS_TVD_TOP>; - reset-names = "rst_bus_tvd_top"; - - tvd-number = <1>; - tvds = <&tvd0>; - status = "okay"; - }; - - tvd0: tvd0@05c01000 { - compatible = "allwinner,sunxi-tvd0"; - reg = <0x0 0x05c01000 0x0 0x00010000>; - interrupts = ; - - clocks = <&ccu CLK_TVD>, - <&ccu CLK_BUS_TVD>; - clock-names = "clk_tvd0","clk_bus_tvd0"; - - resets = <&ccu RST_BUS_TVD>; - reset-names = "rst_bus_tvd0"; - - assigned-clocks = <&ccu CLK_TVD>; - assigned-clock-parents = <&ccu CLK_PLL_VIDEO1>; - - tvd_used = <1>; - tvd_if = <0>; - status = "okay"; - }; - - }; -}; diff --git a/tp2bmc/configs/tp2bmc_defconfig b/tp2bmc/configs/tp2bmc_defconfig index da0868b6..35dc65b0 100644 --- a/tp2bmc/configs/tp2bmc_defconfig +++ b/tp2bmc/configs/tp2bmc_defconfig @@ -19,21 +19,16 @@ BR2_RELRO_NONE=y # Kernel BR2_LINUX_KERNEL=y -BR2_LINUX_KERNEL_CUSTOM_GIT=y -BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/turing-machines/linux.git" -BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="5112fdd843715f1615703ca5ce2a06c1abe5f9ee" BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_TP2BMC_PATH)/patches/linux" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/linux_defconfig" BR2_LINUX_KERNEL_DTS_SUPPORT=y -BR2_LINUX_KERNEL_INTREE_DTS_NAME="" -BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8iw20p1-t113-turingmachines-tp2bmc.dts" +BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts" BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME=y BR2_LINUX_KERNEL_INSTALL_TARGET=y BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y BR2_KERNEL_HEADERS_AS_KERNEL=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_4=y # Filesystem BR2_TARGET_ROOTFS_EROFS=y diff --git a/tp2bmc/patches/linux/0001-Add-devm_regulator_bulk_get_exclusive.patch b/tp2bmc/patches/linux/0001-Add-devm_regulator_bulk_get_exclusive.patch deleted file mode 100644 index 4fa704f8..00000000 --- a/tp2bmc/patches/linux/0001-Add-devm_regulator_bulk_get_exclusive.patch +++ /dev/null @@ -1,210 +0,0 @@ -From 26d3edda2829c7181a44127a2221cec88712b6e7 Mon Sep 17 00:00:00 2001 -From: Zev Weiss -Date: Mon, 31 Oct 2022 16:37:02 -0700 -Subject: [PATCH] regulator: devres: Add devm_regulator_bulk_get_exclusive() - -We had an exclusive variant of the devm_regulator_get() API, but no -corresponding variant for the bulk API; let's add one now. We add a -generalized version of the existing regulator_bulk_get() function that -additionally takes a get_type parameter and redefine -regulator_bulk_get() in terms of it, then do similarly with -devm_regulator_bulk_get(), and finally add the new -devm_regulator_bulk_get_exclusive(). - -Signed-off-by: Zev Weiss -Link: https://lore.kernel.org/r/20221031233704.22575-2-zev@bewilderbeest.net -Signed-off-by: Mark Brown ---- - drivers/regulator/core.c | 42 +++++++++++-------- - drivers/regulator/devres.c | 66 ++++++++++++++++++++++-------- - drivers/regulator/internal.h | 2 + - include/linux/regulator/consumer.h | 2 + - 4 files changed, 76 insertions(+), 36 deletions(-) - -diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c -index 229ad8b4e..a4107d33f 100644 ---- a/drivers/regulator/core.c -+++ b/drivers/regulator/core.c -@@ -4389,22 +4389,8 @@ static int _notifier_call_chain(struct regulator_dev *rdev, - return blocking_notifier_call_chain(&rdev->notifier, event, data); - } - --/** -- * regulator_bulk_get - get multiple regulator consumers -- * -- * @dev: Device to supply -- * @num_consumers: Number of consumers to register -- * @consumers: Configuration of consumers; clients are stored here. -- * -- * @return 0 on success, an errno on failure. -- * -- * This helper function allows drivers to get several regulator -- * consumers in one operation. If any of the regulators cannot be -- * acquired then any regulators that were allocated will be freed -- * before returning to the caller. -- */ --int regulator_bulk_get(struct device *dev, int num_consumers, -- struct regulator_bulk_data *consumers) -+int _regulator_bulk_get(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers, enum regulator_get_type get_type) - { - int i; - int ret; -@@ -4413,8 +4399,8 @@ int regulator_bulk_get(struct device *dev, int num_consumers, - consumers[i].consumer = NULL; - - for (i = 0; i < num_consumers; i++) { -- consumers[i].consumer = regulator_get(dev, -- consumers[i].supply); -+ consumers[i].consumer = _regulator_get(dev, -+ consumers[i].supply, get_type); - if (IS_ERR(consumers[i].consumer)) { - ret = PTR_ERR(consumers[i].consumer); - consumers[i].consumer = NULL; -@@ -4437,6 +4423,26 @@ int regulator_bulk_get(struct device *dev, int num_consumers, - - return ret; - } -+ -+/** -+ * regulator_bulk_get - get multiple regulator consumers -+ * -+ * @dev: Device to supply -+ * @num_consumers: Number of consumers to register -+ * @consumers: Configuration of consumers; clients are stored here. -+ * -+ * @return 0 on success, an errno on failure. -+ * -+ * This helper function allows drivers to get several regulator -+ * consumers in one operation. If any of the regulators cannot be -+ * acquired then any regulators that were allocated will be freed -+ * before returning to the caller. -+ */ -+int regulator_bulk_get(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers) -+{ -+ return _regulator_bulk_get(dev, num_consumers, consumers, NORMAL_GET); -+} - EXPORT_SYMBOL_GPL(regulator_bulk_get); - - static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) -diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c -index 3ea1c170f..e82540843 100644 ---- a/drivers/regulator/devres.c -+++ b/drivers/regulator/devres.c -@@ -127,23 +127,9 @@ static void devm_regulator_bulk_release(struct device *dev, void *res) - regulator_bulk_free(devres->num_consumers, devres->consumers); - } - --/** -- * devm_regulator_bulk_get - managed get multiple regulator consumers -- * -- * @dev: Device to supply -- * @num_consumers: Number of consumers to register -- * @consumers: Configuration of consumers; clients are stored here. -- * -- * @return 0 on success, an errno on failure. -- * -- * This helper function allows drivers to get several regulator -- * consumers in one operation with management, the regulators will -- * automatically be freed when the device is unbound. If any of the -- * regulators cannot be acquired then any regulators that were -- * allocated will be freed before returning to the caller. -- */ --int devm_regulator_bulk_get(struct device *dev, int num_consumers, -- struct regulator_bulk_data *consumers) -+static int _devm_regulator_bulk_get(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers, -+ enum regulator_get_type get_type) - { - struct regulator_bulk_devres *devres; - int ret; -@@ -153,7 +139,7 @@ int devm_regulator_bulk_get(struct device *dev, int num_consumers, - if (!devres) - return -ENOMEM; - -- ret = regulator_bulk_get(dev, num_consumers, consumers); -+ ret = _regulator_bulk_get(dev, num_consumers, consumers, get_type); - if (!ret) { - devres->consumers = consumers; - devres->num_consumers = num_consumers; -@@ -164,8 +150,52 @@ int devm_regulator_bulk_get(struct device *dev, int num_consumers, - - return ret; - } -+ -+/** -+ * devm_regulator_bulk_get - managed get multiple regulator consumers -+ * -+ * @dev: Device to supply -+ * @num_consumers: Number of consumers to register -+ * @consumers: Configuration of consumers; clients are stored here. -+ * -+ * @return 0 on success, an errno on failure. -+ * -+ * This helper function allows drivers to get several regulator -+ * consumers in one operation with management, the regulators will -+ * automatically be freed when the device is unbound. If any of the -+ * regulators cannot be acquired then any regulators that were -+ * allocated will be freed before returning to the caller. -+ */ -+int devm_regulator_bulk_get(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers) -+{ -+ return _devm_regulator_bulk_get(dev, num_consumers, consumers, NORMAL_GET); -+} - EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); - -+/** -+ * devm_regulator_bulk_get_exclusive - managed exclusive get of multiple -+ * regulator consumers -+ * -+ * @dev: device to supply -+ * @num_consumers: number of consumers to register -+ * @consumers: configuration of consumers; clients are stored here. -+ * -+ * @return 0 on success, an errno on failure. -+ * -+ * This helper function allows drivers to exclusively get several -+ * regulator consumers in one operation with management, the regulators -+ * will automatically be freed when the device is unbound. If any of -+ * the regulators cannot be acquired then any regulators that were -+ * allocated will be freed before returning to the caller. -+ */ -+int devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers) -+{ -+ return _devm_regulator_bulk_get(dev, num_consumers, consumers, EXCLUSIVE_GET); -+} -+EXPORT_SYMBOL_GPL(devm_regulator_bulk_get_exclusive); -+ - static void devm_rdev_release(struct device *dev, void *res) - { - regulator_unregister(*(struct regulator_dev **)res); -diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h -index 2391b565e..8ee5c8117 100644 ---- a/drivers/regulator/internal.h -+++ b/drivers/regulator/internal.h -@@ -111,4 +111,6 @@ enum regulator_get_type { - - struct regulator *_regulator_get(struct device *dev, const char *id, - enum regulator_get_type get_type); -+int _regulator_bulk_get(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers, enum regulator_get_type get_type); - #endif -diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h -index 6a92fd310..5a0c06e49 100644 ---- a/include/linux/regulator/consumer.h -+++ b/include/linux/regulator/consumer.h -@@ -229,6 +229,8 @@ int __must_check regulator_bulk_get(struct device *dev, int num_consumers, - struct regulator_bulk_data *consumers); - int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, - struct regulator_bulk_data *consumers); -+int __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers, -+ struct regulator_bulk_data *consumers); - int __must_check regulator_bulk_enable(int num_consumers, - struct regulator_bulk_data *consumers); - int regulator_bulk_disable(int num_consumers, --- -2.39.2 - diff --git a/tp2bmc/patches/linux/0002-Handle-regulator-output-DT-nodes.patch b/tp2bmc/patches/linux/0002-Handle-regulator-output-DT-nodes.patch deleted file mode 100644 index e76cea5c..00000000 --- a/tp2bmc/patches/linux/0002-Handle-regulator-output-DT-nodes.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 5c51d4afcf3fd36159713556402e16cfab794ae9 Mon Sep 17 00:00:00 2001 -From: Zev Weiss -Date: Mon, 31 Oct 2022 16:37:04 -0700 -Subject: [PATCH] regulator: userspace-consumer: Handle regulator-output DT - nodes - -In addition to adding some fairly simple OF support code, we make some -slight adjustments to the userspace-consumer driver to properly -support use with regulator-output hardware: - - - We now do an exclusive get of the supply regulators so as to - prevent regulator_init_complete_work from automatically disabling - them. - - - Instead of assuming that the supply is initially disabled, we now - query its state to determine the initial value of drvdata->enabled. - -Signed-off-by: Zev Weiss -Link: https://lore.kernel.org/r/20221031233704.22575-4-zev@bewilderbeest.net -Signed-off-by: Mark Brown ---- - drivers/regulator/userspace-consumer.c | 60 +++++++++++++++++--- - include/linux/regulator/userspace-consumer.h | 1 + - 2 files changed, 54 insertions(+), 7 deletions(-) - -diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c -index 8ca28664776eb5..402c8037cf39f6 100644 ---- a/drivers/regulator/userspace-consumer.c -+++ b/drivers/regulator/userspace-consumer.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -24,6 +25,7 @@ struct userspace_consumer_data { - - struct mutex lock; - bool enabled; -+ bool no_autoswitch; - - int num_supplies; - struct regulator_bulk_data *supplies; -@@ -96,19 +98,50 @@ static struct attribute *attributes[] = { - NULL, - }; - -+static umode_t attr_visible(struct kobject *kobj, struct attribute *attr, int idx) -+{ -+ struct device *dev = kobj_to_dev(kobj); -+ struct userspace_consumer_data *data = dev_get_drvdata(dev); -+ -+ /* If a name hasn't been set, don't bother with the attribute */ -+ if (attr == &dev_attr_name.attr && !data->name) -+ return 0; -+ -+ return attr->mode; -+} -+ - static const struct attribute_group attr_group = { - .attrs = attributes, -+ .is_visible = attr_visible, - }; - - static int regulator_userspace_consumer_probe(struct platform_device *pdev) - { -+ struct regulator_userspace_consumer_data tmpdata; - struct regulator_userspace_consumer_data *pdata; - struct userspace_consumer_data *drvdata; - int ret; - - pdata = dev_get_platdata(&pdev->dev); -- if (!pdata) -+ if (!pdata) { -+ if (!pdev->dev.of_node) -+ return -EINVAL; -+ -+ pdata = &tmpdata; -+ memset(pdata, 0, sizeof(*pdata)); -+ -+ pdata->no_autoswitch = true; -+ pdata->num_supplies = 1; -+ pdata->supplies = devm_kzalloc(&pdev->dev, sizeof(*pdata->supplies), GFP_KERNEL); -+ if (!pdata->supplies) -+ return -ENOMEM; -+ pdata->supplies[0].supply = "vout"; -+ } -+ -+ if (pdata->num_supplies < 1) { -+ dev_err(&pdev->dev, "At least one supply required\n"); - return -EINVAL; -+ } - - drvdata = devm_kzalloc(&pdev->dev, - sizeof(struct userspace_consumer_data), -@@ -119,21 +152,24 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) - drvdata->name = pdata->name; - drvdata->num_supplies = pdata->num_supplies; - drvdata->supplies = pdata->supplies; -+ drvdata->no_autoswitch = pdata->no_autoswitch; - - mutex_init(&drvdata->lock); - -- ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies, -- drvdata->supplies); -+ ret = devm_regulator_bulk_get_exclusive(&pdev->dev, drvdata->num_supplies, -+ drvdata->supplies); - if (ret) { - dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret); - return ret; - } - -+ platform_set_drvdata(pdev, drvdata); -+ - ret = sysfs_create_group(&pdev->dev.kobj, &attr_group); - if (ret != 0) - return ret; - -- if (pdata->init_on) { -+ if (pdata->init_on && !pdata->no_autoswitch) { - ret = regulator_bulk_enable(drvdata->num_supplies, - drvdata->supplies); - if (ret) { -@@ -143,8 +179,12 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) - } - } - -- drvdata->enabled = pdata->init_on; -- platform_set_drvdata(pdev, drvdata); -+ ret = regulator_is_enabled(pdata->supplies[0].consumer); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Failed to get regulator status\n"); -+ goto err_enable; -+ } -+ drvdata->enabled = !!ret; - - return 0; - -@@ -160,17 +200,23 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev) - - sysfs_remove_group(&pdev->dev.kobj, &attr_group); - -- if (data->enabled) -+ if (data->enabled && !data->no_autoswitch) - regulator_bulk_disable(data->num_supplies, data->supplies); - - return 0; - } - -+static const struct of_device_id regulator_userspace_consumer_of_match[] = { -+ { .compatible = "regulator-output", }, -+ {}, -+}; -+ - static struct platform_driver regulator_userspace_consumer_driver = { - .probe = regulator_userspace_consumer_probe, - .remove = regulator_userspace_consumer_remove, - .driver = { - .name = "reg-userspace-consumer", -+ .of_match_table = regulator_userspace_consumer_of_match, - }, - }; - -diff --git a/include/linux/regulator/userspace-consumer.h b/include/linux/regulator/userspace-consumer.h -index b5dba062895169..2249ee697f8bf0 100644 ---- a/include/linux/regulator/userspace-consumer.h -+++ b/include/linux/regulator/userspace-consumer.h -@@ -21,6 +21,7 @@ struct regulator_userspace_consumer_data { - struct regulator_bulk_data *supplies; - - bool init_on; -+ bool no_autoswitch; - }; - - #endif /* __REGULATOR_PLATFORM_CONSUMER_H_ */ diff --git a/tp2bmc/patches/linux/0010-Introduce-gpiod_set_config.patch b/tp2bmc/patches/linux/0010-Introduce-gpiod_set_config.patch deleted file mode 100644 index 1f6b557a..00000000 --- a/tp2bmc/patches/linux/0010-Introduce-gpiod_set_config.patch +++ /dev/null @@ -1,109 +0,0 @@ -From d5d0ce7d74d7a51af86955822b50c3b0a0922c39 Mon Sep 17 00:00:00 2001 -From: Geert Uytterhoeven -Date: Tue, 24 Mar 2020 14:56:50 +0100 -Subject: [PATCH 1/3] gpiolib: Introduce gpiod_set_config() - -The GPIO Aggregator will need a method to forward a .set_config() call -to its parent gpiochip. This requires obtaining the gpio_chip and -offset for a given gpio_desc. While gpiod_to_chip() is public, -gpio_chip_hwgpio() is not, so there is currently no method to obtain the -needed GPIO offset parameter. - -Hence introduce a public gpiod_set_config() helper, which invokes the -.set_config() callback through a gpio_desc pointer, like is done for -most other gpio_chip callbacks. - -Rewrite the existing gpiod_set_debounce() helper as a wrapper around -gpiod_set_config(), to avoid duplication. - -Signed-off-by: Geert Uytterhoeven -Link: https://lore.kernel.org/r/20200324135653.6676-5-geert+renesas@glider.be -Signed-off-by: Linus Walleij ---- - drivers/gpio/gpiolib.c | 34 ++++++++++++++++++++++------------ - include/linux/gpio/consumer.h | 8 ++++++++ - 2 files changed, 30 insertions(+), 12 deletions(-) - -diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c -index 104ed299d5ea..47b78832c076 100644 ---- a/drivers/gpio/gpiolib.c -+++ b/drivers/gpio/gpiolib.c -@@ -3126,6 +3126,26 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) - } - EXPORT_SYMBOL_GPL(gpiod_direction_output); - -+/** -+ * gpiod_set_config - sets @config for a GPIO -+ * @desc: descriptor of the GPIO for which to set the configuration -+ * @config: Same packed config format as generic pinconf -+ * -+ * Returns: -+ * 0 on success, %-ENOTSUPP if the controller doesn't support setting the -+ * configuration. -+ */ -+int gpiod_set_config(struct gpio_desc *desc, unsigned long config) -+{ -+ struct gpio_chip *chip; -+ -+ VALIDATE_DESC(desc); -+ chip = desc->gdev->chip; -+ -+ return chip->set_config(chip, gpio_chip_hwgpio(desc), config); -+} -+EXPORT_SYMBOL_GPL(gpiod_set_config); -+ - /** - * gpiod_set_debounce - sets @debounce time for a GPIO - * @desc: descriptor of the GPIO for which to set debounce time -@@ -3137,20 +3157,10 @@ EXPORT_SYMBOL_GPL(gpiod_direction_output); - */ - int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) - { -- struct gpio_chip *chip; -- unsigned long config; -- -- VALIDATE_DESC(desc); -- chip = desc->gdev->chip; -- if (!chip->set || !chip->set_config) { -- gpiod_dbg(desc, -- "%s: missing set() or set_config() operations\n", -- __func__); -- return -ENOTSUPP; -- } -+ unsigned long config; - - config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); -- return chip->set_config(chip, gpio_chip_hwgpio(desc), config); -+ return gpiod_set_config(desc, config); - } - EXPORT_SYMBOL_GPL(gpiod_set_debounce); - -diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h -index b70af921c614..9ce245fa6f1f 100644 ---- a/include/linux/gpio/consumer.h -+++ b/include/linux/gpio/consumer.h -@@ -156,6 +156,7 @@ int gpiod_set_raw_array_value_cansleep(unsigned int array_size, - struct gpio_array *array_info, - unsigned long *value_bitmap); - -+int gpiod_set_config(struct gpio_desc *desc, unsigned long config); - int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); - int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); - -@@ -465,6 +466,13 @@ static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size, - return 0; - } - -+static inline int gpiod_set_config(struct gpio_desc *desc, unsigned long config) -+{ -+ /* GPIO can never have been requested */ -+ WARN_ON(desc); -+ return -ENOSYS; -+} -+ - static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) - { - /* GPIO can never have been requested */ --- -2.39.2 - diff --git a/tp2bmc/patches/linux/0011-Add-GPIO-Aggregator.patch b/tp2bmc/patches/linux/0011-Add-GPIO-Aggregator.patch deleted file mode 100644 index a6ab3d52..00000000 --- a/tp2bmc/patches/linux/0011-Add-GPIO-Aggregator.patch +++ /dev/null @@ -1,647 +0,0 @@ -From ed1d902655e37ea8025efc87820921cf2e15c31b Mon Sep 17 00:00:00 2001 -From: Geert Uytterhoeven -Date: Mon, 11 May 2020 16:52:55 +0200 -Subject: [PATCH 2/3] gpio: Add GPIO Aggregator - -GPIO controllers are exported to userspace using /dev/gpiochip* -character devices. Access control to these devices is provided by -standard UNIX file system permissions, on an all-or-nothing basis: -either a GPIO controller is accessible for a user, or it is not. -Currently no mechanism exists to control access to individual GPIOs. - -Hence add a GPIO driver to aggregate existing GPIOs, and expose them as -a new gpiochip. - -This supports the following use cases: - - Aggregating GPIOs using Sysfs - This is useful for implementing access control, and assigning a set - of GPIOs to a specific user or virtual machine. - - Generic GPIO Driver - This is useful for industrial control, where it can provide - userspace access to a simple GPIO-operated device described in DT, - cfr. e.g. spidev for SPI-operated devices. - -Signed-off-by: Geert Uytterhoeven -Tested-by: Eugeniu Rosca -Reviewed-by: Eugeniu Rosca -Link: https://lore.kernel.org/r/20200511145257.22970-5-geert+renesas@glider.be -Signed-off-by: Linus Walleij ---- - drivers/gpio/Kconfig | 12 + - drivers/gpio/Makefile | 1 + - drivers/gpio/gpio-aggregator.c | 568 +++++++++++++++++++++++++++++++++ - 3 files changed, 581 insertions(+) - create mode 100644 drivers/gpio/gpio-aggregator.c - -diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig -index 38e096e6925f..b60637b95ffb 100644 ---- a/drivers/gpio/Kconfig -+++ b/drivers/gpio/Kconfig -@@ -1480,6 +1480,18 @@ config GPIO_VIPERBOARD - - endmenu - -+config GPIO_AGGREGATOR -+ tristate "GPIO Aggregator" -+ help -+ Say yes here to enable the GPIO Aggregator, which provides a way to -+ aggregate existing GPIO lines into a new virtual GPIO chip. -+ This can serve the following purposes: -+ - Assign permissions for a collection of GPIO lines to a user, -+ - Export a collection of GPIO lines to a virtual machine, -+ - Provide a generic driver for a GPIO-operated device in an -+ industrial control context, to be operated from userspace using -+ the GPIO chardev interface. -+ - config GPIO_MOCKUP - tristate "GPIO Testing Driver" - select IRQ_SIM -diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile -index d2fd19c15bae..feb92f9988b1 100644 ---- a/drivers/gpio/Makefile -+++ b/drivers/gpio/Makefile -@@ -25,6 +25,7 @@ obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o - obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o - obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o - obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o -+obj-$(CONFIG_GPIO_AGGREGATOR) += gpio-aggregator.o - obj-$(CONFIG_GPIO_ALTERA_A10SR) += gpio-altera-a10sr.o - obj-$(CONFIG_GPIO_ALTERA) += gpio-altera.o - obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o -diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c -new file mode 100644 -index 000000000000..9b0adbdddbfc ---- /dev/null -+++ b/drivers/gpio/gpio-aggregator.c -@@ -0,0 +1,568 @@ -+// SPDX-License-Identifier: GPL-2.0-only -+// -+// GPIO Aggregator -+// -+// Copyright (C) 2019-2020 Glider bv -+ -+#define DRV_NAME "gpio-aggregator" -+#define pr_fmt(fmt) DRV_NAME ": " fmt -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+/* -+ * GPIO Aggregator sysfs interface -+ */ -+ -+struct gpio_aggregator { -+ struct gpiod_lookup_table *lookups; -+ struct platform_device *pdev; -+ char args[]; -+}; -+ -+static DEFINE_MUTEX(gpio_aggregator_lock); /* protects idr */ -+static DEFINE_IDR(gpio_aggregator_idr); -+ -+static char *get_arg(char **args) -+{ -+ char *start = *args, *end; -+ -+ start = skip_spaces(start); -+ if (!*start) -+ return NULL; -+ -+ if (*start == '"') { -+ /* Quoted arg */ -+ end = strchr(++start, '"'); -+ if (!end) -+ return ERR_PTR(-EINVAL); -+ } else { -+ /* Unquoted arg */ -+ for (end = start; *end && !isspace(*end); end++) ; -+ } -+ -+ if (*end) -+ *end++ = '\0'; -+ -+ *args = end; -+ return start; -+} -+ -+static bool isrange(const char *s) -+{ -+ size_t n; -+ -+ if (IS_ERR_OR_NULL(s)) -+ return false; -+ -+ while (1) { -+ n = strspn(s, "0123456789"); -+ if (!n) -+ return false; -+ -+ s += n; -+ -+ switch (*s++) { -+ case '\0': -+ return true; -+ -+ case '-': -+ case ',': -+ break; -+ -+ default: -+ return false; -+ } -+ } -+} -+ -+static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key, -+ int hwnum, unsigned int *n) -+{ -+ struct gpiod_lookup_table *lookups; -+ -+ lookups = krealloc(aggr->lookups, struct_size(lookups, table, *n + 2), -+ GFP_KERNEL); -+ if (!lookups) -+ return -ENOMEM; -+ -+ lookups->table[*n] = -+ (struct gpiod_lookup)GPIO_LOOKUP_IDX(key, hwnum, NULL, *n, 0); -+ -+ (*n)++; -+ memset(&lookups->table[*n], 0, sizeof(lookups->table[*n])); -+ -+ aggr->lookups = lookups; -+ return 0; -+} -+ -+static int aggr_parse(struct gpio_aggregator *aggr) -+{ -+ unsigned int first_index, last_index, i, n = 0; -+ char *name, *offsets, *first, *last, *next; -+ char *args = aggr->args; -+ int error; -+ -+ for (name = get_arg(&args), offsets = get_arg(&args); name; -+ offsets = get_arg(&args)) { -+ if (IS_ERR(name)) { -+ pr_err("Cannot get GPIO specifier: %pe\n", name); -+ return PTR_ERR(name); -+ } -+ -+ if (!isrange(offsets)) { -+ /* Named GPIO line */ -+ error = aggr_add_gpio(aggr, name, U16_MAX, &n); -+ if (error) -+ return error; -+ -+ name = offsets; -+ continue; -+ } -+ -+ /* GPIO chip + offset(s) */ -+ for (first = offsets; *first; first = next) { -+ next = strchrnul(first, ','); -+ if (*next) -+ *next++ = '\0'; -+ -+ last = strchr(first, '-'); -+ if (last) -+ *last++ = '\0'; -+ -+ if (kstrtouint(first, 10, &first_index)) { -+ pr_err("Cannot parse GPIO index %s\n", first); -+ return -EINVAL; -+ } -+ -+ if (!last) { -+ last_index = first_index; -+ } else if (kstrtouint(last, 10, &last_index)) { -+ pr_err("Cannot parse GPIO index %s\n", last); -+ return -EINVAL; -+ } -+ -+ for (i = first_index; i <= last_index; i++) { -+ error = aggr_add_gpio(aggr, name, i, &n); -+ if (error) -+ return error; -+ } -+ } -+ -+ name = get_arg(&args); -+ } -+ -+ if (!n) { -+ pr_err("No GPIOs specified\n"); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static ssize_t new_device_store(struct device_driver *driver, const char *buf, -+ size_t count) -+{ -+ struct gpio_aggregator *aggr; -+ struct platform_device *pdev; -+ int res, id; -+ -+ /* kernfs guarantees string termination, so count + 1 is safe */ -+ aggr = kzalloc(sizeof(*aggr) + count + 1, GFP_KERNEL); -+ if (!aggr) -+ return -ENOMEM; -+ -+ memcpy(aggr->args, buf, count + 1); -+ -+ aggr->lookups = kzalloc(struct_size(aggr->lookups, table, 1), -+ GFP_KERNEL); -+ if (!aggr->lookups) { -+ res = -ENOMEM; -+ goto free_ga; -+ } -+ -+ mutex_lock(&gpio_aggregator_lock); -+ id = idr_alloc(&gpio_aggregator_idr, aggr, 0, 0, GFP_KERNEL); -+ mutex_unlock(&gpio_aggregator_lock); -+ -+ if (id < 0) { -+ res = id; -+ goto free_table; -+ } -+ -+ aggr->lookups->dev_id = kasprintf(GFP_KERNEL, "%s.%d", DRV_NAME, id); -+ if (!aggr->lookups->dev_id) { -+ res = -ENOMEM; -+ goto remove_idr; -+ } -+ -+ res = aggr_parse(aggr); -+ if (res) -+ goto free_dev_id; -+ -+ gpiod_add_lookup_table(aggr->lookups); -+ -+ pdev = platform_device_register_simple(DRV_NAME, id, NULL, 0); -+ if (IS_ERR(pdev)) { -+ res = PTR_ERR(pdev); -+ goto remove_table; -+ } -+ -+ aggr->pdev = pdev; -+ return count; -+ -+remove_table: -+ gpiod_remove_lookup_table(aggr->lookups); -+free_dev_id: -+ kfree(aggr->lookups->dev_id); -+remove_idr: -+ mutex_lock(&gpio_aggregator_lock); -+ idr_remove(&gpio_aggregator_idr, id); -+ mutex_unlock(&gpio_aggregator_lock); -+free_table: -+ kfree(aggr->lookups); -+free_ga: -+ kfree(aggr); -+ return res; -+} -+ -+static DRIVER_ATTR_WO(new_device); -+ -+static void gpio_aggregator_free(struct gpio_aggregator *aggr) -+{ -+ platform_device_unregister(aggr->pdev); -+ gpiod_remove_lookup_table(aggr->lookups); -+ kfree(aggr->lookups->dev_id); -+ kfree(aggr->lookups); -+ kfree(aggr); -+} -+ -+static ssize_t delete_device_store(struct device_driver *driver, -+ const char *buf, size_t count) -+{ -+ struct gpio_aggregator *aggr; -+ unsigned int id; -+ int error; -+ -+ if (!str_has_prefix(buf, DRV_NAME ".")) -+ return -EINVAL; -+ -+ error = kstrtouint(buf + strlen(DRV_NAME "."), 10, &id); -+ if (error) -+ return error; -+ -+ mutex_lock(&gpio_aggregator_lock); -+ aggr = idr_remove(&gpio_aggregator_idr, id); -+ mutex_unlock(&gpio_aggregator_lock); -+ if (!aggr) -+ return -ENOENT; -+ -+ gpio_aggregator_free(aggr); -+ return count; -+} -+static DRIVER_ATTR_WO(delete_device); -+ -+static struct attribute *gpio_aggregator_attrs[] = { -+ &driver_attr_new_device.attr, -+ &driver_attr_delete_device.attr, -+ NULL, -+}; -+ATTRIBUTE_GROUPS(gpio_aggregator); -+ -+static int __exit gpio_aggregator_idr_remove(int id, void *p, void *data) -+{ -+ gpio_aggregator_free(p); -+ return 0; -+} -+ -+static void __exit gpio_aggregator_remove_all(void) -+{ -+ mutex_lock(&gpio_aggregator_lock); -+ idr_for_each(&gpio_aggregator_idr, gpio_aggregator_idr_remove, NULL); -+ idr_destroy(&gpio_aggregator_idr); -+ mutex_unlock(&gpio_aggregator_lock); -+} -+ -+ -+/* -+ * GPIO Forwarder -+ */ -+ -+struct gpiochip_fwd { -+ struct gpio_chip chip; -+ struct gpio_desc **descs; -+ union { -+ struct mutex mlock; /* protects tmp[] if can_sleep */ -+ spinlock_t slock; /* protects tmp[] if !can_sleep */ -+ }; -+ unsigned long tmp[]; /* values and descs for multiple ops */ -+}; -+ -+static int gpio_fwd_get_direction(struct gpio_chip *chip, unsigned int offset) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ -+ return gpiod_get_direction(fwd->descs[offset]); -+} -+ -+static int gpio_fwd_direction_input(struct gpio_chip *chip, unsigned int offset) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ -+ return gpiod_direction_input(fwd->descs[offset]); -+} -+ -+static int gpio_fwd_direction_output(struct gpio_chip *chip, -+ unsigned int offset, int value) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ -+ return gpiod_direction_output(fwd->descs[offset], value); -+} -+ -+static int gpio_fwd_get(struct gpio_chip *chip, unsigned int offset) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ -+ return gpiod_get_value(fwd->descs[offset]); -+} -+ -+static int gpio_fwd_get_multiple(struct gpio_chip *chip, unsigned long *mask, -+ unsigned long *bits) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ unsigned long *values, flags = 0; -+ struct gpio_desc **descs; -+ unsigned int i, j = 0; -+ int error; -+ -+ if (chip->can_sleep) -+ mutex_lock(&fwd->mlock); -+ else -+ spin_lock_irqsave(&fwd->slock, flags); -+ -+ /* Both values bitmap and desc pointers are stored in tmp[] */ -+ values = &fwd->tmp[0]; -+ descs = (void *)&fwd->tmp[BITS_TO_LONGS(fwd->chip.ngpio)]; -+ -+ bitmap_clear(values, 0, fwd->chip.ngpio); -+ for_each_set_bit(i, mask, fwd->chip.ngpio) -+ descs[j++] = fwd->descs[i]; -+ -+ error = gpiod_get_array_value(j, descs, NULL, values); -+ if (!error) { -+ j = 0; -+ for_each_set_bit(i, mask, fwd->chip.ngpio) -+ __assign_bit(i, bits, test_bit(j++, values)); -+ } -+ -+ if (chip->can_sleep) -+ mutex_unlock(&fwd->mlock); -+ else -+ spin_unlock_irqrestore(&fwd->slock, flags); -+ -+ return error; -+} -+ -+static void gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int value) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ -+ gpiod_set_value(fwd->descs[offset], value); -+} -+ -+static void gpio_fwd_set_multiple(struct gpio_chip *chip, unsigned long *mask, -+ unsigned long *bits) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ unsigned long *values, flags = 0; -+ struct gpio_desc **descs; -+ unsigned int i, j = 0; -+ -+ if (chip->can_sleep) -+ mutex_lock(&fwd->mlock); -+ else -+ spin_lock_irqsave(&fwd->slock, flags); -+ -+ /* Both values bitmap and desc pointers are stored in tmp[] */ -+ values = &fwd->tmp[0]; -+ descs = (void *)&fwd->tmp[BITS_TO_LONGS(fwd->chip.ngpio)]; -+ -+ for_each_set_bit(i, mask, fwd->chip.ngpio) { -+ __assign_bit(j, values, test_bit(i, bits)); -+ descs[j++] = fwd->descs[i]; -+ } -+ -+ gpiod_set_array_value(j, descs, NULL, values); -+ -+ if (chip->can_sleep) -+ mutex_unlock(&fwd->mlock); -+ else -+ spin_unlock_irqrestore(&fwd->slock, flags); -+} -+ -+static int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset, -+ unsigned long config) -+{ -+ struct gpiochip_fwd *fwd = gpiochip_get_data(chip); -+ -+ return gpiod_set_config(fwd->descs[offset], config); -+} -+ -+/** -+ * gpiochip_fwd_create() - Create a new GPIO forwarder -+ * @dev: Parent device pointer -+ * @ngpios: Number of GPIOs in the forwarder. -+ * @descs: Array containing the GPIO descriptors to forward to. -+ * This array must contain @ngpios entries, and must not be deallocated -+ * before the forwarder has been destroyed again. -+ * -+ * This function creates a new gpiochip, which forwards all GPIO operations to -+ * the passed GPIO descriptors. -+ * -+ * Return: An opaque object pointer, or an ERR_PTR()-encoded negative error -+ * code on failure. -+ */ -+static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev, -+ unsigned int ngpios, -+ struct gpio_desc *descs[]) -+{ -+ const char *label = dev_name(dev); -+ struct gpiochip_fwd *fwd; -+ struct gpio_chip *chip; -+ unsigned int i; -+ int error; -+ -+ fwd = devm_kzalloc(dev, struct_size(fwd, tmp, -+ BITS_TO_LONGS(ngpios) + ngpios), GFP_KERNEL); -+ if (!fwd) -+ return ERR_PTR(-ENOMEM); -+ -+ chip = &fwd->chip; -+ -+ /* -+ * If any of the GPIO lines are sleeping, then the entire forwarder -+ * will be sleeping. -+ * If any of the chips support .set_config(), then the forwarder will -+ * support setting configs. -+ */ -+ for (i = 0; i < ngpios; i++) { -+ struct gpio_chip *parent = gpiod_to_chip(descs[i]); -+ -+ dev_dbg(dev, "%u => gpio-%d\n", i, desc_to_gpio(descs[i])); -+ -+ if (gpiod_cansleep(descs[i])) -+ chip->can_sleep = true; -+ if (parent && parent->set_config) -+ chip->set_config = gpio_fwd_set_config; -+ } -+ -+ chip->label = label; -+ chip->parent = dev; -+ chip->owner = THIS_MODULE; -+ chip->get_direction = gpio_fwd_get_direction; -+ chip->direction_input = gpio_fwd_direction_input; -+ chip->direction_output = gpio_fwd_direction_output; -+ chip->get = gpio_fwd_get; -+ chip->get_multiple = gpio_fwd_get_multiple; -+ chip->set = gpio_fwd_set; -+ chip->set_multiple = gpio_fwd_set_multiple; -+ chip->base = -1; -+ chip->ngpio = ngpios; -+ fwd->descs = descs; -+ -+ if (chip->can_sleep) -+ mutex_init(&fwd->mlock); -+ else -+ spin_lock_init(&fwd->slock); -+ -+ error = devm_gpiochip_add_data(dev, chip, fwd); -+ if (error) -+ return ERR_PTR(error); -+ -+ return fwd; -+} -+ -+ -+/* -+ * GPIO Aggregator platform device -+ */ -+ -+static int gpio_aggregator_probe(struct platform_device *pdev) -+{ -+ struct device *dev = &pdev->dev; -+ struct gpio_desc **descs; -+ struct gpiochip_fwd *fwd; -+ int i, n; -+ -+ n = gpiod_count(dev, NULL); -+ if (n < 0) -+ return n; -+ -+ descs = devm_kmalloc_array(dev, n, sizeof(*descs), GFP_KERNEL); -+ if (!descs) -+ return -ENOMEM; -+ -+ for (i = 0; i < n; i++) { -+ descs[i] = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS); -+ if (IS_ERR(descs[i])) -+ return PTR_ERR(descs[i]); -+ } -+ -+ fwd = gpiochip_fwd_create(dev, n, descs); -+ if (IS_ERR(fwd)) -+ return PTR_ERR(fwd); -+ -+ platform_set_drvdata(pdev, fwd); -+ return 0; -+} -+ -+#ifdef CONFIG_OF -+static const struct of_device_id gpio_aggregator_dt_ids[] = { -+ /* -+ * Add GPIO-operated devices controlled from userspace below, -+ * or use "driver_override" in sysfs -+ */ -+ {}, -+}; -+MODULE_DEVICE_TABLE(of, gpio_aggregator_dt_ids); -+#endif -+ -+static struct platform_driver gpio_aggregator_driver = { -+ .probe = gpio_aggregator_probe, -+ .driver = { -+ .name = DRV_NAME, -+ .groups = gpio_aggregator_groups, -+ .of_match_table = of_match_ptr(gpio_aggregator_dt_ids), -+ }, -+}; -+ -+static int __init gpio_aggregator_init(void) -+{ -+ return platform_driver_register(&gpio_aggregator_driver); -+} -+module_init(gpio_aggregator_init); -+ -+static void __exit gpio_aggregator_exit(void) -+{ -+ gpio_aggregator_remove_all(); -+ platform_driver_unregister(&gpio_aggregator_driver); -+} -+module_exit(gpio_aggregator_exit); -+ -+MODULE_AUTHOR("Geert Uytterhoeven "); -+MODULE_DESCRIPTION("GPIO Aggregator"); -+MODULE_LICENSE("GPL v2"); --- -2.39.2 - diff --git a/tp2bmc/patches/linux/0012-mtd-spinand-macronix-Add-support-for-MX35LFxGE4AD.patch b/tp2bmc/patches/linux/0012-mtd-spinand-macronix-Add-support-for-MX35LFxGE4AD.patch deleted file mode 100644 index 4e6fe907..00000000 --- a/tp2bmc/patches/linux/0012-mtd-spinand-macronix-Add-support-for-MX35LFxGE4AD.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 97090438c3999f6175dec471a991222f9ce7fa9f Mon Sep 17 00:00:00 2001 -From: YouChing Lin -Date: Thu, 5 Nov 2020 15:23:40 +0800 -Subject: [PATCH] mtd: spinand: macronix: Add support for MX35LFxGE4AD - -The Macronix MX35LF2GE4AD / MX35LF4GE4AD are 3V, 2G / 4Gbit serial -SLC NAND flash device (with on-die ECC). - -Validated by read, erase, read back, write, read back and nandtest -on Xilinx Zynq PicoZed FPGA board which included Macronix SPI Host -(drivers/spi/spi-mxic.c). - -Signed-off-by: YouChing Lin -Signed-off-by: Miquel Raynal -Link: https://lore.kernel.org/linux-mtd/1604561020-13499-1-git-send-email-ycllin@mxic.com.tw ---- - drivers/mtd/nand/spi/macronix.c | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c -index 21def3f8f..6f26d23ef 100644 ---- a/drivers/mtd/nand/spi/macronix.c -+++ b/drivers/mtd/nand/spi/macronix.c -@@ -116,6 +116,24 @@ static const struct spinand_info macronix_spinand_table[] = { - &update_cache_variants), - SPINAND_HAS_QE_BIT, - SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), -+ SPINAND_INFO("MX35LF2GE4AD", 0x26, -+ NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ 0, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), -+ SPINAND_INFO("MX35LF4GE4AD", 0x37, -+ NAND_MEMORG(1, 4096, 128, 64, 2048, 40, 1, 1, 1), -+ NAND_ECCREQ(8, 512), -+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, -+ &write_cache_variants, -+ &update_cache_variants), -+ 0, -+ SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, -+ mx35lf1ge4ab_ecc_get_status)), - }; - - static int macronix_spinand_detect(struct spinand_device *spinand) --- -2.43.0 - diff --git a/tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch b/tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch index 98a08287..07c2066e 100644 --- a/tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch +++ b/tp2bmc/patches/linux/9000-Add-turingmachines-tp2-nodes-compat.patch @@ -16,8 +16,8 @@ index 9b0adbdddbfc..92afa9ce8a77 100644 * Add GPIO-operated devices controlled from userspace below, * or use "driver_override" in sysfs */ -+ { .compatible = "turingmachines,tp2-nodes", }, - {}, ++ { .compatible = "turing,pi2-nodes", }, + {} }; MODULE_DEVICE_TABLE(of, gpio_aggregator_dt_ids); -- diff --git a/tp2bmc/patches/linux/backport-emc2305.patch b/tp2bmc/patches/linux/backport-emc2305.patch deleted file mode 100644 index 9d759e77..00000000 --- a/tp2bmc/patches/linux/backport-emc2305.patch +++ /dev/null @@ -1,1054 +0,0 @@ -From abaa03886764efa317c5c59a3b47739da16bcab6 Mon Sep 17 00:00:00 2001 -From: Michael Shych -Date: Wed, 10 Aug 2022 20:15:50 +0300 -Subject: [PATCH 1/8] platform_data/emc2305: define platform data for EMC2305 - driver - -Introduce platform data structure for EM2305 driver to allow configuration -device PWMs and thermal zones by passing required platform data -to the driver. If no platform data is provided, the driver is supposed -to work with default settings. - -Signed-off-by: Michael Shych -Reviewed-by: Vadim Pasternak -Link: https://lore.kernel.org/r/20220810171552.56417-2-michaelsh@nvidia.com -Signed-off-by: Guenter Roeck ---- - include/linux/platform_data/emc2305.h | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - create mode 100644 include/linux/platform_data/emc2305.h - -diff --git a/include/linux/platform_data/emc2305.h b/include/linux/platform_data/emc2305.h -new file mode 100644 -index 000000000000..54d672dd6f7d ---- /dev/null -+++ b/include/linux/platform_data/emc2305.h -@@ -0,0 +1,22 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+ -+#ifndef __LINUX_PLATFORM_DATA_EMC2305__ -+#define __LINUX_PLATFORM_DATA_EMC2305__ -+ -+#define EMC2305_PWM_MAX 5 -+ -+/** -+ * struct emc2305_platform_data - EMC2305 driver platform data -+ * @max_state: maximum cooling state of the cooling device; -+ * @pwm_num: number of active channels; -+ * @pwm_separate: separate PWM settings for every channel; -+ * @pwm_min: array of minimum PWM per channel; -+ */ -+struct emc2305_platform_data { -+ u8 max_state; -+ u8 pwm_num; -+ bool pwm_separate; -+ u8 pwm_min[EMC2305_PWM_MAX]; -+}; -+ -+#endif --- -2.41.0 - -From 89ba29f9bec071212c35794872072df592336c54 Mon Sep 17 00:00:00 2001 -From: Michael Shych -Date: Wed, 10 Aug 2022 20:15:51 +0300 -Subject: [PATCH 2/8] hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based - PWM Fan Speed Controller. - -Add driver for Microchip EMC2301/2/3/5 RPM-based PWM Fan Speed Controller. -Modify Makefile and Kconfig to support Microchip EMC2305 RPM-based -PWM Fan Speed Controller. - -Signed-off-by: Michael Shych -Reviewed-by: Vadim Pasternak -Link: https://lore.kernel.org/r/20220810171552.56417-3-michaelsh@nvidia.com -[groeck: Drop unnecessary () around DIV_ROUND_CLOSEST()] -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/Kconfig | 13 + - drivers/hwmon/Makefile | 1 + - drivers/hwmon/emc2305.c | 624 ++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 638 insertions(+) - create mode 100644 drivers/hwmon/emc2305.c - -diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig -index 13a6b4afb4b3..382a3bb8c0c8 100644 ---- a/drivers/hwmon/Kconfig -+++ b/drivers/hwmon/Kconfig -@@ -1448,6 +1448,19 @@ config SENSORS_EMC2103 - This driver can also be built as a module. If so, the module - will be called emc2103. - -+config SENSORS_EMC2305 -+ tristate "Microchip EMC2305 and compatible EMC2301/2/3" -+ depends on I2C -+ imply THERMAL -+ help -+ If you say yes here you get support for the Microchip EMC2305 -+ fan controller chips. -+ The Microchip EMC2305 is a fan controller for up to 5 fans. -+ Fan rotation speeds are reported in RPM. -+ -+ This driver can also be built as a module. If so, the module -+ will be called emc2305. -+ - config SENSORS_EMC6W201 - tristate "SMSC EMC6W201" - depends on I2C -diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile -index 40c036ea45e6..555548f7b230 100644 ---- a/drivers/hwmon/Makefile -+++ b/drivers/hwmon/Makefile -@@ -60,6 +60,7 @@ obj-$(CONFIG_SENSORS_DS620) += ds620.o - obj-$(CONFIG_SENSORS_DS1621) += ds1621.o - obj-$(CONFIG_SENSORS_EMC1403) += emc1403.o - obj-$(CONFIG_SENSORS_EMC2103) += emc2103.o -+obj-$(CONFIG_SENSORS_EMC2305) += emc2305.o - obj-$(CONFIG_SENSORS_EMC6W201) += emc6w201.o - obj-$(CONFIG_SENSORS_F71805F) += f71805f.o - obj-$(CONFIG_SENSORS_F71882FG) += f71882fg.o -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -new file mode 100644 -index 000000000000..9f6546ea3d69 ---- /dev/null -+++ b/drivers/hwmon/emc2305.c -@@ -0,0 +1,624 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Hardware monitoring driver for EMC2305 fan controller -+ * -+ * Copyright (C) 2022 Nvidia Technologies Ltd. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static const unsigned short -+emc2305_normal_i2c[] = { 0x27, 0x2c, 0x2d, 0x2e, 0x2f, 0x4c, 0x4d, I2C_CLIENT_END }; -+ -+#define EMC2305_REG_DRIVE_FAIL_STATUS 0x27 -+#define EMC2305_REG_DEVICE 0xfd -+#define EMC2305_REG_VENDOR 0xfe -+#define EMC2305_FAN_MAX 0xff -+#define EMC2305_FAN_MIN 0x00 -+#define EMC2305_FAN_MAX_STATE 10 -+#define EMC2305_DEVICE 0x34 -+#define EMC2305_VENDOR 0x5d -+#define EMC2305_REG_PRODUCT_ID 0xfd -+#define EMC2305_TACH_REGS_UNUSE_BITS 3 -+#define EMC2305_TACH_CNT_MULTIPLIER 0x02 -+#define EMC2305_TACH_RANGE_MIN 480 -+ -+#define EMC2305_PWM_DUTY2STATE(duty, max_state, pwm_max) \ -+ DIV_ROUND_CLOSEST((duty) * (max_state), (pwm_max)) -+#define EMC2305_PWM_STATE2DUTY(state, max_state, pwm_max) \ -+ DIV_ROUND_CLOSEST((state) * (pwm_max), (max_state)) -+ -+/* -+ * Factor by equations [2] and [3] from data sheet; valid for fans where the number of edges -+ * equal (poles * 2 + 1). -+ */ -+#define EMC2305_RPM_FACTOR 3932160 -+ -+#define EMC2305_REG_FAN_DRIVE(n) (0x30 + 0x10 * (n)) -+#define EMC2305_REG_FAN_MIN_DRIVE(n) (0x38 + 0x10 * (n)) -+#define EMC2305_REG_FAN_TACH(n) (0x3e + 0x10 * (n)) -+ -+enum emc230x_product_id { -+ EMC2305 = 0x34, -+ EMC2303 = 0x35, -+ EMC2302 = 0x36, -+ EMC2301 = 0x37, -+}; -+ -+static const struct i2c_device_id emc2305_ids[] = { -+ { "emc2305", 0 }, -+ { "emc2303", 0 }, -+ { "emc2302", 0 }, -+ { "emc2301", 0 }, -+ { } -+}; -+MODULE_DEVICE_TABLE(i2c, emc2305_ids); -+ -+/** -+ * @cdev: cooling device; -+ * @curr_state: cooling current state; -+ * @last_hwmon_state: last cooling state updated by hwmon subsystem; -+ * @last_thermal_state: last cooling state updated by thermal subsystem; -+ * -+ * The 'last_hwmon_state' and 'last_thermal_state' fields are provided to support fan low limit -+ * speed feature. The purpose of this feature is to provides ability to limit fan speed -+ * according to some system wise considerations, like absence of some replaceable units (PSU or -+ * line cards), high system ambient temperature, unreliable transceivers temperature sensing or -+ * some other factors which indirectly impacts system's airflow -+ * Fan low limit feature is supported through 'hwmon' interface: 'hwmon' 'pwm' attribute is -+ * used for setting low limit for fan speed in case 'thermal' subsystem is configured in -+ * kernel. In this case setting fan speed through 'hwmon' will never let the 'thermal' -+ * subsystem to select a lower duty cycle than the duty cycle selected with the 'pwm' -+ * attribute. -+ * From other side, fan speed is to be updated in hardware through 'pwm' only in case the -+ * requested fan speed is above last speed set by 'thermal' subsystem, otherwise requested fan -+ * speed will be just stored with no PWM update. -+ */ -+struct emc2305_cdev_data { -+ struct thermal_cooling_device *cdev; -+ unsigned int cur_state; -+ unsigned long last_hwmon_state; -+ unsigned long last_thermal_state; -+}; -+ -+/** -+ * @client: i2c client; -+ * @hwmon_dev: hwmon device; -+ * @max_state: maximum cooling state of the cooling device; -+ * @pwm_num: number of PWM channels; -+ * @pwm_separate: separate PWM settings for every channel; -+ * @pwm_min: array of minimum PWM per channel; -+ * @cdev_data: array of cooling devices data; -+ */ -+struct emc2305_data { -+ struct i2c_client *client; -+ struct device *hwmon_dev; -+ u8 max_state; -+ u8 pwm_num; -+ bool pwm_separate; -+ u8 pwm_min[EMC2305_PWM_MAX]; -+ struct emc2305_cdev_data cdev_data[EMC2305_PWM_MAX]; -+}; -+ -+static char *emc2305_fan_name[] = { -+ "emc2305_fan", -+ "emc2305_fan1", -+ "emc2305_fan2", -+ "emc2305_fan3", -+ "emc2305_fan4", -+ "emc2305_fan5", -+}; -+ -+static void emc2305_unset_tz(struct device *dev); -+ -+static int emc2305_get_max_channel(const struct emc2305_data *data) -+{ -+ return data->pwm_num; -+} -+ -+static int emc2305_get_cdev_idx(struct thermal_cooling_device *cdev) -+{ -+ struct emc2305_data *data = cdev->devdata; -+ size_t len = strlen(cdev->type); -+ int ret; -+ -+ if (len <= 0) -+ return -EINVAL; -+ -+ /* -+ * Returns index of cooling device 0..4 in case of separate PWM setting. -+ * Zero index is used in case of one common PWM setting. -+ * If the mode is not set as pwm_separate, all PWMs are to be bound -+ * to the common thermal zone and should work at the same speed -+ * to perform cooling for the same thermal junction. -+ * Otherwise, return specific channel that will be used in bound -+ * related PWM to the thermal zone. -+ */ -+ if (!data->pwm_separate) -+ return 0; -+ -+ ret = cdev->type[len - 1]; -+ switch (ret) { -+ case '1' ... '5': -+ return ret - '1'; -+ default: -+ break; -+ } -+ return -EINVAL; -+} -+ -+static int emc2305_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *state) -+{ -+ int cdev_idx; -+ struct emc2305_data *data = cdev->devdata; -+ -+ cdev_idx = emc2305_get_cdev_idx(cdev); -+ if (cdev_idx < 0) -+ return cdev_idx; -+ -+ *state = data->cdev_data[cdev_idx].cur_state; -+ return 0; -+} -+ -+static int emc2305_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state) -+{ -+ struct emc2305_data *data = cdev->devdata; -+ *state = data->max_state; -+ return 0; -+} -+ -+static int emc2305_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) -+{ -+ int cdev_idx, ret; -+ struct emc2305_data *data = cdev->devdata; -+ struct i2c_client *client = data->client; -+ u8 val, i; -+ -+ if (state > data->max_state) -+ return -EINVAL; -+ -+ cdev_idx = emc2305_get_cdev_idx(cdev); -+ if (cdev_idx < 0) -+ return cdev_idx; -+ -+ /* Save thermal state. */ -+ data->cdev_data[cdev_idx].last_thermal_state = state; -+ state = max_t(unsigned long, state, data->cdev_data[cdev_idx].last_hwmon_state); -+ -+ val = EMC2305_PWM_STATE2DUTY(state, data->max_state, EMC2305_FAN_MAX); -+ if (val > EMC2305_FAN_MAX) -+ return -EINVAL; -+ -+ data->cdev_data[cdev_idx].cur_state = state; -+ if (data->pwm_separate) { -+ ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_DRIVE(cdev_idx), val); -+ if (ret < 0) -+ return ret; -+ } else { -+ /* -+ * Set the same PWM value in all channels -+ * if common PWM channel is used. -+ */ -+ for (i = 0; i < data->pwm_num; i++) { -+ ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_DRIVE(i), val); -+ if (ret < 0) -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static const struct thermal_cooling_device_ops emc2305_cooling_ops = { -+ .get_max_state = emc2305_get_max_state, -+ .get_cur_state = emc2305_get_cur_state, -+ .set_cur_state = emc2305_set_cur_state, -+}; -+ -+static int emc2305_show_fault(struct device *dev, int channel) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ struct i2c_client *client = data->client; -+ int status_reg; -+ -+ status_reg = i2c_smbus_read_byte_data(client, EMC2305_REG_DRIVE_FAIL_STATUS); -+ if (status_reg < 0) -+ return status_reg; -+ -+ return status_reg & (1 << channel) ? 1 : 0; -+} -+ -+static int emc2305_show_fan(struct device *dev, int channel) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ struct i2c_client *client = data->client; -+ int ret; -+ -+ ret = i2c_smbus_read_word_swapped(client, EMC2305_REG_FAN_TACH(channel)); -+ if (ret <= 0) -+ return ret; -+ -+ ret = ret >> EMC2305_TACH_REGS_UNUSE_BITS; -+ ret = EMC2305_RPM_FACTOR / ret; -+ if (ret <= EMC2305_TACH_RANGE_MIN) -+ return 0; -+ -+ return ret * EMC2305_TACH_CNT_MULTIPLIER; -+} -+ -+static int emc2305_show_pwm(struct device *dev, int channel) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ struct i2c_client *client = data->client; -+ -+ return i2c_smbus_read_byte_data(client, EMC2305_REG_FAN_DRIVE(channel)); -+} -+ -+static int emc2305_set_pwm(struct device *dev, long val, int channel) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ struct i2c_client *client = data->client; -+ int ret; -+ -+ if (val < data->pwm_min[channel] || val > EMC2305_FAN_MAX) -+ return -EINVAL; -+ -+ ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_DRIVE(channel), val); -+ if (ret < 0) -+ return ret; -+ data->cdev_data[channel].cur_state = EMC2305_PWM_DUTY2STATE(val, data->max_state, -+ EMC2305_FAN_MAX); -+ return 0; -+} -+ -+static int emc2305_set_single_tz(struct device *dev, int idx) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ long pwm; -+ int i, cdev_idx, ret; -+ -+ cdev_idx = (idx) ? idx - 1 : 0; -+ pwm = data->pwm_min[cdev_idx]; -+ -+ data->cdev_data[cdev_idx].cdev = -+ thermal_cooling_device_register(emc2305_fan_name[idx], data, -+ &emc2305_cooling_ops); -+ -+ if (IS_ERR(data->cdev_data[cdev_idx].cdev)) { -+ dev_err(dev, "Failed to register cooling device %s\n", emc2305_fan_name[idx]); -+ return PTR_ERR(data->cdev_data[cdev_idx].cdev); -+ } -+ /* Set minimal PWM speed. */ -+ if (data->pwm_separate) { -+ ret = emc2305_set_pwm(dev, pwm, cdev_idx); -+ if (ret < 0) -+ return ret; -+ } else { -+ for (i = 0; i < data->pwm_num; i++) { -+ ret = emc2305_set_pwm(dev, pwm, i); -+ if (ret < 0) -+ return ret; -+ } -+ } -+ data->cdev_data[cdev_idx].cur_state = -+ EMC2305_PWM_DUTY2STATE(data->pwm_min[cdev_idx], data->max_state, -+ EMC2305_FAN_MAX); -+ data->cdev_data[cdev_idx].last_hwmon_state = -+ EMC2305_PWM_DUTY2STATE(data->pwm_min[cdev_idx], data->max_state, -+ EMC2305_FAN_MAX); -+ return 0; -+} -+ -+static int emc2305_set_tz(struct device *dev) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ int i, ret; -+ -+ if (!data->pwm_separate) -+ return emc2305_set_single_tz(dev, 0); -+ -+ for (i = 0; i < data->pwm_num; i++) { -+ ret = emc2305_set_single_tz(dev, i + 1); -+ if (ret) -+ goto thermal_cooling_device_register_fail; -+ } -+ return 0; -+ -+thermal_cooling_device_register_fail: -+ emc2305_unset_tz(dev); -+ return ret; -+} -+ -+static void emc2305_unset_tz(struct device *dev) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ int i; -+ -+ /* Unregister cooling device. */ -+ for (i = 0; i < EMC2305_PWM_MAX; i++) -+ if (data->cdev_data[i].cdev) -+ thermal_cooling_device_unregister(data->cdev_data[i].cdev); -+} -+ -+static umode_t -+emc2305_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel) -+{ -+ int max_channel = emc2305_get_max_channel(data); -+ -+ /* Don't show channels which are not physically connected. */ -+ if (channel >= max_channel) -+ return 0; -+ switch (type) { -+ case hwmon_fan: -+ switch (attr) { -+ case hwmon_fan_input: -+ return 0444; -+ case hwmon_fan_fault: -+ return 0444; -+ default: -+ break; -+ } -+ break; -+ case hwmon_pwm: -+ switch (attr) { -+ case hwmon_pwm_input: -+ return 0644; -+ default: -+ break; -+ } -+ break; -+ default: -+ break; -+ } -+ -+ return 0; -+}; -+ -+static int -+emc2305_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long val) -+{ -+ struct emc2305_data *data = dev_get_drvdata(dev); -+ int cdev_idx; -+ -+ switch (type) { -+ case hwmon_pwm: -+ switch (attr) { -+ case hwmon_pwm_input: -+ /* If thermal is configured - handle PWM limit setting. */ -+ if (IS_REACHABLE(CONFIG_THERMAL)) { -+ if (data->pwm_separate) -+ cdev_idx = channel; -+ else -+ cdev_idx = 0; -+ data->cdev_data[cdev_idx].last_hwmon_state = -+ EMC2305_PWM_DUTY2STATE(val, data->max_state, -+ EMC2305_FAN_MAX); -+ /* -+ * Update PWM only in case requested state is not less than the -+ * last thermal state. -+ */ -+ if (data->cdev_data[cdev_idx].last_hwmon_state >= -+ data->cdev_data[cdev_idx].last_thermal_state) -+ return emc2305_set_cur_state(data->cdev_data[cdev_idx].cdev, -+ data->cdev_data[cdev_idx].last_hwmon_state); -+ return 0; -+ } -+ return emc2305_set_pwm(dev, val, channel); -+ default: -+ break; -+ } -+ break; -+ default: -+ break; -+ } -+ -+ return -EOPNOTSUPP; -+}; -+ -+static int -+emc2305_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) -+{ -+ int ret; -+ -+ switch (type) { -+ case hwmon_fan: -+ switch (attr) { -+ case hwmon_fan_input: -+ ret = emc2305_show_fan(dev, channel); -+ if (ret < 0) -+ return ret; -+ *val = ret; -+ return 0; -+ case hwmon_fan_fault: -+ ret = emc2305_show_fault(dev, channel); -+ if (ret < 0) -+ return ret; -+ *val = ret; -+ return 0; -+ default: -+ break; -+ } -+ break; -+ case hwmon_pwm: -+ switch (attr) { -+ case hwmon_pwm_input: -+ ret = emc2305_show_pwm(dev, channel); -+ if (ret < 0) -+ return ret; -+ *val = ret; -+ return 0; -+ default: -+ break; -+ } -+ break; -+ default: -+ break; -+ } -+ -+ return -EOPNOTSUPP; -+}; -+ -+static const struct hwmon_ops emc2305_ops = { -+ .is_visible = emc2305_is_visible, -+ .read = emc2305_read, -+ .write = emc2305_write, -+}; -+ -+static const struct hwmon_channel_info *emc2305_info[] = { -+ HWMON_CHANNEL_INFO(fan, -+ HWMON_F_INPUT | HWMON_F_FAULT, -+ HWMON_F_INPUT | HWMON_F_FAULT, -+ HWMON_F_INPUT | HWMON_F_FAULT, -+ HWMON_F_INPUT | HWMON_F_FAULT, -+ HWMON_F_INPUT | HWMON_F_FAULT), -+ HWMON_CHANNEL_INFO(pwm, -+ HWMON_PWM_INPUT, -+ HWMON_PWM_INPUT, -+ HWMON_PWM_INPUT, -+ HWMON_PWM_INPUT, -+ HWMON_PWM_INPUT), -+ NULL -+}; -+ -+static const struct hwmon_chip_info emc2305_chip_info = { -+ .ops = &emc2305_ops, -+ .info = emc2305_info, -+}; -+ -+static int emc2305_identify(struct device *dev) -+{ -+ struct i2c_client *client = to_i2c_client(dev); -+ struct emc2305_data *data = i2c_get_clientdata(client); -+ int ret; -+ -+ ret = i2c_smbus_read_byte_data(client, EMC2305_REG_PRODUCT_ID); -+ if (ret < 0) -+ return ret; -+ -+ switch (ret) { -+ case EMC2305: -+ data->pwm_num = 5; -+ break; -+ case EMC2303: -+ data->pwm_num = 3; -+ break; -+ case EMC2302: -+ data->pwm_num = 2; -+ break; -+ case EMC2301: -+ data->pwm_num = 1; -+ break; -+ default: -+ return -ENODEV; -+ } -+ -+ return 0; -+} -+ -+static int emc2305_probe(struct i2c_client *client, const struct i2c_device_id *id) -+{ -+ struct i2c_adapter *adapter = client->adapter; -+ struct device *dev = &client->dev; -+ struct emc2305_data *data; -+ struct emc2305_platform_data *pdata; -+ int vendor, device; -+ int ret; -+ int i; -+ -+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) -+ return -ENODEV; -+ -+ vendor = i2c_smbus_read_byte_data(client, EMC2305_REG_VENDOR); -+ if (vendor != EMC2305_VENDOR) -+ return -ENODEV; -+ -+ device = i2c_smbus_read_byte_data(client, EMC2305_REG_DEVICE); -+ if (device != EMC2305_DEVICE) -+ return -ENODEV; -+ -+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); -+ if (!data) -+ return -ENOMEM; -+ -+ i2c_set_clientdata(client, data); -+ data->client = client; -+ -+ ret = emc2305_identify(dev); -+ if (ret) -+ return ret; -+ -+ pdata = dev_get_platdata(&client->dev); -+ if (pdata) { -+ if (!pdata->max_state || pdata->max_state > EMC2305_FAN_MAX_STATE) -+ return -EINVAL; -+ data->max_state = pdata->max_state; -+ /* -+ * Validate a number of active PWM channels. Note that -+ * configured number can be less than the actual maximum -+ * supported by the device. -+ */ -+ if (!pdata->pwm_num || pdata->pwm_num > EMC2305_PWM_MAX) -+ return -EINVAL; -+ data->pwm_num = pdata->pwm_num; -+ data->pwm_separate = pdata->pwm_separate; -+ for (i = 0; i < EMC2305_PWM_MAX; i++) -+ data->pwm_min[i] = pdata->pwm_min[i]; -+ } else { -+ data->max_state = EMC2305_FAN_MAX_STATE; -+ data->pwm_separate = false; -+ for (i = 0; i < EMC2305_PWM_MAX; i++) -+ data->pwm_min[i] = EMC2305_FAN_MIN; -+ } -+ -+ data->hwmon_dev = devm_hwmon_device_register_with_info(dev, "emc2305", data, -+ &emc2305_chip_info, NULL); -+ if (IS_ERR(data->hwmon_dev)) -+ return PTR_ERR(data->hwmon_dev); -+ -+ if (IS_REACHABLE(CONFIG_THERMAL)) { -+ ret = emc2305_set_tz(dev); -+ if (ret != 0) -+ return ret; -+ } -+ -+ for (i = 0; i < data->pwm_num; i++) { -+ ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_MIN_DRIVE(i), -+ data->pwm_min[i]); -+ if (ret < 0) -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int emc2305_remove(struct i2c_client *client) -+{ -+ struct device *dev = &client->dev; -+ -+ if (IS_REACHABLE(CONFIG_THERMAL)) -+ emc2305_unset_tz(dev); -+ return 0; -+} -+ -+static struct i2c_driver emc2305_driver = { -+ .class = I2C_CLASS_HWMON, -+ .driver = { -+ .name = "emc2305", -+ }, -+ .probe = emc2305_probe, -+ .remove = emc2305_remove, -+ .id_table = emc2305_ids, -+ .address_list = emc2305_normal_i2c, -+}; -+ -+module_i2c_driver(emc2305_driver); -+ -+MODULE_AUTHOR("Nvidia"); -+MODULE_DESCRIPTION("Microchip EMC2305 fan controller driver"); -+MODULE_LICENSE("GPL"); --- -2.41.0 - -From 4529b11c5f419b1bf815ddada94898867f2729a8 Mon Sep 17 00:00:00 2001 -From: Jiapeng Chong -Date: Thu, 1 Sep 2022 10:23:32 +0800 -Subject: [PATCH 3/8] hwmon: (emc2305) Remove unused including - - -./drivers/hwmon/emc2305.c: 14 linux/version.h not needed. - -Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2024 -Reported-by: Abaci Robot -Signed-off-by: Jiapeng Chong -Link: https://lore.kernel.org/r/20220901022332.40248-1-jiapeng.chong@linux.alibaba.com -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/emc2305.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -index 9f6546ea3d69..ee5ed24feab5 100644 ---- a/drivers/hwmon/emc2305.c -+++ b/drivers/hwmon/emc2305.c -@@ -11,7 +11,6 @@ - #include - #include - #include --#include - - static const unsigned short - emc2305_normal_i2c[] = { 0x27, 0x2c, 0x2d, 0x2e, 0x2f, 0x4c, 0x4d, I2C_CLIENT_END }; --- -2.41.0 - -From 2cc00885521764f2aa7a17b466c7123ce4c3caf8 Mon Sep 17 00:00:00 2001 -From: Guenter Roeck -Date: Wed, 14 Sep 2022 03:20:56 -0700 -Subject: [PATCH 4/8] hwmon: (emc2305) Remove unnecessary range check - -Static analyzers report: - -drivers/hwmon/emc2305.c:194 emc2305_set_cur_state() - warn: impossible condition '(val > 255) => (0-255 > 255)' - -'val' is u8 and thus can never be larger than 255. In theory -the operation calculating 'val' could result in a value larger -than 255, but this won't happen because its parameter has already -been range checked and it is guaranteed that the result never exceeds -255. Remove the unnecessary value check. - -Cc: Michael Shych -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/emc2305.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -index ee5ed24feab5..bb32172e07e3 100644 ---- a/drivers/hwmon/emc2305.c -+++ b/drivers/hwmon/emc2305.c -@@ -191,8 +191,6 @@ static int emc2305_set_cur_state(struct thermal_cooling_device *cdev, unsigned l - state = max_t(unsigned long, state, data->cdev_data[cdev_idx].last_hwmon_state); - - val = EMC2305_PWM_STATE2DUTY(state, data->max_state, EMC2305_FAN_MAX); -- if (val > EMC2305_FAN_MAX) -- return -EINVAL; - - data->cdev_data[cdev_idx].cur_state = state; - if (data->pwm_separate) { --- -2.41.0 - -From 459c71570e04472fb47a20c1654404b9a7e8d8d9 Mon Sep 17 00:00:00 2001 -From: Xingjiang Qiao -Date: Tue, 6 Dec 2022 13:53:30 +0800 -Subject: [PATCH 5/8] hwmon: (emc2305) fix unable to probe emc2301/2/3 - -The definitions of 'EMC2305_REG_PRODUCT_ID' and 'EMC2305_REG_DEVICE' are -both '0xfd', they actually return the same value, but the values returned -by emc2301/2/3/5 are different, so probe emc2301/2/3 will fail, This patch -fixes that. - -Signed-off-by: Xingjiang Qiao -Link: https://lore.kernel.org/r/20221206055331.170459-1-nanpuyue@gmail.com -Fixes: 0d8400c5a2ce1 ("hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller.") -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/emc2305.c | 7 +------ - 1 file changed, 1 insertion(+), 6 deletions(-) - -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -index bb32172e07e3..b28a4e80fc92 100644 ---- a/drivers/hwmon/emc2305.c -+++ b/drivers/hwmon/emc2305.c -@@ -16,7 +16,6 @@ static const unsigned short - emc2305_normal_i2c[] = { 0x27, 0x2c, 0x2d, 0x2e, 0x2f, 0x4c, 0x4d, I2C_CLIENT_END }; - - #define EMC2305_REG_DRIVE_FAIL_STATUS 0x27 --#define EMC2305_REG_DEVICE 0xfd - #define EMC2305_REG_VENDOR 0xfe - #define EMC2305_FAN_MAX 0xff - #define EMC2305_FAN_MIN 0x00 -@@ -524,7 +523,7 @@ static int emc2305_probe(struct i2c_client *client, const struct i2c_device_id * - struct device *dev = &client->dev; - struct emc2305_data *data; - struct emc2305_platform_data *pdata; -- int vendor, device; -+ int vendor; - int ret; - int i; - -@@ -535,10 +534,6 @@ static int emc2305_probe(struct i2c_client *client, const struct i2c_device_id * - if (vendor != EMC2305_VENDOR) - return -ENODEV; - -- device = i2c_smbus_read_byte_data(client, EMC2305_REG_DEVICE); -- if (device != EMC2305_DEVICE) -- return -ENODEV; -- - data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; --- -2.41.0 - -From 291ebc0b119b4fdf6a39059c7154a2436a71efeb Mon Sep 17 00:00:00 2001 -From: Xingjiang Qiao -Date: Tue, 6 Dec 2022 13:53:31 +0800 -Subject: [PATCH 6/8] hwmon: (emc2305) fix pwm never being able to set lower - -There are fields 'last_hwmon_state' and 'last_thermal_state' in the -structure 'emc2305_cdev_data', which respectively store the cooling state -set by the 'hwmon' and 'thermal' subsystem, and the driver author hopes -that if the state set by 'hwmon' is lower than the value set by 'thermal', -the driver will just save it without actually setting the pwm. Currently, -the 'last_thermal_state' also be updated by 'hwmon', which will cause the -cooling state to never be set to a lower value. This patch fixes that. - -Signed-off-by: Xingjiang Qiao -Link: https://lore.kernel.org/r/20221206055331.170459-2-nanpuyue@gmail.com -Fixes: 0d8400c5a2ce1 ("hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller.") -[groeck: renamed emc2305_set_cur_state_shim -> __emc2305_set_cur_state] -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/emc2305.c | 37 ++++++++++++++++++++++++------------- - 1 file changed, 24 insertions(+), 13 deletions(-) - -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -index b28a4e80fc92..9eaaf8fc5512 100644 ---- a/drivers/hwmon/emc2305.c -+++ b/drivers/hwmon/emc2305.c -@@ -171,22 +171,12 @@ static int emc2305_get_max_state(struct thermal_cooling_device *cdev, unsigned l - return 0; - } - --static int emc2305_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) -+static int __emc2305_set_cur_state(struct emc2305_data *data, int cdev_idx, unsigned long state) - { -- int cdev_idx, ret; -- struct emc2305_data *data = cdev->devdata; -+ int ret; - struct i2c_client *client = data->client; - u8 val, i; - -- if (state > data->max_state) -- return -EINVAL; -- -- cdev_idx = emc2305_get_cdev_idx(cdev); -- if (cdev_idx < 0) -- return cdev_idx; -- -- /* Save thermal state. */ -- data->cdev_data[cdev_idx].last_thermal_state = state; - state = max_t(unsigned long, state, data->cdev_data[cdev_idx].last_hwmon_state); - - val = EMC2305_PWM_STATE2DUTY(state, data->max_state, EMC2305_FAN_MAX); -@@ -211,6 +201,27 @@ static int emc2305_set_cur_state(struct thermal_cooling_device *cdev, unsigned l - return 0; - } - -+static int emc2305_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) -+{ -+ int cdev_idx, ret; -+ struct emc2305_data *data = cdev->devdata; -+ -+ if (state > data->max_state) -+ return -EINVAL; -+ -+ cdev_idx = emc2305_get_cdev_idx(cdev); -+ if (cdev_idx < 0) -+ return cdev_idx; -+ -+ /* Save thermal state. */ -+ data->cdev_data[cdev_idx].last_thermal_state = state; -+ ret = __emc2305_set_cur_state(data, cdev_idx, state); -+ if (ret < 0) -+ return ret; -+ -+ return 0; -+} -+ - static const struct thermal_cooling_device_ops emc2305_cooling_ops = { - .get_max_state = emc2305_get_max_state, - .get_cur_state = emc2305_get_cur_state, -@@ -401,7 +412,7 @@ emc2305_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int ch - */ - if (data->cdev_data[cdev_idx].last_hwmon_state >= - data->cdev_data[cdev_idx].last_thermal_state) -- return emc2305_set_cur_state(data->cdev_data[cdev_idx].cdev, -+ return __emc2305_set_cur_state(data, cdev_idx, - data->cdev_data[cdev_idx].last_hwmon_state); - return 0; - } --- -2.41.0 - -From 2d8f8c4d5980d86cef24974b5f623df47915f053 Mon Sep 17 00:00:00 2001 -From: Randy Dunlap -Date: Thu, 12 Jan 2023 22:45:40 -0800 -Subject: [PATCH 7/8] hwmon: (emc2305) fix kernel-doc warnings - -Fix kernel-doc warnings: -drivers/hwmon/emc2305.c:62: warning: Cannot understand * @cdev: cooling device; - on line 62 - I thought it was a doc line -drivers/hwmon/emc2305.c:89: warning: Cannot understand * @client: i2c client; - on line 89 - I thought it was a doc line - -and drop ';' at end of each struct member line. - -Signed-off-by: Randy Dunlap -Cc: Jean Delvare -Cc: Guenter Roeck -Cc: linux-hwmon@vger.kernel.org -Link: https://lore.kernel.org/r/20230113064540.20179-1-rdunlap@infradead.org -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/emc2305.c | 24 +++++++++++++----------- - 1 file changed, 13 insertions(+), 11 deletions(-) - -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -index 9eaaf8fc5512..1ca9cf30c82d 100644 ---- a/drivers/hwmon/emc2305.c -+++ b/drivers/hwmon/emc2305.c -@@ -59,10 +59,11 @@ static const struct i2c_device_id emc2305_ids[] = { - MODULE_DEVICE_TABLE(i2c, emc2305_ids); - - /** -- * @cdev: cooling device; -- * @curr_state: cooling current state; -- * @last_hwmon_state: last cooling state updated by hwmon subsystem; -- * @last_thermal_state: last cooling state updated by thermal subsystem; -+ * struct emc2305_cdev_data - device-specific cooling device state -+ * @cdev: cooling device -+ * @cur_state: cooling current state -+ * @last_hwmon_state: last cooling state updated by hwmon subsystem -+ * @last_thermal_state: last cooling state updated by thermal subsystem - * - * The 'last_hwmon_state' and 'last_thermal_state' fields are provided to support fan low limit - * speed feature. The purpose of this feature is to provides ability to limit fan speed -@@ -86,13 +87,14 @@ struct emc2305_cdev_data { - }; - - /** -- * @client: i2c client; -- * @hwmon_dev: hwmon device; -- * @max_state: maximum cooling state of the cooling device; -- * @pwm_num: number of PWM channels; -- * @pwm_separate: separate PWM settings for every channel; -- * @pwm_min: array of minimum PWM per channel; -- * @cdev_data: array of cooling devices data; -+ * struct emc2305_data - device-specific data -+ * @client: i2c client -+ * @hwmon_dev: hwmon device -+ * @max_state: maximum cooling state of the cooling device -+ * @pwm_num: number of PWM channels -+ * @pwm_separate: separate PWM settings for every channel -+ * @pwm_min: array of minimum PWM per channel -+ * @cdev_data: array of cooling devices data - */ - struct emc2305_data { - struct i2c_client *client; --- -2.41.0 - -From 157c607e3a630e9ebe0a51e87c9fa75dd3b85e9c Mon Sep 17 00:00:00 2001 -From: Krzysztof Kozlowski -Date: Thu, 6 Apr 2023 22:30:10 +0200 -Subject: [PATCH 8/8] hwmon: emc2305: constify pointers to hwmon_channel_info - -Statically allocated array of pointed to hwmon_channel_info can be made -const for safety. - -Signed-off-by: Krzysztof Kozlowski -Signed-off-by: Guenter Roeck ---- - drivers/hwmon/emc2305.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c -index 1ca9cf30c82d..74f0461c32e2 100644 ---- a/drivers/hwmon/emc2305.c -+++ b/drivers/hwmon/emc2305.c -@@ -479,7 +479,7 @@ static const struct hwmon_ops emc2305_ops = { - .write = emc2305_write, - }; - --static const struct hwmon_channel_info *emc2305_info[] = { -+static const struct hwmon_channel_info * const emc2305_info[] = { - HWMON_CHANNEL_INFO(fan, - HWMON_F_INPUT | HWMON_F_FAULT, - HWMON_F_INPUT | HWMON_F_FAULT, --- -2.41.0 - From 2e74886a786725dfbf011853353c449b0488fc74 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Feb 2024 15:34:49 -0800 Subject: [PATCH 3/9] linux: renumber ttyS# devices to a more intuitive order New mapping: ttyS0: BMC serial console ttyS1-4: Serial connection to node 1-4 Closes #181 --- .../tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts | 12 ++++++------ tp2bmc/configs/tp2bmc_defconfig | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts index 53275338..a0f8bde2 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts @@ -21,16 +21,16 @@ aliases { ethernet0 = &emac; - serial1 = &uart1; - serial2 = &uart2; - serial3 = &uart3; - serial4 = &uart4; - serial5 = &uart5; + serial0 = &uart3; + serial1 = &uart2; + serial2 = &uart1; + serial3 = &uart4; + serial4 = &uart5; flash0 = &flash0; }; chosen { - stdout-path = "serial3:115200n8"; + stdout-path = "serial0:115200n8"; }; // The LEDs are actually GPIO lines that go to the front-panel LEDs. diff --git a/tp2bmc/configs/tp2bmc_defconfig b/tp2bmc/configs/tp2bmc_defconfig index 35dc65b0..8abced12 100644 --- a/tp2bmc/configs/tp2bmc_defconfig +++ b/tp2bmc/configs/tp2bmc_defconfig @@ -7,7 +7,7 @@ BR2_ARM_EABI=y BR2_TARGET_GENERIC_HOSTNAME="turingpi" BR2_TARGET_GENERIC_ISSUE="Welcome to Turing Pi" BR2_TARGET_GENERIC_ROOT_PASSWD="turing" -BR2_TARGET_GENERIC_GETTY_PORT="ttyS3" +BR2_TARGET_GENERIC_GETTY_PORT="ttyS0" BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y BR2_SYSTEM_DHCP="eth0" BR2_INIT_SYSV=y From c9f91c9d6b8d85cf2710c35eaa17d5a6c859fe4d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Feb 2024 16:07:21 -0800 Subject: [PATCH 4/9] devicetree: split apart into versions for 2.4 and 2.5 --- tp2bmc/board/tp2bmc/boot.scr | 2 +- tp2bmc/board/tp2bmc/install.scr | 2 +- .../board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts | 14 ++++++++++++++ .../board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts | 14 ++++++++++++++ ...nes-tp2-bmc.dts => sun8i-t113s-turing-pi2.dtsi} | 5 ----- tp2bmc/board/tp2bmc/uboot_defconfig | 2 +- tp2bmc/configs/tp2bmc_defconfig | 4 ++-- 7 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts create mode 100644 tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts rename tp2bmc/board/tp2bmc/{sun8i-t113s-turingmachines-tp2-bmc.dts => sun8i-t113s-turing-pi2.dtsi} (98%) diff --git a/tp2bmc/board/tp2bmc/boot.scr b/tp2bmc/board/tp2bmc/boot.scr index ed67026f..2f5a73e1 100644 --- a/tp2bmc/board/tp2bmc/boot.scr +++ b/tp2bmc/board/tp2bmc/boot.scr @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ # Copyright (C) 2023 Sam Edwards -fdt_filename="sun8i-t113s-turingmachines-tp2-bmc.dtb" +fdt_filename="sun8i-t113s-turing-pi2-${tpi2_version:-v2.4}.dtb" # Set bootargs: setenv bootargs loglevel=8 cma=8M init=/sbin/preinit rootwait=5 diff --git a/tp2bmc/board/tp2bmc/install.scr b/tp2bmc/board/tp2bmc/install.scr index 59a4d74b..29fb3294 100644 --- a/tp2bmc/board/tp2bmc/install.scr +++ b/tp2bmc/board/tp2bmc/install.scr @@ -12,7 +12,7 @@ if test "${bootmode}" != "safemode"; then if test -e ${devtype} ${devnum}:${distro_bootpart} ${installer_marker}; then echo ...exists: entering installer - fdt_filename="sun8i-t113s-turingmachines-tp2-bmc.dtb" + fdt_filename="sun8i-t113s-turing-pi2-${tpi2_version:-v2.4}.dtb" linux_bootpart=2 # Load image, initramfs, and FDT diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts new file mode 100644 index 00000000..6dcd8a0b --- /dev/null +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +// Copyright (C) 2024 Sam Edwards + +/dts-v1/; +#include "sun8i-t113s-turing-pi2.dtsi" + +/ { + model = "Turing Pi 2 (v2.4)"; + compatible = "turing,pi2", "allwinner,sun8i-t113s"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts new file mode 100644 index 00000000..e49bb2fe --- /dev/null +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +// Copyright (C) 2024 Sam Edwards + +/dts-v1/; +#include "sun8i-t113s-turing-pi2.dtsi" + +/ { + model = "Turing Pi 2 (v2.5)"; + compatible = "turing,pi2", "allwinner,sun8i-t113s"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi similarity index 98% rename from tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts rename to tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi index a0f8bde2..36ee9967 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi @@ -16,7 +16,6 @@ #include / { - model = "Turing Pi 2"; compatible = "turing,pi2", "allwinner,sun8i-t113s"; aliases { @@ -29,10 +28,6 @@ flash0 = &flash0; }; - chosen { - stdout-path = "serial0:115200n8"; - }; - // The LEDs are actually GPIO lines that go to the front-panel LEDs. leds { compatible = "gpio-leds"; diff --git a/tp2bmc/board/tp2bmc/uboot_defconfig b/tp2bmc/board/tp2bmc/uboot_defconfig index 35b062d5..47101fc8 100644 --- a/tp2bmc/board/tp2bmc/uboot_defconfig +++ b/tp2bmc/board/tp2bmc/uboot_defconfig @@ -1,6 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_SUNXI=y -CONFIG_DEFAULT_DEVICE_TREE="sun8i-t113s-turingmachines-tp2-bmc" +CONFIG_DEFAULT_DEVICE_TREE="sun8i-t113s-turing-pi2-v2.4" CONFIG_SPL=y CONFIG_IDENT_STRING=" Turing Machines, Inc." CONFIG_MACH_SUN8I_R528=y diff --git a/tp2bmc/configs/tp2bmc_defconfig b/tp2bmc/configs/tp2bmc_defconfig index 8abced12..2e9deb74 100644 --- a/tp2bmc/configs/tp2bmc_defconfig +++ b/tp2bmc/configs/tp2bmc_defconfig @@ -23,7 +23,7 @@ BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_TP2BMC_PATH)/patches/linux" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/linux_defconfig" BR2_LINUX_KERNEL_DTS_SUPPORT=y -BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts" +BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi $(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts $(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts" BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME=y BR2_LINUX_KERNEL_INSTALL_TARGET=y BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y @@ -53,7 +53,7 @@ BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y BR2_TARGET_UBOOT_NEEDS_OPENSSL=y BR2_TARGET_UBOOT_FORMAT_CUSTOM=y BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-sunxi-with-spl.bin" -BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turingmachines-tp2-bmc.dts" +BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi $(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts $(BR2_EXTERNAL_TP2BMC_PATH)/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts" # Host packages BR2_PACKAGE_HOST_DOSFSTOOLS=y From 50caee9c84f9ee0b0b119f7ae298075a515e2a7c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 5 Feb 2024 17:33:07 -0800 Subject: [PATCH 5/9] devicetree: add gpio-latch and node power/GPIO defs for v2.5 --- tp2bmc/board/tp2bmc/linux_defconfig | 1 + .../tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts | 135 ++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/tp2bmc/board/tp2bmc/linux_defconfig b/tp2bmc/board/tp2bmc/linux_defconfig index d9f35468..e946f781 100644 --- a/tp2bmc/board/tp2bmc/linux_defconfig +++ b/tp2bmc/board/tp2bmc/linux_defconfig @@ -143,6 +143,7 @@ CONFIG_SPI_SPIDEV=y # CONFIG_PINCTRL_SUN8I_H3_R is not set # CONFIG_PINCTRL_SUN8I_V3S is not set CONFIG_GPIO_AGGREGATOR=y +CONFIG_GPIO_LATCH=y CONFIG_POWER_SUPPLY=y CONFIG_SENSORS_EMC2305=y CONFIG_SUN8I_THERMAL=y diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts index e49bb2fe..ea7ecffc 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts @@ -11,4 +11,139 @@ chosen { stdout-path = "serial0:115200n8"; }; + + gpio_latch: gpio-latch { + #gpio-cells = <2>; + compatible = "gpio-latch"; + gpio-controller; + setup-duration-ns = <5>; + clock-duration-ns = <5>; + + clk-gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ + latched-gpios = <&pio 3 3 GPIO_ACTIVE_HIGH>, /* PD3 */ + <&pio 3 4 GPIO_ACTIVE_HIGH>, /* PD4 */ + <&pio 3 5 GPIO_ACTIVE_HIGH>, /* PD5 */ + <&pio 3 6 GPIO_ACTIVE_HIGH>, /* PD6 */ + <&pio 3 7 GPIO_ACTIVE_HIGH>, /* PD7 */ + <&pio 3 8 GPIO_ACTIVE_HIGH>, /* PD8 */ + <&pio 3 9 GPIO_ACTIVE_HIGH>, /* PD9 */ + <&pio 3 10 GPIO_ACTIVE_HIGH>, /* PD10 */ + <&pio 3 11 GPIO_ACTIVE_HIGH>; /* PD11 */ + }; + + nodes { + #gpio-cells = <2>; + compatible = "turing,pi2-nodes"; + gpio-controller; + + gpios = <&gpio_latch 8 GPIO_ACTIVE_LOW>, /* node 1 */ + <&pio 3 19 GPIO_ACTIVE_HIGH>, /* PD19 */ + <&pio 3 15 GPIO_ACTIVE_LOW>, /* PD15 */ + <&gpio_latch 7 GPIO_ACTIVE_LOW>, /* node 2 */ + <&pio 3 18 GPIO_ACTIVE_HIGH>, /* PD18 */ + <&pio 3 14 GPIO_ACTIVE_LOW>, /* PD14 */ + <&gpio_latch 6 GPIO_ACTIVE_LOW>, /* node 3 */ + <&pio 3 17 GPIO_ACTIVE_HIGH>, /* PD17 */ + <&pio 3 12 GPIO_ACTIVE_LOW>, /* PD12 */ + <&gpio_latch 5 GPIO_ACTIVE_LOW>, /* node 4 */ + <&pio 3 16 GPIO_ACTIVE_HIGH>, /* PD16 */ + <&pio 3 13 GPIO_ACTIVE_LOW>; /* PD13 */ + + gpio-line-names = "node1-en", "node1-usbotg-dev", + "node1-rpiboot", + "node2-en", "node2-usbotg-dev", + "node2-rpiboot", + "node3-en", "node3-usbotg-dev", + "node3-rpiboot", + "node4-en", "node4-usbotg-dev", + "node4-rpiboot"; + }; + + reg_atx_psu: regulator-atx-psu { + compatible = "regulator-fixed"; + + regulator-name = "atx-psu"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + startup-delay-us = <250000>; + + gpio = <&gpio_latch 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + reg_slot1: regulator-slot1 { + compatible = "regulator-fixed"; + + regulator-name = "slot1"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&gpio_latch 4 GPIO_ACTIVE_HIGH>; + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node1-power { + compatible = "regulator-output"; + vout-supply = <®_slot1>; + }; + + reg_slot2: regulator-slot2 { + compatible = "regulator-fixed"; + + regulator-name = "slot2"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&gpio_latch 2 GPIO_ACTIVE_HIGH>; + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node2-power { + compatible = "regulator-output"; + vout-supply = <®_slot2>; + }; + + reg_slot3: regulator-slot3 { + compatible = "regulator-fixed"; + + regulator-name = "slot3"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&gpio_latch 3 GPIO_ACTIVE_HIGH>; + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node3-power { + compatible = "regulator-output"; + vout-supply = <®_slot3>; + }; + + reg_slot4: regulator-slot4 { + compatible = "regulator-fixed"; + + regulator-name = "slot4"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&gpio_latch 1 GPIO_ACTIVE_HIGH>; + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node4-power { + compatible = "regulator-output"; + vout-supply = <®_slot4>; + }; }; From b15c8e49decb230725702e85f9d885518c5e5d93 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 11 Feb 2024 11:20:35 -0800 Subject: [PATCH 6/9] devicetree: linux: implement PWM fan --- tp2bmc/board/tp2bmc/linux_defconfig | 3 + .../tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts | 16 + .../board/tp2bmc/sun8i-t113s-turing-pi2.dtsi | 8 + ...-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch | 959 ++++++++++++++++++ 4 files changed, 986 insertions(+) create mode 100644 tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch diff --git a/tp2bmc/board/tp2bmc/linux_defconfig b/tp2bmc/board/tp2bmc/linux_defconfig index e946f781..d44d1b5c 100644 --- a/tp2bmc/board/tp2bmc/linux_defconfig +++ b/tp2bmc/board/tp2bmc/linux_defconfig @@ -145,6 +145,7 @@ CONFIG_SPI_SPIDEV=y CONFIG_GPIO_AGGREGATOR=y CONFIG_GPIO_LATCH=y CONFIG_POWER_SUPPLY=y +CONFIG_SENSORS_PWM_FAN=y CONFIG_SENSORS_EMC2305=y CONFIG_SUN8I_THERMAL=y CONFIG_WATCHDOG=y @@ -191,6 +192,8 @@ CONFIG_STAGING=y # CONFIG_SUN8I_DE2_CCU is not set # CONFIG_SUN8I_R40_CCU is not set CONFIG_SUN20I_PPU=y +CONFIG_PWM=y +CONFIG_PWM_SUN20I=y CONFIG_PHY_SUN4I_USB=y CONFIG_NVMEM_SUNXI_SID=y CONFIG_EXT4_FS=y diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts index ea7ecffc..737fca46 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts @@ -146,4 +146,20 @@ compatible = "regulator-output"; vout-supply = <®_slot4>; }; + +#ifndef IS_UBOOT + pwm-fan { + compatible = "pwm-fan"; + pinctrl-names = "default"; + pinctrl-0 = <&pwm5_pd_pin>; + pwms = <&pwm 5 50000 0>; + #cooling-cells = <2>; + }; +#endif +}; + +#ifndef IS_UBOOT +&pwm { + status = "okay"; }; +#endif diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi index 36ee9967..0fc95b35 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi @@ -241,6 +241,14 @@ }; }; +&pio { + /omit-if-no-ref/ + pwm5_pd_pin: pwm5-pd-pin { + pins = "PD21"; + function = "pwm5"; + }; +}; + &spi0_pins { pins = "PC2", "PC3", "PC4", "PC5", "PC6", "PC7"; }; diff --git a/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch b/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch new file mode 100644 index 00000000..cb59ba93 --- /dev/null +++ b/tp2bmc/patches/linux/Add-support-for-Allwinner-PWM-on-D1-T113s-R329-SoCs.patch @@ -0,0 +1,959 @@ +From patchwork Wed Jan 31 12:59:14 2024 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Aleksandr Shubin +X-Patchwork-Id: 13539410 +Return-Path: + +X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on + aws-us-west-2-korg-lkml-1.web.codeaurora.org +Received: from bombadil.infradead.org (bombadil.infradead.org + [198.137.202.133]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BEEAC47258 + for ; + Wed, 31 Jan 2024 13:00:05 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; + d=lists.infradead.org; s=bombadil.20210309; h=Sender: + Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: + List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: + Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: + Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: + List-Owner; bh=g1avdJr9EJbJhAmFKWysfcYn65vylVycwGiaX+hUb+o=; b=qJtfaBnCTnBg9f + YZ84ncy3NjfvP6YVQs++N3Xrikv42qq6A+jZvX3dB+8spts2/YuHy9/hD46xKkB/UVV/97W85eRdx + I3v9z0huZmP0ogDJhL6UcTSgX+0yORQyW16fU0FJE8ut0frM4xixzO6IzAEFTXE2OFVJcGxpkyiOa + S1D/ZgzPmLweQhBebygjUNIyfWaeifVx2ivI1BKIXOIAAHhYQerbmdWReNfECOk9BuJ4TY44888cK + YbGK4JqBp1bggdAH0XqDxHQGtC/HJe2aNNzOaRAWs8CUgcK3dINLPDKXUSFNamEuDuSdNXbUnj5f1 + kMUKFRoNwhbDyJrdTcUw==; +Received: from localhost ([::1] helo=bombadil.infradead.org) + by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) + id 1rVAC1-00000003TNy-3ecH; + Wed, 31 Jan 2024 12:59:53 +0000 +Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) + by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) + id 1rVABy-00000003TJP-1XnP; + Wed, 31 Jan 2024 12:59:51 +0000 +Received: by mail-lf1-x135.google.com with SMTP id + 2adb3069b0e04-511207d62b6so2041513e87.1; + Wed, 31 Jan 2024 04:59:48 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=gmail.com; s=20230601; t=1706705987; x=1707310787; + darn=lists.infradead.org; + h=content-transfer-encoding:mime-version:references:in-reply-to + :message-id:date:subject:cc:to:from:from:to:cc:subject:date + :message-id:reply-to; + bh=oAfvNX5JYKiOP5F5+HHWWQpkc2VYumz0VDstxq+2dC0=; + b=CVhEpK0EuUx9RJ9FqqEJVNWrQvaFplEK6S+34FR9Dd/e3HumsXMlt+cdMdLD5dVTwL + Bv4cA3+I11kmI8UOsEyZyFwYScwmYE59DXsOFt/QGdDwo82VfAXV20cw/s2bf5F8Sh7e + J7hdugbWtX8VZoi0RYMCu/nkhkxqOPHaUQ6tOlqIeX7gMaOyphyQs/1dz8yJB2Olq/vE + donWx67qVjpTCOvoNPUbXxUXqCVIKc0tGI4DztRgZ82KOwJby50oos2XgLagZ/cmA2wY + aAPq/ZVBOytX4VJlv85a8/s9gyOS/ZUzNljl0Fd3VoOnOOxSFahMq/WsyGY2DtVpvIOQ + uYfw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20230601; t=1706705987; x=1707310787; + h=content-transfer-encoding:mime-version:references:in-reply-to + :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc + :subject:date:message-id:reply-to; + bh=oAfvNX5JYKiOP5F5+HHWWQpkc2VYumz0VDstxq+2dC0=; + b=LzLnyq20+YKN1ZefzSuKqNoEU+9QTxnjnUw7PzG2NxJ3Qa44bRvy3N/o+EJ/pMjWuA + vdZjmrhZ6ZloyxF027pOTEJXI9FrvJJcAGsJm7LoF1drBKdO5UQfUJqlIMGIqms+UaSb + yYzmwW6HgmTjjC2Zp0Lsrlzw1WGt7bHA7oLfH32bX07I2cdJbqP/9kSZBOWAiyM8Rwj/ + 4JFxuQ1v2YQTl0r0jh/2S1s+OJpZm1SSY4nm5Tb0sMoHmwXrKEbh4DKrRQVXu/V1VU3x + E5levz55NwMzh560trRUOQ8UX1J9mj8YKp/XzRd7cFQUPysme5UCIH9p2+ksSLVziXbN + +dsQ== +X-Gm-Message-State: AOJu0YxPUJbxjg/91sbZzmMZcVyA6CP+2kbxoaSCMg8Rg8MMN0s5IvSf + lKyMT4ZAAp1/l0miyYmByMqBEZyAYI3fcXo5gajcwJ/kK+6J940= +X-Google-Smtp-Source: + AGHT+IHozbh85wcnYCXZXYDLJCLM9XGLrWwtHro3SkQvoxBuxVb086cAn/J1lYCBdkXRqYub3zJ7qw== +X-Received: by 2002:ac2:4950:0:b0:50e:9355:a24b with SMTP id + o16-20020ac24950000000b0050e9355a24bmr1003200lfi.22.1706705986343; + Wed, 31 Jan 2024 04:59:46 -0800 (PST) +Received: from localhost.localdomain ([188.162.49.60]) + by smtp.gmail.com with ESMTPSA id + h25-20020a19ca59000000b00510faaa62cfsm1361135lfj.222.2024.01.31.04.59.43 + (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); + Wed, 31 Jan 2024 04:59:45 -0800 (PST) +From: Aleksandr Shubin +To: linux-kernel@vger.kernel.org +Cc: Aleksandr Shubin , + Conor Dooley , + =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , + Rob Herring , + Krzysztof Kozlowski , + Conor Dooley , Chen-Yu Tsai , + Jernej Skrabec , + Samuel Holland , + Paul Walmsley , + Palmer Dabbelt , Albert Ou , + Philipp Zabel , + Marc Kleine-Budde , + Maksim Kiselev , + Cristian Ciocaltea , + John Watts , Cheo Fusi , + linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, + linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, + linux-riscv@lists.infradead.org +Subject: [PATCH v8 1/3] dt-bindings: pwm: Add binding for Allwinner + D1/T113-S3/R329 PWM controller +Date: Wed, 31 Jan 2024 15:59:14 +0300 +Message-Id: <20240131125920.2879433-2-privatesub2@gmail.com> +X-Mailer: git-send-email 2.25.1 +In-Reply-To: <20240131125920.2879433-1-privatesub2@gmail.com> +References: <20240131125920.2879433-1-privatesub2@gmail.com> +MIME-Version: 1.0 +X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 +X-CRM114-CacheID: sfid-20240131_045950_454851_364D21BE +X-CRM114-Status: GOOD ( 15.47 ) +X-BeenThere: linux-arm-kernel@lists.infradead.org +X-Mailman-Version: 2.1.34 +Precedence: list +List-Id: +List-Unsubscribe: + , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: + , + +Sender: "linux-arm-kernel" +Errors-To: + linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org + +Allwinner's D1, T113-S3 and R329 SoCs have a new pwm +controller witch is different from the previous pwm-sun4i. + +The D1 and T113 are identical in terms of peripherals, +they differ only in the architecture of the CPU core, and +even share the majority of their DT. Because of that, +using the same compatible makes sense. +The R329 is a different SoC though, and should have +a different compatible string added, especially as there +is a difference in the number of channels. + +D1 and T113s SoCs have one PWM controller with 8 channels. +R329 SoC has two PWM controllers in both power domains, one of +them has 9 channels (CPUX one) and the other has 6 (CPUS one). + +Add a device tree binding for them. + +Signed-off-by: Aleksandr Shubin +Reviewed-by: Conor Dooley +--- + .../bindings/pwm/allwinner,sun20i-pwm.yaml | 88 +++++++++++++++++++ + 1 file changed, 88 insertions(+) + create mode 100644 Documentation/devicetree/bindings/pwm/allwinner,sun20i-pwm.yaml + +diff --git a/Documentation/devicetree/bindings/pwm/allwinner,sun20i-pwm.yaml b/Documentation/devicetree/bindings/pwm/allwinner,sun20i-pwm.yaml +new file mode 100644 +index 000000000000..716f75776006 +--- /dev/null ++++ b/Documentation/devicetree/bindings/pwm/allwinner,sun20i-pwm.yaml +@@ -0,0 +1,88 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/pwm/allwinner,sun20i-pwm.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: Allwinner D1, T113-S3 and R329 PWM ++ ++maintainers: ++ - Aleksandr Shubin ++ - Brandon Cheo Fusi ++ ++properties: ++ compatible: ++ oneOf: ++ - const: allwinner,sun20i-d1-pwm ++ - items: ++ - const: allwinner,sun20i-r329-pwm ++ - const: allwinner,sun20i-d1-pwm ++ ++ reg: ++ maxItems: 1 ++ ++ "#pwm-cells": ++ const: 3 ++ ++ clocks: ++ items: ++ - description: Bus clock ++ - description: 24 MHz oscillator ++ - description: APB0 clock ++ ++ clock-names: ++ items: ++ - const: bus ++ - const: hosc ++ - const: apb0 ++ ++ resets: ++ maxItems: 1 ++ ++ allwinner,pwm-channels: ++ $ref: /schemas/types.yaml#/definitions/uint32 ++ description: The number of PWM channels configured for this instance ++ enum: [6, 9] ++ ++allOf: ++ - $ref: pwm.yaml# ++ ++ - if: ++ properties: ++ compatible: ++ contains: ++ const: allwinner,sun20i-r329-pwm ++ ++ then: ++ required: ++ - allwinner,pwm-channels ++ ++ else: ++ properties: ++ allwinner,pwm-channels: false ++ ++unevaluatedProperties: false ++ ++required: ++ - compatible ++ - reg ++ - "#pwm-cells" ++ - clocks ++ - clock-names ++ - resets ++ ++examples: ++ - | ++ #include ++ #include ++ ++ pwm: pwm@2000c00 { ++ compatible = "allwinner,sun20i-d1-pwm"; ++ reg = <0x02000c00 0x400>; ++ clocks = <&ccu CLK_BUS_PWM>, <&dcxo>, <&ccu CLK_APB0>; ++ clock-names = "bus", "hosc", "apb0"; ++ resets = <&ccu RST_BUS_PWM>; ++ #pwm-cells = <0x3>; ++ }; ++ ++... + +From patchwork Wed Jan 31 12:59:15 2024 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Patchwork-Submitter: Aleksandr Shubin +X-Patchwork-Id: 13539411 +Return-Path: + +X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on + aws-us-west-2-korg-lkml-1.web.codeaurora.org +Received: from bombadil.infradead.org (bombadil.infradead.org + [198.137.202.133]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by smtp.lore.kernel.org (Postfix) with ESMTPS id 03CF9C47DB3 + for ; + Wed, 31 Jan 2024 13:00:30 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; + d=lists.infradead.org; s=bombadil.20210309; h=Sender: + Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: + List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: + Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: + Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: + List-Owner; bh=s0NxbtQs25ewdS+vQ+JYVT89daQdLz5+ks95gu+AWN0=; b=n4SyeHnbtYg49M + 672QEfb6Zcm8Mlq1MUyeMMlIhFQs0oinHZctMe/0zV1ZGZ5i5wNrpR8m21JOcEXtI9N2PTVU+GtJm + 6Ska4t6ZCS4ejfkVqoVkuSe4F8Yy+urA6TqOP8puECL8IFnasytXrSCiuU0O99TCNivN8i2D0088d + oG8LeiieGlLVx1uq58yS9pijxOVTMyt+poGxrFbm1xCuhLesc98t0HXcoh9Ut+lKbbr7ACU9DBhGM + wxRAjG+cOeq3wNikWxJucRq/Wis7KHZ3D0XGj9F69kKLaAHxYu9+8DulbkmdMKqR741Qy5FmGBs+O + Awjp428vTr0pXxwYInLg==; +Received: from localhost ([::1] helo=bombadil.infradead.org) + by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) + id 1rVACK-00000003TdO-1hFY; + Wed, 31 Jan 2024 13:00:12 +0000 +Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) + by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) + id 1rVAC5-00000003TOW-1ggL; + Wed, 31 Jan 2024 13:00:00 +0000 +Received: by mail-lf1-x133.google.com with SMTP id + 2adb3069b0e04-511207d62b6so2041717e87.1; + Wed, 31 Jan 2024 04:59:55 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=gmail.com; s=20230601; t=1706705994; x=1707310794; + darn=lists.infradead.org; + h=content-transfer-encoding:mime-version:references:in-reply-to + :message-id:date:subject:cc:to:from:from:to:cc:subject:date + :message-id:reply-to; + bh=LJEpMRsYLlgFAcmZofqzHXt8kLBT+ut7O+m2hghOxj0=; + b=hxHe2gaiQULu5vEkbW8wwFAGL/Hf609zhJVJw3f4WYhl+RuhK4+aO72wxObzzeUI25 + bn5rrWfkLm1JYi4KGzsG5eKZshNmtXj6aqSD5qlfrlukL16aBWK3wJvZts/2Ti5N4QSK + nv7zsPAvVRJq+oZwU93rsBNDuX4eZqGX6sghWKTVgoWsW8LcHKc7pRULn+gwXXOf6G4l + YS7YWqatVs0LGfZnzA5rYwxSpcdGDkI9Dfxbz38Nnz7XOjwlcQgQ32/X9raTVqxxOICa + kpZKigNB/rXmyTTEn69Vfw5EsaIICCrXBeeLl+jctSIN9X0uICwloEFY3K0uHZQKQSSd + E75g== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20230601; t=1706705994; x=1707310794; + h=content-transfer-encoding:mime-version:references:in-reply-to + :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc + :subject:date:message-id:reply-to; + bh=LJEpMRsYLlgFAcmZofqzHXt8kLBT+ut7O+m2hghOxj0=; + b=jDFR+WsuUNfHnbJWLK84JOb2/VHg1iaDfuYF91dfug2Mwh9i6XSHXGunU31z2ScaU7 + Pg4vR4gSbN1wKwM+yPerEoWdvMus57PpUyUp/fAzU8UTiJZ2I1NWL9U4xEm6JKebokLs + D62DsJs+6ZmSdKVhBhCFB9RTL4lBXQqbcsqsz16CncBS+dhKC8Y615QM692eyMsfdugo + 55N4pGwEmCudCAimOIM2pMvLesOkEwTv8Ca3MZewyU645rL0elBf53B3Y3hk1Y/yyMT6 + GvLxSEMY2XgS6+KonU4sonHQqakSlUn5SGagcFe10nYoJzt+7LzAiqC13zjnT6+B6j6P + 9dwg== +X-Gm-Message-State: AOJu0YxDo1dgJrid0u1rqbfrQDdSGpXdKVofRaw7o7ji1Qn1WUvSipCO + GSiXBKCqaUCuvJn6WwBvkToEYnBVq7nKQIFWTo+sDaFbd4hcUdM= +X-Google-Smtp-Source: + AGHT+IGtgxJeyTQhG/aZasLr02uoyai6dB5Gw7iYCnTUM1O222ECB10oOjsvDI3WT6CNzRqjzcrFkA== +X-Received: by 2002:a05:6512:ea0:b0:510:1b51:e431 with SMTP id + bi32-20020a0565120ea000b005101b51e431mr1592192lfb.4.1706705993605; + Wed, 31 Jan 2024 04:59:53 -0800 (PST) +Received: from localhost.localdomain ([188.162.49.60]) + by smtp.gmail.com with ESMTPSA id + h25-20020a19ca59000000b00510faaa62cfsm1361135lfj.222.2024.01.31.04.59.50 + (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); + Wed, 31 Jan 2024 04:59:53 -0800 (PST) +From: Aleksandr Shubin +To: linux-kernel@vger.kernel.org +Cc: Aleksandr Shubin , + Brandon Cheo Fusi , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= + =?utf-8?q?g?= , + Rob Herring , + Krzysztof Kozlowski , + Conor Dooley , Chen-Yu Tsai , + Jernej Skrabec , + Samuel Holland , + Paul Walmsley , + Palmer Dabbelt , Albert Ou , + Philipp Zabel , + Cristian Ciocaltea , + John Watts , Marc Kleine-Budde , + Maksim Kiselev , linux-pwm@vger.kernel.org, + devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, + linux-sunxi@lists.linux.dev, linux-riscv@lists.infradead.org +Subject: [PATCH v8 2/3] pwm: Add Allwinner's D1/T113-S3/R329 SoCs PWM support +Date: Wed, 31 Jan 2024 15:59:15 +0300 +Message-Id: <20240131125920.2879433-3-privatesub2@gmail.com> +X-Mailer: git-send-email 2.25.1 +In-Reply-To: <20240131125920.2879433-1-privatesub2@gmail.com> +References: <20240131125920.2879433-1-privatesub2@gmail.com> +MIME-Version: 1.0 +X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 +X-CRM114-CacheID: sfid-20240131_045957_628592_EEA312F1 +X-CRM114-Status: GOOD ( 31.42 ) +X-BeenThere: linux-arm-kernel@lists.infradead.org +X-Mailman-Version: 2.1.34 +Precedence: list +List-Id: +List-Unsubscribe: + , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: + , + +Sender: "linux-arm-kernel" +Errors-To: + linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org + +Allwinner's D1, T113-S3 and R329 SoCs have a quite different PWM +controllers with ones supported by pwm-sun4i driver. + +This patch adds a PWM controller driver for Allwinner's D1, +T113-S3 and R329 SoCs. The main difference between these SoCs +is the number of channels defined by the DT property. + +Co-developed-by: Brandon Cheo Fusi +Signed-off-by: Brandon Cheo Fusi +Signed-off-by: Aleksandr Shubin +--- + drivers/pwm/Kconfig | 10 ++ + drivers/pwm/Makefile | 1 + + drivers/pwm/pwm-sun20i.c | 380 +++++++++++++++++++++++++++++++++++++++ + 3 files changed, 391 insertions(+) + create mode 100644 drivers/pwm/pwm-sun20i.c + +diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig +index 4b956d661755..d2e0a080eb3c 100644 +--- a/drivers/pwm/Kconfig ++++ b/drivers/pwm/Kconfig +@@ -625,6 +625,16 @@ config PWM_SUN4I + To compile this driver as a module, choose M here: the module + will be called pwm-sun4i. + ++config PWM_SUN20I ++ tristate "Allwinner D1/T113s/R329 PWM support" ++ depends on ARCH_SUNXI || COMPILE_TEST ++ depends on COMMON_CLK ++ help ++ Generic PWM framework driver for Allwinner D1/T113s/R329 SoCs. ++ ++ To compile this driver as a module, choose M here: the module ++ will be called pwm-sun20i. ++ + config PWM_SUNPLUS + tristate "Sunplus PWM support" + depends on ARCH_SUNPLUS || COMPILE_TEST +diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile +index c5ec9e168ee7..dcad0d5a2430 100644 +--- a/drivers/pwm/Makefile ++++ b/drivers/pwm/Makefile +@@ -58,6 +58,7 @@ obj-$(CONFIG_PWM_STM32) += pwm-stm32.o + obj-$(CONFIG_PWM_STM32_LP) += pwm-stm32-lp.o + obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o + obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o ++obj-$(CONFIG_PWM_SUN20I) += pwm-sun20i.o + obj-$(CONFIG_PWM_SUNPLUS) += pwm-sunplus.o + obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o + obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o +diff --git a/drivers/pwm/pwm-sun20i.c b/drivers/pwm/pwm-sun20i.c +new file mode 100644 +index 000000000000..19bf3f495155 +--- /dev/null ++++ b/drivers/pwm/pwm-sun20i.c +@@ -0,0 +1,380 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * PWM Controller Driver for sunxi platforms (D1, T113-S3 and R329) ++ * ++ * Limitations: ++ * - When the parameters change, current running period will not be completed ++ * and run new settings immediately. ++ * - It output HIGH-Z state when PWM channel disabled. ++ * ++ * Copyright (c) 2023 Aleksandr Shubin ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define SUN20I_PWM_CLK_CFG(chan) (0x20 + (((chan) >> 1) * 0x4)) ++#define SUN20I_PWM_CLK_CFG_SRC GENMASK(8, 7) ++#define SUN20I_PWM_CLK_CFG_DIV_M GENMASK(3, 0) ++#define SUN20I_PWM_CLK_DIV_M_MAX 8 ++ ++#define SUN20I_PWM_CLK_GATE 0x40 ++#define SUN20I_PWM_CLK_GATE_BYPASS(chan) BIT((chan) + 16) ++#define SUN20I_PWM_CLK_GATE_GATING(chan) BIT(chan) ++ ++#define SUN20I_PWM_ENABLE 0x80 ++#define SUN20I_PWM_ENABLE_EN(chan) BIT(chan) ++ ++#define SUN20I_PWM_CTL(chan) (0x100 + (chan) * 0x20) ++#define SUN20I_PWM_CTL_ACT_STA BIT(8) ++#define SUN20I_PWM_CTL_PRESCAL_K GENMASK(7, 0) ++#define SUN20I_PWM_CTL_PRESCAL_K_MAX 0xff ++ ++#define SUN20I_PWM_PERIOD(chan) (0x104 + (chan) * 0x20) ++#define SUN20I_PWM_PERIOD_ENTIRE_CYCLE GENMASK(31, 16) ++#define SUN20I_PWM_PERIOD_ACT_CYCLE GENMASK(15, 0) ++ ++#define SUN20I_PWM_PCNTR_SIZE BIT(16) ++ ++/** ++ * SUN20I_PWM_MAGIC is used to quickly compute the values of the clock dividers ++ * div_m (SUN20I_PWM_CLK_CFG_DIV_M) & prescale_k (SUN20I_PWM_CTL_PRESCAL_K) ++ * without using a loop. These dividers limit the # of cycles in a period ++ * to SUN20I_PWM_PCNTR_SIZE by applying a scaling factor of ++ * 1/(div_m * (prescale_k + 1)) to the clock source. ++ * ++ * SUN20I_PWM_MAGIC is derived by solving for div_m and prescale_k ++ * such that for a given requested period, ++ * ++ * i) div_m is minimized for any prescale_k ≤ SUN20I_PWM_CTL_PRESCAL_K_MAX, ++ * ii) prescale_k is minimized. ++ * ++ * The derivation proceeds as follows, with val = # of cycles for reqested ++ * period: ++ * ++ * for a given value of div_m we want the smallest prescale_k such that ++ * ++ * (val >> div_m) // (prescale_k + 1) ≤ 65536 (SUN20I_PWM_PCNTR_SIZE) ++ * ++ * This is equivalent to: ++ * ++ * (val >> div_m) ≤ 65536 * (prescale_k + 1) + prescale_k ++ * ⟺ (val >> div_m) ≤ 65537 * prescale_k + 65536 ++ * ⟺ (val >> div_m) - 65536 ≤ 65537 * prescale_k ++ * ⟺ ((val >> div_m) - 65536) / 65537 ≤ prescale_k ++ * ++ * As prescale_k is integer, this becomes ++ * ++ * ((val >> div_m) - 65536) // 65537 ≤ prescale_k ++ * ++ * And is minimized at ++ * ++ * ((val >> div_m) - 65536) // 65537 ++ * ++ * Now we pick the smallest div_m that satifies prescale_k ≤ 255 ++ * (i.e SUN20I_PWM_CTL_PRESCAL_K_MAX), ++ * ++ * ((val >> div_m) - 65536) // 65537 ≤ 255 ++ * ⟺ (val >> div_m) - 65536 ≤ 255 * 65537 + 65536 ++ * ⟺ val >> div_m ≤ 255 * 65537 + 2 * 65536 ++ * ⟺ val >> div_m < (255 * 65537 + 2 * 65536 + 1) ++ * ⟺ div_m = fls((val) / (255 * 65537 + 2 * 65536 + 1)) ++ * ++ * Suggested by Uwe Kleine-König ++ */ ++#define SUN20I_PWM_MAGIC (255 * 65537 + 2 * 65536 + 1) ++ ++struct sun20i_pwm_chip { ++ struct clk *clk_bus, *clk_hosc, *clk_apb0; ++ struct reset_control *rst; ++ struct pwm_chip chip; ++ void __iomem *base; ++ /* Mutex to protect pwm apply state */ ++ struct mutex mutex; ++}; ++ ++static inline struct sun20i_pwm_chip *to_sun20i_pwm_chip(struct pwm_chip *chip) ++{ ++ return container_of(chip, struct sun20i_pwm_chip, chip); ++} ++ ++static inline u32 sun20i_pwm_readl(struct sun20i_pwm_chip *chip, ++ unsigned long offset) ++{ ++ return readl(chip->base + offset); ++} ++ ++static inline void sun20i_pwm_writel(struct sun20i_pwm_chip *chip, ++ u32 val, unsigned long offset) ++{ ++ writel(val, chip->base + offset); ++} ++ ++static int sun20i_pwm_get_state(struct pwm_chip *chip, ++ struct pwm_device *pwm, ++ struct pwm_state *state) ++{ ++ struct sun20i_pwm_chip *sun20i_chip = to_sun20i_pwm_chip(chip); ++ u16 ent_cycle, act_cycle, prescale_k; ++ u64 clk_rate, tmp; ++ u8 div_m; ++ u32 val; ++ ++ mutex_lock(&sun20i_chip->mutex); ++ ++ val = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_CLK_CFG(pwm->hwpwm)); ++ div_m = FIELD_GET(SUN20I_PWM_CLK_CFG_DIV_M, val); ++ if (div_m > SUN20I_PWM_CLK_DIV_M_MAX) ++ div_m = SUN20I_PWM_CLK_DIV_M_MAX; ++ ++ if (FIELD_GET(SUN20I_PWM_CLK_CFG_SRC, val) == 0) ++ clk_rate = clk_get_rate(sun20i_chip->clk_hosc); ++ else ++ clk_rate = clk_get_rate(sun20i_chip->clk_apb0); ++ ++ val = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_CTL(pwm->hwpwm)); ++ state->polarity = (SUN20I_PWM_CTL_ACT_STA & val) ? ++ PWM_POLARITY_NORMAL : PWM_POLARITY_INVERSED; ++ ++ prescale_k = FIELD_GET(SUN20I_PWM_CTL_PRESCAL_K, val) + 1; ++ ++ val = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_ENABLE); ++ state->enabled = (SUN20I_PWM_ENABLE_EN(pwm->hwpwm) & val) ? true : false; ++ ++ val = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_PERIOD(pwm->hwpwm)); ++ ++ mutex_unlock(&sun20i_chip->mutex); ++ ++ act_cycle = FIELD_GET(SUN20I_PWM_PERIOD_ACT_CYCLE, val); ++ ent_cycle = FIELD_GET(SUN20I_PWM_PERIOD_ENTIRE_CYCLE, val); ++ ++ /* ++ * The duration of the active phase should not be longer ++ * than the duration of the period ++ */ ++ if (act_cycle > ent_cycle) ++ act_cycle = ent_cycle; ++ ++ tmp = ((u64)(act_cycle) * prescale_k << div_m) * NSEC_PER_SEC; ++ state->duty_cycle = DIV_ROUND_UP_ULL(tmp, clk_rate); ++ tmp = ((u64)(ent_cycle) * prescale_k << div_m) * NSEC_PER_SEC; ++ state->period = DIV_ROUND_UP_ULL(tmp, clk_rate); ++ ++ return 0; ++} ++ ++static int sun20i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ++ const struct pwm_state *state) ++{ ++ struct sun20i_pwm_chip *sun20i_chip = to_sun20i_pwm_chip(chip); ++ u64 bus_rate, hosc_rate, val, ent_cycle, act_cycle; ++ u32 clk_gate, clk_cfg, pwm_en, ctl, reg_period; ++ u32 prescale_k, div_m; ++ bool use_bus_clk; ++ int ret = 0; ++ ++ mutex_lock(&sun20i_chip->mutex); ++ ++ pwm_en = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_ENABLE); ++ ++ if (state->enabled != pwm->state.enabled) { ++ clk_gate = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_CLK_GATE); ++ ++ if (!state->enabled) { ++ clk_gate &= ~SUN20I_PWM_CLK_GATE_GATING(pwm->hwpwm); ++ pwm_en &= ~SUN20I_PWM_ENABLE_EN(pwm->hwpwm); ++ sun20i_pwm_writel(sun20i_chip, pwm_en, SUN20I_PWM_ENABLE); ++ sun20i_pwm_writel(sun20i_chip, clk_gate, SUN20I_PWM_CLK_GATE); ++ } ++ } ++ ++ if (state->polarity != pwm->state.polarity || ++ state->duty_cycle != pwm->state.duty_cycle || ++ state->period != pwm->state.period) { ++ ctl = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_CTL(pwm->hwpwm)); ++ clk_cfg = sun20i_pwm_readl(sun20i_chip, SUN20I_PWM_CLK_CFG(pwm->hwpwm)); ++ hosc_rate = clk_get_rate(sun20i_chip->clk_hosc); ++ bus_rate = clk_get_rate(sun20i_chip->clk_apb0); ++ if (pwm_en & SUN20I_PWM_ENABLE_EN(pwm->hwpwm ^ 1)) { ++ /* if the neighbor channel is enable, check period only */ ++ use_bus_clk = FIELD_GET(SUN20I_PWM_CLK_CFG_SRC, clk_cfg) != 0; ++ val = mul_u64_u64_div_u64(state->period, ++ (use_bus_clk ? bus_rate : hosc_rate), ++ NSEC_PER_SEC); ++ ++ div_m = FIELD_GET(SUN20I_PWM_CLK_CFG_DIV_M, clk_cfg); ++ } else { ++ /* check period and select clock source */ ++ use_bus_clk = false; ++ val = mul_u64_u64_div_u64(state->period, hosc_rate, NSEC_PER_SEC); ++ if (val <= 1) { ++ use_bus_clk = true; ++ val = mul_u64_u64_div_u64(state->period, bus_rate, NSEC_PER_SEC); ++ if (val <= 1) { ++ ret = -EINVAL; ++ goto unlock_mutex; ++ } ++ } ++ div_m = fls(DIV_ROUND_DOWN_ULL(val, SUN20I_PWM_MAGIC)); ++ if (div_m > SUN20I_PWM_CLK_DIV_M_MAX) { ++ ret = -EINVAL; ++ goto unlock_mutex; ++ } ++ ++ /* set up the CLK_DIV_M and clock CLK_SRC */ ++ clk_cfg = FIELD_PREP(SUN20I_PWM_CLK_CFG_DIV_M, div_m); ++ clk_cfg |= FIELD_PREP(SUN20I_PWM_CLK_CFG_SRC, use_bus_clk); ++ ++ sun20i_pwm_writel(sun20i_chip, clk_cfg, SUN20I_PWM_CLK_CFG(pwm->hwpwm)); ++ } ++ ++ /* calculate prescale_k, PWM entire cycle */ ++ ent_cycle = val >> div_m; ++ prescale_k = DIV_ROUND_DOWN_ULL(ent_cycle, 65537); ++ if (prescale_k > SUN20I_PWM_CTL_PRESCAL_K_MAX) ++ prescale_k = SUN20I_PWM_CTL_PRESCAL_K_MAX; ++ ++ do_div(ent_cycle, prescale_k + 1); ++ ++ /* for N cycles, PPRx.PWM_ENTIRE_CYCLE = (N-1) */ ++ reg_period = FIELD_PREP(SUN20I_PWM_PERIOD_ENTIRE_CYCLE, ent_cycle - 1); ++ ++ /* set duty cycle */ ++ val = mul_u64_u64_div_u64(state->duty_cycle, ++ (use_bus_clk ? bus_rate : hosc_rate), ++ NSEC_PER_SEC); ++ act_cycle = val >> div_m; ++ do_div(act_cycle, prescale_k + 1); ++ ++ /* ++ * The formula of the output period and the duty-cycle for PWM are as follows. ++ * T period = (PWM01_CLK / PWM0_PRESCALE_K)^-1 * (PPR0.PWM_ENTIRE_CYCLE + 1) ++ * T high-level = (PWM01_CLK / PWM0_PRESCALE_K)^-1 * PPR0.PWM_ACT_CYCLE ++ * Duty-cycle = T high-level / T period ++ */ ++ reg_period |= FIELD_PREP(SUN20I_PWM_PERIOD_ACT_CYCLE, act_cycle); ++ sun20i_pwm_writel(sun20i_chip, reg_period, SUN20I_PWM_PERIOD(pwm->hwpwm)); ++ ++ ctl = FIELD_PREP(SUN20I_PWM_CTL_PRESCAL_K, prescale_k); ++ if (state->polarity == PWM_POLARITY_NORMAL) ++ ctl |= SUN20I_PWM_CTL_ACT_STA; ++ ++ sun20i_pwm_writel(sun20i_chip, ctl, SUN20I_PWM_CTL(pwm->hwpwm)); ++ } ++ ++ if (state->enabled != pwm->state.enabled && state->enabled) { ++ clk_gate &= ~SUN20I_PWM_CLK_GATE_BYPASS(pwm->hwpwm); ++ clk_gate |= SUN20I_PWM_CLK_GATE_GATING(pwm->hwpwm); ++ pwm_en |= SUN20I_PWM_ENABLE_EN(pwm->hwpwm); ++ sun20i_pwm_writel(sun20i_chip, pwm_en, SUN20I_PWM_ENABLE); ++ sun20i_pwm_writel(sun20i_chip, clk_gate, SUN20I_PWM_CLK_GATE); ++ } ++ ++unlock_mutex: ++ mutex_unlock(&sun20i_chip->mutex); ++ ++ return ret; ++} ++ ++static const struct pwm_ops sun20i_pwm_ops = { ++ .apply = sun20i_pwm_apply, ++ .get_state = sun20i_pwm_get_state, ++}; ++ ++static const struct of_device_id sun20i_pwm_dt_ids[] = { ++ { .compatible = "allwinner,sun20i-d1-pwm" }, ++ { }, ++}; ++MODULE_DEVICE_TABLE(of, sun20i_pwm_dt_ids); ++ ++static int sun20i_pwm_probe(struct platform_device *pdev) ++{ ++ struct sun20i_pwm_chip *sun20i_chip; ++ int ret; ++ ++ sun20i_chip = devm_kzalloc(&pdev->dev, sizeof(*sun20i_chip), GFP_KERNEL); ++ if (!sun20i_chip) ++ return -ENOMEM; ++ ++ sun20i_chip->base = devm_platform_ioremap_resource(pdev, 0); ++ if (IS_ERR(sun20i_chip->base)) ++ return PTR_ERR(sun20i_chip->base); ++ ++ sun20i_chip->clk_bus = devm_clk_get_enabled(&pdev->dev, "bus"); ++ if (IS_ERR(sun20i_chip->clk_bus)) ++ return dev_err_probe(&pdev->dev, PTR_ERR(sun20i_chip->clk_bus), ++ "failed to get bus clock\n"); ++ ++ sun20i_chip->clk_hosc = devm_clk_get_enabled(&pdev->dev, "hosc"); ++ if (IS_ERR(sun20i_chip->clk_hosc)) ++ return dev_err_probe(&pdev->dev, PTR_ERR(sun20i_chip->clk_hosc), ++ "failed to get hosc clock\n"); ++ ++ sun20i_chip->clk_apb0 = devm_clk_get_enabled(&pdev->dev, "apb0"); ++ if (IS_ERR(sun20i_chip->clk_apb0)) ++ return dev_err_probe(&pdev->dev, PTR_ERR(sun20i_chip->clk_apb0), ++ "failed to get apb0 clock\n"); ++ ++ sun20i_chip->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); ++ if (IS_ERR(sun20i_chip->rst)) ++ return dev_err_probe(&pdev->dev, PTR_ERR(sun20i_chip->rst), ++ "failed to get bus reset\n"); ++ ++ ret = of_property_read_u32(pdev->dev.of_node, "allwinner,pwm-channels", ++ &sun20i_chip->chip.npwm); ++ if (ret) ++ sun20i_chip->chip.npwm = 8; ++ ++ if (sun20i_chip->chip.npwm > 16) ++ sun20i_chip->chip.npwm = 16; ++ ++ /* Deassert reset */ ++ ret = reset_control_deassert(sun20i_chip->rst); ++ if (ret) ++ return dev_err_probe(&pdev->dev, ret, "failed to deassert reset\n"); ++ ++ sun20i_chip->chip.dev = &pdev->dev; ++ sun20i_chip->chip.ops = &sun20i_pwm_ops; ++ ++ mutex_init(&sun20i_chip->mutex); ++ ++ ret = pwmchip_add(&sun20i_chip->chip); ++ if (ret < 0) { ++ reset_control_assert(sun20i_chip->rst); ++ return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); ++ } ++ ++ platform_set_drvdata(pdev, sun20i_chip); ++ ++ return 0; ++} ++ ++static void sun20i_pwm_remove(struct platform_device *pdev) ++{ ++ struct sun20i_pwm_chip *sun20i_chip = platform_get_drvdata(pdev); ++ ++ pwmchip_remove(&sun20i_chip->chip); ++ ++ reset_control_assert(sun20i_chip->rst); ++} ++ ++static struct platform_driver sun20i_pwm_driver = { ++ .driver = { ++ .name = "sun20i-pwm", ++ .of_match_table = sun20i_pwm_dt_ids, ++ }, ++ .probe = sun20i_pwm_probe, ++ .remove_new = sun20i_pwm_remove, ++}; ++module_platform_driver(sun20i_pwm_driver); ++ ++MODULE_AUTHOR("Aleksandr Shubin "); ++MODULE_DESCRIPTION("Allwinner sun20i PWM driver"); ++MODULE_LICENSE("GPL"); + +From patchwork Wed Jan 31 12:59:16 2024 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Aleksandr Shubin +X-Patchwork-Id: 13539412 +Return-Path: + +X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on + aws-us-west-2-korg-lkml-1.web.codeaurora.org +Received: from bombadil.infradead.org (bombadil.infradead.org + [198.137.202.133]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by smtp.lore.kernel.org (Postfix) with ESMTPS id 51419C47258 + for ; + Wed, 31 Jan 2024 13:00:43 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; + d=lists.infradead.org; s=bombadil.20210309; h=Sender: + Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: + List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: + Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: + Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: + List-Owner; bh=c2S3MnnlfH3cC6yGru/ZdOx4a33A75T+65kq7cjRgkE=; b=WHXjWaL/e1NiPQ + eGJjN3b5I3tYI9D8fhDRMpQA3N7K4pcjJN2I5UM2vmdVoqvw0BLRBs8XXD/solz9f6uoBYim3N2EX + OxYyvzMCs9mgQ/Uk47sv2DEzHmCtkJUUNQT+AoAHTPxk8eMPVyhFb2p1AbQW0MpZ9qpq/tTikqN1m + tvNvqKLy+kUQcqyr1nfxB3PRrk1iSDWnFpWJ402otIcQPtiOhcI9Oy0SjIEkRRF0QgUcXMDKWCn9X + Odzr3Hq8mLK3rAnv7P7IClXtySm0KtTo5NLANaakf7OOhtCZZu/VaXUBfrdsX8PJvJPFaxR4fnZgd + kDyjcsvZOIkiBbOLfSBw==; +Received: from localhost ([::1] helo=bombadil.infradead.org) + by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) + id 1rVACX-00000003Tmd-0BOT; + Wed, 31 Jan 2024 13:00:25 +0000 +Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) + by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) + id 1rVACB-00000003TTo-2f1o; + Wed, 31 Jan 2024 13:00:06 +0000 +Received: by mail-lf1-x12f.google.com with SMTP id + 2adb3069b0e04-51025cafb51so7505797e87.2; + Wed, 31 Jan 2024 05:00:02 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=gmail.com; s=20230601; t=1706706000; x=1707310800; + darn=lists.infradead.org; + h=content-transfer-encoding:mime-version:references:in-reply-to + :message-id:date:subject:cc:to:from:from:to:cc:subject:date + :message-id:reply-to; + bh=Qk5axihAKFS9+0dIUTMZ/jrL2YTkFropx3eyJ2mG6qU=; + b=XXPay0935Bp3pcCfiTxOn6Snscj9Nw7mGd+7gjuCwgc5LUKMv7ZsEJ3hVQtIp2WKqV + KAdMVnQgC/mEGsxAREUUDhlKEiuI6DSRsck4312ZRQ6EtnZ3Cc8B/QrXq4tGIpXDqGCn + wG/PCG0hnkKev8JmTsTOdoTVqhUQeuxAp3cKJsrzWzlq5C8+W48kVU5QWM2v7/7o6LiV + bxqMEidvvY9UuP+GgLkogYAp6+ZM9369xaWoIQVVpOavqXhQiXfpDE9eX2XQGAg6etl+ + 2eneFQJHS79KiWae0ZRbl3wBarv6XEVpx/VLPFXzcgCzDtfRQJbRWS0x3TzSKcQiaIz2 + +Tfw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20230601; t=1706706000; x=1707310800; + h=content-transfer-encoding:mime-version:references:in-reply-to + :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc + :subject:date:message-id:reply-to; + bh=Qk5axihAKFS9+0dIUTMZ/jrL2YTkFropx3eyJ2mG6qU=; + b=EYGM5gI80pwV/nUPGWTbaVpk8itS3amBZfU61xVQYpoPfZ+1nci7PmKeycitnMisb5 + s9ZLDtXa45W8xcav5kKFWlXL1BkqqKjz0dZXQ57NSbIlCmgDutDx5P+PE8snq2PevdQ9 + Vo6Ol7xeDXsVQRPgrCYeIFnRJ70/3wJKtKDM60NT/SKNpjMzCNs663SitWsC4kZeqX6S + ivtV9/HMc0oJe2IIdoOwcjC9S4iZA1VXn3qvXK2OJRZ6shMaZ4tniKZS1k2tTQlo+jgo + cBbAM6j18gdqe7V+qV95p0aMYEcWU3mBDMD0A8vLO/3Dr8OworeWqnhwPIb0n24ahDWj + ZTnw== +X-Gm-Message-State: AOJu0Yxaw92L+7QpsBH4rCE3NXOZWq6wwt7+AwMlx1hOGok+a+V5iXLn + wluPIJKfm4yZ4OxQzM8zZtGiNI3tpob6VJCEXSX6kSn8R14GYb8= +X-Google-Smtp-Source: + AGHT+IFlj/2UQlXVTsP85U+sX9Z4Xg+m+7M8urgFGxXNNIrMtV2ixCb6BE8A2Y9DZeChVhyFjSIIgA== +X-Received: by 2002:a05:6512:3b93:b0:511:1ed7:61bd with SMTP id + g19-20020a0565123b9300b005111ed761bdmr1608967lfv.54.1706706000644; + Wed, 31 Jan 2024 05:00:00 -0800 (PST) +Received: from localhost.localdomain ([188.162.49.60]) + by smtp.gmail.com with ESMTPSA id + h25-20020a19ca59000000b00510faaa62cfsm1361135lfj.222.2024.01.31.04.59.57 + (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); + Wed, 31 Jan 2024 04:59:59 -0800 (PST) +From: Aleksandr Shubin +To: linux-kernel@vger.kernel.org +Cc: Aleksandr Shubin , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= + =?utf-8?q?g?= , + Rob Herring , + Krzysztof Kozlowski , + Conor Dooley , Chen-Yu Tsai , + Jernej Skrabec , + Samuel Holland , + Paul Walmsley , + Palmer Dabbelt , Albert Ou , + Philipp Zabel , + Maksim Kiselev , + Cristian Ciocaltea , + Marc Kleine-Budde , John Watts , + Cheo Fusi , linux-pwm@vger.kernel.org, + devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, + linux-sunxi@lists.linux.dev, linux-riscv@lists.infradead.org +Subject: [PATCH v8 3/3] riscv: dts: allwinner: d1: Add pwm node +Date: Wed, 31 Jan 2024 15:59:16 +0300 +Message-Id: <20240131125920.2879433-4-privatesub2@gmail.com> +X-Mailer: git-send-email 2.25.1 +In-Reply-To: <20240131125920.2879433-1-privatesub2@gmail.com> +References: <20240131125920.2879433-1-privatesub2@gmail.com> +MIME-Version: 1.0 +X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 +X-CRM114-CacheID: sfid-20240131_050003_781094_6C718EFA +X-CRM114-Status: GOOD ( 11.29 ) +X-BeenThere: linux-arm-kernel@lists.infradead.org +X-Mailman-Version: 2.1.34 +Precedence: list +List-Id: +List-Unsubscribe: + , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: + , + +Sender: "linux-arm-kernel" +Errors-To: + linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org + +D1 and T113s contain a pwm controller with 8 channels. +This controller is supported by the sun20i-pwm driver. + +Add a device tree node for it. + +Signed-off-by: Aleksandr Shubin +Reviewed-by: Andre Przywara +--- + arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +index 5a9d7f5a75b4..435a1e66aa6a 100644 +--- a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi ++++ b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +@@ -145,6 +145,18 @@ uart3_pb_pins: uart3-pb-pins { + }; + }; + ++ pwm: pwm@2000c00 { ++ compatible = "allwinner,sun20i-d1-pwm"; ++ reg = <0x02000c00 0x400>; ++ clocks = <&ccu CLK_BUS_PWM>, ++ <&dcxo>, ++ <&ccu CLK_APB0>; ++ clock-names = "bus", "hosc", "apb0"; ++ resets = <&ccu RST_BUS_PWM>; ++ status = "disabled"; ++ #pwm-cells = <0x3>; ++ }; ++ + ccu: clock-controller@2001000 { + compatible = "allwinner,sun20i-d1-ccu"; + reg = <0x2001000 0x1000>; From 356101c73904431a25075502124419888f816fed Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 11 Feb 2024 16:52:11 -0800 Subject: [PATCH 7/9] devicetree: add version-specific nodes to v2.4 dts --- .../tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts index 6dcd8a0b..9d59e763 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.4.dts @@ -11,4 +11,183 @@ chosen { stdout-path = "serial0:115200n8"; }; + + nodes { + #gpio-cells = <2>; + compatible = "turing,pi2-nodes"; + gpio-controller; + + gpios = <&pio 3 11 GPIO_ACTIVE_LOW>, /* node 1 */ + <&pio 3 0 GPIO_ACTIVE_LOW>, /* PD0 */ + <&pio 3 19 GPIO_ACTIVE_HIGH>, /* PD19 */ + <&pio 3 15 GPIO_ACTIVE_LOW>, /* PD15 */ + <&pio 3 10 GPIO_ACTIVE_LOW>, /* node 2 */ + <&pio 3 20 GPIO_ACTIVE_LOW>, /* PD20 */ + <&pio 3 18 GPIO_ACTIVE_HIGH>, /* PD18 */ + <&pio 3 14 GPIO_ACTIVE_LOW>, /* PD14 */ + <&pio 3 9 GPIO_ACTIVE_LOW>, /* node 3 */ + <&pio 3 21 GPIO_ACTIVE_LOW>, /* PD21 */ + <&pio 3 17 GPIO_ACTIVE_HIGH>, /* PD17 */ + <&pio 3 12 GPIO_ACTIVE_LOW>, /* PD12 */ + <&pio 3 8 GPIO_ACTIVE_LOW>, /* node 4 */ + <&pio 3 22 GPIO_ACTIVE_LOW>, /* PD22 */ + <&pio 3 16 GPIO_ACTIVE_HIGH>, /* PD16 */ + <&pio 3 13 GPIO_ACTIVE_LOW>; /* PD13 */ + + gpio-line-names = "node1-en", "node1-rst", + "node1-usbotg-dev", "node1-rpiboot", + "node2-en", "node2-rst", + "node2-usbotg-dev", "node2-rpiboot", + "node3-en", "node3-rst", + "node3-usbotg-dev", "node3-rpiboot", + "node4-en", "node4-rst", + "node4-usbotg-dev", "node4-rpiboot"; + }; + + reg_atx_psu: regulator-atx-psu { + compatible = "regulator-fixed"; + + regulator-name = "atx-psu"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + startup-delay-us = <250000>; + + gpio = <&pio 3 3 GPIO_ACTIVE_HIGH>; /* PD3 */ + enable-active-high; + }; + + reg_slot1: regulator-slot1 { + compatible = "regulator-fixed"; + + regulator-name = "slot1"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&pio 3 7 GPIO_ACTIVE_HIGH>; /* PD7 */ + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node1-power { + compatible = "regulator-output"; + vout-supply = <®_slot1>; + }; + + reg_slot2: regulator-slot2 { + compatible = "regulator-fixed"; + + regulator-name = "slot2"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>; /* PD6 */ + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node2-power { + compatible = "regulator-output"; + vout-supply = <®_slot2>; + }; + + reg_slot3: regulator-slot3 { + compatible = "regulator-fixed"; + + regulator-name = "slot3"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&pio 3 5 GPIO_ACTIVE_HIGH>; /* PD5 */ + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node3-power { + compatible = "regulator-output"; + vout-supply = <®_slot3>; + }; + + reg_slot4: regulator-slot4 { + compatible = "regulator-fixed"; + + regulator-name = "slot4"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <100000>; + + gpio = <&pio 3 4 GPIO_ACTIVE_HIGH>; /* PD4 */ + enable-active-high; + + vin-supply = <®_atx_psu>; + }; + + node4-power { + compatible = "regulator-output"; + vout-supply = <®_slot4>; + }; + + reg_usb_port_vbus: regulator-usb-port-vbus { + compatible = "regulator-fixed"; + + regulator-name = "usb-port-vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <5000>; + + gpio = <&pio 6 4 GPIO_ACTIVE_LOW>; /* PG4 */ + + vin-supply = <®_atx_5vsb>; + }; + + usb-port-power { + compatible = "regulator-output"; + vout-supply = <®_usb_port_vbus>; + }; + + reg_usb_otg_vbus: regulator-usb-otg-vbus { + compatible = "regulator-fixed"; + + regulator-name = "usb-otg-vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + startup-delay-us = <5000>; + + gpio = <&pio 6 12 GPIO_ACTIVE_LOW>; /* PG12 */ + + vin-supply = <®_atx_5vsb>; + }; +}; + +&i2c2 { + /* + * The TP2 board design includes a 4-pin fan header (J16) and + * SMBus-compatible fan speed controller (U109). They are not populated + * on current production boards, but some users choose to solder on a + * Molex 47053-1000 and Microchip EMC2301, respectively, to gain this + * functionality. This node is here to enable probing for the EMC2301 + * on boot, even though most boards lack it. + */ + emc2301@2f { + status = "okay"; + compatible = "microchip,emc2301"; + reg = <0x2f>; + }; +}; + +&usb_otg { + dr_mode = "otg"; + adp-disable; + hnp-disable; + srp-disable; + usb-role-switch; +}; + +&usbphy { + usb0_vbus-supply = <®_usb_otg_vbus>; }; From c97ad367f2759fda5fd68079335dcba15ff05006 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 12 Feb 2024 12:43:55 -0800 Subject: [PATCH 8/9] devicetree: enable v2.5's i2c0 and new RTC --- tp2bmc/board/tp2bmc/linux_defconfig | 1 + .../tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts | 20 +++++++++++++++++++ .../board/tp2bmc/sun8i-t113s-turing-pi2.dtsi | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/tp2bmc/board/tp2bmc/linux_defconfig b/tp2bmc/board/tp2bmc/linux_defconfig index d44d1b5c..945d4f81 100644 --- a/tp2bmc/board/tp2bmc/linux_defconfig +++ b/tp2bmc/board/tp2bmc/linux_defconfig @@ -179,6 +179,7 @@ CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_GPIO=y CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_PCF8563=y CONFIG_DMADEVICES=y CONFIG_DMA_SUN6I=y # CONFIG_VIRTIO_MENU is not set diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts index 737fca46..21abf066 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts @@ -8,6 +8,11 @@ model = "Turing Pi 2 (v2.5)"; compatible = "turing,pi2", "allwinner,sun8i-t113s"; + aliases { + rtc0 = &ext_rtc; + rtc1 = &rtc; + }; + chosen { stdout-path = "serial0:115200n8"; }; @@ -158,6 +163,21 @@ #endif }; +&i2c0 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pg_pins>; + + clock-frequency = <400000>; + + ext_rtc: rtc@51 { + compatible = "nxp,pcf8563"; + reg = <0x51>; + #clock-cells = <0>; + }; +}; + #ifndef IS_UBOOT &pwm { status = "okay"; diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi index 0fc95b35..07717a8c 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2.dtsi @@ -242,6 +242,12 @@ }; &pio { + /omit-if-no-ref/ + i2c0_pg_pins: i2c0-pg-pins { + pins = "PG12", "PG13"; + function = "i2c0"; + }; + /omit-if-no-ref/ pwm5_pd_pin: pwm5-pd-pin { pins = "PD21"; From 744550a7ad859d7f6d295cb5d4755094dca6e659 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 18 Mar 2024 17:53:59 -0600 Subject: [PATCH 9/9] devicetree: Add USB hub definition for TPi2.5 --- .../tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts index 21abf066..14c0c412 100644 --- a/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts +++ b/tp2bmc/board/tp2bmc/sun8i-t113s-turing-pi2-v2.5.dts @@ -163,6 +163,31 @@ #endif }; +&ehci1 { + #address-cells = <1>; + #size-cells = <0>; + + hub@1 { + compatible = "usb5e3,608"; + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + node1@1 { + reg = <1>; + }; + node2@2 { + reg = <2>; + }; + node3@3 { + reg = <3>; + }; + node4@4 { + reg = <4>; + }; + }; +}; + &i2c0 { status = "okay";