1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/device.h>
3 #include <linux/etherdevice.h>
4 #include <linux/gpio/driver.h>
6 /* The VSC7395 switch chips have 5+1 ports which means 5 ordinary ports and
7 * a sixth CPU port facing the processor with an RGMII interface. These ports
8 * are numbered 0..4 and 6, so they leave a "hole" in the port map for port 5,
11 * The VSC7398 has 8 ports, port 7 is again the CPU port.
13 * We allocate 8 ports and avoid access to the nonexistent ports.
15 #define VSC73XX_MAX_NUM_PORTS 8
18 * struct vsc73xx_portinfo - port data structure: contains storage data
19 * @pvid_vlan_filtering: pvid vlan number used in vlan filtering mode
20 * @pvid_tag_8021q: pvid vlan number used in tag_8021q mode
21 * @pvid_vlan_filtering_configured: informs if port has configured pvid in vlan
23 * @pvid_tag_8021q_configured: imforms if port have configured pvid in tag_8021q
26 struct vsc73xx_portinfo
{
27 u16 pvid_vlan_filtering
;
29 bool pvid_vlan_filtering_configured
;
30 bool pvid_tag_8021q_configured
;
34 * struct vsc73xx - VSC73xx state container: main data structure
35 * @dev: The device pointer
36 * @reset: The descriptor for the GPIO line tied to the reset pin
37 * @ds: Pointer to the DSA core structure
38 * @gc: Main structure of the GPIO controller
39 * @chipid: Storage for the Chip ID value read from the CHIPID register of the
41 * @addr: MAC address used in flow control frames
42 * @ops: Structure with hardware-dependent operations
43 * @priv: Pointer to the configuration interface structure
44 * @portinfo: Storage table portinfo structructures
45 * @vlans: List of configured vlans. Contains port mask and untagged status of
46 * every vlan configured in port vlan operation. It doesn't cover tag_8021q
48 * @fdb_lock: Mutex protects fdb access
52 struct gpio_desc
*reset
;
53 struct dsa_switch
*ds
;
57 const struct vsc73xx_ops
*ops
;
59 struct vsc73xx_portinfo portinfo
[VSC73XX_MAX_NUM_PORTS
];
60 struct list_head vlans
;
61 struct mutex fdb_lock
;
65 * struct vsc73xx_ops - VSC73xx methods container
66 * @read: Method for register reading over the hardware-dependent interface
67 * @write: Method for register writing over the hardware-dependent interface
70 int (*read
)(struct vsc73xx
*vsc
, u8 block
, u8 subblock
, u8 reg
,
72 int (*write
)(struct vsc73xx
*vsc
, u8 block
, u8 subblock
, u8 reg
,
77 * struct vsc73xx_bridge_vlan - VSC73xx driver structure which keeps vlan
80 * @portmask: each bit represents one port
81 * @untagged: each bit represents one port configured with @vid untagged
82 * @list: list structure
84 struct vsc73xx_bridge_vlan
{
88 struct list_head list
;
91 int vsc73xx_is_addr_valid(u8 block
, u8 subblock
);
92 int vsc73xx_probe(struct vsc73xx
*vsc
);
93 void vsc73xx_remove(struct vsc73xx
*vsc
);
94 void vsc73xx_shutdown(struct vsc73xx
*vsc
);