2 * Old U-boot compatibility for Walnut
4 * Author: Josh Boyer <jwboyer@linux.vnet.ibm.com>
6 * Copyright 2007 IBM Corporation
7 * Based on cuboot-83xx.c, which is:
8 * Copyright (c) 2007 Freescale Semiconductor, Inc.
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
23 void ibm405gp_fixup_clocks(unsigned int sysclk, unsigned int ser_clk)
25 u32 pllmr = mfdcr(DCRN_CPC0_PLLMR);
26 u32 cpc0_cr0 = mfdcr(DCRN_405_CPC0_CR0);
27 u32 cpc0_cr1 = mfdcr(DCRN_405_CPC0_CR1);
28 u32 cpu, plb, opb, ebc, tb, uart0, uart1, m;
29 u32 fwdv, fbdv, cbdv, opdv, epdv, udiv;
31 fwdv = (8 - ((pllmr & 0xe0000000) >> 29));
32 fbdv = (pllmr & 0x1e000000) >> 25;
33 cbdv = ((pllmr & 0x00060000) >> 17) + 1;
34 opdv = ((pllmr & 0x00018000) >> 15) + 1;
35 epdv = ((pllmr & 0x00001800) >> 13) + 2;
36 udiv = ((cpc0_cr0 & 0x3e) >> 1) + 1;
38 m = fwdv * fbdv * cbdv;
40 cpu = sysclk * m / fwdv;
45 if (cpc0_cr0 & 0x80) {
46 /* uart0 uses the external clock */
52 if (cpc0_cr0 & 0x40) {
53 /* uart1 uses the external clock */
59 /* setup the timebase clock to tick at the cpu frequency */
60 cpc0_cr1 = cpc0_cr1 & ~ 0x00800000;
61 mtdcr(DCRN_CPC0_CR1, cpc0_cr1);
64 dt_fixup_cpu_clocks(cpu, tb, 0);
65 dt_fixup_clock("/plb", plb);
66 dt_fixup_clock("/plb/opb", opb);
67 dt_fixup_clock("/plb/ebc", ebc);
68 dt_fixup_clock("/plb/opb/serial@ef600300", uart0);
69 dt_fixup_clock("/plb/opb/serial@ef600400", uart1);
72 static void walnut_flashsel_fixup(void)
75 u32 reg_flash[3] = {0x0, 0x0, 0x80000};
76 u32 reg_sram[3] = {0x0, 0x0, 0x80000};
80 devp = finddevice("/plb/ebc/fpga");
82 fatal("Couldn't locate FPGA node\n\r");
84 if (getprop(devp, "virtual-reg", &fpga, sizeof(fpga)) != sizeof(fpga))
85 fatal("no virtual-reg property\n\r");
87 fpga_brds1 = in_8(fpga);
89 devp = finddevice("/plb/ebc/flash");
91 fatal("Couldn't locate flash node\n\r");
93 if (getprop(devp, "reg", reg_flash, sizeof(reg_flash)) != sizeof(reg_flash))
94 fatal("flash reg property has unexpected size\n\r");
96 sram = finddevice("/plb/ebc/sram");
98 fatal("Couldn't locate sram node\n\r");
100 if (getprop(sram, "reg", reg_sram, sizeof(reg_sram)) != sizeof(reg_sram))
101 fatal("sram reg property has unexpected size\n\r");
103 if (fpga_brds1 & 0x1) {
104 reg_flash[1] ^= 0x80000;
105 reg_sram[1] ^= 0x80000;
108 setprop(devp, "reg", reg_flash, sizeof(reg_flash));
109 setprop(sram, "reg", reg_sram, sizeof(reg_sram));
112 static void walnut_fixups(void)
114 ibm4xx_fixup_memsize();
115 ibm405gp_fixup_clocks(33330000, 0xa8c000);
116 ibm4xx_quiesce_eth((u32 *)0xef600800, NULL);
117 ibm4xx_fixup_ebc_ranges("/plb/ebc");
118 walnut_flashsel_fixup();
121 void platform_init(void)
123 unsigned long end_of_ram = 0x2000000;
124 unsigned long avail_ram = end_of_ram - (unsigned long) _end;
126 simple_alloc_init(_end, avail_ram, 32, 32);
127 platform_ops.fixups = walnut_fixups;
128 platform_ops.exit = ibm40x_dbcr_reset;
129 ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
130 serial_console_init();