Skip to contentSkip to conversation

mpc83xx: convert to using do_fixup_*()

PATCH New Kim Phillips 1 participant 1 message Dec 20, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mpc83xx: convert to using do_fixup_*()

convert to using simpler mpc85xx style fdt update code; streamline by eliminating macros OF_SOC, OF_CPU, etc. which allows us to rm the old school FLAT_TREE code from 83xx (since the sbc8349 was just converted over to using libfdt).

---
 board/freescale/mpc832xemds/pci.c         |   30 ++-
 board/freescale/mpc8349emds/pci.c         |   51 ++--
 board/freescale/mpc8349itx/pci.c          |   51 ++--
 board/freescale/mpc8360emds/mpc8360emds.c |   41 ++--
 board/freescale/mpc8360emds/pci.c         |   27 +-
 board/sbc8349/pci.c                       |   43 +++-
 cpu/mpc83xx/Makefile                      |    2 +-
 cpu/mpc83xx/cpu.c                         |  440 -----------------------------
 cpu/mpc83xx/fdt.c                         |   72 +++++
 cpu/mpc83xx/pci.c                         |   83 ++----
 include/configs/MPC8313ERDB.h             |    6 +-
 include/configs/MPC8323ERDB.h             |    7 +-
 include/configs/MPC832XEMDS.h             |    7 +-
 include/configs/MPC8349EMDS.h             |    6 +-
 include/configs/MPC8349ITX.h              |    8 +-
 include/configs/MPC8360EMDS.h             |    8 +-
 include/configs/MPC837XEMDS.h             |    6 +-
 include/configs/sbc8349.h                 |    6 +-
 18 files changed, 265 insertions(+), 629 deletions(-)
 create mode 100644 cpu/mpc83xx/fdt.c
board/freescale/mpc832xemds/pci.c +18 -12
index 7818a2e..d50b78a 100644
@@ -22,6 +22,7 @@
 #include <ft_build.h>
 #elif defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
+#include <fdt_support.h>
 #endif
 
 #include <asm/fsl_i2c.h>
@@ -262,23 +263,28 @@ void pci_init_board(void)
 #endif				/* CONFIG_PCISLAVE */
 
 #if defined(CONFIG_OF_LIBFDT)
-void
-ft_pci_setup(void *blob, bd_t *bd)
+void ft_pci_setup(void *blob, bd_t *bd)
 {
 	int nodeoffset;
-	int err;
 	int tmp[2];
+	const char *path;
+
+	if (pci_num_buses < 1)
+		return;
 
-	nodeoffset = fdt_path_offset(blob, "/" OF_SOC "/pci@8500");
+	nodeoffset = fdt_path_offset(blob, "/aliases");
 	if (nodeoffset >= 0) {
-		tmp[0] = cpu_to_be32(hose[0].first_busno);
-		tmp[1] = cpu_to_be32(hose[0].last_busno);
-		err = fdt_setprop(blob, nodeoffset, "bus-range",
-				  tmp, sizeof(tmp));
-
-		tmp[0] = cpu_to_be32(gd->pci_clk);
-		err = fdt_setprop(blob, nodeoffset, "clock-frequency",
-				  tmp, sizeof(tmp[0]));
+		path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
+		if (path) {
+			tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
+			tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
+			do_fixup_by_path(blob, path, "bus-range",
+				&tmp, sizeof(tmp), 1);
+
+			tmp[0] = cpu_to_be32(gd->pci_clk);
+			do_fixup_by_path(blob, path, "clock-frequency",
+				&tmp, sizeof(tmp[0]), 1);
+		}
 	}
 }
 #elif defined(CONFIG_OF_FLAT_TREE)
board/freescale/mpc8349emds/pci.c +27 -24

70 lines not on this page · raw message

board/freescale/mpc8349itx/pci.c +27 -24

70 lines not on this page · raw message

board/freescale/mpc8360emds/mpc8360emds.c +24 -17

49 lines not on this page · raw message

board/freescale/mpc8360emds/pci.c +15 -12
index f18e532..64cb8ad 100644
@@ -22,6 +22,7 @@
 #include <ft_build.h>
 #elif defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
+#include <fdt_support.h>
 #endif
 
 #include <asm/fsl_i2c.h>
@@ -262,23 +263,25 @@ void pci_init_board(void)
 #endif				/* CONFIG_PCISLAVE */
 
 #if defined(CONFIG_OF_LIBFDT)
