ar71xx: add support for the wzr-hp-g300nh2
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-pb44.c
index 008babc5cc0541894412ce55c1e59bda27d7ef90..5e013504e6e62dd9626066438b7fd94e7b913598 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <linux/init.h>
 #include <linux/bitops.h>
-#include <linux/input.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/i2c-gpio.h>
 #include <linux/i2c/pcf857x.h>
 
-#include <asm/mips_machine.h>
 #include <asm/mach-ar71xx/ar71xx.h>
 
+#include "machtype.h"
 #include "devices.h"
 #include "dev-pb42-pci.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-usb.h"
 
 #define PB44_PCF8757_VSC7395_CS        0
 #define PB44_PCF8757_STEREO_CS 1
@@ -52,6 +54,9 @@
 #define PB44_GPIO_LED_JUMP1    (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP1)
 #define PB44_GPIO_LED_JUMP2    (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP2)
 
+#define PB44_KEYS_POLL_INTERVAL                20      /* msecs */
+#define PB44_KEYS_DEBOUNCE_INTERVAL    (3 * PB44_KEYS_POLL_INTERVAL)
+
 static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
        .sda_pin        = PB44_GPIO_I2C_SDA,
        .scl_pin        = PB44_GPIO_I2C_SCL,
@@ -88,19 +93,19 @@ static struct gpio_led pb44_leds_gpio[] __initdata = {
        },
 };
 
-static struct gpio_button pb44_gpio_buttons[] __initdata = {
+static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
        {
                .desc           = "soft_reset",
                .type           = EV_KEY,
-               .code           = BTN_0,
-               .threshold      = 5,
+               .code           = KEY_RESTART,
+               .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
                .gpio           = PB44_GPIO_SW_RESET,
                .active_low     = 1,
-       } , {
+       }, {
                .desc           = "jumpstart",
                .type           = EV_KEY,
-               .code           = BTN_1,
-               .threshold      = 5,
+               .code           = KEY_WPS_BUTTON,
+               .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
                .gpio           = PB44_GPIO_SW_JUMP,
                .active_low     = 1,
        }
@@ -124,12 +129,22 @@ static struct vsc7385_platform_data pb44_vsc7395_data = {
        },
 };
 
+static const char *pb44_part_probes[] = {
+       "RedBoot",
+       NULL,
+};
+
+static struct flash_platform_data pb44_flash_data = {
+       .part_probes    = pb44_part_probes,
+};
+
 static struct spi_board_info pb44_spi_info[] = {
        {
                .bus_num        = 0,
                .chip_select    = 0,
                .max_speed_hz   = 25000000,
                .modalias       = "m25p80",
+               .platform_data  = &pb44_flash_data,
        }, {
                .bus_num        = 0,
                .chip_select    = 1,
@@ -169,15 +184,16 @@ static struct platform_device pb44_spi_device = {
 
 static void __init pb44_init(void)
 {
-       ar71xx_add_device_mdio(~PB44_MDIO_PHYMASK);
+       ar71xx_add_device_mdio(0, ~PB44_MDIO_PHYMASK);
 
+       ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0);
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
        ar71xx_eth0_data.phy_mask = PB44_WAN_PHYMASK;
 
        ar71xx_add_device_eth(0);
 
+       ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1);
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth1_data.phy_mask = PB44_LAN_PHYMASK;
        ar71xx_eth1_data.speed = SPEED_1000;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
        ar71xx_eth1_pll_data.pll_1000 = 0x110000;
@@ -189,7 +205,7 @@ static void __init pb44_init(void)
        pb42_pci_init();
 
        i2c_register_board_info(0, pb44_i2c_board_info,
-                               ARRAY_SIZE(pb44_i2c_board_info));
+                               ARRAY_SIZE(pb44_i2c_board_info));
 
        platform_device_register(&pb44_i2c_gpio_device);
 
@@ -197,10 +213,11 @@ static void __init pb44_init(void)
        platform_device_register(&pb44_spi_device);
 
        ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
-                                   pb44_leds_gpio);
+                                       pb44_leds_gpio);
 
-       ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(pb44_gpio_buttons),
-                                      pb44_gpio_buttons);
+       ar71xx_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
+                                        ARRAY_SIZE(pb44_gpio_keys),
+                                        pb44_gpio_keys);
 }
 
-MIPS_MACHINE(AR71XX_MACH_PB44, "Atheros PB44", pb44_init);
+MIPS_MACHINE(AR71XX_MACH_PB44, "PB44", "Atheros PB44", pb44_init);