xref: /linux/drivers/net/dsa/vitesse-vsc73xx.h (revision 6cc5280a08899e704336446c300af2ca80da9e5f)
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 
6*6cc5280aSPawel Dembicki /* The VSC7395 switch chips have 5+1 ports which means 5 ordinary ports and
7*6cc5280aSPawel Dembicki  * a sixth CPU port facing the processor with an RGMII interface. These ports
8*6cc5280aSPawel Dembicki  * are numbered 0..4 and 6, so they leave a "hole" in the port map for port 5,
9*6cc5280aSPawel Dembicki  * which is invalid.
10*6cc5280aSPawel Dembicki  *
11*6cc5280aSPawel Dembicki  * The VSC7398 has 8 ports, port 7 is again the CPU port.
12*6cc5280aSPawel Dembicki  *
13*6cc5280aSPawel Dembicki  * We allocate 8 ports and avoid access to the nonexistent ports.
14*6cc5280aSPawel Dembicki  */
15*6cc5280aSPawel Dembicki #define VSC73XX_MAX_NUM_PORTS	8
16*6cc5280aSPawel Dembicki 
1795711cd5SPawel Dembicki /**
1895711cd5SPawel Dembicki  * struct vsc73xx - VSC73xx state container
1995711cd5SPawel Dembicki  */
2095711cd5SPawel Dembicki struct vsc73xx {
2195711cd5SPawel Dembicki 	struct device			*dev;
2295711cd5SPawel Dembicki 	struct gpio_desc		*reset;
2395711cd5SPawel Dembicki 	struct dsa_switch		*ds;
2495711cd5SPawel Dembicki 	struct gpio_chip		gc;
2595711cd5SPawel Dembicki 	u16				chipid;
2695711cd5SPawel Dembicki 	u8				addr[ETH_ALEN];
2795711cd5SPawel Dembicki 	const struct vsc73xx_ops	*ops;
2895711cd5SPawel Dembicki 	void				*priv;
2995711cd5SPawel Dembicki };
3095711cd5SPawel Dembicki 
3195711cd5SPawel Dembicki struct vsc73xx_ops {
3295711cd5SPawel Dembicki 	int (*read)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg,
3395711cd5SPawel Dembicki 		    u32 *val);
3495711cd5SPawel Dembicki 	int (*write)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg,
3595711cd5SPawel Dembicki 		     u32 val);
3695711cd5SPawel Dembicki };
3795711cd5SPawel Dembicki 
3895711cd5SPawel Dembicki int vsc73xx_is_addr_valid(u8 block, u8 subblock);
3995711cd5SPawel Dembicki int vsc73xx_probe(struct vsc73xx *vsc);
40e99fa423SUwe Kleine-König void vsc73xx_remove(struct vsc73xx *vsc);
410650bf52SVladimir Oltean void vsc73xx_shutdown(struct vsc73xx *vsc);
42