OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | |
2 | /* |
||
3 | * Atheros ARCHER_C7 reference board support |
||
4 | * |
||
5 | * Copyright (c) 2017 Felix Fietkau <nbd@nbd.name> |
||
6 | * Copyright (c) 2014 The Linux Foundation. All rights reserved. |
||
7 | * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org> |
||
8 | * |
||
9 | * Permission to use, copy, modify, and/or distribute this software for any |
||
10 | * purpose with or without fee is hereby granted, provided that the above |
||
11 | * copyright notice and this permission notice appear in all copies. |
||
12 | * |
||
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
20 | * |
||
21 | */ |
||
22 | |||
23 | #include <linux/platform_device.h> |
||
24 | #include <linux/ath9k_platform.h> |
||
25 | #include <linux/ar8216_platform.h> |
||
26 | #include <linux/proc_fs.h> |
||
27 | #include <linux/gpio.h> |
||
28 | #include <linux/spi/spi_gpio.h> |
||
29 | #include <linux/spi/74x164.h> |
||
30 | |||
31 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
32 | |||
33 | #include "common.h" |
||
34 | #include "dev-m25p80.h" |
||
35 | #include "machtypes.h" |
||
36 | #include "pci.h" |
||
37 | #include "dev-eth.h" |
||
38 | #include "dev-gpio-buttons.h" |
||
39 | #include "dev-leds-gpio.h" |
||
40 | #include "dev-spi.h" |
||
41 | #include "dev-usb.h" |
||
42 | #include "dev-wmac.h" |
||
43 | |||
44 | |||
45 | #define ARCHER_C7_GPIO_SHIFT_OE 1 |
||
46 | #define ARCHER_C7_GPIO_SHIFT_SER 14 |
||
47 | #define ARCHER_C7_GPIO_SHIFT_SRCLK 15 |
||
48 | #define ARCHER_C7_GPIO_SHIFT_RCLK 16 |
||
49 | #define ARCHER_C7_GPIO_SHIFT_SRCLR 21 |
||
50 | |||
51 | #define ARCHER_C7_GPIO_BTN_RESET 5 |
||
52 | #define ARCHER_C7_GPIO_BTN_WPS_WIFI 2 |
||
53 | |||
54 | #define ARCHER_C7_GPIO_LED_WLAN5 9 |
||
55 | #define ARCHER_C7_GPIO_LED_POWER 6 |
||
56 | #define ARCHER_C7_GPIO_LED_USB1 7 |
||
57 | #define ARCHER_C7_GPIO_LED_USB2 8 |
||
58 | |||
59 | #define ARCHER_C7_74HC_GPIO_BASE 32 |
||
60 | #define ARCHER_C7_GPIO_LED_WPS (ARCHER_C7_74HC_GPIO_BASE + 0) |
||
61 | #define ARCHER_C7_GPIO_LED_LAN1 (ARCHER_C7_74HC_GPIO_BASE + 1) |
||
62 | #define ARCHER_C7_GPIO_LED_LAN2 (ARCHER_C7_74HC_GPIO_BASE + 2) |
||
63 | #define ARCHER_C7_GPIO_LED_LAN3 (ARCHER_C7_74HC_GPIO_BASE + 3) |
||
64 | #define ARCHER_C7_GPIO_LED_LAN4 (ARCHER_C7_74HC_GPIO_BASE + 4) |
||
65 | #define ARCHER_C7_GPIO_LED_WAN_GREEN (ARCHER_C7_74HC_GPIO_BASE + 5) |
||
66 | #define ARCHER_C7_GPIO_LED_WAN_AMBER (ARCHER_C7_74HC_GPIO_BASE + 6) |
||
67 | #define ARCHER_C7_GPIO_LED_WLAN2 (ARCHER_C7_74HC_GPIO_BASE + 7) |
||
68 | |||
69 | #define ARCHER_C7_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
70 | #define ARCHER_C7_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C7_KEYS_POLL_INTERVAL) |
||
71 | |||
72 | #define ARCHER_C7_MAC0_OFFSET 0 |
||
73 | #define ARCHER_C7_MAC1_OFFSET 6 |
||
74 | #define ARCHER_C7_WMAC_CALDATA_OFFSET 0x1000 |
||
75 | |||
76 | #define ARCHER_C7_GPIO_MDC 3 |
||
77 | #define ARCHER_C7_GPIO_MDIO 4 |
||
78 | |||
79 | static struct spi_gpio_platform_data archer_c7_v4_spi_data = { |
||
80 | .sck = ARCHER_C7_GPIO_SHIFT_SRCLK, |
||
81 | .miso = SPI_GPIO_NO_MISO, |
||
82 | .mosi = ARCHER_C7_GPIO_SHIFT_SER, |
||
83 | .num_chipselect = 1, |
||
84 | }; |
||
85 | |||
86 | static u8 archer_c7_v4_ssr_initdata = 0xff; |
||
87 | |||
88 | static struct gen_74x164_chip_platform_data archer_c7_v4_ssr_data = { |
||
89 | .base = ARCHER_C7_74HC_GPIO_BASE, |
||
90 | .num_registers = 1, |
||
91 | .init_data = &archer_c7_v4_ssr_initdata, |
||
92 | }; |
||
93 | |||
94 | static struct platform_device archer_c7_v4_spi_device = { |
||
95 | .name = "spi_gpio", |
||
96 | .id = 1, |
||
97 | .dev = { |
||
98 | .platform_data = &archer_c7_v4_spi_data, |
||
99 | }, |
||
100 | }; |
||
101 | |||
102 | static struct spi_board_info archer_c7_v4_spi_info[] = { |
||
103 | { |
||
104 | .bus_num = 1, |
||
105 | .chip_select = 0, |
||
106 | .max_speed_hz = 10000000, |
||
107 | .modalias = "74x164", |
||
108 | .platform_data = &archer_c7_v4_ssr_data, |
||
109 | .controller_data = (void *) ARCHER_C7_GPIO_SHIFT_RCLK, |
||
110 | }, |
||
111 | }; |
||
112 | |||
113 | static struct gpio_led archer_c7_v4_leds_gpio[] __initdata = { |
||
114 | { |
||
115 | .name = "archer-c7-v4:green:power", |
||
116 | .gpio = ARCHER_C7_GPIO_LED_POWER, |
||
117 | .active_low = 1, |
||
118 | }, { |
||
119 | .name = "archer-c7-v4:green:wps", |
||
120 | .gpio = ARCHER_C7_GPIO_LED_WPS, |
||
121 | .active_low = 1, |
||
122 | }, { |
||
123 | .name = "archer-c7-v4:green:wlan2g", |
||
124 | .gpio = ARCHER_C7_GPIO_LED_WLAN2, |
||
125 | .active_low = 1, |
||
126 | }, { |
||
127 | .name = "archer-c7-v4:green:wlan5g", |
||
128 | .gpio = ARCHER_C7_GPIO_LED_WLAN5, |
||
129 | .active_low = 1, |
||
130 | }, { |
||
131 | .name = "archer-c7-v4:green:lan1", |
||
132 | .gpio = ARCHER_C7_GPIO_LED_LAN1, |
||
133 | .active_low = 1, |
||
134 | }, { |
||
135 | .name = "archer-c7-v4:green:lan2", |
||
136 | .gpio = ARCHER_C7_GPIO_LED_LAN2, |
||
137 | .active_low = 1, |
||
138 | }, { |
||
139 | .name = "archer-c7-v4:green:lan3", |
||
140 | .gpio = ARCHER_C7_GPIO_LED_LAN3, |
||
141 | .active_low = 1, |
||
142 | }, { |
||
143 | .name = "archer-c7-v4:green:lan4", |
||
144 | .gpio = ARCHER_C7_GPIO_LED_LAN4, |
||
145 | .active_low = 1, |
||
146 | }, { |
||
147 | .name = "archer-c7-v4:green:wan", |
||
148 | .gpio = ARCHER_C7_GPIO_LED_WAN_GREEN, |
||
149 | .active_low = 1, |
||
150 | }, { |
||
151 | .name = "archer-c7-v4:amber:wan", |
||
152 | .gpio = ARCHER_C7_GPIO_LED_WAN_AMBER, |
||
153 | .active_low = 1, |
||
154 | }, { |
||
155 | .name = "archer-c7-v4:green:usb1", |
||
156 | .gpio = ARCHER_C7_GPIO_LED_USB1, |
||
157 | .active_low = 1, |
||
158 | }, { |
||
159 | .name = "archer-c7-v4:green:usb2", |
||
160 | .gpio = ARCHER_C7_GPIO_LED_USB2, |
||
161 | .active_low = 1, |
||
162 | }, |
||
163 | }; |
||
164 | |||
165 | static struct gpio_keys_button archer_c7_v4_gpio_keys[] __initdata = { |
||
166 | { |
||
167 | .desc = "WPS and WIFI button", |
||
168 | .type = EV_KEY, |
||
169 | .code = KEY_WPS_BUTTON, |
||
170 | .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL, |
||
171 | .gpio = ARCHER_C7_GPIO_BTN_WPS_WIFI, |
||
172 | .active_low = 1, |
||
173 | }, |
||
174 | { |
||
175 | .desc = "Reset button", |
||
176 | .type = EV_KEY, |
||
177 | .code = KEY_RESTART, |
||
178 | .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL, |
||
179 | .gpio = ARCHER_C7_GPIO_BTN_RESET, |
||
180 | .active_low = 1, |
||
181 | }, |
||
182 | }; |
||
183 | |||
184 | static struct ar8327_pad_cfg archer_c7_v4_ar8337_pad0_cfg = { |
||
185 | .mode = AR8327_PAD_MAC_SGMII, |
||
186 | .sgmii_delay_en = true, |
||
187 | }; |
||
188 | |||
189 | static struct ar8327_platform_data archer_c7_v4_ar8337_data = { |
||
190 | .pad0_cfg = &archer_c7_v4_ar8337_pad0_cfg, |
||
191 | .port0_cfg = { |
||
192 | .force_link = 1, |
||
193 | .speed = AR8327_PORT_SPEED_1000, |
||
194 | .duplex = 1, |
||
195 | .txpause = 1, |
||
196 | .rxpause = 1, |
||
197 | }, |
||
198 | }; |
||
199 | |||
200 | static struct mdio_board_info archer_c7_v4_mdio0_info[] = { |
||
201 | { |
||
202 | .bus_id = "ag71xx-mdio.0", |
||
203 | .phy_addr = 0, |
||
204 | .platform_data = &archer_c7_v4_ar8337_data, |
||
205 | }, |
||
206 | }; |
||
207 | |||
208 | |||
209 | static void __init archer_c7_v4_setup(void) |
||
210 | { |
||
211 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
212 | u8 *mac = (u8 *) KSEG1ADDR(0x1ff00008); |
||
213 | |||
214 | ath79_register_m25p80(NULL); |
||
215 | |||
216 | spi_register_board_info(archer_c7_v4_spi_info, |
||
217 | ARRAY_SIZE(archer_c7_v4_spi_info)); |
||
218 | |||
219 | platform_device_register(&archer_c7_v4_spi_device); |
||
220 | |||
221 | gpio_request_one(ARCHER_C7_GPIO_SHIFT_OE, |
||
222 | GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, |
||
223 | "LED control"); |
||
224 | |||
225 | gpio_request_one(ARCHER_C7_GPIO_SHIFT_SRCLR, |
||
226 | GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, |
||
227 | "LED reset"); |
||
228 | |||
229 | ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c7_v4_leds_gpio), |
||
230 | archer_c7_v4_leds_gpio); |
||
231 | |||
232 | ath79_register_gpio_keys_polled(-1, ARCHER_C7_KEYS_POLL_INTERVAL, |
||
233 | ARRAY_SIZE(archer_c7_v4_gpio_keys), |
||
234 | archer_c7_v4_gpio_keys); |
||
235 | |||
236 | ath79_register_usb(); |
||
237 | |||
238 | ath79_gpio_output_select(ARCHER_C7_GPIO_MDC, QCA956X_GPIO_OUT_MUX_GE0_MDC); |
||
239 | ath79_gpio_output_select(ARCHER_C7_GPIO_MDIO, QCA956X_GPIO_OUT_MUX_GE0_MDO); |
||
240 | |||
241 | ath79_register_mdio(0, 0x0); |
||
242 | |||
243 | mdiobus_register_board_info(archer_c7_v4_mdio0_info, |
||
244 | ARRAY_SIZE(archer_c7_v4_mdio0_info)); |
||
245 | |||
246 | ath79_register_wmac(art + ARCHER_C7_WMAC_CALDATA_OFFSET, mac); |
||
247 | ath79_register_pci(); |
||
248 | |||
249 | /* GMAC0 is connected to an AR8337 switch */ |
||
250 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); |
||
251 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; |
||
252 | ath79_eth0_data.speed = SPEED_1000; |
||
253 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
254 | ath79_eth0_data.phy_mask = BIT(0); |
||
255 | ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
||
256 | ath79_register_eth(0); |
||
257 | } |
||
258 | |||
259 | MIPS_MACHINE(ATH79_MACH_ARCHER_C7_V4, "ARCHER-C7-V4", "TP-LINK Archer C7 v4", |
||
260 | archer_c7_v4_setup); |