3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /* define DEBUG for debugging output (obviously ;-)) */
32 #include <asm/cache.h>
35 #if defined(CONFIG_OF_LIBFDT)
37 #include <libfdt_env.h>
38 #include <fdt_support.h>
40 DECLARE_GLOBAL_DATA_PTR;
43 * The aliases needed for this generic etherne MAC address
44 * fixup function are not in place yet. So don't use this
45 * approach for now. This will be enabled later.
47 #undef USES_FDT_ALIASES
49 #ifndef USES_FDT_ALIASES
50 static void do_fixup_macaddr(void *fdt, int offset, const void *val, int i)
54 debug("Updating node EMAC%d\n", i);
56 rc = fdt_setprop(fdt, offset, "mac-address", val, 6);
58 printf("Unable to update property %s, err=%s\n",
59 "mac-address", fdt_strerror(rc));
60 rc = fdt_setprop(fdt, offset, "local-mac-address", val, 6);
62 printf("Unable to update property %s, err=%s\n",
63 "local-mac-address", fdt_strerror(rc));
65 #endif /* USES_FDT_ALIASES */
67 void ft_cpu_setup(void *blob, bd_t *bd)
69 char *cpu_path = "/cpus/" OF_CPU;
74 get_sys_info(&sys_info);
76 do_fixup_by_path_u32(blob, cpu_path, "timebase-frequency", bd->bi_intfreq, 1);
77 do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
78 do_fixup_by_path_u32(blob, "/plb", "clock-frequency", sys_info.freqPLB, 1);
79 do_fixup_by_path_u32(blob, "/plb/opb", "clock-frequency", sys_info.freqOPB, 1);
80 do_fixup_by_path_u32(blob, "/plb/opb/ebc", "clock-frequency",
82 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
85 * Setup all baudrates for the UARTs
87 do_fixup_by_compat_u32(blob, "ns16550", "clock-frequency", gd->uart_clk, 1);
89 #ifdef USES_FDT_ALIASES
91 * The aliases needed for this generic etherne MAC address
92 * fixup function are not in place yet. So don't use this
93 * approach for now. This will be enabled later.
95 fdt_fixup_ethernet(blob, bd);
98 for (i = 0; i < 4; i++) {
100 * FIXME: This will cause problems with emac3 compatible
101 * devices, like on 405GP. But hopefully when we deal
102 * with those devices, the aliases stuff will be in
105 offset = fdt_node_offset_by_compatible(blob, offset, "ibm,emac4");
111 do_fixup_macaddr(blob, offset, bd->bi_enetaddr, 0);
113 #ifdef CONFIG_HAS_ETH1
115 do_fixup_macaddr(blob, offset, bd->bi_enet1addr, 1);
118 #ifdef CONFIG_HAS_ETH2
120 do_fixup_macaddr(blob, offset, bd->bi_enet2addr, 2);
123 #ifdef CONFIG_HAS_ETH3
125 do_fixup_macaddr(blob, offset, bd->bi_enet3addr, 3);
130 #endif /* USES_FDT_ALIASES */
132 #endif /* CONFIG_OF_LIBFDT */