From: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] fdt expert advice needed
Date: Sun, 1 Feb 2009 22:30:20 +0100 [thread overview]
Message-ID: <200902012230.21268.matthias.fuchs@esd-electronics.com> (raw)
In-Reply-To: <49836F84.2090000@freescale.com>
Hi Scott,
thanks for your hint. Please see my updated code below.
Do you think it's ok this way?
Matthias
---
cpu/ppc4xx/fdt.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/cpu/ppc4xx/fdt.c b/cpu/ppc4xx/fdt.c
index c55e1cf..f9ff560 100644
--- a/cpu/ppc4xx/fdt.c
+++ b/cpu/ppc4xx/fdt.c
@@ -113,6 +113,7 @@ void fdt_pcie_setup(void *blob)
void ft_cpu_setup(void *blob, bd_t *bd)
{
sys_info_t sys_info;
+ int off, ndepth = 0;
get_sys_info(&sys_info);
@@ -133,9 +134,28 @@ void ft_cpu_setup(void *blob, bd_t *bd)
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
/*
- * Setup all baudrates for the UARTs
+ * Setup all UART clocks for CPU internal UARTs
+ * (only these UARTs are definetely clocked by gd->uart_clk)
+ *
+ * These UARTs are direct childs of /plb/opb. This code
+ * does not touch any UARTs that are connected to the ebc.
*/
- do_fixup_by_compat_u32(blob, "ns16550", "clock-frequency", gd->uart_clk, 1);
+ off = fdt_path_offset(blob, "/plb/opb");
+ while ((off = fdt_next_node(blob, off, &ndepth)) >= 0) {
+ /*
+ * process all sub nodes and stop when we are back
+ * at the starting depth
+ */
+ if (ndepth == 0)
+ break;
+
+ /* only update direct childs */
+ if ((ndepth == 1) &&
+ (fdt_node_check_compatible(blob, off, "ns16550") == 0))
+ fdt_setprop(blob, off,
+ "clock-frequency",
+ (void*)&(gd->uart_clk), 4);
+ }
/*
* Fixup all ethernet nodes
--
1.5.6.3
> Scott Wood wrote:
> > Matthias Fuchs wrote:
> >> Now I want to replace the above code to only touch the ns16550 compatible nodes
> >> that are direct childs of /plb/opb. Not those under /plb/ebc and even not those under
> >> /plb/opb/ebc. This is not easy to do with the fdt API. Below you find my first and dirty
> >> hack.
> >>
> >> Isn't there a more simple way to do so? Don't bother me about the printf, variable names etc.
> >> It's just for discussion.
> >
> > Take the node that you want to search under (/plb/opb), and pass it to
> > fdt_next_node(), with an initial depth of zero. Continue until depth
> > returns to zero (or less).
>
> I just saw that you want to restrict it to direct children -- for that,
> ignore any nodes where depth != 1.
>
> -Scott
next prev parent reply other threads:[~2009-02-01 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-30 21:11 [U-Boot] [RFC] fdt expert advice needed Matthias Fuchs
2009-01-30 21:18 ` Scott Wood
2009-01-30 21:22 ` Scott Wood
2009-02-01 21:30 ` Matthias Fuchs [this message]
2009-02-02 17:09 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200902012230.21268.matthias.fuchs@esd-electronics.com \
--to=matthias.fuchs@esd-electronics.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox