blob: 5932f049e782c8efb50788d7651cee760415dcf7 [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>
Magnus Damm98779ad2009-11-27 04:36:58 +000023#include <linux/mfd/sh_mobile_sdhi.h>
Kuninori Morimotofa3ba512009-08-26 11:04:34 +000024#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto2153ad32009-08-26 11:04:36 +000025#include <media/sh_mobile_ceu.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000026#include <asm/heartbeat.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000027#include <asm/sh_eth.h>
Kuninori Morimotoe9103e72009-09-14 11:23:00 +000028#include <asm/sh_keysc.h>
Kuninori Morimotoa9918012009-09-14 11:23:16 +000029#include <asm/clock.h>
Magnus Dammeb0cd9e2009-10-30 04:23:59 +000030#include <asm/suspend.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000031#include <cpu/sh7724.h>
32
33/*
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000034 * Address Interface BusWidth
35 *-----------------------------------------
36 * 0x0000_0000 uboot 16bit
37 * 0x0004_0000 Linux romImage 16bit
38 * 0x0014_0000 MTD for Linux 16bit
39 * 0x0400_0000 Internal I/O 16/32bit
40 * 0x0800_0000 DRAM 32bit
41 * 0x1800_0000 MFI 16bit
Kuninori Morimoto4138b742009-08-19 12:08:33 +000042 */
43
Kuninori Morimoto9c472c42009-10-02 07:52:20 +000044/* SWITCH
45 *------------------------------
46 * DS2[1] = FlashROM write protect ON : write protect
47 * OFF : No write protect
48 * DS2[2] = RMII / TS, SCIF ON : RMII
49 * OFF : TS, SCIF3
50 * DS2[3] = Camera / Video ON : Camera
51 * OFF : NTSC/PAL (IN)
52 * DS2[5] = NTSC_OUT Clock ON : On board OSC
53 * OFF : SH7724 DV_CLK
54 * DS2[6-7] = MMC / SD ON-OFF : SD
55 * OFF-ON : MMC
56 */
57
Kuninori Morimoto4138b742009-08-19 12:08:33 +000058/* Heartbeat */
59static unsigned char led_pos[] = { 0, 1, 2, 3 };
60static struct heartbeat_data heartbeat_data = {
61 .regsize = 8,
62 .nr_bits = 4,
63 .bit_pos = led_pos,
64};
65
66static struct resource heartbeat_resources[] = {
67 [0] = {
68 .start = 0xA405012C, /* PTG */
69 .end = 0xA405012E - 1,
70 .flags = IORESOURCE_MEM,
71 },
72};
73
74static struct platform_device heartbeat_device = {
75 .name = "heartbeat",
76 .id = -1,
77 .dev = {
78 .platform_data = &heartbeat_data,
79 },
80 .num_resources = ARRAY_SIZE(heartbeat_resources),
81 .resource = heartbeat_resources,
82};
83
84/* MTD */
85static struct mtd_partition nor_flash_partitions[] = {
86 {
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000087 .name = "boot loader",
Kuninori Morimoto4138b742009-08-19 12:08:33 +000088 .offset = 0,
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000089 .size = (5 * 1024 * 1024),
Kuninori Morimotod5ce0102009-09-30 00:50:30 +000090 .mask_flags = MTD_WRITEABLE, /* force read-only */
Kuninori Morimoto4138b742009-08-19 12:08:33 +000091 }, {
Kuninori Morimoto4138b742009-08-19 12:08:33 +000092 .name = "free-area",
93 .offset = MTDPART_OFS_APPEND,
94 .size = MTDPART_SIZ_FULL,
95 },
96};
97
98static struct physmap_flash_data nor_flash_data = {
99 .width = 2,
100 .parts = nor_flash_partitions,
101 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
102};
103
104static struct resource nor_flash_resources[] = {
105 [0] = {
106 .name = "NOR Flash",
107 .start = 0x00000000,
108 .end = 0x03ffffff,
109 .flags = IORESOURCE_MEM,
110 }
111};
112
113static struct platform_device nor_flash_device = {
114 .name = "physmap-flash",
115 .resource = nor_flash_resources,
116 .num_resources = ARRAY_SIZE(nor_flash_resources),
117 .dev = {
118 .platform_data = &nor_flash_data,
119 },
120};
121
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000122/* SH Eth */
123#define SH_ETH_ADDR (0xA4600000)
124#define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
125#define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
126static struct resource sh_eth_resources[] = {
127 [0] = {
128 .start = SH_ETH_ADDR,
129 .end = SH_ETH_ADDR + 0x1FC,
130 .flags = IORESOURCE_MEM,
131 },
132 [1] = {
133 .start = 91,
134 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
135 },
136};
137
138struct sh_eth_plat_data sh_eth_plat = {
139 .phy = 0x1f, /* SMSC LAN8700 */
140 .edmac_endian = EDMAC_LITTLE_ENDIAN,
Kuninori Morimotoacf3cc22009-09-24 06:28:27 +0000141 .ether_link_active_low = 1
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000142};
143
144static struct platform_device sh_eth_device = {
145 .name = "sh-eth",
146 .id = 0,
147 .dev = {
148 .platform_data = &sh_eth_plat,
149 },
150 .num_resources = ARRAY_SIZE(sh_eth_resources),
151 .resource = sh_eth_resources,
Magnus Damm40e42312009-10-26 10:41:58 +0000152 .archdata = {
153 .hwblk_id = HWBLK_ETHER,
154 },
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000155};
156
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000157/* USB0 host */
158void usb0_port_power(int port, int power)
159{
160 gpio_set_value(GPIO_PTB4, power);
161}
162
163static struct r8a66597_platdata usb0_host_data = {
164 .on_chip = 1,
165 .port_power = usb0_port_power,
166};
167
168static struct resource usb0_host_resources[] = {
169 [0] = {
170 .start = 0xa4d80000,
171 .end = 0xa4d80124 - 1,
172 .flags = IORESOURCE_MEM,
173 },
174 [1] = {
175 .start = 65,
176 .end = 65,
177 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
178 },
179};
180
181static struct platform_device usb0_host_device = {
182 .name = "r8a66597_hcd",
183 .id = 0,
184 .dev = {
185 .dma_mask = NULL, /* not use dma */
186 .coherent_dma_mask = 0xffffffff,
187 .platform_data = &usb0_host_data,
188 },
189 .num_resources = ARRAY_SIZE(usb0_host_resources),
190 .resource = usb0_host_resources,
191};
192
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000193/* USB1 host/function */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000194void usb1_port_power(int port, int power)
195{
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000196 gpio_set_value(GPIO_PTB5, power);
197}
198
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000199static struct r8a66597_platdata usb1_common_data = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000200 .on_chip = 1,
201 .port_power = usb1_port_power,
202};
203
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000204static struct resource usb1_common_resources[] = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000205 [0] = {
206 .start = 0xa4d90000,
207 .end = 0xa4d90124 - 1,
208 .flags = IORESOURCE_MEM,
209 },
210 [1] = {
211 .start = 66,
212 .end = 66,
213 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
214 },
215};
216
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000217static struct platform_device usb1_common_device = {
218 /* .name will be added in arch_setup */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000219 .id = 1,
220 .dev = {
221 .dma_mask = NULL, /* not use dma */
222 .coherent_dma_mask = 0xffffffff,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000223 .platform_data = &usb1_common_data,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000224 },
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000225 .num_resources = ARRAY_SIZE(usb1_common_resources),
226 .resource = usb1_common_resources,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000227};
228
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000229/* LCDC */
230static struct sh_mobile_lcdc_info lcdc_info = {
231 .ch[0] = {
232 .interface_type = RGB18,
233 .chan = LCDC_CHAN_MAINLCD,
234 .bpp = 16,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000235 .lcd_cfg = {
236 .sync = 0, /* hsync and vsync are active low */
237 },
238 .lcd_size_cfg = { /* 7.0 inch */
239 .width = 152,
240 .height = 91,
241 },
242 .board_cfg = {
243 },
244 }
245};
246
247static struct resource lcdc_resources[] = {
248 [0] = {
249 .name = "LCDC",
250 .start = 0xfe940000,
Phil Edworthya6f15ad2009-09-15 12:00:30 +0000251 .end = 0xfe942fff,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000252 .flags = IORESOURCE_MEM,
253 },
254 [1] = {
255 .start = 106,
256 .flags = IORESOURCE_IRQ,
257 },
258};
259
260static struct platform_device lcdc_device = {
261 .name = "sh_mobile_lcdc_fb",
262 .num_resources = ARRAY_SIZE(lcdc_resources),
263 .resource = lcdc_resources,
264 .dev = {
265 .platform_data = &lcdc_info,
266 },
267 .archdata = {
268 .hwblk_id = HWBLK_LCDC,
269 },
270};
271
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000272/* CEU0 */
273static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
274 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
275};
276
277static struct resource ceu0_resources[] = {
278 [0] = {
279 .name = "CEU0",
280 .start = 0xfe910000,
281 .end = 0xfe91009f,
282 .flags = IORESOURCE_MEM,
283 },
284 [1] = {
285 .start = 52,
286 .flags = IORESOURCE_IRQ,
287 },
288 [2] = {
289 /* place holder for contiguous memory */
290 },
291};
292
293static struct platform_device ceu0_device = {
294 .name = "sh_mobile_ceu",
295 .id = 0, /* "ceu0" clock */
296 .num_resources = ARRAY_SIZE(ceu0_resources),
297 .resource = ceu0_resources,
298 .dev = {
299 .platform_data = &sh_mobile_ceu0_info,
300 },
301 .archdata = {
302 .hwblk_id = HWBLK_CEU0,
303 },
304};
305
306/* CEU1 */
307static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
308 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
309};
310
311static struct resource ceu1_resources[] = {
312 [0] = {
313 .name = "CEU1",
314 .start = 0xfe914000,
315 .end = 0xfe91409f,
316 .flags = IORESOURCE_MEM,
317 },
318 [1] = {
319 .start = 63,
320 .flags = IORESOURCE_IRQ,
321 },
322 [2] = {
323 /* place holder for contiguous memory */
324 },
325};
326
327static struct platform_device ceu1_device = {
328 .name = "sh_mobile_ceu",
329 .id = 1, /* "ceu1" clock */
330 .num_resources = ARRAY_SIZE(ceu1_resources),
331 .resource = ceu1_resources,
332 .dev = {
333 .platform_data = &sh_mobile_ceu1_info,
334 },
335 .archdata = {
336 .hwblk_id = HWBLK_CEU1,
337 },
338};
339
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000340/* I2C device */
341static struct i2c_board_info i2c1_devices[] = {
342 {
343 I2C_BOARD_INFO("r2025sd", 0x32),
344 },
345};
346
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000347/* KEYSC */
348static struct sh_keysc_info keysc_info = {
349 .mode = SH_KEYSC_MODE_1,
350 .scan_timing = 3,
351 .delay = 50,
352 .kycr2_delay = 100,
353 .keycodes = { KEY_1, 0, 0, 0, 0,
354 KEY_2, 0, 0, 0, 0,
355 KEY_3, 0, 0, 0, 0,
356 KEY_4, 0, 0, 0, 0,
357 KEY_5, 0, 0, 0, 0,
358 KEY_6, 0, 0, 0, 0, },
359};
360
361static struct resource keysc_resources[] = {
362 [0] = {
363 .name = "KEYSC",
364 .start = 0x044b0000,
365 .end = 0x044b000f,
366 .flags = IORESOURCE_MEM,
367 },
368 [1] = {
369 .start = 79,
370 .flags = IORESOURCE_IRQ,
371 },
372};
373
374static struct platform_device keysc_device = {
375 .name = "sh_keysc",
376 .id = 0, /* keysc0 clock */
377 .num_resources = ARRAY_SIZE(keysc_resources),
378 .resource = keysc_resources,
379 .dev = {
380 .platform_data = &keysc_info,
381 },
382 .archdata = {
383 .hwblk_id = HWBLK_KEYSC,
384 },
385};
386
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000387/* TouchScreen */
388#define IRQ0 32
389static int ts_get_pendown_state(void)
390{
391 int val = 0;
392 gpio_free(GPIO_FN_INTC_IRQ0);
393 gpio_request(GPIO_PTZ0, NULL);
394 gpio_direction_input(GPIO_PTZ0);
395
396 val = gpio_get_value(GPIO_PTZ0);
397
398 gpio_free(GPIO_PTZ0);
399 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
400
401 return val ? 0 : 1;
402}
403
404static int ts_init(void)
405{
406 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
407 return 0;
408}
409
410struct tsc2007_platform_data tsc2007_info = {
411 .model = 2007,
412 .x_plate_ohms = 180,
413 .get_pendown_state = ts_get_pendown_state,
414 .init_platform_hw = ts_init,
415};
416
417static struct i2c_board_info ts_i2c_clients = {
418 I2C_BOARD_INFO("tsc2007", 0x48),
419 .type = "tsc2007",
420 .platform_data = &tsc2007_info,
421 .irq = IRQ0,
422};
423
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000424/* SHDI0 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000425static void sdhi0_set_pwr(struct platform_device *pdev, int state)
426{
427 gpio_set_value(GPIO_PTB6, state);
428}
429
430static struct sh_mobile_sdhi_info sdhi0_info = {
431 .set_pwr = sdhi0_set_pwr,
432};
433
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000434static struct resource sdhi0_resources[] = {
435 [0] = {
436 .name = "SDHI0",
437 .start = 0x04ce0000,
438 .end = 0x04ce01ff,
439 .flags = IORESOURCE_MEM,
440 },
441 [1] = {
442 .start = 101,
443 .flags = IORESOURCE_IRQ,
444 },
445};
446
447static struct platform_device sdhi0_device = {
448 .name = "sh_mobile_sdhi",
449 .num_resources = ARRAY_SIZE(sdhi0_resources),
450 .resource = sdhi0_resources,
451 .id = 0,
Magnus Damm98779ad2009-11-27 04:36:58 +0000452 .dev = {
453 .platform_data = &sdhi0_info,
454 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000455 .archdata = {
456 .hwblk_id = HWBLK_SDHI0,
457 },
458};
459
460/* SHDI1 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000461static void sdhi1_set_pwr(struct platform_device *pdev, int state)
462{
463 gpio_set_value(GPIO_PTB7, state);
464}
465
466static struct sh_mobile_sdhi_info sdhi1_info = {
467 .set_pwr = sdhi1_set_pwr,
468};
469
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000470static struct resource sdhi1_resources[] = {
471 [0] = {
472 .name = "SDHI1",
473 .start = 0x04cf0000,
474 .end = 0x04cf01ff,
475 .flags = IORESOURCE_MEM,
476 },
477 [1] = {
478 .start = 24,
479 .flags = IORESOURCE_IRQ,
480 },
481};
482
483static struct platform_device sdhi1_device = {
484 .name = "sh_mobile_sdhi",
485 .num_resources = ARRAY_SIZE(sdhi1_resources),
486 .resource = sdhi1_resources,
487 .id = 1,
Magnus Damm98779ad2009-11-27 04:36:58 +0000488 .dev = {
489 .platform_data = &sdhi1_info,
490 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000491 .archdata = {
492 .hwblk_id = HWBLK_SDHI1,
493 },
494};
495
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000496static struct platform_device *ecovec_devices[] __initdata = {
497 &heartbeat_device,
498 &nor_flash_device,
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000499 &sh_eth_device,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000500 &usb0_host_device,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000501 &usb1_common_device,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000502 &lcdc_device,
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000503 &ceu0_device,
504 &ceu1_device,
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000505 &keysc_device,
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000506 &sdhi0_device,
507 &sdhi1_device,
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000508};
509
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000510#define EEPROM_ADDR 0x50
511static u8 mac_read(struct i2c_adapter *a, u8 command)
512{
513 struct i2c_msg msg[2];
514 u8 buf;
515 int ret;
516
517 msg[0].addr = EEPROM_ADDR;
518 msg[0].flags = 0;
519 msg[0].len = 1;
520 msg[0].buf = &command;
521
522 msg[1].addr = EEPROM_ADDR;
523 msg[1].flags = I2C_M_RD;
524 msg[1].len = 1;
525 msg[1].buf = &buf;
526
527 ret = i2c_transfer(a, msg, 2);
528 if (ret < 0) {
529 printk(KERN_ERR "error %d\n", ret);
530 buf = 0xff;
531 }
532
533 return buf;
534}
535
Magnus Damm376abbb2009-10-26 10:44:37 +0000536static void __init sh_eth_init(struct sh_eth_plat_data *pd)
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000537{
538 struct i2c_adapter *a = i2c_get_adapter(1);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000539 int i;
540
541 if (!a) {
542 pr_err("can not get I2C 1\n");
543 return;
544 }
545
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000546 /* read MAC address frome EEPROM */
Magnus Damm376abbb2009-10-26 10:44:37 +0000547 for (i = 0; i < sizeof(pd->mac_addr); i++) {
548 pd->mac_addr[i] = mac_read(a, 0x10 + i);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000549 msleep(10);
550 }
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000551}
552
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000553#define PORT_HIZA 0xA4050158
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000554#define IODRIVEA 0xA405018A
Magnus Dammeb0cd9e2009-10-30 04:23:59 +0000555
556extern char ecovec24_sdram_enter_start;
557extern char ecovec24_sdram_enter_end;
558extern char ecovec24_sdram_leave_start;
559extern char ecovec24_sdram_leave_end;
560
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000561static int __init arch_setup(void)
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000562{
Magnus Dammeb0cd9e2009-10-30 04:23:59 +0000563 /* register board specific self-refresh code */
564 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
565 &ecovec24_sdram_enter_start,
566 &ecovec24_sdram_enter_end,
567 &ecovec24_sdram_leave_start,
568 &ecovec24_sdram_leave_end);
569
Magnus Dammf78bab32009-10-07 09:00:06 +0000570 /* enable STATUS0, STATUS2 and PDSTATUS */
571 gpio_request(GPIO_FN_STATUS0, NULL);
572 gpio_request(GPIO_FN_STATUS2, NULL);
573 gpio_request(GPIO_FN_PDSTATUS, NULL);
574
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000575 /* enable SCIFA0 */
576 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
577 gpio_request(GPIO_FN_SCIF0_RXD, NULL);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000578
579 /* enable debug LED */
580 gpio_request(GPIO_PTG0, NULL);
581 gpio_request(GPIO_PTG1, NULL);
582 gpio_request(GPIO_PTG2, NULL);
583 gpio_request(GPIO_PTG3, NULL);
Kuninori Morimotob7056bc2009-08-26 11:04:22 +0000584 gpio_direction_output(GPIO_PTG0, 0);
585 gpio_direction_output(GPIO_PTG1, 0);
586 gpio_direction_output(GPIO_PTG2, 0);
587 gpio_direction_output(GPIO_PTG3, 0);
Kuninori Morimoto643e9d12009-09-10 01:40:00 +0000588 ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000589
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000590 /* enable SH-Eth */
591 gpio_request(GPIO_PTA1, NULL);
592 gpio_direction_output(GPIO_PTA1, 1);
593 mdelay(20);
594
595 gpio_request(GPIO_FN_RMII_RXD0, NULL);
596 gpio_request(GPIO_FN_RMII_RXD1, NULL);
597 gpio_request(GPIO_FN_RMII_TXD0, NULL);
598 gpio_request(GPIO_FN_RMII_TXD1, NULL);
599 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
600 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
601 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
602 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
603 gpio_request(GPIO_FN_MDIO, NULL);
604 gpio_request(GPIO_FN_MDC, NULL);
605 gpio_request(GPIO_FN_LNKSTA, NULL);
606
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000607 /* enable USB */
Kuninori Morimotobe4ebf92009-09-10 01:39:55 +0000608 ctrl_outw(0x0000, 0xA4D80000);
Kuninori Morimoto147df2d2009-09-14 11:22:31 +0000609 ctrl_outw(0x0000, 0xA4D90000);
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000610 gpio_request(GPIO_PTB3, NULL);
611 gpio_request(GPIO_PTB4, NULL);
612 gpio_request(GPIO_PTB5, NULL);
613 gpio_direction_input(GPIO_PTB3);
614 gpio_direction_output(GPIO_PTB4, 0);
615 gpio_direction_output(GPIO_PTB5, 0);
616 ctrl_outw(0x0600, 0xa40501d4);
617 ctrl_outw(0x0600, 0xa4050192);
618
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000619 if (gpio_get_value(GPIO_PTB3)) {
620 printk(KERN_INFO "USB1 function is selected\n");
621 usb1_common_device.name = "r8a66597_udc";
622 } else {
623 printk(KERN_INFO "USB1 host is selected\n");
624 usb1_common_device.name = "r8a66597_hcd";
625 }
626
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000627 /* enable LCDC */
628 gpio_request(GPIO_FN_LCDD23, NULL);
629 gpio_request(GPIO_FN_LCDD22, NULL);
630 gpio_request(GPIO_FN_LCDD21, NULL);
631 gpio_request(GPIO_FN_LCDD20, NULL);
632 gpio_request(GPIO_FN_LCDD19, NULL);
633 gpio_request(GPIO_FN_LCDD18, NULL);
634 gpio_request(GPIO_FN_LCDD17, NULL);
635 gpio_request(GPIO_FN_LCDD16, NULL);
636 gpio_request(GPIO_FN_LCDD15, NULL);
637 gpio_request(GPIO_FN_LCDD14, NULL);
638 gpio_request(GPIO_FN_LCDD13, NULL);
639 gpio_request(GPIO_FN_LCDD12, NULL);
640 gpio_request(GPIO_FN_LCDD11, NULL);
641 gpio_request(GPIO_FN_LCDD10, NULL);
642 gpio_request(GPIO_FN_LCDD9, NULL);
643 gpio_request(GPIO_FN_LCDD8, NULL);
644 gpio_request(GPIO_FN_LCDD7, NULL);
645 gpio_request(GPIO_FN_LCDD6, NULL);
646 gpio_request(GPIO_FN_LCDD5, NULL);
647 gpio_request(GPIO_FN_LCDD4, NULL);
648 gpio_request(GPIO_FN_LCDD3, NULL);
649 gpio_request(GPIO_FN_LCDD2, NULL);
650 gpio_request(GPIO_FN_LCDD1, NULL);
651 gpio_request(GPIO_FN_LCDD0, NULL);
652 gpio_request(GPIO_FN_LCDDISP, NULL);
653 gpio_request(GPIO_FN_LCDHSYN, NULL);
654 gpio_request(GPIO_FN_LCDDCK, NULL);
655 gpio_request(GPIO_FN_LCDVSYN, NULL);
656 gpio_request(GPIO_FN_LCDDON, NULL);
657 gpio_request(GPIO_FN_LCDLCLK, NULL);
658 ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
659
660 gpio_request(GPIO_PTE6, NULL);
661 gpio_request(GPIO_PTU1, NULL);
662 gpio_request(GPIO_PTR1, NULL);
663 gpio_request(GPIO_PTA2, NULL);
664 gpio_direction_input(GPIO_PTE6);
665 gpio_direction_output(GPIO_PTU1, 0);
666 gpio_direction_output(GPIO_PTR1, 0);
667 gpio_direction_output(GPIO_PTA2, 0);
668
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000669 /* I/O buffer drive ability is low */
670 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0040 , IODRIVEA);
671
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000672 if (gpio_get_value(GPIO_PTE6)) {
673 /* DVI */
674 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000675 lcdc_info.ch[0].clock_divider = 1,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000676 lcdc_info.ch[0].lcd_cfg.name = "DVI";
677 lcdc_info.ch[0].lcd_cfg.xres = 1280;
678 lcdc_info.ch[0].lcd_cfg.yres = 720;
679 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
680 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
681 lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
682 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
683 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
684 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
685
686 gpio_set_value(GPIO_PTA2, 1);
687 gpio_set_value(GPIO_PTU1, 1);
688 } else {
689 /* Panel */
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000690
691 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
692 lcdc_info.ch[0].clock_divider = 2,
693 lcdc_info.ch[0].lcd_cfg.name = "Panel";
694 lcdc_info.ch[0].lcd_cfg.xres = 800;
695 lcdc_info.ch[0].lcd_cfg.yres = 480;
696 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
697 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
698 lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
699 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
700 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
701 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
702
703 gpio_set_value(GPIO_PTR1, 1);
704
705 /* FIXME
706 *
707 * LCDDON control is needed for Panel,
708 * but current sh_mobile_lcdc driver doesn't control it.
709 * It is temporary correspondence
710 */
711 gpio_request(GPIO_PTF4, NULL);
712 gpio_direction_output(GPIO_PTF4, 1);
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000713
714 /* enable TouchScreen */
715 i2c_register_board_info(0, &ts_i2c_clients, 1);
716 set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000717 }
718
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000719 /* enable CEU0 */
720 gpio_request(GPIO_FN_VIO0_D15, NULL);
721 gpio_request(GPIO_FN_VIO0_D14, NULL);
722 gpio_request(GPIO_FN_VIO0_D13, NULL);
723 gpio_request(GPIO_FN_VIO0_D12, NULL);
724 gpio_request(GPIO_FN_VIO0_D11, NULL);
725 gpio_request(GPIO_FN_VIO0_D10, NULL);
726 gpio_request(GPIO_FN_VIO0_D9, NULL);
727 gpio_request(GPIO_FN_VIO0_D8, NULL);
728 gpio_request(GPIO_FN_VIO0_D7, NULL);
729 gpio_request(GPIO_FN_VIO0_D6, NULL);
730 gpio_request(GPIO_FN_VIO0_D5, NULL);
731 gpio_request(GPIO_FN_VIO0_D4, NULL);
732 gpio_request(GPIO_FN_VIO0_D3, NULL);
733 gpio_request(GPIO_FN_VIO0_D2, NULL);
734 gpio_request(GPIO_FN_VIO0_D1, NULL);
735 gpio_request(GPIO_FN_VIO0_D0, NULL);
736 gpio_request(GPIO_FN_VIO0_VD, NULL);
737 gpio_request(GPIO_FN_VIO0_CLK, NULL);
738 gpio_request(GPIO_FN_VIO0_FLD, NULL);
739 gpio_request(GPIO_FN_VIO0_HD, NULL);
740 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
741
742 /* enable CEU1 */
743 gpio_request(GPIO_FN_VIO1_D7, NULL);
744 gpio_request(GPIO_FN_VIO1_D6, NULL);
745 gpio_request(GPIO_FN_VIO1_D5, NULL);
746 gpio_request(GPIO_FN_VIO1_D4, NULL);
747 gpio_request(GPIO_FN_VIO1_D3, NULL);
748 gpio_request(GPIO_FN_VIO1_D2, NULL);
749 gpio_request(GPIO_FN_VIO1_D1, NULL);
750 gpio_request(GPIO_FN_VIO1_D0, NULL);
751 gpio_request(GPIO_FN_VIO1_FLD, NULL);
752 gpio_request(GPIO_FN_VIO1_HD, NULL);
753 gpio_request(GPIO_FN_VIO1_VD, NULL);
754 gpio_request(GPIO_FN_VIO1_CLK, NULL);
755 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
756
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000757 /* enable KEYSC */
758 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
759 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
760 gpio_request(GPIO_FN_KEYOUT3, NULL);
761 gpio_request(GPIO_FN_KEYOUT2, NULL);
762 gpio_request(GPIO_FN_KEYOUT1, NULL);
763 gpio_request(GPIO_FN_KEYOUT0, NULL);
764 gpio_request(GPIO_FN_KEYIN0, NULL);
765
Kuninori Morimoto064a16d2009-09-16 11:34:34 +0000766 /* enable user debug switch */
767 gpio_request(GPIO_PTR0, NULL);
768 gpio_request(GPIO_PTR4, NULL);
769 gpio_request(GPIO_PTR5, NULL);
770 gpio_request(GPIO_PTR6, NULL);
771 gpio_direction_input(GPIO_PTR0);
772 gpio_direction_input(GPIO_PTR4);
773 gpio_direction_input(GPIO_PTR5);
774 gpio_direction_input(GPIO_PTR6);
775
Magnus Damm98779ad2009-11-27 04:36:58 +0000776 /* enable SDHI0 (needs DS2.4 set to ON) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000777 gpio_request(GPIO_FN_SDHI0CD, NULL);
778 gpio_request(GPIO_FN_SDHI0WP, NULL);
779 gpio_request(GPIO_FN_SDHI0CMD, NULL);
780 gpio_request(GPIO_FN_SDHI0CLK, NULL);
781 gpio_request(GPIO_FN_SDHI0D3, NULL);
782 gpio_request(GPIO_FN_SDHI0D2, NULL);
783 gpio_request(GPIO_FN_SDHI0D1, NULL);
784 gpio_request(GPIO_FN_SDHI0D0, NULL);
Magnus Damm98779ad2009-11-27 04:36:58 +0000785 gpio_request(GPIO_PTB6, NULL);
786 gpio_direction_output(GPIO_PTB6, 0);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000787
Magnus Damm98779ad2009-11-27 04:36:58 +0000788 /* enable SDHI1 (needs DS2.6,7 set to ON,OFF) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000789 gpio_request(GPIO_FN_SDHI1CD, NULL);
790 gpio_request(GPIO_FN_SDHI1WP, NULL);
791 gpio_request(GPIO_FN_SDHI1CMD, NULL);
792 gpio_request(GPIO_FN_SDHI1CLK, NULL);
793 gpio_request(GPIO_FN_SDHI1D3, NULL);
794 gpio_request(GPIO_FN_SDHI1D2, NULL);
795 gpio_request(GPIO_FN_SDHI1D1, NULL);
796 gpio_request(GPIO_FN_SDHI1D0, NULL);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000797 gpio_request(GPIO_PTB7, NULL);
Magnus Damm98779ad2009-11-27 04:36:58 +0000798 gpio_direction_output(GPIO_PTB7, 0);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000799
800 /* I/O buffer drive ability is high for SDHI1 */
801 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
802
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000803 /* enable I2C device */
804 i2c_register_board_info(1, i2c1_devices,
805 ARRAY_SIZE(i2c1_devices));
806
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000807 return platform_add_devices(ecovec_devices,
808 ARRAY_SIZE(ecovec_devices));
809}
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000810arch_initcall(arch_setup);
811
812static int __init devices_setup(void)
813{
Magnus Damm376abbb2009-10-26 10:44:37 +0000814 sh_eth_init(&sh_eth_plat);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000815 return 0;
816}
817device_initcall(devices_setup);
818
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000819static struct sh_machine_vector mv_ecovec __initmv = {
820 .mv_name = "R0P7724 (EcoVec)",
821};