setup.c (9de09ace8d518141a4375e1d216ab64db4377799) setup.c (eb0cd9e88c6a6561055b32a17d44d8918aecc3c7)
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.

--- 12 unchanged lines hidden (view full) ---

21#include <linux/i2c/tsc2007.h>
22#include <linux/input.h>
23#include <video/sh_mobile_lcdc.h>
24#include <media/sh_mobile_ceu.h>
25#include <asm/heartbeat.h>
26#include <asm/sh_eth.h>
27#include <asm/sh_keysc.h>
28#include <asm/clock.h>
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.

--- 12 unchanged lines hidden (view full) ---

21#include <linux/i2c/tsc2007.h>
22#include <linux/input.h>
23#include <video/sh_mobile_lcdc.h>
24#include <media/sh_mobile_ceu.h>
25#include <asm/heartbeat.h>
26#include <asm/sh_eth.h>
27#include <asm/sh_keysc.h>
28#include <asm/clock.h>
29#include <asm/suspend.h>
29#include <cpu/sh7724.h>
30
31/*
32 * Address Interface BusWidth
33 *-----------------------------------------
34 * 0x0000_0000 uboot 16bit
35 * 0x0004_0000 Linux romImage 16bit
36 * 0x0014_0000 MTD for Linux 16bit

--- 105 unchanged lines hidden (view full) ---

142static struct platform_device sh_eth_device = {
143 .name = "sh-eth",
144 .id = 0,
145 .dev = {
146 .platform_data = &sh_eth_plat,
147 },
148 .num_resources = ARRAY_SIZE(sh_eth_resources),
149 .resource = sh_eth_resources,
30#include <cpu/sh7724.h>
31
32/*
33 * Address Interface BusWidth
34 *-----------------------------------------
35 * 0x0000_0000 uboot 16bit
36 * 0x0004_0000 Linux romImage 16bit
37 * 0x0014_0000 MTD for Linux 16bit

--- 105 unchanged lines hidden (view full) ---

143static struct platform_device sh_eth_device = {
144 .name = "sh-eth",
145 .id = 0,
146 .dev = {
147 .platform_data = &sh_eth_plat,
148 },
149 .num_resources = ARRAY_SIZE(sh_eth_resources),
150 .resource = sh_eth_resources,
151 .archdata = {
152 .hwblk_id = HWBLK_ETHER,
153 },
150};
151
152/* USB0 host */
153void usb0_port_power(int port, int power)
154{
155 gpio_set_value(GPIO_PTB4, power);
156}
157

--- 22 unchanged lines hidden (view full) ---

180 .dma_mask = NULL, /* not use dma */
181 .coherent_dma_mask = 0xffffffff,
182 .platform_data = &usb0_host_data,
183 },
184 .num_resources = ARRAY_SIZE(usb0_host_resources),
185 .resource = usb0_host_resources,
186};
187
154};
155
156/* USB0 host */
157void usb0_port_power(int port, int power)
158{
159 gpio_set_value(GPIO_PTB4, power);
160}
161

--- 22 unchanged lines hidden (view full) ---

