2 * Copyright 2007 David Gibson, IBM Corporation.
4 * Based on earlier code:
5 * Copyright (C) Paul Mackerras 1997.
7 * Matt Porter <mporter@kernel.crashing.org>
8 * Copyright 2002-2005 MontaVista Software Inc.
10 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
11 * Copyright (c) 2003, 2004 Zultys Technologies
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
32 static u8 *ebony_mac0, *ebony_mac1;
34 /* Calculate 440GP clocks */
35 void ibm440gp_fixup_clocks(unsigned int sysclk, unsigned int ser_clk)
37 u32 sys0 = mfdcr(DCRN_CPC0_SYS0);
38 u32 cr0 = mfdcr(DCRN_CPC0_CR0);
39 u32 cpu, plb, opb, ebc, tb, uart0, uart1, m;
40 u32 opdv = CPC0_SYS0_OPDV(sys0);
41 u32 epdv = CPC0_SYS0_EPDV(sys0);
43 if (sys0 & CPC0_SYS0_BYPASS) {
44 /* Bypass system PLL */
47 if (sys0 & CPC0_SYS0_EXTSL)
49 m = CPC0_SYS0_FWDVB(sys0) * opdv * epdv;
52 m = CPC0_SYS0_FBDV(sys0) * CPC0_SYS0_FWDVA(sys0);
53 cpu = sysclk * m / CPC0_SYS0_FWDVA(sys0);
54 plb = sysclk * m / CPC0_SYS0_FWDVB(sys0);
60 /* FIXME: Check if this is for all 440GP, or just Ebony */
61 if ((mfpvr() & 0xf0000fff) == 0x40000440)
62 /* Rev. B 440GP, use external system clock */
65 /* Rev. C 440GP, errata force us to use internal clock */
68 if (cr0 & CPC0_CR0_U0EC)
69 /* External UART clock */
72 /* Internal UART clock */
73 uart0 = plb / CPC0_CR0_UDIV(cr0);
75 if (cr0 & CPC0_CR0_U1EC)
76 /* External UART clock */
79 /* Internal UART clock */
80 uart1 = plb / CPC0_CR0_UDIV(cr0);
82 printf("PPC440GP: SysClk = %dMHz (%x)\n\r",
83 (sysclk + 500000) / 1000000, sysclk);
85 dt_fixup_cpu_clocks(cpu, tb, 0);
87 dt_fixup_clock("/plb", plb);
88 dt_fixup_clock("/plb/opb", opb);
89 dt_fixup_clock("/plb/opb/ebc", ebc);
90 dt_fixup_clock("/plb/opb/serial@40000200", uart0);
91 dt_fixup_clock("/plb/opb/serial@40000300", uart1);
94 #define EBONY_FPGA_PATH "/plb/opb/ebc/fpga"
95 #define EBONY_FPGA_FLASH_SEL 0x01
96 #define EBONY_SMALL_FLASH_PATH "/plb/opb/ebc/small-flash"
98 static void ebony_flashsel_fixup(void)
101 u32 reg[3] = {0x0, 0x0, 0x80000};
105 devp = finddevice(EBONY_FPGA_PATH);
107 fatal("Couldn't locate FPGA node %s\n\r", EBONY_FPGA_PATH);
109 if (getprop(devp, "virtual-reg", &fpga, sizeof(fpga)) != sizeof(fpga))
110 fatal("%s has missing or invalid virtual-reg property\n\r",
113 fpga_reg0 = in_8(fpga);
115 devp = finddevice(EBONY_SMALL_FLASH_PATH);
117 fatal("Couldn't locate small flash node %s\n\r",
118 EBONY_SMALL_FLASH_PATH);
120 if (getprop(devp, "reg", reg, sizeof(reg)) != sizeof(reg))
121 fatal("%s has reg property of unexpected size\n\r",
122 EBONY_SMALL_FLASH_PATH);
124 /* Invert address bit 14 (IBM-endian) if FLASH_SEL fpga bit is set */
125 if (fpga_reg0 & EBONY_FPGA_FLASH_SEL)
128 setprop(devp, "reg", reg, sizeof(reg));
131 static void ebony_fixups(void)
133 // FIXME: sysclk should be derived by reading the FPGA registers
134 unsigned long sysclk = 33000000;
136 ibm440gp_fixup_clocks(sysclk, 6 * 1843200);
137 ibm4xx_fixup_memsize();
138 dt_fixup_mac_addresses(ebony_mac0, ebony_mac1);
139 ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
140 ebony_flashsel_fixup();
143 void ebony_init(void *mac0, void *mac1)
145 platform_ops.fixups = ebony_fixups;
146 platform_ops.exit = ibm44x_dbcr_reset;
149 ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
150 serial_console_init();