From ef11df6b66ecf5797e94ba322254b8fb7a4e2e12 Mon Sep 17 00:00:00 2001 From: John Rigby Date: Tue, 5 Aug 2008 17:38:57 -0600 Subject: mpc5121: squash some fdt fixup errors On ADS5121 when booting linux the following errors are seen: Unable to update property /soc5121@80000000:bus-frequency, err=FDT_ERR_NOTFOUND Unable to update property /soc5121@80000000/ethernet@2800:local-mac-address, err=FDT_ERR_NOTFOUND Unable to update property /soc5121@80000000/ethernet@2800:address, err=FDT_ERR_NOTFOUND This is caused by ft_cpu_setup trying to deal with both old and new soc node naming. This patch fixes this by being smarter about what to fixup. Also do soc node fixups by compatible instead of by path. A new board config called OF_SOC_COMPAT defined to be "fsl,mpc5121-immr" replaces the old OF_SOC node path that was defined to be "soc@80000000". Old device trees still work, but the compatiblity is conditional on CONFIG_OF_SUPPORT_OLD_DEVICE_TREES which is on by default in include/configs/ads5121.h. Signed-off-by: John Rigby --- cpu/mpc512x/cpu.c | 77 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 15 deletions(-) (limited to 'cpu/mpc512x') diff --git a/cpu/mpc512x/cpu.c b/cpu/mpc512x/cpu.c index b59f36d..81bae41 100644 --- a/cpu/mpc512x/cpu.c +++ b/cpu/mpc512x/cpu.c @@ -131,22 +131,69 @@ void watchdog_reset (void) #endif #ifdef CONFIG_OF_LIBFDT -void ft_cpu_setup(void *blob, bd_t *bd) + +#ifdef CONFIG_OF_SUPPORT_OLD_DEVICE_TREES +/* + * fdt setup for old device trees + * fix up + * cpu clocks + * soc clocks + * ethernet addresses + */ +static void old_ft_cpu_setup(void *blob, bd_t *bd) +{ + /* + * avoid fixing up by path because that + * produces scary error messages + */ + + /* + * old device trees have ethernet nodes with + * device_type = "network" + */ + do_fixup_by_prop(blob, "device_type", "network", 8, + "local-mac-address", bd->bi_enetaddr, 6, 0); + do_fixup_by_prop(blob, "device_type", "network", 8, + "address", bd->bi_enetaddr, 6, 0); + /* + * old device trees have soc nodes with + * device_type = "soc" + */ + do_fixup_by_prop_u32(blob, "device_type", "soc", 4, + "bus-frequency", bd->bi_ipsfreq, 0); +} +#endif + +static void ft_clock_setup(void *blob, bd_t *bd) { + int node; char *cpu_path = "/cpus/" OF_CPU; - char *eth_path = "/" OF_SOC "/ethernet@2800"; - char *eth_path_old = "/" OF_SOC_OLD "/ethernet@2800"; - - do_fixup_by_path_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1); - do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1); - do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1); - do_fixup_by_path_u32(blob, "/" OF_SOC, "bus-frequency", bd->bi_ipsfreq, 1); - do_fixup_by_path(blob, eth_path, "local-mac-address", bd->bi_enetaddr, 6, 0); - - /* this is so old kernels with old device trees will boot */ - do_fixup_by_path_u32(blob, "/" OF_SOC_OLD, "bus-frequency", bd->bi_ipsfreq, 0); - do_fixup_by_path(blob, eth_path_old, "local-mac-address", - bd->bi_enetaddr, 6, 0); - do_fixup_by_path(blob, eth_path_old, "address", bd->bi_enetaddr, 6, 0); + const char *path = NULL; + + /* + * fixup cpu clocks using path + */ + do_fixup_by_path_u32(blob, cpu_path, + "timebase-frequency", OF_TBCLK, 1); + do_fixup_by_path_u32(blob, cpu_path, + "bus-frequency", bd->bi_busfreq, 1); + do_fixup_by_path_u32(blob, cpu_path, + "clock-frequency", bd->bi_intfreq, 1); + /* + * fixup soc clocks using compatible + */ + do_fixup_by_compat_u32(blob, OF_SOC_COMPAT, + "bus-frequency", bd->bi_ipsfreq, 1); +} + +void ft_cpu_setup(void *blob, bd_t *bd) +{ +#ifdef CONFIG_OF_SUPPORT_OLD_DEVICE_TREES + old_ft_cpu_setup(blob, bd); +#endif + ft_clock_setup(blob, bd); +#ifdef CONFIG_HAS_ETH0 + fdt_fixup_ethernet(blob, bd); +#endif } #endif -- cgit v1.1 From 6689484ccd43189322aaa5a1c6cd02cdd511ad7d Mon Sep 17 00:00:00 2001 From: Kenneth Johansson Date: Tue, 15 Jul 2008 12:13:38 +0200 Subject: mpc5121: Move iopin features from board specific to common files. And in the process eliminate some duplicate register defines. Signed-off-by: Kenneth Johansson --- cpu/mpc512x/Makefile | 2 +- cpu/mpc512x/iopin.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 cpu/mpc512x/iopin.c (limited to 'cpu/mpc512x') diff --git a/cpu/mpc512x/Makefile b/cpu/mpc512x/Makefile index 2be35b2..8ba8ae8 100644 --- a/cpu/mpc512x/Makefile +++ b/cpu/mpc512x/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(CPU).a START = start.o -COBJS = traps.o cpu.o cpu_init.o speed.o interrupts.o serial.o fec.o i2c.o +COBJS = traps.o cpu.o cpu_init.o speed.o interrupts.o serial.o fec.o i2c.o iopin.o SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/cpu/mpc512x/iopin.c b/cpu/mpc512x/iopin.c new file mode 100644 index 0000000..01ab34a --- /dev/null +++ b/cpu/mpc512x/iopin.c @@ -0,0 +1,49 @@ +/* + * (C) Copyright 2008 + * Martha J Marx, Silicon Turnkey Express, mmarx@silicontkx.com + * mpc512x I/O pin/pad initialization for the ADS5121 board + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include + +void iopin_initialize(iopin_t *ioregs_init, int len) +{ + short i, j, n, p; + u_long *reg; + immap_t *im = (immap_t *)CFG_IMMR; + + reg = (u_long *)&(im->io_ctrl.regs[0]); + + if (sizeof(ioregs_init) == 0) + return; + + for (i = 0; i < len; i++) { + for (p = 0, j = ioregs_init[i].p_offset / sizeof(u_long); + p < ioregs_init[i].nr_pins; p++, j++) { + if (ioregs_init[i].bit_or) + reg[j] |= ioregs_init[i].val; + else + reg[j] = ioregs_init[i].val; + } + } + return; +} -- cgit v1.1 From c9c101c660b3d1995045c61c7c6041f52b6cf335 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Tue, 12 Aug 2008 00:36:53 +0200 Subject: ads5121: fix compiler warnings (unused variables) Signed-off-by: Wolfgang Denk --- cpu/mpc512x/cpu.c | 2 -- cpu/mpc512x/iopin.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'cpu/mpc512x') diff --git a/cpu/mpc512x/cpu.c b/cpu/mpc512x/cpu.c index 81bae41..703e188 100644 --- a/cpu/mpc512x/cpu.c +++ b/cpu/mpc512x/cpu.c @@ -166,9 +166,7 @@ static void old_ft_cpu_setup(void *blob, bd_t *bd) static void ft_clock_setup(void *blob, bd_t *bd) { - int node; char *cpu_path = "/cpus/" OF_CPU; - const char *path = NULL; /* * fixup cpu clocks using path diff --git a/cpu/mpc512x/iopin.c b/cpu/mpc512x/iopin.c index 01ab34a..3d7042d 100644 --- a/cpu/mpc512x/iopin.c +++ b/cpu/mpc512x/iopin.c @@ -27,7 +27,7 @@ void iopin_initialize(iopin_t *ioregs_init, int len) { - short i, j, n, p; + short i, j, p; u_long *reg; immap_t *im = (immap_t *)CFG_IMMR; -- cgit v1.1