[PATCH 1/3] fsl_soc.c cleanup
Scott Wood
scottwood at freescale.com
Wed Aug 29 06:16:18 EST 2007
1. Fix get_immrbase() to use ranges, rather than reg.
It is not always the case that the SoC's first reg property points
to the beginning of the entire SoC block.
2. Update the way get_brgfreq() finds things in the device tree.
It now uses names that are less namespace polluting. The old names
are supported until all boards are converted.
3. "size" is changed from unsigned int to int, to match what
of_get_property() expects.
Signed-off-by: Scott Wood <scottwood at freescale.com>
---
arch/powerpc/sysdev/fsl_soc.c | 38 +++++++++++++++++++++++++++-----------
1 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index f3abce1..63e2350 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -52,11 +52,20 @@ phys_addr_t get_immrbase(void)
soc = of_find_node_by_type(NULL, "soc");
if (soc) {
- unsigned int size;
- const void *prop = of_get_property(soc, "reg", &size);
+ int size;
+ u32 naddr;
+ const u32 *prop = of_get_property(soc, "#address-cells", &size);
+
+ if (prop && size == 4)
+ naddr = *prop;
+ else
+ naddr = 2;
+
+ prop = of_get_property(soc, "ranges", &size);
+
+ if (prop && size >= 12)
+ immrbase = of_translate_address(soc, prop + naddr);
- if (prop)
- immrbase = of_translate_address(soc, prop);
of_node_put(soc);
};
@@ -76,16 +85,23 @@ u32 get_brgfreq(void)
if (brgfreq != -1)
return brgfreq;
- node = of_find_node_by_type(NULL, "cpm");
+ node = of_find_compatible_node(NULL, NULL, "fsl,cpm1");
+ if (!node)
+ node = of_find_compatible_node(NULL, NULL, "fsl,cpm2");
+ if (!node)
+ node = of_find_node_by_type(NULL, "cpm");
if (node) {
- unsigned int size;
- const unsigned int *prop = of_get_property(node,
- "brg-frequency", &size);
+ int size;
+ const unsigned int *prop;
- if (prop)
+ prop = of_get_property(node, "fsl,brg-frequency", &size);
+ if (!prop)
+ prop = of_get_property(node, "brg-frequency", &size);
+ if (prop && size == 4)
brgfreq = *prop;
+
of_node_put(node);
- };
+ }
return brgfreq;
}
@@ -103,7 +119,7 @@ u32 get_baudrate(void)
node = of_find_node_by_type(NULL, "serial");
if (node) {
- unsigned int size;
+ int size;
const unsigned int *prop = of_get_property(node,
"current-speed", &size);
--
1.5.0.3
More information about the Linuxppc-dev
mailing list