Skip to contentSkip to conversation

arm: s5p4418: migrate to DM_SERIAL

PATCH In review Stefan Bosch 2 participants 9 messages Dec 18, 2022 – Jan 3, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover arm: s5p4418: migrate to DM_SERIAL

This patch-series migrates the S5P4418-SOC and therefore also the s5p4418_nanopi2 board from CONFIG_SERIAL to CONFIG_DM_SERIAL.

Stefan Bosch (4):
arm: s5p4418: dm_serial: add driver source code
arm: s5p4418: dm_serial: add uarts to dts
arm: s5p4418: dm_serial: switch to DM_SERIAL
arm: s5p4418: dm_serial: remove old code / add DEBUG_UART

 MAINTAINERS                           |  1 +
 arch/arm/cpu/armv7/s5p4418/cpu.c      | 29 ---------
 arch/arm/dts/s5p4418-nanopi2.dts      |  6 ++
 arch/arm/dts/s5p4418-pinctrl.dtsi     | 71 ++++++++++++++++++++
 arch/arm/dts/s5p4418.dtsi             | 40 ++++++++++++
 arch/arm/mach-nexell/Kconfig          |  4 +-
 arch/arm/mach-nexell/clock.c          |  2 +-
 configs/s5p4418_nanopi2_defconfig     |  8 ++-
 drivers/serial/Kconfig                |  9 +++
 drivers/serial/Makefile               |  1 +
 drivers/serial/serial_s5p4418_pl011.c | 94 +++++++++++++++++++++++++++
 include/configs/s5p4418_nanopi2.h     |  8 +--
 12 files changed, 235 insertions(+), 38 deletions(-)
 create mode 100644 drivers/serial/serial_s5p4418_pl011.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 arm: s5p4418: dm_serial: add driver source code

Add dm_serial driver source code for S5P4418 SOC. Extend the "arm,pl011" driver by init of UART-clock and UART-reset.

---

 MAINTAINERS                           |  1 +
 drivers/serial/serial_s5p4418_pl011.c | 94 +++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)
 create mode 100644 drivers/serial/serial_s5p4418_pl011.c
MAINTAINERS +1 -0
index cb4d44584d..3473f765fd 100644
@@ -411,6 +411,7 @@ F:	drivers/gpio/nx_gpio.c
 F:	drivers/i2c/nx_i2c.c
 F:	drivers/mmc/nexell_dw_mmc_dm.c
 F:	drivers/pinctrl/nexell/
+F:	drivers/serial/serial_s5p4418_pl011.c
 F:	drivers/video/nexell/
 F:	drivers/video/nexell_display.c
 F:	include/configs/s5p4418_nanopi2.h
drivers/serial/serial_s5p4418_pl011.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v1 1/4] arm: s5p4418: dm_serial: add driver source code

Quoted 4 lines · Stefan Bosch

Add dm_serial driver source code for S5P4418 SOC. Extend the "arm,pl011" driver by init of UART-clock and UART-reset.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH 2/4 arm: s5p4418: dm_serial: add uarts to dts

In reply to Stefan Bosch

Add S5P4418 UARTs and appropriate pinctrl to dts. Add UART to s5p4418-nanopi2.dts.

---

 arch/arm/dts/s5p4418-nanopi2.dts  |  6 +++
 arch/arm/dts/s5p4418-pinctrl.dtsi | 71 +++++++++++++++++++++++++++++++
 arch/arm/dts/s5p4418.dtsi         | 40 +++++++++++++++++
 3 files changed, 117 insertions(+)
arch/arm/dts/s5p4418-nanopi2.dts +6 -0
index 4deaf10a1c..42251e0a05 100644
@@ -25,6 +25,7 @@
 		i2c0 = "/i2c@c00a4000";
 		i2c1 = "/i2c@c00a5000";
 		i2c2 = "/i2c@c00a6000";
+		serial0 = "/uart@c00a1000";
 	};
 
 	mmc0:mmc@c0062000 {
@@ -107,4 +108,9 @@
 			};
 		};
 	};
+
+	uart0:uart@c00a1000 {
+		skip-init;
+		status = "okay";
+	};
 };
arch/arm/dts/s5p4418-pinctrl.dtsi +71 -0

75 lines not on this page · raw message

