xref: /OK3568_Linux_fs/kernel/include/linux/platform_data/dsa.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __DSA_PDATA_H
3*4882a593Smuzhiyun #define __DSA_PDATA_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun struct device;
6*4882a593Smuzhiyun struct net_device;
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #define DSA_MAX_SWITCHES	4
9*4882a593Smuzhiyun #define DSA_MAX_PORTS		12
10*4882a593Smuzhiyun #define DSA_RTABLE_NONE		-1
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun struct dsa_chip_data {
13*4882a593Smuzhiyun 	/*
14*4882a593Smuzhiyun 	 * How to access the switch configuration registers.
15*4882a593Smuzhiyun 	 */
16*4882a593Smuzhiyun 	struct device	*host_dev;
17*4882a593Smuzhiyun 	int		sw_addr;
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun 	/*
20*4882a593Smuzhiyun 	 * Reference to network devices
21*4882a593Smuzhiyun 	 */
22*4882a593Smuzhiyun 	struct device	*netdev[DSA_MAX_PORTS];
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	/* set to size of eeprom if supported by the switch */
25*4882a593Smuzhiyun 	int		eeprom_len;
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun 	/* Device tree node pointer for this specific switch chip
28*4882a593Smuzhiyun 	 * used during switch setup in case additional properties
29*4882a593Smuzhiyun 	 * and resources needs to be used
30*4882a593Smuzhiyun 	 */
31*4882a593Smuzhiyun 	struct device_node *of_node;
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun 	/*
34*4882a593Smuzhiyun 	 * The names of the switch's ports.  Use "cpu" to
35*4882a593Smuzhiyun 	 * designate the switch port that the cpu is connected to,
36*4882a593Smuzhiyun 	 * "dsa" to indicate that this port is a DSA link to
37*4882a593Smuzhiyun 	 * another switch, NULL to indicate the port is unused,
38*4882a593Smuzhiyun 	 * or any other string to indicate this is a physical port.
39*4882a593Smuzhiyun 	 */
40*4882a593Smuzhiyun 	char		*port_names[DSA_MAX_PORTS];
41*4882a593Smuzhiyun 	struct device_node *port_dn[DSA_MAX_PORTS];
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun 	/*
44*4882a593Smuzhiyun 	 * An array of which element [a] indicates which port on this
45*4882a593Smuzhiyun 	 * switch should be used to send packets to that are destined
46*4882a593Smuzhiyun 	 * for switch a. Can be NULL if there is only one switch chip.
47*4882a593Smuzhiyun 	 */
48*4882a593Smuzhiyun 	s8		rtable[DSA_MAX_SWITCHES];
49*4882a593Smuzhiyun };
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun struct dsa_platform_data {
52*4882a593Smuzhiyun 	/*
53*4882a593Smuzhiyun 	 * Reference to a Linux network interface that connects
54*4882a593Smuzhiyun 	 * to the root switch chip of the tree.
55*4882a593Smuzhiyun 	 */
56*4882a593Smuzhiyun 	struct device	*netdev;
57*4882a593Smuzhiyun 	struct net_device *of_netdev;
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun 	/*
60*4882a593Smuzhiyun 	 * Info structs describing each of the switch chips
61*4882a593Smuzhiyun 	 * connected via this network interface.
62*4882a593Smuzhiyun 	 */
63*4882a593Smuzhiyun 	int		nr_chips;
64*4882a593Smuzhiyun 	struct dsa_chip_data	*chip;
65*4882a593Smuzhiyun };
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun #endif /* __DSA_PDATA_H */
69