[U-Boot] [PATCH] mpc83xx fdt: do not adjust clock frequency of external UARTs

David Müller d.mueller at elsoft.ch
Fri Apr 15 14:30:33 CEST 2011


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.

Signed-off-by: David Müller <d.mueller at elsoft.ch>

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

diff --git a/arch/powerpc/cpu/mpc83xx/fdt.c b/arch/powerpc/cpu/mpc83xx/fdt.c
index daf73a6..e13e2b3 100644
--- a/arch/powerpc/cpu/mpc83xx/fdt.c
+++ b/arch/powerpc/cpu/mpc83xx/fdt.c
@@ -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);
-- 
1.7.1



More information about the U-Boot mailing list