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