]> git.karo-electronics.de Git - linux-beck.git/blob - arch/sh/boards/mach-ecovec24/setup.c
sh: mach-ecovec24: Add mt9t112 camera support
[linux-beck.git] / arch / sh / boards / mach-ecovec24 / setup.c
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>
17 #include <linux/io.h>
18 #include <linux/delay.h>
19 #include <linux/usb/r8a66597.h>
20 #include <linux/i2c.h>
21 #include <linux/i2c/tsc2007.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/sh_msiof.h>
24 #include <linux/spi/mmc_spi.h>
25 #include <linux/mmc/host.h>
26 #include <linux/input.h>
27 #include <linux/input/sh_keysc.h>
28 #include <linux/mfd/sh_mobile_sdhi.h>
29 #include <video/sh_mobile_lcdc.h>
30 #include <media/sh_mobile_ceu.h>
31 #include <media/tw9910.h>
32 #include <media/mt9t112.h>
33 #include <asm/heartbeat.h>
34 #include <asm/sh_eth.h>
35 #include <asm/clock.h>
36 #include <asm/suspend.h>
37 #include <cpu/sh7724.h>
38
39 /*
40  *  Address      Interface        BusWidth
41  *-----------------------------------------
42  *  0x0000_0000  uboot            16bit
43  *  0x0004_0000  Linux romImage   16bit
44  *  0x0014_0000  MTD for Linux    16bit
45  *  0x0400_0000  Internal I/O     16/32bit
46  *  0x0800_0000  DRAM             32bit
47  *  0x1800_0000  MFI              16bit
48  */
49
50 /* SWITCH
51  *------------------------------
52  * DS2[1] = FlashROM write protect  ON     : write protect
53  *                                  OFF    : No write protect
54  * DS2[2] = RMII / TS, SCIF         ON     : RMII
55  *                                  OFF    : TS, SCIF3
56  * DS2[3] = Camera / Video          ON     : Camera
57  *                                  OFF    : NTSC/PAL (IN)
58  * DS2[5] = NTSC_OUT Clock          ON     : On board OSC
59  *                                  OFF    : SH7724 DV_CLK
60  * DS2[6-7] = MMC / SD              ON-OFF : SD
61  *                                  OFF-ON : MMC
62  */
63
64 /* Heartbeat */
65 static unsigned char led_pos[] = { 0, 1, 2, 3 };
66 static struct heartbeat_data heartbeat_data = {
67         .regsize = 8,
68         .nr_bits = 4,
69         .bit_pos = led_pos,
70 };
71
72 static struct resource heartbeat_resources[] = {
73         [0] = {
74                 .start  = 0xA405012C, /* PTG */
75                 .end    = 0xA405012E - 1,
76                 .flags  = IORESOURCE_MEM,
77         },
78 };
79
80 static struct platform_device heartbeat_device = {
81         .name           = "heartbeat",
82         .id             = -1,
83         .dev = {
84                 .platform_data = &heartbeat_data,
85         },
86         .num_resources  = ARRAY_SIZE(heartbeat_resources),
87         .resource       = heartbeat_resources,
88 };
89
90 /* MTD */
91 static struct mtd_partition nor_flash_partitions[] = {
92         {
93                 .name = "boot loader",
94                 .offset = 0,
95                 .size = (5 * 1024 * 1024),
96                 .mask_flags = MTD_WRITEABLE,  /* force read-only */
97         }, {
98                 .name = "free-area",
99                 .offset = MTDPART_OFS_APPEND,
100                 .size = MTDPART_SIZ_FULL,
101         },
102 };
103
104 static struct physmap_flash_data nor_flash_data = {
105         .width          = 2,
106         .parts          = nor_flash_partitions,
107         .nr_parts       = ARRAY_SIZE(nor_flash_partitions),
108 };
109
110 static struct resource nor_flash_resources[] = {
111         [0] = {
112                 .name   = "NOR Flash",
113                 .start  = 0x00000000,
114                 .end    = 0x03ffffff,
115                 .flags  = IORESOURCE_MEM,
116         }
117 };
118
119 static struct platform_device nor_flash_device = {
120         .name           = "physmap-flash",
121         .resource       = nor_flash_resources,
122         .num_resources  = ARRAY_SIZE(nor_flash_resources),
123         .dev            = {
124                 .platform_data = &nor_flash_data,
125         },
126 };
127
128 /* SH Eth */
129 #define SH_ETH_ADDR     (0xA4600000)
130 #define SH_ETH_MAHR     (SH_ETH_ADDR + 0x1C0)
131 #define SH_ETH_MALR     (SH_ETH_ADDR + 0x1C8)
132 static struct resource sh_eth_resources[] = {
133         [0] = {
134                 .start = SH_ETH_ADDR,
135                 .end   = SH_ETH_ADDR + 0x1FC,
136                 .flags = IORESOURCE_MEM,
137         },
138         [1] = {
139                 .start = 91,
140                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
141         },
142 };
143
144 struct sh_eth_plat_data sh_eth_plat = {
145         .phy = 0x1f, /* SMSC LAN8700 */
146         .edmac_endian = EDMAC_LITTLE_ENDIAN,
147         .ether_link_active_low = 1
148 };
149
150 static struct platform_device sh_eth_device = {
151         .name = "sh-eth",
152         .id     = 0,
153         .dev = {
154                 .platform_data = &sh_eth_plat,
155         },
156         .num_resources = ARRAY_SIZE(sh_eth_resources),
157         .resource = sh_eth_resources,
158         .archdata = {
159                 .hwblk_id = HWBLK_ETHER,
160         },
161 };
162
163 /* USB0 host */
164 void usb0_port_power(int port, int power)
165 {
166         gpio_set_value(GPIO_PTB4, power);
167 }
168
169 static struct r8a66597_platdata usb0_host_data = {
170         .on_chip = 1,
171         .port_power = usb0_port_power,
172 };
173
174 static struct resource usb0_host_resources[] = {
175         [0] = {
176                 .start  = 0xa4d80000,
177                 .end    = 0xa4d80124 - 1,
178                 .flags  = IORESOURCE_MEM,
179         },
180         [1] = {
181                 .start  = 65,
182                 .end    = 65,
183                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
184         },
185 };
186
187 static struct platform_device usb0_host_device = {
188         .name           = "r8a66597_hcd",
189         .id             = 0,
190         .dev = {
191                 .dma_mask               = NULL,         /*  not use dma */
192                 .coherent_dma_mask      = 0xffffffff,
193                 .platform_data          = &usb0_host_data,
194         },
195         .num_resources  = ARRAY_SIZE(usb0_host_resources),
196         .resource       = usb0_host_resources,
197 };
198
199 /* USB1 host/function */
200 void usb1_port_power(int port, int power)
201 {
202         gpio_set_value(GPIO_PTB5, power);
203 }
204
205 static struct r8a66597_platdata usb1_common_data = {
206         .on_chip = 1,
207         .port_power = usb1_port_power,
208 };
209
210 static struct resource usb1_common_resources[] = {
211         [0] = {
212                 .start  = 0xa4d90000,
213                 .end    = 0xa4d90124 - 1,
214                 .flags  = IORESOURCE_MEM,
215         },
216         [1] = {
217                 .start  = 66,
218                 .end    = 66,
219                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
220         },
221 };
222
223 static struct platform_device usb1_common_device = {
224         /* .name will be added in arch_setup */
225         .id             = 1,
226         .dev = {
227                 .dma_mask               = NULL,         /*  not use dma */
228                 .coherent_dma_mask      = 0xffffffff,
229                 .platform_data          = &usb1_common_data,
230         },
231         .num_resources  = ARRAY_SIZE(usb1_common_resources),
232         .resource       = usb1_common_resources,
233 };
234
235 /* LCDC */
236 static struct sh_mobile_lcdc_info lcdc_info = {
237         .ch[0] = {
238                 .interface_type = RGB18,
239                 .chan = LCDC_CHAN_MAINLCD,
240                 .bpp = 16,
241                 .lcd_cfg = {
242                         .sync = 0, /* hsync and vsync are active low */
243                 },
244                 .lcd_size_cfg = { /* 7.0 inch */
245                         .width = 152,
246                         .height = 91,
247                 },
248                 .board_cfg = {
249                 },
250         }
251 };
252
253 static struct resource lcdc_resources[] = {
254         [0] = {
255                 .name   = "LCDC",
256                 .start  = 0xfe940000,
257                 .end    = 0xfe942fff,
258                 .flags  = IORESOURCE_MEM,
259         },
260         [1] = {
261                 .start  = 106,
262                 .flags  = IORESOURCE_IRQ,
263         },
264 };
265
266 static struct platform_device lcdc_device = {
267         .name           = "sh_mobile_lcdc_fb",
268         .num_resources  = ARRAY_SIZE(lcdc_resources),
269         .resource       = lcdc_resources,
270         .dev            = {
271                 .platform_data  = &lcdc_info,
272         },
273         .archdata = {
274                 .hwblk_id = HWBLK_LCDC,
275         },
276 };
277
278 /* CEU0 */
279 static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
280         .flags = SH_CEU_FLAG_USE_8BIT_BUS,
281 };
282
283 static struct resource ceu0_resources[] = {
284         [0] = {
285                 .name   = "CEU0",
286                 .start  = 0xfe910000,
287                 .end    = 0xfe91009f,
288                 .flags  = IORESOURCE_MEM,
289         },
290         [1] = {
291                 .start  = 52,
292                 .flags  = IORESOURCE_IRQ,
293         },
294         [2] = {
295                 /* place holder for contiguous memory */
296         },
297 };
298
299 static struct platform_device ceu0_device = {
300         .name           = "sh_mobile_ceu",
301         .id             = 0, /* "ceu0" clock */
302         .num_resources  = ARRAY_SIZE(ceu0_resources),
303         .resource       = ceu0_resources,
304         .dev    = {
305                 .platform_data  = &sh_mobile_ceu0_info,
306         },
307         .archdata = {
308                 .hwblk_id = HWBLK_CEU0,
309         },
310 };
311
312 /* CEU1 */
313 static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
314         .flags = SH_CEU_FLAG_USE_8BIT_BUS,
315 };
316
317 static struct resource ceu1_resources[] = {
318         [0] = {
319                 .name   = "CEU1",
320                 .start  = 0xfe914000,
321                 .end    = 0xfe91409f,
322                 .flags  = IORESOURCE_MEM,
323         },
324         [1] = {
325                 .start  = 63,
326                 .flags  = IORESOURCE_IRQ,
327         },
328         [2] = {
329                 /* place holder for contiguous memory */
330         },
331 };
332
333 static struct platform_device ceu1_device = {
334         .name           = "sh_mobile_ceu",
335         .id             = 1, /* "ceu1" clock */
336         .num_resources  = ARRAY_SIZE(ceu1_resources),
337         .resource       = ceu1_resources,
338         .dev    = {
339                 .platform_data  = &sh_mobile_ceu1_info,
340         },
341         .archdata = {
342                 .hwblk_id = HWBLK_CEU1,
343         },
344 };
345
346 /* I2C device */
347 static struct i2c_board_info i2c1_devices[] = {
348         {
349                 I2C_BOARD_INFO("r2025sd", 0x32),
350         },
351 };
352
353 /* KEYSC */
354 static struct sh_keysc_info keysc_info = {
355         .mode           = SH_KEYSC_MODE_1,
356         .scan_timing    = 3,
357         .delay          = 50,
358         .kycr2_delay    = 100,
359         .keycodes       = { KEY_1, 0, 0, 0, 0,
360                             KEY_2, 0, 0, 0, 0,
361                             KEY_3, 0, 0, 0, 0,
362                             KEY_4, 0, 0, 0, 0,
363                             KEY_5, 0, 0, 0, 0,
364                             KEY_6, 0, 0, 0, 0, },
365 };
366
367 static struct resource keysc_resources[] = {
368         [0] = {
369                 .name   = "KEYSC",
370                 .start  = 0x044b0000,
371                 .end    = 0x044b000f,
372                 .flags  = IORESOURCE_MEM,
373         },
374         [1] = {
375                 .start  = 79,
376                 .flags  = IORESOURCE_IRQ,
377         },
378 };
379
380 static struct platform_device keysc_device = {
381         .name           = "sh_keysc",
382         .id             = 0, /* keysc0 clock */
383         .num_resources  = ARRAY_SIZE(keysc_resources),
384         .resource       = keysc_resources,
385         .dev    = {
386                 .platform_data  = &keysc_info,
387         },
388         .archdata = {
389                 .hwblk_id = HWBLK_KEYSC,
390         },
391 };
392
393 /* TouchScreen */
394 #define IRQ0 32
395 static int ts_get_pendown_state(void)
396 {
397         int val = 0;
398         gpio_free(GPIO_FN_INTC_IRQ0);
399         gpio_request(GPIO_PTZ0, NULL);
400         gpio_direction_input(GPIO_PTZ0);
401
402         val = gpio_get_value(GPIO_PTZ0);
403
404         gpio_free(GPIO_PTZ0);
405         gpio_request(GPIO_FN_INTC_IRQ0, NULL);
406
407         return val ? 0 : 1;
408 }
409
410 static int ts_init(void)
411 {
412         gpio_request(GPIO_FN_INTC_IRQ0, NULL);
413         return 0;
414 }
415
416 struct tsc2007_platform_data tsc2007_info = {
417         .model                  = 2007,
418         .x_plate_ohms           = 180,
419         .get_pendown_state      = ts_get_pendown_state,
420         .init_platform_hw       = ts_init,
421 };
422
423 static struct i2c_board_info ts_i2c_clients = {
424         I2C_BOARD_INFO("tsc2007", 0x48),
425         .type           = "tsc2007",
426         .platform_data  = &tsc2007_info,
427         .irq            = IRQ0,
428 };
429
430 #ifdef CONFIG_MFD_SH_MOBILE_SDHI
431 /* SHDI0 */
432 static void sdhi0_set_pwr(struct platform_device *pdev, int state)
433 {
434         gpio_set_value(GPIO_PTB6, state);
435 }
436
437 static struct sh_mobile_sdhi_info sdhi0_info = {
438         .set_pwr = sdhi0_set_pwr,
439 };
440
441 static struct resource sdhi0_resources[] = {
442         [0] = {
443                 .name   = "SDHI0",
444                 .start  = 0x04ce0000,
445                 .end    = 0x04ce01ff,
446                 .flags  = IORESOURCE_MEM,
447         },
448         [1] = {
449                 .start  = 101,
450                 .flags  = IORESOURCE_IRQ,
451         },
452 };
453
454 static struct platform_device sdhi0_device = {
455         .name           = "sh_mobile_sdhi",
456         .num_resources  = ARRAY_SIZE(sdhi0_resources),
457         .resource       = sdhi0_resources,
458         .id             = 0,
459         .dev    = {
460                 .platform_data  = &sdhi0_info,
461         },
462         .archdata = {
463                 .hwblk_id = HWBLK_SDHI0,
464         },
465 };
466
467 /* SHDI1 */
468 static void sdhi1_set_pwr(struct platform_device *pdev, int state)
469 {
470         gpio_set_value(GPIO_PTB7, state);
471 }
472
473 static struct sh_mobile_sdhi_info sdhi1_info = {
474         .set_pwr = sdhi1_set_pwr,
475 };
476
477 static struct resource sdhi1_resources[] = {
478         [0] = {
479                 .name   = "SDHI1",
480                 .start  = 0x04cf0000,
481                 .end    = 0x04cf01ff,
482                 .flags  = IORESOURCE_MEM,
483         },
484         [1] = {
485                 .start  = 24,
486                 .flags  = IORESOURCE_IRQ,
487         },
488 };
489
490 static struct platform_device sdhi1_device = {
491         .name           = "sh_mobile_sdhi",
492         .num_resources  = ARRAY_SIZE(sdhi1_resources),
493         .resource       = sdhi1_resources,
494         .id             = 1,
495         .dev    = {
496                 .platform_data  = &sdhi1_info,
497         },
498         .archdata = {
499                 .hwblk_id = HWBLK_SDHI1,
500         },
501 };
502
503 #else
504
505 static int mmc_spi_get_ro(struct device *dev)
506 {
507         return gpio_get_value(GPIO_PTY6);
508 }
509
510 static int mmc_spi_get_cd(struct device *dev)
511 {
512         return !gpio_get_value(GPIO_PTY7);
513 }
514
515 static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
516 {
517         gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
518 }
519
520 static struct mmc_spi_platform_data mmc_spi_info = {
521         .get_ro = mmc_spi_get_ro,
522         .get_cd = mmc_spi_get_cd,
523         .caps = MMC_CAP_NEEDS_POLL,
524         .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
525         .setpower = mmc_spi_setpower,
526 };
527
528 static struct spi_board_info spi_bus[] = {
529         {
530                 .modalias       = "mmc_spi",
531                 .platform_data  = &mmc_spi_info,
532                 .max_speed_hz   = 5000000,
533                 .mode           = SPI_MODE_0,
534                 .controller_data = (void *) GPIO_PTM4,
535         },
536 };
537
538 static struct sh_msiof_spi_info msiof0_data = {
539         .num_chipselect = 1,
540 };
541
542 static struct resource msiof0_resources[] = {
543         [0] = {
544                 .name   = "MSIOF0",
545                 .start  = 0xa4c40000,
546                 .end    = 0xa4c40063,
547                 .flags  = IORESOURCE_MEM,
548         },
549         [1] = {
550                 .start  = 84,
551                 .flags  = IORESOURCE_IRQ,
552         },
553 };
554
555 static struct platform_device msiof0_device = {
556         .name           = "spi_sh_msiof",
557         .id             = 0, /* MSIOF0 */
558         .dev = {
559                 .platform_data = &msiof0_data,
560         },
561         .num_resources  = ARRAY_SIZE(msiof0_resources),
562         .resource       = msiof0_resources,
563         .archdata = {
564                 .hwblk_id = HWBLK_MSIOF0,
565         },
566 };
567
568 #endif
569
570 /* I2C Video/Camera */
571 static struct i2c_board_info i2c_camera[] = {
572         {
573                 I2C_BOARD_INFO("tw9910", 0x45),
574         },
575         {
576                 /* 1st camera */
577                 I2C_BOARD_INFO("mt9t112", 0x3c),
578         },
579         {
580                 /* 2nd camera */
581                 I2C_BOARD_INFO("mt9t112", 0x3c),
582         },
583 };
584
585 /* tw9910 */
586 static int tw9910_power(struct device *dev, int mode)
587 {
588         int val = mode ? 0 : 1;
589
590         gpio_set_value(GPIO_PTU2, val);
591         if (mode)
592                 mdelay(100);
593
594         return 0;
595 }
596
597 static struct tw9910_video_info tw9910_info = {
598         .buswidth       = SOCAM_DATAWIDTH_8,
599         .mpout          = TW9910_MPO_FIELD,
600 };
601
602 static struct soc_camera_link tw9910_link = {
603         .i2c_adapter_id = 0,
604         .bus_id         = 1,
605         .power          = tw9910_power,
606         .board_info     = &i2c_camera[0],
607         .module_name    = "tw9910",
608         .priv           = &tw9910_info,
609 };
610
611 /* mt9t112 */
612 static int mt9t112_power1(struct device *dev, int mode)
613 {
614         gpio_set_value(GPIO_PTA3, mode);
615         if (mode)
616                 mdelay(100);
617
618         return 0;
619 }
620
621 static struct mt9t112_camera_info mt9t112_info1 = {
622         .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
623         .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
624 };
625
626 static struct soc_camera_link mt9t112_link1 = {
627         .i2c_adapter_id = 0,
628         .power          = mt9t112_power1,
629         .bus_id         = 0,
630         .board_info     = &i2c_camera[1],
631         .module_name    = "mt9t112",
632         .priv           = &mt9t112_info1,
633 };
634
635 static int mt9t112_power2(struct device *dev, int mode)
636 {
637         gpio_set_value(GPIO_PTA4, mode);
638         if (mode)
639                 mdelay(100);
640
641         return 0;
642 }
643
644 static struct mt9t112_camera_info mt9t112_info2 = {
645         .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
646         .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
647 };
648
649 static struct soc_camera_link mt9t112_link2 = {
650         .i2c_adapter_id = 1,
651         .power          = mt9t112_power2,
652         .bus_id         = 1,
653         .board_info     = &i2c_camera[2],
654         .module_name    = "mt9t112",
655         .priv           = &mt9t112_info2,
656 };
657
658 static struct platform_device camera_devices[] = {
659         {
660                 .name   = "soc-camera-pdrv",
661                 .id     = 0,
662                 .dev    = {
663                         .platform_data = &tw9910_link,
664                 },
665         },
666         {
667                 .name   = "soc-camera-pdrv",
668                 .id     = 1,
669                 .dev    = {
670                         .platform_data = &mt9t112_link1,
671                 },
672         },
673         {
674                 .name   = "soc-camera-pdrv",
675                 .id     = 2,
676                 .dev    = {
677                         .platform_data = &mt9t112_link2,
678                 },
679         },
680 };
681
682 static struct platform_device *ecovec_devices[] __initdata = {
683         &heartbeat_device,
684         &nor_flash_device,
685         &sh_eth_device,
686         &usb0_host_device,
687         &usb1_common_device,
688         &lcdc_device,
689         &ceu0_device,
690         &ceu1_device,
691         &keysc_device,
692 #ifdef CONFIG_MFD_SH_MOBILE_SDHI
693         &sdhi0_device,
694         &sdhi1_device,
695 #else
696         &msiof0_device,
697 #endif
698         &camera_devices[0],
699         &camera_devices[1],
700         &camera_devices[2],
701 };
702
703 #define EEPROM_ADDR 0x50
704 static u8 mac_read(struct i2c_adapter *a, u8 command)
705 {
706         struct i2c_msg msg[2];
707         u8 buf;
708         int ret;
709
710         msg[0].addr  = EEPROM_ADDR;
711         msg[0].flags = 0;
712         msg[0].len   = 1;
713         msg[0].buf   = &command;
714
715         msg[1].addr  = EEPROM_ADDR;
716         msg[1].flags = I2C_M_RD;
717         msg[1].len   = 1;
718         msg[1].buf   = &buf;
719
720         ret = i2c_transfer(a, msg, 2);
721         if (ret < 0) {
722                 printk(KERN_ERR "error %d\n", ret);
723                 buf = 0xff;
724         }
725
726         return buf;
727 }
728
729 static void __init sh_eth_init(struct sh_eth_plat_data *pd)
730 {
731         struct i2c_adapter *a = i2c_get_adapter(1);
732         int i;
733
734         if (!a) {
735                 pr_err("can not get I2C 1\n");
736                 return;
737         }
738
739         /* read MAC address frome EEPROM */
740         for (i = 0; i < sizeof(pd->mac_addr); i++) {
741                 pd->mac_addr[i] = mac_read(a, 0x10 + i);
742                 msleep(10);
743         }
744 }
745
746 #define PORT_HIZA 0xA4050158
747 #define IODRIVEA  0xA405018A
748
749 extern char ecovec24_sdram_enter_start;
750 extern char ecovec24_sdram_enter_end;
751 extern char ecovec24_sdram_leave_start;
752 extern char ecovec24_sdram_leave_end;
753
754 static int __init arch_setup(void)
755 {
756         /* register board specific self-refresh code */
757         sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
758                                         &ecovec24_sdram_enter_start,
759                                         &ecovec24_sdram_enter_end,
760                                         &ecovec24_sdram_leave_start,
761                                         &ecovec24_sdram_leave_end);
762
763         /* enable STATUS0, STATUS2 and PDSTATUS */
764         gpio_request(GPIO_FN_STATUS0, NULL);
765         gpio_request(GPIO_FN_STATUS2, NULL);
766         gpio_request(GPIO_FN_PDSTATUS, NULL);
767
768         /* enable SCIFA0 */
769         gpio_request(GPIO_FN_SCIF0_TXD, NULL);
770         gpio_request(GPIO_FN_SCIF0_RXD, NULL);
771
772         /* enable debug LED */
773         gpio_request(GPIO_PTG0, NULL);
774         gpio_request(GPIO_PTG1, NULL);
775         gpio_request(GPIO_PTG2, NULL);
776         gpio_request(GPIO_PTG3, NULL);
777         gpio_direction_output(GPIO_PTG0, 0);
778         gpio_direction_output(GPIO_PTG1, 0);
779         gpio_direction_output(GPIO_PTG2, 0);
780         gpio_direction_output(GPIO_PTG3, 0);
781         ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
782
783         /* enable SH-Eth */
784         gpio_request(GPIO_PTA1, NULL);
785         gpio_direction_output(GPIO_PTA1, 1);
786         mdelay(20);
787
788         gpio_request(GPIO_FN_RMII_RXD0,    NULL);
789         gpio_request(GPIO_FN_RMII_RXD1,    NULL);
790         gpio_request(GPIO_FN_RMII_TXD0,    NULL);
791         gpio_request(GPIO_FN_RMII_TXD1,    NULL);
792         gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
793         gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
794         gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
795         gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
796         gpio_request(GPIO_FN_MDIO,         NULL);
797         gpio_request(GPIO_FN_MDC,          NULL);
798         gpio_request(GPIO_FN_LNKSTA,       NULL);
799
800         /* enable USB */
801         ctrl_outw(0x0000, 0xA4D80000);
802         ctrl_outw(0x0000, 0xA4D90000);
803         gpio_request(GPIO_PTB3,  NULL);
804         gpio_request(GPIO_PTB4,  NULL);
805         gpio_request(GPIO_PTB5,  NULL);
806         gpio_direction_input(GPIO_PTB3);
807         gpio_direction_output(GPIO_PTB4, 0);
808         gpio_direction_output(GPIO_PTB5, 0);
809         ctrl_outw(0x0600, 0xa40501d4);
810         ctrl_outw(0x0600, 0xa4050192);
811
812         if (gpio_get_value(GPIO_PTB3)) {
813                 printk(KERN_INFO "USB1 function is selected\n");
814                 usb1_common_device.name = "r8a66597_udc";
815         } else {
816                 printk(KERN_INFO "USB1 host is selected\n");
817                 usb1_common_device.name = "r8a66597_hcd";
818         }
819
820         /* enable LCDC */
821         gpio_request(GPIO_FN_LCDD23,   NULL);
822         gpio_request(GPIO_FN_LCDD22,   NULL);
823         gpio_request(GPIO_FN_LCDD21,   NULL);
824         gpio_request(GPIO_FN_LCDD20,   NULL);
825         gpio_request(GPIO_FN_LCDD19,   NULL);
826         gpio_request(GPIO_FN_LCDD18,   NULL);
827         gpio_request(GPIO_FN_LCDD17,   NULL);
828         gpio_request(GPIO_FN_LCDD16,   NULL);
829         gpio_request(GPIO_FN_LCDD15,   NULL);
830         gpio_request(GPIO_FN_LCDD14,   NULL);
831         gpio_request(GPIO_FN_LCDD13,   NULL);
832         gpio_request(GPIO_FN_LCDD12,   NULL);
833         gpio_request(GPIO_FN_LCDD11,   NULL);
834         gpio_request(GPIO_FN_LCDD10,   NULL);
835         gpio_request(GPIO_FN_LCDD9,    NULL);
836         gpio_request(GPIO_FN_LCDD8,    NULL);
837         gpio_request(GPIO_FN_LCDD7,    NULL);
838         gpio_request(GPIO_FN_LCDD6,    NULL);
839         gpio_request(GPIO_FN_LCDD5,    NULL);
840         gpio_request(GPIO_FN_LCDD4,    NULL);
841         gpio_request(GPIO_FN_LCDD3,    NULL);
842         gpio_request(GPIO_FN_LCDD2,    NULL);
843         gpio_request(GPIO_FN_LCDD1,    NULL);
844         gpio_request(GPIO_FN_LCDD0,    NULL);
845         gpio_request(GPIO_FN_LCDDISP,  NULL);
846         gpio_request(GPIO_FN_LCDHSYN,  NULL);
847         gpio_request(GPIO_FN_LCDDCK,   NULL);
848         gpio_request(GPIO_FN_LCDVSYN,  NULL);
849         gpio_request(GPIO_FN_LCDDON,   NULL);
850         gpio_request(GPIO_FN_LCDLCLK,  NULL);
851         ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
852
853         gpio_request(GPIO_PTE6, NULL);
854         gpio_request(GPIO_PTU1, NULL);
855         gpio_request(GPIO_PTR1, NULL);
856         gpio_request(GPIO_PTA2, NULL);
857         gpio_direction_input(GPIO_PTE6);
858         gpio_direction_output(GPIO_PTU1, 0);
859         gpio_direction_output(GPIO_PTR1, 0);
860         gpio_direction_output(GPIO_PTA2, 0);
861
862         /* I/O buffer drive ability is high */
863         ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
864
865         if (gpio_get_value(GPIO_PTE6)) {
866                 /* DVI */
867                 lcdc_info.clock_source                  = LCDC_CLK_EXTERNAL;
868                 lcdc_info.ch[0].clock_divider           = 1,
869                 lcdc_info.ch[0].lcd_cfg.name            = "DVI";
870                 lcdc_info.ch[0].lcd_cfg.xres            = 1280;
871                 lcdc_info.ch[0].lcd_cfg.yres            = 720;
872                 lcdc_info.ch[0].lcd_cfg.left_margin     = 220;
873                 lcdc_info.ch[0].lcd_cfg.right_margin    = 110;
874                 lcdc_info.ch[0].lcd_cfg.hsync_len       = 40;
875                 lcdc_info.ch[0].lcd_cfg.upper_margin    = 20;
876                 lcdc_info.ch[0].lcd_cfg.lower_margin    = 5;
877                 lcdc_info.ch[0].lcd_cfg.vsync_len       = 5;
878
879                 gpio_set_value(GPIO_PTA2, 1);
880                 gpio_set_value(GPIO_PTU1, 1);
881         } else {
882                 /* Panel */
883
884                 lcdc_info.clock_source                  = LCDC_CLK_PERIPHERAL;
885                 lcdc_info.ch[0].clock_divider           = 2,
886                 lcdc_info.ch[0].lcd_cfg.name            = "Panel";
887                 lcdc_info.ch[0].lcd_cfg.xres            = 800;
888                 lcdc_info.ch[0].lcd_cfg.yres            = 480;
889                 lcdc_info.ch[0].lcd_cfg.left_margin     = 220;
890                 lcdc_info.ch[0].lcd_cfg.right_margin    = 110;
891                 lcdc_info.ch[0].lcd_cfg.hsync_len       = 70;
892                 lcdc_info.ch[0].lcd_cfg.upper_margin    = 20;
893                 lcdc_info.ch[0].lcd_cfg.lower_margin    = 5;
894                 lcdc_info.ch[0].lcd_cfg.vsync_len       = 5;
895
896                 gpio_set_value(GPIO_PTR1, 1);
897
898                 /* FIXME
899                  *
900                  * LCDDON control is needed for Panel,
901                  * but current sh_mobile_lcdc driver doesn't control it.
902                  * It is temporary correspondence
903                  */
904                 gpio_request(GPIO_PTF4, NULL);
905                 gpio_direction_output(GPIO_PTF4, 1);
906
907                 /* enable TouchScreen */
908                 i2c_register_board_info(0, &ts_i2c_clients, 1);
909                 set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
910         }
911
912         /* enable CEU0 */
913         gpio_request(GPIO_FN_VIO0_D15, NULL);
914         gpio_request(GPIO_FN_VIO0_D14, NULL);
915         gpio_request(GPIO_FN_VIO0_D13, NULL);
916         gpio_request(GPIO_FN_VIO0_D12, NULL);
917         gpio_request(GPIO_FN_VIO0_D11, NULL);
918         gpio_request(GPIO_FN_VIO0_D10, NULL);
919         gpio_request(GPIO_FN_VIO0_D9,  NULL);
920         gpio_request(GPIO_FN_VIO0_D8,  NULL);
921         gpio_request(GPIO_FN_VIO0_D7,  NULL);
922         gpio_request(GPIO_FN_VIO0_D6,  NULL);
923         gpio_request(GPIO_FN_VIO0_D5,  NULL);
924         gpio_request(GPIO_FN_VIO0_D4,  NULL);
925         gpio_request(GPIO_FN_VIO0_D3,  NULL);
926         gpio_request(GPIO_FN_VIO0_D2,  NULL);
927         gpio_request(GPIO_FN_VIO0_D1,  NULL);
928         gpio_request(GPIO_FN_VIO0_D0,  NULL);
929         gpio_request(GPIO_FN_VIO0_VD,  NULL);
930         gpio_request(GPIO_FN_VIO0_CLK, NULL);
931         gpio_request(GPIO_FN_VIO0_FLD, NULL);
932         gpio_request(GPIO_FN_VIO0_HD,  NULL);
933         platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
934
935         /* enable CEU1 */
936         gpio_request(GPIO_FN_VIO1_D7,  NULL);
937         gpio_request(GPIO_FN_VIO1_D6,  NULL);
938         gpio_request(GPIO_FN_VIO1_D5,  NULL);
939         gpio_request(GPIO_FN_VIO1_D4,  NULL);
940         gpio_request(GPIO_FN_VIO1_D3,  NULL);
941         gpio_request(GPIO_FN_VIO1_D2,  NULL);
942         gpio_request(GPIO_FN_VIO1_D1,  NULL);
943         gpio_request(GPIO_FN_VIO1_D0,  NULL);
944         gpio_request(GPIO_FN_VIO1_FLD, NULL);
945         gpio_request(GPIO_FN_VIO1_HD,  NULL);
946         gpio_request(GPIO_FN_VIO1_VD,  NULL);
947         gpio_request(GPIO_FN_VIO1_CLK, NULL);
948         platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
949
950         /* enable KEYSC */
951         gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
952         gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
953         gpio_request(GPIO_FN_KEYOUT3,     NULL);
954         gpio_request(GPIO_FN_KEYOUT2,     NULL);
955         gpio_request(GPIO_FN_KEYOUT1,     NULL);
956         gpio_request(GPIO_FN_KEYOUT0,     NULL);
957         gpio_request(GPIO_FN_KEYIN0,      NULL);
958
959         /* enable user debug switch */
960         gpio_request(GPIO_PTR0, NULL);
961         gpio_request(GPIO_PTR4, NULL);
962         gpio_request(GPIO_PTR5, NULL);
963         gpio_request(GPIO_PTR6, NULL);
964         gpio_direction_input(GPIO_PTR0);
965         gpio_direction_input(GPIO_PTR4);
966         gpio_direction_input(GPIO_PTR5);
967         gpio_direction_input(GPIO_PTR6);
968
969 #ifdef CONFIG_MFD_SH_MOBILE_SDHI
970         /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
971         gpio_request(GPIO_FN_SDHI0CD,  NULL);
972         gpio_request(GPIO_FN_SDHI0WP,  NULL);
973         gpio_request(GPIO_FN_SDHI0CMD, NULL);
974         gpio_request(GPIO_FN_SDHI0CLK, NULL);
975         gpio_request(GPIO_FN_SDHI0D3,  NULL);
976         gpio_request(GPIO_FN_SDHI0D2,  NULL);
977         gpio_request(GPIO_FN_SDHI0D1,  NULL);
978         gpio_request(GPIO_FN_SDHI0D0,  NULL);
979         gpio_request(GPIO_PTB6, NULL);
980         gpio_direction_output(GPIO_PTB6, 0);
981
982         /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
983         gpio_request(GPIO_FN_SDHI1CD,  NULL);
984         gpio_request(GPIO_FN_SDHI1WP,  NULL);
985         gpio_request(GPIO_FN_SDHI1CMD, NULL);
986         gpio_request(GPIO_FN_SDHI1CLK, NULL);
987         gpio_request(GPIO_FN_SDHI1D3,  NULL);
988         gpio_request(GPIO_FN_SDHI1D2,  NULL);
989         gpio_request(GPIO_FN_SDHI1D1,  NULL);
990         gpio_request(GPIO_FN_SDHI1D0,  NULL);
991         gpio_request(GPIO_PTB7, NULL);
992         gpio_direction_output(GPIO_PTB7, 0);
993
994         /* I/O buffer drive ability is high for SDHI1 */
995         ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
996 #else
997         /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
998         gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
999         gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
1000         gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
1001         gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
1002         gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
1003         gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
1004         gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
1005         gpio_request(GPIO_PTY6, NULL); /* write protect */
1006         gpio_direction_input(GPIO_PTY6);
1007         gpio_request(GPIO_PTY7, NULL); /* card detect */
1008         gpio_direction_input(GPIO_PTY7);
1009
1010         spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
1011 #endif
1012
1013         /* enable Video */
1014         gpio_request(GPIO_PTU2, NULL);
1015         gpio_direction_output(GPIO_PTU2, 1);
1016
1017         /* enable Camera */
1018         gpio_request(GPIO_PTA3, NULL);
1019         gpio_request(GPIO_PTA4, NULL);
1020         gpio_direction_output(GPIO_PTA3, 0);
1021         gpio_direction_output(GPIO_PTA4, 0);
1022
1023         /* enable I2C device */
1024         i2c_register_board_info(1, i2c1_devices,
1025                                 ARRAY_SIZE(i2c1_devices));
1026
1027         return platform_add_devices(ecovec_devices,
1028                                     ARRAY_SIZE(ecovec_devices));
1029 }
1030 arch_initcall(arch_setup);
1031
1032 static int __init devices_setup(void)
1033 {
1034         sh_eth_init(&sh_eth_plat);
1035         return 0;
1036 }
1037 device_initcall(devices_setup);
1038
1039 static struct sh_machine_vector mv_ecovec __initmv = {
1040         .mv_name        = "R0P7724 (EcoVec)",
1041 };