OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * ar8327.c: AR8216 switch driver |
||
3 | * |
||
4 | * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name> |
||
5 | * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org> |
||
6 | * |
||
7 | * This program is free software; you can redistribute it and/or |
||
8 | * modify it under the terms of the GNU General Public License |
||
9 | * as published by the Free Software Foundation; either version 2 |
||
10 | * of the License, or (at your option) any later version. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
15 | * GNU General Public License for more details. |
||
16 | */ |
||
17 | |||
18 | #include <linux/list.h> |
||
19 | #include <linux/bitops.h> |
||
20 | #include <linux/switch.h> |
||
21 | #include <linux/delay.h> |
||
22 | #include <linux/phy.h> |
||
23 | #include <linux/lockdep.h> |
||
24 | #include <linux/ar8216_platform.h> |
||
25 | #include <linux/workqueue.h> |
||
26 | #include <linux/of_device.h> |
||
27 | #include <linux/leds.h> |
||
28 | #include <linux/mdio.h> |
||
29 | |||
30 | #include "ar8216.h" |
||
31 | #include "ar8327.h" |
||
32 | |||
33 | extern const struct ar8xxx_mib_desc ar8236_mibs[39]; |
||
34 | extern const struct switch_attr ar8xxx_sw_attr_vlan[1]; |
||
35 | |||
36 | static u32 |
||
37 | ar8327_get_pad_cfg(struct ar8327_pad_cfg *cfg) |
||
38 | { |
||
39 | u32 t; |
||
40 | |||
41 | if (!cfg) |
||
42 | return 0; |
||
43 | |||
44 | t = 0; |
||
45 | switch (cfg->mode) { |
||
46 | case AR8327_PAD_NC: |
||
47 | break; |
||
48 | |||
49 | case AR8327_PAD_MAC2MAC_MII: |
||
50 | t = AR8327_PAD_MAC_MII_EN; |
||
51 | if (cfg->rxclk_sel) |
||
52 | t |= AR8327_PAD_MAC_MII_RXCLK_SEL; |
||
53 | if (cfg->txclk_sel) |
||
54 | t |= AR8327_PAD_MAC_MII_TXCLK_SEL; |
||
55 | break; |
||
56 | |||
57 | case AR8327_PAD_MAC2MAC_GMII: |
||
58 | t = AR8327_PAD_MAC_GMII_EN; |
||
59 | if (cfg->rxclk_sel) |
||
60 | t |= AR8327_PAD_MAC_GMII_RXCLK_SEL; |
||
61 | if (cfg->txclk_sel) |
||
62 | t |= AR8327_PAD_MAC_GMII_TXCLK_SEL; |
||
63 | break; |
||
64 | |||
65 | case AR8327_PAD_MAC_SGMII: |
||
66 | t = AR8327_PAD_SGMII_EN; |
||
67 | |||
68 | /* |
||
69 | * WAR for the QUalcomm Atheros AP136 board. |
||
70 | * It seems that RGMII TX/RX delay settings needs to be |
||
71 | * applied for SGMII mode as well, The ethernet is not |
||
72 | * reliable without this. |
||
73 | */ |
||
74 | t |= cfg->txclk_delay_sel << AR8327_PAD_RGMII_TXCLK_DELAY_SEL_S; |
||
75 | t |= cfg->rxclk_delay_sel << AR8327_PAD_RGMII_RXCLK_DELAY_SEL_S; |
||
76 | if (cfg->rxclk_delay_en) |
||
77 | t |= AR8327_PAD_RGMII_RXCLK_DELAY_EN; |
||
78 | if (cfg->txclk_delay_en) |
||
79 | t |= AR8327_PAD_RGMII_TXCLK_DELAY_EN; |
||
80 | |||
81 | if (cfg->sgmii_delay_en) |
||
82 | t |= AR8327_PAD_SGMII_DELAY_EN; |
||
83 | |||
84 | break; |
||
85 | |||
86 | case AR8327_PAD_MAC2PHY_MII: |
||
87 | t = AR8327_PAD_PHY_MII_EN; |
||
88 | if (cfg->rxclk_sel) |
||
89 | t |= AR8327_PAD_PHY_MII_RXCLK_SEL; |
||
90 | if (cfg->txclk_sel) |
||
91 | t |= AR8327_PAD_PHY_MII_TXCLK_SEL; |
||
92 | break; |
||
93 | |||
94 | case AR8327_PAD_MAC2PHY_GMII: |
||
95 | t = AR8327_PAD_PHY_GMII_EN; |
||
96 | if (cfg->pipe_rxclk_sel) |
||
97 | t |= AR8327_PAD_PHY_GMII_PIPE_RXCLK_SEL; |
||
98 | if (cfg->rxclk_sel) |
||
99 | t |= AR8327_PAD_PHY_GMII_RXCLK_SEL; |
||
100 | if (cfg->txclk_sel) |
||
101 | t |= AR8327_PAD_PHY_GMII_TXCLK_SEL; |
||
102 | break; |
||
103 | |||
104 | case AR8327_PAD_MAC_RGMII: |
||
105 | t = AR8327_PAD_RGMII_EN; |
||
106 | t |= cfg->txclk_delay_sel << AR8327_PAD_RGMII_TXCLK_DELAY_SEL_S; |
||
107 | t |= cfg->rxclk_delay_sel << AR8327_PAD_RGMII_RXCLK_DELAY_SEL_S; |
||
108 | if (cfg->rxclk_delay_en) |
||
109 | t |= AR8327_PAD_RGMII_RXCLK_DELAY_EN; |
||
110 | if (cfg->txclk_delay_en) |
||
111 | t |= AR8327_PAD_RGMII_TXCLK_DELAY_EN; |
||
112 | break; |
||
113 | |||
114 | case AR8327_PAD_PHY_GMII: |
||
115 | t = AR8327_PAD_PHYX_GMII_EN; |
||
116 | break; |
||
117 | |||
118 | case AR8327_PAD_PHY_RGMII: |
||
119 | t = AR8327_PAD_PHYX_RGMII_EN; |
||
120 | break; |
||
121 | |||
122 | case AR8327_PAD_PHY_MII: |
||
123 | t = AR8327_PAD_PHYX_MII_EN; |
||
124 | break; |
||
125 | } |
||
126 | |||
127 | return t; |
||
128 | } |
||
129 | |||
130 | static void |
||
131 | ar8327_phy_fixup(struct ar8xxx_priv *priv, int phy) |
||
132 | { |
||
133 | switch (priv->chip_rev) { |
||
134 | case 1: |
||
135 | /* For 100M waveform */ |
||
136 | ar8xxx_phy_dbg_write(priv, phy, 0, 0x02ea); |
||
137 | /* Turn on Gigabit clock */ |
||
138 | ar8xxx_phy_dbg_write(priv, phy, 0x3d, 0x68a0); |
||
139 | break; |
||
140 | |||
141 | case 2: |
||
142 | ar8xxx_phy_mmd_write(priv, phy, 0x7, 0x3c, 0x0); |
||
143 | /* fallthrough */ |
||
144 | case 4: |
||
145 | ar8xxx_phy_mmd_write(priv, phy, 0x3, 0x800d, 0x803f); |
||
146 | ar8xxx_phy_dbg_write(priv, phy, 0x3d, 0x6860); |
||
147 | ar8xxx_phy_dbg_write(priv, phy, 0x5, 0x2c46); |
||
148 | ar8xxx_phy_dbg_write(priv, phy, 0x3c, 0x6000); |
||
149 | break; |
||
150 | } |
||
151 | } |
||
152 | |||
153 | static u32 |
||
154 | ar8327_get_port_init_status(struct ar8327_port_cfg *cfg) |
||
155 | { |
||
156 | u32 t; |
||
157 | |||
158 | if (!cfg->force_link) |
||
159 | return AR8216_PORT_STATUS_LINK_AUTO; |
||
160 | |||
161 | t = AR8216_PORT_STATUS_TXMAC | AR8216_PORT_STATUS_RXMAC; |
||
162 | t |= cfg->duplex ? AR8216_PORT_STATUS_DUPLEX : 0; |
||
163 | t |= cfg->rxpause ? AR8216_PORT_STATUS_RXFLOW : 0; |
||
164 | t |= cfg->txpause ? AR8216_PORT_STATUS_TXFLOW : 0; |
||
165 | |||
166 | switch (cfg->speed) { |
||
167 | case AR8327_PORT_SPEED_10: |
||
168 | t |= AR8216_PORT_SPEED_10M; |
||
169 | break; |
||
170 | case AR8327_PORT_SPEED_100: |
||
171 | t |= AR8216_PORT_SPEED_100M; |
||
172 | break; |
||
173 | case AR8327_PORT_SPEED_1000: |
||
174 | t |= AR8216_PORT_SPEED_1000M; |
||
175 | break; |
||
176 | } |
||
177 | |||
178 | return t; |
||
179 | } |
||
180 | |||
181 | #define AR8327_LED_ENTRY(_num, _reg, _shift) \ |
||
182 | [_num] = { .reg = (_reg), .shift = (_shift) } |
||
183 | |||
184 | static const struct ar8327_led_entry |
||
185 | ar8327_led_map[AR8327_NUM_LEDS] = { |
||
186 | AR8327_LED_ENTRY(AR8327_LED_PHY0_0, 0, 14), |
||
187 | AR8327_LED_ENTRY(AR8327_LED_PHY0_1, 1, 14), |
||
188 | AR8327_LED_ENTRY(AR8327_LED_PHY0_2, 2, 14), |
||
189 | |||
190 | AR8327_LED_ENTRY(AR8327_LED_PHY1_0, 3, 8), |
||
191 | AR8327_LED_ENTRY(AR8327_LED_PHY1_1, 3, 10), |
||
192 | AR8327_LED_ENTRY(AR8327_LED_PHY1_2, 3, 12), |
||
193 | |||
194 | AR8327_LED_ENTRY(AR8327_LED_PHY2_0, 3, 14), |
||
195 | AR8327_LED_ENTRY(AR8327_LED_PHY2_1, 3, 16), |
||
196 | AR8327_LED_ENTRY(AR8327_LED_PHY2_2, 3, 18), |
||
197 | |||
198 | AR8327_LED_ENTRY(AR8327_LED_PHY3_0, 3, 20), |
||
199 | AR8327_LED_ENTRY(AR8327_LED_PHY3_1, 3, 22), |
||
200 | AR8327_LED_ENTRY(AR8327_LED_PHY3_2, 3, 24), |
||
201 | |||
202 | AR8327_LED_ENTRY(AR8327_LED_PHY4_0, 0, 30), |
||
203 | AR8327_LED_ENTRY(AR8327_LED_PHY4_1, 1, 30), |
||
204 | AR8327_LED_ENTRY(AR8327_LED_PHY4_2, 2, 30), |
||
205 | }; |
||
206 | |||
207 | static void |
||
208 | ar8327_set_led_pattern(struct ar8xxx_priv *priv, unsigned int led_num, |
||
209 | enum ar8327_led_pattern pattern) |
||
210 | { |
||
211 | const struct ar8327_led_entry *entry; |
||
212 | |||
213 | entry = &ar8327_led_map[led_num]; |
||
214 | ar8xxx_rmw(priv, AR8327_REG_LED_CTRL(entry->reg), |
||
215 | (3 << entry->shift), pattern << entry->shift); |
||
216 | } |
||
217 | |||
218 | static void |
||
219 | ar8327_led_work_func(struct work_struct *work) |
||
220 | { |
||
221 | struct ar8327_led *aled; |
||
222 | u8 pattern; |
||
223 | |||
224 | aled = container_of(work, struct ar8327_led, led_work); |
||
225 | |||
226 | pattern = aled->pattern; |
||
227 | |||
228 | ar8327_set_led_pattern(aled->sw_priv, aled->led_num, |
||
229 | pattern); |
||
230 | } |
||
231 | |||
232 | static void |
||
233 | ar8327_led_schedule_change(struct ar8327_led *aled, u8 pattern) |
||
234 | { |
||
235 | if (aled->pattern == pattern) |
||
236 | return; |
||
237 | |||
238 | aled->pattern = pattern; |
||
239 | schedule_work(&aled->led_work); |
||
240 | } |
||
241 | |||
242 | static inline struct ar8327_led * |
||
243 | led_cdev_to_ar8327_led(struct led_classdev *led_cdev) |
||
244 | { |
||
245 | return container_of(led_cdev, struct ar8327_led, cdev); |
||
246 | } |
||
247 | |||
248 | static int |
||
249 | ar8327_led_blink_set(struct led_classdev *led_cdev, |
||
250 | unsigned long *delay_on, |
||
251 | unsigned long *delay_off) |
||
252 | { |
||
253 | struct ar8327_led *aled = led_cdev_to_ar8327_led(led_cdev); |
||
254 | |||
255 | if (*delay_on == 0 && *delay_off == 0) { |
||
256 | *delay_on = 125; |
||
257 | *delay_off = 125; |
||
258 | } |
||
259 | |||
260 | if (*delay_on != 125 || *delay_off != 125) { |
||
261 | /* |
||
262 | * The hardware only supports blinking at 4Hz. Fall back |
||
263 | * to software implementation in other cases. |
||
264 | */ |
||
265 | return -EINVAL; |
||
266 | } |
||
267 | |||
268 | spin_lock(&aled->lock); |
||
269 | |||
270 | aled->enable_hw_mode = false; |
||
271 | ar8327_led_schedule_change(aled, AR8327_LED_PATTERN_BLINK); |
||
272 | |||
273 | spin_unlock(&aled->lock); |
||
274 | |||
275 | return 0; |
||
276 | } |
||
277 | |||
278 | static void |
||
279 | ar8327_led_set_brightness(struct led_classdev *led_cdev, |
||
280 | enum led_brightness brightness) |
||
281 | { |
||
282 | struct ar8327_led *aled = led_cdev_to_ar8327_led(led_cdev); |
||
283 | u8 pattern; |
||
284 | bool active; |
||
285 | |||
286 | active = (brightness != LED_OFF); |
||
287 | active ^= aled->active_low; |
||
288 | |||
289 | pattern = (active) ? AR8327_LED_PATTERN_ON : |
||
290 | AR8327_LED_PATTERN_OFF; |
||
291 | |||
292 | spin_lock(&aled->lock); |
||
293 | |||
294 | aled->enable_hw_mode = false; |
||
295 | ar8327_led_schedule_change(aled, pattern); |
||
296 | |||
297 | spin_unlock(&aled->lock); |
||
298 | } |
||
299 | |||
300 | static ssize_t |
||
301 | ar8327_led_enable_hw_mode_show(struct device *dev, |
||
302 | struct device_attribute *attr, |
||
303 | char *buf) |
||
304 | { |
||
305 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
||
306 | struct ar8327_led *aled = led_cdev_to_ar8327_led(led_cdev); |
||
307 | ssize_t ret = 0; |
||
308 | |||
309 | ret += scnprintf(buf, PAGE_SIZE, "%d\n", aled->enable_hw_mode); |
||
310 | |||
311 | return ret; |
||
312 | } |
||
313 | |||
314 | static ssize_t |
||
315 | ar8327_led_enable_hw_mode_store(struct device *dev, |
||
316 | struct device_attribute *attr, |
||
317 | const char *buf, |
||
318 | size_t size) |
||
319 | { |
||
320 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
||
321 | struct ar8327_led *aled = led_cdev_to_ar8327_led(led_cdev); |
||
322 | u8 pattern; |
||
323 | u8 value; |
||
324 | int ret; |
||
325 | |||
326 | ret = kstrtou8(buf, 10, &value); |
||
327 | if (ret < 0) |
||
328 | return -EINVAL; |
||
329 | |||
330 | spin_lock(&aled->lock); |
||
331 | |||
332 | aled->enable_hw_mode = !!value; |
||
333 | if (aled->enable_hw_mode) |
||
334 | pattern = AR8327_LED_PATTERN_RULE; |
||
335 | else |
||
336 | pattern = AR8327_LED_PATTERN_OFF; |
||
337 | |||
338 | ar8327_led_schedule_change(aled, pattern); |
||
339 | |||
340 | spin_unlock(&aled->lock); |
||
341 | |||
342 | return size; |
||
343 | } |
||
344 | |||
345 | static DEVICE_ATTR(enable_hw_mode, S_IRUGO | S_IWUSR, |
||
346 | ar8327_led_enable_hw_mode_show, |
||
347 | ar8327_led_enable_hw_mode_store); |
||
348 | |||
349 | static int |
||
350 | ar8327_led_register(struct ar8327_led *aled) |
||
351 | { |
||
352 | int ret; |
||
353 | |||
354 | ret = led_classdev_register(NULL, &aled->cdev); |
||
355 | if (ret < 0) |
||
356 | return ret; |
||
357 | |||
358 | if (aled->mode == AR8327_LED_MODE_HW) { |
||
359 | ret = device_create_file(aled->cdev.dev, |
||
360 | &dev_attr_enable_hw_mode); |
||
361 | if (ret) |
||
362 | goto err_unregister; |
||
363 | } |
||
364 | |||
365 | return 0; |
||
366 | |||
367 | err_unregister: |
||
368 | led_classdev_unregister(&aled->cdev); |
||
369 | return ret; |
||
370 | } |
||
371 | |||
372 | static void |
||
373 | ar8327_led_unregister(struct ar8327_led *aled) |
||
374 | { |
||
375 | if (aled->mode == AR8327_LED_MODE_HW) |
||
376 | device_remove_file(aled->cdev.dev, &dev_attr_enable_hw_mode); |
||
377 | |||
378 | led_classdev_unregister(&aled->cdev); |
||
379 | cancel_work_sync(&aled->led_work); |
||
380 | } |
||
381 | |||
382 | static int |
||
383 | ar8327_led_create(struct ar8xxx_priv *priv, |
||
384 | const struct ar8327_led_info *led_info) |
||
385 | { |
||
386 | struct ar8327_data *data = priv->chip_data; |
||
387 | struct ar8327_led *aled; |
||
388 | int ret; |
||
389 | |||
390 | if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS)) |
||
391 | return 0; |
||
392 | |||
393 | if (!led_info->name) |
||
394 | return -EINVAL; |
||
395 | |||
396 | if (led_info->led_num >= AR8327_NUM_LEDS) |
||
397 | return -EINVAL; |
||
398 | |||
399 | aled = kzalloc(sizeof(*aled) + strlen(led_info->name) + 1, |
||
400 | GFP_KERNEL); |
||
401 | if (!aled) |
||
402 | return -ENOMEM; |
||
403 | |||
404 | aled->sw_priv = priv; |
||
405 | aled->led_num = led_info->led_num; |
||
406 | aled->active_low = led_info->active_low; |
||
407 | aled->mode = led_info->mode; |
||
408 | |||
409 | if (aled->mode == AR8327_LED_MODE_HW) |
||
410 | aled->enable_hw_mode = true; |
||
411 | |||
412 | aled->name = (char *)(aled + 1); |
||
413 | strcpy(aled->name, led_info->name); |
||
414 | |||
415 | aled->cdev.name = aled->name; |
||
416 | aled->cdev.brightness_set = ar8327_led_set_brightness; |
||
417 | aled->cdev.blink_set = ar8327_led_blink_set; |
||
418 | aled->cdev.default_trigger = led_info->default_trigger; |
||
419 | |||
420 | spin_lock_init(&aled->lock); |
||
421 | mutex_init(&aled->mutex); |
||
422 | INIT_WORK(&aled->led_work, ar8327_led_work_func); |
||
423 | |||
424 | ret = ar8327_led_register(aled); |
||
425 | if (ret) |
||
426 | goto err_free; |
||
427 | |||
428 | data->leds[data->num_leds++] = aled; |
||
429 | |||
430 | return 0; |
||
431 | |||
432 | err_free: |
||
433 | kfree(aled); |
||
434 | return ret; |
||
435 | } |
||
436 | |||
437 | static void |
||
438 | ar8327_led_destroy(struct ar8327_led *aled) |
||
439 | { |
||
440 | ar8327_led_unregister(aled); |
||
441 | kfree(aled); |
||
442 | } |
||
443 | |||
444 | static void |
||
445 | ar8327_leds_init(struct ar8xxx_priv *priv) |
||
446 | { |
||
447 | struct ar8327_data *data = priv->chip_data; |
||
448 | unsigned i; |
||
449 | |||
450 | if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS)) |
||
451 | return; |
||
452 | |||
453 | for (i = 0; i < data->num_leds; i++) { |
||
454 | struct ar8327_led *aled; |
||
455 | |||
456 | aled = data->leds[i]; |
||
457 | |||
458 | if (aled->enable_hw_mode) |
||
459 | aled->pattern = AR8327_LED_PATTERN_RULE; |
||
460 | else |
||
461 | aled->pattern = AR8327_LED_PATTERN_OFF; |
||
462 | |||
463 | ar8327_set_led_pattern(priv, aled->led_num, aled->pattern); |
||
464 | } |
||
465 | } |
||
466 | |||
467 | static void |
||
468 | ar8327_leds_cleanup(struct ar8xxx_priv *priv) |
||
469 | { |
||
470 | struct ar8327_data *data = priv->chip_data; |
||
471 | unsigned i; |
||
472 | |||
473 | if (!IS_ENABLED(CONFIG_AR8216_PHY_LEDS)) |
||
474 | return; |
||
475 | |||
476 | for (i = 0; i < data->num_leds; i++) { |
||
477 | struct ar8327_led *aled; |
||
478 | |||
479 | aled = data->leds[i]; |
||
480 | ar8327_led_destroy(aled); |
||
481 | } |
||
482 | |||
483 | kfree(data->leds); |
||
484 | } |
||
485 | |||
486 | static int |
||
487 | ar8327_hw_config_pdata(struct ar8xxx_priv *priv, |
||
488 | struct ar8327_platform_data *pdata) |
||
489 | { |
||
490 | struct ar8327_led_cfg *led_cfg; |
||
491 | struct ar8327_data *data = priv->chip_data; |
||
492 | u32 pos, new_pos; |
||
493 | u32 t; |
||
494 | |||
495 | if (!pdata) |
||
496 | return -EINVAL; |
||
497 | |||
498 | priv->get_port_link = pdata->get_port_link; |
||
499 | |||
500 | data->port0_status = ar8327_get_port_init_status(&pdata->port0_cfg); |
||
501 | data->port6_status = ar8327_get_port_init_status(&pdata->port6_cfg); |
||
502 | |||
503 | t = ar8327_get_pad_cfg(pdata->pad0_cfg); |
||
504 | if (chip_is_ar8337(priv) && !pdata->pad0_cfg->mac06_exchange_dis) |
||
505 | t |= AR8337_PAD_MAC06_EXCHANGE_EN; |
||
506 | ar8xxx_write(priv, AR8327_REG_PAD0_MODE, t); |
||
507 | |||
508 | t = ar8327_get_pad_cfg(pdata->pad5_cfg); |
||
3 | office | 509 | if (chip_is_ar8337(priv)) { |
510 | /* |
||
511 | * Workaround: RGMII RX delay setting needs to be |
||
512 | * always specified for AR8337 to avoid port 5 |
||
513 | * RX hang on high traffic / flood conditions |
||
514 | */ |
||
515 | t |= AR8327_PAD_RGMII_RXCLK_DELAY_EN; |
||
516 | } |
||
1 | office | 517 | ar8xxx_write(priv, AR8327_REG_PAD5_MODE, t); |
518 | t = ar8327_get_pad_cfg(pdata->pad6_cfg); |
||
519 | ar8xxx_write(priv, AR8327_REG_PAD6_MODE, t); |
||
520 | |||
521 | pos = ar8xxx_read(priv, AR8327_REG_POWER_ON_STRIP); |
||
522 | new_pos = pos; |
||
523 | |||
524 | led_cfg = pdata->led_cfg; |
||
525 | if (led_cfg) { |
||
526 | if (led_cfg->open_drain) |
||
527 | new_pos |= AR8327_POWER_ON_STRIP_LED_OPEN_EN; |
||
528 | else |
||
529 | new_pos &= ~AR8327_POWER_ON_STRIP_LED_OPEN_EN; |
||
530 | |||
531 | ar8xxx_write(priv, AR8327_REG_LED_CTRL0, led_cfg->led_ctrl0); |
||
532 | ar8xxx_write(priv, AR8327_REG_LED_CTRL1, led_cfg->led_ctrl1); |
||
533 | ar8xxx_write(priv, AR8327_REG_LED_CTRL2, led_cfg->led_ctrl2); |
||
534 | ar8xxx_write(priv, AR8327_REG_LED_CTRL3, led_cfg->led_ctrl3); |
||
535 | |||
536 | if (new_pos != pos) |
||
537 | new_pos |= AR8327_POWER_ON_STRIP_POWER_ON_SEL; |
||
538 | } |
||
539 | |||
540 | if (pdata->sgmii_cfg) { |
||
541 | t = pdata->sgmii_cfg->sgmii_ctrl; |
||
542 | if (priv->chip_rev == 1) |
||
543 | t |= AR8327_SGMII_CTRL_EN_PLL | |
||
544 | AR8327_SGMII_CTRL_EN_RX | |
||
545 | AR8327_SGMII_CTRL_EN_TX; |
||
546 | else |
||
547 | t &= ~(AR8327_SGMII_CTRL_EN_PLL | |
||
548 | AR8327_SGMII_CTRL_EN_RX | |
||
549 | AR8327_SGMII_CTRL_EN_TX); |
||
550 | |||
551 | ar8xxx_write(priv, AR8327_REG_SGMII_CTRL, t); |
||
552 | |||
553 | if (pdata->sgmii_cfg->serdes_aen) |
||
554 | new_pos &= ~AR8327_POWER_ON_STRIP_SERDES_AEN; |
||
555 | else |
||
556 | new_pos |= AR8327_POWER_ON_STRIP_SERDES_AEN; |
||
557 | } |
||
558 | |||
559 | ar8xxx_write(priv, AR8327_REG_POWER_ON_STRIP, new_pos); |
||
560 | |||
561 | if (pdata->leds && pdata->num_leds) { |
||
562 | int i; |
||
563 | |||
564 | data->leds = kzalloc(pdata->num_leds * sizeof(void *), |
||
565 | GFP_KERNEL); |
||
566 | if (!data->leds) |
||
567 | return -ENOMEM; |
||
568 | |||
569 | for (i = 0; i < pdata->num_leds; i++) |
||
570 | ar8327_led_create(priv, &pdata->leds[i]); |
||
571 | } |
||
572 | |||
573 | return 0; |
||
574 | } |
||
575 | |||
576 | #ifdef CONFIG_OF |
||
577 | static int |
||
578 | ar8327_hw_config_of(struct ar8xxx_priv *priv, struct device_node *np) |
||
579 | { |
||
580 | struct ar8327_data *data = priv->chip_data; |
||
581 | const __be32 *paddr; |
||
582 | int len; |
||
583 | int i; |
||
584 | |||
585 | paddr = of_get_property(np, "qca,ar8327-initvals", &len); |
||
586 | if (!paddr || len < (2 * sizeof(*paddr))) |
||
587 | return -EINVAL; |
||
588 | |||
589 | len /= sizeof(*paddr); |
||
590 | |||
591 | for (i = 0; i < len - 1; i += 2) { |
||
592 | u32 reg; |
||
593 | u32 val; |
||
594 | |||
595 | reg = be32_to_cpup(paddr + i); |
||
596 | val = be32_to_cpup(paddr + i + 1); |
||
597 | |||
598 | switch (reg) { |
||
599 | case AR8327_REG_PORT_STATUS(0): |
||
600 | data->port0_status = val; |
||
601 | break; |
||
602 | case AR8327_REG_PORT_STATUS(6): |
||
603 | data->port6_status = val; |
||
604 | break; |
||
605 | default: |
||
606 | ar8xxx_write(priv, reg, val); |
||
607 | break; |
||
608 | } |
||
609 | } |
||
610 | |||
611 | return 0; |
||
612 | } |
||
613 | #else |
||
614 | static inline int |
||
615 | ar8327_hw_config_of(struct ar8xxx_priv *priv, struct device_node *np) |
||
616 | { |
||
617 | return -EINVAL; |
||
618 | } |
||
619 | #endif |
||
620 | |||
621 | static int |
||
622 | ar8327_hw_init(struct ar8xxx_priv *priv) |
||
623 | { |
||
624 | int ret; |
||
625 | |||
626 | priv->chip_data = kzalloc(sizeof(struct ar8327_data), GFP_KERNEL); |
||
627 | if (!priv->chip_data) |
||
628 | return -ENOMEM; |
||
629 | |||
630 | if (priv->phy->mdio.dev.of_node) |
||
631 | ret = ar8327_hw_config_of(priv, priv->phy->mdio.dev.of_node); |
||
632 | else |
||
633 | ret = ar8327_hw_config_pdata(priv, |
||
634 | priv->phy->mdio.dev.platform_data); |
||
635 | |||
636 | if (ret) |
||
637 | return ret; |
||
638 | |||
639 | ar8327_leds_init(priv); |
||
640 | |||
641 | ar8xxx_phy_init(priv); |
||
642 | |||
643 | return 0; |
||
644 | } |
||
645 | |||
646 | static void |
||
647 | ar8327_cleanup(struct ar8xxx_priv *priv) |
||
648 | { |
||
649 | ar8327_leds_cleanup(priv); |
||
650 | } |
||
651 | |||
652 | static void |
||
653 | ar8327_init_globals(struct ar8xxx_priv *priv) |
||
654 | { |
||
655 | struct ar8327_data *data = priv->chip_data; |
||
656 | u32 t; |
||
657 | int i; |
||
658 | |||
659 | /* enable CPU port and disable mirror port */ |
||
660 | t = AR8327_FWD_CTRL0_CPU_PORT_EN | |
||
661 | AR8327_FWD_CTRL0_MIRROR_PORT; |
||
662 | ar8xxx_write(priv, AR8327_REG_FWD_CTRL0, t); |
||
663 | |||
664 | /* forward multicast and broadcast frames to CPU */ |
||
665 | t = (AR8327_PORTS_ALL << AR8327_FWD_CTRL1_UC_FLOOD_S) | |
||
666 | (AR8327_PORTS_ALL << AR8327_FWD_CTRL1_MC_FLOOD_S) | |
||
667 | (AR8327_PORTS_ALL << AR8327_FWD_CTRL1_BC_FLOOD_S); |
||
668 | ar8xxx_write(priv, AR8327_REG_FWD_CTRL1, t); |
||
669 | |||
670 | /* enable jumbo frames */ |
||
671 | ar8xxx_rmw(priv, AR8327_REG_MAX_FRAME_SIZE, |
||
672 | AR8327_MAX_FRAME_SIZE_MTU, 9018 + 8 + 2); |
||
673 | |||
674 | /* Enable MIB counters */ |
||
675 | ar8xxx_reg_set(priv, AR8327_REG_MODULE_EN, |
||
676 | AR8327_MODULE_EN_MIB); |
||
677 | |||
678 | /* Disable EEE on all phy's due to stability issues */ |
||
679 | for (i = 0; i < AR8XXX_NUM_PHYS; i++) |
||
680 | data->eee[i] = false; |
||
3 | office | 681 | |
682 | if (chip_is_ar8337(priv)) { |
||
683 | /* Update HOL registers with values suggested by QCA switch team */ |
||
684 | for (i = 0; i < AR8327_NUM_PORTS; i++) { |
||
685 | if (i == AR8216_PORT_CPU || i == 5 || i == 6) { |
||
686 | t = 0x3 << AR8327_PORT_HOL_CTRL0_EG_PRI0_BUF_S; |
||
687 | t |= 0x4 << AR8327_PORT_HOL_CTRL0_EG_PRI1_BUF_S; |
||
688 | t |= 0x4 << AR8327_PORT_HOL_CTRL0_EG_PRI2_BUF_S; |
||
689 | t |= 0x4 << AR8327_PORT_HOL_CTRL0_EG_PRI3_BUF_S; |
||
690 | t |= 0x6 << AR8327_PORT_HOL_CTRL0_EG_PRI4_BUF_S; |
||
691 | t |= 0x8 << AR8327_PORT_HOL_CTRL0_EG_PRI5_BUF_S; |
||
692 | t |= 0x1e << AR8327_PORT_HOL_CTRL0_EG_PORT_BUF_S; |
||
693 | } else { |
||
694 | t = 0x3 << AR8327_PORT_HOL_CTRL0_EG_PRI0_BUF_S; |
||
695 | t |= 0x4 << AR8327_PORT_HOL_CTRL0_EG_PRI1_BUF_S; |
||
696 | t |= 0x6 << AR8327_PORT_HOL_CTRL0_EG_PRI2_BUF_S; |
||
697 | t |= 0x8 << AR8327_PORT_HOL_CTRL0_EG_PRI3_BUF_S; |
||
698 | t |= 0x19 << AR8327_PORT_HOL_CTRL0_EG_PORT_BUF_S; |
||
699 | } |
||
700 | ar8xxx_write(priv, AR8327_REG_PORT_HOL_CTRL0(i), t); |
||
701 | |||
702 | t = 0x6 << AR8327_PORT_HOL_CTRL1_ING_BUF_S; |
||
703 | t |= AR8327_PORT_HOL_CTRL1_EG_PRI_BUF_EN; |
||
704 | t |= AR8327_PORT_HOL_CTRL1_EG_PORT_BUF_EN; |
||
705 | t |= AR8327_PORT_HOL_CTRL1_WRED_EN; |
||
706 | ar8xxx_rmw(priv, AR8327_REG_PORT_HOL_CTRL1(i), |
||
707 | AR8327_PORT_HOL_CTRL1_ING_BUF | |
||
708 | AR8327_PORT_HOL_CTRL1_EG_PRI_BUF_EN | |
||
709 | AR8327_PORT_HOL_CTRL1_EG_PORT_BUF_EN | |
||
710 | AR8327_PORT_HOL_CTRL1_WRED_EN, |
||
711 | t); |
||
712 | } |
||
713 | } |
||
1 | office | 714 | } |
715 | |||
716 | static void |
||
717 | ar8327_init_port(struct ar8xxx_priv *priv, int port) |
||
718 | { |
||
719 | struct ar8327_data *data = priv->chip_data; |
||
720 | u32 t; |
||
721 | |||
722 | if (port == AR8216_PORT_CPU) |
||
723 | t = data->port0_status; |
||
724 | else if (port == 6) |
||
725 | t = data->port6_status; |
||
726 | else |
||
727 | t = AR8216_PORT_STATUS_LINK_AUTO; |
||
728 | |||
729 | if (port != AR8216_PORT_CPU && port != 6) { |
||
730 | /*hw limitation:if configure mac when there is traffic, |
||
731 | port MAC may work abnormal. Need disable lan&wan mac at fisrt*/ |
||
732 | ar8xxx_write(priv, AR8327_REG_PORT_STATUS(port), 0); |
||
733 | msleep(100); |
||
734 | t |= AR8216_PORT_STATUS_FLOW_CONTROL; |
||
735 | ar8xxx_write(priv, AR8327_REG_PORT_STATUS(port), t); |
||
736 | } else { |
||
737 | ar8xxx_write(priv, AR8327_REG_PORT_STATUS(port), t); |
||
738 | } |
||
739 | |||
740 | ar8xxx_write(priv, AR8327_REG_PORT_HEADER(port), 0); |
||
741 | |||
742 | ar8xxx_write(priv, AR8327_REG_PORT_VLAN0(port), 0); |
||
743 | |||
744 | t = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH << AR8327_PORT_VLAN1_OUT_MODE_S; |
||
745 | ar8xxx_write(priv, AR8327_REG_PORT_VLAN1(port), t); |
||
746 | |||
747 | t = AR8327_PORT_LOOKUP_LEARN; |
||
748 | t |= AR8216_PORT_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; |
||
749 | ar8xxx_write(priv, AR8327_REG_PORT_LOOKUP(port), t); |
||
750 | } |
||
751 | |||
752 | static u32 |
||
753 | ar8327_read_port_status(struct ar8xxx_priv *priv, int port) |
||
754 | { |
||
755 | u32 t; |
||
756 | |||
757 | t = ar8xxx_read(priv, AR8327_REG_PORT_STATUS(port)); |
||
758 | /* map the flow control autoneg result bits to the flow control bits |
||
759 | * used in forced mode to allow ar8216_read_port_link detect |
||
760 | * flow control properly if autoneg is used |
||
761 | */ |
||
762 | if (t & AR8216_PORT_STATUS_LINK_UP && |
||
763 | t & AR8216_PORT_STATUS_LINK_AUTO) { |
||
764 | t &= ~(AR8216_PORT_STATUS_TXFLOW | AR8216_PORT_STATUS_RXFLOW); |
||
765 | if (t & AR8327_PORT_STATUS_TXFLOW_AUTO) |
||
766 | t |= AR8216_PORT_STATUS_TXFLOW; |
||
767 | if (t & AR8327_PORT_STATUS_RXFLOW_AUTO) |
||
768 | t |= AR8216_PORT_STATUS_RXFLOW; |
||
769 | } |
||
770 | |||
771 | return t; |
||
772 | } |
||
773 | |||
774 | static u32 |
||
775 | ar8327_read_port_eee_status(struct ar8xxx_priv *priv, int port) |
||
776 | { |
||
777 | int phy; |
||
778 | u16 t; |
||
779 | |||
780 | if (port >= priv->dev.ports) |
||
781 | return 0; |
||
782 | |||
783 | if (port == 0 || port == 6) |
||
784 | return 0; |
||
785 | |||
786 | phy = port - 1; |
||
787 | |||
788 | /* EEE Ability Auto-negotiation Result */ |
||
789 | t = ar8xxx_phy_mmd_read(priv, phy, 0x7, 0x8000); |
||
790 | |||
791 | return mmd_eee_adv_to_ethtool_adv_t(t); |
||
792 | } |
||
793 | |||
794 | static int |
||
795 | ar8327_atu_flush(struct ar8xxx_priv *priv) |
||
796 | { |
||
797 | int ret; |
||
798 | |||
799 | ret = ar8216_wait_bit(priv, AR8327_REG_ATU_FUNC, |
||
800 | AR8327_ATU_FUNC_BUSY, 0); |
||
801 | if (!ret) |
||
802 | ar8xxx_write(priv, AR8327_REG_ATU_FUNC, |
||
803 | AR8327_ATU_FUNC_OP_FLUSH | |
||
804 | AR8327_ATU_FUNC_BUSY); |
||
805 | |||
806 | return ret; |
||
807 | } |
||
808 | |||
809 | static int |
||
810 | ar8327_atu_flush_port(struct ar8xxx_priv *priv, int port) |
||
811 | { |
||
812 | u32 t; |
||
813 | int ret; |
||
814 | |||
815 | ret = ar8216_wait_bit(priv, AR8327_REG_ATU_FUNC, |
||
816 | AR8327_ATU_FUNC_BUSY, 0); |
||
817 | if (!ret) { |
||
818 | t = (port << AR8327_ATU_PORT_NUM_S); |
||
819 | t |= AR8327_ATU_FUNC_OP_FLUSH_PORT; |
||
820 | t |= AR8327_ATU_FUNC_BUSY; |
||
821 | ar8xxx_write(priv, AR8327_REG_ATU_FUNC, t); |
||
822 | } |
||
823 | |||
824 | return ret; |
||
825 | } |
||
826 | |||
827 | static int |
||
828 | ar8327_get_port_igmp(struct ar8xxx_priv *priv, int port) |
||
829 | { |
||
830 | u32 fwd_ctrl, frame_ack; |
||
831 | |||
832 | fwd_ctrl = (BIT(port) << AR8327_FWD_CTRL1_IGMP_S); |
||
833 | frame_ack = ((AR8327_FRAME_ACK_CTRL_IGMP_MLD | |
||
834 | AR8327_FRAME_ACK_CTRL_IGMP_JOIN | |
||
835 | AR8327_FRAME_ACK_CTRL_IGMP_LEAVE) << |
||
836 | AR8327_FRAME_ACK_CTRL_S(port)); |
||
837 | |||
838 | return (ar8xxx_read(priv, AR8327_REG_FWD_CTRL1) & |
||
839 | fwd_ctrl) == fwd_ctrl && |
||
840 | (ar8xxx_read(priv, AR8327_REG_FRAME_ACK_CTRL(port)) & |
||
841 | frame_ack) == frame_ack; |
||
842 | } |
||
843 | |||
844 | static void |
||
845 | ar8327_set_port_igmp(struct ar8xxx_priv *priv, int port, int enable) |
||
846 | { |
||
847 | int reg_frame_ack = AR8327_REG_FRAME_ACK_CTRL(port); |
||
848 | u32 val_frame_ack = (AR8327_FRAME_ACK_CTRL_IGMP_MLD | |
||
849 | AR8327_FRAME_ACK_CTRL_IGMP_JOIN | |
||
850 | AR8327_FRAME_ACK_CTRL_IGMP_LEAVE) << |
||
851 | AR8327_FRAME_ACK_CTRL_S(port); |
||
852 | |||
853 | if (enable) { |
||
854 | ar8xxx_rmw(priv, AR8327_REG_FWD_CTRL1, |
||
855 | BIT(port) << AR8327_FWD_CTRL1_MC_FLOOD_S, |
||
856 | BIT(port) << AR8327_FWD_CTRL1_IGMP_S); |
||
857 | ar8xxx_reg_set(priv, reg_frame_ack, val_frame_ack); |
||
858 | } else { |
||
859 | ar8xxx_rmw(priv, AR8327_REG_FWD_CTRL1, |
||
860 | BIT(port) << AR8327_FWD_CTRL1_IGMP_S, |
||
861 | BIT(port) << AR8327_FWD_CTRL1_MC_FLOOD_S); |
||
862 | ar8xxx_reg_clear(priv, reg_frame_ack, val_frame_ack); |
||
863 | } |
||
864 | } |
||
865 | |||
866 | static void |
||
867 | ar8327_vtu_op(struct ar8xxx_priv *priv, u32 op, u32 val) |
||
868 | { |
||
869 | if (ar8216_wait_bit(priv, AR8327_REG_VTU_FUNC1, |
||
870 | AR8327_VTU_FUNC1_BUSY, 0)) |
||
871 | return; |
||
872 | |||
873 | if ((op & AR8327_VTU_FUNC1_OP) == AR8327_VTU_FUNC1_OP_LOAD) |
||
874 | ar8xxx_write(priv, AR8327_REG_VTU_FUNC0, val); |
||
875 | |||
876 | op |= AR8327_VTU_FUNC1_BUSY; |
||
877 | ar8xxx_write(priv, AR8327_REG_VTU_FUNC1, op); |
||
878 | } |
||
879 | |||
880 | static void |
||
881 | ar8327_vtu_flush(struct ar8xxx_priv *priv) |
||
882 | { |
||
883 | ar8327_vtu_op(priv, AR8327_VTU_FUNC1_OP_FLUSH, 0); |
||
884 | } |
||
885 | |||
886 | static void |
||
887 | ar8327_vtu_load_vlan(struct ar8xxx_priv *priv, u32 vid, u32 port_mask) |
||
888 | { |
||
889 | u32 op; |
||
890 | u32 val; |
||
891 | int i; |
||
892 | |||
893 | op = AR8327_VTU_FUNC1_OP_LOAD | (vid << AR8327_VTU_FUNC1_VID_S); |
||
894 | val = AR8327_VTU_FUNC0_VALID | AR8327_VTU_FUNC0_IVL; |
||
895 | for (i = 0; i < AR8327_NUM_PORTS; i++) { |
||
896 | u32 mode; |
||
897 | |||
898 | if ((port_mask & BIT(i)) == 0) |
||
899 | mode = AR8327_VTU_FUNC0_EG_MODE_NOT; |
||
900 | else if (priv->vlan == 0) |
||
901 | mode = AR8327_VTU_FUNC0_EG_MODE_KEEP; |
||
902 | else if ((priv->vlan_tagged & BIT(i)) || (priv->vlan_id[priv->pvid[i]] != vid)) |
||
903 | mode = AR8327_VTU_FUNC0_EG_MODE_TAG; |
||
904 | else |
||
905 | mode = AR8327_VTU_FUNC0_EG_MODE_UNTAG; |
||
906 | |||
907 | val |= mode << AR8327_VTU_FUNC0_EG_MODE_S(i); |
||
908 | } |
||
909 | ar8327_vtu_op(priv, op, val); |
||
910 | } |
||
911 | |||
912 | static void |
||
913 | ar8327_setup_port(struct ar8xxx_priv *priv, int port, u32 members) |
||
914 | { |
||
915 | u32 t; |
||
916 | u32 egress, ingress; |
||
917 | u32 pvid = priv->vlan_id[priv->pvid[port]]; |
||
918 | |||
919 | if (priv->vlan) { |
||
920 | egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD; |
||
921 | ingress = AR8216_IN_SECURE; |
||
922 | } else { |
||
923 | egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH; |
||
924 | ingress = AR8216_IN_PORT_ONLY; |
||
925 | } |
||
926 | |||
927 | t = pvid << AR8327_PORT_VLAN0_DEF_SVID_S; |
||
928 | t |= pvid << AR8327_PORT_VLAN0_DEF_CVID_S; |
||
929 | if (priv->vlan && priv->port_vlan_prio[port]) { |
||
930 | u32 prio = priv->port_vlan_prio[port]; |
||
931 | |||
932 | t |= prio << AR8327_PORT_VLAN0_DEF_SPRI_S; |
||
933 | t |= prio << AR8327_PORT_VLAN0_DEF_CPRI_S; |
||
934 | } |
||
935 | ar8xxx_write(priv, AR8327_REG_PORT_VLAN0(port), t); |
||
936 | |||
937 | t = AR8327_PORT_VLAN1_PORT_VLAN_PROP; |
||
938 | t |= egress << AR8327_PORT_VLAN1_OUT_MODE_S; |
||
939 | if (priv->vlan && priv->port_vlan_prio[port]) |
||
940 | t |= AR8327_PORT_VLAN1_VLAN_PRI_PROP; |
||
941 | |||
942 | ar8xxx_write(priv, AR8327_REG_PORT_VLAN1(port), t); |
||
943 | |||
944 | t = members; |
||
945 | t |= AR8327_PORT_LOOKUP_LEARN; |
||
946 | t |= ingress << AR8327_PORT_LOOKUP_IN_MODE_S; |
||
947 | t |= AR8216_PORT_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; |
||
948 | ar8xxx_write(priv, AR8327_REG_PORT_LOOKUP(port), t); |
||
949 | } |
||
950 | |||
951 | static int |
||
952 | ar8327_sw_get_ports(struct switch_dev *dev, struct switch_val *val) |
||
953 | { |
||
954 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
955 | u8 ports = priv->vlan_table[val->port_vlan]; |
||
956 | int i; |
||
957 | |||
958 | val->len = 0; |
||
959 | for (i = 0; i < dev->ports; i++) { |
||
960 | struct switch_port *p; |
||
961 | |||
962 | if (!(ports & (1 << i))) |
||
963 | continue; |
||
964 | |||
965 | p = &val->value.ports[val->len++]; |
||
966 | p->id = i; |
||
967 | if ((priv->vlan_tagged & (1 << i)) || (priv->pvid[i] != val->port_vlan)) |
||
968 | p->flags = (1 << SWITCH_PORT_FLAG_TAGGED); |
||
969 | else |
||
970 | p->flags = 0; |
||
971 | } |
||
972 | return 0; |
||
973 | } |
||
974 | |||
975 | static int |
||
976 | ar8327_sw_set_ports(struct switch_dev *dev, struct switch_val *val) |
||
977 | { |
||
978 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
979 | u8 *vt = &priv->vlan_table[val->port_vlan]; |
||
980 | int i; |
||
981 | |||
982 | *vt = 0; |
||
983 | for (i = 0; i < val->len; i++) { |
||
984 | struct switch_port *p = &val->value.ports[i]; |
||
985 | |||
986 | if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) { |
||
987 | if (val->port_vlan == priv->pvid[p->id]) { |
||
988 | priv->vlan_tagged |= (1 << p->id); |
||
989 | } |
||
990 | } else { |
||
991 | priv->vlan_tagged &= ~(1 << p->id); |
||
992 | priv->pvid[p->id] = val->port_vlan; |
||
993 | } |
||
994 | |||
995 | *vt |= 1 << p->id; |
||
996 | } |
||
997 | return 0; |
||
998 | } |
||
999 | |||
1000 | static void |
||
1001 | ar8327_set_mirror_regs(struct ar8xxx_priv *priv) |
||
1002 | { |
||
1003 | int port; |
||
1004 | |||
1005 | /* reset all mirror registers */ |
||
1006 | ar8xxx_rmw(priv, AR8327_REG_FWD_CTRL0, |
||
1007 | AR8327_FWD_CTRL0_MIRROR_PORT, |
||
1008 | (0xF << AR8327_FWD_CTRL0_MIRROR_PORT_S)); |
||
1009 | for (port = 0; port < AR8327_NUM_PORTS; port++) { |
||
1010 | ar8xxx_reg_clear(priv, AR8327_REG_PORT_LOOKUP(port), |
||
1011 | AR8327_PORT_LOOKUP_ING_MIRROR_EN); |
||
1012 | |||
1013 | ar8xxx_reg_clear(priv, AR8327_REG_PORT_HOL_CTRL1(port), |
||
1014 | AR8327_PORT_HOL_CTRL1_EG_MIRROR_EN); |
||
1015 | } |
||
1016 | |||
1017 | /* now enable mirroring if necessary */ |
||
1018 | if (priv->source_port >= AR8327_NUM_PORTS || |
||
1019 | priv->monitor_port >= AR8327_NUM_PORTS || |
||
1020 | priv->source_port == priv->monitor_port) { |
||
1021 | return; |
||
1022 | } |
||
1023 | |||
1024 | ar8xxx_rmw(priv, AR8327_REG_FWD_CTRL0, |
||
1025 | AR8327_FWD_CTRL0_MIRROR_PORT, |
||
1026 | (priv->monitor_port << AR8327_FWD_CTRL0_MIRROR_PORT_S)); |
||
1027 | |||
1028 | if (priv->mirror_rx) |
||
1029 | ar8xxx_reg_set(priv, AR8327_REG_PORT_LOOKUP(priv->source_port), |
||
1030 | AR8327_PORT_LOOKUP_ING_MIRROR_EN); |
||
1031 | |||
1032 | if (priv->mirror_tx) |
||
1033 | ar8xxx_reg_set(priv, AR8327_REG_PORT_HOL_CTRL1(priv->source_port), |
||
1034 | AR8327_PORT_HOL_CTRL1_EG_MIRROR_EN); |
||
1035 | } |
||
1036 | |||
1037 | static int |
||
1038 | ar8327_sw_set_eee(struct switch_dev *dev, |
||
1039 | const struct switch_attr *attr, |
||
1040 | struct switch_val *val) |
||
1041 | { |
||
1042 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1043 | struct ar8327_data *data = priv->chip_data; |
||
1044 | int port = val->port_vlan; |
||
1045 | int phy; |
||
1046 | |||
1047 | if (port >= dev->ports) |
||
1048 | return -EINVAL; |
||
1049 | if (port == 0 || port == 6) |
||
1050 | return -EOPNOTSUPP; |
||
1051 | |||
1052 | phy = port - 1; |
||
1053 | |||
1054 | data->eee[phy] = !!(val->value.i); |
||
1055 | |||
1056 | return 0; |
||
1057 | } |
||
1058 | |||
1059 | static int |
||
1060 | ar8327_sw_get_eee(struct switch_dev *dev, |
||
1061 | const struct switch_attr *attr, |
||
1062 | struct switch_val *val) |
||
1063 | { |
||
1064 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1065 | const struct ar8327_data *data = priv->chip_data; |
||
1066 | int port = val->port_vlan; |
||
1067 | int phy; |
||
1068 | |||
1069 | if (port >= dev->ports) |
||
1070 | return -EINVAL; |
||
1071 | if (port == 0 || port == 6) |
||
1072 | return -EOPNOTSUPP; |
||
1073 | |||
1074 | phy = port - 1; |
||
1075 | |||
1076 | val->value.i = data->eee[phy]; |
||
1077 | |||
1078 | return 0; |
||
1079 | } |
||
1080 | |||
1081 | static void |
||
1082 | ar8327_wait_atu_ready(struct ar8xxx_priv *priv, u16 r2, u16 r1) |
||
1083 | { |
||
1084 | int timeout = 20; |
||
1085 | |||
1086 | while (ar8xxx_mii_read32(priv, r2, r1) & AR8327_ATU_FUNC_BUSY && --timeout) { |
||
1087 | udelay(10); |
||
1088 | cond_resched(); |
||
1089 | } |
||
1090 | |||
1091 | if (!timeout) |
||
1092 | pr_err("ar8327: timeout waiting for atu to become ready\n"); |
||
1093 | } |
||
1094 | |||
1095 | static void ar8327_get_arl_entry(struct ar8xxx_priv *priv, |
||
1096 | struct arl_entry *a, u32 *status, enum arl_op op) |
||
1097 | { |
||
1098 | struct mii_bus *bus = priv->mii_bus; |
||
1099 | u16 r2, page; |
||
1100 | u16 r1_data0, r1_data1, r1_data2, r1_func; |
||
3 | office | 1101 | u32 t, val0, val1, val2; |
1102 | int i; |
||
1 | office | 1103 | |
1104 | split_addr(AR8327_REG_ATU_DATA0, &r1_data0, &r2, &page); |
||
1105 | r2 |= 0x10; |
||
1106 | |||
1107 | r1_data1 = (AR8327_REG_ATU_DATA1 >> 1) & 0x1e; |
||
1108 | r1_data2 = (AR8327_REG_ATU_DATA2 >> 1) & 0x1e; |
||
1109 | r1_func = (AR8327_REG_ATU_FUNC >> 1) & 0x1e; |
||
1110 | |||
1111 | switch (op) { |
||
1112 | case AR8XXX_ARL_INITIALIZE: |
||
1113 | /* all ATU registers are on the same page |
||
1114 | * therefore set page only once |
||
1115 | */ |
||
1116 | bus->write(bus, 0x18, 0, page); |
||
1117 | wait_for_page_switch(); |
||
1118 | |||
1119 | ar8327_wait_atu_ready(priv, r2, r1_func); |
||
1120 | |||
1121 | ar8xxx_mii_write32(priv, r2, r1_data0, 0); |
||
1122 | ar8xxx_mii_write32(priv, r2, r1_data1, 0); |
||
1123 | ar8xxx_mii_write32(priv, r2, r1_data2, 0); |
||
1124 | break; |
||
1125 | case AR8XXX_ARL_GET_NEXT: |
||
1126 | ar8xxx_mii_write32(priv, r2, r1_func, |
||
1127 | AR8327_ATU_FUNC_OP_GET_NEXT | |
||
1128 | AR8327_ATU_FUNC_BUSY); |
||
1129 | ar8327_wait_atu_ready(priv, r2, r1_func); |
||
1130 | |||
1131 | val0 = ar8xxx_mii_read32(priv, r2, r1_data0); |
||
1132 | val1 = ar8xxx_mii_read32(priv, r2, r1_data1); |
||
1133 | val2 = ar8xxx_mii_read32(priv, r2, r1_data2); |
||
1134 | |||
1135 | *status = val2 & AR8327_ATU_STATUS; |
||
1136 | if (!*status) |
||
1137 | break; |
||
1138 | |||
3 | office | 1139 | i = 0; |
1140 | t = AR8327_ATU_PORT0; |
||
1141 | while (!(val1 & t) && ++i < AR8327_NUM_PORTS) |
||
1142 | t <<= 1; |
||
1143 | |||
1144 | a->port = i; |
||
1 | office | 1145 | a->mac[0] = (val0 & AR8327_ATU_ADDR0) >> AR8327_ATU_ADDR0_S; |
1146 | a->mac[1] = (val0 & AR8327_ATU_ADDR1) >> AR8327_ATU_ADDR1_S; |
||
1147 | a->mac[2] = (val0 & AR8327_ATU_ADDR2) >> AR8327_ATU_ADDR2_S; |
||
1148 | a->mac[3] = (val0 & AR8327_ATU_ADDR3) >> AR8327_ATU_ADDR3_S; |
||
1149 | a->mac[4] = (val1 & AR8327_ATU_ADDR4) >> AR8327_ATU_ADDR4_S; |
||
1150 | a->mac[5] = (val1 & AR8327_ATU_ADDR5) >> AR8327_ATU_ADDR5_S; |
||
1151 | break; |
||
1152 | } |
||
1153 | } |
||
1154 | |||
1155 | static int |
||
1156 | ar8327_sw_hw_apply(struct switch_dev *dev) |
||
1157 | { |
||
1158 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1159 | const struct ar8327_data *data = priv->chip_data; |
||
1160 | int ret, i; |
||
1161 | |||
1162 | ret = ar8xxx_sw_hw_apply(dev); |
||
1163 | if (ret) |
||
1164 | return ret; |
||
1165 | |||
1166 | for (i=0; i < AR8XXX_NUM_PHYS; i++) { |
||
1167 | if (data->eee[i]) |
||
1168 | ar8xxx_reg_clear(priv, AR8327_REG_EEE_CTRL, |
||
1169 | AR8327_EEE_CTRL_DISABLE_PHY(i)); |
||
1170 | else |
||
1171 | ar8xxx_reg_set(priv, AR8327_REG_EEE_CTRL, |
||
1172 | AR8327_EEE_CTRL_DISABLE_PHY(i)); |
||
1173 | } |
||
1174 | |||
1175 | return 0; |
||
1176 | } |
||
1177 | |||
1178 | int |
||
1179 | ar8327_sw_get_port_igmp_snooping(struct switch_dev *dev, |
||
1180 | const struct switch_attr *attr, |
||
1181 | struct switch_val *val) |
||
1182 | { |
||
1183 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1184 | int port = val->port_vlan; |
||
1185 | |||
1186 | if (port >= dev->ports) |
||
1187 | return -EINVAL; |
||
1188 | |||
1189 | mutex_lock(&priv->reg_mutex); |
||
1190 | val->value.i = ar8327_get_port_igmp(priv, port); |
||
1191 | mutex_unlock(&priv->reg_mutex); |
||
1192 | |||
1193 | return 0; |
||
1194 | } |
||
1195 | |||
1196 | int |
||
1197 | ar8327_sw_set_port_igmp_snooping(struct switch_dev *dev, |
||
1198 | const struct switch_attr *attr, |
||
1199 | struct switch_val *val) |
||
1200 | { |
||
1201 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1202 | int port = val->port_vlan; |
||
1203 | |||
1204 | if (port >= dev->ports) |
||
1205 | return -EINVAL; |
||
1206 | |||
1207 | mutex_lock(&priv->reg_mutex); |
||
1208 | ar8327_set_port_igmp(priv, port, val->value.i); |
||
1209 | mutex_unlock(&priv->reg_mutex); |
||
1210 | |||
1211 | return 0; |
||
1212 | } |
||
1213 | |||
1214 | int |
||
1215 | ar8327_sw_get_igmp_snooping(struct switch_dev *dev, |
||
1216 | const struct switch_attr *attr, |
||
1217 | struct switch_val *val) |
||
1218 | { |
||
1219 | int port; |
||
1220 | |||
1221 | for (port = 0; port < dev->ports; port++) { |
||
1222 | val->port_vlan = port; |
||
1223 | if (ar8327_sw_get_port_igmp_snooping(dev, attr, val) || |
||
1224 | !val->value.i) |
||
1225 | break; |
||
1226 | } |
||
1227 | |||
1228 | return 0; |
||
1229 | } |
||
1230 | |||
1231 | int |
||
1232 | ar8327_sw_set_igmp_snooping(struct switch_dev *dev, |
||
1233 | const struct switch_attr *attr, |
||
1234 | struct switch_val *val) |
||
1235 | { |
||
1236 | int port; |
||
1237 | |||
1238 | for (port = 0; port < dev->ports; port++) { |
||
1239 | val->port_vlan = port; |
||
1240 | if (ar8327_sw_set_port_igmp_snooping(dev, attr, val)) |
||
1241 | break; |
||
1242 | } |
||
1243 | |||
1244 | return 0; |
||
1245 | } |
||
1246 | |||
1247 | int |
||
1248 | ar8327_sw_get_igmp_v3(struct switch_dev *dev, |
||
1249 | const struct switch_attr *attr, |
||
1250 | struct switch_val *val) |
||
1251 | { |
||
1252 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1253 | u32 val_reg; |
||
1254 | |||
1255 | mutex_lock(&priv->reg_mutex); |
||
1256 | val_reg = ar8xxx_read(priv, AR8327_REG_FRAME_ACK_CTRL1); |
||
1257 | val->value.i = ((val_reg & AR8327_FRAME_ACK_CTRL_IGMP_V3_EN) != 0); |
||
1258 | mutex_unlock(&priv->reg_mutex); |
||
1259 | |||
1260 | return 0; |
||
1261 | } |
||
1262 | |||
1263 | int |
||
1264 | ar8327_sw_set_igmp_v3(struct switch_dev *dev, |
||
1265 | const struct switch_attr *attr, |
||
1266 | struct switch_val *val) |
||
1267 | { |
||
1268 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1269 | |||
1270 | mutex_lock(&priv->reg_mutex); |
||
1271 | if (val->value.i) |
||
1272 | ar8xxx_reg_set(priv, AR8327_REG_FRAME_ACK_CTRL1, |
||
1273 | AR8327_FRAME_ACK_CTRL_IGMP_V3_EN); |
||
1274 | else |
||
1275 | ar8xxx_reg_clear(priv, AR8327_REG_FRAME_ACK_CTRL1, |
||
1276 | AR8327_FRAME_ACK_CTRL_IGMP_V3_EN); |
||
1277 | mutex_unlock(&priv->reg_mutex); |
||
1278 | |||
1279 | return 0; |
||
1280 | } |
||
1281 | |||
1282 | static int |
||
1283 | ar8327_sw_set_port_vlan_prio(struct switch_dev *dev, const struct switch_attr *attr, |
||
1284 | struct switch_val *val) |
||
1285 | { |
||
1286 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1287 | int port = val->port_vlan; |
||
1288 | |||
1289 | if (port >= dev->ports) |
||
1290 | return -EINVAL; |
||
1291 | if (port == 0 || port == 6) |
||
1292 | return -EOPNOTSUPP; |
||
1293 | if (val->value.i < 0 || val->value.i > 7) |
||
1294 | return -EINVAL; |
||
1295 | |||
1296 | priv->port_vlan_prio[port] = val->value.i; |
||
1297 | |||
1298 | return 0; |
||
1299 | } |
||
1300 | |||
1301 | static int |
||
1302 | ar8327_sw_get_port_vlan_prio(struct switch_dev *dev, const struct switch_attr *attr, |
||
1303 | struct switch_val *val) |
||
1304 | { |
||
1305 | struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev); |
||
1306 | int port = val->port_vlan; |
||
1307 | |||
1308 | val->value.i = priv->port_vlan_prio[port]; |
||
1309 | |||
1310 | return 0; |
||
1311 | } |
||
1312 | |||
1313 | static const struct switch_attr ar8327_sw_attr_globals[] = { |
||
1314 | { |
||
1315 | .type = SWITCH_TYPE_INT, |
||
1316 | .name = "enable_vlan", |
||
1317 | .description = "Enable VLAN mode", |
||
1318 | .set = ar8xxx_sw_set_vlan, |
||
1319 | .get = ar8xxx_sw_get_vlan, |
||
1320 | .max = 1 |
||
1321 | }, |
||
1322 | { |
||
1323 | .type = SWITCH_TYPE_NOVAL, |
||
1324 | .name = "reset_mibs", |
||
1325 | .description = "Reset all MIB counters", |
||
1326 | .set = ar8xxx_sw_set_reset_mibs, |
||
1327 | }, |
||
1328 | { |
||
1329 | .type = SWITCH_TYPE_INT, |
||
1330 | .name = "enable_mirror_rx", |
||
1331 | .description = "Enable mirroring of RX packets", |
||
1332 | .set = ar8xxx_sw_set_mirror_rx_enable, |
||
1333 | .get = ar8xxx_sw_get_mirror_rx_enable, |
||
1334 | .max = 1 |
||
1335 | }, |
||
1336 | { |
||
1337 | .type = SWITCH_TYPE_INT, |
||
1338 | .name = "enable_mirror_tx", |
||
1339 | .description = "Enable mirroring of TX packets", |
||
1340 | .set = ar8xxx_sw_set_mirror_tx_enable, |
||
1341 | .get = ar8xxx_sw_get_mirror_tx_enable, |
||
1342 | .max = 1 |
||
1343 | }, |
||
1344 | { |
||
1345 | .type = SWITCH_TYPE_INT, |
||
1346 | .name = "mirror_monitor_port", |
||
1347 | .description = "Mirror monitor port", |
||
1348 | .set = ar8xxx_sw_set_mirror_monitor_port, |
||
1349 | .get = ar8xxx_sw_get_mirror_monitor_port, |
||
1350 | .max = AR8327_NUM_PORTS - 1 |
||
1351 | }, |
||
1352 | { |
||
1353 | .type = SWITCH_TYPE_INT, |
||
1354 | .name = "mirror_source_port", |
||
1355 | .description = "Mirror source port", |
||
1356 | .set = ar8xxx_sw_set_mirror_source_port, |
||
1357 | .get = ar8xxx_sw_get_mirror_source_port, |
||
1358 | .max = AR8327_NUM_PORTS - 1 |
||
1359 | }, |
||
1360 | { |
||
1361 | .type = SWITCH_TYPE_INT, |
||
1362 | .name = "arl_age_time", |
||
1363 | .description = "ARL age time (secs)", |
||
1364 | .set = ar8xxx_sw_set_arl_age_time, |
||
1365 | .get = ar8xxx_sw_get_arl_age_time, |
||
1366 | }, |
||
1367 | { |
||
1368 | .type = SWITCH_TYPE_STRING, |
||
1369 | .name = "arl_table", |
||
1370 | .description = "Get ARL table", |
||
1371 | .set = NULL, |
||
1372 | .get = ar8xxx_sw_get_arl_table, |
||
1373 | }, |
||
1374 | { |
||
1375 | .type = SWITCH_TYPE_NOVAL, |
||
1376 | .name = "flush_arl_table", |
||
1377 | .description = "Flush ARL table", |
||
1378 | .set = ar8xxx_sw_set_flush_arl_table, |
||
1379 | }, |
||
1380 | { |
||
1381 | .type = SWITCH_TYPE_INT, |
||
1382 | .name = "igmp_snooping", |
||
1383 | .description = "Enable IGMP Snooping", |
||
1384 | .set = ar8327_sw_set_igmp_snooping, |
||
1385 | .get = ar8327_sw_get_igmp_snooping, |
||
1386 | .max = 1 |
||
1387 | }, |
||
1388 | { |
||
1389 | .type = SWITCH_TYPE_INT, |
||
1390 | .name = "igmp_v3", |
||
1391 | .description = "Enable IGMPv3 support", |
||
1392 | .set = ar8327_sw_set_igmp_v3, |
||
1393 | .get = ar8327_sw_get_igmp_v3, |
||
1394 | .max = 1 |
||
1395 | }, |
||
1396 | }; |
||
1397 | |||
1398 | static const struct switch_attr ar8327_sw_attr_port[] = { |
||
1399 | { |
||
1400 | .type = SWITCH_TYPE_NOVAL, |
||
1401 | .name = "reset_mib", |
||
1402 | .description = "Reset single port MIB counters", |
||
1403 | .set = ar8xxx_sw_set_port_reset_mib, |
||
1404 | }, |
||
1405 | { |
||
1406 | .type = SWITCH_TYPE_STRING, |
||
1407 | .name = "mib", |
||
1408 | .description = "Get port's MIB counters", |
||
1409 | .set = NULL, |
||
1410 | .get = ar8xxx_sw_get_port_mib, |
||
1411 | }, |
||
1412 | { |
||
1413 | .type = SWITCH_TYPE_INT, |
||
1414 | .name = "enable_eee", |
||
1415 | .description = "Enable EEE PHY sleep mode", |
||
1416 | .set = ar8327_sw_set_eee, |
||
1417 | .get = ar8327_sw_get_eee, |
||
1418 | .max = 1, |
||
1419 | }, |
||
1420 | { |
||
1421 | .type = SWITCH_TYPE_NOVAL, |
||
1422 | .name = "flush_arl_table", |
||
1423 | .description = "Flush port's ARL table entries", |
||
1424 | .set = ar8xxx_sw_set_flush_port_arl_table, |
||
1425 | }, |
||
1426 | { |
||
1427 | .type = SWITCH_TYPE_INT, |
||
1428 | .name = "igmp_snooping", |
||
1429 | .description = "Enable port's IGMP Snooping", |
||
1430 | .set = ar8327_sw_set_port_igmp_snooping, |
||
1431 | .get = ar8327_sw_get_port_igmp_snooping, |
||
1432 | .max = 1 |
||
1433 | }, |
||
1434 | { |
||
1435 | .type = SWITCH_TYPE_INT, |
||
1436 | .name = "vlan_prio", |
||
1437 | .description = "Port VLAN default priority (VLAN PCP) (0-7)", |
||
1438 | .set = ar8327_sw_set_port_vlan_prio, |
||
1439 | .get = ar8327_sw_get_port_vlan_prio, |
||
1440 | .max = 7, |
||
1441 | }, |
||
1442 | }; |
||
1443 | |||
1444 | static const struct switch_dev_ops ar8327_sw_ops = { |
||
1445 | .attr_global = { |
||
1446 | .attr = ar8327_sw_attr_globals, |
||
1447 | .n_attr = ARRAY_SIZE(ar8327_sw_attr_globals), |
||
1448 | }, |
||
1449 | .attr_port = { |
||
1450 | .attr = ar8327_sw_attr_port, |
||
1451 | .n_attr = ARRAY_SIZE(ar8327_sw_attr_port), |
||
1452 | }, |
||
1453 | .attr_vlan = { |
||
1454 | .attr = ar8xxx_sw_attr_vlan, |
||
1455 | .n_attr = ARRAY_SIZE(ar8xxx_sw_attr_vlan), |
||
1456 | }, |
||
1457 | .get_port_pvid = ar8xxx_sw_get_pvid, |
||
1458 | .set_port_pvid = ar8xxx_sw_set_pvid, |
||
1459 | .get_vlan_ports = ar8327_sw_get_ports, |
||
1460 | .set_vlan_ports = ar8327_sw_set_ports, |
||
1461 | .apply_config = ar8327_sw_hw_apply, |
||
1462 | .reset_switch = ar8xxx_sw_reset_switch, |
||
1463 | .get_port_link = ar8xxx_sw_get_port_link, |
||
1464 | /* The following op is disabled as it hogs the CPU and degrades performance. |
||
1465 | An implementation has been attempted in 4d8a66d but reading MIB data is slow |
||
1466 | on ar8xxx switches. |
||
1467 | |||
1468 | The high CPU load has been traced down to the ar8xxx_reg_wait() call in |
||
1469 | ar8xxx_mib_op(), which has to usleep_range() till the MIB busy flag set by |
||
1470 | the request to update the MIB counter is cleared. */ |
||
1471 | #if 0 |
||
1472 | .get_port_stats = ar8xxx_sw_get_port_stats, |
||
1473 | #endif |
||
1474 | }; |
||
1475 | |||
1476 | const struct ar8xxx_chip ar8327_chip = { |
||
1477 | .caps = AR8XXX_CAP_GIGE | AR8XXX_CAP_MIB_COUNTERS, |
||
1478 | .config_at_probe = true, |
||
1479 | .mii_lo_first = true, |
||
1480 | |||
1481 | .name = "Atheros AR8327", |
||
1482 | .ports = AR8327_NUM_PORTS, |
||
1483 | .vlans = AR8X16_MAX_VLANS, |
||
1484 | .swops = &ar8327_sw_ops, |
||
1485 | |||
1486 | .reg_port_stats_start = 0x1000, |
||
1487 | .reg_port_stats_length = 0x100, |
||
1488 | .reg_arl_ctrl = AR8327_REG_ARL_CTRL, |
||
1489 | |||
1490 | .hw_init = ar8327_hw_init, |
||
1491 | .cleanup = ar8327_cleanup, |
||
1492 | .init_globals = ar8327_init_globals, |
||
1493 | .init_port = ar8327_init_port, |
||
1494 | .setup_port = ar8327_setup_port, |
||
1495 | .read_port_status = ar8327_read_port_status, |
||
1496 | .read_port_eee_status = ar8327_read_port_eee_status, |
||
1497 | .atu_flush = ar8327_atu_flush, |
||
1498 | .atu_flush_port = ar8327_atu_flush_port, |
||
1499 | .vtu_flush = ar8327_vtu_flush, |
||
1500 | .vtu_load_vlan = ar8327_vtu_load_vlan, |
||
1501 | .set_mirror_regs = ar8327_set_mirror_regs, |
||
1502 | .get_arl_entry = ar8327_get_arl_entry, |
||
1503 | .sw_hw_apply = ar8327_sw_hw_apply, |
||
1504 | |||
1505 | .num_mibs = ARRAY_SIZE(ar8236_mibs), |
||
1506 | .mib_decs = ar8236_mibs, |
||
1507 | .mib_func = AR8327_REG_MIB_FUNC |
||
1508 | }; |
||
1509 | |||
1510 | const struct ar8xxx_chip ar8337_chip = { |
||
1511 | .caps = AR8XXX_CAP_GIGE | AR8XXX_CAP_MIB_COUNTERS, |
||
1512 | .config_at_probe = true, |
||
1513 | .mii_lo_first = true, |
||
1514 | |||
1515 | .name = "Atheros AR8337", |
||
1516 | .ports = AR8327_NUM_PORTS, |
||
1517 | .vlans = AR8X16_MAX_VLANS, |
||
1518 | .swops = &ar8327_sw_ops, |
||
1519 | |||
1520 | .reg_port_stats_start = 0x1000, |
||
1521 | .reg_port_stats_length = 0x100, |
||
1522 | .reg_arl_ctrl = AR8327_REG_ARL_CTRL, |
||
1523 | |||
1524 | .hw_init = ar8327_hw_init, |
||
1525 | .cleanup = ar8327_cleanup, |
||
1526 | .init_globals = ar8327_init_globals, |
||
1527 | .init_port = ar8327_init_port, |
||
1528 | .setup_port = ar8327_setup_port, |
||
1529 | .read_port_status = ar8327_read_port_status, |
||
1530 | .read_port_eee_status = ar8327_read_port_eee_status, |
||
1531 | .atu_flush = ar8327_atu_flush, |
||
1532 | .atu_flush_port = ar8327_atu_flush_port, |
||
1533 | .vtu_flush = ar8327_vtu_flush, |
||
1534 | .vtu_load_vlan = ar8327_vtu_load_vlan, |
||
1535 | .phy_fixup = ar8327_phy_fixup, |
||
1536 | .set_mirror_regs = ar8327_set_mirror_regs, |
||
1537 | .get_arl_entry = ar8327_get_arl_entry, |
||
1538 | .sw_hw_apply = ar8327_sw_hw_apply, |
||
1539 | |||
1540 | .num_mibs = ARRAY_SIZE(ar8236_mibs), |
||
1541 | .mib_decs = ar8236_mibs, |
||
1542 | .mib_func = AR8327_REG_MIB_FUNC |
||
1543 | }; |