blob: 89c5a715d0b6ad538c7224da5a0779130edc6eb9 [file] [log] [blame]
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001/*
2 * Copyright (C) 2009 Renesas Solutions Corp.
3 *
4 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/platform_device.h>
14#include <linux/mtd/physmap.h>
15#include <linux/gpio.h>
16#include <linux/interrupt.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000017#include <linux/io.h>
18#include <linux/delay.h>
Kuninori Morimoto907050a2009-08-26 11:04:31 +000019#include <linux/usb/r8a66597.h>
Kuninori Morimoto4907d572009-09-10 01:39:58 +000020#include <linux/i2c.h>
Kuninori Morimoto8810e052009-09-28 08:21:41 +000021#include <linux/i2c/tsc2007.h>
Magnus Damm1ce4da72009-12-07 14:05:45 +000022#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>
Kuninori Morimotoe9103e72009-09-14 11:23:00 +000026#include <linux/input.h>
Magnus Dammfc1d0032009-11-27 07:32:24 +000027#include <linux/input/sh_keysc.h>
Magnus Damm98779ad2009-11-27 04:36:58 +000028#include <linux/mfd/sh_mobile_sdhi.h>
Kuninori Morimotofa3ba512009-08-26 11:04:34 +000029#include <video/sh_mobile_lcdc.h>
Kuninori Morimoto2153ad32009-08-26 11:04:36 +000030#include <media/sh_mobile_ceu.h>
Kuninori Morimoto207efd02009-12-15 05:37:16 +000031#include <media/tw9910.h>
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +000032#include <media/mt9t112.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000033#include <asm/heartbeat.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000034#include <asm/sh_eth.h>
Kuninori Morimotoa9918012009-09-14 11:23:16 +000035#include <asm/clock.h>
Magnus Dammeb0cd9e2009-10-30 04:23:59 +000036#include <asm/suspend.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000037#include <cpu/sh7724.h>
38
39/*
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000040 * 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
Kuninori Morimoto4138b742009-08-19 12:08:33 +000048 */
49
Kuninori Morimoto9c472c42009-10-02 07:52:20 +000050/* 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
Kuninori Morimoto4138b742009-08-19 12:08:33 +000064/* Heartbeat */
65static unsigned char led_pos[] = { 0, 1, 2, 3 };
66static struct heartbeat_data heartbeat_data = {
67 .regsize = 8,
68 .nr_bits = 4,
69 .bit_pos = led_pos,
70};
71
72static struct resource heartbeat_resources[] = {
73 [0] = {
74 .start = 0xA405012C, /* PTG */
75 .end = 0xA405012E - 1,
76 .flags = IORESOURCE_MEM,
77 },
78};
79
80static 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 */
91static struct mtd_partition nor_flash_partitions[] = {
92 {
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000093 .name = "boot loader",
Kuninori Morimoto4138b742009-08-19 12:08:33 +000094 .offset = 0,
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000095 .size = (5 * 1024 * 1024),
Kuninori Morimotod5ce0102009-09-30 00:50:30 +000096 .mask_flags = MTD_WRITEABLE, /* force read-only */
Kuninori Morimoto4138b742009-08-19 12:08:33 +000097 }, {
Kuninori Morimoto4138b742009-08-19 12:08:33 +000098 .name = "free-area",
99 .offset = MTDPART_OFS_APPEND,
100 .size = MTDPART_SIZ_FULL,
101 },
102};
103
104static 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
110static struct resource nor_flash_resources[] = {
111 [0] = {
112 .name = "NOR Flash",
113 .start = 0x00000000,
114 .end = 0x03ffffff,
115 .flags = IORESOURCE_MEM,
116 }
117};
118
119static 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
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000128/* 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)
132static 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
144struct sh_eth_plat_data sh_eth_plat = {
145 .phy = 0x1f, /* SMSC LAN8700 */
146 .edmac_endian = EDMAC_LITTLE_ENDIAN,
Kuninori Morimotoacf3cc22009-09-24 06:28:27 +0000147 .ether_link_active_low = 1
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000148};
149
150static 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,
Magnus Damm40e42312009-10-26 10:41:58 +0000158 .archdata = {
159 .hwblk_id = HWBLK_ETHER,
160 },
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000161};
162
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000163/* USB0 host */
164void usb0_port_power(int port, int power)
165{
166 gpio_set_value(GPIO_PTB4, power);
167}
168
169static struct r8a66597_platdata usb0_host_data = {
170 .on_chip = 1,
171 .port_power = usb0_port_power,
172};
173
174static 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
187static 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
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000199/* USB1 host/function */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000200void usb1_port_power(int port, int power)
201{
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000202 gpio_set_value(GPIO_PTB5, power);
203}
204
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000205static struct r8a66597_platdata usb1_common_data = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000206 .on_chip = 1,
207 .port_power = usb1_port_power,
208};
209
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000210static struct resource usb1_common_resources[] = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000211 [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
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000223static struct platform_device usb1_common_device = {
224 /* .name will be added in arch_setup */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000225 .id = 1,
226 .dev = {
227 .dma_mask = NULL, /* not use dma */
228 .coherent_dma_mask = 0xffffffff,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000229 .platform_data = &usb1_common_data,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000230 },
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000231 .num_resources = ARRAY_SIZE(usb1_common_resources),
232 .resource = usb1_common_resources,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000233};
234
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000235/* LCDC */
236static struct sh_mobile_lcdc_info lcdc_info = {
237 .ch[0] = {
238 .interface_type = RGB18,
239 .chan = LCDC_CHAN_MAINLCD,
240 .bpp = 16,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000241 .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
253static struct resource lcdc_resources[] = {
254 [0] = {
255 .name = "LCDC",
256 .start = 0xfe940000,
Phil Edworthya6f15ad2009-09-15 12:00:30 +0000257 .end = 0xfe942fff,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000258 .flags = IORESOURCE_MEM,
259 },
260 [1] = {
261 .start = 106,
262 .flags = IORESOURCE_IRQ,
263 },
264};
265
266static 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
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000278/* CEU0 */
279static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
280 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
281};
282
283static 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
299static 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 */
313static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
314 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
315};
316
317static 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
333static 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
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000346/* I2C device */
347static struct i2c_board_info i2c1_devices[] = {
348 {
349 I2C_BOARD_INFO("r2025sd", 0x32),
350 },
351};
352
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000353/* KEYSC */
354static 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
367static 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
380static 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
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000393/* TouchScreen */
394#define IRQ0 32
395static 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
410static int ts_init(void)
411{
412 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
413 return 0;
414}
415
416struct 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
423static 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
Magnus Damm1ce4da72009-12-07 14:05:45 +0000430#ifdef CONFIG_MFD_SH_MOBILE_SDHI
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000431/* SHDI0 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000432static void sdhi0_set_pwr(struct platform_device *pdev, int state)
433{
434 gpio_set_value(GPIO_PTB6, state);
435}
436
437static struct sh_mobile_sdhi_info sdhi0_info = {
438 .set_pwr = sdhi0_set_pwr,
439};
440
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000441static 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
454static struct platform_device sdhi0_device = {
455 .name = "sh_mobile_sdhi",
456 .num_resources = ARRAY_SIZE(sdhi0_resources),
457 .resource = sdhi0_resources,
458 .id = 0,
Magnus Damm98779ad2009-11-27 04:36:58 +0000459 .dev = {
460 .platform_data = &sdhi0_info,
461 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000462 .archdata = {
463 .hwblk_id = HWBLK_SDHI0,
464 },
465};
466
467/* SHDI1 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000468static void sdhi1_set_pwr(struct platform_device *pdev, int state)
469{
470 gpio_set_value(GPIO_PTB7, state);
471}
472
473static struct sh_mobile_sdhi_info sdhi1_info = {
474 .set_pwr = sdhi1_set_pwr,
475};
476
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000477static 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
490static struct platform_device sdhi1_device = {
491 .name = "sh_mobile_sdhi",
492 .num_resources = ARRAY_SIZE(sdhi1_resources),
493 .resource = sdhi1_resources,
494 .id = 1,
Magnus Damm98779ad2009-11-27 04:36:58 +0000495 .dev = {
496 .platform_data = &sdhi1_info,
497 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000498 .archdata = {
499 .hwblk_id = HWBLK_SDHI1,
500 },
501};
502
Magnus Damm1ce4da72009-12-07 14:05:45 +0000503#else
504
505static int mmc_spi_get_ro(struct device *dev)
506{
507 return gpio_get_value(GPIO_PTY6);
508}
509
510static int mmc_spi_get_cd(struct device *dev)
511{
512 return !gpio_get_value(GPIO_PTY7);
513}
514
515static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
516{
517 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
518}
519
520static 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
528static 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
538static struct sh_msiof_spi_info msiof0_data = {
539 .num_chipselect = 1,
540};
541
542static 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
555static 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
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000570/* I2C Video/Camera */
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000571static struct i2c_board_info i2c_camera[] = {
572 {
573 I2C_BOARD_INFO("tw9910", 0x45),
574 },
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000575 {
576 /* 1st camera */
577 I2C_BOARD_INFO("mt9t112", 0x3c),
578 },
579 {
580 /* 2nd camera */
581 I2C_BOARD_INFO("mt9t112", 0x3c),
582 },
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000583};
584
585/* tw9910 */
586static 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
597static struct tw9910_video_info tw9910_info = {
598 .buswidth = SOCAM_DATAWIDTH_8,
599 .mpout = TW9910_MPO_FIELD,
600};
601
602static 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
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000611/* mt9t112 */
612static 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
621static 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
626static 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
635static 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
644static 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
649static 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};
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000657
658static struct platform_device camera_devices[] = {
659 {
660 .name = "soc-camera-pdrv",
661 .id = 0,
662 .dev = {
663 .platform_data = &tw9910_link,
664 },
665 },
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000666 {
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 },
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000680};
681
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000682static struct platform_device *ecovec_devices[] __initdata = {
683 &heartbeat_device,
684 &nor_flash_device,
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000685 &sh_eth_device,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000686 &usb0_host_device,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000687 &usb1_common_device,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000688 &lcdc_device,
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000689 &ceu0_device,
690 &ceu1_device,
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000691 &keysc_device,
Magnus Damm1ce4da72009-12-07 14:05:45 +0000692#ifdef CONFIG_MFD_SH_MOBILE_SDHI
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000693 &sdhi0_device,
694 &sdhi1_device,
Magnus Damm1ce4da72009-12-07 14:05:45 +0000695#else
696 &msiof0_device,
697#endif
Kuninori Morimoto207efd02009-12-15 05:37:16 +0000698 &camera_devices[0],
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +0000699 &camera_devices[1],
700 &camera_devices[2],
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000701};
702
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000703#define EEPROM_ADDR 0x50
704static 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
Magnus Damm376abbb2009-10-26 10:44:37 +0000729static void __init sh_eth_init(struct sh_eth_plat_data *pd)
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000730{
731 struct i2c_adapter *a = i2c_get_adapter(1);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000732 int i;
733
734 if (!a) {
735 pr_err("can not get I2C 1\n");
736 return;
737 }
738
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000739 /* read MAC address frome EEPROM */
Magnus Damm376abbb2009-10-26 10:44:37 +0000740 for (i = 0; i < sizeof(pd->mac_addr); i++) {
741 pd->mac_addr[i] = mac_read(a, 0x10 + i);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000742 msleep(10);
743 }
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000744}
745
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000746#define PORT_HIZA 0xA4050158
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000747#define IODRIVEA 0xA405018A
Magnus Dammeb0cd9e2009-10-30 04:23:59 +0000748
749extern char ecovec24_sdram_enter_start;
750extern char ecovec24_sdram_enter_end;
751extern char ecovec24_sdram_leave_start;
752extern char ecovec24_sdram_leave_end;
753
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000754static int __init arch_setup(void)
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000755{
Magnus Dammeb0cd9e2009-10-30 04:23:59 +0000756 /* 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
Magnus Dammf78bab32009-10-07 09:00:06 +0000763 /* 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
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000768 /* enable SCIFA0 */
769 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
770 gpio_request(GPIO_FN_SCIF0_RXD, NULL);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000771
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);
Kuninori Morimotob7056bc2009-08-26 11:04:22 +0000777 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);
Kuninori Morimoto643e9d12009-09-10 01:40:00 +0000781 ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000782
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000783 /* 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
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000800 /* enable USB */
Kuninori Morimotobe4ebf92009-09-10 01:39:55 +0000801 ctrl_outw(0x0000, 0xA4D80000);
Kuninori Morimoto147df2d2009-09-14 11:22:31 +0000802 ctrl_outw(0x0000, 0xA4D90000);
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000803 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
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000812 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
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000820 /* 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
Kuninori Morimoto82b33222009-12-02 09:35:42 +0000862 /* I/O buffer drive ability is high */
863 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000864
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000865 if (gpio_get_value(GPIO_PTE6)) {
866 /* DVI */
867 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000868 lcdc_info.ch[0].clock_divider = 1,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000869 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 */
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000883
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);
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000906
907 /* enable TouchScreen */
908 i2c_register_board_info(0, &ts_i2c_clients, 1);
909 set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000910 }
911
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000912 /* 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
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000950 /* 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
Kuninori Morimoto064a16d2009-09-16 11:34:34 +0000959 /* 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
Magnus Damm1ce4da72009-12-07 14:05:45 +0000969#ifdef CONFIG_MFD_SH_MOBILE_SDHI
970 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000971 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);
Magnus Damm98779ad2009-11-27 04:36:58 +0000979 gpio_request(GPIO_PTB6, NULL);
980 gpio_direction_output(GPIO_PTB6, 0);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000981
Magnus Damm1ce4da72009-12-07 14:05:45 +0000982 /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000983 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);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000991 gpio_request(GPIO_PTB7, NULL);
Magnus Damm98779ad2009-11-27 04:36:58 +0000992 gpio_direction_output(GPIO_PTB7, 0);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000993
994 /* I/O buffer drive ability is high for SDHI1 */
995 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
Magnus Damm1ce4da72009-12-07 14:05:45 +0000996#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
Kuninori Morimoto96987d92009-10-02 07:54:42 +00001012
Kuninori Morimoto207efd02009-12-15 05:37:16 +00001013 /* enable Video */
1014 gpio_request(GPIO_PTU2, NULL);
1015 gpio_direction_output(GPIO_PTU2, 1);
1016
Kuninori Morimoto9aa25d62009-12-15 05:37:26 +00001017 /* 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
Kuninori Morimoto125ecce2009-09-10 01:39:37 +00001023 /* enable I2C device */
1024 i2c_register_board_info(1, i2c1_devices,
1025 ARRAY_SIZE(i2c1_devices));
1026
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001027 return platform_add_devices(ecovec_devices,
1028 ARRAY_SIZE(ecovec_devices));
1029}
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001030arch_initcall(arch_setup);
1031
1032static int __init devices_setup(void)
1033{
Magnus Damm376abbb2009-10-26 10:44:37 +00001034 sh_eth_init(&sh_eth_plat);
Kuninori Morimoto4907d572009-09-10 01:39:58 +00001035 return 0;
1036}
1037device_initcall(devices_setup);
1038
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001039static struct sh_machine_vector mv_ecovec __initmv = {
1040 .mv_name = "R0P7724 (EcoVec)",
1041};