public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mpc83xx fdt: do not adjust clock frequency of external UARTs
@ 2011-04-15 12:30 David Müller
  2011-04-15 17:44 ` Timur Tabi
  2011-05-02 16:33 ` Kim Phillips
  0 siblings, 2 replies; 6+ messages in thread
From: David Müller @ 2011-04-15 12:30 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-02 16:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-15 12:30 [U-Boot] [PATCH] mpc83xx fdt: do not adjust clock frequency of external UARTs David Müller
2011-04-15 17:44 ` Timur Tabi
2011-04-16  5:30   ` "David Müller (ELSOFT AG)"
2011-04-16 12:41     ` Tabi Timur-B04825
2011-04-18  6:58       ` "David Müller (ELSOFT AG)"
2011-05-02 16:33 ` Kim Phillips

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox