ar71xx: build ALFA AP96 images with default profile as well
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-eap7660d.c
index 3006698f941fb0906dd0ccfefed0e71262a352f7..d1e49eef05d162756ab8967bda1ff3ad81d5dc06 100644 (file)
@@ -22,7 +22,9 @@
 #include "dev-leds-gpio.h"
 #include "dev-m25p80.h"
 
-#define EAP7660D_BUTTONS_POLL_INTERVAL 20
+#define EAP7660D_KEYS_POLL_INTERVAL    20      /* msecs */
+#define EAP7660D_KEYS_DEBOUNCE_INTERVAL        (3 * EAP7660D_KEYS_POLL_INTERVAL)
+
 #define EAP7660D_GPIO_DS4              7
 #define EAP7660D_GPIO_DS5              2
 #define EAP7660D_GPIO_DS7              0
@@ -44,21 +46,22 @@ static char eap7660d_wmac1_mac[6];
 static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
 static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
 
+#ifdef CONFIG_PCI
 static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
-        {
-                .slot   = 0,
-                .pin    = 1,
-                .irq    = AR71XX_PCI_IRQ_DEV0,
-        }, {
-                .slot   = 1,
-                .pin    = 1,
-                .irq    = AR71XX_PCI_IRQ_DEV1,
-        }
+       {
+               .slot   = 0,
+               .pin    = 1,
+               .irq    = AR71XX_PCI_IRQ_DEV0,
+       }, {
+               .slot   = 1,
+               .pin    = 1,
+               .irq    = AR71XX_PCI_IRQ_DEV1,
+       }
 };
 
 static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
 {
-       switch(PCI_SLOT(dev->devfn)) {
+       switch (PCI_SLOT(dev->devfn)) {
        case 17:
                dev->dev.platform_data = &eap7660d_wmac0_data;
                break;
@@ -72,7 +75,7 @@ static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
 }
 
 void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
-                         u8 *cal_data1, u8 *mac_addr1)
+                             u8 *cal_data1, u8 *mac_addr1)
 {
        if (cal_data0 && *cal_data0 == 0xa55a) {
                memcpy(eap7660d_wmac0_eeprom, cal_data0,
@@ -87,18 +90,26 @@ void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
        }
 
        if (mac_addr0) {
-               memcpy(eap7660d_wmac0_mac, mac_addr0, sizeof(eap7660d_wmac0_mac));
+               memcpy(eap7660d_wmac0_mac, mac_addr0,
+                       sizeof(eap7660d_wmac0_mac));
                eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
        }
 
        if (mac_addr1) {
-               memcpy(eap7660d_wmac1_mac, mac_addr1, sizeof(eap7660d_wmac1_mac));
+               memcpy(eap7660d_wmac1_mac, mac_addr1,
+                       sizeof(eap7660d_wmac1_mac));
                eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
        }
 
        ar71xx_pci_plat_dev_init = eap7660d_pci_plat_dev_init;
        ar71xx_pci_init(ARRAY_SIZE(eap7660d_pci_irqs), eap7660d_pci_irqs);
 }
+#else
+static inline void eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
+                                    u8 *cal_data1, u8 *mac_addr1)
+{
+}
+#endif /* CONFIG_PCI */
 
 static struct gpio_led eap7660d_leds_gpio[] __initdata = {
        {
@@ -123,12 +134,12 @@ static struct gpio_led eap7660d_leds_gpio[] __initdata = {
        }
 };
 
-static struct gpio_button eap7660d_gpio_buttons[] __initdata = {
+static struct gpio_keys_button eap7660d_gpio_keys[] __initdata = {
        {
                .desc           = "reset",
                .type           = EV_KEY,
                .code           = KEY_RESTART,
-               .threshold      = 3,
+               .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
                .gpio           = EAP7660D_GPIO_SW1,
                .active_low     = 1,
        },
@@ -136,29 +147,38 @@ static struct gpio_button eap7660d_gpio_buttons[] __initdata = {
                .desc           = "wps",
                .type           = EV_KEY,
                .code           = KEY_WPS_BUTTON,
-               .threshold      = 3,
+               .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
                .gpio           = EAP7660D_GPIO_SW3,
                .active_low     = 1,
        }
 };
 
+static const char *eap7660d_part_probes[] = {
+       "RedBoot",
+       NULL,
+};
+
+static struct flash_platform_data eap7660d_flash_data = {
+       .part_probes    = eap7660d_part_probes,
+};
+
 static void __init eap7660d_setup(void)
 {
        u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
 
-       ar71xx_add_device_mdio(~EAP7660D_PHYMASK);
+       ar71xx_add_device_mdio(0, ~EAP7660D_PHYMASK);
 
        ar71xx_init_mac(ar71xx_eth0_data.mac_addr,
                        boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0);
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
        ar71xx_eth0_data.phy_mask = EAP7660D_PHYMASK;
        ar71xx_add_device_eth(0);
-       ar71xx_add_device_m25p80(NULL);
+       ar71xx_add_device_m25p80(&eap7660d_flash_data);
        ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
                                        eap7660d_leds_gpio);
-       ar71xx_add_device_gpio_buttons(-1, EAP7660D_BUTTONS_POLL_INTERVAL,
-                                       ARRAY_SIZE(eap7660d_gpio_buttons),
-                                       eap7660d_gpio_buttons);
+       ar71xx_register_gpio_keys_polled(-1, EAP7660D_KEYS_POLL_INTERVAL,
+                                        ARRAY_SIZE(eap7660d_gpio_keys),
+                                        eap7660d_gpio_keys);
        eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
                        boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
                        boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,