]> git.karo-electronics.de Git - linux-beck.git/blob - arch/sh/boards/mach-se/7724/setup.c
5cc5ed44d9af7836322210e12421882be4b0bb60
[linux-beck.git] / arch / sh / boards / mach-se / 7724 / setup.c
1 /*
2  * linux/arch/sh/boards/se/7724/setup.c
3  *
4  * Copyright (C) 2009 Renesas Solutions Corp.
5  *
6  * Kuninori Morimoto <morimoto.kuninori@renesas.com>
7  *
8  * This file is subject to the terms and conditions of the GNU General Public
9  * License.  See the file "COPYING" in the main directory of this archive
10  * for more details.
11  */
12
13 #include <linux/init.h>
14 #include <linux/device.h>
15 #include <linux/interrupt.h>
16 #include <linux/platform_device.h>
17 #include <linux/mmc/host.h>
18 #include <linux/mmc/sh_mobile_sdhi.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/delay.h>
21 #include <linux/smc91x.h>
22 #include <linux/gpio.h>
23 #include <linux/input.h>
24 #include <linux/input/sh_keysc.h>
25 #include <linux/usb/r8a66597.h>
26 #include <linux/sh_eth.h>
27 #include <linux/videodev2.h>
28 #include <video/sh_mobile_lcdc.h>
29 #include <media/sh_mobile_ceu.h>
30 #include <sound/sh_fsi.h>
31 #include <sound/simple_card.h>
32 #include <asm/io.h>
33 #include <asm/heartbeat.h>
34 #include <asm/clock.h>
35 #include <asm/suspend.h>
36 #include <cpu/sh7724.h>
37 #include <mach-se/mach/se7724.h>
38
39 /*
40  * SWx    1234 5678
41  * ------------------------------------
42  * SW31 : 1001 1100    : default
43  * SW32 : 0111 1111    : use on board flash
44  *
45  * SW41 : abxx xxxx  -> a = 0 : Analog  monitor
46  *                          1 : Digital monitor
47  *                      b = 0 : VGA
48  *                          1 : 720p
49  */
50
51 /*
52  * about 720p
53  *
54  * When you use 1280 x 720 lcdc output,
55  * you should change OSC6 lcdc clock from 25.175MHz to 74.25MHz,
56  * and change SW41 to use 720p
57  */
58
59 /*
60  * about sound
61  *
62  * This setup.c supports FSI slave mode.
63  * Please change J20, J21, J22 pin to 1-2 connection.
64  */
65
66 /* Heartbeat */
67 static struct resource heartbeat_resource = {
68         .start  = PA_LED,
69         .end    = PA_LED,
70         .flags  = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
71 };
72
73 static struct platform_device heartbeat_device = {
74         .name           = "heartbeat",
75         .id             = -1,
76         .num_resources  = 1,
77         .resource       = &heartbeat_resource,
78 };
79
80 /* LAN91C111 */
81 static struct smc91x_platdata smc91x_info = {
82         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
83 };
84
85 static struct resource smc91x_eth_resources[] = {
86         [0] = {
87                 .name   = "SMC91C111" ,
88                 .start  = 0x1a300300,
89                 .end    = 0x1a30030f,
90                 .flags  = IORESOURCE_MEM,
91         },
92         [1] = {
93                 .start  = IRQ0_SMC,
94                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
95         },
96 };
97
98 static struct platform_device smc91x_eth_device = {
99         .name   = "smc91x",
100         .num_resources  = ARRAY_SIZE(smc91x_eth_resources),
101         .resource       = smc91x_eth_resources,
102         .dev    = {
103                 .platform_data  = &smc91x_info,
104         },
105 };
106
107 /* MTD */
108 static struct mtd_partition nor_flash_partitions[] = {
109         {
110                 .name = "uboot",
111                 .offset = 0,
112                 .size = (1 * 1024 * 1024),
113                 .mask_flags = MTD_WRITEABLE,    /* Read-only */
114         }, {
115                 .name = "kernel",
116                 .offset = MTDPART_OFS_APPEND,
117                 .size = (2 * 1024 * 1024),
118         }, {
119                 .name = "free-area",
120                 .offset = MTDPART_OFS_APPEND,
121                 .size = MTDPART_SIZ_FULL,
122         },
123 };
124
125 static struct physmap_flash_data nor_flash_data = {
126         .width          = 2,
127         .parts          = nor_flash_partitions,
128         .nr_parts       = ARRAY_SIZE(nor_flash_partitions),
129 };
130
131 static struct resource nor_flash_resources[] = {
132         [0] = {
133                 .name   = "NOR Flash",
134                 .start  = 0x00000000,
135                 .end    = 0x01ffffff,
136                 .flags  = IORESOURCE_MEM,
137         }
138 };
139
140 static struct platform_device nor_flash_device = {
141         .name           = "physmap-flash",
142         .resource       = nor_flash_resources,
143         .num_resources  = ARRAY_SIZE(nor_flash_resources),
144         .dev            = {
145                 .platform_data = &nor_flash_data,
146         },
147 };
148
149 /* LCDC */
150 static const struct fb_videomode lcdc_720p_modes[] = {
151         {
152                 .name           = "LB070WV1",
153                 .sync           = 0, /* hsync and vsync are active low */
154                 .xres           = 1280,
155                 .yres           = 720,
156                 .left_margin    = 220,
157                 .right_margin   = 110,
158                 .hsync_len      = 40,
159                 .upper_margin   = 20,
160                 .lower_margin   = 5,
161                 .vsync_len      = 5,
162         },
163 };
164
165 static const struct fb_videomode lcdc_vga_modes[] = {
166         {
167                 .name           = "LB070WV1",
168                 .sync           = 0, /* hsync and vsync are active low */
169                 .xres           = 640,
170                 .yres           = 480,
171                 .left_margin    = 105,
172                 .right_margin   = 50,
173                 .hsync_len      = 96,
174                 .upper_margin   = 33,
175                 .lower_margin   = 10,
176                 .vsync_len      = 2,
177         },
178 };
179
180 static struct sh_mobile_lcdc_info lcdc_info = {
181         .clock_source = LCDC_CLK_EXTERNAL,
182         .ch[0] = {
183                 .chan = LCDC_CHAN_MAINLCD,
184                 .fourcc = V4L2_PIX_FMT_RGB565,
185                 .clock_divider = 1,
186                 .panel_cfg = { /* 7.0 inch */
187                         .width = 152,
188                         .height = 91,
189                 },
190         }
191 };
192
193 static struct resource lcdc_resources[] = {
194         [0] = {
195                 .name   = "LCDC",
196                 .start  = 0xfe940000,
197                 .end    = 0xfe942fff,
198                 .flags  = IORESOURCE_MEM,
199         },
200         [1] = {
201                 .start  = 106,
202                 .flags  = IORESOURCE_IRQ,
203         },
204 };
205
206 static struct platform_device lcdc_device = {
207         .name           = "sh_mobile_lcdc_fb",
208         .num_resources  = ARRAY_SIZE(lcdc_resources),
209         .resource       = lcdc_resources,
210         .dev            = {
211                 .platform_data  = &lcdc_info,
212         },
213 };
214
215 /* CEU0 */
216 static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
217         .flags = SH_CEU_FLAG_USE_8BIT_BUS,
218 };
219
220 static struct resource ceu0_resources[] = {
221         [0] = {
222                 .name   = "CEU0",
223                 .start  = 0xfe910000,
224                 .end    = 0xfe91009f,
225                 .flags  = IORESOURCE_MEM,
226         },
227         [1] = {
228                 .start  = 52,
229                 .flags  = IORESOURCE_IRQ,
230         },
231         [2] = {
232                 /* place holder for contiguous memory */
233         },
234 };
235
236 static struct platform_device ceu0_device = {
237         .name           = "sh_mobile_ceu",
238         .id             = 0, /* "ceu0" clock */
239         .num_resources  = ARRAY_SIZE(ceu0_resources),
240         .resource       = ceu0_resources,
241         .dev    = {
242                 .platform_data  = &sh_mobile_ceu0_info,
243         },
244 };
245
246 /* CEU1 */
247 static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
248         .flags = SH_CEU_FLAG_USE_8BIT_BUS,
249 };
250
251 static struct resource ceu1_resources[] = {
252         [0] = {
253                 .name   = "CEU1",
254                 .start  = 0xfe914000,
255                 .end    = 0xfe91409f,
256                 .flags  = IORESOURCE_MEM,
257         },
258         [1] = {
259                 .start  = 63,
260                 .flags  = IORESOURCE_IRQ,
261         },
262         [2] = {
263                 /* place holder for contiguous memory */
264         },
265 };
266
267 static struct platform_device ceu1_device = {
268         .name           = "sh_mobile_ceu",
269         .id             = 1, /* "ceu1" clock */
270         .num_resources  = ARRAY_SIZE(ceu1_resources),
271         .resource       = ceu1_resources,
272         .dev    = {
273                 .platform_data  = &sh_mobile_ceu1_info,
274         },
275 };
276
277 /* FSI */
278 /* change J20, J21, J22 pin to 1-2 connection to use slave mode */
279 static struct sh_fsi_platform_info fsi_info = {
280         .port_a = {
281                 .flags = SH_FSI_BRS_INV,
282         },
283 };
284
285 static struct resource fsi_resources[] = {
286         [0] = {
287                 .name   = "FSI",
288                 .start  = 0xFE3C0000,
289                 .end    = 0xFE3C021d,
290                 .flags  = IORESOURCE_MEM,
291         },
292         [1] = {
293                 .start  = 108,
294                 .flags  = IORESOURCE_IRQ,
295         },
296 };
297
298 static struct platform_device fsi_device = {
299         .name           = "sh_fsi",
300         .id             = 0,
301         .num_resources  = ARRAY_SIZE(fsi_resources),
302         .resource       = fsi_resources,
303         .dev    = {
304                 .platform_data  = &fsi_info,
305         },
306 };
307
308 static struct asoc_simple_dai_init_info fsi2_ak4642_init_info = {
309         .fmt            = SND_SOC_DAIFMT_LEFT_J,
310         .codec_daifmt   = SND_SOC_DAIFMT_CBM_CFM,
311         .cpu_daifmt     = SND_SOC_DAIFMT_CBS_CFS,
312         .sysclk         = 11289600,
313 };
314
315 static struct asoc_simple_card_info fsi_ak4642_info = {
316         .name           = "AK4642",
317         .card           = "FSIA-AK4642",
318         .cpu_dai        = "fsia-dai",
319         .codec          = "ak4642-codec.0-0012",
320         .platform       = "sh_fsi.0",
321         .codec_dai      = "ak4642-hifi",
322         .init           = &fsi2_ak4642_init_info,
323 };
324
325 static struct platform_device fsi_ak4642_device = {
326         .name   = "asoc-simple-card",
327         .dev    = {
328                 .platform_data  = &fsi_ak4642_info,
329         },
330 };
331
332 /* KEYSC in SoC (Needs SW33-2 set to ON) */
333 static struct sh_keysc_info keysc_info = {
334         .mode = SH_KEYSC_MODE_1,
335         .scan_timing = 3,
336         .delay = 50,
337         .keycodes = {
338                 KEY_1, KEY_2, KEY_3, KEY_4, KEY_5,
339                 KEY_6, KEY_7, KEY_8, KEY_9, KEY_A,
340                 KEY_B, KEY_C, KEY_D, KEY_E, KEY_F,
341                 KEY_G, KEY_H, KEY_I, KEY_K, KEY_L,
342                 KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q,
343                 KEY_R, KEY_S, KEY_T, KEY_U, KEY_V,
344         },
345 };
346
347 static struct resource keysc_resources[] = {
348         [0] = {
349                 .name   = "KEYSC",
350                 .start  = 0x044b0000,
351                 .end    = 0x044b000f,
352                 .flags  = IORESOURCE_MEM,
353         },
354         [1] = {
355                 .start  = 79,
356                 .flags  = IORESOURCE_IRQ,
357         },
358 };
359
360 static struct platform_device keysc_device = {
361         .name           = "sh_keysc",
362         .id             = 0, /* "keysc0" clock */
363         .num_resources  = ARRAY_SIZE(keysc_resources),
364         .resource       = keysc_resources,
365         .dev    = {
366                 .platform_data  = &keysc_info,
367         },
368 };
369
370 /* SH Eth */
371 static struct resource sh_eth_resources[] = {
372         [0] = {
373                 .start = SH_ETH_ADDR,
374                 .end   = SH_ETH_ADDR + 0x1FC,
375                 .flags = IORESOURCE_MEM,
376         },
377         [1] = {
378                 .start = 91,
379                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
380         },
381 };
382
383 static struct sh_eth_plat_data sh_eth_plat = {
384         .phy = 0x1f, /* SMSC LAN8187 */
385         .edmac_endian = EDMAC_LITTLE_ENDIAN,
386 };
387
388 static struct platform_device sh_eth_device = {
389         .name = "sh-eth",
390         .id     = 0,
391         .dev = {
392                 .platform_data = &sh_eth_plat,
393         },
394         .num_resources = ARRAY_SIZE(sh_eth_resources),
395         .resource = sh_eth_resources,
396 };
397
398 static struct r8a66597_platdata sh7724_usb0_host_data = {
399         .on_chip = 1,
400 };
401
402 static struct resource sh7724_usb0_host_resources[] = {
403         [0] = {
404                 .start  = 0xa4d80000,
405                 .end    = 0xa4d80124 - 1,
406                 .flags  = IORESOURCE_MEM,
407         },
408         [1] = {
409                 .start  = 65,
410                 .end    = 65,
411                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
412         },
413 };
414
415 static struct platform_device sh7724_usb0_host_device = {
416         .name           = "r8a66597_hcd",
417         .id             = 0,
418         .dev = {
419                 .dma_mask               = NULL,         /*  not use dma */
420                 .coherent_dma_mask      = 0xffffffff,
421                 .platform_data          = &sh7724_usb0_host_data,
422         },
423         .num_resources  = ARRAY_SIZE(sh7724_usb0_host_resources),
424         .resource       = sh7724_usb0_host_resources,
425 };
426
427 static struct r8a66597_platdata sh7724_usb1_gadget_data = {
428         .on_chip = 1,
429 };
430
431 static struct resource sh7724_usb1_gadget_resources[] = {
432         [0] = {
433                 .start  = 0xa4d90000,
434                 .end    = 0xa4d90123,
435                 .flags  = IORESOURCE_MEM,
436         },
437         [1] = {
438                 .start  = 66,
439                 .end    = 66,
440                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
441         },
442 };
443
444 static struct platform_device sh7724_usb1_gadget_device = {
445         .name           = "r8a66597_udc",
446         .id             = 1, /* USB1 */
447         .dev = {
448                 .dma_mask               = NULL,         /*  not use dma */
449                 .coherent_dma_mask      = 0xffffffff,
450                 .platform_data          = &sh7724_usb1_gadget_data,
451         },
452         .num_resources  = ARRAY_SIZE(sh7724_usb1_gadget_resources),
453         .resource       = sh7724_usb1_gadget_resources,
454 };
455
456 static struct resource sdhi0_cn7_resources[] = {
457         [0] = {
458                 .name   = "SDHI0",
459                 .start  = 0x04ce0000,
460                 .end    = 0x04ce00ff,
461                 .flags  = IORESOURCE_MEM,
462         },
463         [1] = {
464                 .start  = 100,
465                 .flags  = IORESOURCE_IRQ,
466         },
467 };
468
469 static struct sh_mobile_sdhi_info sh7724_sdhi0_data = {
470         .dma_slave_tx   = SHDMA_SLAVE_SDHI0_TX,
471         .dma_slave_rx   = SHDMA_SLAVE_SDHI0_RX,
472         .tmio_caps      = MMC_CAP_SDIO_IRQ,
473 };
474
475 static struct platform_device sdhi0_cn7_device = {
476         .name           = "sh_mobile_sdhi",
477         .id             = 0,
478         .num_resources  = ARRAY_SIZE(sdhi0_cn7_resources),
479         .resource       = sdhi0_cn7_resources,
480         .dev = {
481                 .platform_data  = &sh7724_sdhi0_data,
482         },
483 };
484
485 static struct resource sdhi1_cn8_resources[] = {
486         [0] = {
487                 .name   = "SDHI1",
488                 .start  = 0x04cf0000,
489                 .end    = 0x04cf00ff,
490                 .flags  = IORESOURCE_MEM,
491         },
492         [1] = {
493                 .start  = 23,
494                 .flags  = IORESOURCE_IRQ,
495         },
496 };
497
498 static struct sh_mobile_sdhi_info sh7724_sdhi1_data = {
499         .dma_slave_tx   = SHDMA_SLAVE_SDHI1_TX,
500         .dma_slave_rx   = SHDMA_SLAVE_SDHI1_RX,
501         .tmio_caps      = MMC_CAP_SDIO_IRQ,
502 };
503
504 static struct platform_device sdhi1_cn8_device = {
505         .name           = "sh_mobile_sdhi",
506         .id             = 1,
507         .num_resources  = ARRAY_SIZE(sdhi1_cn8_resources),
508         .resource       = sdhi1_cn8_resources,
509         .dev = {
510                 .platform_data  = &sh7724_sdhi1_data,
511         },
512 };
513
514 /* IrDA */
515 static struct resource irda_resources[] = {
516         [0] = {
517                 .name   = "IrDA",
518                 .start  = 0xA45D0000,
519                 .end    = 0xA45D0049,
520                 .flags  = IORESOURCE_MEM,
521         },
522         [1] = {
523                 .start  = 20,
524                 .flags  = IORESOURCE_IRQ,
525         },
526 };
527
528 static struct platform_device irda_device = {
529         .name           = "sh_sir",
530         .num_resources  = ARRAY_SIZE(irda_resources),
531         .resource       = irda_resources,
532 };
533
534 #include <media/ak881x.h>
535 #include <media/sh_vou.h>
536
537 static struct ak881x_pdata ak881x_pdata = {
538         .flags = AK881X_IF_MODE_SLAVE,
539 };
540
541 static struct i2c_board_info ak8813 = {
542         /* With open J18 jumper address is 0x21 */
543         I2C_BOARD_INFO("ak8813", 0x20),
544         .platform_data = &ak881x_pdata,
545 };
546
547 static struct sh_vou_pdata sh_vou_pdata = {
548         .bus_fmt        = SH_VOU_BUS_8BIT,
549         .flags          = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
550         .board_info     = &ak8813,
551         .i2c_adap       = 0,
552 };
553
554 static struct resource sh_vou_resources[] = {
555         [0] = {
556                 .start  = 0xfe960000,
557                 .end    = 0xfe962043,
558                 .flags  = IORESOURCE_MEM,
559         },
560         [1] = {
561                 .start  = 55,
562                 .flags  = IORESOURCE_IRQ,
563         },
564 };
565
566 static struct platform_device vou_device = {
567         .name           = "sh-vou",
568         .id             = -1,
569         .num_resources  = ARRAY_SIZE(sh_vou_resources),
570         .resource       = sh_vou_resources,
571         .dev            = {
572                 .platform_data  = &sh_vou_pdata,
573         },
574 };
575
576 static struct platform_device *ms7724se_devices[] __initdata = {
577         &heartbeat_device,
578         &smc91x_eth_device,
579         &lcdc_device,
580         &nor_flash_device,
581         &ceu0_device,
582         &ceu1_device,
583         &keysc_device,
584         &sh_eth_device,
585         &sh7724_usb0_host_device,
586         &sh7724_usb1_gadget_device,
587         &fsi_device,
588         &fsi_ak4642_device,
589         &sdhi0_cn7_device,
590         &sdhi1_cn8_device,
591         &irda_device,
592         &vou_device,
593 };
594
595 /* I2C device */
596 static struct i2c_board_info i2c0_devices[] = {
597         {
598                 I2C_BOARD_INFO("ak4642", 0x12),
599         },
600 };
601
602 #define EEPROM_OP   0xBA206000
603 #define EEPROM_ADR  0xBA206004
604 #define EEPROM_DATA 0xBA20600C
605 #define EEPROM_STAT 0xBA206010
606 #define EEPROM_STRT 0xBA206014
607 static int __init sh_eth_is_eeprom_ready(void)
608 {
609         int t = 10000;
610
611         while (t--) {
612                 if (!__raw_readw(EEPROM_STAT))
613                         return 1;
614                 udelay(1);
615         }
616
617         printk(KERN_ERR "ms7724se can not access to eeprom\n");
618         return 0;
619 }
620
621 static void __init sh_eth_init(void)
622 {
623         int i;
624         u16 mac;
625
626         /* check EEPROM status */
627         if (!sh_eth_is_eeprom_ready())
628                 return;
629
630         /* read MAC addr from EEPROM */
631         for (i = 0 ; i < 3 ; i++) {
632                 __raw_writew(0x0, EEPROM_OP); /* read */
633                 __raw_writew(i*2, EEPROM_ADR);
634                 __raw_writew(0x1, EEPROM_STRT);
635                 if (!sh_eth_is_eeprom_ready())
636                         return;
637
638                 mac = __raw_readw(EEPROM_DATA);
639                 sh_eth_plat.mac_addr[i << 1] = mac & 0xff;
640                 sh_eth_plat.mac_addr[(i << 1) + 1] = mac >> 8;
641         }
642 }
643
644 #define SW4140    0xBA201000
645 #define FPGA_OUT  0xBA200400
646 #define PORT_HIZA 0xA4050158
647 #define PORT_MSELCRB 0xA4050182
648
649 #define SW41_A    0x0100
650 #define SW41_B    0x0200
651 #define SW41_C    0x0400
652 #define SW41_D    0x0800
653 #define SW41_E    0x1000
654 #define SW41_F    0x2000
655 #define SW41_G    0x4000
656 #define SW41_H    0x8000
657
658 extern char ms7724se_sdram_enter_start;
659 extern char ms7724se_sdram_enter_end;
660 extern char ms7724se_sdram_leave_start;
661 extern char ms7724se_sdram_leave_end;
662
663
664 static int __init arch_setup(void)
665 {
666         /* enable I2C device */
667         i2c_register_board_info(0, i2c0_devices,
668                                 ARRAY_SIZE(i2c0_devices));
669         return 0;
670 }
671 arch_initcall(arch_setup);
672
673 static int __init devices_setup(void)
674 {
675         u16 sw = __raw_readw(SW4140); /* select camera, monitor */
676         struct clk *clk;
677         u16 fpga_out;
678
679         /* register board specific self-refresh code */
680         sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
681                                         SUSP_SH_RSTANDBY,
682                                         &ms7724se_sdram_enter_start,
683                                         &ms7724se_sdram_enter_end,
684                                         &ms7724se_sdram_leave_start,
685                                         &ms7724se_sdram_leave_end);
686         /* Reset Release */
687         fpga_out = __raw_readw(FPGA_OUT);
688         /* bit4: NTSC_PDN, bit5: NTSC_RESET */
689         fpga_out &= ~((1 << 1)  | /* LAN */
690                       (1 << 4)  | /* AK8813 PDN */
691                       (1 << 5)  | /* AK8813 RESET */
692                       (1 << 6)  | /* VIDEO DAC */
693                       (1 << 7)  | /* AK4643 */
694                       (1 << 8)  | /* IrDA */
695                       (1 << 12) | /* USB0 */
696                       (1 << 14)); /* RMII */
697         __raw_writew(fpga_out | (1 << 4), FPGA_OUT);
698
699         udelay(10);
700
701         /* AK8813 RESET */
702         __raw_writew(fpga_out | (1 << 5), FPGA_OUT);
703
704         udelay(10);
705
706         __raw_writew(fpga_out, FPGA_OUT);
707
708         /* turn on USB clocks, use external clock */
709         __raw_writew((__raw_readw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
710
711         /* Let LED9 show STATUS2 */
712         gpio_request(GPIO_FN_STATUS2, NULL);
713
714         /* Lit LED10 show STATUS0 */
715         gpio_request(GPIO_FN_STATUS0, NULL);
716
717         /* Lit LED11 show PDSTATUS */
718         gpio_request(GPIO_FN_PDSTATUS, NULL);
719
720         /* enable USB0 port */
721         __raw_writew(0x0600, 0xa40501d4);
722
723         /* enable USB1 port */
724         __raw_writew(0x0600, 0xa4050192);
725
726         /* enable IRQ 0,1,2 */
727         gpio_request(GPIO_FN_INTC_IRQ0, NULL);
728         gpio_request(GPIO_FN_INTC_IRQ1, NULL);
729         gpio_request(GPIO_FN_INTC_IRQ2, NULL);
730
731         /* enable SCIFA3 */
732         gpio_request(GPIO_FN_SCIF3_I_SCK, NULL);
733         gpio_request(GPIO_FN_SCIF3_I_RXD, NULL);
734         gpio_request(GPIO_FN_SCIF3_I_TXD, NULL);
735         gpio_request(GPIO_FN_SCIF3_I_CTS, NULL);
736         gpio_request(GPIO_FN_SCIF3_I_RTS, NULL);
737
738         /* enable LCDC */
739         gpio_request(GPIO_FN_LCDD23,   NULL);
740         gpio_request(GPIO_FN_LCDD22,   NULL);
741         gpio_request(GPIO_FN_LCDD21,   NULL);
742         gpio_request(GPIO_FN_LCDD20,   NULL);
743         gpio_request(GPIO_FN_LCDD19,   NULL);
744         gpio_request(GPIO_FN_LCDD18,   NULL);
745         gpio_request(GPIO_FN_LCDD17,   NULL);
746         gpio_request(GPIO_FN_LCDD16,   NULL);
747         gpio_request(GPIO_FN_LCDD15,   NULL);
748         gpio_request(GPIO_FN_LCDD14,   NULL);
749         gpio_request(GPIO_FN_LCDD13,   NULL);
750         gpio_request(GPIO_FN_LCDD12,   NULL);
751         gpio_request(GPIO_FN_LCDD11,   NULL);
752         gpio_request(GPIO_FN_LCDD10,   NULL);
753         gpio_request(GPIO_FN_LCDD9,    NULL);
754         gpio_request(GPIO_FN_LCDD8,    NULL);
755         gpio_request(GPIO_FN_LCDD7,    NULL);
756         gpio_request(GPIO_FN_LCDD6,    NULL);
757         gpio_request(GPIO_FN_LCDD5,    NULL);
758         gpio_request(GPIO_FN_LCDD4,    NULL);
759         gpio_request(GPIO_FN_LCDD3,    NULL);
760         gpio_request(GPIO_FN_LCDD2,    NULL);
761         gpio_request(GPIO_FN_LCDD1,    NULL);
762         gpio_request(GPIO_FN_LCDD0,    NULL);
763         gpio_request(GPIO_FN_LCDDISP,  NULL);
764         gpio_request(GPIO_FN_LCDHSYN,  NULL);
765         gpio_request(GPIO_FN_LCDDCK,   NULL);
766         gpio_request(GPIO_FN_LCDVSYN,  NULL);
767         gpio_request(GPIO_FN_LCDDON,   NULL);
768         gpio_request(GPIO_FN_LCDVEPWC, NULL);
769         gpio_request(GPIO_FN_LCDVCPWC, NULL);
770         gpio_request(GPIO_FN_LCDRD,    NULL);
771         gpio_request(GPIO_FN_LCDLCLK,  NULL);
772         __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
773
774         /* enable CEU0 */
775         gpio_request(GPIO_FN_VIO0_D15, NULL);
776         gpio_request(GPIO_FN_VIO0_D14, NULL);
777         gpio_request(GPIO_FN_VIO0_D13, NULL);
778         gpio_request(GPIO_FN_VIO0_D12, NULL);
779         gpio_request(GPIO_FN_VIO0_D11, NULL);
780         gpio_request(GPIO_FN_VIO0_D10, NULL);
781         gpio_request(GPIO_FN_VIO0_D9,  NULL);
782         gpio_request(GPIO_FN_VIO0_D8,  NULL);
783         gpio_request(GPIO_FN_VIO0_D7,  NULL);
784         gpio_request(GPIO_FN_VIO0_D6,  NULL);
785         gpio_request(GPIO_FN_VIO0_D5,  NULL);
786         gpio_request(GPIO_FN_VIO0_D4,  NULL);
787         gpio_request(GPIO_FN_VIO0_D3,  NULL);
788         gpio_request(GPIO_FN_VIO0_D2,  NULL);
789         gpio_request(GPIO_FN_VIO0_D1,  NULL);
790         gpio_request(GPIO_FN_VIO0_D0,  NULL);
791         gpio_request(GPIO_FN_VIO0_VD,  NULL);
792         gpio_request(GPIO_FN_VIO0_CLK, NULL);
793         gpio_request(GPIO_FN_VIO0_FLD, NULL);
794         gpio_request(GPIO_FN_VIO0_HD,  NULL);
795         platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
796
797         /* enable CEU1 */
798         gpio_request(GPIO_FN_VIO1_D7,  NULL);
799         gpio_request(GPIO_FN_VIO1_D6,  NULL);
800         gpio_request(GPIO_FN_VIO1_D5,  NULL);
801         gpio_request(GPIO_FN_VIO1_D4,  NULL);
802         gpio_request(GPIO_FN_VIO1_D3,  NULL);
803         gpio_request(GPIO_FN_VIO1_D2,  NULL);
804         gpio_request(GPIO_FN_VIO1_D1,  NULL);
805         gpio_request(GPIO_FN_VIO1_D0,  NULL);
806         gpio_request(GPIO_FN_VIO1_FLD, NULL);
807         gpio_request(GPIO_FN_VIO1_HD,  NULL);
808         gpio_request(GPIO_FN_VIO1_VD,  NULL);
809         gpio_request(GPIO_FN_VIO1_CLK, NULL);
810         platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
811
812         /* KEYSC */
813         gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
814         gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
815         gpio_request(GPIO_FN_KEYIN4,      NULL);
816         gpio_request(GPIO_FN_KEYIN3,      NULL);
817         gpio_request(GPIO_FN_KEYIN2,      NULL);
818         gpio_request(GPIO_FN_KEYIN1,      NULL);
819         gpio_request(GPIO_FN_KEYIN0,      NULL);
820         gpio_request(GPIO_FN_KEYOUT3,     NULL);
821         gpio_request(GPIO_FN_KEYOUT2,     NULL);
822         gpio_request(GPIO_FN_KEYOUT1,     NULL);
823         gpio_request(GPIO_FN_KEYOUT0,     NULL);
824
825         /* enable FSI */
826         gpio_request(GPIO_FN_FSIMCKA,    NULL);
827         gpio_request(GPIO_FN_FSIIASD,    NULL);
828         gpio_request(GPIO_FN_FSIOASD,    NULL);
829         gpio_request(GPIO_FN_FSIIABCK,   NULL);
830         gpio_request(GPIO_FN_FSIIALRCK,  NULL);
831         gpio_request(GPIO_FN_FSIOABCK,   NULL);
832         gpio_request(GPIO_FN_FSIOALRCK,  NULL);
833         gpio_request(GPIO_FN_CLKAUDIOAO, NULL);
834
835         /* set SPU2 clock to 83.4 MHz */
836         clk = clk_get(NULL, "spu_clk");
837         if (!IS_ERR(clk)) {
838                 clk_set_rate(clk, clk_round_rate(clk, 83333333));
839                 clk_put(clk);
840         }
841
842         /* change parent of FSI A */
843         clk = clk_get(NULL, "fsia_clk");
844         if (!IS_ERR(clk)) {
845                 /* 48kHz dummy clock was used to make sure 1/1 divide */
846                 clk_set_rate(&sh7724_fsimcka_clk, 48000);
847                 clk_set_parent(clk, &sh7724_fsimcka_clk);
848                 clk_set_rate(clk, 48000);
849                 clk_put(clk);
850         }
851
852         /* SDHI0 connected to cn7 */
853         gpio_request(GPIO_FN_SDHI0CD, NULL);
854         gpio_request(GPIO_FN_SDHI0WP, NULL);
855         gpio_request(GPIO_FN_SDHI0D3, NULL);
856         gpio_request(GPIO_FN_SDHI0D2, NULL);
857         gpio_request(GPIO_FN_SDHI0D1, NULL);
858         gpio_request(GPIO_FN_SDHI0D0, NULL);
859         gpio_request(GPIO_FN_SDHI0CMD, NULL);
860         gpio_request(GPIO_FN_SDHI0CLK, NULL);
861
862         /* SDHI1 connected to cn8 */
863         gpio_request(GPIO_FN_SDHI1CD, NULL);
864         gpio_request(GPIO_FN_SDHI1WP, NULL);
865         gpio_request(GPIO_FN_SDHI1D3, NULL);
866         gpio_request(GPIO_FN_SDHI1D2, NULL);
867         gpio_request(GPIO_FN_SDHI1D1, NULL);
868         gpio_request(GPIO_FN_SDHI1D0, NULL);
869         gpio_request(GPIO_FN_SDHI1CMD, NULL);
870         gpio_request(GPIO_FN_SDHI1CLK, NULL);
871
872         /* enable IrDA */
873         gpio_request(GPIO_FN_IRDA_OUT, NULL);
874         gpio_request(GPIO_FN_IRDA_IN,  NULL);
875
876         /*
877          * enable SH-Eth
878          *
879          * please remove J33 pin from your board !!
880          *
881          * ms7724 board should not use GPIO_FN_LNKSTA pin
882          * So, This time PTX5 is set to input pin
883          */
884         gpio_request(GPIO_FN_RMII_RXD0,    NULL);
885         gpio_request(GPIO_FN_RMII_RXD1,    NULL);
886         gpio_request(GPIO_FN_RMII_TXD0,    NULL);
887         gpio_request(GPIO_FN_RMII_TXD1,    NULL);
888         gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
889         gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
890         gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
891         gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
892         gpio_request(GPIO_FN_MDIO,         NULL);
893         gpio_request(GPIO_FN_MDC,          NULL);
894         gpio_request(GPIO_PTX5, NULL);
895         gpio_direction_input(GPIO_PTX5);
896         sh_eth_init();
897
898         if (sw & SW41_B) {
899                 /* 720p */
900                 lcdc_info.ch[0].lcd_modes = lcdc_720p_modes;
901                 lcdc_info.ch[0].num_modes = ARRAY_SIZE(lcdc_720p_modes);
902         } else {
903                 /* VGA */
904                 lcdc_info.ch[0].lcd_modes = lcdc_vga_modes;
905                 lcdc_info.ch[0].num_modes = ARRAY_SIZE(lcdc_vga_modes);
906         }
907
908         if (sw & SW41_A) {
909                 /* Digital monitor */
910                 lcdc_info.ch[0].interface_type = RGB18;
911                 lcdc_info.ch[0].flags          = 0;
912         } else {
913                 /* Analog monitor */
914                 lcdc_info.ch[0].interface_type = RGB24;
915                 lcdc_info.ch[0].flags          = LCDC_FLAGS_DWPOL;
916         }
917
918         /* VOU */
919         gpio_request(GPIO_FN_DV_D15, NULL);
920         gpio_request(GPIO_FN_DV_D14, NULL);
921         gpio_request(GPIO_FN_DV_D13, NULL);
922         gpio_request(GPIO_FN_DV_D12, NULL);
923         gpio_request(GPIO_FN_DV_D11, NULL);
924         gpio_request(GPIO_FN_DV_D10, NULL);
925         gpio_request(GPIO_FN_DV_D9, NULL);
926         gpio_request(GPIO_FN_DV_D8, NULL);
927         gpio_request(GPIO_FN_DV_CLKI, NULL);
928         gpio_request(GPIO_FN_DV_CLK, NULL);
929         gpio_request(GPIO_FN_DV_VSYNC, NULL);
930         gpio_request(GPIO_FN_DV_HSYNC, NULL);
931
932         return platform_add_devices(ms7724se_devices,
933                                     ARRAY_SIZE(ms7724se_devices));
934 }
935 device_initcall(devices_setup);
936
937 static struct sh_machine_vector mv_ms7724se __initmv = {
938         .mv_name        = "ms7724se",
939         .mv_init_irq    = init_se7724_IRQ,
940         .mv_nr_irqs     = SE7724_FPGA_IRQ_BASE + SE7724_FPGA_IRQ_NR,
941 };