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