Skip to contentSkip to conversation

mpc83xx fdt: do not adjust clock frequency of external UARTs

PATCH New David Müller 4 participants 6 messages Apr 15, 2011 – May 2, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpc83xx fdt: do not adjust clock frequency of external UARTs

The current 83xx FDT implementation adjusts the clock frequency of all 16550 UARTs found in the device tree. This behaviour is ok for the UARTs which are part of the SoC, but wrong for any additional external UART.

---
 arch/powerpc/cpu/mpc83xx/fdt.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
arch/powerpc/cpu/mpc83xx/fdt.c +25 -2
index daf73a6..e13e2b3 100644
@@ -50,6 +50,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 {
 	immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 	int spridr = immr->sysconf.spridr;
+	int off;
 
 	/*
 	 * delete crypto node if not on an E-processor
@@ -131,8 +132,30 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 #endif
 
 #ifdef CONFIG_SYS_NS16550
-	do_fixup_by_compat_u32(blob, "ns16550",
-		"clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
+	/*
+	 * fixup all UART clocks for CPU internal UARTs
+	 * (clock-frequency is usually 0) but do not touch
+	 * any other (external) UARTs
+	 */
+	off = fdt_node_offset_by_compatible(blob, -1, "ns16550");
+
+	while (off != -FDT_ERR_NOTFOUND) {
+		const struct fdt_property *prop;
+		int len;
+
+		prop = fdt_get_property(blob, off, "clock-frequency", &len);
+		if (prop && (len == 4)) {
+			u32 *data = (u32 *)prop->data;
+			u32 val = fdt32_to_cpu(*data);
+			if (val == 0) {
+				val = cpu_to_fdt32(CONFIG_SYS_NS16550_CLK);
+				fdt_setprop(blob, off,
+					    "clock-frequency", &val, 4);
+			}
+		}
+
+		off = fdt_node_offset_by_compatible(blob, off, "ns16550");
+	}
 #endif
 
 	fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 mpc83xx fdt: do not adjust clock frequency of external UARTs

Quoted 3 lines · David M?ller

The current 83xx FDT implementation adjusts the clock frequency of all 16550 UARTs found in the device tree. This behaviour is ok for the UARTs which are part of the SoC, but wrong for any additional external UART.

Just out of curiosity -- do you have an example of a device tree with an external UART?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#2 lore raw

PATCH 1/1 mpc83xx fdt: do not adjust clock frequency of external UARTs

Hello

Quoted 2 lines · Timur Tabi

Just out of curiosity -- do you have an example of a device tree with an external UART?

Yes.

Dave

#3 lore raw

PATCH 1/1 mpc83xx fdt: do not adjust clock frequency of external UARTs

Quoted 4 lines · David M?ller (ELSOFT AG)
Quoted 2 lines
Quoted 2 lines

Just out of curiosity -- do you have an example of a device tree with an external UART?

Yes.

May I see it?

Signature · 2 lines
Timur Tabi
Linux kernel developer
#5 lore raw

PATCH 1/1 mpc83xx fdt: do not adjust clock frequency of external UARTs

In reply to David Müller
Quoted 9 lines · On Fri, 15 Apr 2011 14:30:33 +0200 David M?ller <[email protected]> wrote:

The current 83xx FDT implementation adjusts the clock frequency of all 16550 UARTs found in the device tree. This behaviour is ok for the UARTs which are part of the SoC, but wrong for any additional external UART.

---
 arch/powerpc/cpu/mpc83xx/fdt.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

(a) this is not an mpc83xx-specific issue

(b) the fdt code here should instead be modified to only adjust clock properties on UART nodes contained within the SoC node, not the entire fdt.

Any UARTs not a part of the SoC should get their clocks updated in board/ code (or, as in this case, set manually in the device tree).

Kim