blob: 4dc4a11c6e16444f0bab0d907af59d7f86b3cef1 [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -04002 * Marvell 88E6xxx Ethernet switch single-chip definition
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040012#ifndef _MV88E6XXX_CHIP_H
13#define _MV88E6XXX_CHIP_H
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000014
Vivien Didelot194fea72015-08-10 09:09:47 -040015#include <linux/if_vlan.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020016#include <linux/irq.h>
Andrew Lunn52638f72016-05-10 23:27:22 +020017#include <linux/gpio/consumer.h>
Russell King4d56a292017-02-07 15:03:05 -080018#include <linux/phy.h>
Andrew Lunnc6e970a2017-03-28 23:45:06 +020019#include <net/dsa.h>
Vivien Didelot194fea72015-08-10 09:09:47 -040020
Andrew Lunn80c46272015-06-20 18:42:30 +020021#ifndef UINT64_MAX
22#define UINT64_MAX (u64)(~((u64)0))
23#endif
24
Andrew Lunncca8b132015-04-02 04:06:39 +020025#define SMI_CMD 0x00
26#define SMI_CMD_BUSY BIT(15)
27#define SMI_CMD_CLAUSE_22 BIT(12)
28#define SMI_CMD_OP_22_WRITE ((1 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
29#define SMI_CMD_OP_22_READ ((2 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
30#define SMI_CMD_OP_45_WRITE_ADDR ((0 << 10) | SMI_CMD_BUSY)
31#define SMI_CMD_OP_45_WRITE_DATA ((1 << 10) | SMI_CMD_BUSY)
32#define SMI_CMD_OP_45_READ_DATA ((2 << 10) | SMI_CMD_BUSY)
33#define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY)
34#define SMI_DATA 0x01
Guenter Roeckb2eb0662015-04-02 04:06:30 +020035
Vivien Didelot3285f9e2016-02-26 13:16:03 -050036#define MV88E6XXX_N_FID 4096
37
Vivien Didelot17a15942017-03-30 17:37:09 -040038/* PVT limits for 4-bit port and 5-bit switch */
39#define MV88E6XXX_MAX_PVT_SWITCHES 32
40#define MV88E6XXX_MAX_PVT_PORTS 16
41
Vivien Didelot31bef4e2017-06-08 18:34:09 -040042enum mv88e6xxx_egress_mode {
43 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
44 MV88E6XXX_EGRESS_MODE_UNTAGGED,
45 MV88E6XXX_EGRESS_MODE_TAGGED,
46 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
47};
48
Andrew Lunn56995cb2016-12-03 04:35:19 +010049enum mv88e6xxx_frame_mode {
50 MV88E6XXX_FRAME_MODE_NORMAL,
51 MV88E6XXX_FRAME_MODE_DSA,
52 MV88E6XXX_FRAME_MODE_PROVIDER,
53 MV88E6XXX_FRAME_MODE_ETHERTYPE,
54};
55
Vivien Didelotf81ec902016-05-09 13:22:58 -040056/* List of supported models */
57enum mv88e6xxx_model {
58 MV88E6085,
59 MV88E6095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +010060 MV88E6097,
Vivien Didelotf81ec902016-05-09 13:22:58 -040061 MV88E6123,
62 MV88E6131,
Gregory CLEMENT15587272017-01-30 20:29:35 +010063 MV88E6141,
Vivien Didelotf81ec902016-05-09 13:22:58 -040064 MV88E6161,
65 MV88E6165,
66 MV88E6171,
67 MV88E6172,
68 MV88E6175,
69 MV88E6176,
70 MV88E6185,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010071 MV88E6190,
72 MV88E6190X,
73 MV88E6191,
Vivien Didelotf81ec902016-05-09 13:22:58 -040074 MV88E6240,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010075 MV88E6290,
Vivien Didelotf81ec902016-05-09 13:22:58 -040076 MV88E6320,
77 MV88E6321,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +010078 MV88E6341,
Vivien Didelotf81ec902016-05-09 13:22:58 -040079 MV88E6350,
80 MV88E6351,
81 MV88E6352,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010082 MV88E6390,
83 MV88E6390X,
Vivien Didelotf81ec902016-05-09 13:22:58 -040084};
85
Vivien Didelot22356472016-04-17 13:24:00 -040086enum mv88e6xxx_family {
87 MV88E6XXX_FAMILY_NONE,
88 MV88E6XXX_FAMILY_6065, /* 6031 6035 6061 6065 */
89 MV88E6XXX_FAMILY_6095, /* 6092 6095 */
90 MV88E6XXX_FAMILY_6097, /* 6046 6085 6096 6097 */
91 MV88E6XXX_FAMILY_6165, /* 6123 6161 6165 */
92 MV88E6XXX_FAMILY_6185, /* 6108 6121 6122 6131 6152 6155 6182 6185 */
93 MV88E6XXX_FAMILY_6320, /* 6320 6321 */
Gregory CLEMENTa75961d2017-01-30 20:29:34 +010094 MV88E6XXX_FAMILY_6341, /* 6141 6341 */
Vivien Didelot22356472016-04-17 13:24:00 -040095 MV88E6XXX_FAMILY_6351, /* 6171 6175 6350 6351 */
96 MV88E6XXX_FAMILY_6352, /* 6172 6176 6240 6352 */
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010097 MV88E6XXX_FAMILY_6390, /* 6190 6190X 6191 6290 6390 6390X */
Vivien Didelot22356472016-04-17 13:24:00 -040098};
99
Andrew Lunnc0e4dad2017-02-09 00:00:43 +0100100struct mv88e6xxx_ops;
101
Vivien Didelotf6271e62016-04-17 13:23:59 -0400102struct mv88e6xxx_info {
Vivien Didelot22356472016-04-17 13:24:00 -0400103 enum mv88e6xxx_family family;
Vivien Didelotf6271e62016-04-17 13:23:59 -0400104 u16 prod_num;
105 const char *name;
Vivien Didelotcd5a2c82016-04-17 13:24:02 -0400106 unsigned int num_databases;
Vivien Didelot009a2b92016-04-17 13:24:01 -0400107 unsigned int num_ports;
Vivien Didelot3cf3c842017-05-01 14:05:10 -0400108 unsigned int max_vid;
Vivien Didelot9dddd472016-06-20 13:14:10 -0400109 unsigned int port_base_addr;
Vivien Didelota935c052016-09-29 12:21:53 -0400110 unsigned int global1_addr;
Vivien Didelot9069c132017-07-17 13:03:44 -0400111 unsigned int global2_addr;
Vivien Didelotacddbd22016-07-18 20:45:39 -0400112 unsigned int age_time_coeff;
Andrew Lunndc30c352016-10-16 19:56:49 +0200113 unsigned int g1_irqs;
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -0400114 unsigned int g2_irqs;
Vivien Didelotf3645652017-03-30 17:37:07 -0400115 bool pvt;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -0400116
117 /* Multi-chip Addressing Mode.
118 * Some chips respond to only 2 registers of its own SMI device address
119 * when it is non-zero, and use indirect access to internal registers.
120 */
121 bool multi_chip;
Andrew Lunn443d5a12016-12-03 04:35:18 +0100122 enum dsa_tag_protocol tag_protocol;
Vivien Didelote606ca32017-03-11 16:12:55 -0500123
124 /* Mask for FromPort and ToPort value of PortVec used in ATU Move
125 * operation. 0 means that the ATU Move operation is not supported.
126 */
127 u8 atu_move_port_mask;
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400128 const struct mv88e6xxx_ops *ops;
Vivien Didelotb9b37712015-10-30 19:39:48 -0400129};
130
Vivien Didelotfd231c82015-08-10 09:09:50 -0400131struct mv88e6xxx_atu_entry {
Vivien Didelotfd231c82015-08-10 09:09:50 -0400132 u8 state;
133 bool trunk;
Vivien Didelot01bd96c2017-03-11 16:12:57 -0500134 u16 portvec;
Vivien Didelotfd231c82015-08-10 09:09:50 -0400135 u8 mac[ETH_ALEN];
136};
137
Vivien Didelotb4e47c02016-09-29 12:21:58 -0400138struct mv88e6xxx_vtu_entry {
Vivien Didelotb8fee952015-08-13 12:52:19 -0400139 u16 vid;
140 u16 fid;
Vivien Didelotb8fee952015-08-13 12:52:19 -0400141 u8 sid;
142 bool valid;
Vivien Didelotbd00e052017-05-01 14:05:11 -0400143 u8 member[DSA_MAX_PORTS];
144 u8 state[DSA_MAX_PORTS];
Vivien Didelotb8fee952015-08-13 12:52:19 -0400145};
146
Vivien Didelotc08026a2016-09-29 12:21:59 -0400147struct mv88e6xxx_bus_ops;
Andrew Lunnfcd25162017-02-09 00:03:42 +0100148struct mv88e6xxx_irq_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -0400149
Andrew Lunndc30c352016-10-16 19:56:49 +0200150struct mv88e6xxx_irq {
151 u16 masked;
152 struct irq_chip chip;
153 struct irq_domain *domain;
154 unsigned int nirqs;
155};
156
Vivien Didelotfad09c72016-06-21 12:28:20 -0400157struct mv88e6xxx_chip {
Vivien Didelotf6271e62016-04-17 13:23:59 -0400158 const struct mv88e6xxx_info *info;
159
Andrew Lunn7543a6d2016-04-13 02:40:40 +0200160 /* The dsa_switch this private structure is related to */
161 struct dsa_switch *ds;
162
Andrew Lunn158bc062016-04-28 21:24:06 -0400163 /* The device this structure is associated to */
164 struct device *dev;
165
Vivien Didelot9f8b3ee2016-06-20 13:14:05 -0400166 /* This mutex protects the access to the switch registers */
167 struct mutex reg_lock;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000168
Andrew Lunna77d43f2016-04-13 02:40:42 +0200169 /* The MII bus and the address on the bus that is used to
170 * communication with the switch
171 */
Vivien Didelotc08026a2016-09-29 12:21:59 -0400172 const struct mv88e6xxx_bus_ops *smi_ops;
Andrew Lunna77d43f2016-04-13 02:40:42 +0200173 struct mii_bus *bus;
174 int sw_addr;
175
Barry Grussling3675c8d2013-01-08 16:05:53 +0000176 /* Handles automatic disabling and re-enabling of the PHY
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000177 * polling unit.
178 */
Vivien Didelotc08026a2016-09-29 12:21:59 -0400179 const struct mv88e6xxx_bus_ops *phy_ops;
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000180 struct mutex ppu_mutex;
181 int ppu_disabled;
182 struct work_struct ppu_work;
183 struct timer_list ppu_timer;
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000184
Barry Grussling3675c8d2013-01-08 16:05:53 +0000185 /* This mutex serialises access to the statistics unit.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000186 * Hold this mutex over snapshot + dump sequences.
187 */
188 struct mutex stats_mutex;
Peter Korsgaardec80bfc2011-04-05 03:03:56 +0000189
Andrew Lunn52638f72016-05-10 23:27:22 +0200190 /* A switch may have a GPIO line tied to its reset pin. Parse
191 * this from the device tree, and use it before performing
192 * switch soft reset.
193 */
194 struct gpio_desc *reset;
Andrew Lunnf8cd8752016-05-10 23:27:25 +0200195
196 /* set to size of eeprom if supported by the switch */
197 int eeprom_len;
Andrew Lunnb516d452016-06-04 21:17:06 +0200198
Andrew Lunna3c53be52017-01-24 14:53:50 +0100199 /* List of mdio busses */
200 struct list_head mdios;
Andrew Lunndc30c352016-10-16 19:56:49 +0200201
202 /* There can be two interrupt controllers, which are chained
203 * off a GPIO as interrupt source
204 */
205 struct mv88e6xxx_irq g1_irq;
206 struct mv88e6xxx_irq g2_irq;
207 int irq;
Andrew Lunn8e757eb2016-11-20 20:14:18 +0100208 int device_irq;
Andrew Lunnfcd25162017-02-09 00:03:42 +0100209 int watchdog_irq;
Andrew Lunn09776442018-01-14 02:32:44 +0100210 int atu_prob_irq;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000211};
212
Vivien Didelotc08026a2016-09-29 12:21:59 -0400213struct mv88e6xxx_bus_ops {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400214 int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
215 int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400216};
217
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100218struct mv88e6xxx_mdio_bus {
Andrew Lunna3c53be52017-01-24 14:53:50 +0100219 struct mii_bus *bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100220 struct mv88e6xxx_chip *chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +0100221 struct list_head list;
222 bool external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100223};
224
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400225struct mv88e6xxx_ops {
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400226 /* Ingress Rate Limit unit (IRL) operations */
227 int (*irl_init_all)(struct mv88e6xxx_chip *chip, int port);
228
Vivien Didelotee4dc2e72016-09-29 12:22:02 -0400229 int (*get_eeprom)(struct mv88e6xxx_chip *chip,
230 struct ethtool_eeprom *eeprom, u8 *data);
231 int (*set_eeprom)(struct mv88e6xxx_chip *chip,
232 struct ethtool_eeprom *eeprom, u8 *data);
233
Vivien Didelotb073d4e2016-09-29 12:22:01 -0400234 int (*set_switch_mac)(struct mv88e6xxx_chip *chip, u8 *addr);
235
Andrew Lunnee26a222017-01-24 14:53:48 +0100236 int (*phy_read)(struct mv88e6xxx_chip *chip,
237 struct mii_bus *bus,
238 int addr, int reg, u16 *val);
239 int (*phy_write)(struct mv88e6xxx_chip *chip,
240 struct mii_bus *bus,
241 int addr, int reg, u16 val);
Vivien Didelot08ef7f12016-11-04 03:23:32 +0100242
Vivien Didelot9e907d72017-07-17 13:03:43 -0400243 /* Priority Override Table operations */
244 int (*pot_clear)(struct mv88e6xxx_chip *chip);
245
Vivien Didelota199d8b2016-12-05 17:30:28 -0500246 /* PHY Polling Unit (PPU) operations */
247 int (*ppu_enable)(struct mv88e6xxx_chip *chip);
248 int (*ppu_disable)(struct mv88e6xxx_chip *chip);
249
Vivien Didelot17e708b2016-12-05 17:30:27 -0500250 /* Switch Software Reset */
251 int (*reset)(struct mv88e6xxx_chip *chip);
252
Vivien Didelota0a0f622016-11-04 03:23:34 +0100253 /* RGMII Receive/Transmit Timing Control
254 * Add delay on PHY_INTERFACE_MODE_RGMII_*ID, no delay otherwise.
255 */
256 int (*port_set_rgmii_delay)(struct mv88e6xxx_chip *chip, int port,
257 phy_interface_t mode);
258
Vivien Didelot08ef7f12016-11-04 03:23:32 +0100259#define LINK_FORCED_DOWN 0
260#define LINK_FORCED_UP 1
261#define LINK_UNFORCED -2
262
263 /* Port's MAC link state
264 * Use LINK_FORCED_UP or LINK_FORCED_DOWN to force link up or down,
265 * or LINK_UNFORCED for normal link detection.
266 */
267 int (*port_set_link)(struct mv88e6xxx_chip *chip, int port, int link);
Vivien Didelot7f1ae072016-11-04 03:23:33 +0100268
269#define DUPLEX_UNFORCED -2
270
271 /* Port's MAC duplex mode
272 *
273 * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
274 * or DUPLEX_UNFORCED for normal duplex detection.
275 */
276 int (*port_set_duplex)(struct mv88e6xxx_chip *chip, int port, int dup);
Vivien Didelot96a2b402016-11-04 03:23:35 +0100277
278#define SPEED_MAX INT_MAX
279#define SPEED_UNFORCED -2
280
281 /* Port's MAC speed (in Mbps)
282 *
283 * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
284 * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value.
285 */
286 int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed);
Andrew Lunna605a0f2016-11-21 23:26:58 +0100287
Andrew Lunnef0a7312016-12-03 04:35:16 +0100288 int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port);
289
Andrew Lunn56995cb2016-12-03 04:35:19 +0100290 int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port,
291 enum mv88e6xxx_frame_mode mode);
Vivien Didelot601aeed2017-03-11 16:13:00 -0500292 int (*port_set_egress_floods)(struct mv88e6xxx_chip *chip, int port,
293 bool unicast, bool multicast);
Andrew Lunn56995cb2016-12-03 04:35:19 +0100294 int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
295 u16 etype);
Vivien Didelotcd782652017-06-08 18:34:13 -0400296 int (*port_set_jumbo_size)(struct mv88e6xxx_chip *chip, int port,
297 size_t size);
Andrew Lunn56995cb2016-12-03 04:35:19 +0100298
Andrew Lunnef70b112016-12-03 04:45:18 +0100299 int (*port_egress_rate_limiting)(struct mv88e6xxx_chip *chip, int port);
Vivien Didelot08984322017-06-08 18:34:12 -0400300 int (*port_pause_limit)(struct mv88e6xxx_chip *chip, int port, u8 in,
301 u8 out);
Vivien Didelotc8c94892017-03-11 16:13:01 -0500302 int (*port_disable_learn_limit)(struct mv88e6xxx_chip *chip, int port);
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -0500303 int (*port_disable_pri_override)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnef70b112016-12-03 04:45:18 +0100304
Andrew Lunnf39908d2017-02-04 20:02:50 +0100305 /* CMODE control what PHY mode the MAC will use, eg. SGMII, RGMII, etc.
306 * Some chips allow this to be configured on specific ports.
307 */
308 int (*port_set_cmode)(struct mv88e6xxx_chip *chip, int port,
309 phy_interface_t mode);
310
Andrew Lunna23b2962017-02-04 20:15:28 +0100311 /* Some devices have a per port register indicating what is
312 * the upstream port this port should forward to.
313 */
314 int (*port_set_upstream_port)(struct mv88e6xxx_chip *chip, int port,
315 int upstream_port);
316
Andrew Lunna605a0f2016-11-21 23:26:58 +0100317 /* Snapshot the statistics for a port. The statistics can then
318 * be read back a leisure but still with a consistent view.
319 */
320 int (*stats_snapshot)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnde2273872016-11-21 23:27:01 +0100321
322 /* Set the histogram mode for statistics, when the control registers
323 * are separated out of the STATS_OP register.
324 */
325 int (*stats_set_histogram)(struct mv88e6xxx_chip *chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100326
327 /* Return the number of strings describing statistics */
328 int (*stats_get_sset_count)(struct mv88e6xxx_chip *chip);
329 void (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
Andrew Lunn052f9472016-11-21 23:27:03 +0100330 void (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
331 uint64_t *data);
Vivien Didelotfa8d1172017-06-08 18:34:11 -0400332 int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
333 int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnfcd25162017-02-09 00:03:42 +0100334 const struct mv88e6xxx_irq_ops *watchdog_ops;
Andrew Lunn6e55f692016-12-03 04:45:16 +0100335
Andrew Lunn6e55f692016-12-03 04:45:16 +0100336 int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
Vivien Didelotf1394b72017-05-01 14:05:22 -0400337
Andrew Lunn6d917822017-05-26 01:03:21 +0200338 /* Power on/off a SERDES interface */
339 int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, bool on);
340
Vivien Didelotf1394b72017-05-01 14:05:22 -0400341 /* VLAN Translation Unit operations */
342 int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
343 struct mv88e6xxx_vtu_entry *entry);
Vivien Didelot0ad5daf2017-05-01 14:05:23 -0400344 int (*vtu_loadpurge)(struct mv88e6xxx_chip *chip,
345 struct mv88e6xxx_vtu_entry *entry);
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400346};
347
Andrew Lunnfcd25162017-02-09 00:03:42 +0100348struct mv88e6xxx_irq_ops {
349 /* Action to be performed when the interrupt happens */
350 int (*irq_action)(struct mv88e6xxx_chip *chip, int irq);
351 /* Setup the hardware to generate the interrupt */
352 int (*irq_setup)(struct mv88e6xxx_chip *chip);
353 /* Reset the hardware to stop generating the interrupt */
354 void (*irq_free)(struct mv88e6xxx_chip *chip);
355};
356
Andrew Lunndfafe442016-11-21 23:27:02 +0100357#define STATS_TYPE_PORT BIT(0)
358#define STATS_TYPE_BANK0 BIT(1)
359#define STATS_TYPE_BANK1 BIT(2)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100360
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000361struct mv88e6xxx_hw_stat {
362 char string[ETH_GSTRING_LEN];
363 int sizeof_stat;
364 int reg;
Andrew Lunndfafe442016-11-21 23:27:02 +0100365 int type;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000366};
367
Vivien Didelotf3645652017-03-30 17:37:07 -0400368static inline bool mv88e6xxx_has_pvt(struct mv88e6xxx_chip *chip)
369{
370 return chip->info->pvt;
371}
372
Vivien Didelotde333762016-09-29 12:21:56 -0400373static inline unsigned int mv88e6xxx_num_databases(struct mv88e6xxx_chip *chip)
374{
375 return chip->info->num_databases;
376}
377
Vivien Didelot370b4ff2016-09-29 12:21:57 -0400378static inline unsigned int mv88e6xxx_num_ports(struct mv88e6xxx_chip *chip)
379{
380 return chip->info->num_ports;
381}
382
Vivien Didelot4d294af2017-03-11 16:12:47 -0500383static inline u16 mv88e6xxx_port_mask(struct mv88e6xxx_chip *chip)
384{
385 return GENMASK(mv88e6xxx_num_ports(chip) - 1, 0);
386}
387
Vivien Didelotec561272016-09-02 14:45:33 -0400388int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
389int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
390int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
391 u16 update);
392int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200393struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -0400394
395#endif /* _MV88E6XXX_CHIP_H */