Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1 | /* |
Vivien Didelot | 0d3cd4b | 2016-06-21 12:28:19 -0400 | [diff] [blame] | 2 | * Marvell 88e6xxx Ethernet switch single-chip support |
| 3 | * |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 4 | * Copyright (c) 2008 Marvell Semiconductor |
| 5 | * |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 6 | * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch> |
| 7 | * |
Vivien Didelot | 4333d61 | 2017-03-28 15:10:36 -0400 | [diff] [blame] | 8 | * Copyright (c) 2016-2017 Savoir-faire Linux Inc. |
| 9 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
| 10 | * |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | */ |
| 16 | |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 17 | #include <linux/delay.h> |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 18 | #include <linux/etherdevice.h> |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 19 | #include <linux/ethtool.h> |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 20 | #include <linux/if_bridge.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/irq.h> |
| 23 | #include <linux/irqdomain.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 24 | #include <linux/jiffies.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 25 | #include <linux/list.h> |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 26 | #include <linux/mdio.h> |
Paul Gortmaker | 2bbba27 | 2012-01-24 10:41:40 +0000 | [diff] [blame] | 27 | #include <linux/module.h> |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 28 | #include <linux/of_device.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 29 | #include <linux/of_irq.h> |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 30 | #include <linux/of_mdio.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 31 | #include <linux/netdevice.h> |
Andrew Lunn | c8c1b39a | 2015-11-20 03:56:24 +0100 | [diff] [blame] | 32 | #include <linux/gpio/consumer.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 33 | #include <linux/phy.h> |
Ben Hutchings | c8f0b86 | 2011-11-27 17:06:08 +0000 | [diff] [blame] | 34 | #include <net/dsa.h> |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 35 | |
Vivien Didelot | 4d5f2ba7 | 2017-06-02 17:06:15 -0400 | [diff] [blame] | 36 | #include "chip.h" |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 37 | #include "global1.h" |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 38 | #include "global2.h" |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 39 | #include "hwtstamp.h" |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 40 | #include "phy.h" |
Vivien Didelot | 18abed2 | 2016-11-04 03:23:26 +0100 | [diff] [blame] | 41 | #include "port.h" |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 42 | #include "ptp.h" |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 43 | #include "serdes.h" |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 44 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 45 | static void assert_reg_lock(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 46 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 47 | if (unlikely(!mutex_is_locked(&chip->reg_lock))) { |
| 48 | dev_err(chip->dev, "Switch registers lock not held!\n"); |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 49 | dump_stack(); |
| 50 | } |
| 51 | } |
| 52 | |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 53 | /* The switch ADDR[4:1] configuration pins define the chip SMI device address |
| 54 | * (ADDR[0] is always zero, thus only even SMI addresses can be strapped). |
| 55 | * |
| 56 | * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it |
| 57 | * is the only device connected to the SMI master. In this mode it responds to |
| 58 | * all 32 possible SMI addresses, and thus maps directly the internal devices. |
| 59 | * |
| 60 | * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing |
| 61 | * multiple devices to share the SMI interface. In this mode it responds to only |
| 62 | * 2 registers, used to indirectly access the internal SMI devices. |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 63 | */ |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 64 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 65 | static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 66 | int addr, int reg, u16 *val) |
| 67 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 68 | if (!chip->smi_ops) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 69 | return -EOPNOTSUPP; |
| 70 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 71 | return chip->smi_ops->read(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 72 | } |
| 73 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 74 | static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 75 | int addr, int reg, u16 val) |
| 76 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 77 | if (!chip->smi_ops) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 78 | return -EOPNOTSUPP; |
| 79 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 80 | return chip->smi_ops->write(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 81 | } |
| 82 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 83 | static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 84 | int addr, int reg, u16 *val) |
| 85 | { |
| 86 | int ret; |
| 87 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 88 | ret = mdiobus_read_nested(chip->bus, addr, reg); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 89 | if (ret < 0) |
| 90 | return ret; |
| 91 | |
| 92 | *val = ret & 0xffff; |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 97 | static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 98 | int addr, int reg, u16 val) |
| 99 | { |
| 100 | int ret; |
| 101 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 102 | ret = mdiobus_write_nested(chip->bus, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 103 | if (ret < 0) |
| 104 | return ret; |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
Vivien Didelot | c08026a | 2016-09-29 12:21:59 -0400 | [diff] [blame] | 109 | static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = { |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 110 | .read = mv88e6xxx_smi_single_chip_read, |
| 111 | .write = mv88e6xxx_smi_single_chip_write, |
| 112 | }; |
| 113 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 114 | static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 115 | { |
| 116 | int ret; |
| 117 | int i; |
| 118 | |
| 119 | for (i = 0; i < 16; i++) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 120 | ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 121 | if (ret < 0) |
| 122 | return ret; |
| 123 | |
Andrew Lunn | cca8b13 | 2015-04-02 04:06:39 +0200 | [diff] [blame] | 124 | if ((ret & SMI_CMD_BUSY) == 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | return -ETIMEDOUT; |
| 129 | } |
| 130 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 131 | static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 132 | int addr, int reg, u16 *val) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 133 | { |
| 134 | int ret; |
| 135 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 136 | /* Wait for the bus to become free. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 137 | ret = mv88e6xxx_smi_multi_chip_wait(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 138 | if (ret < 0) |
| 139 | return ret; |
| 140 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 141 | /* Transmit the read command. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 142 | ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD, |
Neil Armstrong | 6e899e6 | 2015-10-22 10:37:53 +0200 | [diff] [blame] | 143 | SMI_CMD_OP_22_READ | (addr << 5) | reg); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 144 | if (ret < 0) |
| 145 | return ret; |
| 146 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 147 | /* Wait for the read command to complete. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 148 | ret = mv88e6xxx_smi_multi_chip_wait(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 149 | if (ret < 0) |
| 150 | return ret; |
| 151 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 152 | /* Read the data. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 153 | ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 154 | if (ret < 0) |
| 155 | return ret; |
| 156 | |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 157 | *val = ret & 0xffff; |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 162 | static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 163 | int addr, int reg, u16 val) |
| 164 | { |
| 165 | int ret; |
| 166 | |
| 167 | /* Wait for the bus to become free. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 168 | ret = mv88e6xxx_smi_multi_chip_wait(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 169 | if (ret < 0) |
| 170 | return ret; |
| 171 | |
| 172 | /* Transmit the data to write. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 173 | ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 174 | if (ret < 0) |
| 175 | return ret; |
| 176 | |
| 177 | /* Transmit the write command. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 178 | ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD, |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 179 | SMI_CMD_OP_22_WRITE | (addr << 5) | reg); |
| 180 | if (ret < 0) |
| 181 | return ret; |
| 182 | |
| 183 | /* Wait for the write command to complete. */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 184 | ret = mv88e6xxx_smi_multi_chip_wait(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 185 | if (ret < 0) |
| 186 | return ret; |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
Vivien Didelot | c08026a | 2016-09-29 12:21:59 -0400 | [diff] [blame] | 191 | static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = { |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 192 | .read = mv88e6xxx_smi_multi_chip_read, |
| 193 | .write = mv88e6xxx_smi_multi_chip_write, |
| 194 | }; |
| 195 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 196 | int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 197 | { |
| 198 | int err; |
| 199 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 200 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 201 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 202 | err = mv88e6xxx_smi_read(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 203 | if (err) |
| 204 | return err; |
| 205 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 206 | dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 207 | addr, reg, *val); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 212 | int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val) |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 213 | { |
| 214 | int err; |
| 215 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 216 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 217 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 218 | err = mv88e6xxx_smi_write(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 219 | if (err) |
| 220 | return err; |
| 221 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 222 | dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 223 | addr, reg, val); |
| 224 | |
| 225 | return 0; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 226 | } |
| 227 | |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 228 | struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip) |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 229 | { |
| 230 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 231 | |
| 232 | mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, |
| 233 | list); |
| 234 | if (!mdio_bus) |
| 235 | return NULL; |
| 236 | |
| 237 | return mdio_bus->bus; |
| 238 | } |
| 239 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 240 | static void mv88e6xxx_g1_irq_mask(struct irq_data *d) |
| 241 | { |
| 242 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 243 | unsigned int n = d->hwirq; |
| 244 | |
| 245 | chip->g1_irq.masked |= (1 << n); |
| 246 | } |
| 247 | |
| 248 | static void mv88e6xxx_g1_irq_unmask(struct irq_data *d) |
| 249 | { |
| 250 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 251 | unsigned int n = d->hwirq; |
| 252 | |
| 253 | chip->g1_irq.masked &= ~(1 << n); |
| 254 | } |
| 255 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 256 | static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 257 | { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 258 | unsigned int nhandled = 0; |
| 259 | unsigned int sub_irq; |
| 260 | unsigned int n; |
| 261 | u16 reg; |
| 262 | int err; |
| 263 | |
| 264 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 265 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 266 | mutex_unlock(&chip->reg_lock); |
| 267 | |
| 268 | if (err) |
| 269 | goto out; |
| 270 | |
| 271 | for (n = 0; n < chip->g1_irq.nirqs; ++n) { |
| 272 | if (reg & (1 << n)) { |
| 273 | sub_irq = irq_find_mapping(chip->g1_irq.domain, n); |
| 274 | handle_nested_irq(sub_irq); |
| 275 | ++nhandled; |
| 276 | } |
| 277 | } |
| 278 | out: |
| 279 | return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); |
| 280 | } |
| 281 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 282 | static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id) |
| 283 | { |
| 284 | struct mv88e6xxx_chip *chip = dev_id; |
| 285 | |
| 286 | return mv88e6xxx_g1_irq_thread_work(chip); |
| 287 | } |
| 288 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 289 | static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d) |
| 290 | { |
| 291 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 292 | |
| 293 | mutex_lock(&chip->reg_lock); |
| 294 | } |
| 295 | |
| 296 | static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d) |
| 297 | { |
| 298 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 299 | u16 mask = GENMASK(chip->g1_irq.nirqs, 0); |
| 300 | u16 reg; |
| 301 | int err; |
| 302 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 303 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 304 | if (err) |
| 305 | goto out; |
| 306 | |
| 307 | reg &= ~mask; |
| 308 | reg |= (~chip->g1_irq.masked & mask); |
| 309 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 310 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 311 | if (err) |
| 312 | goto out; |
| 313 | |
| 314 | out: |
| 315 | mutex_unlock(&chip->reg_lock); |
| 316 | } |
| 317 | |
Bhumika Goyal | 6eb15e2 | 2017-08-19 16:25:52 +0530 | [diff] [blame] | 318 | static const struct irq_chip mv88e6xxx_g1_irq_chip = { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 319 | .name = "mv88e6xxx-g1", |
| 320 | .irq_mask = mv88e6xxx_g1_irq_mask, |
| 321 | .irq_unmask = mv88e6xxx_g1_irq_unmask, |
| 322 | .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock, |
| 323 | .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock, |
| 324 | }; |
| 325 | |
| 326 | static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d, |
| 327 | unsigned int irq, |
| 328 | irq_hw_number_t hwirq) |
| 329 | { |
| 330 | struct mv88e6xxx_chip *chip = d->host_data; |
| 331 | |
| 332 | irq_set_chip_data(irq, d->host_data); |
| 333 | irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq); |
| 334 | irq_set_noprobe(irq); |
| 335 | |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = { |
| 340 | .map = mv88e6xxx_g1_irq_domain_map, |
| 341 | .xlate = irq_domain_xlate_twocell, |
| 342 | }; |
| 343 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 344 | static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 345 | { |
| 346 | int irq, virq; |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 347 | u16 mask; |
| 348 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 349 | mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 350 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 351 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 352 | |
Andreas Färber | 5edef2f | 2016-11-27 23:26:28 +0100 | [diff] [blame] | 353 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) { |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 354 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 355 | irq_dispose_mapping(virq); |
| 356 | } |
| 357 | |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 358 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 359 | } |
| 360 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 361 | static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) |
| 362 | { |
Andrew Lunn | b19e5c1 | 2018-03-08 21:21:36 +0100 | [diff] [blame] | 363 | mv88e6xxx_g1_irq_free_common(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 364 | |
| 365 | free_irq(chip->irq, chip); |
| 366 | } |
| 367 | |
| 368 | static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 369 | { |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 370 | int err, irq, virq; |
| 371 | u16 reg, mask; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 372 | |
| 373 | chip->g1_irq.nirqs = chip->info->g1_irqs; |
| 374 | chip->g1_irq.domain = irq_domain_add_simple( |
| 375 | NULL, chip->g1_irq.nirqs, 0, |
| 376 | &mv88e6xxx_g1_irq_domain_ops, chip); |
| 377 | if (!chip->g1_irq.domain) |
| 378 | return -ENOMEM; |
| 379 | |
| 380 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) |
| 381 | irq_create_mapping(chip->g1_irq.domain, irq); |
| 382 | |
| 383 | chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; |
| 384 | chip->g1_irq.masked = ~0; |
| 385 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 386 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 387 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 388 | goto out_mapping; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 389 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 390 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 391 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 392 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 393 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 394 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 395 | |
| 396 | /* Reading the interrupt status clears (most of) them */ |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 397 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 398 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 399 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 400 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 401 | return 0; |
| 402 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 403 | out_disable: |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 404 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 405 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 406 | |
| 407 | out_mapping: |
| 408 | for (irq = 0; irq < 16; irq++) { |
| 409 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
| 410 | irq_dispose_mapping(virq); |
| 411 | } |
| 412 | |
| 413 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 414 | |
| 415 | return err; |
| 416 | } |
| 417 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 418 | static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) |
| 419 | { |
| 420 | int err; |
| 421 | |
| 422 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 423 | if (err) |
| 424 | return err; |
| 425 | |
| 426 | err = request_threaded_irq(chip->irq, NULL, |
| 427 | mv88e6xxx_g1_irq_thread_fn, |
Andrew Lunn | 422a9fd6 | 2018-03-25 23:43:14 +0200 | [diff] [blame] | 428 | IRQF_ONESHOT, |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 429 | dev_name(chip->dev), chip); |
| 430 | if (err) |
| 431 | mv88e6xxx_g1_irq_free_common(chip); |
| 432 | |
| 433 | return err; |
| 434 | } |
| 435 | |
| 436 | static void mv88e6xxx_irq_poll(struct kthread_work *work) |
| 437 | { |
| 438 | struct mv88e6xxx_chip *chip = container_of(work, |
| 439 | struct mv88e6xxx_chip, |
| 440 | irq_poll_work.work); |
| 441 | mv88e6xxx_g1_irq_thread_work(chip); |
| 442 | |
| 443 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 444 | msecs_to_jiffies(100)); |
| 445 | } |
| 446 | |
| 447 | static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip) |
| 448 | { |
| 449 | int err; |
| 450 | |
| 451 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 452 | if (err) |
| 453 | return err; |
| 454 | |
| 455 | kthread_init_delayed_work(&chip->irq_poll_work, |
| 456 | mv88e6xxx_irq_poll); |
| 457 | |
| 458 | chip->kworker = kthread_create_worker(0, dev_name(chip->dev)); |
| 459 | if (IS_ERR(chip->kworker)) |
| 460 | return PTR_ERR(chip->kworker); |
| 461 | |
| 462 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 463 | msecs_to_jiffies(100)); |
| 464 | |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip) |
| 469 | { |
Andrew Lunn | 71f74ae | 2018-03-25 23:43:15 +0200 | [diff] [blame] | 470 | mv88e6xxx_g1_irq_free_common(chip); |
| 471 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 472 | kthread_cancel_delayed_work_sync(&chip->irq_poll_work); |
| 473 | kthread_destroy_worker(chip->kworker); |
| 474 | } |
| 475 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 476 | int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask) |
Vivien Didelot | 2d79af6 | 2016-08-15 17:18:57 -0400 | [diff] [blame] | 477 | { |
Andrew Lunn | 6441e669 | 2016-08-19 00:01:55 +0200 | [diff] [blame] | 478 | int i; |
Vivien Didelot | 2d79af6 | 2016-08-15 17:18:57 -0400 | [diff] [blame] | 479 | |
Andrew Lunn | 6441e669 | 2016-08-19 00:01:55 +0200 | [diff] [blame] | 480 | for (i = 0; i < 16; i++) { |
Vivien Didelot | 2d79af6 | 2016-08-15 17:18:57 -0400 | [diff] [blame] | 481 | u16 val; |
| 482 | int err; |
| 483 | |
| 484 | err = mv88e6xxx_read(chip, addr, reg, &val); |
| 485 | if (err) |
| 486 | return err; |
| 487 | |
| 488 | if (!(val & mask)) |
| 489 | return 0; |
| 490 | |
| 491 | usleep_range(1000, 2000); |
| 492 | } |
| 493 | |
Andrew Lunn | 3085355 | 2016-08-19 00:01:57 +0200 | [diff] [blame] | 494 | dev_err(chip->dev, "Timeout while waiting for switch\n"); |
Vivien Didelot | 2d79af6 | 2016-08-15 17:18:57 -0400 | [diff] [blame] | 495 | return -ETIMEDOUT; |
| 496 | } |
| 497 | |
Vivien Didelot | f22ab64 | 2016-07-18 20:45:31 -0400 | [diff] [blame] | 498 | /* Indirect write to single pointer-data register with an Update bit */ |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 499 | int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update) |
Vivien Didelot | f22ab64 | 2016-07-18 20:45:31 -0400 | [diff] [blame] | 500 | { |
| 501 | u16 val; |
Andrew Lunn | 0f02b4f | 2016-08-19 00:01:56 +0200 | [diff] [blame] | 502 | int err; |
Vivien Didelot | f22ab64 | 2016-07-18 20:45:31 -0400 | [diff] [blame] | 503 | |
| 504 | /* Wait until the previous operation is completed */ |
Andrew Lunn | 0f02b4f | 2016-08-19 00:01:56 +0200 | [diff] [blame] | 505 | err = mv88e6xxx_wait(chip, addr, reg, BIT(15)); |
| 506 | if (err) |
| 507 | return err; |
Vivien Didelot | f22ab64 | 2016-07-18 20:45:31 -0400 | [diff] [blame] | 508 | |
| 509 | /* Set the Update bit to trigger a write operation */ |
| 510 | val = BIT(15) | update; |
| 511 | |
| 512 | return mv88e6xxx_write(chip, addr, reg, val); |
| 513 | } |
| 514 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 515 | static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, |
| 516 | int link, int speed, int duplex, |
| 517 | phy_interface_t mode) |
| 518 | { |
| 519 | int err; |
| 520 | |
| 521 | if (!chip->info->ops->port_set_link) |
| 522 | return 0; |
| 523 | |
| 524 | /* Port's MAC control must not be changed unless the link is down */ |
| 525 | err = chip->info->ops->port_set_link(chip, port, 0); |
| 526 | if (err) |
| 527 | return err; |
| 528 | |
| 529 | if (chip->info->ops->port_set_speed) { |
| 530 | err = chip->info->ops->port_set_speed(chip, port, speed); |
| 531 | if (err && err != -EOPNOTSUPP) |
| 532 | goto restore_link; |
| 533 | } |
| 534 | |
| 535 | if (chip->info->ops->port_set_duplex) { |
| 536 | err = chip->info->ops->port_set_duplex(chip, port, duplex); |
| 537 | if (err && err != -EOPNOTSUPP) |
| 538 | goto restore_link; |
| 539 | } |
| 540 | |
| 541 | if (chip->info->ops->port_set_rgmii_delay) { |
| 542 | err = chip->info->ops->port_set_rgmii_delay(chip, port, mode); |
| 543 | if (err && err != -EOPNOTSUPP) |
| 544 | goto restore_link; |
| 545 | } |
| 546 | |
Andrew Lunn | f39908d | 2017-02-04 20:02:50 +0100 | [diff] [blame] | 547 | if (chip->info->ops->port_set_cmode) { |
| 548 | err = chip->info->ops->port_set_cmode(chip, port, mode); |
| 549 | if (err && err != -EOPNOTSUPP) |
| 550 | goto restore_link; |
| 551 | } |
| 552 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 553 | err = 0; |
| 554 | restore_link: |
| 555 | if (chip->info->ops->port_set_link(chip, port, link)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 556 | dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 557 | |
| 558 | return err; |
| 559 | } |
| 560 | |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 561 | /* We expect the switch to perform auto negotiation if there is a real |
| 562 | * phy. However, in the case of a fixed link phy, we force the port |
| 563 | * settings from the fixed link settings. |
| 564 | */ |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 565 | static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port, |
| 566 | struct phy_device *phydev) |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 567 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 568 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 569 | int err; |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 570 | |
| 571 | if (!phy_is_pseudo_fixed_link(phydev)) |
| 572 | return; |
| 573 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 574 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 575 | err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed, |
| 576 | phydev->duplex, phydev->interface); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 577 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 578 | |
| 579 | if (err && err != -EOPNOTSUPP) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 580 | dev_err(ds->dev, "p%d: failed to configure MAC\n", port); |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 581 | } |
| 582 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 583 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 584 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 585 | if (!chip->info->ops->stats_snapshot) |
| 586 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 587 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 588 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 591 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 592 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 593 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 594 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 595 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 596 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 597 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 598 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 599 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 600 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 601 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 602 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 603 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 604 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 605 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 606 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 607 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 608 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 609 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 610 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 611 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 612 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 613 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 614 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 615 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 616 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 617 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 618 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 619 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 620 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 621 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 622 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 623 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 624 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 625 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 626 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 627 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 628 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 629 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 630 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 631 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 632 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 633 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 634 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 635 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 636 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 637 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 638 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 639 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 640 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 641 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 642 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 643 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 644 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 645 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 646 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 647 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 648 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 649 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 650 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 651 | }; |
| 652 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 653 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 654 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 655 | int port, u16 bank1_select, |
| 656 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 657 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 658 | u32 low; |
| 659 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 660 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 661 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 662 | u64 value; |
| 663 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 664 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 665 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 666 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 667 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame^] | 668 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 669 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 670 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 671 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 672 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 673 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame^] | 674 | return U64_MAX; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 675 | high = reg; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 676 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 677 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 678 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 679 | reg = bank1_select; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 680 | /* fall through */ |
| 681 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 682 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 683 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 684 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 685 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 686 | break; |
| 687 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame^] | 688 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 689 | } |
| 690 | value = (((u64)high) << 16) | low; |
| 691 | return value; |
| 692 | } |
| 693 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 694 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 695 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 696 | { |
| 697 | struct mv88e6xxx_hw_stat *stat; |
| 698 | int i, j; |
| 699 | |
| 700 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 701 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 702 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 703 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 704 | ETH_GSTRING_LEN); |
| 705 | j++; |
| 706 | } |
| 707 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 708 | |
| 709 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 710 | } |
| 711 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 712 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 713 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 714 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 715 | return mv88e6xxx_stats_get_strings(chip, data, |
| 716 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 717 | } |
| 718 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 719 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 720 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 721 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 722 | return mv88e6xxx_stats_get_strings(chip, data, |
| 723 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 724 | } |
| 725 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 726 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 727 | "atu_member_violation", |
| 728 | "atu_miss_violation", |
| 729 | "atu_full_violation", |
| 730 | "vtu_member_violation", |
| 731 | "vtu_miss_violation", |
| 732 | }; |
| 733 | |
| 734 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 735 | { |
| 736 | unsigned int i; |
| 737 | |
| 738 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 739 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 740 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 741 | ETH_GSTRING_LEN); |
| 742 | } |
| 743 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 744 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 745 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 746 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 747 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 748 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 749 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 750 | if (stringset != ETH_SS_STATS) |
| 751 | return; |
| 752 | |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 753 | mutex_lock(&chip->reg_lock); |
| 754 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 755 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 756 | count = chip->info->ops->stats_get_strings(chip, data); |
| 757 | |
| 758 | if (chip->info->ops->serdes_get_strings) { |
| 759 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 760 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 761 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 762 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 763 | data += count * ETH_GSTRING_LEN; |
| 764 | mv88e6xxx_atu_vtu_get_strings(data); |
| 765 | |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 766 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 770 | int types) |
| 771 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 772 | struct mv88e6xxx_hw_stat *stat; |
| 773 | int i, j; |
| 774 | |
| 775 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 776 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 777 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 778 | j++; |
| 779 | } |
| 780 | return j; |
| 781 | } |
| 782 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 783 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 784 | { |
| 785 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 786 | STATS_TYPE_PORT); |
| 787 | } |
| 788 | |
| 789 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 790 | { |
| 791 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 792 | STATS_TYPE_BANK1); |
| 793 | } |
| 794 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 795 | static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 796 | { |
| 797 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 798 | int serdes_count = 0; |
| 799 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 800 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 801 | if (sset != ETH_SS_STATS) |
| 802 | return 0; |
| 803 | |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 804 | mutex_lock(&chip->reg_lock); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 805 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 806 | count = chip->info->ops->stats_get_sset_count(chip); |
| 807 | if (count < 0) |
| 808 | goto out; |
| 809 | |
| 810 | if (chip->info->ops->serdes_get_sset_count) |
| 811 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 812 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 813 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 814 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 815 | goto out; |
| 816 | } |
| 817 | count += serdes_count; |
| 818 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 819 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 820 | out: |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 821 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 822 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 823 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 824 | } |
| 825 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 826 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 827 | uint64_t *data, int types, |
| 828 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 829 | { |
| 830 | struct mv88e6xxx_hw_stat *stat; |
| 831 | int i, j; |
| 832 | |
| 833 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 834 | stat = &mv88e6xxx_hw_stats[i]; |
| 835 | if (stat->type & types) { |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 836 | mutex_lock(&chip->reg_lock); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 837 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 838 | bank1_select, |
| 839 | histogram); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 840 | mutex_unlock(&chip->reg_lock); |
| 841 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 842 | j++; |
| 843 | } |
| 844 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 845 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 846 | } |
| 847 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 848 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 849 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 850 | { |
| 851 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 852 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 853 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 854 | } |
| 855 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 856 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 857 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 858 | { |
| 859 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 860 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 861 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 862 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 863 | } |
| 864 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 865 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 866 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 867 | { |
| 868 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 869 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 870 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 871 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 872 | } |
| 873 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 874 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 875 | uint64_t *data) |
| 876 | { |
| 877 | *data++ = chip->ports[port].atu_member_violation; |
| 878 | *data++ = chip->ports[port].atu_miss_violation; |
| 879 | *data++ = chip->ports[port].atu_full_violation; |
| 880 | *data++ = chip->ports[port].vtu_member_violation; |
| 881 | *data++ = chip->ports[port].vtu_miss_violation; |
| 882 | } |
| 883 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 884 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 885 | uint64_t *data) |
| 886 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 887 | int count = 0; |
| 888 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 889 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 890 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 891 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 892 | mutex_lock(&chip->reg_lock); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 893 | if (chip->info->ops->serdes_get_stats) { |
| 894 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 895 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 896 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 897 | data += count; |
| 898 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
| 899 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 900 | } |
| 901 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 902 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 903 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 904 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 905 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 906 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 907 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 908 | mutex_lock(&chip->reg_lock); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 909 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 910 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 911 | mutex_unlock(&chip->reg_lock); |
| 912 | |
| 913 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 914 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 915 | |
| 916 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 917 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 918 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 919 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 920 | static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip) |
| 921 | { |
| 922 | if (chip->info->ops->stats_set_histogram) |
| 923 | return chip->info->ops->stats_set_histogram(chip); |
| 924 | |
| 925 | return 0; |
| 926 | } |
| 927 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 928 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 929 | { |
| 930 | return 32 * sizeof(u16); |
| 931 | } |
| 932 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 933 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 934 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 935 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 936 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 937 | int err; |
| 938 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 939 | u16 *p = _p; |
| 940 | int i; |
| 941 | |
| 942 | regs->version = 0; |
| 943 | |
| 944 | memset(p, 0xff, 32 * sizeof(u16)); |
| 945 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 946 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 947 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 948 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 949 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 950 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 951 | if (!err) |
| 952 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 953 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 954 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 955 | mutex_unlock(&chip->reg_lock); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 956 | } |
| 957 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 958 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 959 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 960 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 961 | /* Nothing to do on the port's MAC */ |
| 962 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 963 | } |
| 964 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 965 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 966 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 967 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 968 | /* Nothing to do on the port's MAC */ |
| 969 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 970 | } |
| 971 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 972 | static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 973 | { |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 974 | struct dsa_switch *ds = NULL; |
| 975 | struct net_device *br; |
| 976 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 977 | int i; |
| 978 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 979 | if (dev < DSA_MAX_SWITCHES) |
| 980 | ds = chip->ds->dst->ds[dev]; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 981 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 982 | /* Prevent frames from unknown switch or port */ |
| 983 | if (!ds || port >= ds->num_ports) |
| 984 | return 0; |
| 985 | |
| 986 | /* Frames from DSA links and CPU ports can egress any local port */ |
| 987 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 988 | return mv88e6xxx_port_mask(chip); |
| 989 | |
| 990 | br = ds->ports[port].bridge_dev; |
| 991 | pvlan = 0; |
| 992 | |
| 993 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 994 | * as well as any local member of their bridge group. |
| 995 | */ |
| 996 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 997 | if (dsa_is_cpu_port(chip->ds, i) || |
| 998 | dsa_is_dsa_port(chip->ds, i) || |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 999 | (br && dsa_to_port(chip->ds, i)->bridge_dev == br)) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1000 | pvlan |= BIT(i); |
| 1001 | |
| 1002 | return pvlan; |
| 1003 | } |
| 1004 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1005 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1006 | { |
| 1007 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1008 | |
| 1009 | /* prevent frames from going back out of the port they came in on */ |
| 1010 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1011 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1012 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1013 | } |
| 1014 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1015 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1016 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1017 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1018 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1019 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1020 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1021 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1022 | err = mv88e6xxx_port_set_state(chip, port, state); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1023 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1024 | |
| 1025 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1026 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1029 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1030 | { |
| 1031 | if (chip->info->ops->pot_clear) |
| 1032 | return chip->info->ops->pot_clear(chip); |
| 1033 | |
| 1034 | return 0; |
| 1035 | } |
| 1036 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1037 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1038 | { |
| 1039 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1040 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1041 | |
| 1042 | return 0; |
| 1043 | } |
| 1044 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1045 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1046 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1047 | int err; |
| 1048 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1049 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1050 | if (err) |
| 1051 | return err; |
| 1052 | |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1053 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1054 | if (err) |
| 1055 | return err; |
| 1056 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1057 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1058 | } |
| 1059 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1060 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1061 | { |
| 1062 | int port; |
| 1063 | int err; |
| 1064 | |
| 1065 | if (!chip->info->ops->irl_init_all) |
| 1066 | return 0; |
| 1067 | |
| 1068 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1069 | /* Disable ingress rate limiting by resetting all per port |
| 1070 | * ingress rate limit resources to their initial state. |
| 1071 | */ |
| 1072 | err = chip->info->ops->irl_init_all(chip, port); |
| 1073 | if (err) |
| 1074 | return err; |
| 1075 | } |
| 1076 | |
| 1077 | return 0; |
| 1078 | } |
| 1079 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1080 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1081 | { |
| 1082 | if (chip->info->ops->set_switch_mac) { |
| 1083 | u8 addr[ETH_ALEN]; |
| 1084 | |
| 1085 | eth_random_addr(addr); |
| 1086 | |
| 1087 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1088 | } |
| 1089 | |
| 1090 | return 0; |
| 1091 | } |
| 1092 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1093 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1094 | { |
| 1095 | u16 pvlan = 0; |
| 1096 | |
| 1097 | if (!mv88e6xxx_has_pvt(chip)) |
| 1098 | return -EOPNOTSUPP; |
| 1099 | |
| 1100 | /* Skip the local source device, which uses in-chip port VLAN */ |
| 1101 | if (dev != chip->ds->index) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1102 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1103 | |
| 1104 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1105 | } |
| 1106 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1107 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1108 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1109 | int dev, port; |
| 1110 | int err; |
| 1111 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1112 | if (!mv88e6xxx_has_pvt(chip)) |
| 1113 | return 0; |
| 1114 | |
| 1115 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1116 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1117 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1118 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1119 | if (err) |
| 1120 | return err; |
| 1121 | |
| 1122 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1123 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1124 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1125 | if (err) |
| 1126 | return err; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1131 | } |
| 1132 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1133 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1134 | { |
| 1135 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1136 | int err; |
| 1137 | |
| 1138 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1139 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1140 | mutex_unlock(&chip->reg_lock); |
| 1141 | |
| 1142 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1143 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1144 | } |
| 1145 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1146 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1147 | { |
| 1148 | if (!chip->info->max_vid) |
| 1149 | return 0; |
| 1150 | |
| 1151 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1152 | } |
| 1153 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1154 | static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip, |
| 1155 | struct mv88e6xxx_vtu_entry *entry) |
| 1156 | { |
| 1157 | if (!chip->info->ops->vtu_getnext) |
| 1158 | return -EOPNOTSUPP; |
| 1159 | |
| 1160 | return chip->info->ops->vtu_getnext(chip, entry); |
| 1161 | } |
| 1162 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1163 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1164 | struct mv88e6xxx_vtu_entry *entry) |
| 1165 | { |
| 1166 | if (!chip->info->ops->vtu_loadpurge) |
| 1167 | return -EOPNOTSUPP; |
| 1168 | |
| 1169 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1170 | } |
| 1171 | |
Vivien Didelot | d7f435f | 2017-03-11 16:12:56 -0500 | [diff] [blame] | 1172 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1173 | { |
| 1174 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
Vivien Didelot | 3afb4bd | 2017-05-01 14:05:16 -0400 | [diff] [blame] | 1175 | struct mv88e6xxx_vtu_entry vlan = { |
| 1176 | .vid = chip->info->max_vid, |
| 1177 | }; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1178 | int i, err; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1179 | |
| 1180 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1181 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1182 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1183 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 1184 | err = mv88e6xxx_port_get_fid(chip, i, fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1185 | if (err) |
| 1186 | return err; |
| 1187 | |
| 1188 | set_bit(*fid, fid_bitmap); |
| 1189 | } |
| 1190 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1191 | /* Set every FID bit used by the VLAN entries */ |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1192 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1193 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1194 | if (err) |
| 1195 | return err; |
| 1196 | |
| 1197 | if (!vlan.valid) |
| 1198 | break; |
| 1199 | |
| 1200 | set_bit(vlan.fid, fid_bitmap); |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1201 | } while (vlan.vid < chip->info->max_vid); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1202 | |
| 1203 | /* The reset value 0x000 is used to indicate that multiple address |
| 1204 | * databases are not needed. Return the next positive available. |
| 1205 | */ |
| 1206 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1207 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1208 | return -ENOSPC; |
| 1209 | |
| 1210 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1211 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1212 | } |
| 1213 | |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1214 | static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, |
| 1215 | struct mv88e6xxx_vtu_entry *entry, bool new) |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1216 | { |
| 1217 | int err; |
| 1218 | |
| 1219 | if (!vid) |
| 1220 | return -EINVAL; |
| 1221 | |
Vivien Didelot | 3afb4bd | 2017-05-01 14:05:16 -0400 | [diff] [blame] | 1222 | entry->vid = vid - 1; |
| 1223 | entry->valid = false; |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1224 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1225 | err = mv88e6xxx_vtu_getnext(chip, entry); |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1226 | if (err) |
| 1227 | return err; |
| 1228 | |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1229 | if (entry->vid == vid && entry->valid) |
| 1230 | return 0; |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1231 | |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1232 | if (new) { |
| 1233 | int i; |
| 1234 | |
| 1235 | /* Initialize a fresh VLAN entry */ |
| 1236 | memset(entry, 0, sizeof(*entry)); |
| 1237 | entry->valid = true; |
| 1238 | entry->vid = vid; |
| 1239 | |
Vivien Didelot | 553a768 | 2017-06-07 18:12:16 -0400 | [diff] [blame] | 1240 | /* Exclude all ports */ |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1241 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
Vivien Didelot | 553a768 | 2017-06-07 18:12:16 -0400 | [diff] [blame] | 1242 | entry->member[i] = |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1243 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1244 | |
| 1245 | return mv88e6xxx_atu_new(chip, &entry->fid); |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1246 | } |
| 1247 | |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1248 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
| 1249 | return -EOPNOTSUPP; |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1250 | } |
| 1251 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1252 | static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, |
| 1253 | u16 vid_begin, u16 vid_end) |
| 1254 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1255 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 3afb4bd | 2017-05-01 14:05:16 -0400 | [diff] [blame] | 1256 | struct mv88e6xxx_vtu_entry vlan = { |
| 1257 | .vid = vid_begin - 1, |
| 1258 | }; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1259 | int i, err; |
| 1260 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1261 | /* DSA and CPU ports have to be members of multiple vlans */ |
| 1262 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 1263 | return 0; |
| 1264 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1265 | if (!vid_begin) |
| 1266 | return -EOPNOTSUPP; |
| 1267 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1268 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1269 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1270 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1271 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1272 | if (err) |
| 1273 | goto unlock; |
| 1274 | |
| 1275 | if (!vlan.valid) |
| 1276 | break; |
| 1277 | |
| 1278 | if (vlan.vid > vid_end) |
| 1279 | break; |
| 1280 | |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1281 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1282 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) |
| 1283 | continue; |
| 1284 | |
Andrew Lunn | cd88646 | 2017-11-09 22:29:53 +0100 | [diff] [blame] | 1285 | if (!ds->ports[i].slave) |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1286 | continue; |
| 1287 | |
Vivien Didelot | bd00e05 | 2017-05-01 14:05:11 -0400 | [diff] [blame] | 1288 | if (vlan.member[i] == |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1289 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1290 | continue; |
| 1291 | |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1292 | if (dsa_to_port(ds, i)->bridge_dev == |
Vivien Didelot | fae8a25 | 2017-01-27 15:29:42 -0500 | [diff] [blame] | 1293 | ds->ports[port].bridge_dev) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1294 | break; /* same bridge, check next VLAN */ |
| 1295 | |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1296 | if (!dsa_to_port(ds, i)->bridge_dev) |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1297 | continue; |
| 1298 | |
Andrew Lunn | 743fcc2 | 2017-11-09 22:29:54 +0100 | [diff] [blame] | 1299 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
| 1300 | port, vlan.vid, i, |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1301 | netdev_name(dsa_to_port(ds, i)->bridge_dev)); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1302 | err = -EOPNOTSUPP; |
| 1303 | goto unlock; |
| 1304 | } |
| 1305 | } while (vlan.vid < vid_end); |
| 1306 | |
| 1307 | unlock: |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1308 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1309 | |
| 1310 | return err; |
| 1311 | } |
| 1312 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1313 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
| 1314 | bool vlan_filtering) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1315 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1316 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1317 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1318 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1319 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1320 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1321 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1322 | return -EOPNOTSUPP; |
| 1323 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1324 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1325 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1326 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1327 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1328 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1329 | } |
| 1330 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1331 | static int |
| 1332 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1333 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1334 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1335 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1336 | int err; |
| 1337 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1338 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1339 | return -EOPNOTSUPP; |
| 1340 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1341 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1342 | * members, do not support it (yet) and fallback to software VLAN. |
| 1343 | */ |
| 1344 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin, |
| 1345 | vlan->vid_end); |
| 1346 | if (err) |
| 1347 | return err; |
| 1348 | |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1349 | /* We don't need any dynamic resource from the kernel (yet), |
| 1350 | * so skip the prepare phase. |
| 1351 | */ |
| 1352 | return 0; |
| 1353 | } |
| 1354 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1355 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1356 | const unsigned char *addr, u16 vid, |
| 1357 | u8 state) |
| 1358 | { |
| 1359 | struct mv88e6xxx_vtu_entry vlan; |
| 1360 | struct mv88e6xxx_atu_entry entry; |
| 1361 | int err; |
| 1362 | |
| 1363 | /* Null VLAN ID corresponds to the port private database */ |
| 1364 | if (vid == 0) |
| 1365 | err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid); |
| 1366 | else |
| 1367 | err = mv88e6xxx_vtu_get(chip, vid, &vlan, false); |
| 1368 | if (err) |
| 1369 | return err; |
| 1370 | |
| 1371 | entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED; |
| 1372 | ether_addr_copy(entry.mac, addr); |
| 1373 | eth_addr_dec(entry.mac); |
| 1374 | |
| 1375 | err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry); |
| 1376 | if (err) |
| 1377 | return err; |
| 1378 | |
| 1379 | /* Initialize a fresh ATU entry if it isn't found */ |
| 1380 | if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED || |
| 1381 | !ether_addr_equal(entry.mac, addr)) { |
| 1382 | memset(&entry, 0, sizeof(entry)); |
| 1383 | ether_addr_copy(entry.mac, addr); |
| 1384 | } |
| 1385 | |
| 1386 | /* Purge the ATU entry only if no port is using it anymore */ |
| 1387 | if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) { |
| 1388 | entry.portvec &= ~BIT(port); |
| 1389 | if (!entry.portvec) |
| 1390 | entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED; |
| 1391 | } else { |
| 1392 | entry.portvec |= BIT(port); |
| 1393 | entry.state = state; |
| 1394 | } |
| 1395 | |
| 1396 | return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry); |
| 1397 | } |
| 1398 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1399 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 1400 | u16 vid) |
| 1401 | { |
| 1402 | const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 1403 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 1404 | |
| 1405 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 1406 | } |
| 1407 | |
| 1408 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 1409 | { |
| 1410 | int port; |
| 1411 | int err; |
| 1412 | |
| 1413 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1414 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 1415 | if (err) |
| 1416 | return err; |
| 1417 | } |
| 1418 | |
| 1419 | return 0; |
| 1420 | } |
| 1421 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1422 | static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1423 | u16 vid, u8 member) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1424 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1425 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1426 | int err; |
| 1427 | |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1428 | err = mv88e6xxx_vtu_get(chip, vid, &vlan, true); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1429 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1430 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1431 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1432 | vlan.member[port] = member; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1433 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1434 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 1435 | if (err) |
| 1436 | return err; |
| 1437 | |
| 1438 | return mv88e6xxx_broadcast_setup(chip, vid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1439 | } |
| 1440 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1441 | static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1442 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1443 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1444 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1445 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 1446 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1447 | u8 member; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1448 | u16 vid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1449 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1450 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1451 | return; |
| 1452 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1453 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1454 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1455 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1456 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1457 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1458 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1459 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1460 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1461 | |
Vivien Didelot | 4d5770b | 2016-04-06 11:55:05 -0400 | [diff] [blame] | 1462 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1463 | if (_mv88e6xxx_port_vlan_add(chip, port, vid, member)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1464 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 1465 | vid, untagged ? 'u' : 't'); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1466 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 1467 | if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1468 | dev_err(ds->dev, "p%d: failed to set PVID %d\n", port, |
| 1469 | vlan->vid_end); |
Vivien Didelot | 4d5770b | 2016-04-06 11:55:05 -0400 | [diff] [blame] | 1470 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1471 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1472 | } |
| 1473 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1474 | static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip, |
Andrew Lunn | 158bc06 | 2016-04-28 21:24:06 -0400 | [diff] [blame] | 1475 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1476 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1477 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1478 | int i, err; |
| 1479 | |
Vivien Didelot | 567aa59 | 2017-05-01 14:05:25 -0400 | [diff] [blame] | 1480 | err = mv88e6xxx_vtu_get(chip, vid, &vlan, false); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1481 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1482 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1483 | |
Vivien Didelot | 2fb5ef0 | 2016-02-26 13:16:01 -0500 | [diff] [blame] | 1484 | /* Tell switchdev if this VLAN is handled in software */ |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1485 | if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 1486 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1487 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1488 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1489 | |
| 1490 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 1491 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1492 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1493 | if (vlan.member[i] != |
| 1494 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 1495 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1496 | break; |
| 1497 | } |
| 1498 | } |
| 1499 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1500 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1501 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1502 | return err; |
| 1503 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1504 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1505 | } |
| 1506 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1507 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 1508 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1509 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1510 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1511 | u16 pvid, vid; |
| 1512 | int err = 0; |
| 1513 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1514 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1515 | return -EOPNOTSUPP; |
| 1516 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1517 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1518 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 1519 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1520 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1521 | goto unlock; |
| 1522 | |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1523 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1524 | err = _mv88e6xxx_port_vlan_del(chip, port, vid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1525 | if (err) |
| 1526 | goto unlock; |
| 1527 | |
| 1528 | if (vid == pvid) { |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 1529 | err = mv88e6xxx_port_set_pvid(chip, port, 0); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1530 | if (err) |
| 1531 | goto unlock; |
| 1532 | } |
| 1533 | } |
| 1534 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1535 | unlock: |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1536 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1537 | |
| 1538 | return err; |
| 1539 | } |
| 1540 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 1541 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 1542 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 1543 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1544 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 1545 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 1546 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1547 | mutex_lock(&chip->reg_lock); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 1548 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1549 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1550 | mutex_unlock(&chip->reg_lock); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 1551 | |
| 1552 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 1553 | } |
| 1554 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1555 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 1556 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 1557 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1558 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1559 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 1560 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1561 | mutex_lock(&chip->reg_lock); |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 1562 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 1563 | MV88E6XXX_G1_ATU_DATA_STATE_UNUSED); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1564 | mutex_unlock(&chip->reg_lock); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 1565 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1566 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 1567 | } |
| 1568 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1569 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 1570 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1571 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1572 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 1573 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1574 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1575 | int err; |
| 1576 | |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 1577 | addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 1578 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1579 | |
| 1580 | do { |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1581 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 1582 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1583 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1584 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1585 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1586 | |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 1587 | if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1588 | break; |
| 1589 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 1590 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1591 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1592 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1593 | if (!is_unicast_ether_addr(addr.mac)) |
| 1594 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1595 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1596 | is_static = (addr.state == |
| 1597 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 1598 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1599 | if (err) |
| 1600 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 1601 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 1602 | |
| 1603 | return err; |
| 1604 | } |
| 1605 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1606 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1607 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1608 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1609 | struct mv88e6xxx_vtu_entry vlan = { |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1610 | .vid = chip->info->max_vid, |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1611 | }; |
| 1612 | u16 fid; |
| 1613 | int err; |
| 1614 | |
| 1615 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1616 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 1617 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1618 | mutex_unlock(&chip->reg_lock); |
| 1619 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1620 | if (err) |
| 1621 | return err; |
| 1622 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1623 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1624 | if (err) |
| 1625 | return err; |
| 1626 | |
| 1627 | /* Dump VLANs' Filtering Information Databases */ |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1628 | do { |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1629 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1630 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1631 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1632 | if (err) |
| 1633 | return err; |
| 1634 | |
| 1635 | if (!vlan.valid) |
| 1636 | break; |
| 1637 | |
| 1638 | err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1639 | cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1640 | if (err) |
| 1641 | return err; |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1642 | } while (vlan.vid < chip->info->max_vid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 1643 | |
| 1644 | return err; |
| 1645 | } |
| 1646 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1647 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 1648 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 1649 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1650 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 1651 | |
Andrew Lunn | a61e540 | 2018-02-15 14:38:35 +0100 | [diff] [blame] | 1652 | return mv88e6xxx_port_db_dump(chip, port, cb, data); |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 1653 | } |
| 1654 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1655 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
| 1656 | struct net_device *br) |
| 1657 | { |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 1658 | struct dsa_switch *ds; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1659 | int port; |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 1660 | int dev; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1661 | int err; |
| 1662 | |
| 1663 | /* Remap the Port VLAN of each local bridge group member */ |
| 1664 | for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) { |
| 1665 | if (chip->ds->ports[port].bridge_dev == br) { |
| 1666 | err = mv88e6xxx_port_vlan_map(chip, port); |
| 1667 | if (err) |
| 1668 | return err; |
| 1669 | } |
| 1670 | } |
| 1671 | |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 1672 | if (!mv88e6xxx_has_pvt(chip)) |
| 1673 | return 0; |
| 1674 | |
| 1675 | /* Remap the Port VLAN of each cross-chip bridge group member */ |
| 1676 | for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) { |
| 1677 | ds = chip->ds->dst->ds[dev]; |
| 1678 | if (!ds) |
| 1679 | break; |
| 1680 | |
| 1681 | for (port = 0; port < ds->num_ports; ++port) { |
| 1682 | if (ds->ports[port].bridge_dev == br) { |
| 1683 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1684 | if (err) |
| 1685 | return err; |
| 1686 | } |
| 1687 | } |
| 1688 | } |
| 1689 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1690 | return 0; |
| 1691 | } |
| 1692 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1693 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vivien Didelot | fae8a25 | 2017-01-27 15:29:42 -0500 | [diff] [blame] | 1694 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 1695 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1696 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1697 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 1698 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1699 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1700 | err = mv88e6xxx_bridge_map(chip, br); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1701 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 1702 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 1703 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 1704 | } |
| 1705 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 1706 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
| 1707 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 1708 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1709 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 1710 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1711 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1712 | if (mv88e6xxx_bridge_map(chip, br) || |
| 1713 | mv88e6xxx_port_vlan_map(chip, port)) |
| 1714 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1715 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 1716 | } |
| 1717 | |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1718 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev, |
| 1719 | int port, struct net_device *br) |
| 1720 | { |
| 1721 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1722 | int err; |
| 1723 | |
| 1724 | if (!mv88e6xxx_has_pvt(chip)) |
| 1725 | return 0; |
| 1726 | |
| 1727 | mutex_lock(&chip->reg_lock); |
| 1728 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1729 | mutex_unlock(&chip->reg_lock); |
| 1730 | |
| 1731 | return err; |
| 1732 | } |
| 1733 | |
| 1734 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev, |
| 1735 | int port, struct net_device *br) |
| 1736 | { |
| 1737 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1738 | |
| 1739 | if (!mv88e6xxx_has_pvt(chip)) |
| 1740 | return; |
| 1741 | |
| 1742 | mutex_lock(&chip->reg_lock); |
| 1743 | if (mv88e6xxx_pvt_map(chip, dev, port)) |
| 1744 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
| 1745 | mutex_unlock(&chip->reg_lock); |
| 1746 | } |
| 1747 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 1748 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 1749 | { |
| 1750 | if (chip->info->ops->reset) |
| 1751 | return chip->info->ops->reset(chip); |
| 1752 | |
| 1753 | return 0; |
| 1754 | } |
| 1755 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 1756 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 1757 | { |
| 1758 | struct gpio_desc *gpiod = chip->reset; |
| 1759 | |
| 1760 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 1761 | if (gpiod) { |
| 1762 | gpiod_set_value_cansleep(gpiod, 1); |
| 1763 | usleep_range(10000, 20000); |
| 1764 | gpiod_set_value_cansleep(gpiod, 0); |
| 1765 | usleep_range(10000, 20000); |
| 1766 | } |
| 1767 | } |
| 1768 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 1769 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 1770 | { |
| 1771 | int i, err; |
| 1772 | |
| 1773 | /* Set all ports to the Disabled state */ |
| 1774 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1775 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 1776 | if (err) |
| 1777 | return err; |
| 1778 | } |
| 1779 | |
| 1780 | /* Wait for transmit queues to drain, |
| 1781 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 1782 | */ |
| 1783 | usleep_range(2000, 4000); |
| 1784 | |
| 1785 | return 0; |
| 1786 | } |
| 1787 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1788 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 1789 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 1790 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 1791 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 1792 | err = mv88e6xxx_disable_ports(chip); |
| 1793 | if (err) |
| 1794 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 1795 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 1796 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 1797 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 1798 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 1799 | } |
| 1800 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1801 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 1802 | enum mv88e6xxx_frame_mode frame, |
| 1803 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 1804 | { |
| 1805 | int err; |
| 1806 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1807 | if (!chip->info->ops->port_set_frame_mode) |
| 1808 | return -EOPNOTSUPP; |
| 1809 | |
| 1810 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 1811 | if (err) |
| 1812 | return err; |
| 1813 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1814 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 1815 | if (err) |
| 1816 | return err; |
| 1817 | |
| 1818 | if (chip->info->ops->port_set_ether_type) |
| 1819 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 1820 | |
| 1821 | return 0; |
| 1822 | } |
| 1823 | |
| 1824 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 1825 | { |
| 1826 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 1827 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 1828 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1829 | } |
| 1830 | |
| 1831 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 1832 | { |
| 1833 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 1834 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 1835 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1836 | } |
| 1837 | |
| 1838 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 1839 | { |
| 1840 | return mv88e6xxx_set_port_mode(chip, port, |
| 1841 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 1842 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 1843 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1844 | } |
| 1845 | |
| 1846 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 1847 | { |
| 1848 | if (dsa_is_dsa_port(chip->ds, port)) |
| 1849 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 1850 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 1851 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1852 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 1853 | |
| 1854 | /* Setup CPU port mode depending on its supported tag format */ |
| 1855 | if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA) |
| 1856 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 1857 | |
| 1858 | if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA) |
| 1859 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 1860 | |
| 1861 | return -EINVAL; |
| 1862 | } |
| 1863 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 1864 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 1865 | { |
| 1866 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 1867 | |
| 1868 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 1869 | } |
| 1870 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 1871 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 1872 | { |
Vivien Didelot | 3ee50cb | 2017-12-05 15:34:09 -0500 | [diff] [blame] | 1873 | struct dsa_switch *ds = chip->ds; |
| 1874 | bool flood; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 1875 | |
| 1876 | /* Upstream ports flood frames with unknown unicast or multicast DA */ |
Vivien Didelot | 3ee50cb | 2017-12-05 15:34:09 -0500 | [diff] [blame] | 1877 | flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port); |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 1878 | if (chip->info->ops->port_set_egress_floods) |
| 1879 | return chip->info->ops->port_set_egress_floods(chip, port, |
| 1880 | flood, flood); |
| 1881 | |
| 1882 | return 0; |
| 1883 | } |
| 1884 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 1885 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 1886 | bool on) |
| 1887 | { |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 1888 | if (chip->info->ops->serdes_power) |
| 1889 | return chip->info->ops->serdes_power(chip, port, on); |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 1890 | |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 1891 | return 0; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 1892 | } |
| 1893 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 1894 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 1895 | { |
| 1896 | struct dsa_switch *ds = chip->ds; |
| 1897 | int upstream_port; |
| 1898 | int err; |
| 1899 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 1900 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 1901 | if (chip->info->ops->port_set_upstream_port) { |
| 1902 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 1903 | upstream_port); |
| 1904 | if (err) |
| 1905 | return err; |
| 1906 | } |
| 1907 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 1908 | if (port == upstream_port) { |
| 1909 | if (chip->info->ops->set_cpu_port) { |
| 1910 | err = chip->info->ops->set_cpu_port(chip, |
| 1911 | upstream_port); |
| 1912 | if (err) |
| 1913 | return err; |
| 1914 | } |
| 1915 | |
| 1916 | if (chip->info->ops->set_egress_port) { |
| 1917 | err = chip->info->ops->set_egress_port(chip, |
| 1918 | upstream_port); |
| 1919 | if (err) |
| 1920 | return err; |
| 1921 | } |
| 1922 | } |
| 1923 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 1924 | return 0; |
| 1925 | } |
| 1926 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1927 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 1928 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1929 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1930 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 1931 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 1932 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 1933 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 1934 | * state to any particular values on physical ports, but force the CPU |
| 1935 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 1936 | */ |
| 1937 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 1938 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 1939 | SPEED_MAX, DUPLEX_FULL, |
| 1940 | PHY_INTERFACE_MODE_NA); |
| 1941 | else |
| 1942 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 1943 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
| 1944 | PHY_INTERFACE_MODE_NA); |
| 1945 | if (err) |
| 1946 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 1947 | |
| 1948 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 1949 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 1950 | * tunneling, determine priority by looking at 802.1p and IP |
| 1951 | * priority fields (IP prio has precedence), and set STP state |
| 1952 | * to Forwarding. |
| 1953 | * |
| 1954 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 1955 | * on which tagging mode was configured. |
| 1956 | * |
| 1957 | * If this is a link to another switch, use DSA tagging mode. |
| 1958 | * |
| 1959 | * If this is the upstream port for this switch, enable |
| 1960 | * forwarding of unknown unicasts and multicasts. |
| 1961 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 1962 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 1963 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 1964 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 1965 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 1966 | if (err) |
| 1967 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 1968 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 1969 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 1970 | if (err) |
| 1971 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 1972 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 1973 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 1974 | if (err) |
| 1975 | return err; |
| 1976 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 1977 | /* Enable the SERDES interface for DSA and CPU ports. Normal |
| 1978 | * ports SERDES are enabled when the port is enabled, thus |
| 1979 | * saving a bit of power. |
Patrick Uiterwijk | 13a7ebb | 2016-03-30 01:39:41 +0000 | [diff] [blame] | 1980 | */ |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 1981 | if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) { |
| 1982 | err = mv88e6xxx_serdes_power(chip, port, true); |
| 1983 | if (err) |
| 1984 | return err; |
| 1985 | } |
Patrick Uiterwijk | 13a7ebb | 2016-03-30 01:39:41 +0000 | [diff] [blame] | 1986 | |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 1987 | /* Port Control 2: don't force a good FCS, set the maximum frame size to |
Vivien Didelot | 46fbe5e | 2016-02-26 13:16:07 -0500 | [diff] [blame] | 1988 | * 10240 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 1989 | * untagged frames on this port, do a destination address lookup on all |
| 1990 | * received packets as usual, disable ARP mirroring and don't send a |
| 1991 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 1992 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 1993 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 1994 | if (err) |
| 1995 | return err; |
| 1996 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 1997 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 1998 | if (err) |
| 1999 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2000 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2001 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2002 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2003 | if (err) |
| 2004 | return err; |
| 2005 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2006 | if (chip->info->ops->port_set_jumbo_size) { |
| 2007 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10240); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2008 | if (err) |
| 2009 | return err; |
| 2010 | } |
| 2011 | |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2012 | /* Port Association Vector: when learning source addresses |
| 2013 | * of packets, add the address to the address database using |
| 2014 | * a port bitmap that has only the bit for this port set and |
| 2015 | * the other bits clear. |
| 2016 | */ |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2017 | reg = 1 << port; |
Vivien Didelot | 996ecb8 | 2016-04-14 14:42:08 -0400 | [diff] [blame] | 2018 | /* Disable learning for CPU port */ |
| 2019 | if (dsa_is_cpu_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2020 | reg = 0; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2021 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2022 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2023 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2024 | if (err) |
| 2025 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2026 | |
| 2027 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2028 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2029 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2030 | if (err) |
| 2031 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2032 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2033 | if (chip->info->ops->port_pause_limit) { |
| 2034 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2035 | if (err) |
| 2036 | return err; |
| 2037 | } |
| 2038 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2039 | if (chip->info->ops->port_disable_learn_limit) { |
| 2040 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2041 | if (err) |
| 2042 | return err; |
| 2043 | } |
| 2044 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2045 | if (chip->info->ops->port_disable_pri_override) { |
| 2046 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2047 | if (err) |
| 2048 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2049 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2050 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2051 | if (chip->info->ops->port_tag_remap) { |
| 2052 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2053 | if (err) |
| 2054 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2055 | } |
| 2056 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2057 | if (chip->info->ops->port_egress_rate_limiting) { |
| 2058 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2059 | if (err) |
| 2060 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2061 | } |
| 2062 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2063 | err = mv88e6xxx_setup_message_port(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2064 | if (err) |
| 2065 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2066 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 2067 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 2068 | * database, and allow bidirectional communication between the |
| 2069 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2070 | */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2071 | err = mv88e6xxx_port_set_fid(chip, port, 0); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2072 | if (err) |
| 2073 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 2074 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2075 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2076 | if (err) |
| 2077 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2078 | |
| 2079 | /* Default VLAN ID and priority: don't set a default VLAN |
| 2080 | * ID, and set the default packet priority to zero. |
| 2081 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 2082 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 2083 | } |
| 2084 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2085 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 2086 | struct phy_device *phydev) |
| 2087 | { |
| 2088 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2089 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2090 | |
| 2091 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2092 | err = mv88e6xxx_serdes_power(chip, port, true); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2093 | mutex_unlock(&chip->reg_lock); |
| 2094 | |
| 2095 | return err; |
| 2096 | } |
| 2097 | |
| 2098 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port, |
| 2099 | struct phy_device *phydev) |
| 2100 | { |
| 2101 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2102 | |
| 2103 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2104 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 2105 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2106 | mutex_unlock(&chip->reg_lock); |
| 2107 | } |
| 2108 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2109 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 2110 | unsigned int ageing_time) |
| 2111 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2112 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2113 | int err; |
| 2114 | |
| 2115 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 2116 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2117 | mutex_unlock(&chip->reg_lock); |
| 2118 | |
| 2119 | return err; |
| 2120 | } |
| 2121 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2122 | static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2123 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2124 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2125 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2126 | |
Vivien Didelot | 50484ff | 2016-05-09 13:22:54 -0400 | [diff] [blame] | 2127 | /* Disable remote management, and set the switch's DSA device number. */ |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 2128 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2, |
| 2129 | MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE | |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2130 | (ds->index & 0x1f)); |
Vivien Didelot | 50484ff | 2016-05-09 13:22:54 -0400 | [diff] [blame] | 2131 | if (err) |
| 2132 | return err; |
| 2133 | |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2134 | /* Configure the IP ToS mapping registers. */ |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2135 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2136 | if (err) |
| 2137 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2138 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2139 | if (err) |
| 2140 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2141 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2142 | if (err) |
| 2143 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2144 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2145 | if (err) |
| 2146 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2147 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2148 | if (err) |
| 2149 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2150 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2151 | if (err) |
| 2152 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2153 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2154 | if (err) |
| 2155 | return err; |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2156 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2157 | if (err) |
| 2158 | return err; |
| 2159 | |
| 2160 | /* Configure the IEEE 802.1p priority mapping register. */ |
Vivien Didelot | ccba8f3 | 2017-06-15 12:14:06 -0400 | [diff] [blame] | 2161 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41); |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2162 | if (err) |
| 2163 | return err; |
| 2164 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2165 | /* Initialize the statistics unit */ |
| 2166 | err = mv88e6xxx_stats_set_histogram(chip); |
| 2167 | if (err) |
| 2168 | return err; |
| 2169 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2170 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2171 | } |
| 2172 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2173 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 2174 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2175 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2176 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 2177 | int i; |
| 2178 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2179 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2180 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2181 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2182 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2183 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2184 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 2185 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | 91dee14 | 2017-10-26 11:22:52 -0400 | [diff] [blame] | 2186 | if (dsa_is_unused_port(ds, i)) |
| 2187 | continue; |
| 2188 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2189 | err = mv88e6xxx_setup_port(chip, i); |
| 2190 | if (err) |
| 2191 | goto unlock; |
| 2192 | } |
| 2193 | |
| 2194 | /* Setup Switch Global 1 Registers */ |
| 2195 | err = mv88e6xxx_g1_setup(chip); |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 2196 | if (err) |
| 2197 | goto unlock; |
| 2198 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2199 | /* Setup Switch Global 2 Registers */ |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 2200 | if (chip->info->global2_addr) { |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2201 | err = mv88e6xxx_g2_setup(chip); |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 2202 | if (err) |
| 2203 | goto unlock; |
| 2204 | } |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2205 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2206 | err = mv88e6xxx_irl_setup(chip); |
| 2207 | if (err) |
| 2208 | goto unlock; |
| 2209 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 2210 | err = mv88e6xxx_mac_setup(chip); |
| 2211 | if (err) |
| 2212 | goto unlock; |
| 2213 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 2214 | err = mv88e6xxx_phy_setup(chip); |
| 2215 | if (err) |
| 2216 | goto unlock; |
| 2217 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 2218 | err = mv88e6xxx_vtu_setup(chip); |
| 2219 | if (err) |
| 2220 | goto unlock; |
| 2221 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 2222 | err = mv88e6xxx_pvt_setup(chip); |
| 2223 | if (err) |
| 2224 | goto unlock; |
| 2225 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 2226 | err = mv88e6xxx_atu_setup(chip); |
| 2227 | if (err) |
| 2228 | goto unlock; |
| 2229 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 2230 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 2231 | if (err) |
| 2232 | goto unlock; |
| 2233 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2234 | err = mv88e6xxx_pot_setup(chip); |
| 2235 | if (err) |
| 2236 | goto unlock; |
| 2237 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2238 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 2239 | if (err) |
| 2240 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 2241 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 2242 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 2243 | if (chip->info->ptp_support) { |
| 2244 | err = mv88e6xxx_ptp_setup(chip); |
| 2245 | if (err) |
| 2246 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 2247 | |
| 2248 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 2249 | if (err) |
| 2250 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 2251 | } |
| 2252 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 2253 | unlock: |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2254 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 2255 | |
Andrew Lunn | 48ace4e | 2016-04-14 23:47:12 +0200 | [diff] [blame] | 2256 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2257 | } |
| 2258 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2259 | static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg) |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 2260 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2261 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 2262 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2263 | u16 val; |
| 2264 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 2265 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 2266 | if (!chip->info->ops->phy_read) |
| 2267 | return -EOPNOTSUPP; |
| 2268 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2269 | mutex_lock(&chip->reg_lock); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 2270 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2271 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2272 | |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 2273 | if (reg == MII_PHYSID2) { |
| 2274 | /* Some internal PHYS don't have a model number. Use |
| 2275 | * the mv88e6390 family model number instead. |
| 2276 | */ |
| 2277 | if (!(val & 0x3f0)) |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 2278 | val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 2279 | } |
| 2280 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2281 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 2282 | } |
| 2283 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2284 | static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val) |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 2285 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2286 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 2287 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2288 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 2289 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 2290 | if (!chip->info->ops->phy_write) |
| 2291 | return -EOPNOTSUPP; |
| 2292 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2293 | mutex_lock(&chip->reg_lock); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 2294 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2295 | mutex_unlock(&chip->reg_lock); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 2296 | |
| 2297 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 2298 | } |
| 2299 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2300 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2301 | struct device_node *np, |
| 2302 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2303 | { |
| 2304 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2305 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2306 | struct mii_bus *bus; |
| 2307 | int err; |
| 2308 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 2309 | if (external) { |
| 2310 | mutex_lock(&chip->reg_lock); |
| 2311 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
| 2312 | mutex_unlock(&chip->reg_lock); |
| 2313 | |
| 2314 | if (err) |
| 2315 | return err; |
| 2316 | } |
| 2317 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2318 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2319 | if (!bus) |
| 2320 | return -ENOMEM; |
| 2321 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2322 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2323 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2324 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2325 | INIT_LIST_HEAD(&mdio_bus->list); |
| 2326 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 2327 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2328 | if (np) { |
| 2329 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 2330 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2331 | } else { |
| 2332 | bus->name = "mv88e6xxx SMI"; |
| 2333 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 2334 | } |
| 2335 | |
| 2336 | bus->read = mv88e6xxx_mdio_read; |
| 2337 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2338 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2339 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 2340 | if (!external) { |
| 2341 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 2342 | if (err) |
| 2343 | return err; |
| 2344 | } |
| 2345 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2346 | if (np) |
| 2347 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2348 | else |
| 2349 | err = mdiobus_register(bus); |
| 2350 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2351 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 2352 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2353 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2354 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2355 | |
| 2356 | if (external) |
| 2357 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 2358 | else |
| 2359 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2360 | |
| 2361 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 2362 | } |
| 2363 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2364 | static const struct of_device_id mv88e6xxx_mdio_external_match[] = { |
| 2365 | { .compatible = "marvell,mv88e6xxx-mdio-external", |
| 2366 | .data = (void *)true }, |
| 2367 | { }, |
| 2368 | }; |
| 2369 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 2370 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 2371 | |
| 2372 | { |
| 2373 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 2374 | struct mii_bus *bus; |
| 2375 | |
| 2376 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 2377 | bus = mdio_bus->bus; |
| 2378 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 2379 | if (!mdio_bus->external) |
| 2380 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 2381 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 2382 | mdiobus_unregister(bus); |
| 2383 | } |
| 2384 | } |
| 2385 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2386 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 2387 | struct device_node *np) |
| 2388 | { |
| 2389 | const struct of_device_id *match; |
| 2390 | struct device_node *child; |
| 2391 | int err; |
| 2392 | |
| 2393 | /* Always register one mdio bus for the internal/default mdio |
| 2394 | * bus. This maybe represented in the device tree, but is |
| 2395 | * optional. |
| 2396 | */ |
| 2397 | child = of_get_child_by_name(np, "mdio"); |
| 2398 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 2399 | if (err) |
| 2400 | return err; |
| 2401 | |
| 2402 | /* Walk the device tree, and see if there are any other nodes |
| 2403 | * which say they are compatible with the external mdio |
| 2404 | * bus. |
| 2405 | */ |
| 2406 | for_each_available_child_of_node(np, child) { |
| 2407 | match = of_match_node(mv88e6xxx_mdio_external_match, child); |
| 2408 | if (match) { |
| 2409 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 2410 | if (err) { |
| 2411 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2412 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 2413 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2414 | } |
| 2415 | } |
| 2416 | |
| 2417 | return 0; |
| 2418 | } |
| 2419 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2420 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 2421 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2422 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2423 | |
| 2424 | return chip->eeprom_len; |
| 2425 | } |
| 2426 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2427 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 2428 | struct ethtool_eeprom *eeprom, u8 *data) |
| 2429 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2430 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2431 | int err; |
| 2432 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2433 | if (!chip->info->ops->get_eeprom) |
| 2434 | return -EOPNOTSUPP; |
| 2435 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2436 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2437 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2438 | mutex_unlock(&chip->reg_lock); |
| 2439 | |
| 2440 | if (err) |
| 2441 | return err; |
| 2442 | |
| 2443 | eeprom->magic = 0xc3ec4951; |
| 2444 | |
| 2445 | return 0; |
| 2446 | } |
| 2447 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2448 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 2449 | struct ethtool_eeprom *eeprom, u8 *data) |
| 2450 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2451 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2452 | int err; |
| 2453 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2454 | if (!chip->info->ops->set_eeprom) |
| 2455 | return -EOPNOTSUPP; |
| 2456 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2457 | if (eeprom->magic != 0xc3ec4951) |
| 2458 | return -EINVAL; |
| 2459 | |
| 2460 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2461 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 2462 | mutex_unlock(&chip->reg_lock); |
| 2463 | |
| 2464 | return err; |
| 2465 | } |
| 2466 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2467 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2468 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2469 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2470 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 2471 | .phy_read = mv88e6185_phy_ppu_read, |
| 2472 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2473 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2474 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2475 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2476 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2477 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2478 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2479 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2480 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2481 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2482 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2483 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2484 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2485 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2486 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2487 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2488 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2489 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2490 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2491 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2492 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2493 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 2494 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 2495 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2496 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2497 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2498 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2499 | }; |
| 2500 | |
| 2501 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2502 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2503 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 2504 | .phy_read = mv88e6185_phy_ppu_read, |
| 2505 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2506 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2507 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2508 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2509 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2510 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2511 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2512 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2513 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2514 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2515 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2516 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2517 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 2518 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 2519 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2520 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2521 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2522 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2523 | }; |
| 2524 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 2525 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 2526 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2527 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 2528 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 2529 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2530 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 2531 | .port_set_link = mv88e6xxx_port_set_link, |
| 2532 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 2533 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2534 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2535 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2536 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2537 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2538 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2539 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2540 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2541 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2542 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 2543 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2544 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 2545 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2546 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 2547 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2548 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2549 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 2550 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2551 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2552 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2553 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2554 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2555 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 2556 | }; |
| 2557 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2558 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2559 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2560 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2561 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 2562 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2563 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2564 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2565 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2566 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2567 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2568 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2569 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2570 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 2571 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2572 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2573 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2574 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2575 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2576 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2577 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2578 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2579 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2580 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2581 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2582 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2583 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2584 | }; |
| 2585 | |
| 2586 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2587 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2588 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 2589 | .phy_read = mv88e6185_phy_ppu_read, |
| 2590 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2591 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2592 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2593 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2594 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2595 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2596 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2597 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2598 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2599 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2600 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2601 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2602 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2603 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2604 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2605 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2606 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2607 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2608 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2609 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2610 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 2611 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 2612 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2613 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2614 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2615 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2616 | }; |
| 2617 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2618 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 2619 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2620 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2621 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 2622 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 2623 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 2624 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2625 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 2626 | .port_set_link = mv88e6xxx_port_set_link, |
| 2627 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 2628 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 2629 | .port_set_speed = mv88e6390_port_set_speed, |
| 2630 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 2631 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 2632 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 2633 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2634 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2635 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2636 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2637 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 2638 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 2639 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2640 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2641 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 2642 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 2643 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2644 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 2645 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2646 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 2647 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2648 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2649 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2650 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2651 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 2652 | .gpio_ops = &mv88e6352_gpio_ops, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 2653 | }; |
| 2654 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2655 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2656 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2657 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2658 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 2659 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2660 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2661 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2662 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2663 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2664 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2665 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2666 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2667 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2668 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2669 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2670 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2671 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2672 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 2673 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2674 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2675 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2676 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2677 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2678 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2679 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2680 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2681 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2682 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2683 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2684 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2685 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2686 | }; |
| 2687 | |
| 2688 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2689 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2690 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2691 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 2692 | .phy_read = mv88e6165_phy_read, |
| 2693 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2694 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2695 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2696 | .port_set_speed = mv88e6185_port_set_speed, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2697 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2698 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2699 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2700 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2701 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2702 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2703 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2704 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2705 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2706 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2707 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2708 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2709 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2710 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2711 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2712 | }; |
| 2713 | |
| 2714 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2715 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2716 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2717 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2718 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2719 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2720 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2721 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 2722 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2723 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2724 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2725 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2726 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2727 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2728 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2729 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2730 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2731 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2732 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2733 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2734 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2735 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2736 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2737 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2738 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2739 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2740 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2741 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2742 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2743 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2744 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2745 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2746 | }; |
| 2747 | |
| 2748 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2749 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2750 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2751 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 2752 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2753 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2754 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2755 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2756 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2757 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 2758 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2759 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2760 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2761 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2762 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2763 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2764 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2765 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2766 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2767 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2768 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2769 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2770 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2771 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2772 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2773 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2774 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2775 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2776 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2777 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2778 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2779 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2780 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2781 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2782 | .serdes_power = mv88e6352_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 2783 | .gpio_ops = &mv88e6352_gpio_ops, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2784 | }; |
| 2785 | |
| 2786 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2787 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2788 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2789 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2790 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2791 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2792 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2793 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 2794 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2795 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2796 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2797 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2798 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2799 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2800 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2801 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2802 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2803 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2804 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2805 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2806 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2807 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2808 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2809 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2810 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2811 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2812 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2813 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2814 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2815 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2816 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2817 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2818 | }; |
| 2819 | |
| 2820 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2821 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2822 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2823 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 2824 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2825 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2826 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2827 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2828 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2829 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 2830 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2831 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2832 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2833 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2834 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2835 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2836 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2837 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2838 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2839 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2840 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2841 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2842 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2843 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2844 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2845 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2846 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2847 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2848 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2849 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2850 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2851 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2852 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2853 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2854 | .serdes_power = mv88e6352_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 2855 | .gpio_ops = &mv88e6352_gpio_ops, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2856 | }; |
| 2857 | |
| 2858 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2859 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2860 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 2861 | .phy_read = mv88e6185_phy_ppu_read, |
| 2862 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 2863 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 2864 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 2865 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2866 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2867 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2868 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2869 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 2870 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2871 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2872 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 2873 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 2874 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2875 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 2876 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 2877 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 2878 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 2879 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 2880 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2881 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2882 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2883 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2884 | }; |
| 2885 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2886 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2887 | /* MV88E6XXX_FAMILY_6390 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2888 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 2889 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 2890 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2891 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 2892 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2893 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 2894 | .port_set_link = mv88e6xxx_port_set_link, |
| 2895 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 2896 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 2897 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2898 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2899 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2900 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2901 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2902 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2903 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2904 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 2905 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2906 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2907 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 2908 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 2909 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2910 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 2911 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 2912 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 2913 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2914 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2915 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 2916 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 2917 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 2918 | .serdes_power = mv88e6390_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 2919 | .gpio_ops = &mv88e6352_gpio_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2920 | }; |
| 2921 | |
| 2922 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2923 | /* MV88E6XXX_FAMILY_6390 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2924 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 2925 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 2926 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2927 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 2928 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2929 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 2930 | .port_set_link = mv88e6xxx_port_set_link, |
| 2931 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 2932 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 2933 | .port_set_speed = mv88e6390x_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2934 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2935 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2936 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2937 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2938 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2939 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2940 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 2941 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2942 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2943 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 2944 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 2945 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2946 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 2947 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 2948 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 2949 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2950 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2951 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 2952 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 2953 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 2954 | .serdes_power = mv88e6390_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 2955 | .gpio_ops = &mv88e6352_gpio_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2956 | }; |
| 2957 | |
| 2958 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2959 | /* MV88E6XXX_FAMILY_6390 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2960 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 2961 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 2962 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2963 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 2964 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 2965 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 2966 | .port_set_link = mv88e6xxx_port_set_link, |
| 2967 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 2968 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 2969 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2970 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2971 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2972 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2973 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2974 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2975 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2976 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 2977 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2978 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 2979 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 2980 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 2981 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 2982 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 2983 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 2984 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 2985 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 2986 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2987 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 2988 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 2989 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 2990 | .serdes_power = mv88e6390_serdes_power, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 2991 | }; |
| 2992 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2993 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 2994 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 2995 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 2996 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 2997 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 2998 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 2999 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3000 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3001 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3002 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3003 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3004 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3005 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3006 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3007 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3008 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3009 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3010 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3011 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3012 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3013 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3014 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3015 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3016 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3017 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3018 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3019 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3020 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3021 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3022 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3023 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3024 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3025 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3026 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3027 | .serdes_power = mv88e6352_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3028 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3029 | .avb_ops = &mv88e6352_avb_ops, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3030 | }; |
| 3031 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3032 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3033 | /* MV88E6XXX_FAMILY_6390 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3034 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3035 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3036 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3037 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3038 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3039 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3040 | .port_set_link = mv88e6xxx_port_set_link, |
| 3041 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3042 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3043 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3044 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3045 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3046 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3047 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3048 | .port_pause_limit = mv88e6390_port_pause_limit, |
Andrew Lunn | f39908d | 2017-02-04 20:02:50 +0100 | [diff] [blame] | 3049 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3050 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3051 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3052 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3053 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3054 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3055 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3056 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3057 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3058 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 3059 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3060 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3061 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3062 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3063 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 3064 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 3065 | .serdes_power = mv88e6390_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3066 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3067 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3068 | }; |
| 3069 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3070 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3071 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3072 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3073 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3074 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3075 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3076 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3077 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3078 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3079 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3080 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3081 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3082 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3083 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3084 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3085 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3086 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3087 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3088 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3089 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3090 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3091 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3092 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3093 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3094 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3095 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3096 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3097 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3098 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3099 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3100 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3101 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3102 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3103 | .avb_ops = &mv88e6352_avb_ops, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3104 | }; |
| 3105 | |
| 3106 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 3107 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3108 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3109 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3110 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3111 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3112 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3113 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3114 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3115 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3116 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3117 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3118 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3119 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3120 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3121 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3122 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3123 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3124 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3125 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3126 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3127 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3128 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3129 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3130 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3131 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3132 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3133 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3134 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3135 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3136 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3137 | .avb_ops = &mv88e6352_avb_ops, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3138 | }; |
| 3139 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3140 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 3141 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3142 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3143 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3144 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3145 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3146 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3147 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3148 | .port_set_link = mv88e6xxx_port_set_link, |
| 3149 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3150 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3151 | .port_set_speed = mv88e6390_port_set_speed, |
| 3152 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 3153 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 3154 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 3155 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3156 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3157 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3158 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3159 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3160 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 3161 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3162 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3163 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3164 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3165 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3166 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3167 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3168 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3169 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3170 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3171 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3172 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3173 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3174 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3175 | .avb_ops = &mv88e6390_avb_ops, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 3176 | }; |
| 3177 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3178 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3179 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3180 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3181 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3182 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3183 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3184 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3185 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3186 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3187 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3188 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3189 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3190 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3191 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3192 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3193 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3194 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3195 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3196 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3197 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3198 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3199 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3200 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3201 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3202 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3203 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3204 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3205 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3206 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3207 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3208 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3209 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3210 | }; |
| 3211 | |
| 3212 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3213 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3214 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3215 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3216 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3217 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3218 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3219 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3220 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3221 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3222 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3223 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3224 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3225 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3226 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3227 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3228 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3229 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3230 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3231 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3232 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3233 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3234 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3235 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3236 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3237 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3238 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3239 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3240 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3241 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3242 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3243 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3244 | .avb_ops = &mv88e6352_avb_ops, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3245 | }; |
| 3246 | |
| 3247 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3248 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3249 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3250 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3251 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3252 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3253 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3254 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3255 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3256 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3257 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3258 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3259 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3260 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3261 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3262 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3263 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3264 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3265 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3266 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3267 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3268 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3269 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3270 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3271 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3272 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3273 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3274 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3275 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3276 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3277 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3278 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3279 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3280 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3281 | .serdes_power = mv88e6352_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3282 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3283 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 3284 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 3285 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 3286 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3287 | }; |
| 3288 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3289 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3290 | /* MV88E6XXX_FAMILY_6390 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3291 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3292 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3293 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3294 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3295 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3296 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3297 | .port_set_link = mv88e6xxx_port_set_link, |
| 3298 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3299 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3300 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3301 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3302 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3303 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3304 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3305 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3306 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3307 | .port_pause_limit = mv88e6390_port_pause_limit, |
Andrew Lunn | f39908d | 2017-02-04 20:02:50 +0100 | [diff] [blame] | 3308 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3309 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3310 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3311 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3312 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3313 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3314 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3315 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3316 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3317 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 3318 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3319 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3320 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3321 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3322 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 3323 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 3324 | .serdes_power = mv88e6390_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3325 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3326 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3327 | }; |
| 3328 | |
| 3329 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3330 | /* MV88E6XXX_FAMILY_6390 */ |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3331 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3332 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3333 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3334 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3335 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3336 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3337 | .port_set_link = mv88e6xxx_port_set_link, |
| 3338 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3339 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3340 | .port_set_speed = mv88e6390x_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3341 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3342 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3343 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3344 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3345 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3346 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3347 | .port_pause_limit = mv88e6390_port_pause_limit, |
Martin Hundebøll | bb0a267 | 2017-07-19 08:17:02 +0200 | [diff] [blame] | 3348 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3349 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3350 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3351 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3352 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3353 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3354 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3355 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3356 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3357 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 3358 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3359 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3360 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3361 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3362 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 3363 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 3364 | .serdes_power = mv88e6390_serdes_power, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3365 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 3366 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3367 | }; |
| 3368 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3369 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 3370 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3371 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3372 | .family = MV88E6XXX_FAMILY_6097, |
| 3373 | .name = "Marvell 88E6085", |
| 3374 | .num_databases = 4096, |
| 3375 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3376 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3377 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3378 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3379 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3380 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3381 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3382 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3383 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3384 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3385 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3386 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3387 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3388 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3389 | }, |
| 3390 | |
| 3391 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3392 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3393 | .family = MV88E6XXX_FAMILY_6095, |
| 3394 | .name = "Marvell 88E6095/88E6095F", |
| 3395 | .num_databases = 256, |
| 3396 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3397 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3398 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3399 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3400 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3401 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3402 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3403 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3404 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3405 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3406 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3407 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3408 | }, |
| 3409 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3410 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3411 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3412 | .family = MV88E6XXX_FAMILY_6097, |
| 3413 | .name = "Marvell 88E6097/88E6097F", |
| 3414 | .num_databases = 4096, |
| 3415 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3416 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3417 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3418 | .port_base_addr = 0x10, |
| 3419 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3420 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3421 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 3422 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3423 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3424 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3425 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3426 | .multi_chip = true, |
Stefan Eichenberger | 2bfcfcd | 2016-12-05 14:12:42 +0100 | [diff] [blame] | 3427 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3428 | .ops = &mv88e6097_ops, |
| 3429 | }, |
| 3430 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3431 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3432 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3433 | .family = MV88E6XXX_FAMILY_6165, |
| 3434 | .name = "Marvell 88E6123", |
| 3435 | .num_databases = 4096, |
| 3436 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3437 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3438 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3439 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3440 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3441 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3442 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3443 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3444 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3445 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3446 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3447 | .multi_chip = true, |
Andrew Lunn | 5ebe31d | 2017-06-07 15:06:19 +0200 | [diff] [blame] | 3448 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3449 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3450 | }, |
| 3451 | |
| 3452 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3453 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3454 | .family = MV88E6XXX_FAMILY_6185, |
| 3455 | .name = "Marvell 88E6131", |
| 3456 | .num_databases = 256, |
| 3457 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3458 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3459 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3460 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3461 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3462 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3463 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3464 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3465 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3466 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3467 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3468 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3469 | }, |
| 3470 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3471 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3472 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3473 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 3474 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3475 | .num_databases = 4096, |
| 3476 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3477 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3478 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3479 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3480 | .port_base_addr = 0x10, |
| 3481 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3482 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3483 | .age_time_coeff = 3750, |
| 3484 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 3485 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3486 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3487 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3488 | .multi_chip = true, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3489 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3490 | .ops = &mv88e6141_ops, |
| 3491 | }, |
| 3492 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3493 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3494 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3495 | .family = MV88E6XXX_FAMILY_6165, |
| 3496 | .name = "Marvell 88E6161", |
| 3497 | .num_databases = 4096, |
| 3498 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3499 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3500 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3501 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3502 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3503 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3504 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3505 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3506 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3507 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3508 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3509 | .multi_chip = true, |
Andrew Lunn | 5ebe31d | 2017-06-07 15:06:19 +0200 | [diff] [blame] | 3510 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3511 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3512 | }, |
| 3513 | |
| 3514 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3515 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3516 | .family = MV88E6XXX_FAMILY_6165, |
| 3517 | .name = "Marvell 88E6165", |
| 3518 | .num_databases = 4096, |
| 3519 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3520 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3521 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3522 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3523 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3524 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3525 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3526 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3527 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3528 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3529 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3530 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3531 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3532 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3533 | }, |
| 3534 | |
| 3535 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3536 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3537 | .family = MV88E6XXX_FAMILY_6351, |
| 3538 | .name = "Marvell 88E6171", |
| 3539 | .num_databases = 4096, |
| 3540 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3541 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3542 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3543 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3544 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3545 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3546 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3547 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3548 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3549 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3550 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3551 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3552 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3553 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3554 | }, |
| 3555 | |
| 3556 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3557 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3558 | .family = MV88E6XXX_FAMILY_6352, |
| 3559 | .name = "Marvell 88E6172", |
| 3560 | .num_databases = 4096, |
| 3561 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3562 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3563 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3564 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3565 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3566 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3567 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3568 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3569 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3570 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3571 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3572 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3573 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3574 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3575 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3576 | }, |
| 3577 | |
| 3578 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3579 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3580 | .family = MV88E6XXX_FAMILY_6351, |
| 3581 | .name = "Marvell 88E6175", |
| 3582 | .num_databases = 4096, |
| 3583 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3584 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3585 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3586 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3587 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3588 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3589 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3590 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3591 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3592 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3593 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3594 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3595 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3596 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3597 | }, |
| 3598 | |
| 3599 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3600 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3601 | .family = MV88E6XXX_FAMILY_6352, |
| 3602 | .name = "Marvell 88E6176", |
| 3603 | .num_databases = 4096, |
| 3604 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3605 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3606 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3607 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3608 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3609 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3610 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3611 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3612 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3613 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3614 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3615 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3616 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3617 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3618 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3619 | }, |
| 3620 | |
| 3621 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3622 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3623 | .family = MV88E6XXX_FAMILY_6185, |
| 3624 | .name = "Marvell 88E6185", |
| 3625 | .num_databases = 256, |
| 3626 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3627 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3628 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3629 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3630 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3631 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3632 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3633 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3634 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3635 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3636 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3637 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3638 | }, |
| 3639 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3640 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3641 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3642 | .family = MV88E6XXX_FAMILY_6390, |
| 3643 | .name = "Marvell 88E6190", |
| 3644 | .num_databases = 4096, |
| 3645 | .num_ports = 11, /* 10 + Z80 */ |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3646 | .num_internal_phys = 11, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3647 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3648 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3649 | .port_base_addr = 0x0, |
| 3650 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3651 | .global2_addr = 0x1c, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3652 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 3653 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3654 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3655 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3656 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3657 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3658 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3659 | .ops = &mv88e6190_ops, |
| 3660 | }, |
| 3661 | |
| 3662 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3663 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3664 | .family = MV88E6XXX_FAMILY_6390, |
| 3665 | .name = "Marvell 88E6190X", |
| 3666 | .num_databases = 4096, |
| 3667 | .num_ports = 11, /* 10 + Z80 */ |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3668 | .num_internal_phys = 11, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3669 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3670 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3671 | .port_base_addr = 0x0, |
| 3672 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3673 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 3674 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3675 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3676 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3677 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3678 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3679 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3680 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3681 | .ops = &mv88e6190x_ops, |
| 3682 | }, |
| 3683 | |
| 3684 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3685 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3686 | .family = MV88E6XXX_FAMILY_6390, |
| 3687 | .name = "Marvell 88E6191", |
| 3688 | .num_databases = 4096, |
| 3689 | .num_ports = 11, /* 10 + Z80 */ |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3690 | .num_internal_phys = 11, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3691 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3692 | .port_base_addr = 0x0, |
| 3693 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3694 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 3695 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3696 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3697 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3698 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3699 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3700 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3701 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3702 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 3703 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3704 | }, |
| 3705 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3706 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3707 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3708 | .family = MV88E6XXX_FAMILY_6352, |
| 3709 | .name = "Marvell 88E6240", |
| 3710 | .num_databases = 4096, |
| 3711 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3712 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3713 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3714 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3715 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3716 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3717 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3718 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3719 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3720 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3721 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3722 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3723 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3724 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3725 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3726 | .ops = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3727 | }, |
| 3728 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3729 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3730 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3731 | .family = MV88E6XXX_FAMILY_6390, |
| 3732 | .name = "Marvell 88E6290", |
| 3733 | .num_databases = 4096, |
| 3734 | .num_ports = 11, /* 10 + Z80 */ |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3735 | .num_internal_phys = 11, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3736 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3737 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3738 | .port_base_addr = 0x0, |
| 3739 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3740 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 3741 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3742 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3743 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3744 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3745 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3746 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3747 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3748 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3749 | .ops = &mv88e6290_ops, |
| 3750 | }, |
| 3751 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3752 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3753 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3754 | .family = MV88E6XXX_FAMILY_6320, |
| 3755 | .name = "Marvell 88E6320", |
| 3756 | .num_databases = 4096, |
| 3757 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3758 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3759 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3760 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3761 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3762 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3763 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3764 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3765 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3766 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3767 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3768 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3769 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3770 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3771 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3772 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3773 | }, |
| 3774 | |
| 3775 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3776 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3777 | .family = MV88E6XXX_FAMILY_6320, |
| 3778 | .name = "Marvell 88E6321", |
| 3779 | .num_databases = 4096, |
| 3780 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3781 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3782 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3783 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3784 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3785 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3786 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3787 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3788 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3789 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3790 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3791 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3792 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3793 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3794 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3795 | }, |
| 3796 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3797 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3798 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3799 | .family = MV88E6XXX_FAMILY_6341, |
| 3800 | .name = "Marvell 88E6341", |
| 3801 | .num_databases = 4096, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3802 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3803 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3804 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3805 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3806 | .port_base_addr = 0x10, |
| 3807 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3808 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3809 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3810 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 3811 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3812 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3813 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3814 | .multi_chip = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3815 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3816 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 3817 | .ops = &mv88e6341_ops, |
| 3818 | }, |
| 3819 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3820 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3821 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3822 | .family = MV88E6XXX_FAMILY_6351, |
| 3823 | .name = "Marvell 88E6350", |
| 3824 | .num_databases = 4096, |
| 3825 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3826 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3827 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3828 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3829 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3830 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3831 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3832 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3833 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3834 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3835 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3836 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3837 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3838 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3839 | }, |
| 3840 | |
| 3841 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3842 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3843 | .family = MV88E6XXX_FAMILY_6351, |
| 3844 | .name = "Marvell 88E6351", |
| 3845 | .num_databases = 4096, |
| 3846 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3847 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3848 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3849 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3850 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3851 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3852 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3853 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3854 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3855 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3856 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3857 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3858 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3859 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3860 | }, |
| 3861 | |
| 3862 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3863 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3864 | .family = MV88E6XXX_FAMILY_6352, |
| 3865 | .name = "Marvell 88E6352", |
| 3866 | .num_databases = 4096, |
| 3867 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3868 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3869 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 3870 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 3871 | .port_base_addr = 0x10, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 3872 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3873 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 3874 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 3875 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3876 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3877 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3878 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3879 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3880 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3881 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3882 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3883 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3884 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3885 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3886 | .family = MV88E6XXX_FAMILY_6390, |
| 3887 | .name = "Marvell 88E6390", |
| 3888 | .num_databases = 4096, |
| 3889 | .num_ports = 11, /* 10 + Z80 */ |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3890 | .num_internal_phys = 11, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3891 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3892 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3893 | .port_base_addr = 0x0, |
| 3894 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3895 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 3896 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3897 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3898 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3899 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3900 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3901 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3902 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3903 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3904 | .ops = &mv88e6390_ops, |
| 3905 | }, |
| 3906 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3907 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3908 | .family = MV88E6XXX_FAMILY_6390, |
| 3909 | .name = "Marvell 88E6390X", |
| 3910 | .num_databases = 4096, |
| 3911 | .num_ports = 11, /* 10 + Z80 */ |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 3912 | .num_internal_phys = 11, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3913 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3914 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3915 | .port_base_addr = 0x0, |
| 3916 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 3917 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 3918 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3919 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 3920 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 3921 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 3922 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3923 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 3924 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3925 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3926 | .ops = &mv88e6390x_ops, |
| 3927 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3928 | }; |
| 3929 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 3930 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 3931 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 3932 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 3933 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 3934 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 3935 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 3936 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 3937 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 3938 | return NULL; |
| 3939 | } |
| 3940 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3941 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 3942 | { |
| 3943 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 3944 | unsigned int prod_num, rev; |
| 3945 | u16 id; |
| 3946 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 3947 | |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 3948 | mutex_lock(&chip->reg_lock); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3949 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 3950 | mutex_unlock(&chip->reg_lock); |
| 3951 | if (err) |
| 3952 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 3953 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 3954 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 3955 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 3956 | |
| 3957 | info = mv88e6xxx_lookup_info(prod_num); |
| 3958 | if (!info) |
| 3959 | return -ENODEV; |
| 3960 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 3961 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3962 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 3963 | |
Vivien Didelot | ca070c1 | 2016-09-02 14:45:34 -0400 | [diff] [blame] | 3964 | err = mv88e6xxx_g2_require(chip); |
| 3965 | if (err) |
| 3966 | return err; |
| 3967 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3968 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 3969 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 3970 | |
| 3971 | return 0; |
| 3972 | } |
| 3973 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3974 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 3975 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3976 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 3977 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3978 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 3979 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 3980 | return NULL; |
| 3981 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3982 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 3983 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3984 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3985 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 3986 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3987 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 3988 | } |
| 3989 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3990 | static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip, |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 3991 | struct mii_bus *bus, int sw_addr) |
| 3992 | { |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 3993 | if (sw_addr == 0) |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3994 | chip->smi_ops = &mv88e6xxx_smi_single_chip_ops; |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 3995 | else if (chip->info->multi_chip) |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3996 | chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops; |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 3997 | else |
| 3998 | return -EINVAL; |
| 3999 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4000 | chip->bus = bus; |
| 4001 | chip->sw_addr = sw_addr; |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 4002 | |
| 4003 | return 0; |
| 4004 | } |
| 4005 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 4006 | static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds, |
| 4007 | int port) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 4008 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 4009 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 4010 | |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4011 | return chip->info->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 4012 | } |
| 4013 | |
Florian Fainelli | 2a93c1a | 2017-12-06 15:03:33 -0800 | [diff] [blame] | 4014 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) |
Andrew Lunn | fcdce7d | 2016-05-10 23:27:20 +0200 | [diff] [blame] | 4015 | static const char *mv88e6xxx_drv_probe(struct device *dsa_dev, |
| 4016 | struct device *host_dev, int sw_addr, |
| 4017 | void **priv) |
Andrew Lunn | a77d43f | 2016-04-13 02:40:42 +0200 | [diff] [blame] | 4018 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4019 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 4020 | struct mii_bus *bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 4021 | int err; |
Andrew Lunn | a77d43f | 2016-04-13 02:40:42 +0200 | [diff] [blame] | 4022 | |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 4023 | bus = dsa_host_dev_to_mii_bus(host_dev); |
Andrew Lunn | c156913 | 2016-04-13 02:40:45 +0200 | [diff] [blame] | 4024 | if (!bus) |
| 4025 | return NULL; |
| 4026 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4027 | chip = mv88e6xxx_alloc_chip(dsa_dev); |
| 4028 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 4029 | return NULL; |
| 4030 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 4031 | /* Legacy SMI probing will only support chips similar to 88E6085 */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4032 | chip->info = &mv88e6xxx_table[MV88E6085]; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 4033 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4034 | err = mv88e6xxx_smi_init(chip, bus, sw_addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 4035 | if (err) |
| 4036 | goto free; |
| 4037 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4038 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 4039 | if (err) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 4040 | goto free; |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 4041 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4042 | mutex_lock(&chip->reg_lock); |
| 4043 | err = mv88e6xxx_switch_reset(chip); |
| 4044 | mutex_unlock(&chip->reg_lock); |
| 4045 | if (err) |
| 4046 | goto free; |
| 4047 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 4048 | mv88e6xxx_phy_init(chip); |
| 4049 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 4050 | err = mv88e6xxx_mdios_register(chip, NULL); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 4051 | if (err) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 4052 | goto free; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 4053 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4054 | *priv = chip; |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 4055 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4056 | return chip->info->name; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 4057 | free: |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4058 | devm_kfree(dsa_dev, chip); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 4059 | |
| 4060 | return NULL; |
Andrew Lunn | a77d43f | 2016-04-13 02:40:42 +0200 | [diff] [blame] | 4061 | } |
Florian Fainelli | 2a93c1a | 2017-12-06 15:03:33 -0800 | [diff] [blame] | 4062 | #endif |
Andrew Lunn | a77d43f | 2016-04-13 02:40:42 +0200 | [diff] [blame] | 4063 | |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4064 | static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 3709aad | 2017-11-30 11:23:58 -0500 | [diff] [blame] | 4065 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4066 | { |
| 4067 | /* We don't need any dynamic resource from the kernel (yet), |
| 4068 | * so skip the prepare phase. |
| 4069 | */ |
| 4070 | |
| 4071 | return 0; |
| 4072 | } |
| 4073 | |
| 4074 | static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
Vivien Didelot | 3709aad | 2017-11-30 11:23:58 -0500 | [diff] [blame] | 4075 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4076 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 4077 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4078 | |
| 4079 | mutex_lock(&chip->reg_lock); |
| 4080 | if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 4081 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 4082 | dev_err(ds->dev, "p%d: failed to load multicast MAC address\n", |
| 4083 | port); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4084 | mutex_unlock(&chip->reg_lock); |
| 4085 | } |
| 4086 | |
| 4087 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 4088 | const struct switchdev_obj_port_mdb *mdb) |
| 4089 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 4090 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4091 | int err; |
| 4092 | |
| 4093 | mutex_lock(&chip->reg_lock); |
| 4094 | err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 4095 | MV88E6XXX_G1_ATU_DATA_STATE_UNUSED); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4096 | mutex_unlock(&chip->reg_lock); |
| 4097 | |
| 4098 | return err; |
| 4099 | } |
| 4100 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 4101 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Florian Fainelli | 2a93c1a | 2017-12-06 15:03:33 -0800 | [diff] [blame] | 4102 | #if IS_ENABLED(CONFIG_NET_DSA_LEGACY) |
Andrew Lunn | fcdce7d | 2016-05-10 23:27:20 +0200 | [diff] [blame] | 4103 | .probe = mv88e6xxx_drv_probe, |
Florian Fainelli | 2a93c1a | 2017-12-06 15:03:33 -0800 | [diff] [blame] | 4104 | #endif |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 4105 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4106 | .setup = mv88e6xxx_setup, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4107 | .adjust_link = mv88e6xxx_adjust_link, |
| 4108 | .get_strings = mv88e6xxx_get_strings, |
| 4109 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 4110 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 4111 | .port_enable = mv88e6xxx_port_enable, |
| 4112 | .port_disable = mv88e6xxx_port_disable, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 4113 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 4114 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 4115 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4116 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 4117 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 4118 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 4119 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 4120 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4121 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 4122 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
| 4123 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 4124 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4125 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
| 4126 | .port_vlan_prepare = mv88e6xxx_port_vlan_prepare, |
| 4127 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 4128 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4129 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 4130 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 4131 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 4132 | .port_mdb_prepare = mv88e6xxx_port_mdb_prepare, |
| 4133 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 4134 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 4135 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 4136 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 4137 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 4138 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 4139 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 4140 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 4141 | .get_ts_info = mv88e6xxx_get_ts_info, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4142 | }; |
| 4143 | |
Florian Fainelli | ab3d408 | 2017-01-08 14:52:07 -0800 | [diff] [blame] | 4144 | static struct dsa_switch_driver mv88e6xxx_switch_drv = { |
| 4145 | .ops = &mv88e6xxx_switch_ops, |
| 4146 | }; |
| 4147 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 4148 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4149 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4150 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4151 | struct dsa_switch *ds; |
| 4152 | |
Vivien Didelot | 73b1204 | 2017-03-30 17:37:10 -0400 | [diff] [blame] | 4153 | ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip)); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4154 | if (!ds) |
| 4155 | return -ENOMEM; |
| 4156 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4157 | ds->priv = chip; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 4158 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 4159 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 4160 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4161 | |
| 4162 | dev_set_drvdata(dev, ds); |
| 4163 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 4164 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4165 | } |
| 4166 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4167 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4168 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4169 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 4170 | } |
| 4171 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 4172 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4173 | { |
| 4174 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 4175 | struct device_node *np = dev->of_node; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 4176 | const struct mv88e6xxx_info *compat_info; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4177 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 4178 | u32 eeprom_len; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 4179 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4180 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 4181 | compat_info = of_device_get_match_data(dev); |
| 4182 | if (!compat_info) |
| 4183 | return -EINVAL; |
| 4184 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4185 | chip = mv88e6xxx_alloc_chip(dev); |
| 4186 | if (!chip) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4187 | return -ENOMEM; |
| 4188 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4189 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 4190 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4191 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 4192 | if (err) |
| 4193 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4194 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 4195 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
| 4196 | if (IS_ERR(chip->reset)) |
| 4197 | return PTR_ERR(chip->reset); |
| 4198 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4199 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 4200 | if (err) |
| 4201 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4202 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 4203 | mv88e6xxx_phy_init(chip); |
| 4204 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4205 | if (chip->info->ops->get_eeprom && |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 4206 | !of_property_read_u32(np, "eeprom-length", &eeprom_len)) |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4207 | chip->eeprom_len = eeprom_len; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 4208 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4209 | mutex_lock(&chip->reg_lock); |
| 4210 | err = mv88e6xxx_switch_reset(chip); |
| 4211 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 4212 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4213 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 4214 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4215 | chip->irq = of_irq_get(np, 0); |
| 4216 | if (chip->irq == -EPROBE_DEFER) { |
| 4217 | err = chip->irq; |
| 4218 | goto out; |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 4219 | } |
| 4220 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4221 | /* Has to be performed before the MDIO bus is created, because |
Uwe Kleine-König | a708767 | 2018-03-20 10:44:41 +0100 | [diff] [blame] | 4222 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4223 | * controllers |
| 4224 | */ |
| 4225 | mutex_lock(&chip->reg_lock); |
| 4226 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4227 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4228 | else |
| 4229 | err = mv88e6xxx_irq_poll_setup(chip); |
| 4230 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4231 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4232 | if (err) |
| 4233 | goto out; |
| 4234 | |
| 4235 | if (chip->info->g2_irqs > 0) { |
| 4236 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4237 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4238 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4239 | } |
| 4240 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4241 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 4242 | if (err) |
| 4243 | goto out_g2_irq; |
| 4244 | |
| 4245 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 4246 | if (err) |
| 4247 | goto out_g1_atu_prob_irq; |
| 4248 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 4249 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4250 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 4251 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4252 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 4253 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4254 | if (err) |
| 4255 | goto out_mdio; |
| 4256 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4257 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4258 | |
| 4259 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 4260 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 4261 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4262 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 4263 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4264 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4265 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4266 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4267 | mv88e6xxx_g2_irq_free(chip); |
| 4268 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4269 | mutex_lock(&chip->reg_lock); |
| 4270 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 4271 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 4272 | else |
| 4273 | mv88e6xxx_irq_poll_free(chip); |
| 4274 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4275 | out: |
| 4276 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4277 | } |
| 4278 | |
| 4279 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 4280 | { |
| 4281 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 4282 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4283 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 4284 | if (chip->info->ptp_support) { |
| 4285 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 4286 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 4287 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 4288 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 4289 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 4290 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 4291 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4292 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 4293 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 4294 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 4295 | |
| 4296 | if (chip->info->g2_irqs > 0) |
| 4297 | mv88e6xxx_g2_irq_free(chip); |
| 4298 | |
| 4299 | mutex_lock(&chip->reg_lock); |
| 4300 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 4301 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 4302 | else |
| 4303 | mv88e6xxx_irq_poll_free(chip); |
| 4304 | mutex_unlock(&chip->reg_lock); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4305 | } |
| 4306 | |
| 4307 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 4308 | { |
| 4309 | .compatible = "marvell,mv88e6085", |
| 4310 | .data = &mv88e6xxx_table[MV88E6085], |
| 4311 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4312 | { |
| 4313 | .compatible = "marvell,mv88e6190", |
| 4314 | .data = &mv88e6xxx_table[MV88E6190], |
| 4315 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4316 | { /* sentinel */ }, |
| 4317 | }; |
| 4318 | |
| 4319 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 4320 | |
| 4321 | static struct mdio_driver mv88e6xxx_driver = { |
| 4322 | .probe = mv88e6xxx_probe, |
| 4323 | .remove = mv88e6xxx_remove, |
| 4324 | .mdiodrv.driver = { |
| 4325 | .name = "mv88e6085", |
| 4326 | .of_match_table = mv88e6xxx_of_match, |
| 4327 | }, |
| 4328 | }; |
| 4329 | |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 4330 | static int __init mv88e6xxx_init(void) |
| 4331 | { |
Florian Fainelli | ab3d408 | 2017-01-08 14:52:07 -0800 | [diff] [blame] | 4332 | register_switch_driver(&mv88e6xxx_switch_drv); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4333 | return mdio_driver_register(&mv88e6xxx_driver); |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 4334 | } |
| 4335 | module_init(mv88e6xxx_init); |
| 4336 | |
| 4337 | static void __exit mv88e6xxx_cleanup(void) |
| 4338 | { |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 4339 | mdio_driver_unregister(&mv88e6xxx_driver); |
Florian Fainelli | ab3d408 | 2017-01-08 14:52:07 -0800 | [diff] [blame] | 4340 | unregister_switch_driver(&mv88e6xxx_switch_drv); |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 4341 | } |
| 4342 | module_exit(mv88e6xxx_cleanup); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 4343 | |
| 4344 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 4345 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 4346 | MODULE_LICENSE("GPL"); |