xref: /openbmc/linux/drivers/net/dsa/ocelot/felix.h (revision c64d01b3ceba873aa8e8605598cec4a6bc6d1601)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright 2019 NXP
3  */
4 #ifndef _MSCC_FELIX_H
5 #define _MSCC_FELIX_H
6 
7 #define ocelot_to_felix(o)		container_of((o), struct felix, ocelot)
8 #define FELIX_MAC_QUIRKS		OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION
9 
10 /* Platform-specific information */
11 struct felix_info {
12 	const struct resource		*target_io_res;
13 	const struct resource		*port_io_res;
14 	const struct resource		*imdio_res;
15 	const struct reg_field		*regfields;
16 	const u32 *const		*map;
17 	const struct ocelot_ops		*ops;
18 	int				num_mact_rows;
19 	const struct ocelot_stat_layout	*stats_layout;
20 	unsigned int			num_stats;
21 	int				num_ports;
22 	int				num_tx_queues;
23 	struct vcap_props		*vcap;
24 	u16				vcap_pol_base;
25 	u16				vcap_pol_max;
26 	u16				vcap_pol_base2;
27 	u16				vcap_pol_max2;
28 	int				switch_pci_bar;
29 	int				imdio_pci_bar;
30 	const struct ptp_clock_info	*ptp_caps;
31 
32 	/* Some Ocelot switches are integrated into the SoC without the
33 	 * extraction IRQ line connected to the ARM GIC. By enabling this
34 	 * workaround, the few packets that are delivered to the CPU port
35 	 * module (currently only PTP) are copied not only to the hardware CPU
36 	 * port module, but also to the 802.1Q Ethernet CPU port, and polling
37 	 * the extraction registers is triggered once the DSA tagger sees a PTP
38 	 * frame. The Ethernet frame is only used as a notification: it is
39 	 * dropped, and the original frame is extracted over MMIO and annotated
40 	 * with the RX timestamp.
41 	 */
42 	bool				quirk_no_xtr_irq;
43 
44 	int	(*mdio_bus_alloc)(struct ocelot *ocelot);
45 	void	(*mdio_bus_free)(struct ocelot *ocelot);
46 	void	(*phylink_validate)(struct ocelot *ocelot, int port,
47 				    unsigned long *supported,
48 				    struct phylink_link_state *state);
49 	int	(*prevalidate_phy_mode)(struct ocelot *ocelot, int port,
50 					phy_interface_t phy_mode);
51 	int	(*port_setup_tc)(struct dsa_switch *ds, int port,
52 				 enum tc_setup_type type, void *type_data);
53 	void	(*port_sched_speed_set)(struct ocelot *ocelot, int port,
54 					u32 speed);
55 };
56 
57 extern const struct dsa_switch_ops felix_switch_ops;
58 
59 /* DSA glue / front-end for struct ocelot */
60 struct felix {
61 	struct dsa_switch		*ds;
62 	const struct felix_info		*info;
63 	struct ocelot			ocelot;
64 	struct mii_bus			*imdio;
65 	struct lynx_pcs			**pcs;
66 	resource_size_t			switch_base;
67 	resource_size_t			imdio_base;
68 	enum dsa_tag_protocol		tag_proto;
69 	struct kthread_worker		*xmit_worker;
70 };
71 
72 struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
73 int felix_netdev_to_port(struct net_device *dev);
74 
75 #endif
76