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.
30 extern char _dtb_start[];
31 extern char _dtb_end[];
33 static u8 *ebony_mac0, *ebony_mac1;
35 /* Calculate 440GP clocks */
36 void ibm440gp_fixup_clocks(unsigned int sysclk, unsigned int ser_clk)
38 u32 sys0 = mfdcr(DCRN_CPC0_SYS0);
39 u32 cr0 = mfdcr(DCRN_CPC0_CR0);
40 u32 cpu, plb, opb, ebc, tb, uart0, uart1, m;
41 u32 opdv = CPC0_SYS0_OPDV(sys0);
42 u32 epdv = CPC0_SYS0_EPDV(sys0);
44 if (sys0 & CPC0_SYS0_BYPASS) {
45 /* Bypass system PLL */
48 if (sys0 & CPC0_SYS0_EXTSL)
50 m = CPC0_SYS0_FWDVB(sys0) * opdv * epdv;
53 m = CPC0_SYS0_FBDV(sys0) * CPC0_SYS0_FWDVA(sys0);
54 cpu = sysclk * m / CPC0_SYS0_FWDVA(sys0);
55 plb = sysclk * m / CPC0_SYS0_FWDVB(sys0);
61 /* FIXME: Check if this is for all 440GP, or just Ebony */
62 if ((mfpvr() & 0xf0000fff) == 0x40000440)
63 /* Rev. B 440GP, use external system clock */
66 /* Rev. C 440GP, errata force us to use internal clock */
69 if (cr0 & CPC0_CR0_U0EC)
70 /* External UART clock */
73 /* Internal UART clock */
74 uart0 = plb / CPC0_CR0_UDIV(cr0);
76 if (cr0 & CPC0_CR0_U1EC)
77 /* External UART clock */
80 /* Internal UART clock */
81 uart1 = plb / CPC0_CR0_UDIV(cr0);
83 printf("PPC440GP: SysClk = %dMHz (%x)\n\r",
84 (sysclk + 500000) / 1000000, sysclk);
86 dt_fixup_cpu_clocks(cpu, tb, 0);
88 dt_fixup_clock("/plb", plb);
89 dt_fixup_clock("/plb/opb", opb);
90 dt_fixup_clock("/plb/opb/ebc", ebc);
91 dt_fixup_clock("/plb/opb/serial@40000200", uart0);
92 dt_fixup_clock("/plb/opb/serial@40000300", uart1);
95 static void ebony_fixups(void)
97 // FIXME: sysclk should be derived by reading the FPGA registers
98 unsigned long sysclk = 33000000;
100 ibm440gp_fixup_clocks(sysclk, 6 * 1843200);
101 ibm44x_fixup_memsize();
102 dt_fixup_mac_addresses(ebony_mac0, ebony_mac1);
103 ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
106 void ebony_init(void *mac0, void *mac1)
108 platform_ops.fixups = ebony_fixups;
109 platform_ops.exit = ibm44x_dbcr_reset;
112 ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
113 serial_console_init();