Skip to contentSkip to conversation

ARM: phycore-rk3288: Use UART2 as debug output

PATCH Applied Wadim Egorov 2 participants 6 messages Feb 9, 2017 – Feb 28, 2017

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

PATCH 1/2 ARM: phycore-rk3288: Use UART2 as debug output

RK3288's UART2 is the default debug uart interface.

---
 arch/arm/boards/phytec-som-rk3288/lowlevel.c | 11 +++++------
 arch/arm/dts/rk3288-phycore-som.dts          |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)
arch/arm/boards/phytec-som-rk3288/lowlevel.c +5 -6
index 7804a55..7649ef8 100644
@@ -30,14 +30,13 @@ ENTRY_FUNCTION(start_rk3288_phycore_som, r0, r1, r2)
 
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 		struct rk3288_grf * const grf = (void *)RK3288_GRF_BASE;
-		rk_clrsetreg(&grf->gpio4c_iomux,
-			GPIO4C1_MASK << GPIO4C1_SHIFT |
-			GPIO4C0_MASK << GPIO4C0_SHIFT,
-			GPIO4C1_UART0BT_SOUT << GPIO4C1_SHIFT |
-			GPIO4C0_UART0BT_SIN << GPIO4C0_SHIFT);
+		rk_clrsetreg(&grf->gpio7ch_iomux,
+			     GPIO7C7_MASK << GPIO7C7_SHIFT |
+			     GPIO7C6_MASK << GPIO7C6_SHIFT,
+			     GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
+			     GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
 		INIT_LL();
 	}
-
 	fdt = __dtb_rk3288_phycore_som_start - get_runtime_offset();
 
 	barebox_arm_entry(0x0, SZ_1G, fdt);