-void
-ft_pci_setup(void *blob, bd_t *bd)
+void ft_pci_setup(void *blob, bd_t *bd)
 {
 	int nodeoffset;
-	int err;
 	int tmp[2];
+	const char *path;
 
-	nodeoffset = fdt_path_offset(blob, "/" OF_SOC "/pci at 8500");
+	nodeoffset = fdt_path_offset(blob, "/aliases");
 	if (nodeoffset >= 0) {
-		tmp[0] = cpu_to_be32(hose[0].first_busno);
-		tmp[1] = cpu_to_be32(hose[0].last_busno);
-		err = fdt_setprop(blob, nodeoffset, "bus-range",
-				  tmp, sizeof(tmp));
-
-		tmp[0] = cpu_to_be32(gd->pci_clk);
-		err = fdt_setprop(blob, nodeoffset, "clock-frequency",
-				  tmp, sizeof(tmp[0]));
+		path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
+		if (path) {
+			tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
+			tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
+			do_fixup_by_path(blob, path, "bus-range",
+				&tmp, sizeof(tmp), 1);
+
+			tmp[0] = cpu_to_be32(gd->pci_clk);
+			do_fixup_by_path(blob, path, "clock-frequency",
+				&tmp, sizeof(tmp[0]), 1);
+		}
 	}
 }
 #elif defined(CONFIG_OF_FLAT_TREE)
board/sbc8349/pci.c +42 -1

55 lines not on this page · raw message

cpu/mpc83xx/Makefile +1 -1
index 2329970..94a3cb8 100644
@@ -29,7 +29,7 @@ LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
 COBJS	= traps.o cpu.o cpu_init.o speed.o interrupts.o \
-	  spd_sdram.o ecc.o qe_io.o pci.o
+	  spd_sdram.o ecc.o qe_io.o pci.o fdt.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
cpu/mpc83xx/cpu.c +0 -440

453 lines not on this page · raw message

cpu/mpc83xx/fdt.c new file +72 -0

72 lines not on this page · raw message

cpu/mpc83xx/pci.c +30 -53

101 lines not on this page · raw message

include/configs/MPC8313ERDB.h +1 -5
index 0c3bc16..c9a9c83 100644
@@ -231,11 +231,7 @@
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,8313 at 0"
-#define OF_SOC			"soc8313 at e0000000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8313 at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /*
  * Serial Port
include/configs/MPC8323ERDB.h +1 -6
index 558f94b..564de02 100644
@@ -270,12 +270,7 @@
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,8323 at 0"
-#define OF_SOC			"soc8323 at e0000000"
-#define OF_QE			"qe at e0100000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8323 at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
include/configs/MPC832XEMDS.h +1 -6
index 5345fc6..a48b311 100644
@@ -321,12 +321,7 @@
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,8323 at 0"
-#define OF_SOC			"soc8323 at e0000000"
-#define OF_QE			"qe at e0100000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8323 at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
include/configs/MPC8349EMDS.h +1 -5
index 7d5b17b..03409bb 100644
@@ -341,11 +341,7 @@
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,8349 at 0"
-#define OF_SOC			"soc8349 at e0000000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8349 at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
 #define CONFIG_HARD_I2C			/* I2C with hardware support*/
include/configs/MPC8349ITX.h +2 -6
index 2a2e753..49dc0de 100644
@@ -298,12 +298,8 @@ boards, we say we have two, but don't display a message if we find only one. */
 
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
-#define CONFIG_OF_BOARD_SETUP
-
-#define OF_CPU			"PowerPC,8349 at 0"
-#define OF_SOC			"soc8349 at e0000000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8349 at e0000000/serial at 4500"
+#define CONFIG_OF_BOARD_SETUP	1
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /*
  * PCI
include/configs/MPC8360EMDS.h +1 -7
index c192f33..fedb8a9 100644
@@ -347,14 +347,8 @@
 
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
-#undef  CONFIG_OF_FLAT_TREE
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,8360 at 0"
-#define OF_SOC			"soc8360 at e0000000"
-#define OF_QE			"qe at e0100000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8360 at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
include/configs/MPC837XEMDS.h +1 -5
index 772fd02..0958e6b 100644
@@ -297,11 +297,7 @@
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,837x at 0"
-#define OF_SOC			"soc837x at e0000000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc837x at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
include/configs/sbc8349.h +1 -5
index 45f20dc..9efe3c4 100644
@@ -312,11 +312,7 @@
 /* pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
-
-#define OF_CPU			"PowerPC,8349 at 0"
-#define OF_SOC			"soc8349 at e0000000"
-#define OF_TBCLK		(bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH		"/soc8349 at e0000000/serial at 4500"
+#define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
 /* I2C */
 #define CONFIG_HARD_I2C			/* I2C with hardware support*/
Signature · 1 line
1.5.3