xref: /openbmc/linux/drivers/net/dsa/sja1105/sja1105.h (revision 6dfd23d35e75098ac61a605f6c591ce42e95cdcb)
1b790b554SNishad Kamdar /* SPDX-License-Identifier: GPL-2.0 */
2b790b554SNishad Kamdar /* Copyright (c) 2018, Sensor-Technik Wiedemann GmbH
38aa9ebccSVladimir Oltean  * Copyright (c) 2018-2019, Vladimir Oltean <olteanv@gmail.com>
48aa9ebccSVladimir Oltean  */
58aa9ebccSVladimir Oltean #ifndef _SJA1105_H
68aa9ebccSVladimir Oltean #define _SJA1105_H
78aa9ebccSVladimir Oltean 
8bb77f36aSVladimir Oltean #include <linux/ptp_clock_kernel.h>
9bb77f36aSVladimir Oltean #include <linux/timecounter.h>
108aa9ebccSVladimir Oltean #include <linux/dsa/sja1105.h>
11ac02a451SVladimir Oltean #include <linux/dsa/8021q.h>
128aa9ebccSVladimir Oltean #include <net/dsa.h>
13227d07a0SVladimir Oltean #include <linux/mutex.h>
148aa9ebccSVladimir Oltean #include "sja1105_static_config.h"
158aa9ebccSVladimir Oltean 
168aa9ebccSVladimir Oltean #define SJA1105ET_FDB_BIN_SIZE		4
178456721dSVladimir Oltean /* The hardware value is in multiples of 10 ms.
188456721dSVladimir Oltean  * The passed parameter is in multiples of 1 ms.
198456721dSVladimir Oltean  */
208456721dSVladimir Oltean #define SJA1105_AGEING_TIME_MS(ms)	((ms) / 10)
213e77e59bSVladimir Oltean #define SJA1105_NUM_L2_POLICERS		SJA1110_MAX_L2_POLICING_COUNT
228aa9ebccSVladimir Oltean 
2341603d78SVladimir Oltean typedef enum {
2441603d78SVladimir Oltean 	SPI_READ = 0,
2541603d78SVladimir Oltean 	SPI_WRITE = 1,
2641603d78SVladimir Oltean } sja1105_spi_rw_mode_t;
2741603d78SVladimir Oltean 
28317ab5b8SVladimir Oltean #include "sja1105_tas.h"
29a9d6ed7aSVladimir Oltean #include "sja1105_ptp.h"
30317ab5b8SVladimir Oltean 
31039b167dSVladimir Oltean enum sja1105_stats_area {
32039b167dSVladimir Oltean 	MAC,
33039b167dSVladimir Oltean 	HL1,
34039b167dSVladimir Oltean 	HL2,
35039b167dSVladimir Oltean 	ETHER,
36039b167dSVladimir Oltean 	__MAX_SJA1105_STATS_AREA,
37039b167dSVladimir Oltean };
38039b167dSVladimir Oltean 
398aa9ebccSVladimir Oltean /* Keeps the different addresses between E/T and P/Q/R/S */
408aa9ebccSVladimir Oltean struct sja1105_regs {
418aa9ebccSVladimir Oltean 	u64 device_id;
428aa9ebccSVladimir Oltean 	u64 prod_id;
438aa9ebccSVladimir Oltean 	u64 status;
441a4c6940SVladimir Oltean 	u64 port_control;
458aa9ebccSVladimir Oltean 	u64 rgu;
46834f8933SVladimir Oltean 	u64 vl_status;
478aa9ebccSVladimir Oltean 	u64 config;
488aa9ebccSVladimir Oltean 	u64 rmii_pll1;
49747e5eb3SVladimir Oltean 	u64 ptppinst;
50747e5eb3SVladimir Oltean 	u64 ptppindur;
51bb77f36aSVladimir Oltean 	u64 ptp_control;
522fb079a2SVladimir Oltean 	u64 ptpclkval;
53bb77f36aSVladimir Oltean 	u64 ptpclkrate;
5486db36a3SVladimir Oltean 	u64 ptpclkcorp;
55747e5eb3SVladimir Oltean 	u64 ptpsyncts;
5686db36a3SVladimir Oltean 	u64 ptpschtm;
5782760d7fSVladimir Oltean 	u64 ptpegr_ts[SJA1105_MAX_NUM_PORTS];
5882760d7fSVladimir Oltean 	u64 pad_mii_tx[SJA1105_MAX_NUM_PORTS];
5982760d7fSVladimir Oltean 	u64 pad_mii_rx[SJA1105_MAX_NUM_PORTS];
6082760d7fSVladimir Oltean 	u64 pad_mii_id[SJA1105_MAX_NUM_PORTS];
6182760d7fSVladimir Oltean 	u64 cgu_idiv[SJA1105_MAX_NUM_PORTS];
6282760d7fSVladimir Oltean 	u64 mii_tx_clk[SJA1105_MAX_NUM_PORTS];
6382760d7fSVladimir Oltean 	u64 mii_rx_clk[SJA1105_MAX_NUM_PORTS];
6482760d7fSVladimir Oltean 	u64 mii_ext_tx_clk[SJA1105_MAX_NUM_PORTS];
6582760d7fSVladimir Oltean 	u64 mii_ext_rx_clk[SJA1105_MAX_NUM_PORTS];
6682760d7fSVladimir Oltean 	u64 rgmii_tx_clk[SJA1105_MAX_NUM_PORTS];
6782760d7fSVladimir Oltean 	u64 rmii_ref_clk[SJA1105_MAX_NUM_PORTS];
6882760d7fSVladimir Oltean 	u64 rmii_ext_tx_clk[SJA1105_MAX_NUM_PORTS];
6982760d7fSVladimir Oltean 	u64 stats[__MAX_SJA1105_STATS_AREA][SJA1105_MAX_NUM_PORTS];
705a8f0974SVladimir Oltean 	u64 mdio_100base_tx;
715a8f0974SVladimir Oltean 	u64 mdio_100base_t1;
7227871359SVladimir Oltean 	u64 pcs_base[SJA1105_MAX_NUM_PORTS];
735a8f0974SVladimir Oltean };
745a8f0974SVladimir Oltean 
755a8f0974SVladimir Oltean struct sja1105_mdio_private {
765a8f0974SVladimir Oltean 	struct sja1105_private *priv;
778aa9ebccSVladimir Oltean };
788aa9ebccSVladimir Oltean 
7941fed17fSVladimir Oltean enum {
8041fed17fSVladimir Oltean 	SJA1105_SPEED_AUTO,
8141fed17fSVladimir Oltean 	SJA1105_SPEED_10MBPS,
8241fed17fSVladimir Oltean 	SJA1105_SPEED_100MBPS,
8341fed17fSVladimir Oltean 	SJA1105_SPEED_1000MBPS,
8441fed17fSVladimir Oltean 	SJA1105_SPEED_2500MBPS,
8541fed17fSVladimir Oltean 	SJA1105_SPEED_MAX,
8641fed17fSVladimir Oltean };
8741fed17fSVladimir Oltean 
885a8f0974SVladimir Oltean enum sja1105_internal_phy_t {
895a8f0974SVladimir Oltean 	SJA1105_NO_PHY		= 0,
905a8f0974SVladimir Oltean 	SJA1105_PHY_BASE_TX,
915a8f0974SVladimir Oltean 	SJA1105_PHY_BASE_T1,
925a8f0974SVladimir Oltean };
935a8f0974SVladimir Oltean 
948aa9ebccSVladimir Oltean struct sja1105_info {
958aa9ebccSVladimir Oltean 	u64 device_id;
968aa9ebccSVladimir Oltean 	/* Needed for distinction between P and R, and between Q and S
978aa9ebccSVladimir Oltean 	 * (since the parts with/without SGMII share the same
988aa9ebccSVladimir Oltean 	 * switch core and device_id)
998aa9ebccSVladimir Oltean 	 */
1008aa9ebccSVladimir Oltean 	u64 part_no;
10147ed985eSVladimir Oltean 	/* E/T and P/Q/R/S have partial timestamps of different sizes.
10247ed985eSVladimir Oltean 	 * They must be reconstructed on both families anyway to get the full
10347ed985eSVladimir Oltean 	 * 64-bit values back.
10447ed985eSVladimir Oltean 	 */
10547ed985eSVladimir Oltean 	int ptp_ts_bits;
10647ed985eSVladimir Oltean 	/* Also SPI commands are of different sizes to retrieve
10747ed985eSVladimir Oltean 	 * the egress timestamps.
10847ed985eSVladimir Oltean 	 */
10947ed985eSVladimir Oltean 	int ptpegr_ts_bytes;
1104d752508SVladimir Oltean 	int num_cbs_shapers;
1111bf658eeSVladimir Oltean 	int max_frame_mem;
1123e77e59bSVladimir Oltean 	int num_ports;
1136c0de59bSVladimir Oltean 	bool multiple_cascade_ports;
1144913b8ebSVladimir Oltean 	enum dsa_tag_protocol tag_proto;
1158aa9ebccSVladimir Oltean 	const struct sja1105_dynamic_table_ops *dyn_ops;
1168aa9ebccSVladimir Oltean 	const struct sja1105_table_ops *static_ops;
1178aa9ebccSVladimir Oltean 	const struct sja1105_regs *regs;
11838b5beeaSVladimir Oltean 	/* Both E/T and P/Q/R/S have quirks when it comes to popping the S-Tag
11938b5beeaSVladimir Oltean 	 * from double-tagged frames. E/T will pop it only when it's equal to
12038b5beeaSVladimir Oltean 	 * TPID from the General Parameters Table, while P/Q/R/S will only
12138b5beeaSVladimir Oltean 	 * pop it when it's equal to TPID2.
12238b5beeaSVladimir Oltean 	 */
12338b5beeaSVladimir Oltean 	u16 qinq_tpid;
1244d942354SVladimir Oltean 	bool can_limit_mcast_flood;
125abfb228aSVladimir Oltean 	int (*reset_cmd)(struct dsa_switch *ds);
126f5b8631cSVladimir Oltean 	int (*setup_rgmii_delay)(const void *ctx, int port);
1279dfa6911SVladimir Oltean 	/* Prototypes from include/net/dsa.h */
1289dfa6911SVladimir Oltean 	int (*fdb_add_cmd)(struct dsa_switch *ds, int port,
1299dfa6911SVladimir Oltean 			   const unsigned char *addr, u16 vid);
1309dfa6911SVladimir Oltean 	int (*fdb_del_cmd)(struct dsa_switch *ds, int port,
1319dfa6911SVladimir Oltean 			   const unsigned char *addr, u16 vid);
13241603d78SVladimir Oltean 	void (*ptp_cmd_packing)(u8 *buf, struct sja1105_ptp_cmd *cmd,
13341603d78SVladimir Oltean 				enum packing_op op);
13430b73242SVladimir Oltean 	bool (*rxtstamp)(struct dsa_switch *ds, int port, struct sk_buff *skb);
135566b18c8SVladimir Oltean 	void (*txtstamp)(struct dsa_switch *ds, int port, struct sk_buff *skb);
136c5037678SVladimir Oltean 	int (*clocking_setup)(struct sja1105_private *priv);
1373ad1d171SVladimir Oltean 	int (*pcs_mdio_read)(struct mii_bus *bus, int phy, int reg);
1383ad1d171SVladimir Oltean 	int (*pcs_mdio_write)(struct mii_bus *bus, int phy, int reg, u16 val);
139cb5a82d2SVladimir Oltean 	int (*disable_microcontroller)(struct sja1105_private *priv);
1408aa9ebccSVladimir Oltean 	const char *name;
14191a05078SVladimir Oltean 	bool supports_mii[SJA1105_MAX_NUM_PORTS];
14291a05078SVladimir Oltean 	bool supports_rmii[SJA1105_MAX_NUM_PORTS];
14391a05078SVladimir Oltean 	bool supports_rgmii[SJA1105_MAX_NUM_PORTS];
14491a05078SVladimir Oltean 	bool supports_sgmii[SJA1105_MAX_NUM_PORTS];
14591a05078SVladimir Oltean 	bool supports_2500basex[SJA1105_MAX_NUM_PORTS];
1465a8f0974SVladimir Oltean 	enum sja1105_internal_phy_t internal_phy[SJA1105_MAX_NUM_PORTS];
14741fed17fSVladimir Oltean 	const u64 port_speed[SJA1105_SPEED_MAX];
1488aa9ebccSVladimir Oltean };
1498aa9ebccSVladimir Oltean 
150b70bb8d4SVladimir Oltean enum sja1105_key_type {
151b70bb8d4SVladimir Oltean 	SJA1105_KEY_BCAST,
152b70bb8d4SVladimir Oltean 	SJA1105_KEY_TC,
153b70bb8d4SVladimir Oltean 	SJA1105_KEY_VLAN_UNAWARE_VL,
154b70bb8d4SVladimir Oltean 	SJA1105_KEY_VLAN_AWARE_VL,
155b70bb8d4SVladimir Oltean };
156b70bb8d4SVladimir Oltean 
157b70bb8d4SVladimir Oltean struct sja1105_key {
158b70bb8d4SVladimir Oltean 	enum sja1105_key_type type;
159b70bb8d4SVladimir Oltean 
160b70bb8d4SVladimir Oltean 	union {
161b70bb8d4SVladimir Oltean 		/* SJA1105_KEY_TC */
162b70bb8d4SVladimir Oltean 		struct {
163b70bb8d4SVladimir Oltean 			int pcp;
164b70bb8d4SVladimir Oltean 		} tc;
165b70bb8d4SVladimir Oltean 
166b70bb8d4SVladimir Oltean 		/* SJA1105_KEY_VLAN_UNAWARE_VL */
167b70bb8d4SVladimir Oltean 		/* SJA1105_KEY_VLAN_AWARE_VL */
168b70bb8d4SVladimir Oltean 		struct {
169b70bb8d4SVladimir Oltean 			u64 dmac;
170b70bb8d4SVladimir Oltean 			u16 vid;
171b70bb8d4SVladimir Oltean 			u16 pcp;
172b70bb8d4SVladimir Oltean 		} vl;
173b70bb8d4SVladimir Oltean 	};
174b70bb8d4SVladimir Oltean };
175b70bb8d4SVladimir Oltean 
176a6af7763SVladimir Oltean enum sja1105_rule_type {
177a6af7763SVladimir Oltean 	SJA1105_RULE_BCAST_POLICER,
178a6af7763SVladimir Oltean 	SJA1105_RULE_TC_POLICER,
179dfacc5a2SVladimir Oltean 	SJA1105_RULE_VL,
180dfacc5a2SVladimir Oltean };
181dfacc5a2SVladimir Oltean 
182dfacc5a2SVladimir Oltean enum sja1105_vl_type {
183dfacc5a2SVladimir Oltean 	SJA1105_VL_NONCRITICAL,
184dfacc5a2SVladimir Oltean 	SJA1105_VL_RATE_CONSTRAINED,
185dfacc5a2SVladimir Oltean 	SJA1105_VL_TIME_TRIGGERED,
186a6af7763SVladimir Oltean };
187a6af7763SVladimir Oltean 
188a6af7763SVladimir Oltean struct sja1105_rule {
189a6af7763SVladimir Oltean 	struct list_head list;
190a6af7763SVladimir Oltean 	unsigned long cookie;
191a6af7763SVladimir Oltean 	unsigned long port_mask;
192b70bb8d4SVladimir Oltean 	struct sja1105_key key;
193a6af7763SVladimir Oltean 	enum sja1105_rule_type type;
194a6af7763SVladimir Oltean 
195dfacc5a2SVladimir Oltean 	/* Action */
196a6af7763SVladimir Oltean 	union {
197a6af7763SVladimir Oltean 		/* SJA1105_RULE_BCAST_POLICER */
198a6af7763SVladimir Oltean 		struct {
199a6af7763SVladimir Oltean 			int sharindx;
200a6af7763SVladimir Oltean 		} bcast_pol;
201a6af7763SVladimir Oltean 
202a6af7763SVladimir Oltean 		/* SJA1105_RULE_TC_POLICER */
203a6af7763SVladimir Oltean 		struct {
204a6af7763SVladimir Oltean 			int sharindx;
205a6af7763SVladimir Oltean 		} tc_pol;
206dfacc5a2SVladimir Oltean 
207dfacc5a2SVladimir Oltean 		/* SJA1105_RULE_VL */
208dfacc5a2SVladimir Oltean 		struct {
209dfacc5a2SVladimir Oltean 			enum sja1105_vl_type type;
210834f8933SVladimir Oltean 			unsigned long destports;
211834f8933SVladimir Oltean 			int sharindx;
212834f8933SVladimir Oltean 			int maxlen;
213834f8933SVladimir Oltean 			int ipv;
214834f8933SVladimir Oltean 			u64 base_time;
215834f8933SVladimir Oltean 			u64 cycle_time;
216834f8933SVladimir Oltean 			int num_entries;
217834f8933SVladimir Oltean 			struct action_gate_entry *entries;
218834f8933SVladimir Oltean 			struct flow_stats stats;
219dfacc5a2SVladimir Oltean 		} vl;
220a6af7763SVladimir Oltean 	};
221a6af7763SVladimir Oltean };
222a6af7763SVladimir Oltean 
223a6af7763SVladimir Oltean struct sja1105_flow_block {
224a6af7763SVladimir Oltean 	struct list_head rules;
225a6af7763SVladimir Oltean 	bool l2_policer_used[SJA1105_NUM_L2_POLICERS];
226dfacc5a2SVladimir Oltean 	int num_virtual_links;
227a6af7763SVladimir Oltean };
228a6af7763SVladimir Oltean 
2298aa9ebccSVladimir Oltean struct sja1105_private {
2308aa9ebccSVladimir Oltean 	struct sja1105_static_config static_config;
23182760d7fSVladimir Oltean 	bool rgmii_rx_delay[SJA1105_MAX_NUM_PORTS];
23282760d7fSVladimir Oltean 	bool rgmii_tx_delay[SJA1105_MAX_NUM_PORTS];
233bf4edf4aSVladimir Oltean 	phy_interface_t phy_mode[SJA1105_MAX_NUM_PORTS];
23429afb83aSVladimir Oltean 	bool fixed_link[SJA1105_MAX_NUM_PORTS];
2350fac6aa0SVladimir Oltean 	bool vlan_aware;
2364d942354SVladimir Oltean 	unsigned long learn_ena;
2377f7ccdeaSVladimir Oltean 	unsigned long ucast_egress_floods;
2387f7ccdeaSVladimir Oltean 	unsigned long bcast_egress_floods;
2398aa9ebccSVladimir Oltean 	const struct sja1105_info *info;
240718bad0eSVladimir Oltean 	size_t max_xfer_len;
2418aa9ebccSVladimir Oltean 	struct gpio_desc *reset_gpio;
2428aa9ebccSVladimir Oltean 	struct spi_device *spidev;
2438aa9ebccSVladimir Oltean 	struct dsa_switch *ds;
244*6dfd23d3SVladimir Oltean 	u16 bridge_pvid[SJA1105_MAX_NUM_PORTS];
245*6dfd23d3SVladimir Oltean 	u16 tag_8021q_pvid[SJA1105_MAX_NUM_PORTS];
246a6af7763SVladimir Oltean 	struct sja1105_flow_block flow_block;
24782760d7fSVladimir Oltean 	struct sja1105_port ports[SJA1105_MAX_NUM_PORTS];
248227d07a0SVladimir Oltean 	/* Serializes transmission of management frames so that
249227d07a0SVladimir Oltean 	 * the switch doesn't confuse them with one another.
250227d07a0SVladimir Oltean 	 */
251227d07a0SVladimir Oltean 	struct mutex mgmt_lock;
252bf425b82SVladimir Oltean 	struct devlink_region **regions;
2534d752508SVladimir Oltean 	struct sja1105_cbs_entry *cbs;
2545a8f0974SVladimir Oltean 	struct mii_bus *mdio_base_t1;
2555a8f0974SVladimir Oltean 	struct mii_bus *mdio_base_tx;
2563ad1d171SVladimir Oltean 	struct mii_bus *mdio_pcs;
2573ad1d171SVladimir Oltean 	struct dw_xpcs *xpcs[SJA1105_MAX_NUM_PORTS];
258844d7edcSVladimir Oltean 	struct sja1105_tagger_data tagger_data;
259a9d6ed7aSVladimir Oltean 	struct sja1105_ptp_data ptp_data;
260317ab5b8SVladimir Oltean 	struct sja1105_tas_data tas_data;
2618aa9ebccSVladimir Oltean };
2628aa9ebccSVladimir Oltean 
2638aa9ebccSVladimir Oltean #include "sja1105_dynamic_config.h"
2648aa9ebccSVladimir Oltean 
2658aa9ebccSVladimir Oltean struct sja1105_spi_message {
2668aa9ebccSVladimir Oltean 	u64 access;
2678aa9ebccSVladimir Oltean 	u64 read_count;
2688aa9ebccSVladimir Oltean 	u64 address;
2698aa9ebccSVladimir Oltean };
2708aa9ebccSVladimir Oltean 
271317ab5b8SVladimir Oltean /* From sja1105_main.c */
2722eea1fa8SVladimir Oltean enum sja1105_reset_reason {
2732eea1fa8SVladimir Oltean 	SJA1105_VLAN_FILTERING = 0,
2742eea1fa8SVladimir Oltean 	SJA1105_RX_HWTSTAMPING,
2752eea1fa8SVladimir Oltean 	SJA1105_AGEING_TIME,
2762eea1fa8SVladimir Oltean 	SJA1105_SCHEDULING,
277c279c726SVladimir Oltean 	SJA1105_BEST_EFFORT_POLICING,
278dfacc5a2SVladimir Oltean 	SJA1105_VIRTUAL_LINKS,
2792eea1fa8SVladimir Oltean };
2802eea1fa8SVladimir Oltean 
2812eea1fa8SVladimir Oltean int sja1105_static_config_reload(struct sja1105_private *priv,
2822eea1fa8SVladimir Oltean 				 enum sja1105_reset_reason reason);
28389153ed6SVladimir Oltean int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
28489153ed6SVladimir Oltean 			   struct netlink_ext_ack *extack);
285aaa270c6SVladimir Oltean void sja1105_frame_memory_partitioning(struct sja1105_private *priv);
286aaa270c6SVladimir Oltean 
2875a8f0974SVladimir Oltean /* From sja1105_mdio.c */
2885a8f0974SVladimir Oltean int sja1105_mdiobus_register(struct dsa_switch *ds);
2895a8f0974SVladimir Oltean void sja1105_mdiobus_unregister(struct dsa_switch *ds);
2903ad1d171SVladimir Oltean int sja1105_pcs_mdio_read(struct mii_bus *bus, int phy, int reg);
2913ad1d171SVladimir Oltean int sja1105_pcs_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val);
29227871359SVladimir Oltean int sja1110_pcs_mdio_read(struct mii_bus *bus, int phy, int reg);
29327871359SVladimir Oltean int sja1110_pcs_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val);
2945a8f0974SVladimir Oltean 
2950a7bdbc2SVladimir Oltean /* From sja1105_devlink.c */
2960a7bdbc2SVladimir Oltean int sja1105_devlink_setup(struct dsa_switch *ds);
2970a7bdbc2SVladimir Oltean void sja1105_devlink_teardown(struct dsa_switch *ds);
298ff4cf8eaSVladimir Oltean int sja1105_devlink_info_get(struct dsa_switch *ds,
299ff4cf8eaSVladimir Oltean 			     struct devlink_info_req *req,
300ff4cf8eaSVladimir Oltean 			     struct netlink_ext_ack *extack);
3010a7bdbc2SVladimir Oltean 
3028aa9ebccSVladimir Oltean /* From sja1105_spi.c */
3031bd44870SVladimir Oltean int sja1105_xfer_buf(const struct sja1105_private *priv,
3048aa9ebccSVladimir Oltean 		     sja1105_spi_rw_mode_t rw, u64 reg_addr,
30508839c06SVladimir Oltean 		     u8 *buf, size_t len);
306dff79620SVladimir Oltean int sja1105_xfer_u32(const struct sja1105_private *priv,
30734d76e9fSVladimir Oltean 		     sja1105_spi_rw_mode_t rw, u64 reg_addr, u32 *value,
30834d76e9fSVladimir Oltean 		     struct ptp_system_timestamp *ptp_sts);
309dff79620SVladimir Oltean int sja1105_xfer_u64(const struct sja1105_private *priv,
31034d76e9fSVladimir Oltean 		     sja1105_spi_rw_mode_t rw, u64 reg_addr, u64 *value,
31134d76e9fSVladimir Oltean 		     struct ptp_system_timestamp *ptp_sts);
312bf425b82SVladimir Oltean int static_config_buf_prepare_for_upload(struct sja1105_private *priv,
313bf425b82SVladimir Oltean 					 void *config_buf, int buf_len);
3148aa9ebccSVladimir Oltean int sja1105_static_config_upload(struct sja1105_private *priv);
315d114fb04SVladimir Oltean int sja1105_inhibit_tx(const struct sja1105_private *priv,
316d114fb04SVladimir Oltean 		       unsigned long port_bitmap, bool tx_inhibited);
3178aa9ebccSVladimir Oltean 
31813c832a4SVladimir Oltean extern const struct sja1105_info sja1105e_info;
31913c832a4SVladimir Oltean extern const struct sja1105_info sja1105t_info;
32013c832a4SVladimir Oltean extern const struct sja1105_info sja1105p_info;
32113c832a4SVladimir Oltean extern const struct sja1105_info sja1105q_info;
32213c832a4SVladimir Oltean extern const struct sja1105_info sja1105r_info;
32313c832a4SVladimir Oltean extern const struct sja1105_info sja1105s_info;
3243e77e59bSVladimir Oltean extern const struct sja1105_info sja1110a_info;
3253e77e59bSVladimir Oltean extern const struct sja1105_info sja1110b_info;
3263e77e59bSVladimir Oltean extern const struct sja1105_info sja1110c_info;
3273e77e59bSVladimir Oltean extern const struct sja1105_info sja1110d_info;
3288aa9ebccSVladimir Oltean 
3298aa9ebccSVladimir Oltean /* From sja1105_clocking.c */
3308aa9ebccSVladimir Oltean 
3318aa9ebccSVladimir Oltean typedef enum {
3328aa9ebccSVladimir Oltean 	XMII_MAC = 0,
3338aa9ebccSVladimir Oltean 	XMII_PHY = 1,
3348aa9ebccSVladimir Oltean } sja1105_mii_role_t;
3358aa9ebccSVladimir Oltean 
3368aa9ebccSVladimir Oltean typedef enum {
3378aa9ebccSVladimir Oltean 	XMII_MODE_MII		= 0,
3388aa9ebccSVladimir Oltean 	XMII_MODE_RMII		= 1,
3398aa9ebccSVladimir Oltean 	XMII_MODE_RGMII		= 2,
340ffe10e67SVladimir Oltean 	XMII_MODE_SGMII		= 3,
3418aa9ebccSVladimir Oltean } sja1105_phy_interface_t;
3428aa9ebccSVladimir Oltean 
343c05ec3d4SVladimir Oltean int sja1105pqrs_setup_rgmii_delay(const void *ctx, int port);
3443e77e59bSVladimir Oltean int sja1110_setup_rgmii_delay(const void *ctx, int port);
3458aa9ebccSVladimir Oltean int sja1105_clocking_setup_port(struct sja1105_private *priv, int port);
3468aa9ebccSVladimir Oltean int sja1105_clocking_setup(struct sja1105_private *priv);
347cb5a82d2SVladimir Oltean int sja1110_disable_microcontroller(struct sja1105_private *priv);
3488aa9ebccSVladimir Oltean 
34952c34e6eSVladimir Oltean /* From sja1105_ethtool.c */
35052c34e6eSVladimir Oltean void sja1105_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data);
35152c34e6eSVladimir Oltean void sja1105_get_strings(struct dsa_switch *ds, int port,
35252c34e6eSVladimir Oltean 			 u32 stringset, u8 *data);
35352c34e6eSVladimir Oltean int sja1105_get_sset_count(struct dsa_switch *ds, int port, int sset);
3548aa9ebccSVladimir Oltean 
35552c34e6eSVladimir Oltean /* From sja1105_dynamic_config.c */
3568aa9ebccSVladimir Oltean int sja1105_dynamic_config_read(struct sja1105_private *priv,
3578aa9ebccSVladimir Oltean 				enum sja1105_blk_idx blk_idx,
3588aa9ebccSVladimir Oltean 				int index, void *entry);
3598aa9ebccSVladimir Oltean int sja1105_dynamic_config_write(struct sja1105_private *priv,
3608aa9ebccSVladimir Oltean 				 enum sja1105_blk_idx blk_idx,
3618aa9ebccSVladimir Oltean 				 int index, void *entry, bool keep);
3628aa9ebccSVladimir Oltean 
3631da73821SVladimir Oltean enum sja1105_iotag {
3641da73821SVladimir Oltean 	SJA1105_C_TAG = 0, /* Inner VLAN header */
3651da73821SVladimir Oltean 	SJA1105_S_TAG = 1, /* Outer VLAN header */
3661da73821SVladimir Oltean };
3671da73821SVladimir Oltean 
3683e77e59bSVladimir Oltean enum sja1110_vlan_type {
3693e77e59bSVladimir Oltean 	SJA1110_VLAN_INVALID = 0,
3703e77e59bSVladimir Oltean 	SJA1110_VLAN_C_TAG = 1, /* Single inner VLAN tag */
3713e77e59bSVladimir Oltean 	SJA1110_VLAN_S_TAG = 2, /* Single outer VLAN tag */
3723e77e59bSVladimir Oltean 	SJA1110_VLAN_D_TAG = 3, /* Double tagged, use outer tag for lookup */
3733e77e59bSVladimir Oltean };
3743e77e59bSVladimir Oltean 
3753e77e59bSVladimir Oltean enum sja1110_shaper_type {
3763e77e59bSVladimir Oltean 	SJA1110_LEAKY_BUCKET_SHAPER = 0,
3773e77e59bSVladimir Oltean 	SJA1110_CBS_SHAPER = 1,
3783e77e59bSVladimir Oltean };
3793e77e59bSVladimir Oltean 
3809dfa6911SVladimir Oltean u8 sja1105et_fdb_hash(struct sja1105_private *priv, const u8 *addr, u16 vid);
3819dfa6911SVladimir Oltean int sja1105et_fdb_add(struct dsa_switch *ds, int port,
3829dfa6911SVladimir Oltean 		      const unsigned char *addr, u16 vid);
3839dfa6911SVladimir Oltean int sja1105et_fdb_del(struct dsa_switch *ds, int port,
3849dfa6911SVladimir Oltean 		      const unsigned char *addr, u16 vid);
3859dfa6911SVladimir Oltean int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port,
3869dfa6911SVladimir Oltean 			const unsigned char *addr, u16 vid);
3879dfa6911SVladimir Oltean int sja1105pqrs_fdb_del(struct dsa_switch *ds, int port,
3889dfa6911SVladimir Oltean 			const unsigned char *addr, u16 vid);
389291d1e72SVladimir Oltean 
390a6af7763SVladimir Oltean /* From sja1105_flower.c */
391a6af7763SVladimir Oltean int sja1105_cls_flower_del(struct dsa_switch *ds, int port,
392a6af7763SVladimir Oltean 			   struct flow_cls_offload *cls, bool ingress);
393a6af7763SVladimir Oltean int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
394a6af7763SVladimir Oltean 			   struct flow_cls_offload *cls, bool ingress);
395834f8933SVladimir Oltean int sja1105_cls_flower_stats(struct dsa_switch *ds, int port,
396834f8933SVladimir Oltean 			     struct flow_cls_offload *cls, bool ingress);
397a6af7763SVladimir Oltean void sja1105_flower_setup(struct dsa_switch *ds);
398a6af7763SVladimir Oltean void sja1105_flower_teardown(struct dsa_switch *ds);
399dfacc5a2SVladimir Oltean struct sja1105_rule *sja1105_rule_find(struct sja1105_private *priv,
400dfacc5a2SVladimir Oltean 				       unsigned long cookie);
401a6af7763SVladimir Oltean 
4028aa9ebccSVladimir Oltean #endif
403