blob: cfd958c613d4ab60a9b0235e36ff52d1f110d110 [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 Morimoto4138b742009-08-19 12:08:33 +000031#include <asm/heartbeat.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000032#include <asm/sh_eth.h>
Kuninori Morimotoa9918012009-09-14 11:23:16 +000033#include <asm/clock.h>
Magnus Dammeb0cd9e2009-10-30 04:23:59 +000034#include <asm/suspend.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000035#include <cpu/sh7724.h>
36
37/*
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000038 * Address Interface BusWidth
39 *-----------------------------------------
40 * 0x0000_0000 uboot 16bit
41 * 0x0004_0000 Linux romImage 16bit
42 * 0x0014_0000 MTD for Linux 16bit
43 * 0x0400_0000 Internal I/O 16/32bit
44 * 0x0800_0000 DRAM 32bit
45 * 0x1800_0000 MFI 16bit
Kuninori Morimoto4138b742009-08-19 12:08:33 +000046 */
47
Kuninori Morimoto9c472c42009-10-02 07:52:20 +000048/* SWITCH
49 *------------------------------
50 * DS2[1] = FlashROM write protect ON : write protect
51 * OFF : No write protect
52 * DS2[2] = RMII / TS, SCIF ON : RMII
53 * OFF : TS, SCIF3
54 * DS2[3] = Camera / Video ON : Camera
55 * OFF : NTSC/PAL (IN)
56 * DS2[5] = NTSC_OUT Clock ON : On board OSC
57 * OFF : SH7724 DV_CLK
58 * DS2[6-7] = MMC / SD ON-OFF : SD
59 * OFF-ON : MMC
60 */
61
Kuninori Morimoto4138b742009-08-19 12:08:33 +000062/* Heartbeat */
63static unsigned char led_pos[] = { 0, 1, 2, 3 };
64static struct heartbeat_data heartbeat_data = {
65 .regsize = 8,
66 .nr_bits = 4,
67 .bit_pos = led_pos,
68};
69
70static struct resource heartbeat_resources[] = {
71 [0] = {
72 .start = 0xA405012C, /* PTG */
73 .end = 0xA405012E - 1,
74 .flags = IORESOURCE_MEM,
75 },
76};
77
78static struct platform_device heartbeat_device = {
79 .name = "heartbeat",
80 .id = -1,
81 .dev = {
82 .platform_data = &heartbeat_data,
83 },
84 .num_resources = ARRAY_SIZE(heartbeat_resources),
85 .resource = heartbeat_resources,
86};
87
88/* MTD */
89static struct mtd_partition nor_flash_partitions[] = {
90 {
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000091 .name = "boot loader",
Kuninori Morimoto4138b742009-08-19 12:08:33 +000092 .offset = 0,
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000093 .size = (5 * 1024 * 1024),
Kuninori Morimotod5ce0102009-09-30 00:50:30 +000094 .mask_flags = MTD_WRITEABLE, /* force read-only */
Kuninori Morimoto4138b742009-08-19 12:08:33 +000095 }, {
Kuninori Morimoto4138b742009-08-19 12:08:33 +000096 .name = "free-area",
97 .offset = MTDPART_OFS_APPEND,
98 .size = MTDPART_SIZ_FULL,
99 },
100};
101
102static struct physmap_flash_data nor_flash_data = {
103 .width = 2,
104 .parts = nor_flash_partitions,
105 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
106};
107
108static struct resource nor_flash_resources[] = {
109 [0] = {
110 .name = "NOR Flash",
111 .start = 0x00000000,
112 .end = 0x03ffffff,
113 .flags = IORESOURCE_MEM,
114 }
115};
116
117static struct platform_device nor_flash_device = {
118 .name = "physmap-flash",
119 .resource = nor_flash_resources,
120 .num_resources = ARRAY_SIZE(nor_flash_resources),
121 .dev = {
122 .platform_data = &nor_flash_data,
123 },
124};
125
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000126/* SH Eth */
127#define SH_ETH_ADDR (0xA4600000)
128#define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
129#define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
130static struct resource sh_eth_resources[] = {
131 [0] = {
132 .start = SH_ETH_ADDR,
133 .end = SH_ETH_ADDR + 0x1FC,
134 .flags = IORESOURCE_MEM,
135 },
136 [1] = {
137 .start = 91,
138 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
139 },
140};
141
142struct sh_eth_plat_data sh_eth_plat = {
143 .phy = 0x1f, /* SMSC LAN8700 */
144 .edmac_endian = EDMAC_LITTLE_ENDIAN,
Kuninori Morimotoacf3cc22009-09-24 06:28:27 +0000145 .ether_link_active_low = 1
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000146};
147
148static struct platform_device sh_eth_device = {
149 .name = "sh-eth",
150 .id = 0,
151 .dev = {
152 .platform_data = &sh_eth_plat,
153 },
154 .num_resources = ARRAY_SIZE(sh_eth_resources),
155 .resource = sh_eth_resources,
Magnus Damm40e42312009-10-26 10:41:58 +0000156 .archdata = {
157 .hwblk_id = HWBLK_ETHER,
158 },
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000159};
160
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000161/* USB0 host */
162void usb0_port_power(int port, int power)
163{
164 gpio_set_value(GPIO_PTB4, power);
165}
166
167static struct r8a66597_platdata usb0_host_data = {
168 .on_chip = 1,
169 .port_power = usb0_port_power,
170};
171
172static struct resource usb0_host_resources[] = {
173 [0] = {
174 .start = 0xa4d80000,
175 .end = 0xa4d80124 - 1,
176 .flags = IORESOURCE_MEM,
177 },
178 [1] = {
179 .start = 65,
180 .end = 65,
181 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
182 },
183};
184
185static struct platform_device usb0_host_device = {
186 .name = "r8a66597_hcd",
187 .id = 0,
188 .dev = {
189 .dma_mask = NULL, /* not use dma */
190 .coherent_dma_mask = 0xffffffff,
191 .platform_data = &usb0_host_data,
192 },
193 .num_resources = ARRAY_SIZE(usb0_host_resources),
194 .resource = usb0_host_resources,
195};
196
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000197/* USB1 host/function */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000198void usb1_port_power(int port, int power)
199{
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000200 gpio_set_value(GPIO_PTB5, power);
201}
202
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000203static struct r8a66597_platdata usb1_common_data = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000204 .on_chip = 1,
205 .port_power = usb1_port_power,
206};
207
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000208static struct resource usb1_common_resources[] = {
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000209 [0] = {
210 .start = 0xa4d90000,
211 .end = 0xa4d90124 - 1,
212 .flags = IORESOURCE_MEM,
213 },
214 [1] = {
215 .start = 66,
216 .end = 66,
217 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
218 },
219};
220
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000221static struct platform_device usb1_common_device = {
222 /* .name will be added in arch_setup */
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000223 .id = 1,
224 .dev = {
225 .dma_mask = NULL, /* not use dma */
226 .coherent_dma_mask = 0xffffffff,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000227 .platform_data = &usb1_common_data,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000228 },
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000229 .num_resources = ARRAY_SIZE(usb1_common_resources),
230 .resource = usb1_common_resources,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000231};
232
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000233/* LCDC */
234static struct sh_mobile_lcdc_info lcdc_info = {
235 .ch[0] = {
236 .interface_type = RGB18,
237 .chan = LCDC_CHAN_MAINLCD,
238 .bpp = 16,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000239 .lcd_cfg = {
240 .sync = 0, /* hsync and vsync are active low */
241 },
242 .lcd_size_cfg = { /* 7.0 inch */
243 .width = 152,
244 .height = 91,
245 },
246 .board_cfg = {
247 },
248 }
249};
250
251static struct resource lcdc_resources[] = {
252 [0] = {
253 .name = "LCDC",
254 .start = 0xfe940000,
Phil Edworthya6f15ad2009-09-15 12:00:30 +0000255 .end = 0xfe942fff,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000256 .flags = IORESOURCE_MEM,
257 },
258 [1] = {
259 .start = 106,
260 .flags = IORESOURCE_IRQ,
261 },
262};
263
264static struct platform_device lcdc_device = {
265 .name = "sh_mobile_lcdc_fb",
266 .num_resources = ARRAY_SIZE(lcdc_resources),
267 .resource = lcdc_resources,
268 .dev = {
269 .platform_data = &lcdc_info,
270 },
271 .archdata = {
272 .hwblk_id = HWBLK_LCDC,
273 },
274};
275
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000276/* CEU0 */
277static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
278 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
279};
280
281static struct resource ceu0_resources[] = {
282 [0] = {
283 .name = "CEU0",
284 .start = 0xfe910000,
285 .end = 0xfe91009f,
286 .flags = IORESOURCE_MEM,
287 },
288 [1] = {
289 .start = 52,
290 .flags = IORESOURCE_IRQ,
291 },
292 [2] = {
293 /* place holder for contiguous memory */
294 },
295};
296
297static struct platform_device ceu0_device = {
298 .name = "sh_mobile_ceu",
299 .id = 0, /* "ceu0" clock */
300 .num_resources = ARRAY_SIZE(ceu0_resources),
301 .resource = ceu0_resources,
302 .dev = {
303 .platform_data = &sh_mobile_ceu0_info,
304 },
305 .archdata = {
306 .hwblk_id = HWBLK_CEU0,
307 },
308};
309
310/* CEU1 */
311static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
312 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
313};
314
315static struct resource ceu1_resources[] = {
316 [0] = {
317 .name = "CEU1",
318 .start = 0xfe914000,
319 .end = 0xfe91409f,
320 .flags = IORESOURCE_MEM,
321 },
322 [1] = {
323 .start = 63,
324 .flags = IORESOURCE_IRQ,
325 },
326 [2] = {
327 /* place holder for contiguous memory */
328 },
329};
330
331static struct platform_device ceu1_device = {
332 .name = "sh_mobile_ceu",
333 .id = 1, /* "ceu1" clock */
334 .num_resources = ARRAY_SIZE(ceu1_resources),
335 .resource = ceu1_resources,
336 .dev = {
337 .platform_data = &sh_mobile_ceu1_info,
338 },
339 .archdata = {
340 .hwblk_id = HWBLK_CEU1,
341 },
342};
343
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000344/* I2C device */
345static struct i2c_board_info i2c1_devices[] = {
346 {
347 I2C_BOARD_INFO("r2025sd", 0x32),
348 },
349};
350
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000351/* KEYSC */
352static struct sh_keysc_info keysc_info = {
353 .mode = SH_KEYSC_MODE_1,
354 .scan_timing = 3,
355 .delay = 50,
356 .kycr2_delay = 100,
357 .keycodes = { KEY_1, 0, 0, 0, 0,
358 KEY_2, 0, 0, 0, 0,
359 KEY_3, 0, 0, 0, 0,
360 KEY_4, 0, 0, 0, 0,
361 KEY_5, 0, 0, 0, 0,
362 KEY_6, 0, 0, 0, 0, },
363};
364
365static struct resource keysc_resources[] = {
366 [0] = {
367 .name = "KEYSC",
368 .start = 0x044b0000,
369 .end = 0x044b000f,
370 .flags = IORESOURCE_MEM,
371 },
372 [1] = {
373 .start = 79,
374 .flags = IORESOURCE_IRQ,
375 },
376};
377
378static struct platform_device keysc_device = {
379 .name = "sh_keysc",
380 .id = 0, /* keysc0 clock */
381 .num_resources = ARRAY_SIZE(keysc_resources),
382 .resource = keysc_resources,
383 .dev = {
384 .platform_data = &keysc_info,
385 },
386 .archdata = {
387 .hwblk_id = HWBLK_KEYSC,
388 },
389};
390
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000391/* TouchScreen */
392#define IRQ0 32
393static int ts_get_pendown_state(void)
394{
395 int val = 0;
396 gpio_free(GPIO_FN_INTC_IRQ0);
397 gpio_request(GPIO_PTZ0, NULL);
398 gpio_direction_input(GPIO_PTZ0);
399
400 val = gpio_get_value(GPIO_PTZ0);
401
402 gpio_free(GPIO_PTZ0);
403 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
404
405 return val ? 0 : 1;
406}
407
408static int ts_init(void)
409{
410 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
411 return 0;
412}
413
414struct tsc2007_platform_data tsc2007_info = {
415 .model = 2007,
416 .x_plate_ohms = 180,
417 .get_pendown_state = ts_get_pendown_state,
418 .init_platform_hw = ts_init,
419};
420
421static struct i2c_board_info ts_i2c_clients = {
422 I2C_BOARD_INFO("tsc2007", 0x48),
423 .type = "tsc2007",
424 .platform_data = &tsc2007_info,
425 .irq = IRQ0,
426};
427
Magnus Damm1ce4da72009-12-07 14:05:45 +0000428#ifdef CONFIG_MFD_SH_MOBILE_SDHI
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000429/* SHDI0 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000430static void sdhi0_set_pwr(struct platform_device *pdev, int state)
431{
432 gpio_set_value(GPIO_PTB6, state);
433}
434
435static struct sh_mobile_sdhi_info sdhi0_info = {
436 .set_pwr = sdhi0_set_pwr,
437};
438
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000439static struct resource sdhi0_resources[] = {
440 [0] = {
441 .name = "SDHI0",
442 .start = 0x04ce0000,
443 .end = 0x04ce01ff,
444 .flags = IORESOURCE_MEM,
445 },
446 [1] = {
447 .start = 101,
448 .flags = IORESOURCE_IRQ,
449 },
450};
451
452static struct platform_device sdhi0_device = {
453 .name = "sh_mobile_sdhi",
454 .num_resources = ARRAY_SIZE(sdhi0_resources),
455 .resource = sdhi0_resources,
456 .id = 0,
Magnus Damm98779ad2009-11-27 04:36:58 +0000457 .dev = {
458 .platform_data = &sdhi0_info,
459 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000460 .archdata = {
461 .hwblk_id = HWBLK_SDHI0,
462 },
463};
464
465/* SHDI1 */
Magnus Damm98779ad2009-11-27 04:36:58 +0000466static void sdhi1_set_pwr(struct platform_device *pdev, int state)
467{
468 gpio_set_value(GPIO_PTB7, state);
469}
470
471static struct sh_mobile_sdhi_info sdhi1_info = {
472 .set_pwr = sdhi1_set_pwr,
473};
474
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000475static struct resource sdhi1_resources[] = {
476 [0] = {
477 .name = "SDHI1",
478 .start = 0x04cf0000,
479 .end = 0x04cf01ff,
480 .flags = IORESOURCE_MEM,
481 },
482 [1] = {
483 .start = 24,
484 .flags = IORESOURCE_IRQ,
485 },
486};
487
488static struct platform_device sdhi1_device = {
489 .name = "sh_mobile_sdhi",
490 .num_resources = ARRAY_SIZE(sdhi1_resources),
491 .resource = sdhi1_resources,
492 .id = 1,
Magnus Damm98779ad2009-11-27 04:36:58 +0000493 .dev = {
494 .platform_data = &sdhi1_info,
495 },
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000496 .archdata = {
497 .hwblk_id = HWBLK_SDHI1,
498 },
499};
500
Magnus Damm1ce4da72009-12-07 14:05:45 +0000501#else
502
503static int mmc_spi_get_ro(struct device *dev)
504{
505 return gpio_get_value(GPIO_PTY6);
506}
507
508static int mmc_spi_get_cd(struct device *dev)
509{
510 return !gpio_get_value(GPIO_PTY7);
511}
512
513static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
514{
515 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
516}
517
518static struct mmc_spi_platform_data mmc_spi_info = {
519 .get_ro = mmc_spi_get_ro,
520 .get_cd = mmc_spi_get_cd,
521 .caps = MMC_CAP_NEEDS_POLL,
522 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
523 .setpower = mmc_spi_setpower,
524};
525
526static struct spi_board_info spi_bus[] = {
527 {
528 .modalias = "mmc_spi",
529 .platform_data = &mmc_spi_info,
530 .max_speed_hz = 5000000,
531 .mode = SPI_MODE_0,
532 .controller_data = (void *) GPIO_PTM4,
533 },
534};
535
536static struct sh_msiof_spi_info msiof0_data = {
537 .num_chipselect = 1,
538};
539
540static struct resource msiof0_resources[] = {
541 [0] = {
542 .name = "MSIOF0",
543 .start = 0xa4c40000,
544 .end = 0xa4c40063,
545 .flags = IORESOURCE_MEM,
546 },
547 [1] = {
548 .start = 84,
549 .flags = IORESOURCE_IRQ,
550 },
551};
552
553static struct platform_device msiof0_device = {
554 .name = "spi_sh_msiof",
555 .id = 0, /* MSIOF0 */
556 .dev = {
557 .platform_data = &msiof0_data,
558 },
559 .num_resources = ARRAY_SIZE(msiof0_resources),
560 .resource = msiof0_resources,
561 .archdata = {
562 .hwblk_id = HWBLK_MSIOF0,
563 },
564};
565
566#endif
567
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000568static struct platform_device *ecovec_devices[] __initdata = {
569 &heartbeat_device,
570 &nor_flash_device,
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000571 &sh_eth_device,
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000572 &usb0_host_device,
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000573 &usb1_common_device,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000574 &lcdc_device,
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000575 &ceu0_device,
576 &ceu1_device,
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000577 &keysc_device,
Magnus Damm1ce4da72009-12-07 14:05:45 +0000578#ifdef CONFIG_MFD_SH_MOBILE_SDHI
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000579 &sdhi0_device,
580 &sdhi1_device,
Magnus Damm1ce4da72009-12-07 14:05:45 +0000581#else
582 &msiof0_device,
583#endif
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000584};
585
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000586#define EEPROM_ADDR 0x50
587static u8 mac_read(struct i2c_adapter *a, u8 command)
588{
589 struct i2c_msg msg[2];
590 u8 buf;
591 int ret;
592
593 msg[0].addr = EEPROM_ADDR;
594 msg[0].flags = 0;
595 msg[0].len = 1;
596 msg[0].buf = &command;
597
598 msg[1].addr = EEPROM_ADDR;
599 msg[1].flags = I2C_M_RD;
600 msg[1].len = 1;
601 msg[1].buf = &buf;
602
603 ret = i2c_transfer(a, msg, 2);
604 if (ret < 0) {
605 printk(KERN_ERR "error %d\n", ret);
606 buf = 0xff;
607 }
608
609 return buf;
610}
611
Magnus Damm376abbb2009-10-26 10:44:37 +0000612static void __init sh_eth_init(struct sh_eth_plat_data *pd)
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000613{
614 struct i2c_adapter *a = i2c_get_adapter(1);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000615 int i;
616
617 if (!a) {
618 pr_err("can not get I2C 1\n");
619 return;
620 }
621
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000622 /* read MAC address frome EEPROM */
Magnus Damm376abbb2009-10-26 10:44:37 +0000623 for (i = 0; i < sizeof(pd->mac_addr); i++) {
624 pd->mac_addr[i] = mac_read(a, 0x10 + i);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000625 msleep(10);
626 }
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000627}
628
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000629#define PORT_HIZA 0xA4050158
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000630#define IODRIVEA 0xA405018A
Magnus Dammeb0cd9e2009-10-30 04:23:59 +0000631
632extern char ecovec24_sdram_enter_start;
633extern char ecovec24_sdram_enter_end;
634extern char ecovec24_sdram_leave_start;
635extern char ecovec24_sdram_leave_end;
636
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000637static int __init arch_setup(void)
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000638{
Magnus Dammeb0cd9e2009-10-30 04:23:59 +0000639 /* register board specific self-refresh code */
640 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
641 &ecovec24_sdram_enter_start,
642 &ecovec24_sdram_enter_end,
643 &ecovec24_sdram_leave_start,
644 &ecovec24_sdram_leave_end);
645
Magnus Dammf78bab32009-10-07 09:00:06 +0000646 /* enable STATUS0, STATUS2 and PDSTATUS */
647 gpio_request(GPIO_FN_STATUS0, NULL);
648 gpio_request(GPIO_FN_STATUS2, NULL);
649 gpio_request(GPIO_FN_PDSTATUS, NULL);
650
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000651 /* enable SCIFA0 */
652 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
653 gpio_request(GPIO_FN_SCIF0_RXD, NULL);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000654
655 /* enable debug LED */
656 gpio_request(GPIO_PTG0, NULL);
657 gpio_request(GPIO_PTG1, NULL);
658 gpio_request(GPIO_PTG2, NULL);
659 gpio_request(GPIO_PTG3, NULL);
Kuninori Morimotob7056bc2009-08-26 11:04:22 +0000660 gpio_direction_output(GPIO_PTG0, 0);
661 gpio_direction_output(GPIO_PTG1, 0);
662 gpio_direction_output(GPIO_PTG2, 0);
663 gpio_direction_output(GPIO_PTG3, 0);
Kuninori Morimoto643e9d12009-09-10 01:40:00 +0000664 ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000665
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000666 /* enable SH-Eth */
667 gpio_request(GPIO_PTA1, NULL);
668 gpio_direction_output(GPIO_PTA1, 1);
669 mdelay(20);
670
671 gpio_request(GPIO_FN_RMII_RXD0, NULL);
672 gpio_request(GPIO_FN_RMII_RXD1, NULL);
673 gpio_request(GPIO_FN_RMII_TXD0, NULL);
674 gpio_request(GPIO_FN_RMII_TXD1, NULL);
675 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
676 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
677 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
678 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
679 gpio_request(GPIO_FN_MDIO, NULL);
680 gpio_request(GPIO_FN_MDC, NULL);
681 gpio_request(GPIO_FN_LNKSTA, NULL);
682
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000683 /* enable USB */
Kuninori Morimotobe4ebf92009-09-10 01:39:55 +0000684 ctrl_outw(0x0000, 0xA4D80000);
Kuninori Morimoto147df2d2009-09-14 11:22:31 +0000685 ctrl_outw(0x0000, 0xA4D90000);
Kuninori Morimoto907050a2009-08-26 11:04:31 +0000686 gpio_request(GPIO_PTB3, NULL);
687 gpio_request(GPIO_PTB4, NULL);
688 gpio_request(GPIO_PTB5, NULL);
689 gpio_direction_input(GPIO_PTB3);
690 gpio_direction_output(GPIO_PTB4, 0);
691 gpio_direction_output(GPIO_PTB5, 0);
692 ctrl_outw(0x0600, 0xa40501d4);
693 ctrl_outw(0x0600, 0xa4050192);
694
Kuninori Morimoto3714a9a2009-10-28 06:31:57 +0000695 if (gpio_get_value(GPIO_PTB3)) {
696 printk(KERN_INFO "USB1 function is selected\n");
697 usb1_common_device.name = "r8a66597_udc";
698 } else {
699 printk(KERN_INFO "USB1 host is selected\n");
700 usb1_common_device.name = "r8a66597_hcd";
701 }
702
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000703 /* enable LCDC */
704 gpio_request(GPIO_FN_LCDD23, NULL);
705 gpio_request(GPIO_FN_LCDD22, NULL);
706 gpio_request(GPIO_FN_LCDD21, NULL);
707 gpio_request(GPIO_FN_LCDD20, NULL);
708 gpio_request(GPIO_FN_LCDD19, NULL);
709 gpio_request(GPIO_FN_LCDD18, NULL);
710 gpio_request(GPIO_FN_LCDD17, NULL);
711 gpio_request(GPIO_FN_LCDD16, NULL);
712 gpio_request(GPIO_FN_LCDD15, NULL);
713 gpio_request(GPIO_FN_LCDD14, NULL);
714 gpio_request(GPIO_FN_LCDD13, NULL);
715 gpio_request(GPIO_FN_LCDD12, NULL);
716 gpio_request(GPIO_FN_LCDD11, NULL);
717 gpio_request(GPIO_FN_LCDD10, NULL);
718 gpio_request(GPIO_FN_LCDD9, NULL);
719 gpio_request(GPIO_FN_LCDD8, NULL);
720 gpio_request(GPIO_FN_LCDD7, NULL);
721 gpio_request(GPIO_FN_LCDD6, NULL);
722 gpio_request(GPIO_FN_LCDD5, NULL);
723 gpio_request(GPIO_FN_LCDD4, NULL);
724 gpio_request(GPIO_FN_LCDD3, NULL);
725 gpio_request(GPIO_FN_LCDD2, NULL);
726 gpio_request(GPIO_FN_LCDD1, NULL);
727 gpio_request(GPIO_FN_LCDD0, NULL);
728 gpio_request(GPIO_FN_LCDDISP, NULL);
729 gpio_request(GPIO_FN_LCDHSYN, NULL);
730 gpio_request(GPIO_FN_LCDDCK, NULL);
731 gpio_request(GPIO_FN_LCDVSYN, NULL);
732 gpio_request(GPIO_FN_LCDDON, NULL);
733 gpio_request(GPIO_FN_LCDLCLK, NULL);
734 ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
735
736 gpio_request(GPIO_PTE6, NULL);
737 gpio_request(GPIO_PTU1, NULL);
738 gpio_request(GPIO_PTR1, NULL);
739 gpio_request(GPIO_PTA2, NULL);
740 gpio_direction_input(GPIO_PTE6);
741 gpio_direction_output(GPIO_PTU1, 0);
742 gpio_direction_output(GPIO_PTR1, 0);
743 gpio_direction_output(GPIO_PTA2, 0);
744
Kuninori Morimoto82b33222009-12-02 09:35:42 +0000745 /* I/O buffer drive ability is high */
746 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000747
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000748 if (gpio_get_value(GPIO_PTE6)) {
749 /* DVI */
750 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000751 lcdc_info.ch[0].clock_divider = 1,
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000752 lcdc_info.ch[0].lcd_cfg.name = "DVI";
753 lcdc_info.ch[0].lcd_cfg.xres = 1280;
754 lcdc_info.ch[0].lcd_cfg.yres = 720;
755 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
756 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
757 lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
758 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
759 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
760 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
761
762 gpio_set_value(GPIO_PTA2, 1);
763 gpio_set_value(GPIO_PTU1, 1);
764 } else {
765 /* Panel */
Kuninori Morimotoea15edb2009-08-26 11:04:39 +0000766
767 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
768 lcdc_info.ch[0].clock_divider = 2,
769 lcdc_info.ch[0].lcd_cfg.name = "Panel";
770 lcdc_info.ch[0].lcd_cfg.xres = 800;
771 lcdc_info.ch[0].lcd_cfg.yres = 480;
772 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
773 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
774 lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
775 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
776 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
777 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
778
779 gpio_set_value(GPIO_PTR1, 1);
780
781 /* FIXME
782 *
783 * LCDDON control is needed for Panel,
784 * but current sh_mobile_lcdc driver doesn't control it.
785 * It is temporary correspondence
786 */
787 gpio_request(GPIO_PTF4, NULL);
788 gpio_direction_output(GPIO_PTF4, 1);
Kuninori Morimoto8810e052009-09-28 08:21:41 +0000789
790 /* enable TouchScreen */
791 i2c_register_board_info(0, &ts_i2c_clients, 1);
792 set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
Kuninori Morimotofa3ba512009-08-26 11:04:34 +0000793 }
794
Kuninori Morimoto2153ad32009-08-26 11:04:36 +0000795 /* enable CEU0 */
796 gpio_request(GPIO_FN_VIO0_D15, NULL);
797 gpio_request(GPIO_FN_VIO0_D14, NULL);
798 gpio_request(GPIO_FN_VIO0_D13, NULL);
799 gpio_request(GPIO_FN_VIO0_D12, NULL);
800 gpio_request(GPIO_FN_VIO0_D11, NULL);
801 gpio_request(GPIO_FN_VIO0_D10, NULL);
802 gpio_request(GPIO_FN_VIO0_D9, NULL);
803 gpio_request(GPIO_FN_VIO0_D8, NULL);
804 gpio_request(GPIO_FN_VIO0_D7, NULL);
805 gpio_request(GPIO_FN_VIO0_D6, NULL);
806 gpio_request(GPIO_FN_VIO0_D5, NULL);
807 gpio_request(GPIO_FN_VIO0_D4, NULL);
808 gpio_request(GPIO_FN_VIO0_D3, NULL);
809 gpio_request(GPIO_FN_VIO0_D2, NULL);
810 gpio_request(GPIO_FN_VIO0_D1, NULL);
811 gpio_request(GPIO_FN_VIO0_D0, NULL);
812 gpio_request(GPIO_FN_VIO0_VD, NULL);
813 gpio_request(GPIO_FN_VIO0_CLK, NULL);
814 gpio_request(GPIO_FN_VIO0_FLD, NULL);
815 gpio_request(GPIO_FN_VIO0_HD, NULL);
816 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
817
818 /* enable CEU1 */
819 gpio_request(GPIO_FN_VIO1_D7, NULL);
820 gpio_request(GPIO_FN_VIO1_D6, NULL);
821 gpio_request(GPIO_FN_VIO1_D5, NULL);
822 gpio_request(GPIO_FN_VIO1_D4, NULL);
823 gpio_request(GPIO_FN_VIO1_D3, NULL);
824 gpio_request(GPIO_FN_VIO1_D2, NULL);
825 gpio_request(GPIO_FN_VIO1_D1, NULL);
826 gpio_request(GPIO_FN_VIO1_D0, NULL);
827 gpio_request(GPIO_FN_VIO1_FLD, NULL);
828 gpio_request(GPIO_FN_VIO1_HD, NULL);
829 gpio_request(GPIO_FN_VIO1_VD, NULL);
830 gpio_request(GPIO_FN_VIO1_CLK, NULL);
831 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
832
Kuninori Morimotoe9103e72009-09-14 11:23:00 +0000833 /* enable KEYSC */
834 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
835 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
836 gpio_request(GPIO_FN_KEYOUT3, NULL);
837 gpio_request(GPIO_FN_KEYOUT2, NULL);
838 gpio_request(GPIO_FN_KEYOUT1, NULL);
839 gpio_request(GPIO_FN_KEYOUT0, NULL);
840 gpio_request(GPIO_FN_KEYIN0, NULL);
841
Kuninori Morimoto064a16d2009-09-16 11:34:34 +0000842 /* enable user debug switch */
843 gpio_request(GPIO_PTR0, NULL);
844 gpio_request(GPIO_PTR4, NULL);
845 gpio_request(GPIO_PTR5, NULL);
846 gpio_request(GPIO_PTR6, NULL);
847 gpio_direction_input(GPIO_PTR0);
848 gpio_direction_input(GPIO_PTR4);
849 gpio_direction_input(GPIO_PTR5);
850 gpio_direction_input(GPIO_PTR6);
851
Magnus Damm1ce4da72009-12-07 14:05:45 +0000852#ifdef CONFIG_MFD_SH_MOBILE_SDHI
853 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000854 gpio_request(GPIO_FN_SDHI0CD, NULL);
855 gpio_request(GPIO_FN_SDHI0WP, NULL);
856 gpio_request(GPIO_FN_SDHI0CMD, NULL);
857 gpio_request(GPIO_FN_SDHI0CLK, NULL);
858 gpio_request(GPIO_FN_SDHI0D3, NULL);
859 gpio_request(GPIO_FN_SDHI0D2, NULL);
860 gpio_request(GPIO_FN_SDHI0D1, NULL);
861 gpio_request(GPIO_FN_SDHI0D0, NULL);
Magnus Damm98779ad2009-11-27 04:36:58 +0000862 gpio_request(GPIO_PTB6, NULL);
863 gpio_direction_output(GPIO_PTB6, 0);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000864
Magnus Damm1ce4da72009-12-07 14:05:45 +0000865 /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000866 gpio_request(GPIO_FN_SDHI1CD, NULL);
867 gpio_request(GPIO_FN_SDHI1WP, NULL);
868 gpio_request(GPIO_FN_SDHI1CMD, NULL);
869 gpio_request(GPIO_FN_SDHI1CLK, NULL);
870 gpio_request(GPIO_FN_SDHI1D3, NULL);
871 gpio_request(GPIO_FN_SDHI1D2, NULL);
872 gpio_request(GPIO_FN_SDHI1D1, NULL);
873 gpio_request(GPIO_FN_SDHI1D0, NULL);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000874 gpio_request(GPIO_PTB7, NULL);
Magnus Damm98779ad2009-11-27 04:36:58 +0000875 gpio_direction_output(GPIO_PTB7, 0);
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000876
877 /* I/O buffer drive ability is high for SDHI1 */
878 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
Magnus Damm1ce4da72009-12-07 14:05:45 +0000879#else
880 /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
881 gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
882 gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
883 gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
884 gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
885 gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
886 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
887 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
888 gpio_request(GPIO_PTY6, NULL); /* write protect */
889 gpio_direction_input(GPIO_PTY6);
890 gpio_request(GPIO_PTY7, NULL); /* card detect */
891 gpio_direction_input(GPIO_PTY7);
892
893 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
894#endif
Kuninori Morimoto96987d92009-10-02 07:54:42 +0000895
Kuninori Morimoto125ecce2009-09-10 01:39:37 +0000896 /* enable I2C device */
897 i2c_register_board_info(1, i2c1_devices,
898 ARRAY_SIZE(i2c1_devices));
899
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000900 return platform_add_devices(ecovec_devices,
901 ARRAY_SIZE(ecovec_devices));
902}
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000903arch_initcall(arch_setup);
904
905static int __init devices_setup(void)
906{
Magnus Damm376abbb2009-10-26 10:44:37 +0000907 sh_eth_init(&sh_eth_plat);
Kuninori Morimoto4907d572009-09-10 01:39:58 +0000908 return 0;
909}
910device_initcall(devices_setup);
911
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000912static struct sh_machine_vector mv_ecovec __initmv = {
913 .mv_name = "R0P7724 (EcoVec)",
914};