[U-Boot] [PATCH 4/8] serial: UniPhier: support OF configuration

Masahiro Yamada yamada.m at jp.panasonic.com
Wed Nov 26 10:34:00 CET 2014


This commit implements the ofdata_to_platdata handler for the UniPhier
serial driver and adds serial device nodes to the device tree sources.

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---

 arch/arm/dts/uniphier-ph1-ld4-ref.dts  |  9 +++++++++
 arch/arm/dts/uniphier-ph1-ld4.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/arm/dts/uniphier-ph1-pro4-ref.dts |  9 +++++++++
 arch/arm/dts/uniphier-ph1-pro4.dtsi    | 28 ++++++++++++++++++++++++++++
 arch/arm/dts/uniphier-ph1-sld8-ref.dts |  9 +++++++++
 arch/arm/dts/uniphier-ph1-sld8.dtsi    | 28 ++++++++++++++++++++++++++++
 drivers/serial/serial_uniphier.c       | 19 +++++++++++--------
 7 files changed, 122 insertions(+), 8 deletions(-)

diff --git a/arch/arm/dts/uniphier-ph1-ld4-ref.dts b/arch/arm/dts/uniphier-ph1-ld4-ref.dts
index 9f690dd..49642e1 100644
--- a/arch/arm/dts/uniphier-ph1-ld4-ref.dts
+++ b/arch/arm/dts/uniphier-ph1-ld4-ref.dts
@@ -21,5 +21,14 @@
 
 	chosen {
 		bootargs = "console=ttyPS0,115200 earlyprintk";
+		stdout-path = &uart0;
 	};
 };
+
+&uart0 {
+       status = "okay";
+};
+
+&uart1 {
+       status = "okay";
+};
diff --git a/arch/arm/dts/uniphier-ph1-ld4.dtsi b/arch/arm/dts/uniphier-ph1-ld4.dtsi
index ee53d9c..c1c2c62 100644
--- a/arch/arm/dts/uniphier-ph1-ld4.dtsi
+++ b/arch/arm/dts/uniphier-ph1-ld4.dtsi
@@ -28,5 +28,33 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 		ranges;
+
+		uart0: serial at 54006800 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006800 0x20>;
+			clock-frequency = <36864000>;
+		};
+
+		uart1: serial at 54006900 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006900 0x20>;
+			clock-frequency = <36864000>;
+		};
+
+		uart2: serial at 54006a00 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006a00 0x20>;
+			clock-frequency = <36864000>;
+		};
+
+		uart3: serial at 54006b00 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006b00 0x20>;
+			clock-frequency = <36864000>;
+		};
 	};
 };
diff --git a/arch/arm/dts/uniphier-ph1-pro4-ref.dts b/arch/arm/dts/uniphier-ph1-pro4-ref.dts
index 9a5823e..cfed70b 100644
--- a/arch/arm/dts/uniphier-ph1-pro4-ref.dts
+++ b/arch/arm/dts/uniphier-ph1-pro4-ref.dts
@@ -21,5 +21,14 @@
 
 	chosen {
 		bootargs = "console=ttyPS0,115200 earlyprintk";
+		stdout-path = &uart0;
 	};
 };
+
+&uart0 {
+       status = "okay";
+};
+
+&uart1 {
+       status = "okay";
+};
diff --git a/arch/arm/dts/uniphier-ph1-pro4.dtsi b/arch/arm/dts/uniphier-ph1-pro4.dtsi
index 7619c36..b53fbc5 100644
--- a/arch/arm/dts/uniphier-ph1-pro4.dtsi
+++ b/arch/arm/dts/uniphier-ph1-pro4.dtsi
@@ -34,5 +34,33 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 		ranges;
+
+		uart0: serial at 54006800 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006800 0x20>;
+			clock-frequency = <73728000>;
+		};
+
+		uart1: serial at 54006900 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006900 0x20>;
+			clock-frequency = <73728000>;
+		};
+
+		uart2: serial at 54006a00 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006a00 0x20>;
+			clock-frequency = <73728000>;
+		};
+
+		uart3: serial at 54006b00 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006b00 0x20>;
+			clock-frequency = <73728000>;
+		};
 	};
 };
diff --git a/arch/arm/dts/uniphier-ph1-sld8-ref.dts b/arch/arm/dts/uniphier-ph1-sld8-ref.dts
index 75f35da..d38df3c 100644
--- a/arch/arm/dts/uniphier-ph1-sld8-ref.dts
+++ b/arch/arm/dts/uniphier-ph1-sld8-ref.dts
@@ -21,5 +21,14 @@
 
 	chosen {
 		bootargs = "console=ttyPS0,115200 earlyprintk";
+		stdout-path = &uart0;
 	};
 };
+
+&uart0 {
+       status = "okay";
+};
+
+&uart1 {
+       status = "okay";
+};
diff --git a/arch/arm/dts/uniphier-ph1-sld8.dtsi b/arch/arm/dts/uniphier-ph1-sld8.dtsi
index 2f895e9..9a8da5e 100644
--- a/arch/arm/dts/uniphier-ph1-sld8.dtsi
+++ b/arch/arm/dts/uniphier-ph1-sld8.dtsi
@@ -28,5 +28,33 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 		ranges;
+
+		uart0: serial at 54006800 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006800 0x20>;
+			clock-frequency = <80000000>;
+		};
+
+		uart1: serial at 54006900 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006900 0x20>;
+			clock-frequency = <80000000>;
+		};
+
+		uart2: serial at 54006a00 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006a00 0x20>;
+			clock-frequency = <80000000>;
+		};
+
+		uart3: serial at 54006b00 {
+			compatible = "panasonic,uniphier-uart";
+			status = "disabled";
+			reg = <0x54006b00 0x20>;
+			clock-frequency = <80000000>;
+		};
 	};
 };
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 6046efb..e8a1608 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -11,6 +11,7 @@
 #include <dm/device.h>
 #include <dm/platform_data/serial-uniphier.h>
 #include <serial.h>
+#include <fdtdec.h>
 
 #define UART_REG(x)					\
 	u8 x;						\
@@ -113,19 +114,21 @@ static int uniphier_serial_remove(struct udevice *dev)
 }
 
 #ifdef CONFIG_OF_CONTROL
-static const struct udevice_id uniphier_uart_of_match = {
-	{ .compatible = "panasonic,uniphier-uart"},
+static const struct udevice_id uniphier_uart_of_match[] = {
+	{ .compatible = "panasonic,uniphier-uart" },
 	{},
 };
 
 static int uniphier_serial_ofdata_to_platdata(struct udevice *dev)
 {
-	/*
-	 * TODO: Masahiro Yamada (yamada.m at jp.panasonic.com)
-	 *
-	 * Implement conversion code from DTB to platform data
-	 * when supporting CONFIG_OF_CONTROL on UniPhir platform.
-	 */
+	struct uniphier_serial_platform_data *plat = dev_get_platdata(dev);
+	DECLARE_GLOBAL_DATA_PTR;
+
+	plat->base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+	plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+				       "clock-frequency", 0);
+
+	return 0;
 }
 #endif
 
-- 
1.9.1



More information about the U-Boot mailing list