2 * Copyright (C) 2009 Renesas Solutions Corp.
4 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
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
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>
18 #include <linux/delay.h>
19 #include <linux/usb/r8a66597.h>
20 #include <video/sh_mobile_lcdc.h>
21 #include <media/sh_mobile_ceu.h>
22 #include <asm/heartbeat.h>
23 #include <asm/sh_eth.h>
24 #include <cpu/sh7724.h>
27 * Address Interface BusWidth
28 *-----------------------------------------
29 * 0x0000_0000 uboot 16bit
30 * 0x0004_0000 Linux romImage 16bit
31 * 0x0014_0000 MTD for Linux 16bit
32 * 0x0400_0000 Internal I/O 16/32bit
33 * 0x0800_0000 DRAM 32bit
34 * 0x1800_0000 MFI 16bit
38 static unsigned char led_pos[] = { 0, 1, 2, 3 };
39 static struct heartbeat_data heartbeat_data = {
45 static struct resource heartbeat_resources[] = {
47 .start = 0xA405012C, /* PTG */
48 .end = 0xA405012E - 1,
49 .flags = IORESOURCE_MEM,
53 static struct platform_device heartbeat_device = {
57 .platform_data = &heartbeat_data,
59 .num_resources = ARRAY_SIZE(heartbeat_resources),
60 .resource = heartbeat_resources,
64 static struct mtd_partition nor_flash_partitions[] = {
66 .name = "boot loader",
68 .size = (5 * 1024 * 1024),
69 .mask_flags = MTD_CAP_ROM,
72 .offset = MTDPART_OFS_APPEND,
73 .size = MTDPART_SIZ_FULL,
77 static struct physmap_flash_data nor_flash_data = {
79 .parts = nor_flash_partitions,
80 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
83 static struct resource nor_flash_resources[] = {
88 .flags = IORESOURCE_MEM,
92 static struct platform_device nor_flash_device = {
93 .name = "physmap-flash",
94 .resource = nor_flash_resources,
95 .num_resources = ARRAY_SIZE(nor_flash_resources),
97 .platform_data = &nor_flash_data,
102 #define SH_ETH_ADDR (0xA4600000)
103 #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
104 #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
105 static struct resource sh_eth_resources[] = {
107 .start = SH_ETH_ADDR,
108 .end = SH_ETH_ADDR + 0x1FC,
109 .flags = IORESOURCE_MEM,
113 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
117 struct sh_eth_plat_data sh_eth_plat = {
118 .phy = 0x1f, /* SMSC LAN8700 */
119 .edmac_endian = EDMAC_LITTLE_ENDIAN,
122 static struct platform_device sh_eth_device = {
126 .platform_data = &sh_eth_plat,
128 .num_resources = ARRAY_SIZE(sh_eth_resources),
129 .resource = sh_eth_resources,
133 void usb0_port_power(int port, int power)
135 gpio_set_value(GPIO_PTB4, power);
138 static struct r8a66597_platdata usb0_host_data = {
140 .port_power = usb0_port_power,
143 static struct resource usb0_host_resources[] = {
146 .end = 0xa4d80124 - 1,
147 .flags = IORESOURCE_MEM,
152 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
156 static struct platform_device usb0_host_device = {
157 .name = "r8a66597_hcd",
160 .dma_mask = NULL, /* not use dma */
161 .coherent_dma_mask = 0xffffffff,
162 .platform_data = &usb0_host_data,
164 .num_resources = ARRAY_SIZE(usb0_host_resources),
165 .resource = usb0_host_resources,
171 * CN5 can use both host/function,
172 * and we can determine it by checking PTB[3]
174 * This time only USB1 host is supported.
176 void usb1_port_power(int port, int power)
178 if (!gpio_get_value(GPIO_PTB3)) {
179 printk(KERN_ERR "USB1 function is not supported\n");
183 gpio_set_value(GPIO_PTB5, power);
186 static struct r8a66597_platdata usb1_host_data = {
188 .port_power = usb1_port_power,
191 static struct resource usb1_host_resources[] = {
194 .end = 0xa4d90124 - 1,
195 .flags = IORESOURCE_MEM,
200 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
204 static struct platform_device usb1_host_device = {
205 .name = "r8a66597_hcd",
208 .dma_mask = NULL, /* not use dma */
209 .coherent_dma_mask = 0xffffffff,
210 .platform_data = &usb1_host_data,
212 .num_resources = ARRAY_SIZE(usb1_host_resources),
213 .resource = usb1_host_resources,
217 static struct sh_mobile_lcdc_info lcdc_info = {
219 .interface_type = RGB18,
220 .chan = LCDC_CHAN_MAINLCD,
224 .sync = 0, /* hsync and vsync are active low */
226 .lcd_size_cfg = { /* 7.0 inch */
235 static struct resource lcdc_resources[] = {
240 .flags = IORESOURCE_MEM,
244 .flags = IORESOURCE_IRQ,
248 static struct platform_device lcdc_device = {
249 .name = "sh_mobile_lcdc_fb",
250 .num_resources = ARRAY_SIZE(lcdc_resources),
251 .resource = lcdc_resources,
253 .platform_data = &lcdc_info,
256 .hwblk_id = HWBLK_LCDC,
261 static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
262 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
265 static struct resource ceu0_resources[] = {
270 .flags = IORESOURCE_MEM,
274 .flags = IORESOURCE_IRQ,
277 /* place holder for contiguous memory */
281 static struct platform_device ceu0_device = {
282 .name = "sh_mobile_ceu",
283 .id = 0, /* "ceu0" clock */
284 .num_resources = ARRAY_SIZE(ceu0_resources),
285 .resource = ceu0_resources,
287 .platform_data = &sh_mobile_ceu0_info,
290 .hwblk_id = HWBLK_CEU0,
295 static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
296 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
299 static struct resource ceu1_resources[] = {
304 .flags = IORESOURCE_MEM,
308 .flags = IORESOURCE_IRQ,
311 /* place holder for contiguous memory */
315 static struct platform_device ceu1_device = {
316 .name = "sh_mobile_ceu",
317 .id = 1, /* "ceu1" clock */
318 .num_resources = ARRAY_SIZE(ceu1_resources),
319 .resource = ceu1_resources,
321 .platform_data = &sh_mobile_ceu1_info,
324 .hwblk_id = HWBLK_CEU1,
328 static struct platform_device *ecovec_devices[] __initdata = {
333 &usb1_host_device, /* USB1 host support */
339 #define PORT_HIZA 0xA4050158
340 static int __init devices_setup(void)
343 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
344 gpio_request(GPIO_FN_SCIF0_RXD, NULL);
346 /* enable debug LED */
347 gpio_request(GPIO_PTG0, NULL);
348 gpio_request(GPIO_PTG1, NULL);
349 gpio_request(GPIO_PTG2, NULL);
350 gpio_request(GPIO_PTG3, NULL);
351 gpio_direction_output(GPIO_PTG0, 0);
352 gpio_direction_output(GPIO_PTG1, 0);
353 gpio_direction_output(GPIO_PTG2, 0);
354 gpio_direction_output(GPIO_PTG3, 0);
357 gpio_request(GPIO_PTA1, NULL);
358 gpio_direction_output(GPIO_PTA1, 1);
361 gpio_request(GPIO_FN_RMII_RXD0, NULL);
362 gpio_request(GPIO_FN_RMII_RXD1, NULL);
363 gpio_request(GPIO_FN_RMII_TXD0, NULL);
364 gpio_request(GPIO_FN_RMII_TXD1, NULL);
365 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
366 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
367 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
368 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
369 gpio_request(GPIO_FN_MDIO, NULL);
370 gpio_request(GPIO_FN_MDC, NULL);
371 gpio_request(GPIO_FN_LNKSTA, NULL);
374 gpio_request(GPIO_PTB3, NULL);
375 gpio_request(GPIO_PTB4, NULL);
376 gpio_request(GPIO_PTB5, NULL);
377 gpio_direction_input(GPIO_PTB3);
378 gpio_direction_output(GPIO_PTB4, 0);
379 gpio_direction_output(GPIO_PTB5, 0);
380 ctrl_outw(0x0600, 0xa40501d4);
381 ctrl_outw(0x0600, 0xa4050192);
384 gpio_request(GPIO_FN_LCDD23, NULL);
385 gpio_request(GPIO_FN_LCDD22, NULL);
386 gpio_request(GPIO_FN_LCDD21, NULL);
387 gpio_request(GPIO_FN_LCDD20, NULL);
388 gpio_request(GPIO_FN_LCDD19, NULL);
389 gpio_request(GPIO_FN_LCDD18, NULL);
390 gpio_request(GPIO_FN_LCDD17, NULL);
391 gpio_request(GPIO_FN_LCDD16, NULL);
392 gpio_request(GPIO_FN_LCDD15, NULL);
393 gpio_request(GPIO_FN_LCDD14, NULL);
394 gpio_request(GPIO_FN_LCDD13, NULL);
395 gpio_request(GPIO_FN_LCDD12, NULL);
396 gpio_request(GPIO_FN_LCDD11, NULL);
397 gpio_request(GPIO_FN_LCDD10, NULL);
398 gpio_request(GPIO_FN_LCDD9, NULL);
399 gpio_request(GPIO_FN_LCDD8, NULL);
400 gpio_request(GPIO_FN_LCDD7, NULL);
401 gpio_request(GPIO_FN_LCDD6, NULL);
402 gpio_request(GPIO_FN_LCDD5, NULL);
403 gpio_request(GPIO_FN_LCDD4, NULL);
404 gpio_request(GPIO_FN_LCDD3, NULL);
405 gpio_request(GPIO_FN_LCDD2, NULL);
406 gpio_request(GPIO_FN_LCDD1, NULL);
407 gpio_request(GPIO_FN_LCDD0, NULL);
408 gpio_request(GPIO_FN_LCDDISP, NULL);
409 gpio_request(GPIO_FN_LCDHSYN, NULL);
410 gpio_request(GPIO_FN_LCDDCK, NULL);
411 gpio_request(GPIO_FN_LCDVSYN, NULL);
412 gpio_request(GPIO_FN_LCDDON, NULL);
413 gpio_request(GPIO_FN_LCDLCLK, NULL);
414 ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
416 gpio_request(GPIO_PTE6, NULL);
417 gpio_request(GPIO_PTU1, NULL);
418 gpio_request(GPIO_PTR1, NULL);
419 gpio_request(GPIO_PTA2, NULL);
420 gpio_direction_input(GPIO_PTE6);
421 gpio_direction_output(GPIO_PTU1, 0);
422 gpio_direction_output(GPIO_PTR1, 0);
423 gpio_direction_output(GPIO_PTA2, 0);
425 if (gpio_get_value(GPIO_PTE6)) {
427 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
428 lcdc_info.ch[0].lcd_cfg.name = "DVI";
429 lcdc_info.ch[0].lcd_cfg.xres = 1280;
430 lcdc_info.ch[0].lcd_cfg.yres = 720;
431 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
432 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
433 lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
434 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
435 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
436 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
438 gpio_set_value(GPIO_PTA2, 1);
439 gpio_set_value(GPIO_PTU1, 1);
446 gpio_request(GPIO_FN_VIO0_D15, NULL);
447 gpio_request(GPIO_FN_VIO0_D14, NULL);
448 gpio_request(GPIO_FN_VIO0_D13, NULL);
449 gpio_request(GPIO_FN_VIO0_D12, NULL);
450 gpio_request(GPIO_FN_VIO0_D11, NULL);
451 gpio_request(GPIO_FN_VIO0_D10, NULL);
452 gpio_request(GPIO_FN_VIO0_D9, NULL);
453 gpio_request(GPIO_FN_VIO0_D8, NULL);
454 gpio_request(GPIO_FN_VIO0_D7, NULL);
455 gpio_request(GPIO_FN_VIO0_D6, NULL);
456 gpio_request(GPIO_FN_VIO0_D5, NULL);
457 gpio_request(GPIO_FN_VIO0_D4, NULL);
458 gpio_request(GPIO_FN_VIO0_D3, NULL);
459 gpio_request(GPIO_FN_VIO0_D2, NULL);
460 gpio_request(GPIO_FN_VIO0_D1, NULL);
461 gpio_request(GPIO_FN_VIO0_D0, NULL);
462 gpio_request(GPIO_FN_VIO0_VD, NULL);
463 gpio_request(GPIO_FN_VIO0_CLK, NULL);
464 gpio_request(GPIO_FN_VIO0_FLD, NULL);
465 gpio_request(GPIO_FN_VIO0_HD, NULL);
466 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
469 gpio_request(GPIO_FN_VIO1_D7, NULL);
470 gpio_request(GPIO_FN_VIO1_D6, NULL);
471 gpio_request(GPIO_FN_VIO1_D5, NULL);
472 gpio_request(GPIO_FN_VIO1_D4, NULL);
473 gpio_request(GPIO_FN_VIO1_D3, NULL);
474 gpio_request(GPIO_FN_VIO1_D2, NULL);
475 gpio_request(GPIO_FN_VIO1_D1, NULL);
476 gpio_request(GPIO_FN_VIO1_D0, NULL);
477 gpio_request(GPIO_FN_VIO1_FLD, NULL);
478 gpio_request(GPIO_FN_VIO1_HD, NULL);
479 gpio_request(GPIO_FN_VIO1_VD, NULL);
480 gpio_request(GPIO_FN_VIO1_CLK, NULL);
481 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
483 return platform_add_devices(ecovec_devices,
484 ARRAY_SIZE(ecovec_devices));
486 device_initcall(devices_setup);
488 static struct sh_machine_vector mv_ecovec __initmv = {
489 .mv_name = "R0P7724 (EcoVec)",