2 * jjPlus JA76PF board support
6 #include <linux/i2c-gpio.h>
7 #include <linux/platform_device.h>
9 #include <asm/mach-ath79/ath79.h>
12 #include "dev-gpio-buttons.h"
13 #include "dev-leds-gpio.h"
14 #include "dev-m25p80.h"
16 #include "machtypes.h"
19 #define JA76PF_KEYS_POLL_INTERVAL 20 /* msecs */
20 #define JA76PF_KEYS_DEBOUNCE_INTERVAL (3 * JA76PF_KEYS_POLL_INTERVAL)
22 #define JA76PF_GPIO_I2C_SCL 0
23 #define JA76PF_GPIO_I2C_SDA 1
24 #define JA76PF_GPIO_LED_1 5
25 #define JA76PF_GPIO_LED_2 4
26 #define JA76PF_GPIO_LED_3 3
27 #define JA76PF_GPIO_BTN_RESET 11
29 static struct gpio_led ja76pf_leds_gpio[] __initdata = {
31 .name = "jjplus:green:led1",
32 .gpio = JA76PF_GPIO_LED_1,
35 .name = "jjplus:green:led2",
36 .gpio = JA76PF_GPIO_LED_2,
39 .name = "jjplus:green:led3",
40 .gpio = JA76PF_GPIO_LED_3,
45 static struct gpio_keys_button ja76pf_gpio_keys[] __initdata = {
50 .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
51 .gpio = JA76PF_GPIO_BTN_RESET,
56 static struct i2c_gpio_platform_data ja76pf_i2c_gpio_data = {
57 .sda_pin = JA76PF_GPIO_I2C_SDA,
58 .scl_pin = JA76PF_GPIO_I2C_SCL,
61 static struct platform_device ja76pf_i2c_gpio_device = {
65 .platform_data = &ja76pf_i2c_gpio_data,
69 static const char *ja76pf_part_probes[] = {
74 static struct flash_platform_data ja76pf_flash_data = {
75 .part_probes = ja76pf_part_probes,
78 #define JA76PF_WAN_PHYMASK (1 << 4)
79 #define JA76PF_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 < 3))
80 #define JA76PF_MDIO_PHYMASK (JA76PF_LAN_PHYMASK | JA76PF_WAN_PHYMASK)
82 static void __init ja76pf_init(void)
84 ath79_register_m25p80(&ja76pf_flash_data);
86 ath79_register_mdio(0, ~JA76PF_MDIO_PHYMASK);
88 ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
89 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
90 ath79_eth0_data.phy_mask = JA76PF_LAN_PHYMASK;
92 ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
93 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
94 ath79_eth1_data.phy_mask = JA76PF_WAN_PHYMASK;
95 ath79_eth1_data.speed = SPEED_1000;
96 ath79_eth1_data.duplex = DUPLEX_FULL;
98 ath79_register_eth(0);
99 ath79_register_eth(1);
101 platform_device_register(&ja76pf_i2c_gpio_device);
103 ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf_leds_gpio),
106 ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
107 ARRAY_SIZE(ja76pf_gpio_keys),
110 ath79_register_usb();
111 ath79_register_pci();
114 MIPS_MACHINE(ATH79_MACH_JA76PF, "JA76PF", "jjPlus JA76PF", ja76pf_init);
116 #define JA76PF2_GPIO_LED_D2 5
117 #define JA76PF2_GPIO_LED_D3 4
118 #define JA76PF2_GPIO_LED_D4 3
119 #define JA76PF2_GPIO_BTN_RESET 7
120 #define JA76PF2_GPIO_BTN_WPS 8
122 static struct gpio_led ja76pf2_leds_gpio[] __initdata = {
124 .name = "jjplus:green:led1",
125 .gpio = JA76PF2_GPIO_LED_D2,
128 .name = "jjplus:green:led2",
129 .gpio = JA76PF2_GPIO_LED_D3,
132 .name = "jjplus:green:led3",
133 .gpio = JA76PF2_GPIO_LED_D4,
138 static struct gpio_keys_button ja76pf2_gpio_keys[] __initdata = {
143 .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
144 .gpio = JA76PF2_GPIO_BTN_RESET,
150 .code = KEY_WPS_BUTTON,
151 .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
152 .gpio = JA76PF2_GPIO_BTN_WPS,
157 #define JA76PF2_LAN_PHYMASK BIT(0)
158 #define JA76PF2_WAN_PHYMASK BIT(4)
159 #define JA76PF2_MDIO_PHYMASK (JA76PF2_LAN_PHYMASK | JA76PF2_WAN_PHYMASK)
161 static void __init ja76pf2_init(void)
163 ath79_register_m25p80(&ja76pf_flash_data);
165 ath79_register_mdio(0, ~JA76PF2_MDIO_PHYMASK);
167 /* MAC0 is connected to the CPU port of the AR8316 switch */
168 ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
169 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
170 ath79_eth0_data.phy_mask = BIT(0);
172 /* MAC1 is connected to the PHY4 of the AR8316 switch */
173 ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
174 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
175 ath79_eth1_data.phy_mask = BIT(4);
177 ath79_register_eth(0);
178 ath79_register_eth(1);
180 ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf2_leds_gpio),
183 ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
184 ARRAY_SIZE(ja76pf2_gpio_keys),
187 ath79_register_pci();
190 MIPS_MACHINE(ATH79_MACH_JA76PF2, "JA76PF2", "jjPlus JA76PF2", ja76pf2_init);