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