]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Migrate 5xxx boards from CONFIG_OF_FLAT_TREE to CONFIG_OF_LIBFDT
authorGrant Likely <grant.likely@secretlab.ca>
Thu, 6 Sep 2007 15:46:23 +0000 (09:46 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Thu, 6 Sep 2007 15:46:23 +0000 (09:46 -0600)
Affects boards: icecube (lite5200), jupiter, motionpro, tqm5200

Tested on: lite5200b

Note: the fixup functions have not been moved to a common place.  This
patch is targeted for immediate merging as in solves a build issue, but
the final name/location of the fixups is still subject to debate.  I
propose to merge this now, and move the fixups in the next merge window
to be usable by all targets.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
board/icecube/icecube.c
board/jupiter/jupiter.c
board/motionpro/motionpro.c
board/tqm5200/tqm5200.c
cpu/mpc5xxx/cpu.c
include/configs/IceCube.h
include/configs/TQM5200.h
include/configs/jupiter.h
include/configs/motionpro.h

index c027f6f34e61dad7107faf8c723cc83d5367182c..07ba2459d89023c59c9faff3a8f125d5f3cea4c6 100644 (file)
 #include <mpc5xxx.h>
 #include <pci.h>
 #include <asm/processor.h>
-
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-#endif
+#include <libfdt.h>
 
 #if defined(CONFIG_LITE5200B)
 #include "mt46v32m16.h"
@@ -386,7 +383,7 @@ void ide_set_reset (int idereset)
 }
 #endif
 
-#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
index b2274875e5158f3a7464ba4f646bfada354315a9..efdc333493ec6d40413d37cf87b12f2346958048 100644 (file)
 #include <mpc5xxx.h>
 #include <pci.h>
 #include <asm/processor.h>
-
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-#endif
-
+#include <libfdt.h>
 
 #define SDRAM_DDR      0
 #if 1
@@ -308,7 +304,7 @@ void ide_set_reset (int idereset)
 }
 #endif
 
-#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
index 6eb5fe9cfc9950a914e9ebfad3d274a9cc701e6a..f83998e5aa05c9970ff1cf844e38d483c3b72e29 100644 (file)
@@ -29,9 +29,7 @@
 #include <common.h>
 #include <mpc5xxx.h>
 #include <miiphy.h>
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-#endif
+#include <libfdt.h>
 
 #if defined(CONFIG_STATUS_LED)
 #include <status_led.h>
@@ -196,12 +194,12 @@ int checkboard(void)
 }
 
 
-#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 }
-#endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */
+#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
 
 
 #if defined(CONFIG_STATUS_LED)
index 51f4aebc06e0b46a990ab14003d4a75554f766fe..21f67aa4e535a7329b3153227dda6705f240cead 100644 (file)
 #include <mpc5xxx.h>
 #include <pci.h>
 #include <asm/processor.h>
-
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-#endif
+#include <libfdt.h>
 
 #ifdef CONFIG_VIDEO_SM501
 #include <sm501.h>
@@ -780,9 +777,9 @@ int board_get_height (void)
 
 #endif /* CONFIG_VIDEO_SM501 */
 
-#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 }
-#endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */
+#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
index 1eac2bbfbe10a2f1e64c4d5f0bb959630c366258..7f16b92a6cac06af26f00a9a267f7bd6c371323a 100644 (file)
 #include <watchdog.h>
 #include <command.h>
 #include <mpc5xxx.h>
+#include <asm/io.h>
 #include <asm/processor.h>
 
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#include <libfdt_env.h>
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -111,29 +113,43 @@ unsigned long get_tbclk (void)
 
 /* ------------------------------------------------------------------------- */
 
