Add pinctrl support for TH1520 SoC
Subsystems (3)
cover Add pinctrl support for TH1520 SoC
This series adds pin configuration support for TH1520 SoC with a driver ported from Linux kernel, and enables it by default. As a test, random configuration is specified in devicetree, then the effects are verified by reading back registers or observing hardware behavior.
With several downstream patches, I've also successfully brought up the second GMAC controller on TH1520. Since the controller won't work with the default pin configuration, this also serves as a proof of the driver's functionality.
This series may depend on the previous series "Bring up secondary cores on Lichee Pi 4A"[1] for a clean apply. An output of pinmux status -a could be obtained here[2].
[1]: https://lore.kernel.org/u-boot/[email protected]/
[2]: https://gist.github.com/ziyao233/55738ed1a33d450ccb1dc3752494a2b4
Yao Zi (3):
pinctrl: Port pin controller driver for T-Head TH1520 SoC
riscv: dts: th1520: Add pin controllers
riscv: cpu: th1520: Enable pinctrl by default
MAINTAINERS | 1 + arch/riscv/cpu/th1520/Kconfig | 1 + arch/riscv/dts/th1520.dtsi | 28 ++ configs/th1520_lpi4a_defconfig | 1 + drivers/pinctrl/Kconfig | 8 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-th1520.c | 700 +++++++++++++++++++++++++++++++ 7 files changed, 740 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-th1520.c
Signature · 1 line
2.49.0
PATCH 1/3 pinctrl: Port pin controller driver for T-Head TH1520 SoC
The SoC pads of TH1520 are separated into three groups (AP 1, AP 2 and AON) controlled by independent pin controllers. This patch ports their driver from Linux kernel with most code for setting pinconf and pinmux kept as is.
The dt-binding of TH1520 pin controller uses a schema where pins to configure are specfied as strings and looked up at runtime, which the generic pinctrl helpers of U-Boot cannot parse, thus a customized set_state() callback is implemented to parse pinconfig nodes and setup the configuration.
--- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 8 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-th1520.c | 700 +++++++++++++++++++++++++++++++ 4 files changed, 710 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-th1520.c
MAINTAINERS +1 -0
@@ -1574,6 +1574,7 @@ M: Yao Zi <[email protected]> S: Maintained F: arch/riscv/cpu/th1520/ F: drivers/clk/thead/clk-th1520-ap.c +F: drivers/pinctrl/pinctrl-th1520.c F: drivers/ram/thead/th1520_ddr.c RNG
drivers/pinctrl/Kconfig +8 -0
@@ -341,6 +341,14 @@ config SPL_PINCTRL_STMFX This option is an SPL-variant of the SPL_PINCTRL_STMFX option. See the help of PINCTRL_STMFX for details. +config PINCTRL_TH1520 + bool "T-Head TH1520 pinctrl driver" + depends on DM && PINCTRL_FULL + select PINCONF + help + Support pin multiplexing and configuration control blocks on the + T-Head TH1520 SoC. + config ASPEED_AST2500_PINCTRL bool "Aspeed AST2500 pin control driver" depends on DM && PINCTRL_GENERIC && ASPEED_AST2500
drivers/pinctrl/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_PINCTRL_STI) += pinctrl-sti.o obj-$(CONFIG_PINCTRL_STM32) += pinctrl_stm32.o obj-$(CONFIG_$(PHASE_)PINCTRL_SX150X) += pinctrl-sx150x.o obj-$(CONFIG_$(PHASE_)PINCTRL_STMFX) += pinctrl-stmfx.o +obj-$(CONFIG_PINCTRL_TH1520) += pinctrl-th1520.o obj-y += broadcom/ obj-$(CONFIG_PINCTRL_ZYNQMP) += pinctrl-zynqmp.o obj-$(CONFIG_PINCTRL_STARFIVE) += starfive/
drivers/pinctrl/pinctrl-th1520.c new file +700 -0
700 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH 1/3] pinctrl: Port pin controller driver for T-Head TH1520 SoC
Quoted 11 lines · Yao Zi
The SoC pads of TH1520 are separated into three groups (AP 1, AP 2 and AON) controlled by independent pin controllers. This patch ports their driver from Linux kernel with most code for setting pinconf and pinmux kept as is.
The dt-binding of TH1520 pin controller uses a schema where pins to configure are specfied as strings and looked up at runtime, which the generic pinctrl helpers of U-Boot cannot parse, thus a customized
set_state()callback is implemented to parse pinconfig nodes and setup the configuration.
Quoted 8 lines
Signed-off-by Yao Zi <[email protected]>--- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 8 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-th1520.c | 700 +++++++++++++++++++++++++++++++ 4 files changed, 710 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-th1520.c
PATCH 2/3 riscv: dts: th1520: Add pin controllers
In reply to Yao ZiDescribe the three pin controllers integrated in TH1520 SoC. Since we don't have support for clocks in the AON region, a dummy fixed-clock node is added to supply the pin controller locating in it.
--- arch/riscv/dts/th1520.dtsi | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
arch/riscv/dts/th1520.dtsi +28 -0
@@ -128,6 +128,13 @@ #clock-cells = <0>; }; + aonsys_clk: clock-73728000 { + compatible = "fixed-clock"; + clock-frequency = <73728000>; + clock-output-names = "aonsys_clk"; + #clock-cells = <0>; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&plic>;
@@ -259,6 +266,13 @@ }; }; + padctrl1_apsys: pinctrl@ffe7f3c000 { + compatible = "thead,th1520-pinctrl"; + reg = <0xff 0xe7f3c000 0x0 0x1000>; + clocks = <&clk CLK_PADCTRL1>; + thead,pad-group = <2>; + }; + gpio0: gpio@ffec005000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xec005000 0x0 0x1000>;
@@ -299,6 +313,13 @@ }; }; + padctrl0_apsys: pinctrl@ffec007000 { + compatible = "thead,th1520-pinctrl"; + reg = <0xff 0xec007000 0x0 0x1000>; + clocks = <&clk CLK_PADCTRL0>; + thead,pad-group = <3>; + }; + uart2: serial@ffec010000 { compatible = "snps,dw-apb-uart"; reg = <0xff 0xec010000 0x0 0x4000>;
@@ -439,6 +460,13 @@ }; }; + padctrl_aosys: pinctrl@fffff4a000 { + compatible = "thead,th1520-pinctrl"; + reg = <0xff 0xfff4a000 0x0 0x2000>; + clocks = <&aonsys_clk>; + thead,pad-group = <1>; + }; + ao_gpio1: gpio@fffff52000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xfff52000 0x0 0x1000>;
Signature · 1 line
2.49.0
Re: [PATCH 2/3] riscv: dts: th1520: Add pin controllers
Quoted 8 lines · Yao Zi
Describe the three pin controllers integrated in TH1520 SoC. Since we don't have support for clocks in the AON region, a dummy fixed-clock node is added to supply the pin controller locating in it.
Signed-off-by Yao Zi <[email protected]>--- arch/riscv/dts/th1520.dtsi | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
PATCH 3/3 riscv: cpu: th1520: Enable pinctrl by default
In reply to Yao ZiSelect PINCTRL_TH1520 in CPU Kconfig entry and update defconfig for existing TH1520-based boards to ensure PINCTRL is enabled.
--- arch/riscv/cpu/th1520/Kconfig | 1 + configs/th1520_lpi4a_defconfig | 1 + 2 files changed, 2 insertions(+)
arch/riscv/cpu/th1520/Kconfig +1 -0
@@ -11,6 +11,7 @@ config THEAD_TH1520 select BINMAN if SPL select SYS_CACHE_THEAD_CMO select CLK_THEAD + select PINCTRL_TH1520 imply CPU imply CPU_RISCV imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE)
configs/th1520_lpi4a_defconfig +1 -0
@@ -105,3 +105,4 @@ CONFIG_ZLIB_UNCOMPRESS=y CONFIG_BZIP2=y CONFIG_ZSTD=y CONFIG_LIB_RATIONAL=y +CONFIG_PINCTRL=y
Signature · 1 line
2.49.0
Re: [PATCH 3/3] riscv: cpu: th1520: Enable pinctrl by default
Quoted 8 lines · Yao Zi
Select
PINCTRL_TH1520in CPUKconfigentry and update defconfig for existing TH1520-based boards to ensure PINCTRL is enabled.Signed-off-by Yao Zi <[email protected]>--- arch/riscv/cpu/th1520/Kconfig | 1 + configs/th1520_lpi4a_defconfig | 1 + 2 files changed, 2 insertions(+)