[ar71xx] enable TL-WR941ND in kernel config
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / platform.c
index ad22e06e17a23798bf0e7a020fa026fd9b905737..6a29fc46a00429ed776b5e90bc17ba01ac8d0122 100644 (file)
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/etherdevice.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
+#include <linux/ath9k_platform.h>
 
-#include <asm/mips_machine.h>
 #include <asm/mach-ar71xx/ar71xx.h>
 #include <asm/mach-ar71xx/platform.h>
 
@@ -103,6 +104,18 @@ static void ar71xx_usb_setup(void)
        mdelay(900);
 }
 
+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);
+}
+
 void __init ar71xx_add_device_usb(void)
 {
        switch (ar71xx_soc) {
@@ -116,6 +129,7 @@ void __init ar71xx_add_device_usb(void)
 
        case AR71XX_SOC_AR9130:
        case AR71XX_SOC_AR9132:
+               ar91xx_usb_setup();
                ar71xx_ehci_data.is_ar91xx = 1;
                platform_device_register(&ar71xx_ehci_device);
                break;
@@ -125,9 +139,7 @@ void __init ar71xx_add_device_usb(void)
        }
 }
 
-#ifdef CONFIG_AR71XX_EARLY_SERIAL
-static void __init ar71xx_add_device_uart(void) {};
-#else
+#ifndef CONFIG_AR71XX_EARLY_SERIAL
 static struct resource ar71xx_uart_resources[] = {
        {
                .start  = AR71XX_UART_BASE,
@@ -159,7 +171,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);
@@ -445,8 +457,15 @@ void __init ar71xx_add_device_eth(unsigned int id)
                break;
        }
 
-       memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN);
-       pdata->mac_addr[5] += ar71xx_eth_instance;
+       if (is_valid_ether_addr(ar71xx_mac_base)) {
+               memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN);
+               pdata->mac_addr[5] += ar71xx_eth_instance;
+       } else {
+               random_ether_addr(pdata->mac_addr);
+               printk(KERN_DEBUG
+                       "ar71xx: using random MAC address for eth%d\n",
+                       ar71xx_eth_instance);
+       }
 
        platform_device_register(pdev);
        ar71xx_eth_instance++;
@@ -471,8 +490,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);
@@ -498,7 +515,7 @@ void __init ar71xx_add_device_leds_gpio(int id, unsigned num_leds,
 
        memset(&pdata, 0, sizeof(pdata));
        pdata.num_leds = num_leds;
-       pdata.leds = leds;
+       pdata.leds = p;
 
        err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
        if (err)
@@ -578,6 +595,10 @@ void __init ar71xx_parse_mac_addr(char *mac_str)
        t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
                        &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
 
+       if (t != ETH_ALEN)
+               t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
+                       &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
+
        if (t == ETH_ALEN)
                ar71xx_set_mac_base(tmp);
        else
@@ -585,15 +606,42 @@ void __init ar71xx_parse_mac_addr(char *mac_str)
                                "\"%s\"\n", mac_str);
 }
 
-static int __init ar71xx_machine_setup(void)
+static struct resource ar91xx_wmac_resources[] = {
+       {
+               .start  = AR91XX_WMAC_BASE,
+               .end    = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .start  = AR71XX_CPU_IRQ_WMAC,
+               .end    = AR71XX_CPU_IRQ_WMAC,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct ath9k_platform_data ar91xx_wmac_data;
+
+static struct platform_device ar91xx_wmac_device = {
+       .name           = "ath9k",
+       .id             = -1,
+       .resource       = ar91xx_wmac_resources,
+       .num_resources  = ARRAY_SIZE(ar91xx_wmac_resources),
+       .dev = {
+               .platform_data = &ar91xx_wmac_data,
+       },
+};
+
+void __init ar91xx_add_device_wmac(void)
 {
-       ar71xx_gpio_init();
+       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
 
-       ar71xx_add_device_uart();
-       ar71xx_add_device_wdt();
+       memcpy(ar91xx_wmac_data.eeprom_data, ee,
+              sizeof(ar91xx_wmac_data.eeprom_data));
 
-       mips_machine_setup(ar71xx_mach_type);
-       return 0;
-}
+       ar71xx_device_stop(RESET_MODULE_AMBA2WMAC);
+       mdelay(10);
+
+       ar71xx_device_start(RESET_MODULE_AMBA2WMAC);
+       mdelay(10);
 
-arch_initcall(ar71xx_machine_setup);
+       platform_device_register(&ar91xx_wmac_device);
+}