blob: c3d05e5be2e9e366e13046a6ffc37a5bdbf09832 [file] [log] [blame]
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001/*
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>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000017#include <linux/io.h>
18#include <linux/delay.h>
Kuninori Morimoto907050a2009-08-26 11:04:31 +000019#include <linux/usb/r8a66597.h>
Kuninori Morimoto4907d572009-09-10 01:39:58 +000020#include <linux/i2c.h>
Kuninori Morimoto8810e052009-09-28 08:21:41 +000021#include <linux/i2c/tsc2007.h>
Kuninori Morimotoe9103e72009-09-14 11:23:00 +000022#include <linux/input.h>
Kuninori Morimotofa3ba512009-08-26 11:04:34 +000023#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto2153ad32009-08-26 11:04:36 +000024#include <media/sh_mobile_ceu.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000025#include <asm/heartbeat.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000026#include <asm/sh_eth.h>
Kuninori Morimotoe9103e72009-09-14 11:23:00 +000027#include <asm/sh_keysc.h>
Kuninori Morimotoa9918012009-09-14 11:23:16 +000028#include <asm/clock.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000029#include <cpu/sh7724.h>
30
31/*
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000032 * 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
Kuninori Morimoto4138b742009-08-19 12:08:33 +000040 */
41
Kuninori Morimoto9c472c42009-10-02 07:52:20 +000042/* SWITCH
43 *------------------------------
44 * DS2[1] = FlashROM write protect ON : write protect
45 * OFF : No write protect
46 * DS2[2] = RMII / TS, SCIF ON : RMII
47 * OFF : TS, SCIF3
48 * DS2[3] = Camera / Video ON : Camera
49 * OFF : NTSC/PAL (IN)
50 * DS2[5] = NTSC_OUT Clock ON : On board OSC
51 * OFF : SH7724 DV_CLK
52 * DS2[6-7] = MMC / SD ON-OFF : SD
53 * OFF-ON : MMC
54 */
55
Kuninori Morimoto4138b742009-08-19 12:08:33 +000056/* Heartbeat */
57static unsigned char led_pos[] = { 0, 1, 2, 3 };
58static struct heartbeat_data heartbeat_data = {
59 .regsize = 8,
60 .nr_bits = 4,
61 .bit_pos = led_pos,
62};
63
64static struct resource heartbeat_resources[] = {
65 [0] = {
66 .start = 0xA405012C, /* PTG */
67 .end = 0xA405012E - 1,
68 .flags = IORESOURCE_MEM,
69 },
70};
71
72static struct platform_device heartbeat_device = {
73 .name = "heartbeat",
74 .id = -1,
75 .dev = {
76 .platform_data = &heartbeat_data,
77 },
78 .num_resources = ARRAY_SIZE(heartbeat_resources),
79 .resource = heartbeat_resources,
80};
81
82/* MTD */
83static struct mtd_partition nor_flash_partitions[] = {
84 {
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000085 .name = "boot loader",
Kuninori Morimoto4138b742009-08-19 12:08:33 +000086 .offset = 0,
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000087 .size = (5 * 1024 * 1024),
Kuninori Morimotod5ce0102009-09-30 00:50:30 +000088 .mask_flags = MTD_WRITEABLE, /* force read-only */
Kuninori Morimoto4138b742009-08-19 12:08:33 +000089 }, {
Kuninori Morimoto4138b742009-08-19 12:08:33 +000090 .name = "free-area",
91 .offset = MTDPART_OFS_APPEND,
92 .size = MTDPART_SIZ_FULL,
93 },
94};
95
96static struct physmap_flash_data nor_flash_data = {
97 .width = 2,
98 .parts = nor_flash_partitions,
99 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
100};
101
102static struct resource nor_flash_resources[] = {
103 [0] = {
104 .name = "NOR Flash",
105 .start = 0x00000000,
106 .end = 0x03ffffff,
107 .flags = IORESOURCE_MEM,
108 }
109};
110
111static struct platform_device nor_flash_device = {
112 .name = "physmap-flash",
113 .resource = nor_flash_resources,
114 .num_resources = ARRAY_SIZE(nor_flash_resources),
115 .dev = {
116 .platform_data = &nor_flash_data,
117 },
118};
119
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000120/* SH Eth */
121#define SH_ETH_ADDR (0xA4600000)
122#define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
123#define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
124static struct resource sh_eth_resources[] = {
125 [0] = {
126 .start = SH_ETH_ADDR,
127 .end = SH_ETH_ADDR + 0x1FC,
128 .flags = IORESOURCE_MEM,
129 },
130 [1] = {
131 .start = 91,
132 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
133 },
134};
135
136struct sh_eth_plat_data sh_eth_plat = {
137 .phy = 0x1f, /* SMSC LAN8700 */
138 .edmac_endian = EDMAC_LITTLE_ENDIAN,
Kuninori Morimotoacf3cc22009-09-24 06:28:27 +0000139 .ether_link_active_low = 1
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000140};
141
142static struct platform_device sh_eth_device = {
143 .name = "sh-eth",
144 .id = 0,
145 .dev = {
146 .platform_data = &sh_eth_plat,
147 },
148 .num_resources = ARRAY_SIZE(sh_eth_resources),
149 .resource = sh_eth_resources,
Magnus Damm40e42312009-10-26 10:41:58 +0000150 .archdata = {
151 .hwblk_id = HWBLK_ETHER,
152 },
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000153};
154
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000155/* USB0 host */
156void usb0_port_power(int port, int power)
157{
158 gpio_set_value(GPIO_PTB4, power);
159}
160
161static struct r8a66597_platdata usb0_host_data = {
162 .on_chip = 1,
163 .port_power = usb0_port_power,
164};
165
166static struct resource usb0_host_resources[] = {
167 [0] = {
168 .start = 0xa4d80000,
169 .end = 0xa4d80124 - 1,
170 .flags = IORESOURCE_MEM,
171 },
172 [1] = {
173 .start = 65,
174 .end = 65,
175 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
176 },
177};
178
179static struct platform_device usb0_host_device = {
180 .name = "r8a66597_hcd",
181 .id = 0,
182 .dev = {
183 .dma_mask = NULL, /* not use dma */
184 .coherent_dma_mask = 0xffffffff,
185 .platform_data = &usb0_host_data,
186 },
187 .num_resources = ARRAY_SIZE(usb0_host_resources),
188 .resource = usb0_host_resources,
189};
190
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000191/* USB1 host/function */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000192void usb1_port_power(int port, int power)
193{
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000194 gpio_set_value(GPIO_PTB5, power);
195}
196
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000197static struct r8a66597_platdata usb1_common_data = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000198 .on_chip = 1,
199 .port_power = usb1_port_power,
200};
201
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000202static struct resource usb1_common_resources[] = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000203 [0] = {
204 .start = 0xa4d90000,
205 .end = 0xa4d90124 - 1,
206 .flags = IORESOURCE_MEM,
207 },
208 [1] = {
209 .start = 66,
210 .end = 66,
211 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
212 },
213};
214
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000215static struct platform_device usb1_common_device = {
216 /* .name will be added in arch_setup */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000217 .id = 1,
218 .dev = {
219 .dma_mask = NULL, /* not use dma */
220 .coherent_dma_mask = 0xffffffff,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000221 .platform_data = &usb1_common_data,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000222 },
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000223 .num_resources = ARRAY_SIZE(usb1_common_resources),
224 .resource = usb1_common_resources,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000225};
226
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000227/* LCDC */
228static struct sh_mobile_lcdc_info lcdc_info = {
229 .ch[0] = {
230 .interface_type = RGB18,
231 .chan = LCDC_CHAN_MAINLCD,
232 .bpp = 16,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000233 .lcd_cfg = {
234 .sync = 0, /* hsync and vsync are active low */
235 },
236 .lcd_size_cfg = { /* 7.0 inch */
237 .width = 152,
238 .height = 91,
239 },
240 .board_cfg = {
241 },
242 }
243};
244
245static struct resource lcdc_resources[] = {
246 [0] = {
247 .name = "LCDC",
248 .start = 0xfe940000,
Phil Edworthya6f15ad2009-09-15 12:00:30 +0000249 .end = 0xfe942fff,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000250 .flags = IORESOURCE_MEM,
251 },
252 [1] = {
253 .start = 106,
254 .flags = IORESOURCE_IRQ,
255 },
256};
257
258static struct platform_device lcdc_device = {
259 .name = "sh_mobile_lcdc_fb",
260 .num_resources = ARRAY_SIZE(lcdc_resources),
261 .resource = lcdc_resources,
262 .dev = {
263 .platform_data = &lcdc_info,
264 },
265 .archdata = {
266 .hwblk_id = HWBLK_LCDC,
267 },
268};
269
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000270/* CEU0 */
271static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
272 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
273};
274
275static struct resource ceu0_resources[] = {
276 [0] = {
277 .name = "CEU0",
278 .start = 0xfe910000,
279 .end = 0xfe91009f,
280 .flags = IORESOURCE_MEM,
281 },
282 [1] = {
283 .start = 52,
284 .flags = IORESOURCE_IRQ,
285 },
286 [2] = {
287 /* place holder for contiguous memory */
288 },
289};
290
291static struct platform_device ceu0_device = {
292 .name = "sh_mobile_ceu",
293 .id = 0, /* "ceu0" clock */
294 .num_resources = ARRAY_SIZE(ceu0_resources),
295 .resource = ceu0_resources,
296 .dev = {
297 .platform_data = &sh_mobile_ceu0_info,
298 },
299 .archdata = {
300 .hwblk_id = HWBLK_CEU0,
301 },
302};
303
304/* CEU1 */
305static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
306 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
307};
308
309static struct resource ceu1_resources[] = {
310 [0] = {
311 .name = "CEU1",
312 .start = 0xfe914000,
313 .end = 0xfe91409f,
314 .flags = IORESOURCE_MEM,
315 },
316 [1] = {
317 .start = 63,
318 .flags = IORESOURCE_IRQ,
319 },
320 [2] = {
321 /* place holder for contiguous memory */
322 },
323};
324
325static struct platform_device ceu1_device = {
326 .name = "sh_mobile_ceu",
327 .id = 1, /* "ceu1" clock */
328 .num_resources = ARRAY_SIZE(ceu1_resources),
329 .resource = ceu1_resources,
330 .dev = {
331 .platform_data = &sh_mobile_ceu1_info,
332 },
333 .archdata = {
334 .hwblk_id = HWBLK_CEU1,
335 },
336};
337
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000338/* I2C device */
339static struct i2c_board_info i2c1_devices[] = {
340 {
341 I2C_BOARD_INFO("r2025sd", 0x32),
342 },
343};
344
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000345/* KEYSC */
346static struct sh_keysc_info keysc_info = {
347 .mode = SH_KEYSC_MODE_1,
348 .scan_timing = 3,
349 .delay = 50,
350 .kycr2_delay = 100,
351 .keycodes = { KEY_1, 0, 0, 0, 0,
352 KEY_2, 0, 0, 0, 0,
353 KEY_3, 0, 0, 0, 0,
354 KEY_4, 0, 0, 0, 0,
355 KEY_5, 0, 0, 0, 0,
356 KEY_6, 0, 0, 0, 0, },
357};
358
359static struct resource keysc_resources[] = {
360 [0] = {
361 .name = "KEYSC",
362 .start = 0x044b0000,
363 .end = 0x044b000f,
364 .flags = IORESOURCE_MEM,
365 },
366 [1] = {
367 .start = 79,
368 .flags = IORESOURCE_IRQ,
369 },
370};
371
372static struct platform_device keysc_device = {
373 .name = "sh_keysc",
374 .id = 0, /* keysc0 clock */
375 .num_resources = ARRAY_SIZE(keysc_resources),
376 .resource = keysc_resources,
377 .dev = {
378 .platform_data = &keysc_info,
379 },
380 .archdata = {
381 .hwblk_id = HWBLK_KEYSC,
382 },
383};
384
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000385/* TouchScreen */
386#define IRQ0 32
387static int ts_get_pendown_state(void)
388{
389 int val = 0;
390 gpio_free(GPIO_FN_INTC_IRQ0);
391 gpio_request(GPIO_PTZ0, NULL);
392 gpio_direction_input(GPIO_PTZ0);
393
394 val = gpio_get_value(GPIO_PTZ0);
395
396 gpio_free(GPIO_PTZ0);
397 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
398
399 return val ? 0 : 1;
400}
401
402static int ts_init(void)
403{
404 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
405 return 0;
406}
407
408struct tsc2007_platform_data tsc2007_info = {
409 .model = 2007,
410 .x_plate_ohms = 180,
411 .get_pendown_state = ts_get_pendown_state,
412 .init_platform_hw = ts_init,
413};
414
415static struct i2c_board_info ts_i2c_clients = {
416 I2C_BOARD_INFO("tsc2007", 0x48),
417 .type = "tsc2007",
418 .platform_data = &tsc2007_info,
419 .irq = IRQ0,
420};
421
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000422/* SHDI0 */
423static struct resource sdhi0_resources[] = {
424 [0] = {
425 .name = "SDHI0",
426 .start = 0x04ce0000,
427 .end = 0x04ce01ff,
428 .flags = IORESOURCE_MEM,
429 },
430 [1] = {
431 .start = 101,
432 .flags = IORESOURCE_IRQ,
433 },
434};
435
436static struct platform_device sdhi0_device = {
437 .name = "sh_mobile_sdhi",
438 .num_resources = ARRAY_SIZE(sdhi0_resources),
439 .resource = sdhi0_resources,
440 .id = 0,
441 .archdata = {
442 .hwblk_id = HWBLK_SDHI0,
443 },
444};
445
446/* SHDI1 */
447static struct resource sdhi1_resources[] = {
448 [0] = {
449 .name = "SDHI1",
450 .start = 0x04cf0000,
451 .end = 0x04cf01ff,
452 .flags = IORESOURCE_MEM,
453 },
454 [1] = {
455 .start = 24,
456 .flags = IORESOURCE_IRQ,
457 },
458};
459
460static struct platform_device sdhi1_device = {
461 .name = "sh_mobile_sdhi",
462 .num_resources = ARRAY_SIZE(sdhi1_resources),
463 .resource = sdhi1_resources,
464 .id = 1,
465 .archdata = {
466 .hwblk_id = HWBLK_SDHI1,
467 },
468};
469
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000470static struct platform_device *ecovec_devices[] __initdata = {
471 &heartbeat_device,
472 &nor_flash_device,
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000473 &sh_eth_device,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000474 &usb0_host_device,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000475 &usb1_common_device,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000476 &lcdc_device,
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000477 &ceu0_device,
478 &ceu1_device,
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000479 &keysc_device,
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000480 &sdhi0_device,
481 &sdhi1_device,
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000482};
483
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000484#define EEPROM_ADDR 0x50
485static u8 mac_read(struct i2c_adapter *a, u8 command)
486{
487 struct i2c_msg msg[2];
488 u8 buf;
489 int ret;
490
491 msg[0].addr = EEPROM_ADDR;
492 msg[0].flags = 0;
493 msg[0].len = 1;
494 msg[0].buf = &command;
495
496 msg[1].addr = EEPROM_ADDR;
497 msg[1].flags = I2C_M_RD;
498 msg[1].len = 1;
499 msg[1].buf = &buf;
500
501 ret = i2c_transfer(a, msg, 2);
502 if (ret < 0) {
503 printk(KERN_ERR "error %d\n", ret);
504 buf = 0xff;
505 }
506
507 return buf;
508}
509
Magnus Damm376abbb2009-10-26 10:44:37 +0000510static void __init sh_eth_init(struct sh_eth_plat_data *pd)
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000511{
512 struct i2c_adapter *a = i2c_get_adapter(1);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000513 int i;
514
515 if (!a) {
516 pr_err("can not get I2C 1\n");
517 return;
518 }
519
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000520 /* read MAC address frome EEPROM */
Magnus Damm376abbb2009-10-26 10:44:37 +0000521 for (i = 0; i < sizeof(pd->mac_addr); i++) {
522 pd->mac_addr[i] = mac_read(a, 0x10 + i);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000523 msleep(10);
524 }
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000525}
526
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000527#define PORT_HIZA 0xA4050158
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000528#define IODRIVEA 0xA405018A
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000529static int __init arch_setup(void)
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000530{
Magnus Dammf78bab32009-10-07 09:00:06 +0000531 /* enable STATUS0, STATUS2 and PDSTATUS */
532 gpio_request(GPIO_FN_STATUS0, NULL);
533 gpio_request(GPIO_FN_STATUS2, NULL);
534 gpio_request(GPIO_FN_PDSTATUS, NULL);
535
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000536 /* enable SCIFA0 */
537 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
538 gpio_request(GPIO_FN_SCIF0_RXD, NULL);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000539
540 /* enable debug LED */
541 gpio_request(GPIO_PTG0, NULL);
542 gpio_request(GPIO_PTG1, NULL);
543 gpio_request(GPIO_PTG2, NULL);
544 gpio_request(GPIO_PTG3, NULL);
Kuninori Morimotob7056bc2009-08-26 11:04:22 +0000545 gpio_direction_output(GPIO_PTG0, 0);
546 gpio_direction_output(GPIO_PTG1, 0);
547 gpio_direction_output(GPIO_PTG2, 0);
548 gpio_direction_output(GPIO_PTG3, 0);
Kuninori Morimoto643e9d12009-09-10 01:40:00 +0000549 ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000550
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000551 /* enable SH-Eth */
552 gpio_request(GPIO_PTA1, NULL);
553 gpio_direction_output(GPIO_PTA1, 1);
554 mdelay(20);
555
556 gpio_request(GPIO_FN_RMII_RXD0, NULL);
557 gpio_request(GPIO_FN_RMII_RXD1, NULL);
558 gpio_request(GPIO_FN_RMII_TXD0, NULL);
559 gpio_request(GPIO_FN_RMII_TXD1, NULL);
560 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
561 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
562 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
563 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
564 gpio_request(GPIO_FN_MDIO, NULL);
565 gpio_request(GPIO_FN_MDC, NULL);
566 gpio_request(GPIO_FN_LNKSTA, NULL);
567
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000568 /* enable USB */
Kuninori Morimotobe4ebf92009-09-10 01:39:55 +0000569 ctrl_outw(0x0000, 0xA4D80000);
Kuninori Morimoto147df2d2009-09-14 11:22:31 +0000570 ctrl_outw(0x0000, 0xA4D90000);
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000571 gpio_request(GPIO_PTB3, NULL);
572 gpio_request(GPIO_PTB4, NULL);
573 gpio_request(GPIO_PTB5, NULL);
574 gpio_direction_input(GPIO_PTB3);
575 gpio_direction_output(GPIO_PTB4, 0);
576 gpio_direction_output(GPIO_PTB5, 0);
577 ctrl_outw(0x0600, 0xa40501d4);
578 ctrl_outw(0x0600, 0xa4050192);
579
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000580 if (gpio_get_value(GPIO_PTB3)) {
581 printk(KERN_INFO "USB1 function is selected\n");
582 usb1_common_device.name = "r8a66597_udc";
583 } else {
584 printk(KERN_INFO "USB1 host is selected\n");
585 usb1_common_device.name = "r8a66597_hcd";
586 }
587
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000588 /* enable LCDC */
589 gpio_request(GPIO_FN_LCDD23, NULL);
590 gpio_request(GPIO_FN_LCDD22, NULL);
591 gpio_request(GPIO_FN_LCDD21, NULL);
592 gpio_request(GPIO_FN_LCDD20, NULL);
593 gpio_request(GPIO_FN_LCDD19, NULL);
594 gpio_request(GPIO_FN_LCDD18, NULL);
595 gpio_request(GPIO_FN_LCDD17, NULL);
596 gpio_request(GPIO_FN_LCDD16, NULL);
597 gpio_request(GPIO_FN_LCDD15, NULL);
598 gpio_request(GPIO_FN_LCDD14, NULL);
599 gpio_request(GPIO_FN_LCDD13, NULL);
600 gpio_request(GPIO_FN_LCDD12, NULL);
601 gpio_request(GPIO_FN_LCDD11, NULL);
602 gpio_request(GPIO_FN_LCDD10, NULL);
603 gpio_request(GPIO_FN_LCDD9, NULL);
604 gpio_request(GPIO_FN_LCDD8, NULL);
605 gpio_request(GPIO_FN_LCDD7, NULL);
606 gpio_request(GPIO_FN_LCDD6, NULL);
607 gpio_request(GPIO_FN_LCDD5, NULL);
608 gpio_request(GPIO_FN_LCDD4, NULL);
609 gpio_request(GPIO_FN_LCDD3, NULL);
610 gpio_request(GPIO_FN_LCDD2, NULL);
611 gpio_request(GPIO_FN_LCDD1, NULL);
612 gpio_request(GPIO_FN_LCDD0, NULL);
613 gpio_request(GPIO_FN_LCDDISP, NULL);
614 gpio_request(GPIO_FN_LCDHSYN, NULL);
615 gpio_request(GPIO_FN_LCDDCK, NULL);
616 gpio_request(GPIO_FN_LCDVSYN, NULL);
617 gpio_request(GPIO_FN_LCDDON, NULL);
618 gpio_request(GPIO_FN_LCDLCLK, NULL);
619 ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
620
621 gpio_request(GPIO_PTE6, NULL);
622 gpio_request(GPIO_PTU1, NULL);
623 gpio_request(GPIO_PTR1, NULL);
624 gpio_request(GPIO_PTA2, NULL);
625 gpio_direction_input(GPIO_PTE6);
626 gpio_direction_output(GPIO_PTU1, 0);
627 gpio_direction_output(GPIO_PTR1, 0);
628 gpio_direction_output(GPIO_PTA2, 0);
629
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000630 /* I/O buffer drive ability is low */
631 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA);
632
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000633 if (gpio_get_value(GPIO_PTE6)) {
634 /* DVI */
635 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000636 lcdc_info.ch[0].clock_divider = 1,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000637 lcdc_info.ch[0].lcd_cfg.name = "DVI";
638 lcdc_info.ch[0].lcd_cfg.xres = 1280;
639 lcdc_info.ch[0].lcd_cfg.yres = 720;
640 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
641 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
642 lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
643 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
644 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
645 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
646
647 gpio_set_value(GPIO_PTA2, 1);
648 gpio_set_value(GPIO_PTU1, 1);
649 } else {
650 /* Panel */
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000651
652 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
653 lcdc_info.ch[0].clock_divider = 2,
654 lcdc_info.ch[0].lcd_cfg.name = "Panel";
655 lcdc_info.ch[0].lcd_cfg.xres = 800;
656 lcdc_info.ch[0].lcd_cfg.yres = 480;
657 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
658 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
659 lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
660 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
661 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
662 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
663
664 gpio_set_value(GPIO_PTR1, 1);
665
666 /* FIXME
667 *
668 * LCDDON control is needed for Panel,
669 * but current sh_mobile_lcdc driver doesn't control it.
670 * It is temporary correspondence
671 */
672 gpio_request(GPIO_PTF4, NULL);
673 gpio_direction_output(GPIO_PTF4, 1);
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000674
675 /* enable TouchScreen */
676 i2c_register_board_info(0, &ts_i2c_clients, 1);
677 set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000678 }
679
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000680 /* enable CEU0 */
681 gpio_request(GPIO_FN_VIO0_D15, NULL);
682 gpio_request(GPIO_FN_VIO0_D14, NULL);
683 gpio_request(GPIO_FN_VIO0_D13, NULL);
684 gpio_request(GPIO_FN_VIO0_D12, NULL);
685 gpio_request(GPIO_FN_VIO0_D11, NULL);
686 gpio_request(GPIO_FN_VIO0_D10, NULL);
687 gpio_request(GPIO_FN_VIO0_D9, NULL);
688 gpio_request(GPIO_FN_VIO0_D8, NULL);
689 gpio_request(GPIO_FN_VIO0_D7, NULL);
690 gpio_request(GPIO_FN_VIO0_D6, NULL);
691 gpio_request(GPIO_FN_VIO0_D5, NULL);
692 gpio_request(GPIO_FN_VIO0_D4, NULL);
693 gpio_request(GPIO_FN_VIO0_D3, NULL);
694 gpio_request(GPIO_FN_VIO0_D2, NULL);
695 gpio_request(GPIO_FN_VIO0_D1, NULL);
696 gpio_request(GPIO_FN_VIO0_D0, NULL);
697 gpio_request(GPIO_FN_VIO0_VD, NULL);
698 gpio_request(GPIO_FN_VIO0_CLK, NULL);
699 gpio_request(GPIO_FN_VIO0_FLD, NULL);
700 gpio_request(GPIO_FN_VIO0_HD, NULL);
701 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
702
703 /* enable CEU1 */
704 gpio_request(GPIO_FN_VIO1_D7, NULL);
705 gpio_request(GPIO_FN_VIO1_D6, NULL);
706 gpio_request(GPIO_FN_VIO1_D5, NULL);
707 gpio_request(GPIO_FN_VIO1_D4, NULL);
708 gpio_request(GPIO_FN_VIO1_D3, NULL);
709 gpio_request(GPIO_FN_VIO1_D2, NULL);
710 gpio_request(GPIO_FN_VIO1_D1, NULL);
711 gpio_request(GPIO_FN_VIO1_D0, NULL);
712 gpio_request(GPIO_FN_VIO1_FLD, NULL);
713 gpio_request(GPIO_FN_VIO1_HD, NULL);
714 gpio_request(GPIO_FN_VIO1_VD, NULL);
715 gpio_request(GPIO_FN_VIO1_CLK, NULL);
716 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
717
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000718 /* enable KEYSC */
719 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
720 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
721 gpio_request(GPIO_FN_KEYOUT3, NULL);
722 gpio_request(GPIO_FN_KEYOUT2, NULL);
723 gpio_request(GPIO_FN_KEYOUT1, NULL);
724 gpio_request(GPIO_FN_KEYOUT0, NULL);
725 gpio_request(GPIO_FN_KEYIN0, NULL);
726
Kuninori Morimoto064a16d2009-09-16 11:34:34 +0000727 /* enable user debug switch */
728 gpio_request(GPIO_PTR0, NULL);
729 gpio_request(GPIO_PTR4, NULL);
730 gpio_request(GPIO_PTR5, NULL);
731 gpio_request(GPIO_PTR6, NULL);
732 gpio_direction_input(GPIO_PTR0);
733 gpio_direction_input(GPIO_PTR4);
734 gpio_direction_input(GPIO_PTR5);
735 gpio_direction_input(GPIO_PTR6);
736
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000737 /* enable SDHI0 */
738 gpio_request(GPIO_FN_SDHI0CD, NULL);
739 gpio_request(GPIO_FN_SDHI0WP, NULL);
740 gpio_request(GPIO_FN_SDHI0CMD, NULL);
741 gpio_request(GPIO_FN_SDHI0CLK, NULL);
742 gpio_request(GPIO_FN_SDHI0D3, NULL);
743 gpio_request(GPIO_FN_SDHI0D2, NULL);
744 gpio_request(GPIO_FN_SDHI0D1, NULL);
745 gpio_request(GPIO_FN_SDHI0D0, NULL);
746
747 /* enable SDHI1 */
748 gpio_request(GPIO_FN_SDHI1CD, NULL);
749 gpio_request(GPIO_FN_SDHI1WP, NULL);
750 gpio_request(GPIO_FN_SDHI1CMD, NULL);
751 gpio_request(GPIO_FN_SDHI1CLK, NULL);
752 gpio_request(GPIO_FN_SDHI1D3, NULL);
753 gpio_request(GPIO_FN_SDHI1D2, NULL);
754 gpio_request(GPIO_FN_SDHI1D1, NULL);
755 gpio_request(GPIO_FN_SDHI1D0, NULL);
756
757 gpio_request(GPIO_PTB6, NULL);
758 gpio_request(GPIO_PTB7, NULL);
759 gpio_direction_output(GPIO_PTB6, 1);
760 gpio_direction_output(GPIO_PTB7, 1);
761
762 /* I/O buffer drive ability is high for SDHI1 */
763 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
764
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000765 /* enable I2C device */
766 i2c_register_board_info(1, i2c1_devices,
767 ARRAY_SIZE(i2c1_devices));
768
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000769 return platform_add_devices(ecovec_devices,
770 ARRAY_SIZE(ecovec_devices));
771}
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000772arch_initcall(arch_setup);
773
774static int __init devices_setup(void)
775{
Magnus Damm376abbb2009-10-26 10:44:37 +0000776 sh_eth_init(&sh_eth_plat);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000777 return 0;
778}
779device_initcall(devices_setup);
780
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000781static struct sh_machine_vector mv_ecovec __initmv = {
782 .mv_name = "R0P7724 (EcoVec)",
783};