xref: /openbmc/linux/drivers/net/dsa/sja1105/sja1105.h (revision 3e77e59bf8cf105d64f70133e41c38daf482acc3)
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)
21*3e77e59bSVladimir 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];
708aa9ebccSVladimir Oltean };
718aa9ebccSVladimir Oltean 
7241fed17fSVladimir Oltean enum {
7341fed17fSVladimir Oltean 	SJA1105_SPEED_AUTO,
7441fed17fSVladimir Oltean 	SJA1105_SPEED_10MBPS,
7541fed17fSVladimir Oltean 	SJA1105_SPEED_100MBPS,
7641fed17fSVladimir Oltean 	SJA1105_SPEED_1000MBPS,
7741fed17fSVladimir Oltean 	SJA1105_SPEED_2500MBPS,
7841fed17fSVladimir Oltean 	SJA1105_SPEED_MAX,
7941fed17fSVladimir Oltean };
8041fed17fSVladimir Oltean 
818aa9ebccSVladimir Oltean struct sja1105_info {
828aa9ebccSVladimir Oltean 	u64 device_id;
838aa9ebccSVladimir Oltean 	/* Needed for distinction between P and R, and between Q and S
848aa9ebccSVladimir Oltean 	 * (since the parts with/without SGMII share the same
858aa9ebccSVladimir Oltean 	 * switch core and device_id)
868aa9ebccSVladimir Oltean 	 */
878aa9ebccSVladimir Oltean 	u64 part_no;
8847ed985eSVladimir Oltean 	/* E/T and P/Q/R/S have partial timestamps of different sizes.
8947ed985eSVladimir Oltean 	 * They must be reconstructed on both families anyway to get the full
9047ed985eSVladimir Oltean 	 * 64-bit values back.
9147ed985eSVladimir Oltean 	 */
9247ed985eSVladimir Oltean 	int ptp_ts_bits;
9347ed985eSVladimir Oltean 	/* Also SPI commands are of different sizes to retrieve
9447ed985eSVladimir Oltean 	 * the egress timestamps.
9547ed985eSVladimir Oltean 	 */
9647ed985eSVladimir Oltean 	int ptpegr_ts_bytes;
974d752508SVladimir Oltean 	int num_cbs_shapers;
981bf658eeSVladimir Oltean 	int max_frame_mem;
99*3e77e59bSVladimir Oltean 	int num_ports;
1008aa9ebccSVladimir Oltean 	const struct sja1105_dynamic_table_ops *dyn_ops;
1018aa9ebccSVladimir Oltean 	const struct sja1105_table_ops *static_ops;
1028aa9ebccSVladimir Oltean 	const struct sja1105_regs *regs;
10338b5beeaSVladimir Oltean 	/* Both E/T and P/Q/R/S have quirks when it comes to popping the S-Tag
10438b5beeaSVladimir Oltean 	 * from double-tagged frames. E/T will pop it only when it's equal to
10538b5beeaSVladimir Oltean 	 * TPID from the General Parameters Table, while P/Q/R/S will only
10638b5beeaSVladimir Oltean 	 * pop it when it's equal to TPID2.
10738b5beeaSVladimir Oltean 	 */
10838b5beeaSVladimir Oltean 	u16 qinq_tpid;
1094d942354SVladimir Oltean 	bool can_limit_mcast_flood;
110abfb228aSVladimir Oltean 	int (*reset_cmd)(struct dsa_switch *ds);
111f5b8631cSVladimir Oltean 	int (*setup_rgmii_delay)(const void *ctx, int port);
1129dfa6911SVladimir Oltean 	/* Prototypes from include/net/dsa.h */
1139dfa6911SVladimir Oltean 	int (*fdb_add_cmd)(struct dsa_switch *ds, int port,
1149dfa6911SVladimir Oltean 			   const unsigned char *addr, u16 vid);
1159dfa6911SVladimir Oltean 	int (*fdb_del_cmd)(struct dsa_switch *ds, int port,
1169dfa6911SVladimir Oltean 			   const unsigned char *addr, u16 vid);
11741603d78SVladimir Oltean 	void (*ptp_cmd_packing)(u8 *buf, struct sja1105_ptp_cmd *cmd,
11841603d78SVladimir Oltean 				enum packing_op op);
119c5037678SVladimir Oltean 	int (*clocking_setup)(struct sja1105_private *priv);
1208aa9ebccSVladimir Oltean 	const char *name;
12191a05078SVladimir Oltean 	bool supports_mii[SJA1105_MAX_NUM_PORTS];
12291a05078SVladimir Oltean 	bool supports_rmii[SJA1105_MAX_NUM_PORTS];
12391a05078SVladimir Oltean 	bool supports_rgmii[SJA1105_MAX_NUM_PORTS];
12491a05078SVladimir Oltean 	bool supports_sgmii[SJA1105_MAX_NUM_PORTS];
12591a05078SVladimir Oltean 	bool supports_2500basex[SJA1105_MAX_NUM_PORTS];
12641fed17fSVladimir Oltean 	const u64 port_speed[SJA1105_SPEED_MAX];
1278aa9ebccSVladimir Oltean };
1288aa9ebccSVladimir Oltean 
129b70bb8d4SVladimir Oltean enum sja1105_key_type {
130b70bb8d4SVladimir Oltean 	SJA1105_KEY_BCAST,
131b70bb8d4SVladimir Oltean 	SJA1105_KEY_TC,
132b70bb8d4SVladimir Oltean 	SJA1105_KEY_VLAN_UNAWARE_VL,
133b70bb8d4SVladimir Oltean 	SJA1105_KEY_VLAN_AWARE_VL,
134b70bb8d4SVladimir Oltean };
135b70bb8d4SVladimir Oltean 
136b70bb8d4SVladimir Oltean struct sja1105_key {
137b70bb8d4SVladimir Oltean 	enum sja1105_key_type type;
138b70bb8d4SVladimir Oltean 
139b70bb8d4SVladimir Oltean 	union {
140b70bb8d4SVladimir Oltean 		/* SJA1105_KEY_TC */
141b70bb8d4SVladimir Oltean 		struct {
142b70bb8d4SVladimir Oltean 			int pcp;
143b70bb8d4SVladimir Oltean 		} tc;
144b70bb8d4SVladimir Oltean 
145b70bb8d4SVladimir Oltean 		/* SJA1105_KEY_VLAN_UNAWARE_VL */
146b70bb8d4SVladimir Oltean 		/* SJA1105_KEY_VLAN_AWARE_VL */
147b70bb8d4SVladimir Oltean 		struct {
148b70bb8d4SVladimir Oltean 			u64 dmac;
149b70bb8d4SVladimir Oltean 			u16 vid;
150b70bb8d4SVladimir Oltean 			u16 pcp;
151b70bb8d4SVladimir Oltean 		} vl;
152b70bb8d4SVladimir Oltean 	};
153b70bb8d4SVladimir Oltean };
154b70bb8d4SVladimir Oltean 
155a6af7763SVladimir Oltean enum sja1105_rule_type {
156a6af7763SVladimir Oltean 	SJA1105_RULE_BCAST_POLICER,
157a6af7763SVladimir Oltean 	SJA1105_RULE_TC_POLICER,
158dfacc5a2SVladimir Oltean 	SJA1105_RULE_VL,
159dfacc5a2SVladimir Oltean };
160dfacc5a2SVladimir Oltean 
161dfacc5a2SVladimir Oltean enum sja1105_vl_type {
162dfacc5a2SVladimir Oltean 	SJA1105_VL_NONCRITICAL,
163dfacc5a2SVladimir Oltean 	SJA1105_VL_RATE_CONSTRAINED,
164dfacc5a2SVladimir Oltean 	SJA1105_VL_TIME_TRIGGERED,
165a6af7763SVladimir Oltean };
166a6af7763SVladimir Oltean 
167a6af7763SVladimir Oltean struct sja1105_rule {
168a6af7763SVladimir Oltean 	struct list_head list;
169a6af7763SVladimir Oltean 	unsigned long cookie;
170a6af7763SVladimir Oltean 	unsigned long port_mask;
171b70bb8d4SVladimir Oltean 	struct sja1105_key key;
172a6af7763SVladimir Oltean 	enum sja1105_rule_type type;
173a6af7763SVladimir Oltean 
174dfacc5a2SVladimir Oltean 	/* Action */
175a6af7763SVladimir Oltean 	union {
176a6af7763SVladimir Oltean 		/* SJA1105_RULE_BCAST_POLICER */
177a6af7763SVladimir Oltean 		struct {
178a6af7763SVladimir Oltean 			int sharindx;
179a6af7763SVladimir Oltean 		} bcast_pol;
180a6af7763SVladimir Oltean 
181a6af7763SVladimir Oltean 		/* SJA1105_RULE_TC_POLICER */
182a6af7763SVladimir Oltean 		struct {
183a6af7763SVladimir Oltean 			int sharindx;
184a6af7763SVladimir Oltean 		} tc_pol;
185dfacc5a2SVladimir Oltean 
186dfacc5a2SVladimir Oltean 		/* SJA1105_RULE_VL */
187dfacc5a2SVladimir Oltean 		struct {
188dfacc5a2SVladimir Oltean 			enum sja1105_vl_type type;
189834f8933SVladimir Oltean 			unsigned long destports;
190834f8933SVladimir Oltean 			int sharindx;
191834f8933SVladimir Oltean 			int maxlen;
192834f8933SVladimir Oltean 			int ipv;
193834f8933SVladimir Oltean 			u64 base_time;
194834f8933SVladimir Oltean 			u64 cycle_time;
195834f8933SVladimir Oltean 			int num_entries;
196834f8933SVladimir Oltean 			struct action_gate_entry *entries;
197834f8933SVladimir Oltean 			struct flow_stats stats;
198dfacc5a2SVladimir Oltean 		} vl;
199a6af7763SVladimir Oltean 	};
200a6af7763SVladimir Oltean };
201a6af7763SVladimir Oltean 
202a6af7763SVladimir Oltean struct sja1105_flow_block {
203a6af7763SVladimir Oltean 	struct list_head rules;
204a6af7763SVladimir Oltean 	bool l2_policer_used[SJA1105_NUM_L2_POLICERS];
205dfacc5a2SVladimir Oltean 	int num_virtual_links;
206a6af7763SVladimir Oltean };
207a6af7763SVladimir Oltean 
208ec5ae610SVladimir Oltean struct sja1105_bridge_vlan {
209ec5ae610SVladimir Oltean 	struct list_head list;
210ec5ae610SVladimir Oltean 	int port;
211ec5ae610SVladimir Oltean 	u16 vid;
212ec5ae610SVladimir Oltean 	bool pvid;
213ec5ae610SVladimir Oltean 	bool untagged;
214ec5ae610SVladimir Oltean };
215ec5ae610SVladimir Oltean 
2167f14937fSVladimir Oltean enum sja1105_vlan_state {
2177f14937fSVladimir Oltean 	SJA1105_VLAN_UNAWARE,
2182cafa72eSVladimir Oltean 	SJA1105_VLAN_BEST_EFFORT,
2197f14937fSVladimir Oltean 	SJA1105_VLAN_FILTERING_FULL,
2207f14937fSVladimir Oltean };
2217f14937fSVladimir Oltean 
2228aa9ebccSVladimir Oltean struct sja1105_private {
2238aa9ebccSVladimir Oltean 	struct sja1105_static_config static_config;
22482760d7fSVladimir Oltean 	bool rgmii_rx_delay[SJA1105_MAX_NUM_PORTS];
22582760d7fSVladimir Oltean 	bool rgmii_tx_delay[SJA1105_MAX_NUM_PORTS];
226bf4edf4aSVladimir Oltean 	phy_interface_t phy_mode[SJA1105_MAX_NUM_PORTS];
22729afb83aSVladimir Oltean 	bool fixed_link[SJA1105_MAX_NUM_PORTS];
2282cafa72eSVladimir Oltean 	bool best_effort_vlan_filtering;
2294d942354SVladimir Oltean 	unsigned long learn_ena;
2307f7ccdeaSVladimir Oltean 	unsigned long ucast_egress_floods;
2317f7ccdeaSVladimir Oltean 	unsigned long bcast_egress_floods;
2328aa9ebccSVladimir Oltean 	const struct sja1105_info *info;
233718bad0eSVladimir Oltean 	size_t max_xfer_len;
2348aa9ebccSVladimir Oltean 	struct gpio_desc *reset_gpio;
2358aa9ebccSVladimir Oltean 	struct spi_device *spidev;
2368aa9ebccSVladimir Oltean 	struct dsa_switch *ds;
237ec5ae610SVladimir Oltean 	struct list_head dsa_8021q_vlans;
238ec5ae610SVladimir Oltean 	struct list_head bridge_vlans;
239a6af7763SVladimir Oltean 	struct sja1105_flow_block flow_block;
24082760d7fSVladimir Oltean 	struct sja1105_port ports[SJA1105_MAX_NUM_PORTS];
241227d07a0SVladimir Oltean 	/* Serializes transmission of management frames so that
242227d07a0SVladimir Oltean 	 * the switch doesn't confuse them with one another.
243227d07a0SVladimir Oltean 	 */
244227d07a0SVladimir Oltean 	struct mutex mgmt_lock;
2455899ee36SVladimir Oltean 	struct dsa_8021q_context *dsa_8021q_ctx;
2467f14937fSVladimir Oltean 	enum sja1105_vlan_state vlan_state;
247bf425b82SVladimir Oltean 	struct devlink_region **regions;
2484d752508SVladimir Oltean 	struct sja1105_cbs_entry *cbs;
249844d7edcSVladimir Oltean 	struct sja1105_tagger_data tagger_data;
250a9d6ed7aSVladimir Oltean 	struct sja1105_ptp_data ptp_data;
251317ab5b8SVladimir Oltean 	struct sja1105_tas_data tas_data;
2528aa9ebccSVladimir Oltean };
2538aa9ebccSVladimir Oltean 
2548aa9ebccSVladimir Oltean #include "sja1105_dynamic_config.h"
2558aa9ebccSVladimir Oltean 
2568aa9ebccSVladimir Oltean struct sja1105_spi_message {
2578aa9ebccSVladimir Oltean 	u64 access;
2588aa9ebccSVladimir Oltean 	u64 read_count;
2598aa9ebccSVladimir Oltean 	u64 address;
2608aa9ebccSVladimir Oltean };
2618aa9ebccSVladimir Oltean 
262317ab5b8SVladimir Oltean /* From sja1105_main.c */
2632eea1fa8SVladimir Oltean enum sja1105_reset_reason {
2642eea1fa8SVladimir Oltean 	SJA1105_VLAN_FILTERING = 0,
2652eea1fa8SVladimir Oltean 	SJA1105_RX_HWTSTAMPING,
2662eea1fa8SVladimir Oltean 	SJA1105_AGEING_TIME,
2672eea1fa8SVladimir Oltean 	SJA1105_SCHEDULING,
268c279c726SVladimir Oltean 	SJA1105_BEST_EFFORT_POLICING,
269dfacc5a2SVladimir Oltean 	SJA1105_VIRTUAL_LINKS,
2702eea1fa8SVladimir Oltean };
2712eea1fa8SVladimir Oltean 
2722eea1fa8SVladimir Oltean int sja1105_static_config_reload(struct sja1105_private *priv,
2732eea1fa8SVladimir Oltean 				 enum sja1105_reset_reason reason);
27489153ed6SVladimir Oltean int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
27589153ed6SVladimir Oltean 			   struct netlink_ext_ack *extack);
276aaa270c6SVladimir Oltean void sja1105_frame_memory_partitioning(struct sja1105_private *priv);
277aaa270c6SVladimir Oltean 
2780a7bdbc2SVladimir Oltean /* From sja1105_devlink.c */
2790a7bdbc2SVladimir Oltean int sja1105_devlink_setup(struct dsa_switch *ds);
2800a7bdbc2SVladimir Oltean void sja1105_devlink_teardown(struct dsa_switch *ds);
2810a7bdbc2SVladimir Oltean int sja1105_devlink_param_get(struct dsa_switch *ds, u32 id,
2820a7bdbc2SVladimir Oltean 			      struct devlink_param_gset_ctx *ctx);
2830a7bdbc2SVladimir Oltean int sja1105_devlink_param_set(struct dsa_switch *ds, u32 id,
2840a7bdbc2SVladimir Oltean 			      struct devlink_param_gset_ctx *ctx);
285ff4cf8eaSVladimir Oltean int sja1105_devlink_info_get(struct dsa_switch *ds,
286ff4cf8eaSVladimir Oltean 			     struct devlink_info_req *req,
287ff4cf8eaSVladimir Oltean 			     struct netlink_ext_ack *extack);
2880a7bdbc2SVladimir Oltean 
2898aa9ebccSVladimir Oltean /* From sja1105_spi.c */
2901bd44870SVladimir Oltean int sja1105_xfer_buf(const struct sja1105_private *priv,
2918aa9ebccSVladimir Oltean 		     sja1105_spi_rw_mode_t rw, u64 reg_addr,
29208839c06SVladimir Oltean 		     u8 *buf, size_t len);
293dff79620SVladimir Oltean int sja1105_xfer_u32(const struct sja1105_private *priv,
29434d76e9fSVladimir Oltean 		     sja1105_spi_rw_mode_t rw, u64 reg_addr, u32 *value,
29534d76e9fSVladimir Oltean 		     struct ptp_system_timestamp *ptp_sts);
296dff79620SVladimir Oltean int sja1105_xfer_u64(const struct sja1105_private *priv,
29734d76e9fSVladimir Oltean 		     sja1105_spi_rw_mode_t rw, u64 reg_addr, u64 *value,
29834d76e9fSVladimir Oltean 		     struct ptp_system_timestamp *ptp_sts);
299bf425b82SVladimir Oltean int static_config_buf_prepare_for_upload(struct sja1105_private *priv,
300bf425b82SVladimir Oltean 					 void *config_buf, int buf_len);
3018aa9ebccSVladimir Oltean int sja1105_static_config_upload(struct sja1105_private *priv);
302d114fb04SVladimir Oltean int sja1105_inhibit_tx(const struct sja1105_private *priv,
303d114fb04SVladimir Oltean 		       unsigned long port_bitmap, bool tx_inhibited);
3048aa9ebccSVladimir Oltean 
30513c832a4SVladimir Oltean extern const struct sja1105_info sja1105e_info;
30613c832a4SVladimir Oltean extern const struct sja1105_info sja1105t_info;
30713c832a4SVladimir Oltean extern const struct sja1105_info sja1105p_info;
30813c832a4SVladimir Oltean extern const struct sja1105_info sja1105q_info;
30913c832a4SVladimir Oltean extern const struct sja1105_info sja1105r_info;
31013c832a4SVladimir Oltean extern const struct sja1105_info sja1105s_info;
311*3e77e59bSVladimir Oltean extern const struct sja1105_info sja1110a_info;
312*3e77e59bSVladimir Oltean extern const struct sja1105_info sja1110b_info;
313*3e77e59bSVladimir Oltean extern const struct sja1105_info sja1110c_info;
314*3e77e59bSVladimir Oltean extern const struct sja1105_info sja1110d_info;
3158aa9ebccSVladimir Oltean 
3168aa9ebccSVladimir Oltean /* From sja1105_clocking.c */
3178aa9ebccSVladimir Oltean 
3188aa9ebccSVladimir Oltean typedef enum {
3198aa9ebccSVladimir Oltean 	XMII_MAC = 0,
3208aa9ebccSVladimir Oltean 	XMII_PHY = 1,
3218aa9ebccSVladimir Oltean } sja1105_mii_role_t;
3228aa9ebccSVladimir Oltean 
3238aa9ebccSVladimir Oltean typedef enum {
3248aa9ebccSVladimir Oltean 	XMII_MODE_MII		= 0,
3258aa9ebccSVladimir Oltean 	XMII_MODE_RMII		= 1,
3268aa9ebccSVladimir Oltean 	XMII_MODE_RGMII		= 2,
327ffe10e67SVladimir Oltean 	XMII_MODE_SGMII		= 3,
3288aa9ebccSVladimir Oltean } sja1105_phy_interface_t;
3298aa9ebccSVladimir Oltean 
330c05ec3d4SVladimir Oltean int sja1105pqrs_setup_rgmii_delay(const void *ctx, int port);
331*3e77e59bSVladimir Oltean int sja1110_setup_rgmii_delay(const void *ctx, int port);
3328aa9ebccSVladimir Oltean int sja1105_clocking_setup_port(struct sja1105_private *priv, int port);
3338aa9ebccSVladimir Oltean int sja1105_clocking_setup(struct sja1105_private *priv);
334*3e77e59bSVladimir Oltean int sja1110_clocking_setup(struct sja1105_private *priv);
3358aa9ebccSVladimir Oltean 
33652c34e6eSVladimir Oltean /* From sja1105_ethtool.c */
33752c34e6eSVladimir Oltean void sja1105_get_ethtool_stats(struct dsa_switch *ds, int port, u64 *data);
33852c34e6eSVladimir Oltean void sja1105_get_strings(struct dsa_switch *ds, int port,
33952c34e6eSVladimir Oltean 			 u32 stringset, u8 *data);
34052c34e6eSVladimir Oltean int sja1105_get_sset_count(struct dsa_switch *ds, int port, int sset);
3418aa9ebccSVladimir Oltean 
34252c34e6eSVladimir Oltean /* From sja1105_dynamic_config.c */
3438aa9ebccSVladimir Oltean int sja1105_dynamic_config_read(struct sja1105_private *priv,
3448aa9ebccSVladimir Oltean 				enum sja1105_blk_idx blk_idx,
3458aa9ebccSVladimir Oltean 				int index, void *entry);
3468aa9ebccSVladimir Oltean int sja1105_dynamic_config_write(struct sja1105_private *priv,
3478aa9ebccSVladimir Oltean 				 enum sja1105_blk_idx blk_idx,
3488aa9ebccSVladimir Oltean 				 int index, void *entry, bool keep);
3498aa9ebccSVladimir Oltean 
3501da73821SVladimir Oltean enum sja1105_iotag {
3511da73821SVladimir Oltean 	SJA1105_C_TAG = 0, /* Inner VLAN header */
3521da73821SVladimir Oltean 	SJA1105_S_TAG = 1, /* Outer VLAN header */
3531da73821SVladimir Oltean };
3541da73821SVladimir Oltean 
355*3e77e59bSVladimir Oltean enum sja1110_vlan_type {
356*3e77e59bSVladimir Oltean 	SJA1110_VLAN_INVALID = 0,
357*3e77e59bSVladimir Oltean 	SJA1110_VLAN_C_TAG = 1, /* Single inner VLAN tag */
358*3e77e59bSVladimir Oltean 	SJA1110_VLAN_S_TAG = 2, /* Single outer VLAN tag */
359*3e77e59bSVladimir Oltean 	SJA1110_VLAN_D_TAG = 3, /* Double tagged, use outer tag for lookup */
360*3e77e59bSVladimir Oltean };
361*3e77e59bSVladimir Oltean 
362*3e77e59bSVladimir Oltean enum sja1110_shaper_type {
363*3e77e59bSVladimir Oltean 	SJA1110_LEAKY_BUCKET_SHAPER = 0,
364*3e77e59bSVladimir Oltean 	SJA1110_CBS_SHAPER = 1,
365*3e77e59bSVladimir Oltean };
366*3e77e59bSVladimir Oltean 
3679dfa6911SVladimir Oltean u8 sja1105et_fdb_hash(struct sja1105_private *priv, const u8 *addr, u16 vid);
3689dfa6911SVladimir Oltean int sja1105et_fdb_add(struct dsa_switch *ds, int port,
3699dfa6911SVladimir Oltean 		      const unsigned char *addr, u16 vid);
3709dfa6911SVladimir Oltean int sja1105et_fdb_del(struct dsa_switch *ds, int port,
3719dfa6911SVladimir Oltean 		      const unsigned char *addr, u16 vid);
3729dfa6911SVladimir Oltean int sja1105pqrs_fdb_add(struct dsa_switch *ds, int port,
3739dfa6911SVladimir Oltean 			const unsigned char *addr, u16 vid);
3749dfa6911SVladimir Oltean int sja1105pqrs_fdb_del(struct dsa_switch *ds, int port,
3759dfa6911SVladimir Oltean 			const unsigned char *addr, u16 vid);
376291d1e72SVladimir Oltean 
377a6af7763SVladimir Oltean /* From sja1105_flower.c */
378a6af7763SVladimir Oltean int sja1105_cls_flower_del(struct dsa_switch *ds, int port,
379a6af7763SVladimir Oltean 			   struct flow_cls_offload *cls, bool ingress);
380a6af7763SVladimir Oltean int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
381a6af7763SVladimir Oltean 			   struct flow_cls_offload *cls, bool ingress);
382834f8933SVladimir Oltean int sja1105_cls_flower_stats(struct dsa_switch *ds, int port,
383834f8933SVladimir Oltean 			     struct flow_cls_offload *cls, bool ingress);
384a6af7763SVladimir Oltean void sja1105_flower_setup(struct dsa_switch *ds);
385a6af7763SVladimir Oltean void sja1105_flower_teardown(struct dsa_switch *ds);
386dfacc5a2SVladimir Oltean struct sja1105_rule *sja1105_rule_find(struct sja1105_private *priv,
387dfacc5a2SVladimir Oltean 				       unsigned long cookie);
388a6af7763SVladimir Oltean 
3898aa9ebccSVladimir Oltean #endif
390