OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * P&W (Shenzhen Progress&Win Technologies) R602N and CPE505N boards support |
||
3 | * |
||
4 | * Copyright (C) 2017 Piotr Dymacz <pepe2k@gmail.com> |
||
5 | * |
||
6 | * Based on mach-zbt-we1526.c |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or modify it |
||
9 | * under the terms of the GNU General Public License version 2 as published |
||
10 | * by the Free Software Foundation. |
||
11 | */ |
||
12 | |||
13 | #include <linux/gpio.h> |
||
14 | #include <linux/platform_device.h> |
||
15 | |||
16 | #include <asm/mach-ath79/ath79.h> |
||
17 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
18 | |||
19 | #include "common.h" |
||
20 | #include "dev-eth.h" |
||
21 | #include "dev-gpio-buttons.h" |
||
22 | #include "dev-leds-gpio.h" |
||
23 | #include "dev-m25p80.h" |
||
24 | #include "dev-usb.h" |
||
25 | #include "dev-wmac.h" |
||
26 | #include "machtypes.h" |
||
27 | |||
28 | #define PW_GPIO_BTN_RESET 17 |
||
29 | |||
30 | #define PW_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
31 | #define PW_KEYS_DEBOUNCE_INTERVAL (3 * PW_KEYS_POLL_INTERVAL) |
||
32 | |||
33 | #define PW_MAC0_OFFSET 0x0 |
||
34 | #define PW_MAC1_OFFSET 0x6 |
||
35 | #define PW_WMAC_CALDATA_OFFSET 0x1000 |
||
36 | |||
37 | /* CPE505N GPIO LEDs */ |
||
38 | #define CPE505N_GPIO_LED_DIAG 12 |
||
39 | #define CPE505N_GPIO_LED_LAN 11 |
||
40 | #define CPE505N_GPIO_LED_STATUS 14 |
||
41 | #define CPE505N_GPIO_LED_WAN 4 |
||
42 | #define CPE505N_GPIO_LED_WLAN 15 |
||
43 | |||
44 | static struct gpio_led cpe505n_leds_gpio[] __initdata = { |
||
45 | { |
||
46 | .name = "cpe505n:red:diag", |
||
47 | .gpio = CPE505N_GPIO_LED_DIAG, |
||
48 | .active_low = 1, |
||
49 | }, { |
||
50 | .name = "cpe505n:green:lan", |
||
51 | .gpio = CPE505N_GPIO_LED_LAN, |
||
52 | .active_low = 1, |
||
53 | }, { |
||
54 | .name = "cpe505n:green:status", |
||
55 | .gpio = CPE505N_GPIO_LED_STATUS, |
||
56 | .active_low = 1, |
||
57 | }, { |
||
58 | .name = "cpe505n:green:wan", |
||
59 | .gpio = CPE505N_GPIO_LED_WAN, |
||
60 | .active_low = 1, |
||
61 | }, { |
||
62 | .name = "cpe505n:blue:wlan", |
||
63 | .gpio = CPE505N_GPIO_LED_WLAN, |
||
64 | .active_low = 1, |
||
65 | }, |
||
66 | }; |
||
67 | |||
68 | static void __init cpe505n_gpio_setup(void) |
||
69 | { |
||
70 | /* For LED on GPIO4 */ |
||
71 | ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN); |
||
72 | ath79_gpio_output_select(CPE505N_GPIO_LED_WAN, 0); |
||
73 | |||
74 | ath79_gpio_direction_select(CPE505N_GPIO_LED_DIAG, true); |
||
75 | ath79_gpio_direction_select(CPE505N_GPIO_LED_LAN, true); |
||
76 | ath79_gpio_direction_select(CPE505N_GPIO_LED_STATUS, true); |
||
77 | ath79_gpio_direction_select(CPE505N_GPIO_LED_WAN, true); |
||
78 | ath79_gpio_direction_select(CPE505N_GPIO_LED_WLAN, true); |
||
79 | |||
80 | /* Mute LEDs */ |
||
81 | gpio_set_value(CPE505N_GPIO_LED_DIAG, 1); |
||
82 | gpio_set_value(CPE505N_GPIO_LED_LAN, 1); |
||
83 | gpio_set_value(CPE505N_GPIO_LED_STATUS, 1); |
||
84 | gpio_set_value(CPE505N_GPIO_LED_WAN, 1); |
||
85 | gpio_set_value(CPE505N_GPIO_LED_WLAN, 1); |
||
86 | |||
87 | ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe505n_leds_gpio), |
||
88 | cpe505n_leds_gpio); |
||
89 | } |
||
90 | |||
91 | /* R602N GPIO LEDs */ |
||
92 | #define R602N_GPIO_LED_LAN1 16 |
||
93 | #define R602N_GPIO_LED_LAN2 15 |
||
94 | #define R602N_GPIO_LED_LAN3 14 |
||
95 | #define R602N_GPIO_LED_LAN4 11 |
||
96 | #define R602N_GPIO_LED_WAN 4 |
||
97 | #define R602N_GPIO_LED_WLAN 12 |
||
98 | |||
99 | static struct gpio_led r602n_leds_gpio[] __initdata = { |
||
100 | { |
||
101 | .name = "r602n:green:lan1", |
||
102 | .gpio = R602N_GPIO_LED_LAN1, |
||
103 | .active_low = 1, |
||
104 | }, { |
||
105 | .name = "r602n:green:lan2", |
||
106 | .gpio = R602N_GPIO_LED_LAN2, |
||
107 | .active_low = 1, |
||
108 | }, { |
||
109 | .name = "r602n:green:lan3", |
||
110 | .gpio = R602N_GPIO_LED_LAN3, |
||
111 | .active_low = 1, |
||
112 | }, { |
||
113 | .name = "r602n:green:lan4", |
||
114 | .gpio = R602N_GPIO_LED_LAN4, |
||
115 | .active_low = 1, |
||
116 | }, { |
||
117 | .name = "r602n:green:wan", |
||
118 | .gpio = R602N_GPIO_LED_WAN, |
||
119 | .active_low = 1, |
||
120 | }, { |
||
121 | .name = "r602n:green:wlan", |
||
122 | .gpio = R602N_GPIO_LED_WLAN, |
||
123 | .active_low = 1, |
||
124 | }, |
||
125 | }; |
||
126 | |||
127 | static void __init r602n_gpio_setup(void) |
||
128 | { |
||
129 | /* For LED on GPIO4 */ |
||
130 | ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN); |
||
131 | ath79_gpio_output_select(R602N_GPIO_LED_WAN, 0); |
||
132 | |||
133 | ath79_gpio_direction_select(R602N_GPIO_LED_LAN1, true); |
||
134 | ath79_gpio_direction_select(R602N_GPIO_LED_LAN2, true); |
||
135 | ath79_gpio_direction_select(R602N_GPIO_LED_LAN3, true); |
||
136 | ath79_gpio_direction_select(R602N_GPIO_LED_LAN4, true); |
||
137 | ath79_gpio_direction_select(R602N_GPIO_LED_WAN, true); |
||
138 | ath79_gpio_direction_select(R602N_GPIO_LED_WLAN, true); |
||
139 | |||
140 | /* Mute LEDs */ |
||
141 | gpio_set_value(R602N_GPIO_LED_LAN1, 1); |
||
142 | gpio_set_value(R602N_GPIO_LED_LAN2, 1); |
||
143 | gpio_set_value(R602N_GPIO_LED_LAN3, 1); |
||
144 | gpio_set_value(R602N_GPIO_LED_LAN4, 1); |
||
145 | gpio_set_value(R602N_GPIO_LED_WAN, 1); |
||
146 | gpio_set_value(R602N_GPIO_LED_WLAN, 1); |
||
147 | |||
148 | ath79_register_leds_gpio(-1, ARRAY_SIZE(r602n_leds_gpio), |
||
149 | r602n_leds_gpio); |
||
150 | } |
||
151 | |||
152 | static struct gpio_keys_button pw_gpio_keys[] __initdata = { |
||
153 | { |
||
154 | .desc = "reset", |
||
155 | .type = EV_KEY, |
||
156 | .code = KEY_RESTART, |
||
157 | .debounce_interval = PW_KEYS_DEBOUNCE_INTERVAL, |
||
158 | .gpio = PW_GPIO_BTN_RESET, |
||
159 | .active_low = 1, |
||
160 | }, |
||
161 | }; |
||
162 | |||
163 | static void __init r602n_cpe505n_setup(void) |
||
164 | { |
||
165 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
166 | |||
167 | ath79_register_m25p80(NULL); |
||
168 | |||
169 | ath79_setup_ar933x_phy4_switch(false, false); |
||
170 | |||
171 | ath79_register_mdio(0, 0x0); |
||
172 | |||
173 | /* LAN */ |
||
174 | ath79_eth1_data.duplex = DUPLEX_FULL; |
||
175 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; |
||
176 | ath79_switch_data.phy_poll_mask |= BIT(4); |
||
177 | ath79_init_mac(ath79_eth1_data.mac_addr, art + PW_MAC1_OFFSET, 0); |
||
178 | ath79_register_eth(1); |
||
179 | |||
180 | /* WAN */ |
||
181 | ath79_switch_data.phy4_mii_en = 1; |
||
182 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
183 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; |
||
184 | ath79_eth0_data.phy_mask = BIT(4); |
||
185 | ath79_eth0_data.speed = SPEED_100; |
||
186 | ath79_init_mac(ath79_eth0_data.mac_addr, art + PW_MAC0_OFFSET, 0); |
||
187 | ath79_register_eth(0); |
||
188 | |||
189 | ath79_register_wmac(art + PW_WMAC_CALDATA_OFFSET, NULL); |
||
190 | |||
191 | ath79_register_gpio_keys_polled(-1, PW_KEYS_POLL_INTERVAL, |
||
192 | ARRAY_SIZE(pw_gpio_keys), |
||
193 | pw_gpio_keys); |
||
194 | } |
||
195 | |||
196 | static void __init cpe505n_setup(void) |
||
197 | { |
||
198 | r602n_cpe505n_setup(); |
||
199 | |||
200 | cpe505n_gpio_setup(); |
||
201 | } |
||
202 | |||
203 | static void __init r602n_setup(void) |
||
204 | { |
||
205 | r602n_cpe505n_setup(); |
||
206 | |||
207 | r602n_gpio_setup(); |
||
208 | |||
209 | ath79_register_usb(); |
||
210 | } |
||
211 | |||
212 | MIPS_MACHINE(ATH79_MACH_CPE505N, "CPE505N", "P&W CPE505N", cpe505n_setup); |
||
213 | MIPS_MACHINE(ATH79_MACH_R602N, "R602N", "P&W R602N", r602n_setup); |