arch/arm/dts/rk3288-phycore-som.dts +1 -1
index 5410bd1..dd74bcf 100644
@@ -44,7 +44,7 @@
 	};
 
 	chosen {
-		stdout-path = &uart0;
+		stdout-path = &uart2;
 
 		environment-emmc {
 			compatible = "barebox,environment";
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/2 config: Set UART port 2 as debug port

---
 arch/arm/configs/rk3288_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/configs/rk3288_defconfig +1 -1
index f54f4cc..15e6c15 100644
@@ -26,7 +26,7 @@ CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_RESET_SOURCE=y
 CONFIG_DEBUG_INFO=y
 CONFIG_DEBUG_LL=y
-CONFIG_DEBUG_ROCKCHIP_UART_PORT=0
+CONFIG_DEBUG_ROCKCHIP_UART_PORT=2
 CONFIG_CMD_DMESG=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

RFC 1/1 serial: ns16550: Set read/write functions depending on reg-io-width

In reply to Wadim Egorov

Set proper register read/write functions depending on reg-io-width device tree property.

---

of_platform_device_create() creates resources in the device_d struct. ns16550_init_iomem() and ns16550_init_ioport() are reading the resources and it's flags (register width).
So both functions are not failing, because there is a valid resource. The res->flags might be not set at all. And if it is not set, the driver will use always IORESOURCE_MEM_8BIT.

With this patch the probe_dt() func will override the read/write funcs, if there is a valid reg-io-width property.

---
 drivers/serial/serial_ns16550.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/serial/serial_ns16550.c +19 -0
index c6548e3..752e77b 100644
@@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev)
 static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 {
 	struct device_node *np = dev->device_node;
+	u32 width;
 
 	if (!IS_ENABLED(CONFIG_OFDEVICE))
 		return;
 
 	of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
 	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
+	if (!of_property_read_u32(np, "reg-io-width", &width))
+		switch (width) {
+		case 1:
+			priv->read_reg = ns16550_read_reg_mmio_8;
+			priv->write_reg = ns16550_write_reg_mmio_8;
+			break;
+		case 2:
+			priv->read_reg = ns16550_read_reg_mmio_16;
+			priv->write_reg = ns16550_write_reg_mmio_16;
+			break;
+		case 4:
+			priv->read_reg = ns16550_read_reg_mmio_32;
+			priv->write_reg = ns16550_write_reg_mmio_32;
+			break;
+		default:
+			dev_err(dev, "unsupported reg-io-width (%d)\n",
+				width);
+		}
 }
 
 static struct ns16550_drvdata ns16450_drvdata = {
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [RFC] serial: ns16550: Set read/write functions depending on reg-io-width

Is this patch okay?

Am 09.02.2017 um 10:36 schrieb Wadim Egorov:

Quoted 45 lines

Set proper register read/write functions depending on reg-io-width device tree property.

---

of_platform_device_create() creates resources in the device_d struct. ns16550_init_iomem() and ns16550_init_ioport() are reading the resources and it's flags (register width).
So both functions are not failing, because there is a valid resource. The res->flags might be not set at all. And if it is not set, the driver will use always IORESOURCE_MEM_8BIT.

With this patch the probe_dt() func will override the read/write funcs, if there is a valid reg-io-width property.

---
 drivers/serial/serial_ns16550.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/serial/serial_ns16550.c +12 -0
index c6548e3..752e77b 100644
@@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev)
 static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 {
 	struct device_node *np = dev->device_node;
+	u32 width;
 
 	if (!IS_ENABLED(CONFIG_OFDEVICE))
 		return;
 
 	of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
 	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
+	if (!of_property_read_u32(np, "reg-io-width", &width))
+		switch (width) {
+		case 1:
+			priv->read_reg = ns16550_read_reg_mmio_8;
+			priv->write_reg = ns16550_write_reg_mmio_8;
+			break;
+		case 2:
+			priv->read_reg = ns16550_read_reg_mmio_16;
+			priv->write_reg = ns16550_write_reg_mmio_16;
+			break;
+		case 4:

drivers/serial/serial_ns16550.c static int ns16550_tstc(struct console_device *cdev) · line 317

Quoted 10 lines
drivers/serial/serial_ns16550.c +7 -0
+			priv->read_reg = ns16550_read_reg_mmio_32;
+			priv->write_reg = ns16550_write_reg_mmio_32;
+			break;
+		default:
+			dev_err(dev, "unsupported reg-io-width (%d)\n",
+				width);
+		}
 }
 
 static struct ns16550_drvdata ns16450_drvdata = {

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

Re: [RFC] serial: ns16550: Set read/write functions depending on reg-io-width

Quoted 1 line · Wadim Egorov

Is this patch okay?

I hope so, it's already applied ;)

Sascha

Quoted 65 lines

Am 09.02.2017 um 10:36 schrieb Wadim Egorov:

Quoted 45 lines

Set proper register read/write functions depending on reg-io-width device tree property.

---

of_platform_device_create() creates resources in the device_d struct. ns16550_init_iomem() and ns16550_init_ioport() are reading the resources and it's flags (register width).
So both functions are not failing, because there is a valid resource. The res->flags might be not set at all. And if it is not set, the driver will use always IORESOURCE_MEM_8BIT.

With this patch the probe_dt() func will override the read/write funcs, if there is a valid reg-io-width property.

---
 drivers/serial/serial_ns16550.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/serial/serial_ns16550.c +12 -0
index c6548e3..752e77b 100644
@@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev)
 static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 {
 	struct device_node *np = dev->device_node;
+	u32 width;
 
 	if (!IS_ENABLED(CONFIG_OFDEVICE))
 		return;
 
 	of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
 	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
+	if (!of_property_read_u32(np, "reg-io-width", &width))
+		switch (width) {
+		case 1:
+			priv->read_reg = ns16550_read_reg_mmio_8;
+			priv->write_reg = ns16550_write_reg_mmio_8;
+			break;
+		case 2:
+			priv->read_reg = ns16550_read_reg_mmio_16;
+			priv->write_reg = ns16550_write_reg_mmio_16;
+			break;
+		case 4:

drivers/serial/serial_ns16550.c static int ns16550_tstc(struct console_device *cdev) · line 317

Quoted 10 lines
drivers/serial/serial_ns16550.c +7 -0
+			priv->read_reg = ns16550_read_reg_mmio_32;
+			priv->write_reg = ns16550_write_reg_mmio_32;
+			break;
+		default:
+			dev_err(dev, "unsupported reg-io-width (%d)\n",
+				width);
+		}
 }
 
 static struct ns16550_drvdata ns16450_drvdata = {

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#5 lore raw
In reply to Wadim Egorov
Quoted 4 lines · Wadim Egorov

RK3288's UART2 is the default debug uart interface.

---

Applied, thanks

Sascha

Quoted 50 lines
 arch/arm/boards/phytec-som-rk3288/lowlevel.c | 11 +++++------
 arch/arm/dts/rk3288-phycore-som.dts          |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)
arch/arm/boards/phytec-som-rk3288/lowlevel.c +5 -6
index 7804a55..7649ef8 100644
@@ -30,14 +30,13 @@ ENTRY_FUNCTION(start_rk3288_phycore_som, r0, r1, r2)
 
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 		struct rk3288_grf * const grf = (void *)RK3288_GRF_BASE;
-		rk_clrsetreg(&grf->gpio4c_iomux,
-			GPIO4C1_MASK << GPIO4C1_SHIFT |
-			GPIO4C0_MASK << GPIO4C0_SHIFT,
-			GPIO4C1_UART0BT_SOUT << GPIO4C1_SHIFT |
-			GPIO4C0_UART0BT_SIN << GPIO4C0_SHIFT);
+		rk_clrsetreg(&grf->gpio7ch_iomux,
+			     GPIO7C7_MASK << GPIO7C7_SHIFT |
+			     GPIO7C6_MASK << GPIO7C6_SHIFT,
+			     GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
+			     GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
 		INIT_LL();
 	}
-
 	fdt = __dtb_rk3288_phycore_som_start - get_runtime_offset();
 
 	barebox_arm_entry(0x0, SZ_1G, fdt);
arch/arm/dts/rk3288-phycore-som.dts +1 -1
index 5410bd1..dd74bcf 100644
@@ -44,7 +44,7 @@
 	};
 
 	chosen {
-		stdout-path = &uart0;
+		stdout-path = &uart2;
 
 		environment-emmc {
 			compatible = "barebox,environment";
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox