blob: 5467c86f38a10b43068cb07ed071965616c7cdf3 [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;
Brandon Streiff0d632c32018-02-14 01:07:44 +0100149struct mv88e6xxx_avb_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -0400150
Andrew Lunndc30c352016-10-16 19:56:49 +0200151struct mv88e6xxx_irq {
152 u16 masked;
153 struct irq_chip chip;
154 struct irq_domain *domain;
155 unsigned int nirqs;
156};
157
Vivien Didelotfad09c72016-06-21 12:28:20 -0400158struct mv88e6xxx_chip {
Vivien Didelotf6271e62016-04-17 13:23:59 -0400159 const struct mv88e6xxx_info *info;
160
Andrew Lunn7543a6d2016-04-13 02:40:40 +0200161 /* The dsa_switch this private structure is related to */
162 struct dsa_switch *ds;
163
Andrew Lunn158bc062016-04-28 21:24:06 -0400164 /* The device this structure is associated to */
165 struct device *dev;
166
Vivien Didelot9f8b3ee2016-06-20 13:14:05 -0400167 /* This mutex protects the access to the switch registers */
168 struct mutex reg_lock;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000169
Andrew Lunna77d43f2016-04-13 02:40:42 +0200170 /* The MII bus and the address on the bus that is used to
171 * communication with the switch
172 */
Vivien Didelotc08026a2016-09-29 12:21:59 -0400173 const struct mv88e6xxx_bus_ops *smi_ops;
Andrew Lunna77d43f2016-04-13 02:40:42 +0200174 struct mii_bus *bus;
175 int sw_addr;
176
Barry Grussling3675c8d2013-01-08 16:05:53 +0000177 /* Handles automatic disabling and re-enabling of the PHY
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000178 * polling unit.
179 */
Vivien Didelotc08026a2016-09-29 12:21:59 -0400180 const struct mv88e6xxx_bus_ops *phy_ops;
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000181 struct mutex ppu_mutex;
182 int ppu_disabled;
183 struct work_struct ppu_work;
184 struct timer_list ppu_timer;
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000185
Barry Grussling3675c8d2013-01-08 16:05:53 +0000186 /* This mutex serialises access to the statistics unit.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000187 * Hold this mutex over snapshot + dump sequences.
188 */
189 struct mutex stats_mutex;
Peter Korsgaardec80bfc2011-04-05 03:03:56 +0000190
Andrew Lunn52638f72016-05-10 23:27:22 +0200191 /* A switch may have a GPIO line tied to its reset pin. Parse
192 * this from the device tree, and use it before performing
193 * switch soft reset.
194 */
195 struct gpio_desc *reset;
Andrew Lunnf8cd8752016-05-10 23:27:25 +0200196
197 /* set to size of eeprom if supported by the switch */
198 int eeprom_len;
Andrew Lunnb516d452016-06-04 21:17:06 +0200199
Andrew Lunna3c53be52017-01-24 14:53:50 +0100200 /* List of mdio busses */
201 struct list_head mdios;
Andrew Lunndc30c352016-10-16 19:56:49 +0200202
203 /* There can be two interrupt controllers, which are chained
204 * off a GPIO as interrupt source
205 */
206 struct mv88e6xxx_irq g1_irq;
207 struct mv88e6xxx_irq g2_irq;
208 int irq;
Andrew Lunn8e757eb2016-11-20 20:14:18 +0100209 int device_irq;
Andrew Lunnfcd25162017-02-09 00:03:42 +0100210 int watchdog_irq;
Andrew Lunn09776442018-01-14 02:32:44 +0100211 int atu_prob_irq;
Andrew Lunn62eb1162018-01-14 02:32:45 +0100212 int vtu_prob_irq;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000213};
214
Vivien Didelotc08026a2016-09-29 12:21:59 -0400215struct mv88e6xxx_bus_ops {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400216 int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
217 int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400218};
219
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100220struct mv88e6xxx_mdio_bus {
Andrew Lunna3c53be52017-01-24 14:53:50 +0100221 struct mii_bus *bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100222 struct mv88e6xxx_chip *chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +0100223 struct list_head list;
224 bool external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100225};
226
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400227struct mv88e6xxx_ops {
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400228 /* Ingress Rate Limit unit (IRL) operations */
229 int (*irl_init_all)(struct mv88e6xxx_chip *chip, int port);
230
Vivien Didelotee4dc2e72016-09-29 12:22:02 -0400231 int (*get_eeprom)(struct mv88e6xxx_chip *chip,
232 struct ethtool_eeprom *eeprom, u8 *data);
233 int (*set_eeprom)(struct mv88e6xxx_chip *chip,
234 struct ethtool_eeprom *eeprom, u8 *data);
235
Vivien Didelotb073d4e2016-09-29 12:22:01 -0400236 int (*set_switch_mac)(struct mv88e6xxx_chip *chip, u8 *addr);
237
Andrew Lunnee26a222017-01-24 14:53:48 +0100238 int (*phy_read)(struct mv88e6xxx_chip *chip,
239 struct mii_bus *bus,
240 int addr, int reg, u16 *val);
241 int (*phy_write)(struct mv88e6xxx_chip *chip,
242 struct mii_bus *bus,
243 int addr, int reg, u16 val);
Vivien Didelot08ef7f12016-11-04 03:23:32 +0100244
Vivien Didelot9e907d72017-07-17 13:03:43 -0400245 /* Priority Override Table operations */
246 int (*pot_clear)(struct mv88e6xxx_chip *chip);
247
Vivien Didelota199d8b2016-12-05 17:30:28 -0500248 /* PHY Polling Unit (PPU) operations */
249 int (*ppu_enable)(struct mv88e6xxx_chip *chip);
250 int (*ppu_disable)(struct mv88e6xxx_chip *chip);
251
Vivien Didelot17e708b2016-12-05 17:30:27 -0500252 /* Switch Software Reset */
253 int (*reset)(struct mv88e6xxx_chip *chip);
254
Vivien Didelota0a0f622016-11-04 03:23:34 +0100255 /* RGMII Receive/Transmit Timing Control
256 * Add delay on PHY_INTERFACE_MODE_RGMII_*ID, no delay otherwise.
257 */
258 int (*port_set_rgmii_delay)(struct mv88e6xxx_chip *chip, int port,
259 phy_interface_t mode);
260
Vivien Didelot08ef7f12016-11-04 03:23:32 +0100261#define LINK_FORCED_DOWN 0
262#define LINK_FORCED_UP 1
263#define LINK_UNFORCED -2
264
265 /* Port's MAC link state
266 * Use LINK_FORCED_UP or LINK_FORCED_DOWN to force link up or down,
267 * or LINK_UNFORCED for normal link detection.
268 */
269 int (*port_set_link)(struct mv88e6xxx_chip *chip, int port, int link);
Vivien Didelot7f1ae072016-11-04 03:23:33 +0100270
271#define DUPLEX_UNFORCED -2
272
273 /* Port's MAC duplex mode
274 *
275 * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
276 * or DUPLEX_UNFORCED for normal duplex detection.
277 */
278 int (*port_set_duplex)(struct mv88e6xxx_chip *chip, int port, int dup);
Vivien Didelot96a2b402016-11-04 03:23:35 +0100279
280#define SPEED_MAX INT_MAX
281#define SPEED_UNFORCED -2
282
283 /* Port's MAC speed (in Mbps)
284 *
285 * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
286 * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value.
287 */
288 int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed);
Andrew Lunna605a0f2016-11-21 23:26:58 +0100289
Andrew Lunnef0a7312016-12-03 04:35:16 +0100290 int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port);
291
Andrew Lunn56995cb2016-12-03 04:35:19 +0100292 int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port,
293 enum mv88e6xxx_frame_mode mode);
Vivien Didelot601aeed2017-03-11 16:13:00 -0500294 int (*port_set_egress_floods)(struct mv88e6xxx_chip *chip, int port,
295 bool unicast, bool multicast);
Andrew Lunn56995cb2016-12-03 04:35:19 +0100296 int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
297 u16 etype);
Vivien Didelotcd782652017-06-08 18:34:13 -0400298 int (*port_set_jumbo_size)(struct mv88e6xxx_chip *chip, int port,
299 size_t size);
Andrew Lunn56995cb2016-12-03 04:35:19 +0100300
Andrew Lunnef70b112016-12-03 04:45:18 +0100301 int (*port_egress_rate_limiting)(struct mv88e6xxx_chip *chip, int port);
Vivien Didelot08984322017-06-08 18:34:12 -0400302 int (*port_pause_limit)(struct mv88e6xxx_chip *chip, int port, u8 in,
303 u8 out);
Vivien Didelotc8c94892017-03-11 16:13:01 -0500304 int (*port_disable_learn_limit)(struct mv88e6xxx_chip *chip, int port);
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -0500305 int (*port_disable_pri_override)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnef70b112016-12-03 04:45:18 +0100306
Andrew Lunnf39908d2017-02-04 20:02:50 +0100307 /* CMODE control what PHY mode the MAC will use, eg. SGMII, RGMII, etc.
308 * Some chips allow this to be configured on specific ports.
309 */
310 int (*port_set_cmode)(struct mv88e6xxx_chip *chip, int port,
311 phy_interface_t mode);
312
Andrew Lunna23b2962017-02-04 20:15:28 +0100313 /* Some devices have a per port register indicating what is
314 * the upstream port this port should forward to.
315 */
316 int (*port_set_upstream_port)(struct mv88e6xxx_chip *chip, int port,
317 int upstream_port);
318
Andrew Lunna605a0f2016-11-21 23:26:58 +0100319 /* Snapshot the statistics for a port. The statistics can then
320 * be read back a leisure but still with a consistent view.
321 */
322 int (*stats_snapshot)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnde2273872016-11-21 23:27:01 +0100323
324 /* Set the histogram mode for statistics, when the control registers
325 * are separated out of the STATS_OP register.
326 */
327 int (*stats_set_histogram)(struct mv88e6xxx_chip *chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100328
329 /* Return the number of strings describing statistics */
330 int (*stats_get_sset_count)(struct mv88e6xxx_chip *chip);
331 void (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
Andrew Lunn052f9472016-11-21 23:27:03 +0100332 void (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
333 uint64_t *data);
Vivien Didelotfa8d1172017-06-08 18:34:11 -0400334 int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
335 int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnfcd25162017-02-09 00:03:42 +0100336 const struct mv88e6xxx_irq_ops *watchdog_ops;
Andrew Lunn6e55f692016-12-03 04:45:16 +0100337
Andrew Lunn6e55f692016-12-03 04:45:16 +0100338 int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
Vivien Didelotf1394b72017-05-01 14:05:22 -0400339
Andrew Lunn6d917822017-05-26 01:03:21 +0200340 /* Power on/off a SERDES interface */
341 int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, bool on);
342
Vivien Didelotf1394b72017-05-01 14:05:22 -0400343 /* VLAN Translation Unit operations */
344 int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
345 struct mv88e6xxx_vtu_entry *entry);
Vivien Didelot0ad5daf2017-05-01 14:05:23 -0400346 int (*vtu_loadpurge)(struct mv88e6xxx_chip *chip,
347 struct mv88e6xxx_vtu_entry *entry);
Brandon Streiff0d632c32018-02-14 01:07:44 +0100348
349 /* Interface to the AVB/PTP registers */
350 const struct mv88e6xxx_avb_ops *avb_ops;
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400351};
352
Andrew Lunnfcd25162017-02-09 00:03:42 +0100353struct mv88e6xxx_irq_ops {
354 /* Action to be performed when the interrupt happens */
355 int (*irq_action)(struct mv88e6xxx_chip *chip, int irq);
356 /* Setup the hardware to generate the interrupt */
357 int (*irq_setup)(struct mv88e6xxx_chip *chip);
358 /* Reset the hardware to stop generating the interrupt */
359 void (*irq_free)(struct mv88e6xxx_chip *chip);
360};
361
Brandon Streiff0d632c32018-02-14 01:07:44 +0100362struct mv88e6xxx_avb_ops {
363 /* Access port-scoped Precision Time Protocol registers */
364 int (*port_ptp_read)(struct mv88e6xxx_chip *chip, int port, int addr,
365 u16 *data, int len);
366 int (*port_ptp_write)(struct mv88e6xxx_chip *chip, int port, int addr,
367 u16 data);
368
369 /* Access global Precision Time Protocol registers */
370 int (*ptp_read)(struct mv88e6xxx_chip *chip, int addr, u16 *data,
371 int len);
372 int (*ptp_write)(struct mv88e6xxx_chip *chip, int addr, u16 data);
373
374 /* Access global Time Application Interface registers */
375 int (*tai_read)(struct mv88e6xxx_chip *chip, int addr, u16 *data,
376 int len);
377 int (*tai_write)(struct mv88e6xxx_chip *chip, int addr, u16 data);
378};
379
Andrew Lunndfafe442016-11-21 23:27:02 +0100380#define STATS_TYPE_PORT BIT(0)
381#define STATS_TYPE_BANK0 BIT(1)
382#define STATS_TYPE_BANK1 BIT(2)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100383
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000384struct mv88e6xxx_hw_stat {
385 char string[ETH_GSTRING_LEN];
386 int sizeof_stat;
387 int reg;
Andrew Lunndfafe442016-11-21 23:27:02 +0100388 int type;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000389};
390
Vivien Didelotf3645652017-03-30 17:37:07 -0400391static inline bool mv88e6xxx_has_pvt(struct mv88e6xxx_chip *chip)
392{
393 return chip->info->pvt;
394}
395
Vivien Didelotde333762016-09-29 12:21:56 -0400396static inline unsigned int mv88e6xxx_num_databases(struct mv88e6xxx_chip *chip)
397{
398 return chip->info->num_databases;
399}
400
Vivien Didelot370b4ff2016-09-29 12:21:57 -0400401static inline unsigned int mv88e6xxx_num_ports(struct mv88e6xxx_chip *chip)
402{
403 return chip->info->num_ports;
404}
405
Vivien Didelot4d294af2017-03-11 16:12:47 -0500406static inline u16 mv88e6xxx_port_mask(struct mv88e6xxx_chip *chip)
407{
408 return GENMASK(mv88e6xxx_num_ports(chip) - 1, 0);
409}
410
Vivien Didelotec561272016-09-02 14:45:33 -0400411int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
412int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
413int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
414 u16 update);
415int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200416struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -0400417
418#endif /* _MV88E6XXX_CHIP_H */