184 .dma_mask = NULL, /* not use dma */
185 .coherent_dma_mask = 0xffffffff,
186 .platform_data = &usb0_host_data,
187 },
188 .num_resources = ARRAY_SIZE(usb0_host_resources),
189 .resource = usb0_host_resources,
190};
191
188/*
189 * USB1
190 *
191 * CN5 can use both host/function,
192 * and we can determine it by checking PTB[3]
193 *
194 * This time only USB1 host is supported.
195 */
192/* USB1 host/function */
196void usb1_port_power(int port, int power)
197{
193void usb1_port_power(int port, int power)
194{
198 if (!gpio_get_value(GPIO_PTB3)) {
199 printk(KERN_ERR "USB1 function is not supported\n");
200 return;
201 }
202
203 gpio_set_value(GPIO_PTB5, power);
204}
205
195 gpio_set_value(GPIO_PTB5, power);
196}
197
206static struct r8a66597_platdata usb1_host_data = {
198static struct r8a66597_platdata usb1_common_data = {
207 .on_chip = 1,
208 .port_power = usb1_port_power,
209};
210
199 .on_chip = 1,
200 .port_power = usb1_port_power,
201};
202
211static struct resource usb1_host_resources[] = {
203static struct resource usb1_common_resources[] = {
212 [0] = {
213 .start = 0xa4d90000,
214 .end = 0xa4d90124 - 1,
215 .flags = IORESOURCE_MEM,
216 },
217 [1] = {
218 .start = 66,
219 .end = 66,
220 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
221 },
222};
223
204 [0] = {
205 .start = 0xa4d90000,
206 .end = 0xa4d90124 - 1,
207 .flags = IORESOURCE_MEM,
208 },
209 [1] = {
210 .start = 66,
211 .end = 66,
212 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
213 },
214};
215
224static struct platform_device usb1_host_device = {
225 .name = "r8a66597_hcd",
216static struct platform_device usb1_common_device = {
217 /* .name will be added in arch_setup */
226 .id = 1,
227 .dev = {
228 .dma_mask = NULL, /* not use dma */
229 .coherent_dma_mask = 0xffffffff,
218 .id = 1,
219 .dev = {
220 .dma_mask = NULL, /* not use dma */
221 .coherent_dma_mask = 0xffffffff,
230 .platform_data = &usb1_host_data,
222 .platform_data = &usb1_common_data,
231 },
223 },
232 .num_resources = ARRAY_SIZE(usb1_host_resources),
233 .resource = usb1_host_resources,
224 .num_resources = ARRAY_SIZE(usb1_common_resources),
225 .resource = usb1_common_resources,
234};
235
236/* LCDC */
237static struct sh_mobile_lcdc_info lcdc_info = {
238 .ch[0] = {
239 .interface_type = RGB18,
240 .chan = LCDC_CHAN_MAINLCD,
241 .bpp = 16,

--- 181 unchanged lines hidden (view full) ---

423
424static struct i2c_board_info ts_i2c_clients = {
425 I2C_BOARD_INFO("tsc2007", 0x48),
426 .type = "tsc2007",
427 .platform_data = &tsc2007_info,
428 .irq = IRQ0,
429};
430
226};
227
228/* LCDC */
229static struct sh_mobile_lcdc_info lcdc_info = {
230 .ch[0] = {
231 .interface_type = RGB18,
232 .chan = LCDC_CHAN_MAINLCD,
233 .bpp = 16,

--- 181 unchanged lines hidden (view full) ---

415
416static struct i2c_board_info ts_i2c_clients = {
417 I2C_BOARD_INFO("tsc2007", 0x48),
418 .type = "tsc2007",
419 .platform_data = &tsc2007_info,
420 .irq = IRQ0,
421};
422
423/* SHDI0 */
424static struct resource sdhi0_resources[] = {
425 [0] = {
426 .name = "SDHI0",
427 .start = 0x04ce0000,
428 .end = 0x04ce01ff,
429 .flags = IORESOURCE_MEM,
430 },
431 [1] = {
432 .start = 101,
433 .flags = IORESOURCE_IRQ,
434 },
435};
436
437static struct platform_device sdhi0_device = {
438 .name = "sh_mobile_sdhi",
439 .num_resources = ARRAY_SIZE(sdhi0_resources),
440 .resource = sdhi0_resources,
441 .id = 0,
442 .archdata = {
443 .hwblk_id = HWBLK_SDHI0,
444 },
445};
446
447/* SHDI1 */
448static struct resource sdhi1_resources[] = {
449 [0] = {
450 .name = "SDHI1",
451 .start = 0x04cf0000,
452 .end = 0x04cf01ff,
453 .flags = IORESOURCE_MEM,
454 },
455 [1] = {
456 .start = 24,
457 .flags = IORESOURCE_IRQ,
458 },
459};
460
461static struct platform_device sdhi1_device = {
462 .name = "sh_mobile_sdhi",
463 .num_resources = ARRAY_SIZE(sdhi1_resources),
464 .resource = sdhi1_resources,
465 .id = 1,
466 .archdata = {
467 .hwblk_id = HWBLK_SDHI1,
468 },
469};
470
431static struct platform_device *ecovec_devices[] __initdata = {
432 &heartbeat_device,
433 &nor_flash_device,
434 &sh_eth_device,
435 &usb0_host_device,
471static struct platform_device *ecovec_devices[] __initdata = {
472 &heartbeat_device,
473 &nor_flash_device,
474 &sh_eth_device,
475 &usb0_host_device,
436 &usb1_host_device, /* USB1 host support */
476 &usb1_common_device,
437 &lcdc_device,
438 &ceu0_device,
439 &ceu1_device,
440 &keysc_device,
477 &lcdc_device,
478 &ceu0_device,
479 &ceu1_device,
480 &keysc_device,
481 &sdhi0_device,
482 &sdhi1_device,
441};
442
443#define EEPROM_ADDR 0x50
444static u8 mac_read(struct i2c_adapter *a, u8 command)
445{
446 struct i2c_msg msg[2];
447 u8 buf;
448 int ret;

--- 12 unchanged lines hidden (view full) ---

461 if (ret < 0) {
462 printk(KERN_ERR "error %d\n", ret);
463 buf = 0xff;
464 }
465
466 return buf;
467}
468
483};
484
485#define EEPROM_ADDR 0x50
486static u8 mac_read(struct i2c_adapter *a, u8 command)
487{
488 struct i2c_msg msg[2];
489 u8 buf;
490 int ret;

--- 12 unchanged lines hidden (view full) ---

503 if (ret < 0) {
504 printk(KERN_ERR "error %d\n", ret);
505 buf = 0xff;
506 }
507
508 return buf;
509}
510
469#define MAC_LEN 6
470static void __init sh_eth_init(void)
511static void __init sh_eth_init(struct sh_eth_plat_data *pd)
471{
472 struct i2c_adapter *a = i2c_get_adapter(1);
512{
513 struct i2c_adapter *a = i2c_get_adapter(1);
473 struct clk *eth_clk;
474 u8 mac[MAC_LEN];
475 int i;
476
477 if (!a) {
478 pr_err("can not get I2C 1\n");
479 return;
480 }
481
514 int i;
515
516 if (!a) {
517 pr_err("can not get I2C 1\n");
518 return;
519 }
520
482 eth_clk = clk_get(NULL, "eth0");
483 if (!eth_clk) {
484 pr_err("can not get eth0 clk\n");
485 return;
486 }
487
488 /* read MAC address frome EEPROM */
521 /* read MAC address frome EEPROM */
489 for (i = 0; i < MAC_LEN; i++) {
490 mac[i] = mac_read(a, 0x10 + i);
522 for (i = 0; i < sizeof(pd->mac_addr); i++) {
523 pd->mac_addr[i] = mac_read(a, 0x10 + i);
491 msleep(10);
492 }
524 msleep(10);
525 }
493
494 /* clock enable */
495 clk_enable(eth_clk);
496
497 /* reset sh-eth */
498 ctrl_outl(0x1, SH_ETH_ADDR + 0x0);
499
500 /* set MAC addr */
501 ctrl_outl((mac[0] << 24) |
502 (mac[1] << 16) |
503 (mac[2] << 8) |
504 (mac[3] << 0), SH_ETH_MAHR);
505 ctrl_outl((mac[4] << 8) |
506 (mac[5] << 0), SH_ETH_MALR);
507
508 clk_put(eth_clk);
509}
510
511#define PORT_HIZA 0xA4050158
512#define IODRIVEA 0xA405018A
526}
527
528#define PORT_HIZA 0xA4050158
529#define IODRIVEA 0xA405018A
530
531extern char ecovec24_sdram_enter_start;
532extern char ecovec24_sdram_enter_end;
533extern char ecovec24_sdram_leave_start;
534extern char ecovec24_sdram_leave_end;
535
513static int __init arch_setup(void)
514{
536static int __init arch_setup(void)
537{
538 /* register board specific self-refresh code */
539 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
540 &ecovec24_sdram_enter_start,
541 &ecovec24_sdram_enter_end,
542 &ecovec24_sdram_leave_start,
543 &ecovec24_sdram_leave_end);
544
515 /* enable STATUS0, STATUS2 and PDSTATUS */
516 gpio_request(GPIO_FN_STATUS0, NULL);
517 gpio_request(GPIO_FN_STATUS2, NULL);
518 gpio_request(GPIO_FN_PDSTATUS, NULL);
519
520 /* enable SCIFA0 */
521 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
522 gpio_request(GPIO_FN_SCIF0_RXD, NULL);

--- 33 unchanged lines hidden (view full) ---

556 gpio_request(GPIO_PTB4, NULL);
557 gpio_request(GPIO_PTB5, NULL);
558 gpio_direction_input(GPIO_PTB3);
559 gpio_direction_output(GPIO_PTB4, 0);
560 gpio_direction_output(GPIO_PTB5, 0);
561 ctrl_outw(0x0600, 0xa40501d4);
562 ctrl_outw(0x0600, 0xa4050192);
563
545 /* enable STATUS0, STATUS2 and PDSTATUS */
546 gpio_request(GPIO_FN_STATUS0, NULL);
547 gpio_request(GPIO_FN_STATUS2, NULL);
548 gpio_request(GPIO_FN_PDSTATUS, NULL);
549
550 /* enable SCIFA0 */
551 gpio_request(GPIO_FN_SCIF0_TXD, NULL);
552 gpio_request(GPIO_FN_SCIF0_RXD, NULL);

--- 33 unchanged lines hidden (view full) ---

586 gpio_request(GPIO_PTB4, NULL);
587 gpio_request(GPIO_PTB5, NULL);
588 gpio_direction_input(GPIO_PTB3);
589 gpio_direction_output(GPIO_PTB4, 0);
590 gpio_direction_output(GPIO_PTB5, 0);
591 ctrl_outw(0x0600, 0xa40501d4);
592 ctrl_outw(0x0600, 0xa4050192);
593
594 if (gpio_get_value(GPIO_PTB3)) {
595 printk(KERN_INFO "USB1 function is selected\n");
596 usb1_common_device.name = "r8a66597_udc";
597 } else {
598 printk(KERN_INFO "USB1 host is selected\n");
599 usb1_common_device.name = "r8a66597_hcd";
600 }
601
564 /* enable LCDC */
565 gpio_request(GPIO_FN_LCDD23, NULL);
566 gpio_request(GPIO_FN_LCDD22, NULL);
567 gpio_request(GPIO_FN_LCDD21, NULL);
568 gpio_request(GPIO_FN_LCDD20, NULL);
569 gpio_request(GPIO_FN_LCDD19, NULL);
570 gpio_request(GPIO_FN_LCDD18, NULL);
571 gpio_request(GPIO_FN_LCDD17, NULL);

--- 133 unchanged lines hidden (view full) ---

705 gpio_request(GPIO_PTR4, NULL);
706 gpio_request(GPIO_PTR5, NULL);
707 gpio_request(GPIO_PTR6, NULL);
708 gpio_direction_input(GPIO_PTR0);
709 gpio_direction_input(GPIO_PTR4);
710 gpio_direction_input(GPIO_PTR5);
711 gpio_direction_input(GPIO_PTR6);
712
602 /* enable LCDC */
603 gpio_request(GPIO_FN_LCDD23, NULL);
604 gpio_request(GPIO_FN_LCDD22, NULL);
605 gpio_request(GPIO_FN_LCDD21, NULL);
606 gpio_request(GPIO_FN_LCDD20, NULL);
607 gpio_request(GPIO_FN_LCDD19, NULL);
608 gpio_request(GPIO_FN_LCDD18, NULL);
609 gpio_request(GPIO_FN_LCDD17, NULL);

--- 133 unchanged lines hidden (view full) ---

743 gpio_request(GPIO_PTR4, NULL);
744 gpio_request(GPIO_PTR5, NULL);
745 gpio_request(GPIO_PTR6, NULL);
746 gpio_direction_input(GPIO_PTR0);
747 gpio_direction_input(GPIO_PTR4);
748 gpio_direction_input(GPIO_PTR5);
749 gpio_direction_input(GPIO_PTR6);
750
751 /* enable SDHI0 */
752 gpio_request(GPIO_FN_SDHI0CD, NULL);
753 gpio_request(GPIO_FN_SDHI0WP, NULL);
754 gpio_request(GPIO_FN_SDHI0CMD, NULL);
755 gpio_request(GPIO_FN_SDHI0CLK, NULL);
756 gpio_request(GPIO_FN_SDHI0D3, NULL);
757 gpio_request(GPIO_FN_SDHI0D2, NULL);
758 gpio_request(GPIO_FN_SDHI0D1, NULL);
759 gpio_request(GPIO_FN_SDHI0D0, NULL);
760
761 /* enable SDHI1 */
762 gpio_request(GPIO_FN_SDHI1CD, NULL);
763 gpio_request(GPIO_FN_SDHI1WP, NULL);
764 gpio_request(GPIO_FN_SDHI1CMD, NULL);
765 gpio_request(GPIO_FN_SDHI1CLK, NULL);
766 gpio_request(GPIO_FN_SDHI1D3, NULL);
767 gpio_request(GPIO_FN_SDHI1D2, NULL);
768 gpio_request(GPIO_FN_SDHI1D1, NULL);
769 gpio_request(GPIO_FN_SDHI1D0, NULL);
770
771 gpio_request(GPIO_PTB6, NULL);
772 gpio_request(GPIO_PTB7, NULL);
773 gpio_direction_output(GPIO_PTB6, 1);
774 gpio_direction_output(GPIO_PTB7, 1);
775
776 /* I/O buffer drive ability is high for SDHI1 */
777 ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
778
713 /* enable I2C device */
714 i2c_register_board_info(1, i2c1_devices,
715 ARRAY_SIZE(i2c1_devices));
716
717 return platform_add_devices(ecovec_devices,
718 ARRAY_SIZE(ecovec_devices));
719}
720arch_initcall(arch_setup);
721
722static int __init devices_setup(void)
723{
779 /* enable I2C device */
780 i2c_register_board_info(1, i2c1_devices,
781 ARRAY_SIZE(i2c1_devices));
782
783 return platform_add_devices(ecovec_devices,
784 ARRAY_SIZE(ecovec_devices));
785}
786arch_initcall(arch_setup);
787
788static int __init devices_setup(void)
789{
724 sh_eth_init();
790 sh_eth_init(&sh_eth_plat);
725 return 0;
726}
727device_initcall(devices_setup);
728
791 return 0;
792}
793device_initcall(devices_setup);
794
729
730static struct sh_machine_vector mv_ecovec __initmv = {
731 .mv_name = "R0P7724 (EcoVec)",
732};
795static struct sh_machine_vector mv_ecovec __initmv = {
796 .mv_name = "R0P7724 (EcoVec)",
797};