11 #include <linux/list.h>
12 #include <linux/module.h>
13 #include <linux/netdevice.h>
27 static int mv88e6xxx_reg_wait_ready(
struct mii_bus *
bus,
int sw_addr)
32 for (i = 0; i < 16; i++) {
37 if ((ret & 0x8000) == 0)
54 ret = mv88e6xxx_reg_wait_ready(bus, sw_addr);
61 ret =
mdiobus_write(bus, sw_addr, 0, 0x9800 | (addr << 5) | reg);
68 ret = mv88e6xxx_reg_wait_ready(bus, sw_addr);
89 ds->
pd->sw_addr, addr, reg);
106 ret = mv88e6xxx_reg_wait_ready(bus, sw_addr);
120 ret =
mdiobus_write(bus, sw_addr, 0, 0x9400 | (addr << 5) | reg);
127 ret = mv88e6xxx_reg_wait_ready(bus, sw_addr);
141 ds->
pd->sw_addr, addr, reg, val);
183 for (i = 0; i < 6; i++) {
194 for (j = 0; j < 16; j++) {
196 if ((ret & 0x8000) == 0)
220 #ifdef CONFIG_NET_DSA_MV88E6XXX_NEED_PPU
229 for (i = 0; i < 1000; i++) {
232 if ((ret & 0xc000) != 0xc000)
239 static int mv88e6xxx_ppu_enable(
struct dsa_switch *ds)
247 for (i = 0; i < 1000; i++) {
250 if ((ret & 0xc000) == 0xc000)
257 static void mv88e6xxx_ppu_reenable_work(
struct work_struct *ugly)
265 if (mv88e6xxx_ppu_enable(ds) == 0)
266 ps->ppu_disabled = 0;
271 static void mv88e6xxx_ppu_reenable_timer(
unsigned long _ps)
278 static int mv88e6xxx_ppu_access_get(
struct dsa_switch *ds)
291 if (!ps->ppu_disabled) {
292 ret = mv88e6xxx_ppu_disable(ds);
297 ps->ppu_disabled = 1;
306 static void mv88e6xxx_ppu_access_put(
struct dsa_switch *ds)
322 INIT_WORK(&ps->ppu_work, mv88e6xxx_ppu_reenable_work);
324 ps->ppu_timer.data = (
unsigned long)ps;
325 ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer;
332 ret = mv88e6xxx_ppu_access_get(ds);
335 mv88e6xxx_ppu_access_put(ds);
346 ret = mv88e6xxx_ppu_access_get(ds);
349 mv88e6xxx_ppu_access_put(ds);
382 if (netif_carrier_ok(dev)) {
406 if (!netif_carrier_ok(dev)) {
408 "flow control %sabled\n", dev->
name,
409 speed, duplex ?
"full" :
"half",
416 static int mv88e6xxx_stats_wait(
struct dsa_switch *ds)
421 for (i = 0; i < 10; i++) {
423 if ((ret & 0x8000) == 0)
430 static int mv88e6xxx_stats_snapshot(
struct dsa_switch *ds,
int port)
442 ret = mv88e6xxx_stats_wait(ds);
460 ret = mv88e6xxx_stats_wait(ds);
483 for (i = 0; i < nr_stats; i++) {
485 stats[i].
string, ETH_GSTRING_LEN);
499 ret = mv88e6xxx_stats_snapshot(ds, port);
508 for (i = 0; i < nr_stats; i++) {
513 mv88e6xxx_stats_read(ds, s->
reg, &low);
515 mv88e6xxx_stats_read(ds, s->
reg + 1, &high);
519 data[
i] = (((
u64)high) << 32) | low;
525 static int __init mv88e6xxx_init(
void)
527 #if IS_ENABLED(CONFIG_NET_DSA_MV88E6131)
530 #if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65)
537 static void __exit mv88e6xxx_cleanup(
void)
539 #if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65)
542 #if IS_ENABLED(CONFIG_NET_DSA_MV88E6131)