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