-#ifdef CONFIG_OF_FLAT_TREE
-void
-ft_cpu_setup(void *blob, bd_t *bd)
+#ifdef CONFIG_OF_LIBFDT
+static void do_fixup(void *fdt, const char *node, const char *prop,
+                    const void *val, int len, int create)
 {
-       u32 *p;
-       int len;
-
-       /* Core XLB bus frequency */
-       p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
-       if (p != NULL)
-               *p = cpu_to_be32(bd->bi_busfreq);
-
-       /* SOC peripherals use the IPB bus frequency */
-       p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len);
-       if (p != NULL)
-               *p = cpu_to_be32(bd->bi_ipbfreq);
-
-       p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/mac-address", &len);
-       if (p != NULL)
-               memcpy(p, bd->bi_enetaddr, 6);
-
-       p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/local-mac-address", &len);
-       if (p != NULL)
-               memcpy(p, bd->bi_enetaddr, 6);
+#if defined(DEBUG)
+       int i;
+       debug("Updating property '%s/%s' = ", node, prop);
+       for (i = 0; i < len; i++)
+               debug(" %.2x", *(u8*)(val+i));
+       debug("\n");
+#endif
+       int rc = fdt_find_and_setprop(fdt, node, prop, val, len, create);
+       if (rc)
+               printf("Unable to update property %s:%s, err=%s\n",
+                      node, prop, fdt_strerror(rc));
+}
+
+static void do_fixup_u32(void *fdt, const char *node, const char *prop,
+                        u32 val, int create)
+{
+       val = cpu_to_fdt32(val);
+       do_fixup(fdt, node, prop, &val, sizeof(val), create);
+}
+
+void ft_cpu_setup(void *blob, bd_t *bd)
+{
+       int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4;
+       char * cpu_path = "/cpus/" OF_CPU;
+       char * eth_path = "/" OF_SOC "/ethernet@3000";
+
+       do_fixup_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
+       do_fixup_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
+       do_fixup_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
+       do_fixup_u32(blob, "/" OF_SOC, "bus-frequency", bd->bi_ipbfreq, 1);
+       do_fixup_u32(blob, "/" OF_SOC, "system-frequency",
+                       bd->bi_busfreq*div, 1);
+       do_fixup(blob, eth_path, "mac-address", bd->bi_enetaddr, 6, 0);
+       do_fixup(blob, eth_path, "local-mac-address", bd->bi_enetaddr, 6, 0);
 }
 #endif
index bdd92bae3cc0c5fc9a38e092c21b0a5af4c3af2c..4c16d22959ce66e1014f8925ffae2860bb5d27d8 100644 (file)
 #endif /* CONFIG_MPC5200 */
 
 /* pass open firmware flat tree */
-#define CONFIG_OF_FLAT_TREE    1
+#define CONFIG_OF_LIBFDT       1
 #define CONFIG_OF_BOARD_SETUP  1
 
 #define OF_CPU                 "PowerPC,5200@0"
index c08173b075fef541f0d7cd843df13e6488e20f9d..e0c9d81be0838776d41a96b6d6c8189556c671ad 100644 (file)
  * Open firmware flat tree support
  *-----------------------------------------------------------------------
  */
-#define CONFIG_OF_FLAT_TREE    1
+#define CONFIG_OF_LIBFDT       1
 #define CONFIG_OF_BOARD_SETUP  1
 
 #define OF_CPU                 "PowerPC,5200@0"
index 4070ab971eb8c3b022a6086270f548131c0d040c..b7100e986cd04f4d13f21e08a679e5564fe0c5d9 100644 (file)
 
 #if 0
 /* pass open firmware flat tree */
-#define CONFIG_OF_FLAT_TREE    1
+#define CONFIG_OF_LIBFDT       1
 #define CONFIG_OF_BOARD_SETUP  1
 
 #define OF_CPU                 "PowerPC,5200@0"
index 82827c692f53f683a4a630d63007fa5af17fc25b..9a216321628f038af000ab541c167b2a2e1cc605 100644 (file)
@@ -417,7 +417,7 @@ extern void __led_set(led_id_t id, int state);
 #define CFG_RESET_ADDRESS      0xfff00100
 
 /* pass open firmware flat tree */
-#define CONFIG_OF_FLAT_TREE    1
+#define CONFIG_OF_LIBFDT       1
 #define CONFIG_OF_BOARD_SETUP  1
 
 #define OF_CPU                 "PowerPC,5200@0"