blob: 1f75e7a886337c1f02d31a8de146e62fe1a12506 [file] [log] [blame]
Vivien Didelotec561272016-09-02 14:45:33 -04001/*
2 * Marvell 88E6xxx Switch Global 2 Registers support (device address 0x1C)
3 *
4 * Copyright (c) 2008 Marvell Semiconductor
5 *
Vivien Didelot4333d612017-03-28 15:10:36 -04006 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
7 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Vivien Didelotec561272016-09-02 14:45:33 -04008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#ifndef _MV88E6XXX_GLOBAL2_H
16#define _MV88E6XXX_GLOBAL2_H
17
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040018#include "chip.h"
Vivien Didelotec561272016-09-02 14:45:33 -040019
Vivien Didelotd23a83f2017-06-02 17:06:19 -040020#define ADDR_GLOBAL2 0x1c
21
22#define GLOBAL2_INT_SOURCE 0x00
23#define GLOBAL2_INT_SOURCE_WATCHDOG 15
24#define GLOBAL2_INT_MASK 0x01
Vivien Didelot6bff47b2017-06-19 10:55:40 -040025
26/* Offset 0x02: MGMT Enable Register 2x */
27#define MV88E6XXX_G2_MGMT_EN_2X 0x02
28
29/* Offset 0x03: MGMT Enable Register 0x */
30#define MV88E6XXX_G2_MGMT_EN_0X 0x03
31
Vivien Didelotd23a83f2017-06-02 17:06:19 -040032#define GLOBAL2_FLOW_CONTROL 0x04
Vivien Didelot6bff47b2017-06-19 10:55:40 -040033
34/* Offset 0x05: Switch Management Register */
35#define MV88E6XXX_G2_SWITCH_MGMT 0x05
36#define MV88E6XXX_G2_SWITCH_MGMT_USE_DOUBLE_TAG_DATA 0x8000
37#define MV88E6XXX_G2_SWITCH_MGMT_PREVENT_LOOPS 0x4000
38#define MV88E6XXX_G2_SWITCH_MGMT_FLOW_CTL_MSG 0x2000
39#define MV88E6XXX_G2_SWITCH_MGMT_FORCE_FLOW_CTL_PRI 0x0080
40#define MV88E6XXX_G2_SWITCH_MGMT_RSVD2CPU 0x0008
Vivien Didelot067e4742017-06-19 10:55:39 -040041
42/* Offset 0x06: Device Mapping Table Register */
43#define MV88E6XXX_G2_DEVICE_MAPPING 0x06
44#define MV88E6XXX_G2_DEVICE_MAPPING_UPDATE 0x8000
45#define MV88E6XXX_G2_DEVICE_MAPPING_DEV_MASK 0x1f00
46#define MV88E6XXX_G2_DEVICE_MAPPING_PORT_MASK 0x000f
Vivien Didelot56dc7342017-06-19 10:55:38 -040047
48/* Offset 0x07: Trunk Mask Table Register */
49#define MV88E6XXX_G2_TRUNK_MASK 0x07
50#define MV88E6XXX_G2_TRUNK_MASK_UPDATE 0x8000
51#define MV88E6XXX_G2_TRUNK_MASK_NUM_MASK 0x7000
52#define MV88E6XXX_G2_TRUNK_MASK_HASH 0x0800
53
54/* Offset 0x08: Trunk Mapping Table Register */
55#define MV88E6XXX_G2_TRUNK_MAPPING 0x08
56#define MV88E6XXX_G2_TRUNK_MAPPING_UPDATE 0x8000
57#define MV88E6XXX_G2_TRUNK_MAPPING_ID_MASK 0x7800
Vivien Didelotcd8da8b2017-06-19 10:55:36 -040058
59/* Offset 0x09: Ingress Rate Command Register */
60#define MV88E6XXX_G2_IRL_CMD 0x09
61#define MV88E6XXX_G2_IRL_CMD_BUSY 0x8000
62#define MV88E6352_G2_IRL_CMD_OP_MASK 0x7000
63#define MV88E6352_G2_IRL_CMD_OP_NOOP 0x0000
64#define MV88E6352_G2_IRL_CMD_OP_INIT_ALL 0x1000
65#define MV88E6352_G2_IRL_CMD_OP_INIT_RES 0x2000
66#define MV88E6352_G2_IRL_CMD_OP_WRITE_REG 0x3000
67#define MV88E6352_G2_IRL_CMD_OP_READ_REG 0x4000
68#define MV88E6390_G2_IRL_CMD_OP_MASK 0x6000
69#define MV88E6390_G2_IRL_CMD_OP_READ_REG 0x0000
70#define MV88E6390_G2_IRL_CMD_OP_INIT_ALL 0x2000
71#define MV88E6390_G2_IRL_CMD_OP_INIT_RES 0x4000
72#define MV88E6390_G2_IRL_CMD_OP_WRITE_REG 0x6000
73#define MV88E6352_G2_IRL_CMD_PORT_MASK 0x0f00
74#define MV88E6390_G2_IRL_CMD_PORT_MASK 0x1f00
75#define MV88E6XXX_G2_IRL_CMD_RES_MASK 0x00e0
76#define MV88E6XXX_G2_IRL_CMD_REG_MASK 0x000f
77
78/* Offset 0x0A: Ingress Rate Data Register */
79#define MV88E6XXX_G2_IRL_DATA 0x0a
80#define MV88E6XXX_G2_IRL_DATA_MASK 0xffff
81
Vivien Didelot67d1ea82017-06-19 10:55:41 -040082/* Offset 0x0B: Cross-chip Port VLAN Register */
83#define MV88E6XXX_G2_PVT_ADDR 0x0b
84#define MV88E6XXX_G2_PVT_ADDR_BUSY 0x8000
85#define MV88E6XXX_G2_PVT_ADDR_OP_MASK 0x7000
86#define MV88E6XXX_G2_PVT_ADDR_OP_INIT_ONES 0x1000
87#define MV88E6XXX_G2_PVT_ADDR_OP_WRITE_PVLAN 0x3000
88#define MV88E6XXX_G2_PVT_ADDR_OP_READ 0x4000
89#define MV88E6XXX_G2_PVT_ADDR_PTR_MASK 0x01ff
90
91/* Offset 0x0C: Cross-chip Port VLAN Data Register */
92#define MV88E6XXX_G2_PVT_DATA 0x0c
93#define MV88E6XXX_G2_PVT_DATA_MASK 0x7f
94
Vivien Dideloted441522017-06-19 10:55:43 -040095/* Offset 0x0D: Switch MAC/WoL/WoF Register */
96#define MV88E6XXX_G2_SWITCH_MAC 0x0d
97#define MV88E6XXX_G2_SWITCH_MAC_UPDATE 0x8000
98#define MV88E6XXX_G2_SWITCH_MAC_PTR_MASK 0x1f00
99#define MV88E6XXX_G2_SWITCH_MAC_DATA_MASK 0x00ff
100
Vivien Didelotd23a83f2017-06-02 17:06:19 -0400101#define GLOBAL2_ATU_STATS 0x0e
102#define GLOBAL2_PRIO_OVERRIDE 0x0f
103#define GLOBAL2_PRIO_OVERRIDE_FORCE_SNOOP BIT(7)
104#define GLOBAL2_PRIO_OVERRIDE_SNOOP_SHIFT 4
105#define GLOBAL2_PRIO_OVERRIDE_FORCE_ARP BIT(3)
106#define GLOBAL2_PRIO_OVERRIDE_ARP_SHIFT 0
Vivien Didelot7fc8c9d2017-06-19 10:55:42 -0400107
108/* Offset 0x14: EEPROM Command */
109#define MV88E6XXX_G2_EEPROM_CMD 0x14
110#define MV88E6XXX_G2_EEPROM_CMD_BUSY 0x8000
111#define MV88E6XXX_G2_EEPROM_CMD_OP_MASK 0x7000
112#define MV88E6XXX_G2_EEPROM_CMD_OP_WRITE 0x3000
113#define MV88E6XXX_G2_EEPROM_CMD_OP_READ 0x4000
114#define MV88E6XXX_G2_EEPROM_CMD_OP_LOAD 0x6000
115#define MV88E6XXX_G2_EEPROM_CMD_RUNNING 0x0800
116#define MV88E6XXX_G2_EEPROM_CMD_WRITE_EN 0x0400
117#define MV88E6352_G2_EEPROM_CMD_ADDR_MASK 0x00ff
118#define MV88E6390_G2_EEPROM_CMD_DATA_MASK 0x00ff
119
120/* Offset 0x15: EEPROM Data */
121#define MV88E6352_G2_EEPROM_DATA 0x15
122#define MV88E6352_G2_EEPROM_DATA_MASK 0xffff
123
124/* Offset 0x15: EEPROM Addr */
125#define MV88E6390_G2_EEPROM_ADDR 0x15
126#define MV88E6390_G2_EEPROM_ADDR_MASK 0xffff
127
Vivien Didelotd23a83f2017-06-02 17:06:19 -0400128#define GLOBAL2_PTP_AVB_OP 0x16
129#define GLOBAL2_PTP_AVB_DATA 0x17
Vivien Didelotd23a83f2017-06-02 17:06:19 -0400130
Vivien Didelote289ef02017-06-19 10:55:37 -0400131/* Offset 0x18: SMI PHY Command Register */
132#define MV88E6XXX_G2_SMI_PHY_CMD 0x18
133#define MV88E6XXX_G2_SMI_PHY_CMD_BUSY 0x8000
134#define MV88E6390_G2_SMI_PHY_CMD_FUNC_MASK 0x6000
135#define MV88E6390_G2_SMI_PHY_CMD_FUNC_INTERNAL 0x0000
136#define MV88E6390_G2_SMI_PHY_CMD_FUNC_EXTERNAL 0x2000
137#define MV88E6390_G2_SMI_PHY_CMD_FUNC_SETUP 0x4000
138#define MV88E6XXX_G2_SMI_PHY_CMD_MODE_MASK 0x1000
139#define MV88E6XXX_G2_SMI_PHY_CMD_MODE_45 0x0000
140#define MV88E6XXX_G2_SMI_PHY_CMD_MODE_22 0x1000
141#define MV88E6XXX_G2_SMI_PHY_CMD_OP_MASK 0x0c00
142#define MV88E6XXX_G2_SMI_PHY_CMD_OP_22_WRITE_DATA 0x0400
143#define MV88E6XXX_G2_SMI_PHY_CMD_OP_22_READ_DATA 0x0800
144#define MV88E6XXX_G2_SMI_PHY_CMD_OP_45_WRITE_ADDR 0x0000
145#define MV88E6XXX_G2_SMI_PHY_CMD_OP_45_WRITE_DATA 0x0400
146#define MV88E6XXX_G2_SMI_PHY_CMD_OP_45_READ_DATA_INC 0x0800
147#define MV88E6XXX_G2_SMI_PHY_CMD_OP_45_READ_DATA 0x0c00
148#define MV88E6XXX_G2_SMI_PHY_CMD_DEV_ADDR_MASK 0x03e0
149#define MV88E6XXX_G2_SMI_PHY_CMD_REG_ADDR_MASK 0x001f
150#define MV88E6XXX_G2_SMI_PHY_CMD_SETUP_PTR_MASK 0x03ff
151
152/* Offset 0x19: SMI PHY Data Register */
153#define MV88E6XXX_G2_SMI_PHY_DATA 0x19
154
Vivien Didelotd23a83f2017-06-02 17:06:19 -0400155#define GLOBAL2_SCRATCH_MISC 0x1a
156#define GLOBAL2_SCRATCH_BUSY BIT(15)
157#define GLOBAL2_SCRATCH_REGISTER_SHIFT 8
158#define GLOBAL2_SCRATCH_VALUE_MASK 0xff
Vivien Didelot3b19df72017-06-19 10:55:44 -0400159
160/* Offset 0x1B: Watch Dog Control Register */
161#define MV88E6352_G2_WDOG_CTL 0x1b
162#define MV88E6352_G2_WDOG_CTL_EGRESS_EVENT 0x0080
163#define MV88E6352_G2_WDOG_CTL_RMU_TIMEOUT 0x0040
164#define MV88E6352_G2_WDOG_CTL_QC_ENABLE 0x0020
165#define MV88E6352_G2_WDOG_CTL_EGRESS_HISTORY 0x0010
166#define MV88E6352_G2_WDOG_CTL_EGRESS_ENABLE 0x0008
167#define MV88E6352_G2_WDOG_CTL_FORCE_IRQ 0x0004
168#define MV88E6352_G2_WDOG_CTL_HISTORY 0x0002
169#define MV88E6352_G2_WDOG_CTL_SWRESET 0x0001
170
171/* Offset 0x1B: Watch Dog Control Register */
172#define MV88E6390_G2_WDOG_CTL 0x1b
173#define MV88E6390_G2_WDOG_CTL_UPDATE 0x8000
174#define MV88E6390_G2_WDOG_CTL_PTR_MASK 0x7f00
175#define MV88E6390_G2_WDOG_CTL_PTR_INT_SOURCE 0x0000
176#define MV88E6390_G2_WDOG_CTL_PTR_INT_STS 0x1000
177#define MV88E6390_G2_WDOG_CTL_PTR_INT_ENABLE 0x1100
178#define MV88E6390_G2_WDOG_CTL_PTR_EVENT 0x1200
179#define MV88E6390_G2_WDOG_CTL_PTR_HISTORY 0x1300
180#define MV88E6390_G2_WDOG_CTL_DATA_MASK 0x00ff
181#define MV88E6390_G2_WDOG_CTL_CUT_THROUGH 0x0008
182#define MV88E6390_G2_WDOG_CTL_QUEUE_CONTROLLER 0x0004
183#define MV88E6390_G2_WDOG_CTL_EGRESS 0x0002
184#define MV88E6390_G2_WDOG_CTL_FORCE_IRQ 0x0001
185
Vivien Didelotd23a83f2017-06-02 17:06:19 -0400186#define GLOBAL2_QOS_WEIGHT 0x1c
187#define GLOBAL2_MISC 0x1d
188#define GLOBAL2_MISC_5_BIT_PORT BIT(14)
189
Vivien Didelotca070c12016-09-02 14:45:34 -0400190#ifdef CONFIG_NET_DSA_MV88E6XXX_GLOBAL2
191
192static inline int mv88e6xxx_g2_require(struct mv88e6xxx_chip *chip)
193{
194 return 0;
195}
196
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400197int mv88e6352_g2_irl_init_all(struct mv88e6xxx_chip *chip, int port);
198int mv88e6390_g2_irl_init_all(struct mv88e6xxx_chip *chip, int port);
199
Andrew Lunnee26a222017-01-24 14:53:48 +0100200int mv88e6xxx_g2_smi_phy_read(struct mv88e6xxx_chip *chip,
201 struct mii_bus *bus,
202 int addr, int reg, u16 *val);
203int mv88e6xxx_g2_smi_phy_write(struct mv88e6xxx_chip *chip,
204 struct mii_bus *bus,
205 int addr, int reg, u16 val);
Vivien Didelotec561272016-09-02 14:45:33 -0400206int mv88e6xxx_g2_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr);
Vivien Didelot98fc3c62017-01-12 18:07:16 -0500207
208int mv88e6xxx_g2_get_eeprom8(struct mv88e6xxx_chip *chip,
209 struct ethtool_eeprom *eeprom, u8 *data);
210int mv88e6xxx_g2_set_eeprom8(struct mv88e6xxx_chip *chip,
211 struct ethtool_eeprom *eeprom, u8 *data);
212
Vivien Didelotec561272016-09-02 14:45:33 -0400213int mv88e6xxx_g2_get_eeprom16(struct mv88e6xxx_chip *chip,
214 struct ethtool_eeprom *eeprom, u8 *data);
215int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip,
216 struct ethtool_eeprom *eeprom, u8 *data);
Vivien Didelot98fc3c62017-01-12 18:07:16 -0500217
Vivien Didelot17a15942017-03-30 17:37:09 -0400218int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip, int src_dev,
219 int src_port, u16 data);
Vivien Didelot81228992017-03-30 17:37:08 -0400220int mv88e6xxx_g2_misc_4_bit_port(struct mv88e6xxx_chip *chip);
221
Vivien Didelotec561272016-09-02 14:45:33 -0400222int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200223int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip);
224void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip);
Andrew Lunn6e55f692016-12-03 04:45:16 +0100225int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
Vivien Didelotec561272016-09-02 14:45:33 -0400226
Andrew Lunnfcd25162017-02-09 00:03:42 +0100227extern const struct mv88e6xxx_irq_ops mv88e6097_watchdog_ops;
Andrew Lunn61303732017-02-09 00:03:43 +0100228extern const struct mv88e6xxx_irq_ops mv88e6390_watchdog_ops;
Andrew Lunnfcd25162017-02-09 00:03:42 +0100229
Vivien Didelotca070c12016-09-02 14:45:34 -0400230#else /* !CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 */
231
232static inline int mv88e6xxx_g2_require(struct mv88e6xxx_chip *chip)
233{
234 if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_GLOBAL2)) {
235 dev_err(chip->dev, "this chip requires CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 enabled\n");
236 return -EOPNOTSUPP;
237 }
238
239 return 0;
240}
241
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400242static inline int mv88e6352_g2_irl_init_all(struct mv88e6xxx_chip *chip,
243 int port)
244{
245 return -EOPNOTSUPP;
246}
247
248static inline int mv88e6390_g2_irl_init_all(struct mv88e6xxx_chip *chip,
249 int port)
250{
251 return -EOPNOTSUPP;
252}
253
Vivien Didelotca070c12016-09-02 14:45:34 -0400254static inline int mv88e6xxx_g2_smi_phy_read(struct mv88e6xxx_chip *chip,
Andrew Lunnee26a222017-01-24 14:53:48 +0100255 struct mii_bus *bus,
Vivien Didelotca070c12016-09-02 14:45:34 -0400256 int addr, int reg, u16 *val)
257{
258 return -EOPNOTSUPP;
259}
260
261static inline int mv88e6xxx_g2_smi_phy_write(struct mv88e6xxx_chip *chip,
Andrew Lunnee26a222017-01-24 14:53:48 +0100262 struct mii_bus *bus,
Vivien Didelotca070c12016-09-02 14:45:34 -0400263 int addr, int reg, u16 val)
264{
265 return -EOPNOTSUPP;
266}
267
268static inline int mv88e6xxx_g2_set_switch_mac(struct mv88e6xxx_chip *chip,
269 u8 *addr)
270{
271 return -EOPNOTSUPP;
272}
273
Vivien Didelot98fc3c62017-01-12 18:07:16 -0500274static inline int mv88e6xxx_g2_get_eeprom8(struct mv88e6xxx_chip *chip,
275 struct ethtool_eeprom *eeprom,
276 u8 *data)
277{
278 return -EOPNOTSUPP;
279}
280
281static inline int mv88e6xxx_g2_set_eeprom8(struct mv88e6xxx_chip *chip,
282 struct ethtool_eeprom *eeprom,
283 u8 *data)
284{
285 return -EOPNOTSUPP;
286}
287
Vivien Didelotca070c12016-09-02 14:45:34 -0400288static inline int mv88e6xxx_g2_get_eeprom16(struct mv88e6xxx_chip *chip,
289 struct ethtool_eeprom *eeprom,
290 u8 *data)
291{
292 return -EOPNOTSUPP;
293}
294
295static inline int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip,
296 struct ethtool_eeprom *eeprom,
297 u8 *data)
298{
299 return -EOPNOTSUPP;
300}
301
Arnd Bergmann59b2c312017-05-29 14:56:01 +0200302static inline int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip,
303 int src_dev, int src_port, u16 data)
Vivien Didelot17a15942017-03-30 17:37:09 -0400304{
305 return -EOPNOTSUPP;
306}
307
Arnd Bergmann59b2c312017-05-29 14:56:01 +0200308static inline int mv88e6xxx_g2_misc_4_bit_port(struct mv88e6xxx_chip *chip)
Vivien Didelot81228992017-03-30 17:37:08 -0400309{
310 return -EOPNOTSUPP;
311}
312
Vivien Didelotca070c12016-09-02 14:45:34 -0400313static inline int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip)
314{
315 return -EOPNOTSUPP;
316}
317
Andrew Lunndc30c352016-10-16 19:56:49 +0200318static inline int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip)
319{
320 return -EOPNOTSUPP;
321}
322
323static inline void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip)
324{
325}
326
Andrew Lunn6e55f692016-12-03 04:45:16 +0100327static inline int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
328{
329 return -EOPNOTSUPP;
330}
331
Andrew Lunnfcd25162017-02-09 00:03:42 +0100332static const struct mv88e6xxx_irq_ops mv88e6097_watchdog_ops = {};
Andrew Lunn61303732017-02-09 00:03:43 +0100333static const struct mv88e6xxx_irq_ops mv88e6390_watchdog_ops = {};
Andrew Lunnfcd25162017-02-09 00:03:42 +0100334
Vivien Didelotca070c12016-09-02 14:45:34 -0400335#endif /* CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 */
336
Vivien Didelotec561272016-09-02 14:45:33 -0400337#endif /* _MV88E6XXX_GLOBAL2_H */