]>
Commit | Line | Data |
---|---|---|
4138b740 KM |
1 | /* |
2 | * Copyright (C) 2009 Renesas Solutions Corp. | |
3 | * | |
4 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> | |
5 | * | |
6 | * This file is subject to the terms and conditions of the GNU General Public | |
7 | * License. See the file "COPYING" in the main directory of this archive | |
8 | * for more details. | |
9 | */ | |
10 | ||
11 | #include <linux/init.h> | |
12 | #include <linux/device.h> | |
13 | #include <linux/platform_device.h> | |
14 | #include <linux/mtd/physmap.h> | |
15 | #include <linux/gpio.h> | |
16 | #include <linux/interrupt.h> | |
35a35408 KM |
17 | #include <linux/io.h> |
18 | #include <linux/delay.h> | |
907050a3 | 19 | #include <linux/usb/r8a66597.h> |
4907d57f | 20 | #include <linux/i2c.h> |
8810e055 | 21 | #include <linux/i2c/tsc2007.h> |
e9103e74 | 22 | #include <linux/input.h> |
fa3ba51b | 23 | #include <video/sh_mobile_lcdc.h> |
2153ad32 | 24 | #include <media/sh_mobile_ceu.h> |
4138b740 | 25 | #include <asm/heartbeat.h> |
35a35408 | 26 | #include <asm/sh_eth.h> |
e9103e74 | 27 | #include <asm/sh_keysc.h> |
a991801a | 28 | #include <asm/clock.h> |
4138b740 KM |
29 | #include <cpu/sh7724.h> |
30 | ||
31 | /* | |
b7056bc1 KM |
32 | * Address Interface BusWidth |
33 | *----------------------------------------- | |
34 | * 0x0000_0000 uboot 16bit | |
35 | * 0x0004_0000 Linux romImage 16bit | |
36 | * 0x0014_0000 MTD for Linux 16bit | |
37 | * 0x0400_0000 Internal I/O 16/32bit | |
38 | * 0x0800_0000 DRAM 32bit | |
39 | * 0x1800_0000 MFI 16bit | |
4138b740 KM |
40 | */ |
41 | ||
42 | /* Heartbeat */ | |
43 | static unsigned char led_pos[] = { 0, 1, 2, 3 }; | |
44 | static struct heartbeat_data heartbeat_data = { | |
45 | .regsize = 8, | |
46 | .nr_bits = 4, | |
47 | .bit_pos = led_pos, | |
48 | }; | |
49 | ||
50 | static struct resource heartbeat_resources[] = { | |
51 | [0] = { | |
52 | .start = 0xA405012C, /* PTG */ | |
53 | .end = 0xA405012E - 1, | |
54 | .flags = IORESOURCE_MEM, | |
55 | }, | |
56 | }; | |
57 | ||
58 | static struct platform_device heartbeat_device = { | |
59 | .name = "heartbeat", | |
60 | .id = -1, | |
61 | .dev = { | |
62 | .platform_data = &heartbeat_data, | |
63 | }, | |
64 | .num_resources = ARRAY_SIZE(heartbeat_resources), | |
65 | .resource = heartbeat_resources, | |
66 | }; | |
67 | ||
68 | /* MTD */ | |
69 | static struct mtd_partition nor_flash_partitions[] = { | |
70 | { | |
b7056bc1 | 71 | .name = "boot loader", |
4138b740 | 72 | .offset = 0, |
b7056bc1 | 73 | .size = (5 * 1024 * 1024), |
d5ce010c | 74 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
4138b740 KM |
75 | }, { |
76 | .name = "free-area", | |
77 | .offset = MTDPART_OFS_APPEND, | |
78 | .size = MTDPART_SIZ_FULL, | |
79 | }, | |
80 | }; | |
81 | ||
82 | static struct physmap_flash_data nor_flash_data = { | |
83 | .width = 2, | |
84 | .parts = nor_flash_partitions, | |
85 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
86 | }; | |
87 | ||
88 | static struct resource nor_flash_resources[] = { | |
89 | [0] = { | |
90 | .name = "NOR Flash", | |
91 | .start = 0x00000000, | |
92 | .end = 0x03ffffff, | |
93 | .flags = IORESOURCE_MEM, | |
94 | } | |
95 | }; | |
96 | ||
97 | static struct platform_device nor_flash_device = { | |
98 | .name = "physmap-flash", | |
99 | .resource = nor_flash_resources, | |
100 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
101 | .dev = { | |
102 | .platform_data = &nor_flash_data, | |
103 | }, | |
104 | }; | |
105 | ||
35a35408 KM |
106 | /* SH Eth */ |
107 | #define SH_ETH_ADDR (0xA4600000) | |
108 | #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0) | |
109 | #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8) | |
110 | static struct resource sh_eth_resources[] = { | |
111 | [0] = { | |
112 | .start = SH_ETH_ADDR, | |
113 | .end = SH_ETH_ADDR + 0x1FC, | |
114 | .flags = IORESOURCE_MEM, | |
115 | }, | |
116 | [1] = { | |
117 | .start = 91, | |
118 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, | |
119 | }, | |
120 | }; | |
121 | ||
122 | struct sh_eth_plat_data sh_eth_plat = { | |
123 | .phy = 0x1f, /* SMSC LAN8700 */ | |
124 | .edmac_endian = EDMAC_LITTLE_ENDIAN, | |
acf3cc28 | 125 | .ether_link_active_low = 1 |
35a35408 KM |
126 | }; |
127 | ||
128 | static struct platform_device sh_eth_device = { | |
129 | .name = "sh-eth", | |
130 | .id = 0, | |
131 | .dev = { | |
132 | .platform_data = &sh_eth_plat, | |
133 | }, | |
134 | .num_resources = ARRAY_SIZE(sh_eth_resources), | |
135 | .resource = sh_eth_resources, | |
136 | }; | |
137 | ||
907050a3 KM |
138 | /* USB0 host */ |
139 | void usb0_port_power(int port, int power) | |
140 | { | |
141 | gpio_set_value(GPIO_PTB4, power); | |
142 | } | |
143 | ||
144 | static struct r8a66597_platdata usb0_host_data = { | |
145 | .on_chip = 1, | |
146 | .port_power = usb0_port_power, | |
147 | }; | |
148 | ||
149 | static struct resource usb0_host_resources[] = { | |
150 | [0] = { | |
151 | .start = 0xa4d80000, | |
152 | .end = 0xa4d80124 - 1, | |
153 | .flags = IORESOURCE_MEM, | |
154 | }, | |
155 | [1] = { | |
156 | .start = 65, | |
157 | .end = 65, | |
158 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, | |
159 | }, | |
160 | }; | |
161 | ||
162 | static struct platform_device usb0_host_device = { | |
163 | .name = "r8a66597_hcd", | |
164 | .id = 0, | |
165 | .dev = { | |
166 | .dma_mask = NULL, /* not use dma */ | |
167 | .coherent_dma_mask = 0xffffffff, | |
168 | .platform_data = &usb0_host_data, | |
169 | }, | |
170 | .num_resources = ARRAY_SIZE(usb0_host_resources), | |
171 | .resource = usb0_host_resources, | |
172 | }; | |
173 | ||
174 | /* | |
175 | * USB1 | |
176 | * | |
177 | * CN5 can use both host/function, | |
178 | * and we can determine it by checking PTB[3] | |
179 | * | |
180 | * This time only USB1 host is supported. | |
181 | */ | |
182 | void usb1_port_power(int port, int power) | |
183 | { | |
184 | if (!gpio_get_value(GPIO_PTB3)) { | |
185 | printk(KERN_ERR "USB1 function is not supported\n"); | |
186 | return; | |
187 | } | |
188 | ||
189 | gpio_set_value(GPIO_PTB5, power); | |
190 | } | |
191 | ||
192 | static struct r8a66597_platdata usb1_host_data = { | |
193 | .on_chip = 1, | |
194 | .port_power = usb1_port_power, | |
195 | }; | |
196 | ||
197 | static struct resource usb1_host_resources[] = { | |
198 | [0] = { | |
199 | .start = 0xa4d90000, | |
200 | .end = 0xa4d90124 - 1, | |
201 | .flags = IORESOURCE_MEM, | |
202 | }, | |
203 | [1] = { | |
204 | .start = 66, | |
205 | .end = 66, | |
206 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, | |
207 | }, | |
208 | }; | |
209 | ||
210 | static struct platform_device usb1_host_device = { | |
211 | .name = "r8a66597_hcd", | |
212 | .id = 1, | |
213 | .dev = { | |
214 | .dma_mask = NULL, /* not use dma */ | |
215 | .coherent_dma_mask = 0xffffffff, | |
216 | .platform_data = &usb1_host_data, | |
217 | }, | |
218 | .num_resources = ARRAY_SIZE(usb1_host_resources), | |
219 | .resource = usb1_host_resources, | |
220 | }; | |
221 | ||
fa3ba51b KM |
222 | /* LCDC */ |
223 | static struct sh_mobile_lcdc_info lcdc_info = { | |
224 | .ch[0] = { | |
225 | .interface_type = RGB18, | |
226 | .chan = LCDC_CHAN_MAINLCD, | |
227 | .bpp = 16, | |
fa3ba51b KM |
228 | .lcd_cfg = { |
229 | .sync = 0, /* hsync and vsync are active low */ | |
230 | }, | |
231 | .lcd_size_cfg = { /* 7.0 inch */ | |
232 | .width = 152, | |
233 | .height = 91, | |
234 | }, | |
235 | .board_cfg = { | |
236 | }, | |
237 | } | |
238 | }; | |
239 | ||
240 | static struct resource lcdc_resources[] = { | |
241 | [0] = { | |
242 | .name = "LCDC", | |
243 | .start = 0xfe940000, | |
a6f15ade | 244 | .end = 0xfe942fff, |
fa3ba51b KM |
245 | .flags = IORESOURCE_MEM, |
246 | }, | |
247 | [1] = { | |
248 | .start = 106, | |
249 | .flags = IORESOURCE_IRQ, | |
250 | }, | |
251 | }; | |
252 | ||
253 | static struct platform_device lcdc_device = { | |
254 | .name = "sh_mobile_lcdc_fb", | |
255 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
256 | .resource = lcdc_resources, | |
257 | .dev = { | |
258 | .platform_data = &lcdc_info, | |
259 | }, | |
260 | .archdata = { | |
261 | .hwblk_id = HWBLK_LCDC, | |
262 | }, | |
263 | }; | |
264 | ||
2153ad32 KM |
265 | /* CEU0 */ |
266 | static struct sh_mobile_ceu_info sh_mobile_ceu0_info = { | |
267 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, | |
268 | }; | |
269 | ||
270 | static struct resource ceu0_resources[] = { | |
271 | [0] = { | |
272 | .name = "CEU0", | |
273 | .start = 0xfe910000, | |
274 | .end = 0xfe91009f, | |
275 | .flags = IORESOURCE_MEM, | |
276 | }, | |
277 | [1] = { | |
278 | .start = 52, | |
279 | .flags = IORESOURCE_IRQ, | |
280 | }, | |
281 | [2] = { | |
282 | /* place holder for contiguous memory */ | |
283 | }, | |
284 | }; | |
285 | ||
286 | static struct platform_device ceu0_device = { | |
287 | .name = "sh_mobile_ceu", | |
288 | .id = 0, /* "ceu0" clock */ | |
289 | .num_resources = ARRAY_SIZE(ceu0_resources), | |
290 | .resource = ceu0_resources, | |
291 | .dev = { | |
292 | .platform_data = &sh_mobile_ceu0_info, | |
293 | }, | |
294 | .archdata = { | |
295 | .hwblk_id = HWBLK_CEU0, | |
296 | }, | |
297 | }; | |
298 | ||
299 | /* CEU1 */ | |
300 | static struct sh_mobile_ceu_info sh_mobile_ceu1_info = { | |
301 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, | |
302 | }; | |
303 | ||
304 | static struct resource ceu1_resources[] = { | |
305 | [0] = { | |
306 | .name = "CEU1", | |
307 | .start = 0xfe914000, | |
308 | .end = 0xfe91409f, | |
309 | .flags = IORESOURCE_MEM, | |
310 | }, | |
311 | [1] = { | |
312 | .start = 63, | |
313 | .flags = IORESOURCE_IRQ, | |
314 | }, | |
315 | [2] = { | |
316 | /* place holder for contiguous memory */ | |
317 | }, | |
318 | }; | |
319 | ||
320 | static struct platform_device ceu1_device = { | |
321 | .name = "sh_mobile_ceu", | |
322 | .id = 1, /* "ceu1" clock */ | |
323 | .num_resources = ARRAY_SIZE(ceu1_resources), | |
324 | .resource = ceu1_resources, | |
325 | .dev = { | |
326 | .platform_data = &sh_mobile_ceu1_info, | |
327 | }, | |
328 | .archdata = { | |
329 | .hwblk_id = HWBLK_CEU1, | |
330 | }, | |
331 | }; | |
332 | ||
125ecce6 KM |
333 | /* I2C device */ |
334 | static struct i2c_board_info i2c1_devices[] = { | |
335 | { | |
336 | I2C_BOARD_INFO("r2025sd", 0x32), | |
337 | }, | |
338 | }; | |
339 | ||
e9103e74 KM |
340 | /* KEYSC */ |
341 | static struct sh_keysc_info keysc_info = { | |
342 | .mode = SH_KEYSC_MODE_1, | |
343 | .scan_timing = 3, | |
344 | .delay = 50, | |
345 | .kycr2_delay = 100, | |
346 | .keycodes = { KEY_1, 0, 0, 0, 0, | |
347 | KEY_2, 0, 0, 0, 0, | |
348 | KEY_3, 0, 0, 0, 0, | |
349 | KEY_4, 0, 0, 0, 0, | |
350 | KEY_5, 0, 0, 0, 0, | |
351 | KEY_6, 0, 0, 0, 0, }, | |
352 | }; | |
353 | ||
354 | static struct resource keysc_resources[] = { | |
355 | [0] = { | |
356 | .name = "KEYSC", | |
357 | .start = 0x044b0000, | |
358 | .end = 0x044b000f, | |
359 | .flags = IORESOURCE_MEM, | |
360 | }, | |
361 | [1] = { | |
362 | .start = 79, | |
363 | .flags = IORESOURCE_IRQ, | |
364 | }, | |
365 | }; | |
366 | ||
367 | static struct platform_device keysc_device = { | |
368 | .name = "sh_keysc", | |
369 | .id = 0, /* keysc0 clock */ | |
370 | .num_resources = ARRAY_SIZE(keysc_resources), | |
371 | .resource = keysc_resources, | |
372 | .dev = { | |
373 | .platform_data = &keysc_info, | |
374 | }, | |
375 | .archdata = { | |
376 | .hwblk_id = HWBLK_KEYSC, | |
377 | }, | |
378 | }; | |
379 | ||
8810e055 KM |
380 | /* TouchScreen */ |
381 | #define IRQ0 32 | |
382 | static int ts_get_pendown_state(void) | |
383 | { | |
384 | int val = 0; | |
385 | gpio_free(GPIO_FN_INTC_IRQ0); | |
386 | gpio_request(GPIO_PTZ0, NULL); | |
387 | gpio_direction_input(GPIO_PTZ0); | |
388 | ||
389 | val = gpio_get_value(GPIO_PTZ0); | |
390 | ||
391 | gpio_free(GPIO_PTZ0); | |
392 | gpio_request(GPIO_FN_INTC_IRQ0, NULL); | |
393 | ||
394 | return val ? 0 : 1; | |
395 | } | |
396 | ||
397 | static int ts_init(void) | |
398 | { | |
399 | gpio_request(GPIO_FN_INTC_IRQ0, NULL); | |
400 | return 0; | |
401 | } | |
402 | ||
403 | struct tsc2007_platform_data tsc2007_info = { | |
404 | .model = 2007, | |
405 | .x_plate_ohms = 180, | |
406 | .get_pendown_state = ts_get_pendown_state, | |
407 | .init_platform_hw = ts_init, | |
408 | }; | |
409 | ||
410 | static struct i2c_board_info ts_i2c_clients = { | |
411 | I2C_BOARD_INFO("tsc2007", 0x48), | |
412 | .type = "tsc2007", | |
413 | .platform_data = &tsc2007_info, | |
414 | .irq = IRQ0, | |
415 | }; | |
416 | ||
4138b740 KM |
417 | static struct platform_device *ecovec_devices[] __initdata = { |
418 | &heartbeat_device, | |
419 | &nor_flash_device, | |
35a35408 | 420 | &sh_eth_device, |
907050a3 KM |
421 | &usb0_host_device, |
422 | &usb1_host_device, /* USB1 host support */ | |
fa3ba51b | 423 | &lcdc_device, |
2153ad32 KM |
424 | &ceu0_device, |
425 | &ceu1_device, | |
e9103e74 | 426 | &keysc_device, |
4138b740 KM |
427 | }; |
428 | ||
4907d57f KM |
429 | #define EEPROM_ADDR 0x50 |
430 | static u8 mac_read(struct i2c_adapter *a, u8 command) | |
431 | { | |
432 | struct i2c_msg msg[2]; | |
433 | u8 buf; | |
434 | int ret; | |
435 | ||
436 | msg[0].addr = EEPROM_ADDR; | |
437 | msg[0].flags = 0; | |
438 | msg[0].len = 1; | |
439 | msg[0].buf = &command; | |
440 | ||
441 | msg[1].addr = EEPROM_ADDR; | |
442 | msg[1].flags = I2C_M_RD; | |
443 | msg[1].len = 1; | |
444 | msg[1].buf = &buf; | |
445 | ||
446 | ret = i2c_transfer(a, msg, 2); | |
447 | if (ret < 0) { | |
448 | printk(KERN_ERR "error %d\n", ret); | |
449 | buf = 0xff; | |
450 | } | |
451 | ||
452 | return buf; | |
453 | } | |
454 | ||
455 | #define MAC_LEN 6 | |
456 | static void __init sh_eth_init(void) | |
457 | { | |
458 | struct i2c_adapter *a = i2c_get_adapter(1); | |
459 | struct clk *eth_clk; | |
460 | u8 mac[MAC_LEN]; | |
461 | int i; | |
462 | ||
463 | if (!a) { | |
464 | pr_err("can not get I2C 1\n"); | |
465 | return; | |
466 | } | |
467 | ||
468 | eth_clk = clk_get(NULL, "eth0"); | |
469 | if (!eth_clk) { | |
470 | pr_err("can not get eth0 clk\n"); | |
471 | return; | |
472 | } | |
473 | ||
474 | /* read MAC address frome EEPROM */ | |
475 | for (i = 0; i < MAC_LEN; i++) { | |
476 | mac[i] = mac_read(a, 0x10 + i); | |
477 | msleep(10); | |
478 | } | |
479 | ||
480 | /* clock enable */ | |
481 | clk_enable(eth_clk); | |
482 | ||
483 | /* reset sh-eth */ | |
484 | ctrl_outl(0x1, SH_ETH_ADDR + 0x0); | |
485 | ||
486 | /* set MAC addr */ | |
487 | ctrl_outl((mac[0] << 24) | | |
488 | (mac[1] << 16) | | |
489 | (mac[2] << 8) | | |
490 | (mac[3] << 0), SH_ETH_MAHR); | |
491 | ctrl_outl((mac[4] << 8) | | |
492 | (mac[5] << 0), SH_ETH_MALR); | |
493 | ||
494 | clk_put(eth_clk); | |
495 | } | |
496 | ||
fa3ba51b | 497 | #define PORT_HIZA 0xA4050158 |
ea15edb2 | 498 | #define IODRIVEA 0xA405018A |
4907d57f | 499 | static int __init arch_setup(void) |
4138b740 KM |
500 | { |
501 | /* enable SCIFA0 */ | |
502 | gpio_request(GPIO_FN_SCIF0_TXD, NULL); | |
503 | gpio_request(GPIO_FN_SCIF0_RXD, NULL); | |
4138b740 KM |
504 | |
505 | /* enable debug LED */ | |
506 | gpio_request(GPIO_PTG0, NULL); | |
507 | gpio_request(GPIO_PTG1, NULL); | |
508 | gpio_request(GPIO_PTG2, NULL); | |
509 | gpio_request(GPIO_PTG3, NULL); | |
b7056bc1 KM |
510 | gpio_direction_output(GPIO_PTG0, 0); |
511 | gpio_direction_output(GPIO_PTG1, 0); | |
512 | gpio_direction_output(GPIO_PTG2, 0); | |
513 | gpio_direction_output(GPIO_PTG3, 0); | |
643e9d10 | 514 | ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA); |
4138b740 | 515 | |
35a35408 KM |
516 | /* enable SH-Eth */ |
517 | gpio_request(GPIO_PTA1, NULL); | |
518 | gpio_direction_output(GPIO_PTA1, 1); | |
519 | mdelay(20); | |
520 | ||
521 | gpio_request(GPIO_FN_RMII_RXD0, NULL); | |
522 | gpio_request(GPIO_FN_RMII_RXD1, NULL); | |
523 | gpio_request(GPIO_FN_RMII_TXD0, NULL); | |
524 | gpio_request(GPIO_FN_RMII_TXD1, NULL); | |
525 | gpio_request(GPIO_FN_RMII_REF_CLK, NULL); | |
526 | gpio_request(GPIO_FN_RMII_TX_EN, NULL); | |
527 | gpio_request(GPIO_FN_RMII_RX_ER, NULL); | |
528 | gpio_request(GPIO_FN_RMII_CRS_DV, NULL); | |
529 | gpio_request(GPIO_FN_MDIO, NULL); | |
530 | gpio_request(GPIO_FN_MDC, NULL); | |
531 | gpio_request(GPIO_FN_LNKSTA, NULL); | |
532 | ||
907050a3 | 533 | /* enable USB */ |
be4ebf99 | 534 | ctrl_outw(0x0000, 0xA4D80000); |
147df2d6 | 535 | ctrl_outw(0x0000, 0xA4D90000); |
907050a3 KM |
536 | gpio_request(GPIO_PTB3, NULL); |
537 | gpio_request(GPIO_PTB4, NULL); | |
538 | gpio_request(GPIO_PTB5, NULL); | |
539 | gpio_direction_input(GPIO_PTB3); | |
540 | gpio_direction_output(GPIO_PTB4, 0); | |
541 | gpio_direction_output(GPIO_PTB5, 0); | |
542 | ctrl_outw(0x0600, 0xa40501d4); | |
543 | ctrl_outw(0x0600, 0xa4050192); | |
544 | ||
fa3ba51b KM |
545 | /* enable LCDC */ |
546 | gpio_request(GPIO_FN_LCDD23, NULL); | |
547 | gpio_request(GPIO_FN_LCDD22, NULL); | |
548 | gpio_request(GPIO_FN_LCDD21, NULL); | |
549 | gpio_request(GPIO_FN_LCDD20, NULL); | |
550 | gpio_request(GPIO_FN_LCDD19, NULL); | |
551 | gpio_request(GPIO_FN_LCDD18, NULL); | |
552 | gpio_request(GPIO_FN_LCDD17, NULL); | |
553 | gpio_request(GPIO_FN_LCDD16, NULL); | |
554 | gpio_request(GPIO_FN_LCDD15, NULL); | |
555 | gpio_request(GPIO_FN_LCDD14, NULL); | |
556 | gpio_request(GPIO_FN_LCDD13, NULL); | |
557 | gpio_request(GPIO_FN_LCDD12, NULL); | |
558 | gpio_request(GPIO_FN_LCDD11, NULL); | |
559 | gpio_request(GPIO_FN_LCDD10, NULL); | |
560 | gpio_request(GPIO_FN_LCDD9, NULL); | |
561 | gpio_request(GPIO_FN_LCDD8, NULL); | |
562 | gpio_request(GPIO_FN_LCDD7, NULL); | |
563 | gpio_request(GPIO_FN_LCDD6, NULL); | |
564 | gpio_request(GPIO_FN_LCDD5, NULL); | |
565 | gpio_request(GPIO_FN_LCDD4, NULL); | |
566 | gpio_request(GPIO_FN_LCDD3, NULL); | |
567 | gpio_request(GPIO_FN_LCDD2, NULL); | |
568 | gpio_request(GPIO_FN_LCDD1, NULL); | |
569 | gpio_request(GPIO_FN_LCDD0, NULL); | |
570 | gpio_request(GPIO_FN_LCDDISP, NULL); | |
571 | gpio_request(GPIO_FN_LCDHSYN, NULL); | |
572 | gpio_request(GPIO_FN_LCDDCK, NULL); | |
573 | gpio_request(GPIO_FN_LCDVSYN, NULL); | |
574 | gpio_request(GPIO_FN_LCDDON, NULL); | |
575 | gpio_request(GPIO_FN_LCDLCLK, NULL); | |
576 | ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA); | |
577 | ||
578 | gpio_request(GPIO_PTE6, NULL); | |
579 | gpio_request(GPIO_PTU1, NULL); | |
580 | gpio_request(GPIO_PTR1, NULL); | |
581 | gpio_request(GPIO_PTA2, NULL); | |
582 | gpio_direction_input(GPIO_PTE6); | |
583 | gpio_direction_output(GPIO_PTU1, 0); | |
584 | gpio_direction_output(GPIO_PTR1, 0); | |
585 | gpio_direction_output(GPIO_PTA2, 0); | |
586 | ||
ea15edb2 KM |
587 | /* I/O buffer drive ability is low */ |
588 | ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA); | |
589 | ||
fa3ba51b KM |
590 | if (gpio_get_value(GPIO_PTE6)) { |
591 | /* DVI */ | |
592 | lcdc_info.clock_source = LCDC_CLK_EXTERNAL; | |
ea15edb2 | 593 | lcdc_info.ch[0].clock_divider = 1, |
fa3ba51b KM |
594 | lcdc_info.ch[0].lcd_cfg.name = "DVI"; |
595 | lcdc_info.ch[0].lcd_cfg.xres = 1280; | |
596 | lcdc_info.ch[0].lcd_cfg.yres = 720; | |
597 | lcdc_info.ch[0].lcd_cfg.left_margin = 220; | |
598 | lcdc_info.ch[0].lcd_cfg.right_margin = 110; | |
599 | lcdc_info.ch[0].lcd_cfg.hsync_len = 40; | |
600 | lcdc_info.ch[0].lcd_cfg.upper_margin = 20; | |
601 | lcdc_info.ch[0].lcd_cfg.lower_margin = 5; | |
602 | lcdc_info.ch[0].lcd_cfg.vsync_len = 5; | |
603 | ||
604 | gpio_set_value(GPIO_PTA2, 1); | |
605 | gpio_set_value(GPIO_PTU1, 1); | |
606 | } else { | |
607 | /* Panel */ | |
ea15edb2 KM |
608 | |
609 | lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; | |
610 | lcdc_info.ch[0].clock_divider = 2, | |
611 | lcdc_info.ch[0].lcd_cfg.name = "Panel"; | |
612 | lcdc_info.ch[0].lcd_cfg.xres = 800; | |
613 | lcdc_info.ch[0].lcd_cfg.yres = 480; | |
614 | lcdc_info.ch[0].lcd_cfg.left_margin = 220; | |
615 | lcdc_info.ch[0].lcd_cfg.right_margin = 110; | |
616 | lcdc_info.ch[0].lcd_cfg.hsync_len = 70; | |
617 | lcdc_info.ch[0].lcd_cfg.upper_margin = 20; | |
618 | lcdc_info.ch[0].lcd_cfg.lower_margin = 5; | |
619 | lcdc_info.ch[0].lcd_cfg.vsync_len = 5; | |
620 | ||
621 | gpio_set_value(GPIO_PTR1, 1); | |
622 | ||
623 | /* FIXME | |
624 | * | |
625 | * LCDDON control is needed for Panel, | |
626 | * but current sh_mobile_lcdc driver doesn't control it. | |
627 | * It is temporary correspondence | |
628 | */ | |
629 | gpio_request(GPIO_PTF4, NULL); | |
630 | gpio_direction_output(GPIO_PTF4, 1); | |
8810e055 KM |
631 | |
632 | /* enable TouchScreen */ | |
633 | i2c_register_board_info(0, &ts_i2c_clients, 1); | |
634 | set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW); | |
fa3ba51b KM |
635 | } |
636 | ||
2153ad32 KM |
637 | /* enable CEU0 */ |
638 | gpio_request(GPIO_FN_VIO0_D15, NULL); | |
639 | gpio_request(GPIO_FN_VIO0_D14, NULL); | |
640 | gpio_request(GPIO_FN_VIO0_D13, NULL); | |
641 | gpio_request(GPIO_FN_VIO0_D12, NULL); | |
642 | gpio_request(GPIO_FN_VIO0_D11, NULL); | |
643 | gpio_request(GPIO_FN_VIO0_D10, NULL); | |
644 | gpio_request(GPIO_FN_VIO0_D9, NULL); | |
645 | gpio_request(GPIO_FN_VIO0_D8, NULL); | |
646 | gpio_request(GPIO_FN_VIO0_D7, NULL); | |
647 | gpio_request(GPIO_FN_VIO0_D6, NULL); | |
648 | gpio_request(GPIO_FN_VIO0_D5, NULL); | |
649 | gpio_request(GPIO_FN_VIO0_D4, NULL); | |
650 | gpio_request(GPIO_FN_VIO0_D3, NULL); | |
651 | gpio_request(GPIO_FN_VIO0_D2, NULL); | |
652 | gpio_request(GPIO_FN_VIO0_D1, NULL); | |
653 | gpio_request(GPIO_FN_VIO0_D0, NULL); | |
654 | gpio_request(GPIO_FN_VIO0_VD, NULL); | |
655 | gpio_request(GPIO_FN_VIO0_CLK, NULL); | |
656 | gpio_request(GPIO_FN_VIO0_FLD, NULL); | |
657 | gpio_request(GPIO_FN_VIO0_HD, NULL); | |
658 | platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20); | |
659 | ||
660 | /* enable CEU1 */ | |
661 | gpio_request(GPIO_FN_VIO1_D7, NULL); | |
662 | gpio_request(GPIO_FN_VIO1_D6, NULL); | |
663 | gpio_request(GPIO_FN_VIO1_D5, NULL); | |
664 | gpio_request(GPIO_FN_VIO1_D4, NULL); | |
665 | gpio_request(GPIO_FN_VIO1_D3, NULL); | |
666 | gpio_request(GPIO_FN_VIO1_D2, NULL); | |
667 | gpio_request(GPIO_FN_VIO1_D1, NULL); | |
668 | gpio_request(GPIO_FN_VIO1_D0, NULL); | |
669 | gpio_request(GPIO_FN_VIO1_FLD, NULL); | |
670 | gpio_request(GPIO_FN_VIO1_HD, NULL); | |
671 | gpio_request(GPIO_FN_VIO1_VD, NULL); | |
672 | gpio_request(GPIO_FN_VIO1_CLK, NULL); | |
673 | platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20); | |
674 | ||
e9103e74 KM |
675 | /* enable KEYSC */ |
676 | gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); | |
677 | gpio_request(GPIO_FN_KEYOUT4_IN6, NULL); | |
678 | gpio_request(GPIO_FN_KEYOUT3, NULL); | |
679 | gpio_request(GPIO_FN_KEYOUT2, NULL); | |
680 | gpio_request(GPIO_FN_KEYOUT1, NULL); | |
681 | gpio_request(GPIO_FN_KEYOUT0, NULL); | |
682 | gpio_request(GPIO_FN_KEYIN0, NULL); | |
683 | ||
064a16dc KM |
684 | /* enable user debug switch */ |
685 | gpio_request(GPIO_PTR0, NULL); | |
686 | gpio_request(GPIO_PTR4, NULL); | |
687 | gpio_request(GPIO_PTR5, NULL); | |
688 | gpio_request(GPIO_PTR6, NULL); | |
689 | gpio_direction_input(GPIO_PTR0); | |
690 | gpio_direction_input(GPIO_PTR4); | |
691 | gpio_direction_input(GPIO_PTR5); | |
692 | gpio_direction_input(GPIO_PTR6); | |
693 | ||
125ecce6 KM |
694 | /* enable I2C device */ |
695 | i2c_register_board_info(1, i2c1_devices, | |
696 | ARRAY_SIZE(i2c1_devices)); | |
697 | ||
4138b740 KM |
698 | return platform_add_devices(ecovec_devices, |
699 | ARRAY_SIZE(ecovec_devices)); | |
700 | } | |
4907d57f KM |
701 | arch_initcall(arch_setup); |
702 | ||
703 | static int __init devices_setup(void) | |
704 | { | |
705 | sh_eth_init(); | |
706 | return 0; | |
707 | } | |
708 | device_initcall(devices_setup); | |
709 | ||
4138b740 KM |
710 | |
711 | static struct sh_machine_vector mv_ecovec __initmv = { | |
712 | .mv_name = "R0P7724 (EcoVec)", | |
713 | }; |