xref: /openbmc/linux/drivers/net/dsa/b53/b53_priv.h (revision 3117455d)
1967dd82fSFlorian Fainelli /*
2967dd82fSFlorian Fainelli  * B53 common definitions
3967dd82fSFlorian Fainelli  *
4967dd82fSFlorian Fainelli  * Copyright (C) 2011-2013 Jonas Gorski <jogo@openwrt.org>
5967dd82fSFlorian Fainelli  *
6967dd82fSFlorian Fainelli  * Permission to use, copy, modify, and/or distribute this software for any
7967dd82fSFlorian Fainelli  * purpose with or without fee is hereby granted, provided that the above
8967dd82fSFlorian Fainelli  * copyright notice and this permission notice appear in all copies.
9967dd82fSFlorian Fainelli  *
10967dd82fSFlorian Fainelli  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11967dd82fSFlorian Fainelli  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12967dd82fSFlorian Fainelli  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13967dd82fSFlorian Fainelli  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14967dd82fSFlorian Fainelli  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15967dd82fSFlorian Fainelli  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16967dd82fSFlorian Fainelli  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17967dd82fSFlorian Fainelli  */
18967dd82fSFlorian Fainelli 
19967dd82fSFlorian Fainelli #ifndef __B53_PRIV_H
20967dd82fSFlorian Fainelli #define __B53_PRIV_H
21967dd82fSFlorian Fainelli 
22967dd82fSFlorian Fainelli #include <linux/kernel.h>
23967dd82fSFlorian Fainelli #include <linux/mutex.h>
24967dd82fSFlorian Fainelli #include <linux/phy.h>
254b92ea81SFlorian Fainelli #include <linux/etherdevice.h>
26967dd82fSFlorian Fainelli #include <net/dsa.h>
27967dd82fSFlorian Fainelli 
281da6df85SFlorian Fainelli #include "b53_regs.h"
291da6df85SFlorian Fainelli 
30967dd82fSFlorian Fainelli struct b53_device;
31ff39c2d6SFlorian Fainelli struct net_device;
32967dd82fSFlorian Fainelli 
33967dd82fSFlorian Fainelli struct b53_io_ops {
34967dd82fSFlorian Fainelli 	int (*read8)(struct b53_device *dev, u8 page, u8 reg, u8 *value);
35967dd82fSFlorian Fainelli 	int (*read16)(struct b53_device *dev, u8 page, u8 reg, u16 *value);
36967dd82fSFlorian Fainelli 	int (*read32)(struct b53_device *dev, u8 page, u8 reg, u32 *value);
37967dd82fSFlorian Fainelli 	int (*read48)(struct b53_device *dev, u8 page, u8 reg, u64 *value);
38967dd82fSFlorian Fainelli 	int (*read64)(struct b53_device *dev, u8 page, u8 reg, u64 *value);
39967dd82fSFlorian Fainelli 	int (*write8)(struct b53_device *dev, u8 page, u8 reg, u8 value);
40967dd82fSFlorian Fainelli 	int (*write16)(struct b53_device *dev, u8 page, u8 reg, u16 value);
41967dd82fSFlorian Fainelli 	int (*write32)(struct b53_device *dev, u8 page, u8 reg, u32 value);
42967dd82fSFlorian Fainelli 	int (*write48)(struct b53_device *dev, u8 page, u8 reg, u64 value);
43967dd82fSFlorian Fainelli 	int (*write64)(struct b53_device *dev, u8 page, u8 reg, u64 value);
44967dd82fSFlorian Fainelli 	int (*phy_read16)(struct b53_device *dev, int addr, int reg, u16 *value);
45967dd82fSFlorian Fainelli 	int (*phy_write16)(struct b53_device *dev, int addr, int reg, u16 value);
46967dd82fSFlorian Fainelli };
47967dd82fSFlorian Fainelli 
48967dd82fSFlorian Fainelli enum {
49967dd82fSFlorian Fainelli 	BCM5325_DEVICE_ID = 0x25,
50967dd82fSFlorian Fainelli 	BCM5365_DEVICE_ID = 0x65,
51967dd82fSFlorian Fainelli 	BCM5395_DEVICE_ID = 0x95,
52967dd82fSFlorian Fainelli 	BCM5397_DEVICE_ID = 0x97,
53967dd82fSFlorian Fainelli 	BCM5398_DEVICE_ID = 0x98,
54967dd82fSFlorian Fainelli 	BCM53115_DEVICE_ID = 0x53115,
55967dd82fSFlorian Fainelli 	BCM53125_DEVICE_ID = 0x53125,
56967dd82fSFlorian Fainelli 	BCM53128_DEVICE_ID = 0x53128,
57967dd82fSFlorian Fainelli 	BCM63XX_DEVICE_ID = 0x6300,
58967dd82fSFlorian Fainelli 	BCM53010_DEVICE_ID = 0x53010,
59967dd82fSFlorian Fainelli 	BCM53011_DEVICE_ID = 0x53011,
60967dd82fSFlorian Fainelli 	BCM53012_DEVICE_ID = 0x53012,
61967dd82fSFlorian Fainelli 	BCM53018_DEVICE_ID = 0x53018,
62967dd82fSFlorian Fainelli 	BCM53019_DEVICE_ID = 0x53019,
63991a36bbSFlorian Fainelli 	BCM58XX_DEVICE_ID = 0x5800,
64130401d9SFlorian Fainelli 	BCM7445_DEVICE_ID = 0x7445,
65967dd82fSFlorian Fainelli };
66967dd82fSFlorian Fainelli 
67967dd82fSFlorian Fainelli #define B53_N_PORTS	9
68967dd82fSFlorian Fainelli #define B53_N_PORTS_25	6
69967dd82fSFlorian Fainelli 
70967dd82fSFlorian Fainelli struct b53_port {
71ff39c2d6SFlorian Fainelli 	u16		vlan_ctl_mask;
72ff39c2d6SFlorian Fainelli 	struct net_device *bridge_dev;
73967dd82fSFlorian Fainelli };
74967dd82fSFlorian Fainelli 
75a2482d2cSFlorian Fainelli struct b53_vlan {
76a2482d2cSFlorian Fainelli 	u16 members;
77a2482d2cSFlorian Fainelli 	u16 untag;
78a2482d2cSFlorian Fainelli 	bool valid;
79a2482d2cSFlorian Fainelli };
80a2482d2cSFlorian Fainelli 
81967dd82fSFlorian Fainelli struct b53_device {
82967dd82fSFlorian Fainelli 	struct dsa_switch *ds;
83967dd82fSFlorian Fainelli 	struct b53_platform_data *pdata;
84967dd82fSFlorian Fainelli 	const char *name;
85967dd82fSFlorian Fainelli 
86967dd82fSFlorian Fainelli 	struct mutex reg_mutex;
87967dd82fSFlorian Fainelli 	struct mutex stats_mutex;
88967dd82fSFlorian Fainelli 	const struct b53_io_ops *ops;
89967dd82fSFlorian Fainelli 
90967dd82fSFlorian Fainelli 	/* chip specific data */
91967dd82fSFlorian Fainelli 	u32 chip_id;
92967dd82fSFlorian Fainelli 	u8 core_rev;
93967dd82fSFlorian Fainelli 	u8 vta_regs[3];
94967dd82fSFlorian Fainelli 	u8 duplex_reg;
95967dd82fSFlorian Fainelli 	u8 jumbo_pm_reg;
96967dd82fSFlorian Fainelli 	u8 jumbo_size_reg;
97967dd82fSFlorian Fainelli 	int reset_gpio;
981da6df85SFlorian Fainelli 	u8 num_arl_entries;
99967dd82fSFlorian Fainelli 
100967dd82fSFlorian Fainelli 	/* used ports mask */
101967dd82fSFlorian Fainelli 	u16 enabled_ports;
102967dd82fSFlorian Fainelli 	unsigned int cpu_port;
103967dd82fSFlorian Fainelli 
104967dd82fSFlorian Fainelli 	/* connect specific data */
105967dd82fSFlorian Fainelli 	u8 current_page;
106967dd82fSFlorian Fainelli 	struct device *dev;
107967dd82fSFlorian Fainelli 
108967dd82fSFlorian Fainelli 	/* Master MDIO bus we got probed from */
109967dd82fSFlorian Fainelli 	struct mii_bus *bus;
110967dd82fSFlorian Fainelli 
111967dd82fSFlorian Fainelli 	void *priv;
112967dd82fSFlorian Fainelli 
113967dd82fSFlorian Fainelli 	/* run time configuration */
114a2482d2cSFlorian Fainelli 	bool enable_jumbo;
115a2482d2cSFlorian Fainelli 
116967dd82fSFlorian Fainelli 	unsigned int num_vlans;
117a2482d2cSFlorian Fainelli 	struct b53_vlan *vlans;
118967dd82fSFlorian Fainelli 	unsigned int num_ports;
119967dd82fSFlorian Fainelli 	struct b53_port *ports;
120967dd82fSFlorian Fainelli };
121967dd82fSFlorian Fainelli 
122967dd82fSFlorian Fainelli #define b53_for_each_port(dev, i) \
123967dd82fSFlorian Fainelli 	for (i = 0; i < B53_N_PORTS; i++) \
124967dd82fSFlorian Fainelli 		if (dev->enabled_ports & BIT(i))
125967dd82fSFlorian Fainelli 
126967dd82fSFlorian Fainelli 
127967dd82fSFlorian Fainelli static inline int is5325(struct b53_device *dev)
128967dd82fSFlorian Fainelli {
129967dd82fSFlorian Fainelli 	return dev->chip_id == BCM5325_DEVICE_ID;
130967dd82fSFlorian Fainelli }
131967dd82fSFlorian Fainelli 
132967dd82fSFlorian Fainelli static inline int is5365(struct b53_device *dev)
133967dd82fSFlorian Fainelli {
134967dd82fSFlorian Fainelli #ifdef CONFIG_BCM47XX
135967dd82fSFlorian Fainelli 	return dev->chip_id == BCM5365_DEVICE_ID;
136967dd82fSFlorian Fainelli #else
137967dd82fSFlorian Fainelli 	return 0;
138967dd82fSFlorian Fainelli #endif
139967dd82fSFlorian Fainelli }
140967dd82fSFlorian Fainelli 
141967dd82fSFlorian Fainelli static inline int is5397_98(struct b53_device *dev)
142967dd82fSFlorian Fainelli {
143967dd82fSFlorian Fainelli 	return dev->chip_id == BCM5397_DEVICE_ID ||
144967dd82fSFlorian Fainelli 		dev->chip_id == BCM5398_DEVICE_ID;
145967dd82fSFlorian Fainelli }
146967dd82fSFlorian Fainelli 
147967dd82fSFlorian Fainelli static inline int is539x(struct b53_device *dev)
148967dd82fSFlorian Fainelli {
149967dd82fSFlorian Fainelli 	return dev->chip_id == BCM5395_DEVICE_ID ||
150967dd82fSFlorian Fainelli 		dev->chip_id == BCM5397_DEVICE_ID ||
151967dd82fSFlorian Fainelli 		dev->chip_id == BCM5398_DEVICE_ID;
152967dd82fSFlorian Fainelli }
153967dd82fSFlorian Fainelli 
154967dd82fSFlorian Fainelli static inline int is531x5(struct b53_device *dev)
155967dd82fSFlorian Fainelli {
156967dd82fSFlorian Fainelli 	return dev->chip_id == BCM53115_DEVICE_ID ||
157967dd82fSFlorian Fainelli 		dev->chip_id == BCM53125_DEVICE_ID ||
158967dd82fSFlorian Fainelli 		dev->chip_id == BCM53128_DEVICE_ID;
159967dd82fSFlorian Fainelli }
160967dd82fSFlorian Fainelli 
161967dd82fSFlorian Fainelli static inline int is63xx(struct b53_device *dev)
162967dd82fSFlorian Fainelli {
163967dd82fSFlorian Fainelli #ifdef CONFIG_BCM63XX
164967dd82fSFlorian Fainelli 	return dev->chip_id == BCM63XX_DEVICE_ID;
165967dd82fSFlorian Fainelli #else
166967dd82fSFlorian Fainelli 	return 0;
167967dd82fSFlorian Fainelli #endif
168967dd82fSFlorian Fainelli }
169967dd82fSFlorian Fainelli 
170967dd82fSFlorian Fainelli static inline int is5301x(struct b53_device *dev)
171967dd82fSFlorian Fainelli {
172967dd82fSFlorian Fainelli 	return dev->chip_id == BCM53010_DEVICE_ID ||
173967dd82fSFlorian Fainelli 		dev->chip_id == BCM53011_DEVICE_ID ||
174967dd82fSFlorian Fainelli 		dev->chip_id == BCM53012_DEVICE_ID ||
175967dd82fSFlorian Fainelli 		dev->chip_id == BCM53018_DEVICE_ID ||
176967dd82fSFlorian Fainelli 		dev->chip_id == BCM53019_DEVICE_ID;
177967dd82fSFlorian Fainelli }
178967dd82fSFlorian Fainelli 
179bde5d132SFlorian Fainelli static inline int is58xx(struct b53_device *dev)
180bde5d132SFlorian Fainelli {
181bde5d132SFlorian Fainelli 	return dev->chip_id == BCM58XX_DEVICE_ID ||
182bde5d132SFlorian Fainelli 		dev->chip_id == BCM7445_DEVICE_ID;
183bde5d132SFlorian Fainelli }
184bde5d132SFlorian Fainelli 
185967dd82fSFlorian Fainelli #define B53_CPU_PORT_25	5
186967dd82fSFlorian Fainelli #define B53_CPU_PORT	8
187967dd82fSFlorian Fainelli 
188967dd82fSFlorian Fainelli static inline int is_cpu_port(struct b53_device *dev, int port)
189967dd82fSFlorian Fainelli {
190967dd82fSFlorian Fainelli 	return dev->cpu_port;
191967dd82fSFlorian Fainelli }
192967dd82fSFlorian Fainelli 
1930dff88d3SJulia Lawall struct b53_device *b53_switch_alloc(struct device *base,
1940dff88d3SJulia Lawall 				    const struct b53_io_ops *ops,
195967dd82fSFlorian Fainelli 				    void *priv);
196967dd82fSFlorian Fainelli 
197967dd82fSFlorian Fainelli int b53_switch_detect(struct b53_device *dev);
198967dd82fSFlorian Fainelli 
199967dd82fSFlorian Fainelli int b53_switch_register(struct b53_device *dev);
200967dd82fSFlorian Fainelli 
201967dd82fSFlorian Fainelli static inline void b53_switch_remove(struct b53_device *dev)
202967dd82fSFlorian Fainelli {
203967dd82fSFlorian Fainelli 	dsa_unregister_switch(dev->ds);
204967dd82fSFlorian Fainelli }
205967dd82fSFlorian Fainelli 
206967dd82fSFlorian Fainelli static inline int b53_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
207967dd82fSFlorian Fainelli {
208967dd82fSFlorian Fainelli 	int ret;
209967dd82fSFlorian Fainelli 
210967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
211967dd82fSFlorian Fainelli 	ret = dev->ops->read8(dev, page, reg, val);
212967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
213967dd82fSFlorian Fainelli 
214967dd82fSFlorian Fainelli 	return ret;
215967dd82fSFlorian Fainelli }
216967dd82fSFlorian Fainelli 
217967dd82fSFlorian Fainelli static inline int b53_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val)
218967dd82fSFlorian Fainelli {
219967dd82fSFlorian Fainelli 	int ret;
220967dd82fSFlorian Fainelli 
221967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
222967dd82fSFlorian Fainelli 	ret = dev->ops->read16(dev, page, reg, val);
223967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
224967dd82fSFlorian Fainelli 
225967dd82fSFlorian Fainelli 	return ret;
226967dd82fSFlorian Fainelli }
227967dd82fSFlorian Fainelli 
228967dd82fSFlorian Fainelli static inline int b53_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val)
229967dd82fSFlorian Fainelli {
230967dd82fSFlorian Fainelli 	int ret;
231967dd82fSFlorian Fainelli 
232967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
233967dd82fSFlorian Fainelli 	ret = dev->ops->read32(dev, page, reg, val);
234967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
235967dd82fSFlorian Fainelli 
236967dd82fSFlorian Fainelli 	return ret;
237967dd82fSFlorian Fainelli }
238967dd82fSFlorian Fainelli 
239967dd82fSFlorian Fainelli static inline int b53_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val)
240967dd82fSFlorian Fainelli {
241967dd82fSFlorian Fainelli 	int ret;
242967dd82fSFlorian Fainelli 
243967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
244967dd82fSFlorian Fainelli 	ret = dev->ops->read48(dev, page, reg, val);
245967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
246967dd82fSFlorian Fainelli 
247967dd82fSFlorian Fainelli 	return ret;
248967dd82fSFlorian Fainelli }
249967dd82fSFlorian Fainelli 
250967dd82fSFlorian Fainelli static inline int b53_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val)
251967dd82fSFlorian Fainelli {
252967dd82fSFlorian Fainelli 	int ret;
253967dd82fSFlorian Fainelli 
254967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
255967dd82fSFlorian Fainelli 	ret = dev->ops->read64(dev, page, reg, val);
256967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
257967dd82fSFlorian Fainelli 
258967dd82fSFlorian Fainelli 	return ret;
259967dd82fSFlorian Fainelli }
260967dd82fSFlorian Fainelli 
261967dd82fSFlorian Fainelli static inline int b53_write8(struct b53_device *dev, u8 page, u8 reg, u8 value)
262967dd82fSFlorian Fainelli {
263967dd82fSFlorian Fainelli 	int ret;
264967dd82fSFlorian Fainelli 
265967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
266967dd82fSFlorian Fainelli 	ret = dev->ops->write8(dev, page, reg, value);
267967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
268967dd82fSFlorian Fainelli 
269967dd82fSFlorian Fainelli 	return ret;
270967dd82fSFlorian Fainelli }
271967dd82fSFlorian Fainelli 
272967dd82fSFlorian Fainelli static inline int b53_write16(struct b53_device *dev, u8 page, u8 reg,
273967dd82fSFlorian Fainelli 			      u16 value)
274967dd82fSFlorian Fainelli {
275967dd82fSFlorian Fainelli 	int ret;
276967dd82fSFlorian Fainelli 
277967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
278967dd82fSFlorian Fainelli 	ret = dev->ops->write16(dev, page, reg, value);
279967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
280967dd82fSFlorian Fainelli 
281967dd82fSFlorian Fainelli 	return ret;
282967dd82fSFlorian Fainelli }
283967dd82fSFlorian Fainelli 
284967dd82fSFlorian Fainelli static inline int b53_write32(struct b53_device *dev, u8 page, u8 reg,
285967dd82fSFlorian Fainelli 			      u32 value)
286967dd82fSFlorian Fainelli {
287967dd82fSFlorian Fainelli 	int ret;
288967dd82fSFlorian Fainelli 
289967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
290967dd82fSFlorian Fainelli 	ret = dev->ops->write32(dev, page, reg, value);
291967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
292967dd82fSFlorian Fainelli 
293967dd82fSFlorian Fainelli 	return ret;
294967dd82fSFlorian Fainelli }
295967dd82fSFlorian Fainelli 
296967dd82fSFlorian Fainelli static inline int b53_write48(struct b53_device *dev, u8 page, u8 reg,
297967dd82fSFlorian Fainelli 			      u64 value)
298967dd82fSFlorian Fainelli {
299967dd82fSFlorian Fainelli 	int ret;
300967dd82fSFlorian Fainelli 
301967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
302967dd82fSFlorian Fainelli 	ret = dev->ops->write48(dev, page, reg, value);
303967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
304967dd82fSFlorian Fainelli 
305967dd82fSFlorian Fainelli 	return ret;
306967dd82fSFlorian Fainelli }
307967dd82fSFlorian Fainelli 
308967dd82fSFlorian Fainelli static inline int b53_write64(struct b53_device *dev, u8 page, u8 reg,
309967dd82fSFlorian Fainelli 			       u64 value)
310967dd82fSFlorian Fainelli {
311967dd82fSFlorian Fainelli 	int ret;
312967dd82fSFlorian Fainelli 
313967dd82fSFlorian Fainelli 	mutex_lock(&dev->reg_mutex);
314967dd82fSFlorian Fainelli 	ret = dev->ops->write64(dev, page, reg, value);
315967dd82fSFlorian Fainelli 	mutex_unlock(&dev->reg_mutex);
316967dd82fSFlorian Fainelli 
317967dd82fSFlorian Fainelli 	return ret;
318967dd82fSFlorian Fainelli }
319967dd82fSFlorian Fainelli 
3201da6df85SFlorian Fainelli struct b53_arl_entry {
3211da6df85SFlorian Fainelli 	u8 port;
3221da6df85SFlorian Fainelli 	u8 mac[ETH_ALEN];
3231da6df85SFlorian Fainelli 	u16 vid;
3241da6df85SFlorian Fainelli 	u8 is_valid:1;
3251da6df85SFlorian Fainelli 	u8 is_age:1;
3261da6df85SFlorian Fainelli 	u8 is_static:1;
3271da6df85SFlorian Fainelli };
3281da6df85SFlorian Fainelli 
3291da6df85SFlorian Fainelli static inline void b53_arl_to_entry(struct b53_arl_entry *ent,
3301da6df85SFlorian Fainelli 				    u64 mac_vid, u32 fwd_entry)
3311da6df85SFlorian Fainelli {
3321da6df85SFlorian Fainelli 	memset(ent, 0, sizeof(*ent));
3331da6df85SFlorian Fainelli 	ent->port = fwd_entry & ARLTBL_DATA_PORT_ID_MASK;
3341da6df85SFlorian Fainelli 	ent->is_valid = !!(fwd_entry & ARLTBL_VALID);
3351da6df85SFlorian Fainelli 	ent->is_age = !!(fwd_entry & ARLTBL_AGE);
3361da6df85SFlorian Fainelli 	ent->is_static = !!(fwd_entry & ARLTBL_STATIC);
3374b92ea81SFlorian Fainelli 	u64_to_ether_addr(mac_vid, ent->mac);
3381da6df85SFlorian Fainelli 	ent->vid = mac_vid >> ARLTBL_VID_S;
3391da6df85SFlorian Fainelli }
3401da6df85SFlorian Fainelli 
3411da6df85SFlorian Fainelli static inline void b53_arl_from_entry(u64 *mac_vid, u32 *fwd_entry,
3421da6df85SFlorian Fainelli 				      const struct b53_arl_entry *ent)
3431da6df85SFlorian Fainelli {
3444b92ea81SFlorian Fainelli 	*mac_vid = ether_addr_to_u64(ent->mac);
3451da6df85SFlorian Fainelli 	*mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK) << ARLTBL_VID_S;
3461da6df85SFlorian Fainelli 	*fwd_entry = ent->port & ARLTBL_DATA_PORT_ID_MASK;
3471da6df85SFlorian Fainelli 	if (ent->is_valid)
3481da6df85SFlorian Fainelli 		*fwd_entry |= ARLTBL_VALID;
3491da6df85SFlorian Fainelli 	if (ent->is_static)
3501da6df85SFlorian Fainelli 		*fwd_entry |= ARLTBL_STATIC;
3511da6df85SFlorian Fainelli 	if (ent->is_age)
3521da6df85SFlorian Fainelli 		*fwd_entry |= ARLTBL_AGE;
3531da6df85SFlorian Fainelli }
3541da6df85SFlorian Fainelli 
355967dd82fSFlorian Fainelli #ifdef CONFIG_BCM47XX
356967dd82fSFlorian Fainelli 
357967dd82fSFlorian Fainelli #include <linux/bcm47xx_nvram.h>
358967dd82fSFlorian Fainelli #include <bcm47xx_board.h>
359967dd82fSFlorian Fainelli static inline int b53_switch_get_reset_gpio(struct b53_device *dev)
360967dd82fSFlorian Fainelli {
361967dd82fSFlorian Fainelli 	enum bcm47xx_board board = bcm47xx_board_get();
362967dd82fSFlorian Fainelli 
363967dd82fSFlorian Fainelli 	switch (board) {
364967dd82fSFlorian Fainelli 	case BCM47XX_BOARD_LINKSYS_WRT300NV11:
365967dd82fSFlorian Fainelli 	case BCM47XX_BOARD_LINKSYS_WRT310NV1:
366967dd82fSFlorian Fainelli 		return 8;
367967dd82fSFlorian Fainelli 	default:
368967dd82fSFlorian Fainelli 		return bcm47xx_nvram_gpio_pin("robo_reset");
369967dd82fSFlorian Fainelli 	}
370967dd82fSFlorian Fainelli }
371967dd82fSFlorian Fainelli #else
372967dd82fSFlorian Fainelli static inline int b53_switch_get_reset_gpio(struct b53_device *dev)
373967dd82fSFlorian Fainelli {
374967dd82fSFlorian Fainelli 	return -ENOENT;
375967dd82fSFlorian Fainelli }
376967dd82fSFlorian Fainelli #endif
3773117455dSFlorian Fainelli 
3783117455dSFlorian Fainelli /* Exported functions towards other drivers */
3793117455dSFlorian Fainelli void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data);
3803117455dSFlorian Fainelli void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data);
3813117455dSFlorian Fainelli int b53_get_sset_count(struct dsa_switch *ds);
3823117455dSFlorian Fainelli int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge);
3833117455dSFlorian Fainelli void b53_br_leave(struct dsa_switch *ds, int port);
3843117455dSFlorian Fainelli void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state);
3853117455dSFlorian Fainelli void b53_br_fast_age(struct dsa_switch *ds, int port);
3863117455dSFlorian Fainelli int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering);
3873117455dSFlorian Fainelli int b53_vlan_prepare(struct dsa_switch *ds, int port,
3883117455dSFlorian Fainelli 		     const struct switchdev_obj_port_vlan *vlan,
3893117455dSFlorian Fainelli 		     struct switchdev_trans *trans);
3903117455dSFlorian Fainelli void b53_vlan_add(struct dsa_switch *ds, int port,
3913117455dSFlorian Fainelli 		  const struct switchdev_obj_port_vlan *vlan,
3923117455dSFlorian Fainelli 		  struct switchdev_trans *trans);
3933117455dSFlorian Fainelli int b53_vlan_del(struct dsa_switch *ds, int port,
3943117455dSFlorian Fainelli 		 const struct switchdev_obj_port_vlan *vlan);
3953117455dSFlorian Fainelli int b53_vlan_dump(struct dsa_switch *ds, int port,
3963117455dSFlorian Fainelli 		  struct switchdev_obj_port_vlan *vlan,
3973117455dSFlorian Fainelli 		  int (*cb)(struct switchdev_obj *obj));
3983117455dSFlorian Fainelli int b53_fdb_prepare(struct dsa_switch *ds, int port,
3993117455dSFlorian Fainelli 		    const struct switchdev_obj_port_fdb *fdb,
4003117455dSFlorian Fainelli 		    struct switchdev_trans *trans);
4013117455dSFlorian Fainelli void b53_fdb_add(struct dsa_switch *ds, int port,
4023117455dSFlorian Fainelli 		 const struct switchdev_obj_port_fdb *fdb,
4033117455dSFlorian Fainelli 		 struct switchdev_trans *trans);
4043117455dSFlorian Fainelli int b53_fdb_del(struct dsa_switch *ds, int port,
4053117455dSFlorian Fainelli 		const struct switchdev_obj_port_fdb *fdb);
4063117455dSFlorian Fainelli int b53_fdb_dump(struct dsa_switch *ds, int port,
4073117455dSFlorian Fainelli 		 struct switchdev_obj_port_fdb *fdb,
4083117455dSFlorian Fainelli 		 int (*cb)(struct switchdev_obj *obj));
4093117455dSFlorian Fainelli 
410967dd82fSFlorian Fainelli #endif
411