arch/arm/dts/s5p4418.dtsi +40 -0
index a4d1a1bd03..3027cd4bb9 100644
@@ -167,4 +167,44 @@
 		reg = <0xc0010000 0xf000>;
 		u-boot,dm-pre-reloc;
 	};
+
+	uart0:uart@c00a1000 {
+		compatible = "nexell,s5p4418-pl011", "arm,primecell";
+		reg = <0xc00a1000 0x1000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart0_rx>, <&uart0_tx>;
+		status = "disabled";
+	};
+
+	uart1:uart@c00a0000 {
+		compatible = "nexell,s5p4418-pl011", "arm,primecell";
+		reg = <0xc00a0000 0x1000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart1_rx>, <&uart1_tx>;
+		status = "disabled";
+	};
+
+	uart2:uart@c00a2000 {
+		compatible = "nexell,s5p4418-pl011", "arm,primecell";
+		reg = <0xc00a2000 0x1000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart2_rx>, <&uart2_tx>;
+		status = "disabled";
+	};
+
+	uart3:uart@c00a3000 {
+		compatible = "nexell,s5p4418-pl011", "arm,primecell";
+		reg = <0xc00a3000 0x1000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart3_rx>, <&uart3_tx>;
+		status = "disabled";
+	};
+
+	uart4:uart@c006d000 {
+		compatible = "nexell,s5p4418-pl011", "arm,primecell";
+		reg = <0xc006d000 0x1000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart4_rx>, <&uart4_tx>;
+		status = "disabled";
+	};
 };
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v1 2/4] arm: s5p4418: dm_serial: add uarts to dts

Quoted 4 lines · Stefan Bosch

Add S5P4418 UARTs and appropriate pinctrl to dts. Add UART to s5p4418-nanopi2.dts.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 3/4 arm: s5p4418: dm_serial: switch to DM_SERIAL

In reply to Stefan Bosch

Switch the S5P4418-SOC and therefore the s5p4418_nanopi2 board to DM_SERIAL.

---

 arch/arm/mach-nexell/Kconfig | 4 ++--
 drivers/serial/Kconfig       | 9 +++++++++
 drivers/serial/Makefile      | 1 +
 3 files changed, 12 insertions(+), 2 deletions(-)
arch/arm/mach-nexell/Kconfig +2 -2
index 86a2398637..16324e1520 100644
@@ -6,8 +6,8 @@ config ARCH_S5P4418
 	select OF_CONTROL
 	select OF_SEPARATE
 	select NX_GPIO
-	select PL011_SERIAL
-	select PL011_SERIAL_FLUSH_ON_INIT
+	select DM_SERIAL
+	select PL01X_SERIAL
 	help
 	  Enable support for Nexell S5P4418 SoC.
 
drivers/serial/Kconfig +9 -0
index de02e08a29..b3e9bb4a15 100644
@@ -789,6 +789,15 @@ config S5P_SERIAL
 	help
 	  Select this to enable Samsung S5P UART support.
 
+config S5P4418_PL011_SERIAL
+	bool "Extended PL011 driver for S5P4418"
+	depends on DM_SERIAL && PL01X_SERIAL && ARCH_NEXELL
+	default y
+	help
+	  Select this to enable support of the PL011 UARTs in the S5P4418 SOC.
+	  With this driver the UART-clocks are set to the appropriate rate
+	  (if not 'skip-init').
+
 config SANDBOX_SERIAL
 	bool "Sandbox UART support"
 	depends on SANDBOX
drivers/serial/Makefile +1 -0
index eb7b8f23ee..4853f4d59b 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o
 obj-$(CONFIG_HTIF_CONSOLE) += serial_htif.o
 obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
 obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
+obj-$(CONFIG_S5P4418_PL011_SERIAL) += serial_s5p4418_pl011.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH v1 3/4] arm: s5p4418: dm_serial: switch to DM_SERIAL

Quoted 4 lines · Stefan Bosch

Switch the S5P4418-SOC and therefore the s5p4418_nanopi2 board to DM_SERIAL.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#7 lore raw

PATCH 4/4 arm: s5p4418: dm_serial: remove old code / add DEBUG_UART

In reply to Stefan Bosch

Remove init of UART-clock and UART-reset in arch_cpu_init(). Add DEBUG_UART to s5p4418_nanopi2_defconfig.

