diff options
author | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2007-08-20 08:30:32 -0400 |
---|---|---|
committer | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2007-08-20 08:30:32 -0400 |
commit | 2ba4573cdaf98b0f3acb8795a66f412c1c41284a (patch) | |
tree | 34e161751ed0192c5b1af1f2001d4b035b985f34 | |
parent | 8c1449bdb4c7e9c4492ba18ded70fd8669eeffae (diff) |
[POWERPC] Bamboo zImage wrapper
Add a bootwrapper for the AMCC 440EP Bamboo Eval board. This also adds a
common fixup_clock function for all 440EP(x) chips.
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r-- | arch/powerpc/boot/44x.h | 1 | ||||
-rw-r--r-- | arch/powerpc/boot/4xx.c | 82 | ||||
-rw-r--r-- | arch/powerpc/boot/4xx.h | 1 | ||||
-rw-r--r-- | arch/powerpc/boot/Makefile | 5 | ||||
-rw-r--r-- | arch/powerpc/boot/bamboo.c | 45 | ||||
-rw-r--r-- | arch/powerpc/boot/dcr.h | 10 | ||||
-rw-r--r-- | arch/powerpc/boot/treeboot-bamboo.c | 27 |
7 files changed, 169 insertions, 2 deletions
diff --git a/arch/powerpc/boot/44x.h b/arch/powerpc/boot/44x.h index 490a1cbdf1ed..ad33dcc95ae5 100644 --- a/arch/powerpc/boot/44x.h +++ b/arch/powerpc/boot/44x.h | |||
@@ -11,5 +11,6 @@ | |||
11 | #define _PPC_BOOT_44X_H_ | 11 | #define _PPC_BOOT_44X_H_ |
12 | 12 | ||
13 | void ebony_init(void *mac0, void *mac1); | 13 | void ebony_init(void *mac0, void *mac1); |
14 | void bamboo_init(void); | ||
14 | 15 | ||
15 | #endif /* _PPC_BOOT_44X_H_ */ | 16 | #endif /* _PPC_BOOT_44X_H_ */ |
diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c index 59026e4585dc..642d8780bb31 100644 --- a/arch/powerpc/boot/4xx.c +++ b/arch/powerpc/boot/4xx.c | |||
@@ -108,3 +108,85 @@ void ibm4xx_fixup_ebc_ranges(const char *ebc) | |||
108 | 108 | ||
109 | setprop(devp, "ranges", ranges, (p - ranges) * sizeof(u32)); | 109 | setprop(devp, "ranges", ranges, (p - ranges) * sizeof(u32)); |
110 | } | 110 | } |
111 | |||
112 | #define SPRN_CCR1 0x378 | ||
113 | void ibm440ep_fixup_clocks(unsigned int sysclk, unsigned int ser_clk) | ||
114 | { | ||
115 | u32 cpu, plb, opb, ebc, tb, uart0, m, vco; | ||
116 | u32 reg; | ||
117 | u32 fwdva, fwdvb, fbdv, lfbdv, opbdv0, perdv0, spcid0, prbdv0, tmp; | ||
118 | |||
119 | mtdcr(DCRN_CPR0_ADDR, CPR0_PLLD0); | ||
120 | reg = mfdcr(DCRN_CPR0_DATA); | ||
121 | tmp = (reg & 0x000F0000) >> 16; | ||
122 | fwdva = tmp ? tmp : 16; | ||
123 | tmp = (reg & 0x00000700) >> 8; | ||
124 | fwdvb = tmp ? tmp : 8; | ||
125 | tmp = (reg & 0x1F000000) >> 24; | ||
126 | fbdv = tmp ? tmp : 32; | ||
127 | lfbdv = (reg & 0x0000007F); | ||
128 | |||
129 | mtdcr(DCRN_CPR0_ADDR, CPR0_OPBD0); | ||
130 | reg = mfdcr(DCRN_CPR0_DATA); | ||
131 | tmp = (reg & 0x03000000) >> 24; | ||
132 | opbdv0 = tmp ? tmp : 4; | ||
133 | |||
134 | mtdcr(DCRN_CPR0_ADDR, CPR0_PERD0); | ||
135 | reg = mfdcr(DCRN_CPR0_DATA); | ||
136 | tmp = (reg & 0x07000000) >> 24; | ||
137 | perdv0 = tmp ? tmp : 8; | ||
138 | |||
139 | mtdcr(DCRN_CPR0_ADDR, CPR0_PRIMBD0); | ||
140 | reg = mfdcr(DCRN_CPR0_DATA); | ||
141 | tmp = (reg & 0x07000000) >> 24; | ||
142 | prbdv0 = tmp ? tmp : 8; | ||
143 | |||
144 | mtdcr(DCRN_CPR0_ADDR, CPR0_SCPID); | ||
145 | reg = mfdcr(DCRN_CPR0_DATA); | ||
146 | tmp = (reg & 0x03000000) >> 24; | ||
147 | spcid0 = tmp ? tmp : 4; | ||
148 | |||
149 | /* Calculate M */ | ||
150 | mtdcr(DCRN_CPR0_ADDR, CPR0_PLLC0); | ||
151 | reg = mfdcr(DCRN_CPR0_DATA); | ||
152 | tmp = (reg & 0x03000000) >> 24; | ||
153 | if (tmp == 0) { /* PLL output */ | ||
154 | tmp = (reg & 0x20000000) >> 29; | ||
155 | if (!tmp) /* PLLOUTA */ | ||
156 | m = fbdv * lfbdv * fwdva; | ||
157 | else | ||
158 | m = fbdv * lfbdv * fwdvb; | ||
159 | } | ||
160 | else if (tmp == 1) /* CPU output */ | ||
161 | m = fbdv * fwdva; | ||
162 | else | ||
163 | m = perdv0 * opbdv0 * fwdvb; | ||
164 | |||
165 | vco = (m * sysclk) + (m >> 1); | ||
166 | cpu = vco / fwdva; | ||
167 | plb = vco / fwdvb / prbdv0; | ||
168 | opb = plb / opbdv0; | ||
169 | ebc = plb / perdv0; | ||
170 | |||
171 | /* FIXME */ | ||
172 | uart0 = ser_clk; | ||
173 | |||
174 | /* Figure out timebase. Either CPU or default TmrClk */ | ||
175 | asm volatile ( | ||
176 | "mfspr %0,%1\n" | ||
177 | : | ||
178 | "=&r"(reg) : "i"(SPRN_CCR1)); | ||
179 | if (reg & 0x0080) | ||
180 | tb = 25000000; /* TmrClk is 25MHz */ | ||
181 | else | ||
182 | tb = cpu; | ||
183 | |||
184 | dt_fixup_cpu_clocks(cpu, tb, 0); | ||
185 | dt_fixup_clock("/plb", plb); | ||
186 | dt_fixup_clock("/plb/opb", opb); | ||
187 | dt_fixup_clock("/plb/opb/ebc", ebc); | ||
188 | dt_fixup_clock("/plb/opb/serial@ef600300", uart0); | ||
189 | dt_fixup_clock("/plb/opb/serial@ef600400", uart0); | ||
190 | dt_fixup_clock("/plb/opb/serial@ef600500", uart0); | ||
191 | dt_fixup_clock("/plb/opb/serial@ef600600", uart0); | ||
192 | } | ||
diff --git a/arch/powerpc/boot/4xx.h b/arch/powerpc/boot/4xx.h index 65008427e03f..8f26e480dcd3 100644 --- a/arch/powerpc/boot/4xx.h +++ b/arch/powerpc/boot/4xx.h | |||
@@ -16,5 +16,6 @@ void ibm44x_dbcr_reset(void); | |||
16 | void ibm40x_dbcr_reset(void); | 16 | void ibm40x_dbcr_reset(void); |
17 | void ibm4xx_quiesce_eth(u32 *emac0, u32 *emac1); | 17 | void ibm4xx_quiesce_eth(u32 *emac0, u32 *emac1); |
18 | void ibm4xx_fixup_ebc_ranges(const char *ebc); | 18 | void ibm4xx_fixup_ebc_ranges(const char *ebc); |
19 | void ibm440ep_fixup_clocks(unsigned int sysclk, unsigned int ser_clk); | ||
19 | 20 | ||
20 | #endif /* _POWERPC_BOOT_4XX_H_ */ | 21 | #endif /* _POWERPC_BOOT_4XX_H_ */ |
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index b4869e61b738..54a72108bcc3 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile | |||
@@ -44,10 +44,10 @@ $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ | |||
44 | src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ | 44 | src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ |
45 | ns16550.c serial.c simple_alloc.c div64.S util.S \ | 45 | ns16550.c serial.c simple_alloc.c div64.S util.S \ |
46 | gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ | 46 | gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ |
47 | 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c | 47 | 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c |
48 | src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \ | 48 | src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \ |
49 | cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ | 49 | cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ |
50 | ps3-head.S ps3-hvcall.S ps3.c | 50 | ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c |
51 | src-boot := $(src-wlib) $(src-plat) empty.c | 51 | src-boot := $(src-wlib) $(src-plat) empty.c |
52 | 52 | ||
53 | src-boot := $(addprefix $(obj)/, $(src-boot)) | 53 | src-boot := $(addprefix $(obj)/, $(src-boot)) |
@@ -142,6 +142,7 @@ ifneq ($(CONFIG_DEVICE_TREE),"") | |||
142 | image-$(CONFIG_PPC_83xx) += cuImage.83xx | 142 | image-$(CONFIG_PPC_83xx) += cuImage.83xx |
143 | image-$(CONFIG_PPC_85xx) += cuImage.85xx | 143 | image-$(CONFIG_PPC_85xx) += cuImage.85xx |
144 | image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony | 144 | image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony |
145 | image-$(CONFIG_BAMBOO) += treeImage.bamboo | ||
145 | endif | 146 | endif |
146 | 147 | ||
147 | # For 32-bit powermacs, build the COFF and miboot images | 148 | # For 32-bit powermacs, build the COFF and miboot images |
diff --git a/arch/powerpc/boot/bamboo.c b/arch/powerpc/boot/bamboo.c new file mode 100644 index 000000000000..bc097694b445 --- /dev/null +++ b/arch/powerpc/boot/bamboo.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Copyright IBM Corporation, 2007 | ||
3 | * Josh Boyer <jwboyer@linux.vnet.ibm.com> | ||
4 | * | ||
5 | * Based on ebony wrapper: | ||
6 | * Copyright 2007 David Gibson, IBM Corporation. | ||
7 | * | ||
8 | * Clocking code based on code by: | ||
9 | * Stefan Roese <sr@denx.de> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License | ||
13 | * as published by the Free Software Foundation; version 2 of the License | ||
14 | */ | ||
15 | #include <stdarg.h> | ||
16 | #include <stddef.h> | ||
17 | #include "types.h" | ||
18 | #include "elf.h" | ||
19 | #include "string.h" | ||
20 | #include "stdio.h" | ||
21 | #include "page.h" | ||
22 | #include "ops.h" | ||
23 | #include "dcr.h" | ||
24 | #include "4xx.h" | ||
25 | #include "44x.h" | ||
26 | |||
27 | extern char _dtb_start[]; | ||
28 | extern char _dtb_end[]; | ||
29 | |||
30 | static void bamboo_fixups(void) | ||
31 | { | ||
32 | unsigned long sysclk = 33333333; | ||
33 | |||
34 | ibm440ep_fixup_clocks(sysclk, 11059200); | ||
35 | ibm4xx_fixup_memsize(); | ||
36 | ibm4xx_quiesce_eth((u32 *)0xef600e00, (u32 *)0xef600f00); | ||
37 | } | ||
38 | |||
39 | void bamboo_init(void) | ||
40 | { | ||
41 | platform_ops.fixups = bamboo_fixups; | ||
42 | platform_ops.exit = ibm44x_dbcr_reset; | ||
43 | ft_init(_dtb_start, 0, 32); | ||
44 | serial_console_init(); | ||
45 | } | ||
diff --git a/arch/powerpc/boot/dcr.h b/arch/powerpc/boot/dcr.h index c95d1a9222c9..e158311c501b 100644 --- a/arch/powerpc/boot/dcr.h +++ b/arch/powerpc/boot/dcr.h | |||
@@ -124,4 +124,14 @@ static const unsigned long sdram_bxcr[] = { SDRAM0_B0CR, SDRAM0_B1CR, SDRAM0_B2C | |||
124 | #define DCRN_MAL0_CFG 0x180 | 124 | #define DCRN_MAL0_CFG 0x180 |
125 | #define MAL_RESET 0x80000000 | 125 | #define MAL_RESET 0x80000000 |
126 | 126 | ||
127 | /* 440EP Clock/Power-on Reset regs */ | ||
128 | #define DCRN_CPR0_ADDR 0xc | ||
129 | #define DCRN_CPR0_DATA 0xd | ||
130 | #define CPR0_PLLD0 0x60 | ||
131 | #define CPR0_OPBD0 0xc0 | ||
132 | #define CPR0_PERD0 0xe0 | ||
133 | #define CPR0_PRIMBD0 0xa0 | ||
134 | #define CPR0_SCPID 0x120 | ||
135 | #define CPR0_PLLC0 0x40 | ||
136 | |||
127 | #endif /* _PPC_BOOT_DCR_H_ */ | 137 | #endif /* _PPC_BOOT_DCR_H_ */ |
diff --git a/arch/powerpc/boot/treeboot-bamboo.c b/arch/powerpc/boot/treeboot-bamboo.c new file mode 100644 index 000000000000..1f1fe5aaac12 --- /dev/null +++ b/arch/powerpc/boot/treeboot-bamboo.c | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright IBM Corporation, 2007 | ||
3 | * Josh Boyer <jwboyer@linux.vnet.ibm.com> | ||
4 | * | ||
5 | * Based on ebony wrapper: | ||
6 | * Copyright 2007 David Gibson, IBM Corporation. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; version 2 of the License | ||
11 | */ | ||
12 | #include "ops.h" | ||
13 | #include "stdio.h" | ||
14 | #include "44x.h" | ||
15 | |||
16 | extern char _end[]; | ||
17 | |||
18 | BSS_STACK(4096); | ||
19 | |||
20 | void platform_init(void) | ||
21 | { | ||
22 | unsigned long end_of_ram = 0x8000000; | ||
23 | unsigned long avail_ram = end_of_ram - (unsigned long)_end; | ||
24 | |||
25 | simple_alloc_init(_end, avail_ram, 32, 64); | ||
26 | bamboo_init(); | ||
27 | } | ||