xref: /linux/drivers/net/dsa/vitesse-vsc73xx.h (revision 96944aafaaa64e6ead1d3d227a1493dd8196a827)
195711cd5SPawel Dembicki /* SPDX-License-Identifier: GPL-2.0 */
295711cd5SPawel Dembicki #include <linux/device.h>
395711cd5SPawel Dembicki #include <linux/etherdevice.h>
495711cd5SPawel Dembicki #include <linux/gpio/driver.h>
595711cd5SPawel Dembicki 
66cc5280aSPawel Dembicki /* The VSC7395 switch chips have 5+1 ports which means 5 ordinary ports and
76cc5280aSPawel Dembicki  * a sixth CPU port facing the processor with an RGMII interface. These ports
86cc5280aSPawel Dembicki  * are numbered 0..4 and 6, so they leave a "hole" in the port map for port 5,
96cc5280aSPawel Dembicki  * which is invalid.
106cc5280aSPawel Dembicki  *
116cc5280aSPawel Dembicki  * The VSC7398 has 8 ports, port 7 is again the CPU port.
126cc5280aSPawel Dembicki  *
136cc5280aSPawel Dembicki  * We allocate 8 ports and avoid access to the nonexistent ports.
146cc5280aSPawel Dembicki  */
156cc5280aSPawel Dembicki #define VSC73XX_MAX_NUM_PORTS	8
166cc5280aSPawel Dembicki 
1795711cd5SPawel Dembicki /**
18*96944aafSPawel Dembicki  * struct vsc73xx - VSC73xx state container: main data structure
19*96944aafSPawel Dembicki  * @dev: The device pointer
20*96944aafSPawel Dembicki  * @reset: The descriptor for the GPIO line tied to the reset pin
21*96944aafSPawel Dembicki  * @ds: Pointer to the DSA core structure
22*96944aafSPawel Dembicki  * @gc: Main structure of the GPIO controller
23*96944aafSPawel Dembicki  * @chipid: Storage for the Chip ID value read from the CHIPID register of the
24*96944aafSPawel Dembicki  *	switch
25*96944aafSPawel Dembicki  * @addr: MAC address used in flow control frames
26*96944aafSPawel Dembicki  * @ops: Structure with hardware-dependent operations
27*96944aafSPawel Dembicki  * @priv: Pointer to the configuration interface structure
2895711cd5SPawel Dembicki  */
2995711cd5SPawel Dembicki struct vsc73xx {
3095711cd5SPawel Dembicki 	struct device			*dev;
3195711cd5SPawel Dembicki 	struct gpio_desc		*reset;
3295711cd5SPawel Dembicki 	struct dsa_switch		*ds;
3395711cd5SPawel Dembicki 	struct gpio_chip		gc;
3495711cd5SPawel Dembicki 	u16				chipid;
3595711cd5SPawel Dembicki 	u8				addr[ETH_ALEN];
3695711cd5SPawel Dembicki 	const struct vsc73xx_ops	*ops;
3795711cd5SPawel Dembicki 	void				*priv;
3895711cd5SPawel Dembicki };
3995711cd5SPawel Dembicki 
40*96944aafSPawel Dembicki /**
41*96944aafSPawel Dembicki  * struct vsc73xx_ops - VSC73xx methods container
42*96944aafSPawel Dembicki  * @read: Method for register reading over the hardware-dependent interface
43*96944aafSPawel Dembicki  * @write: Method for register writing over the hardware-dependent interface
44*96944aafSPawel Dembicki  */
4595711cd5SPawel Dembicki struct vsc73xx_ops {
4695711cd5SPawel Dembicki 	int (*read)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg,
4795711cd5SPawel Dembicki 		    u32 *val);
4895711cd5SPawel Dembicki 	int (*write)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg,
4995711cd5SPawel Dembicki 		     u32 val);
5095711cd5SPawel Dembicki };
5195711cd5SPawel Dembicki 
5295711cd5SPawel Dembicki int vsc73xx_is_addr_valid(u8 block, u8 subblock);
5395711cd5SPawel Dembicki int vsc73xx_probe(struct vsc73xx *vsc);
54e99fa423SUwe Kleine-König void vsc73xx_remove(struct vsc73xx *vsc);
550650bf52SVladimir Oltean void vsc73xx_shutdown(struct vsc73xx *vsc);
56