ar71xx: use the tp-link parser on the tp-link boards
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-jwap003.c
1 /*
2  *  jjPlus JWAP003 board support
3  *
4  */
5
6 #include <asm/mach-ar71xx/ar71xx.h>
7 #include <linux/i2c.h>
8 #include <linux/i2c-gpio.h>
9 #include <linux/platform_device.h>
10
11 #include "machtype.h"
12 #include "devices.h"
13 #include "dev-m25p80.h"
14 #include "dev-gpio-buttons.h"
15 #include "dev-pb42-pci.h"
16 #include "dev-usb.h"
17
18 #define JWAP003_KEYS_POLL_INTERVAL      20      /* msecs */
19 #define JWAP003_KEYS_DEBOUNCE_INTERVAL  (3 * JWAP003_KEYS_POLL_INTERVAL)
20
21 #define JWAP003_GPIO_WPS        11
22 #define JWAP003_GPIO_I2C_SCL    0
23 #define JWAP003_GPIO_I2C_SDA    1
24
25 static struct gpio_keys_button jwap003_gpio_keys[] __initdata = {
26         {
27                 .desc           = "wps",
28                 .type           = EV_KEY,
29                 .code           = KEY_WPS_BUTTON,
30                 .debounce_interval = JWAP003_KEYS_DEBOUNCE_INTERVAL,
31                 .gpio           = JWAP003_GPIO_WPS,
32                 .active_low     = 1,
33         }
34 };
35
36 static struct i2c_gpio_platform_data jwap003_i2c_gpio_data = {
37         .sda_pin        = JWAP003_GPIO_I2C_SDA,
38         .scl_pin        = JWAP003_GPIO_I2C_SCL,
39 };
40
41 static struct platform_device jwap003_i2c_gpio_device = {
42         .name           = "i2c-gpio",
43         .id             = 0,
44         .dev = {
45                 .platform_data  = &jwap003_i2c_gpio_data,
46         }
47 };
48
49 static const char *jwap003_part_probes[] = {
50         "RedBoot",
51         NULL,
52 };
53
54 static struct flash_platform_data jwap003_flash_data = {
55         .part_probes    = jwap003_part_probes,
56 };
57
58 #define JWAP003_WAN_PHYMASK     BIT(0)
59 #define JWAP003_LAN_PHYMASK     BIT(4)
60
61 static void __init jwap003_init(void)
62 {
63         ar71xx_add_device_m25p80(&jwap003_flash_data);
64
65         ar71xx_add_device_mdio(0, 0x0);
66
67         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
68         ar71xx_eth0_data.phy_mask = JWAP003_WAN_PHYMASK;
69         ar71xx_eth0_data.speed = SPEED_100;
70         ar71xx_eth0_data.duplex = DUPLEX_FULL;
71         ar71xx_eth0_data.has_ar8216 = 1;
72
73         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
74         ar71xx_eth1_data.phy_mask = JWAP003_LAN_PHYMASK;
75         ar71xx_eth1_data.speed = SPEED_100;
76         ar71xx_eth1_data.duplex = DUPLEX_FULL;
77
78         ar71xx_add_device_eth(0);
79         ar71xx_add_device_eth(1);
80
81         platform_device_register(&jwap003_i2c_gpio_device);
82
83         ar71xx_add_device_usb();
84
85         ar71xx_register_gpio_keys_polled(-1, JWAP003_KEYS_POLL_INTERVAL,
86                                          ARRAY_SIZE(jwap003_gpio_keys),
87                                          jwap003_gpio_keys);
88
89         pb42_pci_init();
90 }
91
92 MIPS_MACHINE(AR71XX_MACH_JWAP003, "JWAP003", "jjPlus JWAP003", jwap003_init);