]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/arm/mach-shmobile/board-g3evm.c
ARM: mach-shmobile: G3EVM USBHS support
[karo-tx-linux.git] / arch / arm / mach-shmobile / board-g3evm.c
index b4b202718e4d6875a11044108a9939266967368d..f36c9a94d32646dd19ce3a4f82c2606b11c4dfc0 100644 (file)
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
+#include <linux/usb/r8a66597.h>
 #include <linux/io.h>
+#include <linux/gpio.h>
+#include <mach/sh7367.h>
 #include <mach/common.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -84,9 +87,49 @@ static struct platform_device nor_flash_device = {
        .resource       = nor_flash_resources,
 };
 
+/* USBHS */
+void usb_host_port_power(int port, int power)
+{
+       if (!power) /* only power-on supported for now */
+               return;
+
+       /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
+       __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
+}
+
+static struct r8a66597_platdata usb_host_data = {
+       .on_chip = 1,
+       .port_power = usb_host_port_power,
+};
+
+static struct resource usb_host_resources[] = {
+       [0] = {
+               .name   = "USBHS",
+               .start  = 0xe6890000,
+               .end    = 0xe68900e5,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = 65,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device usb_host_device = {
+       .name           = "r8a66597_hcd",
+       .id             = 0,
+       .dev = {
+               .platform_data          = &usb_host_data,
+               .dma_mask               = NULL,
+               .coherent_dma_mask      = 0xffffffff,
+       },
+       .num_resources  = ARRAY_SIZE(usb_host_resources),
+       .resource       = usb_host_resources,
+};
 
 static struct platform_device *g3evm_devices[] __initdata = {
        &nor_flash_device,
+       &usb_host_device,
 };
 
 static struct map_desc g3evm_io_desc[] __initdata = {
@@ -105,13 +148,54 @@ static void __init g3evm_map_io(void)
 {
        iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc));
 
-       /* setup early devices and clocks here as well */
+       /* setup early devices, clocks and console here as well */
        sh7367_add_early_devices();
        sh7367_clock_init();
+       shmobile_setup_console();
 }
 
 static void __init g3evm_init(void)
 {
+       sh7367_pinmux_init();
+
+       /* Lit DS4 LED */
+       gpio_request(GPIO_PORT22, NULL);
+       gpio_direction_output(GPIO_PORT22, 1);
+       gpio_export(GPIO_PORT22, 0);
+
+       /* Lit DS8 LED */
+       gpio_request(GPIO_PORT23, NULL);
+       gpio_direction_output(GPIO_PORT23, 1);
+       gpio_export(GPIO_PORT23, 0);
+
+       /* Lit DS3 LED */
+       gpio_request(GPIO_PORT24, NULL);
+       gpio_direction_output(GPIO_PORT24, 1);
+       gpio_export(GPIO_PORT24, 0);
+
+       /* SCIFA1 */
+       gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
+       gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
+       gpio_request(GPIO_FN_SCIFA1_CTS, NULL);
+       gpio_request(GPIO_FN_SCIFA1_RTS, NULL);
+
+       /* USBHS */
+       gpio_request(GPIO_FN_VBUS0, NULL);
+       gpio_request(GPIO_FN_PWEN, NULL);
+       gpio_request(GPIO_FN_OVCN, NULL);
+       gpio_request(GPIO_FN_OVCN2, NULL);
+       gpio_request(GPIO_FN_EXTLP, NULL);
+       gpio_request(GPIO_FN_IDIN, NULL);
+
+       /* enable clock in SYMSTPCR2 */
+       __raw_writel(__raw_readl(0xe6158048) & ~(1 << 22), 0xe6158048);
+
+       /* setup USB phy */
+       __raw_writew(0x0300, 0xe605810a);       /* USBCR1 */
+       __raw_writew(0x00e0, 0xe60581c0);       /* CPFCH */
+       __raw_writew(0x6010, 0xe60581c6);       /* CGPOSR */
+       __raw_writew(0x8a0a, 0xe605810c);       /* USBCR2 */
+
        sh7367_add_standard_devices();
 
        platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));