1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <common.h>
27#include <asm/bitops.h>
28#include <command.h>
29#include <asm/io.h>
30#include <asm/processor.h>
31#include <asm/mpc512x.h>
32#include <fdt_support.h>
33
34DECLARE_GLOBAL_DATA_PTR;
35
36
37#define SCCR1_CLOCKS_EN (CLOCK_SCCR1_CFG_EN | \
38 CLOCK_SCCR1_LPC_EN | \
39 CLOCK_SCCR1_PSC_EN(CONFIG_PSC_CONSOLE) | \
40 CLOCK_SCCR1_PSCFIFO_EN | \
41 CLOCK_SCCR1_DDR_EN | \
42 CLOCK_SCCR1_FEC_EN | \
43 CLOCK_SCCR1_NFC_EN | \
44 CLOCK_SCCR1_PCI_EN | \
45 CLOCK_SCCR1_TPR_EN)
46
47#define SCCR2_CLOCKS_EN (CLOCK_SCCR2_MEM_EN | \
48 CLOCK_SCCR2_I2C_EN)
49
50int eeprom_write_enable(unsigned dev_addr, int state)
51{
52 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
53
54 if (dev_addr != CONFIG_SYS_I2C_EEPROM_ADDR)
55 return -1;
56
57 if (state == 0)
58 setbits_be32(&im->gpio.gpdat, 0x00100000);
59 else
60 clrbits_be32(&im->gpio.gpdat, 0x00100000);
61
62 return 0;
63}
64
65int board_early_init_f(void)
66{
67 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
68 u32 spridr;
69 int i;
70
71
72
73
74 out_be32(&im->sysconf.lpcs0aw,
75 CSAW_START(CONFIG_SYS_FLASH_BASE) |
76 CSAW_STOP(CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_SIZE));
77 sync_law(&im->sysconf.lpcs0aw);
78
79
80
81
82 out_be32(&im->sysconf.lpbaw,
83 CSAW_START(0xffb00000) | CSAW_STOP(0xffb00000, 0x00010000));
84 sync_law(&im->sysconf.lpbaw);
85
86
87
88
89 out_be32(&im->sysconf.lpcs1aw,
90 CSAW_START(CONFIG_SYS_VPC3_BASE) |
91 CSAW_STOP(CONFIG_SYS_VPC3_BASE, CONFIG_SYS_VPC3_SIZE));
92 sync_law(&im->sysconf.lpcs1aw);
93
94
95
96
97 out_be32(&im->lpc.cs_cfg[0], CONFIG_SYS_CS0_CFG);
98
99
100
101
102 out_be32(&im->lpc.cs_cfg[1], CONFIG_SYS_CS1_CFG);
103
104 spridr = in_be32(&im->sysconf.spridr);
105 if (SVR_MJREV(spridr) >= 2)
106 out_be32(&im->lpc.altr, CONFIG_SYS_CS_ALETIMING);
107
108
109
110
111 out_be32(&im->clk.sccr[0], SCCR1_CLOCKS_EN);
112 out_be32(&im->clk.sccr[1], SCCR2_CLOCKS_EN);
113#if defined(CONFIG_IIM) || defined(CONFIG_CMD_FUSE)
114 setbits_be32(&im->clk.sccr[1], CLOCK_SCCR2_IIM_EN);
115#endif
116
117
118
119
120 for (i=0; i<4; ++i) {
121 out_be32(&im->clk.msccr[i], 0x00300000);
122 out_be32(&im->clk.msccr[i], 0x00310000);
123 }
124
125
126
127
128 clrbits_be32(&im->gpio.gpodr, 0x000000e0);
129 clrbits_be32(&im->gpio.gpdir, 0x00ef0000);
130 setbits_be32(&im->gpio.gpdir, 0x001000e0);
131 setbits_be32(&im->gpio.gpdat, 0x00100000);
132
133 return 0;
134}
135
136phys_size_t initdram(int board_type)
137{
138 return get_ram_size(0, fixed_sdram(NULL, NULL, 0));
139}
140
141int misc_init_r(void)
142{
143 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
144 u32 val;
145
146
147
148
149
150
151
152
153 val = in_be32(&im->clk.scfr[0]) & ~SCFR1_LPC_DIV_MASK;
154 out_be32(&im->clk.scfr[0], val | (0x1 << SCFR1_LPC_DIV_SHIFT));
155
156
157
158
159
160
161 clrbits_be32(&im->lpc.cs_dccr, 0x000000ff);
162 setbits_be32(&im->lpc.cs_dccr, (0x00 << 4) | (0x01 << 0));
163
164
165
166
167
168
169 clrbits_be32(&im->lpc.cs_hccr, 0x000000ff);
170 setbits_be32(&im->lpc.cs_hccr, (0x00 << 4) | (0x01 << 0));
171
172 return 0;
173}
174
175static iopin_t ioregs_init[] = {
176
177 {
178 offsetof(struct ioctrl512x, io_control_spdif_txclk), 3, 0,
179 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
180 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
181 },
182
183 {
184 offsetof(struct ioctrl512x, io_control_psc0_0), 15, 0,
185 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
186 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
187 },
188
189 {
190 offsetof(struct ioctrl512x, io_control_lpc_cs1), 1, 0,
191 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
192 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
193 },
194
195 {
196 offsetof(struct ioctrl512x, io_control_psc5_2), 1, 0,
197 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
198 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
199 },
200
201 {
202 offsetof(struct ioctrl512x, io_control_psc5_3), 1, 0,
203 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
204 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
205 },
206
207 {
208 offsetof(struct ioctrl512x, io_control_psc7_3), 1, 0,
209 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
210 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
211 },
212
213 {
214 offsetof(struct ioctrl512x, io_control_psc9_0), 3, 0,
215 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
216 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
217 },
218
219 {
220 offsetof(struct ioctrl512x, io_control_psc10_0), 3, 0,
221 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
222 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
223 },
224
225 {
226 offsetof(struct ioctrl512x, io_control_psc10_3), 1, 0,
227 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
228 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
229 },
230
231 {
232 offsetof(struct ioctrl512x, io_control_psc11_0), 4, 0,
233 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
234 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
235 },
236
237 {
238 offsetof(struct ioctrl512x, io_control_irq0), 4, 0,
239 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
240 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
241 }
242};
243
244static iopin_t rev2_silicon_pci_ioregs_init[] = {
245
246 {
247 offsetof(struct ioctrl512x, io_control_pci_ad31), 54, 0,
248 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_DS(0)
249 }
250};
251
252int checkboard(void)
253{
254 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
255 u32 spridr;
256
257 puts("Board: MECP_5123\n");
258
259
260
261
262
263 iopin_initialize(ioregs_init, ARRAY_SIZE(ioregs_init));
264
265 spridr = in_be32(&im->sysconf.spridr);
266 if (SVR_MJREV(spridr) >= 2)
267 iopin_initialize(rev2_silicon_pci_ioregs_init, 1);
268
269 return 0;
270}
271
272#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
273void ft_board_setup(void *blob, bd_t *bd)
274{
275 ft_cpu_setup(blob, bd);
276}
277#endif
278