ar71xx: mach-rbspi: return rb_info from rbspi_platform_setup
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-ja76pf.c
1 /*
2 * jjPlus JA76PF board support
3 */
4
5 #include <linux/i2c.h>
6 #include <linux/i2c-gpio.h>
7 #include <linux/platform_device.h>
8
9 #include <asm/mach-ath79/ath79.h>
10
11 #include "dev-eth.h"
12 #include "dev-gpio-buttons.h"
13 #include "dev-leds-gpio.h"
14 #include "dev-m25p80.h"
15 #include "dev-usb.h"
16 #include "machtypes.h"
17 #include "pci.h"
18
19 #define JA76PF_KEYS_POLL_INTERVAL 20 /* msecs */
20 #define JA76PF_KEYS_DEBOUNCE_INTERVAL (3 * JA76PF_KEYS_POLL_INTERVAL)
21
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
28
29 static struct gpio_led ja76pf_leds_gpio[] __initdata = {
30 {
31 .name = "jjplus:green:led1",
32 .gpio = JA76PF_GPIO_LED_1,
33 .active_low = 1,
34 }, {
35 .name = "jjplus:green:led2",
36 .gpio = JA76PF_GPIO_LED_2,
37 .active_low = 1,
38 }, {
39 .name = "jjplus:green:led3",
40 .gpio = JA76PF_GPIO_LED_3,
41 .active_low = 1,
42 }
43 };
44
45 static struct gpio_keys_button ja76pf_gpio_keys[] __initdata = {
46 {
47 .desc = "reset",
48 .type = EV_KEY,
49 .code = KEY_RESTART,
50 .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
51 .gpio = JA76PF_GPIO_BTN_RESET,
52 .active_low = 1,
53 }
54 };
55
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,
59 };
60
61 static struct platform_device ja76pf_i2c_gpio_device = {
62 .name = "i2c-gpio",
63 .id = 0,
64 .dev = {
65 .platform_data = &ja76pf_i2c_gpio_data,
66 }
67 };
68
69 static const char *ja76pf_part_probes[] = {
70 "RedBoot",
71 NULL,
72 };
73
74 static struct flash_platform_data ja76pf_flash_data = {
75 .part_probes = ja76pf_part_probes,
76 };
77
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)
81
82 static void __init ja76pf_init(void)
83 {
84 ath79_register_m25p80(&ja76pf_flash_data);
85
86 ath79_register_mdio(0, ~JA76PF_MDIO_PHYMASK);
87
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;
91
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;
97
98 ath79_register_eth(0);
99 ath79_register_eth(1);
100
101 platform_device_register(&ja76pf_i2c_gpio_device);
102
103 ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf_leds_gpio),
104 ja76pf_leds_gpio);
105
106 ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
107 ARRAY_SIZE(ja76pf_gpio_keys),
108 ja76pf_gpio_keys);
109
110 ath79_register_usb();
111 ath79_register_pci();
112 }
113
114 MIPS_MACHINE(ATH79_MACH_JA76PF, "JA76PF", "jjPlus JA76PF", ja76pf_init);
115
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
121
122 static struct gpio_led ja76pf2_leds_gpio[] __initdata = {
123 {
124 .name = "jjplus:green:led1",
125 .gpio = JA76PF2_GPIO_LED_D2,
126 .active_low = 1,
127 }, {
128 .name = "jjplus:green:led2",
129 .gpio = JA76PF2_GPIO_LED_D3,
130 .active_low = 0,
131 }, {
132 .name = "jjplus:green:led3",
133 .gpio = JA76PF2_GPIO_LED_D4,
134 .active_low = 0,
135 }
136 };
137
138 static struct gpio_keys_button ja76pf2_gpio_keys[] __initdata = {
139 {
140 .desc = "reset",
141 .type = EV_KEY,
142 .code = KEY_RESTART,
143 .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
144 .gpio = JA76PF2_GPIO_BTN_RESET,
145 .active_low = 1,
146 },
147 {
148 .desc = "wps",
149 .type = EV_KEY,
150 .code = KEY_WPS_BUTTON,
151 .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
152 .gpio = JA76PF2_GPIO_BTN_WPS,
153 .active_low = 1,
154 },
155 };
156
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)
160
161 static void __init ja76pf2_init(void)
162 {
163 ath79_register_m25p80(&ja76pf_flash_data);
164
165 ath79_register_mdio(0, ~JA76PF2_MDIO_PHYMASK);
166
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);
171
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);
176
177 ath79_register_eth(0);
178 ath79_register_eth(1);
179
180 ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf2_leds_gpio),
181 ja76pf2_leds_gpio);
182
183 ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
184 ARRAY_SIZE(ja76pf2_gpio_keys),
185 ja76pf2_gpio_keys);
186
187 ath79_register_pci();
188 }
189
190 MIPS_MACHINE(ATH79_MACH_JA76PF2, "JA76PF2", "jjPlus JA76PF2", ja76pf2_init);