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
27
28
29
30
31#include <common.h>
32#include <status_led.h>
33#include <netdev.h>
34#include <net.h>
35#include <i2c.h>
36#include <twl4030.h>
37
38#include <asm/io.h>
39#include <asm/arch/mem.h>
40#include <asm/arch/mux.h>
41#include <asm/arch/mmc_host_def.h>
42#include <asm/arch/sys_proto.h>
43#include <asm/mach-types.h>
44
45DECLARE_GLOBAL_DATA_PTR;
46
47const omap3_sysinfo sysinfo = {
48 DDR_DISCRETE,
49 "CM-T3x board",
50 "NAND",
51};
52
53static u32 gpmc_net_config[GPMC_MAX_REG] = {
54 NET_GPMC_CONFIG1,
55 NET_GPMC_CONFIG2,
56 NET_GPMC_CONFIG3,
57 NET_GPMC_CONFIG4,
58 NET_GPMC_CONFIG5,
59 NET_GPMC_CONFIG6,
60 0
61};
62
63static u32 gpmc_nand_config[GPMC_MAX_REG] = {
64 SMNAND_GPMC_CONFIG1,
65 SMNAND_GPMC_CONFIG2,
66 SMNAND_GPMC_CONFIG3,
67 SMNAND_GPMC_CONFIG4,
68 SMNAND_GPMC_CONFIG5,
69 SMNAND_GPMC_CONFIG6,
70 0,
71};
72
73
74
75
76
77int board_init(void)
78{
79 gpmc_init();
80
81 enable_gpmc_cs_config(gpmc_nand_config, &gpmc_cfg->cs[0],
82 CONFIG_SYS_NAND_BASE, GPMC_SIZE_16M);
83
84
85 if (get_cpu_family() == CPU_OMAP34XX)
86 gd->bd->bi_arch_number = MACH_TYPE_CM_T35;
87 else
88 gd->bd->bi_arch_number = MACH_TYPE_CM_T3730;
89
90
91 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
92
93#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
94 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
95#endif
96
97 return 0;
98}
99
100
101
102
103
104int misc_init_r(void)
105{
106 dieid_num_r();
107
108 return 0;
109}
110
111
112
113
114
115
116
117static void cm_t3x_set_common_muxconf(void)
118{
119
120 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0));
121 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0));
122 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0));
123 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0));
124 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0));
125 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0));
126 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0));
127 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0));
128 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0));
129 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0));
130 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0));
131 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0));
132 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0));
133 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0));
134 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0));
135 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0));
136 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0));
137 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0));
138 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0));
139 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0));
140 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0));
141 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0));
142 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0));
143 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0));
144 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0));
145 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0));
146 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0));
147 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0));
148 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0));
149 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0));
150 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0));
151 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0));
152 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0));
153 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0));
154 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0));
155 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0));
156 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0));
157 MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0));
158 MUX_VAL(CP(SDRC_CKE1), (IDIS | PTD | DIS | M7));
159
160
161 MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0));
162 MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0));
163 MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0));
164 MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0));
165 MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0));
166 MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0));
167 MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0));
168 MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0));
169 MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0));
170 MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0));
171 MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0));
172 MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0));
173 MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0));
174 MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0));
175 MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0));
176 MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0));
177 MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0));
178 MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0));
179 MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0));
180 MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0));
181 MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0));
182 MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0));
183 MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0));
184 MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0));
185 MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0));
186 MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0));
187 MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0));
188
189
190 MUX_VAL(CP(GPMC_NCS4), (IEN | PTU | EN | M0));
191
192
193 MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M0));
194 MUX_VAL(CP(GPMC_CLK), (IEN | PTD | DIS | M4));
195 MUX_VAL(CP(GPMC_NADV_ALE), (IDIS | PTD | DIS | M0));
196 MUX_VAL(CP(GPMC_NOE), (IDIS | PTD | DIS | M0));
197 MUX_VAL(CP(GPMC_NWE), (IDIS | PTD | DIS | M0));
198 MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0));
199 MUX_VAL(CP(GPMC_NBE1), (IDIS | PTD | DIS | M4));
200 MUX_VAL(CP(GPMC_NWP), (IEN | PTD | DIS | M0));
201 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0));
202
203
204 MUX_VAL(CP(DSS_PCLK), (IDIS | PTD | DIS | M0));
205 MUX_VAL(CP(DSS_HSYNC), (IDIS | PTD | DIS | M0));
206 MUX_VAL(CP(DSS_VSYNC), (IDIS | PTD | DIS | M0));
207 MUX_VAL(CP(DSS_ACBIAS), (IDIS | PTD | DIS | M0));
208 MUX_VAL(CP(DSS_DATA6), (IDIS | PTD | DIS | M0));
209 MUX_VAL(CP(DSS_DATA7), (IDIS | PTD | DIS | M0));
210 MUX_VAL(CP(DSS_DATA8), (IDIS | PTD | DIS | M0));
211 MUX_VAL(CP(DSS_DATA9), (IDIS | PTD | DIS | M0));
212 MUX_VAL(CP(DSS_DATA10), (IDIS | PTD | DIS | M0));
213 MUX_VAL(CP(DSS_DATA11), (IDIS | PTD | DIS | M0));
214 MUX_VAL(CP(DSS_DATA12), (IDIS | PTD | DIS | M0));
215 MUX_VAL(CP(DSS_DATA13), (IDIS | PTD | DIS | M0));
216 MUX_VAL(CP(DSS_DATA14), (IDIS | PTD | DIS | M0));
217 MUX_VAL(CP(DSS_DATA15), (IDIS | PTD | DIS | M0));
218 MUX_VAL(CP(DSS_DATA16), (IDIS | PTD | DIS | M0));
219 MUX_VAL(CP(DSS_DATA17), (IDIS | PTD | DIS | M0));
220
221
222 MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0));
223 MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0));
224
225
226 MUX_VAL(CP(HSUSB0_CLK), (IEN | PTD | DIS | M0));
227 MUX_VAL(CP(HSUSB0_STP), (IDIS | PTU | EN | M0));
228 MUX_VAL(CP(HSUSB0_DIR), (IEN | PTD | DIS | M0));
229 MUX_VAL(CP(HSUSB0_NXT), (IEN | PTD | DIS | M0));
230 MUX_VAL(CP(HSUSB0_DATA0), (IEN | PTD | DIS | M0));
231 MUX_VAL(CP(HSUSB0_DATA1), (IEN | PTD | DIS | M0));
232 MUX_VAL(CP(HSUSB0_DATA2), (IEN | PTD | DIS | M0));
233 MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0));
234 MUX_VAL(CP(HSUSB0_DATA4), (IEN | PTD | DIS | M0));
235 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0));
236 MUX_VAL(CP(HSUSB0_DATA6), (IEN | PTD | DIS | M0));
237 MUX_VAL(CP(HSUSB0_DATA7), (IEN | PTD | DIS | M0));
238
239
240 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0));
241 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0));
242
243
244 MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0));
245 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTD | DIS | M0));
246 MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0));
247 MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0));
248 MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0));
249 MUX_VAL(CP(SYS_CLKOUT2), (IDIS | PTU | DIS | M4));
250 MUX_VAL(CP(JTAG_nTRST), (IEN | PTD | DIS | M0));
251 MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0));
252 MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0));
253 MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0));
254
255
256 MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0));
257 MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0));
258 MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0));
259 MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0));
260 MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0));
261 MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0));
262}
263
264static void cm_t35_set_muxconf(void)
265{
266
267 MUX_VAL(CP(DSS_DATA0), (IDIS | PTD | DIS | M0));
268 MUX_VAL(CP(DSS_DATA1), (IDIS | PTD | DIS | M0));
269 MUX_VAL(CP(DSS_DATA2), (IDIS | PTD | DIS | M0));
270 MUX_VAL(CP(DSS_DATA3), (IDIS | PTD | DIS | M0));
271 MUX_VAL(CP(DSS_DATA4), (IDIS | PTD | DIS | M0));
272 MUX_VAL(CP(DSS_DATA5), (IDIS | PTD | DIS | M0));
273
274 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M0));
275 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M0));
276 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M0));
277 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M0));
278 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M0));
279 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M0));
280
281
282 MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0));
283 MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0));
284 MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0));
285 MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0));
286}
287
288static void cm_t3730_set_muxconf(void)
289{
290
291 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M3));
292 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M3));
293 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M3));
294 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M3));
295 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M3));
296 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M3));
297
298 MUX_VAL(CP(SYS_BOOT0), (IDIS | PTD | DIS | M3));
299 MUX_VAL(CP(SYS_BOOT1), (IDIS | PTD | DIS | M3));
300 MUX_VAL(CP(SYS_BOOT3), (IDIS | PTD | DIS | M3));
301 MUX_VAL(CP(SYS_BOOT4), (IDIS | PTD | DIS | M3));
302 MUX_VAL(CP(SYS_BOOT5), (IDIS | PTD | DIS | M3));
303 MUX_VAL(CP(SYS_BOOT6), (IDIS | PTD | DIS | M3));
304}
305
306void set_muxconf_regs(void)
307{
308 cm_t3x_set_common_muxconf();
309
310 if (get_cpu_family() == CPU_OMAP34XX)
311 cm_t35_set_muxconf();
312 else
313 cm_t3730_set_muxconf();
314}
315
316#ifdef CONFIG_GENERIC_MMC
317int board_mmc_init(bd_t *bis)
318{
319 omap_mmc_init(0);
320 return 0;
321}
322#endif
323
324
325
326
327
328
329static void setup_net_chip_gmpc(void)
330{
331 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
332
333 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[5],
334 CM_T3X_SMC911X_BASE, GPMC_SIZE_16M);
335 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[4],
336 SB_T35_SMC911X_BASE, GPMC_SIZE_16M);
337
338
339 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
340
341
342 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
343
344
345 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
346 &ctrl_base->gpmc_nadv_ale);
347}
348
349#ifdef CONFIG_DRIVER_OMAP34XX_I2C
350
351
352
353
354static void reset_net_chip(void)
355{
356
357 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
358 TWL4030_BASEADD_GPIO+0x03);
359
360 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
361 TWL4030_BASEADD_GPIO+0x0C);
362 udelay(1);
363 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
364 TWL4030_BASEADD_GPIO+0x09);
365 udelay(1);
366 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
367 TWL4030_BASEADD_GPIO+0x0C);
368}
369#else
370static inline void reset_net_chip(void) {}
371#endif
372
373
374
375
376
377static int handle_mac_address(void)
378{
379 unsigned char enetaddr[6];
380 int rc;
381
382 rc = eth_getenv_enetaddr("ethaddr", enetaddr);
383 if (rc)
384 return 0;
385
386#ifdef CONFIG_DRIVER_OMAP34XX_I2C
387 rc = i2c_read(0x50, 0, 1, enetaddr, 6);
388 if (rc)
389 return rc;
390#endif
391
392 if (!is_valid_ether_addr(enetaddr))
393 return -1;
394
395 return eth_setenv_enetaddr("ethaddr", enetaddr);
396}
397
398
399
400
401
402
403int board_eth_init(bd_t *bis)
404{
405 int rc = 0, rc1 = 0;
406
407#ifdef CONFIG_SMC911X
408 setup_net_chip_gmpc();
409 reset_net_chip();
410
411 rc1 = handle_mac_address();
412 if (rc1)
413 printf("CM-T3x: No MAC address found\n");
414
415 rc1 = smc911x_initialize(0, CM_T3X_SMC911X_BASE);
416 if (rc1 > 0)
417 rc++;
418
419 rc1 = smc911x_initialize(1, SB_T35_SMC911X_BASE);
420 if (rc1 > 0)
421 rc++;
422#endif
423
424 return rc;
425}
426