---

 arch/arm/cpu/armv7/s5p4418/cpu.c  | 29 -----------------------------
 arch/arm/mach-nexell/clock.c      |  2 +-
 configs/s5p4418_nanopi2_defconfig |  8 +++++++-
 include/configs/s5p4418_nanopi2.h |  8 +++-----
 4 files changed, 11 insertions(+), 36 deletions(-)
arch/arm/cpu/armv7/s5p4418/cpu.c +0 -29
index 3baa761ec7..fcaafc0ff7 100644
@@ -13,10 +13,8 @@
 #include <asm/io.h>
 #include <asm/arch/nexell.h>
 #include <asm/arch/clk.h>
-#include <asm/arch/reset.h>
 #include <asm/arch/tieoff.h>
 #include <cpu_func.h>
-#include <linux/delay.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -45,39 +43,12 @@ static void cpu_soc_init(void)
 	nx_tieoff_set(NX_TIEOFF_CORTEXA9MP_TOP_QUADL2C_L2RET1N_1, 1);
 }
 
-#ifdef CONFIG_PL011_SERIAL
-static void serial_device_init(void)
-{
-	char dev[10];
-	int id;
-
-	sprintf(dev, "nx-uart.%d", CONFIG_CONS_INDEX);
-	id = RESET_ID_UART0 + CONFIG_CONS_INDEX;
-
-	struct clk *clk = clk_get((const char *)dev);
-
-	/* reset control: Low active ___|---   */
-	nx_rstcon_setrst(id, RSTCON_ASSERT);
-	udelay(10);
-	nx_rstcon_setrst(id, RSTCON_NEGATE);
-	udelay(10);
-
-	/* set clock   */
-	clk_disable(clk);
-	clk_set_rate(clk, CONFIG_PL011_CLOCK);
-	clk_enable(clk);
-}
-#endif
-
 int arch_cpu_init(void)
 {
 	flush_dcache_all();
 	cpu_soc_init();
 	clk_init();
 
-	if (IS_ENABLED(CONFIG_PL011_SERIAL))
-		serial_device_init();
-
 	return 0;
 }
 
arch/arm/mach-nexell/clock.c +1 -1
index 24fa204ccd..59ffa26255 100644
@@ -856,7 +856,7 @@ void __init clk_init(void)
 		}
 
 		/* prevent uart clock disable for low step debug message */
-		#ifndef CONFIG_DEBUG_NX_UART
+		#ifndef CONFIG_DEBUG_UART
 		if (peri->dev_name) {
 			#ifdef CONFIG_BACKLIGHT_PWM
 			if (!strcmp(peri->dev_name, DEV_NAME_PWM))
configs/s5p4418_nanopi2_defconfig +7 -1
index f3a316513c..042037acfc 100644
@@ -54,7 +54,7 @@ CONFIG_MMC_DW=y
 CONFIG_PINCTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_REGULATOR=y
-CONFIG_CONS_INDEX=0
+
 CONFIG_DM_VIDEO=y
 CONFIG_VIDEO_LOGO=y
 CONFIG_DISPLAY=y
@@ -67,3 +67,9 @@ CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_SPLASH_SOURCE=y
 CONFIG_BMP_24BPP=y
 CONFIG_ERRNO_STR=y
+
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_PL011=y
+CONFIG_DEBUG_UART_BASE=0xC00A1000
+CONFIG_DEBUG_UART_CLOCK=150000000
+CONFIG_DEBUG_UART_SKIP_INIT=y
include/configs/s5p4418_nanopi2.h +3 -5
index ae94f0ecc5..a6d3957dc1 100644
@@ -78,11 +78,9 @@
 /*-----------------------------------------------------------------------
  * serial console configuration
  */
-#define CONFIG_PL011_CLOCK		50000000
-#define CONFIG_PL01x_PORTS		{(void *)PHY_BASEADDR_UART0, \
-					 (void *)PHY_BASEADDR_UART1, \
-					 (void *)PHY_BASEADDR_UART2, \
-					 (void *)PHY_BASEADDR_UART3}
+
+/* 150MHz is the clock rate set by SPL (uart0) */
+#define CONFIG_PL011_CLOCK		150000000
 
 /*-----------------------------------------------------------------------
  * BACKLIGHT
Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH v1 4/4] arm: s5p4418: dm_serial: remove old code / add DEBUG_UART

Quoted 4 lines · Stefan Bosch

Remove init of UART-clock and UART-reset in arch_cpu_init(). Add DEBUG_UART to s5p4418_nanopi2_defconfig.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom