blob: 92e5fd6e23186e976f107aae93a26d1f612747fa [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>
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010019#include <linux/ptp_clock_kernel.h>
20#include <linux/timecounter.h>
Andrew Lunnc6e970a2017-03-28 23:45:06 +020021#include <net/dsa.h>
Vivien Didelot194fea72015-08-10 09:09:47 -040022
Andrew Lunn80c46272015-06-20 18:42:30 +020023#ifndef UINT64_MAX
24#define UINT64_MAX (u64)(~((u64)0))
25#endif
26
Andrew Lunncca8b132015-04-02 04:06:39 +020027#define SMI_CMD 0x00
28#define SMI_CMD_BUSY BIT(15)
29#define SMI_CMD_CLAUSE_22 BIT(12)
30#define SMI_CMD_OP_22_WRITE ((1 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
31#define SMI_CMD_OP_22_READ ((2 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22)
32#define SMI_CMD_OP_45_WRITE_ADDR ((0 << 10) | SMI_CMD_BUSY)
33#define SMI_CMD_OP_45_WRITE_DATA ((1 << 10) | SMI_CMD_BUSY)
34#define SMI_CMD_OP_45_READ_DATA ((2 << 10) | SMI_CMD_BUSY)
35#define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY)
36#define SMI_DATA 0x01
Guenter Roeckb2eb0662015-04-02 04:06:30 +020037
Vivien Didelot3285f9e2016-02-26 13:16:03 -050038#define MV88E6XXX_N_FID 4096
39
Vivien Didelot17a15942017-03-30 17:37:09 -040040/* PVT limits for 4-bit port and 5-bit switch */
41#define MV88E6XXX_MAX_PVT_SWITCHES 32
42#define MV88E6XXX_MAX_PVT_PORTS 16
43
Vivien Didelot31bef4e2017-06-08 18:34:09 -040044enum mv88e6xxx_egress_mode {
45 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
46 MV88E6XXX_EGRESS_MODE_UNTAGGED,
47 MV88E6XXX_EGRESS_MODE_TAGGED,
48 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
49};
50
Andrew Lunn56995cb2016-12-03 04:35:19 +010051enum mv88e6xxx_frame_mode {
52 MV88E6XXX_FRAME_MODE_NORMAL,
53 MV88E6XXX_FRAME_MODE_DSA,
54 MV88E6XXX_FRAME_MODE_PROVIDER,
55 MV88E6XXX_FRAME_MODE_ETHERTYPE,
56};
57
Vivien Didelotf81ec902016-05-09 13:22:58 -040058/* List of supported models */
59enum mv88e6xxx_model {
60 MV88E6085,
61 MV88E6095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +010062 MV88E6097,
Vivien Didelotf81ec902016-05-09 13:22:58 -040063 MV88E6123,
64 MV88E6131,
Gregory CLEMENT15587272017-01-30 20:29:35 +010065 MV88E6141,
Vivien Didelotf81ec902016-05-09 13:22:58 -040066 MV88E6161,
67 MV88E6165,
68 MV88E6171,
69 MV88E6172,
70 MV88E6175,
71 MV88E6176,
72 MV88E6185,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010073 MV88E6190,
74 MV88E6190X,
75 MV88E6191,
Vivien Didelotf81ec902016-05-09 13:22:58 -040076 MV88E6240,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010077 MV88E6290,
Vivien Didelotf81ec902016-05-09 13:22:58 -040078 MV88E6320,
79 MV88E6321,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +010080 MV88E6341,
Vivien Didelotf81ec902016-05-09 13:22:58 -040081 MV88E6350,
82 MV88E6351,
83 MV88E6352,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010084 MV88E6390,
85 MV88E6390X,
Vivien Didelotf81ec902016-05-09 13:22:58 -040086};
87
Vivien Didelot22356472016-04-17 13:24:00 -040088enum mv88e6xxx_family {
89 MV88E6XXX_FAMILY_NONE,
90 MV88E6XXX_FAMILY_6065, /* 6031 6035 6061 6065 */
91 MV88E6XXX_FAMILY_6095, /* 6092 6095 */
92 MV88E6XXX_FAMILY_6097, /* 6046 6085 6096 6097 */
93 MV88E6XXX_FAMILY_6165, /* 6123 6161 6165 */
94 MV88E6XXX_FAMILY_6185, /* 6108 6121 6122 6131 6152 6155 6182 6185 */
95 MV88E6XXX_FAMILY_6320, /* 6320 6321 */
Gregory CLEMENTa75961d2017-01-30 20:29:34 +010096 MV88E6XXX_FAMILY_6341, /* 6141 6341 */
Vivien Didelot22356472016-04-17 13:24:00 -040097 MV88E6XXX_FAMILY_6351, /* 6171 6175 6350 6351 */
98 MV88E6XXX_FAMILY_6352, /* 6172 6176 6240 6352 */
Andrew Lunn1a3b39e2016-11-21 23:26:57 +010099 MV88E6XXX_FAMILY_6390, /* 6190 6190X 6191 6290 6390 6390X */
Vivien Didelot22356472016-04-17 13:24:00 -0400100};
101
Andrew Lunnc0e4dad2017-02-09 00:00:43 +0100102struct mv88e6xxx_ops;
103
Vivien Didelotf6271e62016-04-17 13:23:59 -0400104struct mv88e6xxx_info {
Vivien Didelot22356472016-04-17 13:24:00 -0400105 enum mv88e6xxx_family family;
Vivien Didelotf6271e62016-04-17 13:23:59 -0400106 u16 prod_num;
107 const char *name;
Vivien Didelotcd5a2c82016-04-17 13:24:02 -0400108 unsigned int num_databases;
Vivien Didelot009a2b92016-04-17 13:24:01 -0400109 unsigned int num_ports;
Vivien Didelot3cf3c842017-05-01 14:05:10 -0400110 unsigned int max_vid;
Vivien Didelot9dddd472016-06-20 13:14:10 -0400111 unsigned int port_base_addr;
Vivien Didelota935c052016-09-29 12:21:53 -0400112 unsigned int global1_addr;
Vivien Didelot9069c132017-07-17 13:03:44 -0400113 unsigned int global2_addr;
Vivien Didelotacddbd22016-07-18 20:45:39 -0400114 unsigned int age_time_coeff;
Andrew Lunndc30c352016-10-16 19:56:49 +0200115 unsigned int g1_irqs;
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -0400116 unsigned int g2_irqs;
Vivien Didelotf3645652017-03-30 17:37:07 -0400117 bool pvt;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -0400118
119 /* Multi-chip Addressing Mode.
120 * Some chips respond to only 2 registers of its own SMI device address
121 * when it is non-zero, and use indirect access to internal registers.
122 */
123 bool multi_chip;
Andrew Lunn443d5a12016-12-03 04:35:18 +0100124 enum dsa_tag_protocol tag_protocol;
Vivien Didelote606ca32017-03-11 16:12:55 -0500125
126 /* Mask for FromPort and ToPort value of PortVec used in ATU Move
127 * operation. 0 means that the ATU Move operation is not supported.
128 */
129 u8 atu_move_port_mask;
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400130 const struct mv88e6xxx_ops *ops;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +0100131
132 /* Supports PTP */
133 bool ptp_support;
Vivien Didelotb9b37712015-10-30 19:39:48 -0400134};
135
Vivien Didelotfd231c82015-08-10 09:09:50 -0400136struct mv88e6xxx_atu_entry {
Vivien Didelotfd231c82015-08-10 09:09:50 -0400137 u8 state;
138 bool trunk;
Vivien Didelot01bd96c2017-03-11 16:12:57 -0500139 u16 portvec;
Vivien Didelotfd231c82015-08-10 09:09:50 -0400140 u8 mac[ETH_ALEN];
141};
142
Vivien Didelotb4e47c02016-09-29 12:21:58 -0400143struct mv88e6xxx_vtu_entry {
Vivien Didelotb8fee952015-08-13 12:52:19 -0400144 u16 vid;
145 u16 fid;
Vivien Didelotb8fee952015-08-13 12:52:19 -0400146 u8 sid;
147 bool valid;
Vivien Didelotbd00e052017-05-01 14:05:11 -0400148 u8 member[DSA_MAX_PORTS];
149 u8 state[DSA_MAX_PORTS];
Vivien Didelotb8fee952015-08-13 12:52:19 -0400150};
151
Vivien Didelotc08026a2016-09-29 12:21:59 -0400152struct mv88e6xxx_bus_ops;
Andrew Lunnfcd25162017-02-09 00:03:42 +0100153struct mv88e6xxx_irq_ops;
Brandon Streiff0d632c32018-02-14 01:07:44 +0100154struct mv88e6xxx_avb_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -0400155
Andrew Lunndc30c352016-10-16 19:56:49 +0200156struct mv88e6xxx_irq {
157 u16 masked;
158 struct irq_chip chip;
159 struct irq_domain *domain;
160 unsigned int nirqs;
161};
162
Vivien Didelotfad09c72016-06-21 12:28:20 -0400163struct mv88e6xxx_chip {
Vivien Didelotf6271e62016-04-17 13:23:59 -0400164 const struct mv88e6xxx_info *info;
165
Andrew Lunn7543a6d2016-04-13 02:40:40 +0200166 /* The dsa_switch this private structure is related to */
167 struct dsa_switch *ds;
168
Andrew Lunn158bc062016-04-28 21:24:06 -0400169 /* The device this structure is associated to */
170 struct device *dev;
171
Vivien Didelot9f8b3ee2016-06-20 13:14:05 -0400172 /* This mutex protects the access to the switch registers */
173 struct mutex reg_lock;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000174
Andrew Lunna77d43f2016-04-13 02:40:42 +0200175 /* The MII bus and the address on the bus that is used to
176 * communication with the switch
177 */
Vivien Didelotc08026a2016-09-29 12:21:59 -0400178 const struct mv88e6xxx_bus_ops *smi_ops;
Andrew Lunna77d43f2016-04-13 02:40:42 +0200179 struct mii_bus *bus;
180 int sw_addr;
181
Barry Grussling3675c8d2013-01-08 16:05:53 +0000182 /* Handles automatic disabling and re-enabling of the PHY
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000183 * polling unit.
184 */
Vivien Didelotc08026a2016-09-29 12:21:59 -0400185 const struct mv88e6xxx_bus_ops *phy_ops;
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000186 struct mutex ppu_mutex;
187 int ppu_disabled;
188 struct work_struct ppu_work;
189 struct timer_list ppu_timer;
Lennert Buytenhek2e5f0322008-10-07 13:45:18 +0000190
Barry Grussling3675c8d2013-01-08 16:05:53 +0000191 /* This mutex serialises access to the statistics unit.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000192 * Hold this mutex over snapshot + dump sequences.
193 */
194 struct mutex stats_mutex;
Peter Korsgaardec80bfc2011-04-05 03:03:56 +0000195
Andrew Lunn52638f72016-05-10 23:27:22 +0200196 /* A switch may have a GPIO line tied to its reset pin. Parse
197 * this from the device tree, and use it before performing
198 * switch soft reset.
199 */
200 struct gpio_desc *reset;
Andrew Lunnf8cd8752016-05-10 23:27:25 +0200201
202 /* set to size of eeprom if supported by the switch */
203 int eeprom_len;
Andrew Lunnb516d452016-06-04 21:17:06 +0200204
Andrew Lunna3c53be52017-01-24 14:53:50 +0100205 /* List of mdio busses */
206 struct list_head mdios;
Andrew Lunndc30c352016-10-16 19:56:49 +0200207
208 /* There can be two interrupt controllers, which are chained
209 * off a GPIO as interrupt source
210 */
211 struct mv88e6xxx_irq g1_irq;
212 struct mv88e6xxx_irq g2_irq;
213 int irq;
Andrew Lunn8e757eb2016-11-20 20:14:18 +0100214 int device_irq;
Andrew Lunnfcd25162017-02-09 00:03:42 +0100215 int watchdog_irq;
Andrew Lunn09776442018-01-14 02:32:44 +0100216 int atu_prob_irq;
Andrew Lunn62eb1162018-01-14 02:32:45 +0100217 int vtu_prob_irq;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +0100218
219 /* This cyclecounter abstracts the switch PTP time.
220 * reg_lock must be held for any operation that read()s.
221 */
222 struct cyclecounter tstamp_cc;
223 struct timecounter tstamp_tc;
224 struct delayed_work overflow_work;
225
226 struct ptp_clock *ptp_clock;
227 struct ptp_clock_info ptp_clock_info;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000228};
229
Vivien Didelotc08026a2016-09-29 12:21:59 -0400230struct mv88e6xxx_bus_ops {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400231 int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
232 int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400233};
234
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100235struct mv88e6xxx_mdio_bus {
Andrew Lunna3c53be52017-01-24 14:53:50 +0100236 struct mii_bus *bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100237 struct mv88e6xxx_chip *chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +0100238 struct list_head list;
239 bool external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +0100240};
241
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400242struct mv88e6xxx_ops {
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400243 /* Ingress Rate Limit unit (IRL) operations */
244 int (*irl_init_all)(struct mv88e6xxx_chip *chip, int port);
245
Vivien Didelotee4dc2e72016-09-29 12:22:02 -0400246 int (*get_eeprom)(struct mv88e6xxx_chip *chip,
247 struct ethtool_eeprom *eeprom, u8 *data);
248 int (*set_eeprom)(struct mv88e6xxx_chip *chip,
249 struct ethtool_eeprom *eeprom, u8 *data);
250
Vivien Didelotb073d4e2016-09-29 12:22:01 -0400251 int (*set_switch_mac)(struct mv88e6xxx_chip *chip, u8 *addr);
252
Andrew Lunnee26a222017-01-24 14:53:48 +0100253 int (*phy_read)(struct mv88e6xxx_chip *chip,
254 struct mii_bus *bus,
255 int addr, int reg, u16 *val);
256 int (*phy_write)(struct mv88e6xxx_chip *chip,
257 struct mii_bus *bus,
258 int addr, int reg, u16 val);
Vivien Didelot08ef7f12016-11-04 03:23:32 +0100259
Vivien Didelot9e907d72017-07-17 13:03:43 -0400260 /* Priority Override Table operations */
261 int (*pot_clear)(struct mv88e6xxx_chip *chip);
262
Vivien Didelota199d8b2016-12-05 17:30:28 -0500263 /* PHY Polling Unit (PPU) operations */
264 int (*ppu_enable)(struct mv88e6xxx_chip *chip);
265 int (*ppu_disable)(struct mv88e6xxx_chip *chip);
266
Vivien Didelot17e708b2016-12-05 17:30:27 -0500267 /* Switch Software Reset */
268 int (*reset)(struct mv88e6xxx_chip *chip);
269
Vivien Didelota0a0f622016-11-04 03:23:34 +0100270 /* RGMII Receive/Transmit Timing Control
271 * Add delay on PHY_INTERFACE_MODE_RGMII_*ID, no delay otherwise.
272 */
273 int (*port_set_rgmii_delay)(struct mv88e6xxx_chip *chip, int port,
274 phy_interface_t mode);
275
Vivien Didelot08ef7f12016-11-04 03:23:32 +0100276#define LINK_FORCED_DOWN 0
277#define LINK_FORCED_UP 1
278#define LINK_UNFORCED -2
279
280 /* Port's MAC link state
281 * Use LINK_FORCED_UP or LINK_FORCED_DOWN to force link up or down,
282 * or LINK_UNFORCED for normal link detection.
283 */
284 int (*port_set_link)(struct mv88e6xxx_chip *chip, int port, int link);
Vivien Didelot7f1ae072016-11-04 03:23:33 +0100285
286#define DUPLEX_UNFORCED -2
287
288 /* Port's MAC duplex mode
289 *
290 * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
291 * or DUPLEX_UNFORCED for normal duplex detection.
292 */
293 int (*port_set_duplex)(struct mv88e6xxx_chip *chip, int port, int dup);
Vivien Didelot96a2b402016-11-04 03:23:35 +0100294
295#define SPEED_MAX INT_MAX
296#define SPEED_UNFORCED -2
297
298 /* Port's MAC speed (in Mbps)
299 *
300 * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
301 * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value.
302 */
303 int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed);
Andrew Lunna605a0f2016-11-21 23:26:58 +0100304
Andrew Lunnef0a7312016-12-03 04:35:16 +0100305 int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port);
306
Andrew Lunn56995cb2016-12-03 04:35:19 +0100307 int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port,
308 enum mv88e6xxx_frame_mode mode);
Vivien Didelot601aeed2017-03-11 16:13:00 -0500309 int (*port_set_egress_floods)(struct mv88e6xxx_chip *chip, int port,
310 bool unicast, bool multicast);
Andrew Lunn56995cb2016-12-03 04:35:19 +0100311 int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
312 u16 etype);
Vivien Didelotcd782652017-06-08 18:34:13 -0400313 int (*port_set_jumbo_size)(struct mv88e6xxx_chip *chip, int port,
314 size_t size);
Andrew Lunn56995cb2016-12-03 04:35:19 +0100315
Andrew Lunnef70b112016-12-03 04:45:18 +0100316 int (*port_egress_rate_limiting)(struct mv88e6xxx_chip *chip, int port);
Vivien Didelot08984322017-06-08 18:34:12 -0400317 int (*port_pause_limit)(struct mv88e6xxx_chip *chip, int port, u8 in,
318 u8 out);
Vivien Didelotc8c94892017-03-11 16:13:01 -0500319 int (*port_disable_learn_limit)(struct mv88e6xxx_chip *chip, int port);
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -0500320 int (*port_disable_pri_override)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnef70b112016-12-03 04:45:18 +0100321
Andrew Lunnf39908d2017-02-04 20:02:50 +0100322 /* CMODE control what PHY mode the MAC will use, eg. SGMII, RGMII, etc.
323 * Some chips allow this to be configured on specific ports.
324 */
325 int (*port_set_cmode)(struct mv88e6xxx_chip *chip, int port,
326 phy_interface_t mode);
327
Andrew Lunna23b2962017-02-04 20:15:28 +0100328 /* Some devices have a per port register indicating what is
329 * the upstream port this port should forward to.
330 */
331 int (*port_set_upstream_port)(struct mv88e6xxx_chip *chip, int port,
332 int upstream_port);
333
Andrew Lunna605a0f2016-11-21 23:26:58 +0100334 /* Snapshot the statistics for a port. The statistics can then
335 * be read back a leisure but still with a consistent view.
336 */
337 int (*stats_snapshot)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnde2273872016-11-21 23:27:01 +0100338
339 /* Set the histogram mode for statistics, when the control registers
340 * are separated out of the STATS_OP register.
341 */
342 int (*stats_set_histogram)(struct mv88e6xxx_chip *chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100343
344 /* Return the number of strings describing statistics */
345 int (*stats_get_sset_count)(struct mv88e6xxx_chip *chip);
346 void (*stats_get_strings)(struct mv88e6xxx_chip *chip, uint8_t *data);
Andrew Lunn052f9472016-11-21 23:27:03 +0100347 void (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port,
348 uint64_t *data);
Vivien Didelotfa8d1172017-06-08 18:34:11 -0400349 int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
350 int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port);
Andrew Lunnfcd25162017-02-09 00:03:42 +0100351 const struct mv88e6xxx_irq_ops *watchdog_ops;
Andrew Lunn6e55f692016-12-03 04:45:16 +0100352
Andrew Lunn6e55f692016-12-03 04:45:16 +0100353 int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
Vivien Didelotf1394b72017-05-01 14:05:22 -0400354
Andrew Lunn6d917822017-05-26 01:03:21 +0200355 /* Power on/off a SERDES interface */
356 int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, bool on);
357
Vivien Didelotf1394b72017-05-01 14:05:22 -0400358 /* VLAN Translation Unit operations */
359 int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
360 struct mv88e6xxx_vtu_entry *entry);
Vivien Didelot0ad5daf2017-05-01 14:05:23 -0400361 int (*vtu_loadpurge)(struct mv88e6xxx_chip *chip,
362 struct mv88e6xxx_vtu_entry *entry);
Brandon Streiff0d632c32018-02-14 01:07:44 +0100363
364 /* Interface to the AVB/PTP registers */
365 const struct mv88e6xxx_avb_ops *avb_ops;
Vivien Didelotb3469dd2016-09-29 12:22:00 -0400366};
367
Andrew Lunnfcd25162017-02-09 00:03:42 +0100368struct mv88e6xxx_irq_ops {
369 /* Action to be performed when the interrupt happens */
370 int (*irq_action)(struct mv88e6xxx_chip *chip, int irq);
371 /* Setup the hardware to generate the interrupt */
372 int (*irq_setup)(struct mv88e6xxx_chip *chip);
373 /* Reset the hardware to stop generating the interrupt */
374 void (*irq_free)(struct mv88e6xxx_chip *chip);
375};
376
Brandon Streiff0d632c32018-02-14 01:07:44 +0100377struct mv88e6xxx_avb_ops {
378 /* Access port-scoped Precision Time Protocol registers */
379 int (*port_ptp_read)(struct mv88e6xxx_chip *chip, int port, int addr,
380 u16 *data, int len);
381 int (*port_ptp_write)(struct mv88e6xxx_chip *chip, int port, int addr,
382 u16 data);
383
384 /* Access global Precision Time Protocol registers */
385 int (*ptp_read)(struct mv88e6xxx_chip *chip, int addr, u16 *data,
386 int len);
387 int (*ptp_write)(struct mv88e6xxx_chip *chip, int addr, u16 data);
388
389 /* Access global Time Application Interface registers */
390 int (*tai_read)(struct mv88e6xxx_chip *chip, int addr, u16 *data,
391 int len);
392 int (*tai_write)(struct mv88e6xxx_chip *chip, int addr, u16 data);
393};
394
Andrew Lunndfafe442016-11-21 23:27:02 +0100395#define STATS_TYPE_PORT BIT(0)
396#define STATS_TYPE_BANK0 BIT(1)
397#define STATS_TYPE_BANK1 BIT(2)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100398
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000399struct mv88e6xxx_hw_stat {
400 char string[ETH_GSTRING_LEN];
401 int sizeof_stat;
402 int reg;
Andrew Lunndfafe442016-11-21 23:27:02 +0100403 int type;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000404};
405
Vivien Didelotf3645652017-03-30 17:37:07 -0400406static inline bool mv88e6xxx_has_pvt(struct mv88e6xxx_chip *chip)
407{
408 return chip->info->pvt;
409}
410
Vivien Didelotde333762016-09-29 12:21:56 -0400411static inline unsigned int mv88e6xxx_num_databases(struct mv88e6xxx_chip *chip)
412{
413 return chip->info->num_databases;
414}
415
Vivien Didelot370b4ff2016-09-29 12:21:57 -0400416static inline unsigned int mv88e6xxx_num_ports(struct mv88e6xxx_chip *chip)
417{
418 return chip->info->num_ports;
419}
420
Vivien Didelot4d294af2017-03-11 16:12:47 -0500421static inline u16 mv88e6xxx_port_mask(struct mv88e6xxx_chip *chip)
422{
423 return GENMASK(mv88e6xxx_num_ports(chip) - 1, 0);
424}
425
Vivien Didelotec561272016-09-02 14:45:33 -0400426int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val);
427int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val);
428int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg,
429 u16 update);
430int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask);
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200431struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip);
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -0400432
433#endif /* _MV88E6XXX_CHIP_H */