fix GPIO function select bit definitions (based on a patch by Jonas <jmajau at ubnt...
[openwrt/staging/wigyori.git] / target / linux / ar71xx / files / arch / mips / ar71xx / platform.c
index e41fcd646b0830ba02009998ead622a714d44f81..705f24315a4c29953cbe22994da688adcc371858 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
 
-#include <asm/mips_machine.h>
 #include <asm/mach-ar71xx/ar71xx.h>
 #include <asm/mach-ar71xx/platform.h>
 
@@ -27,7 +26,7 @@ static u8 ar71xx_mac_base[ETH_ALEN] __initdata;
 /*
  * OHCI (USB full speed host controller)
  */
-static struct resource ar71xx_usb_ohci_resources[] = {
+static struct resource ar71xx_ohci_resources[] = {
        [0] = {
                .start  = AR71XX_OHCI_BASE,
                .end    = AR71XX_OHCI_BASE + AR71XX_OHCI_SIZE - 1,
@@ -41,11 +40,11 @@ static struct resource ar71xx_usb_ohci_resources[] = {
 };
 
 static u64 ar71xx_ohci_dmamask = DMA_BIT_MASK(32);
-static struct platform_device ar71xx_usb_ohci_device = {
+static struct platform_device ar71xx_ohci_device = {
        .name           = "ar71xx-ohci",
        .id             = -1,
-       .resource       = ar71xx_usb_ohci_resources,
-       .num_resources  = ARRAY_SIZE(ar71xx_usb_ohci_resources),
+       .resource       = ar71xx_ohci_resources,
+       .num_resources  = ARRAY_SIZE(ar71xx_ohci_resources),
        .dev = {
                .dma_mask               = &ar71xx_ohci_dmamask,
                .coherent_dma_mask      = DMA_BIT_MASK(32),
@@ -55,7 +54,7 @@ static struct platform_device ar71xx_usb_ohci_device = {
 /*
  * EHCI (USB full speed host controller)
  */
-static struct resource ar71xx_usb_ehci_resources[] = {
+static struct resource ar71xx_ehci_resources[] = {
        [0] = {
                .start  = AR71XX_EHCI_BASE,
                .end    = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1,
@@ -68,15 +67,19 @@ static struct resource ar71xx_usb_ehci_resources[] = {
        },
 };
 
+
 static u64 ar71xx_ehci_dmamask = DMA_BIT_MASK(32);
-static struct platform_device ar71xx_usb_ehci_device = {
+static struct ar71xx_ehci_platform_data ar71xx_ehci_data;
+
+static struct platform_device ar71xx_ehci_device = {
        .name           = "ar71xx-ehci",
        .id             = -1,
-       .resource       = ar71xx_usb_ehci_resources,
-       .num_resources  = ARRAY_SIZE(ar71xx_usb_ehci_resources),
+       .resource       = ar71xx_ehci_resources,
+       .num_resources  = ARRAY_SIZE(ar71xx_ehci_resources),
        .dev = {
                .dma_mask               = &ar71xx_ehci_dmamask,
                .coherent_dma_mask      = DMA_BIT_MASK(32),
+               .platform_data          = &ar71xx_ehci_data,
        },
 };
 
@@ -84,7 +87,7 @@ static struct platform_device ar71xx_usb_ehci_device = {
        (RESET_MODULE_USB_HOST | RESET_MODULE_USB_PHY \
        | RESET_MODULE_USB_OHCI_DLL)
 
-void __init ar71xx_add_device_usb(void)
+static void ar71xx_usb_setup(void)
 {
        ar71xx_device_stop(AR71XX_USB_RESET_MASK);
        mdelay(1000);
@@ -97,14 +100,44 @@ void __init ar71xx_add_device_usb(void)
        ar71xx_usb_ctrl_wr(USB_CTRL_REG_FLADJ, 0x20c00);
 
        mdelay(900);
+}
 
-       platform_device_register(&ar71xx_usb_ohci_device);
-       platform_device_register(&ar71xx_usb_ehci_device);
+static void ar91xx_usb_setup(void)
+{
+       ar71xx_device_stop(RESET_MODULE_USBSUS_OVERRIDE);
+       mdelay(10);
+
+       ar71xx_device_start(RESET_MODULE_USB_HOST);
+       mdelay(10);
+
+       ar71xx_device_start(RESET_MODULE_USB_PHY);
+       mdelay(10);
 }
 
-#ifdef CONFIG_AR71XX_EARLY_SERIAL
-static void __init ar71xx_add_device_uart(void) {};
-#else
+void __init ar71xx_add_device_usb(void)
+{
+       switch (ar71xx_soc) {
+       case AR71XX_SOC_AR7130:
+       case AR71XX_SOC_AR7141:
+       case AR71XX_SOC_AR7161:
+               ar71xx_usb_setup();
+               platform_device_register(&ar71xx_ohci_device);
+               platform_device_register(&ar71xx_ehci_device);
+               break;
+
+       case AR71XX_SOC_AR9130:
+       case AR71XX_SOC_AR9132:
+               ar91xx_usb_setup();
+               ar71xx_ehci_data.is_ar91xx = 1;
+               platform_device_register(&ar71xx_ehci_device);
+               break;
+
+       default:
+               BUG();
+       }
+}
+
+#ifndef CONFIG_AR71XX_EARLY_SERIAL
 static struct resource ar71xx_uart_resources[] = {
        {
                .start  = AR71XX_UART_BASE,
@@ -136,7 +169,7 @@ static struct platform_device ar71xx_uart_device = {
        },
 };
 
-static void __init ar71xx_add_device_uart(void)
+void __init ar71xx_add_device_uart(void)
 {
        ar71xx_uart_data[0].uartclk = ar71xx_ahb_freq;
        platform_device_register(&ar71xx_uart_device);
@@ -448,8 +481,6 @@ void __init ar71xx_add_device_spi(struct ar71xx_spi_platform_data *pdata,
                                struct spi_board_info const *info,
                                unsigned n)
 {
-       ar71xx_gpio_function_enable(GPIO_FUNC_SPI_EN);
-
        spi_register_board_info(info, n);
        ar71xx_spi_device.dev.platform_data = pdata;
        platform_device_register(&ar71xx_spi_device);
@@ -561,16 +592,3 @@ void __init ar71xx_parse_mac_addr(char *mac_str)
                printk(KERN_DEBUG "ar71xx: failed to parse mac address "
                                "\"%s\"\n", mac_str);
 }
-
-static int __init ar71xx_machine_setup(void)
-{
-       ar71xx_gpio_init();
-
-       ar71xx_add_device_uart();
-       ar71xx_add_device_wdt();
-
-       mips_machine_setup(ar71xx_mach_type);
-       return 0;
-}
-
-arch_initcall(ar71xx_machine_setup);