hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/dsa/qca8k.h
....@@ -1,16 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name>
34 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
45 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 and
8
- * only version 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
168 #ifndef __QCA8K_H
....@@ -18,8 +10,10 @@
1810
1911 #include <linux/delay.h>
2012 #include <linux/regmap.h>
13
+#include <linux/gpio.h>
2114
2215 #define QCA8K_NUM_PORTS 7
16
+#define QCA8K_MAX_MTU 9000
2317
2418 #define PHY_ID_QCA8337 0x004dd036
2519 #define QCA8K_ID_QCA8337 0x13
....@@ -27,6 +21,8 @@
2721 #define QCA8K_NUM_FDB_RECORDS 2048
2822
2923 #define QCA8K_CPU_PORT 0
24
+
25
+#define QCA8K_PORT_VID_DEF 1
3026
3127 /* Global control registers */
3228 #define QCA8K_REG_MASK_CTRL 0x000
....@@ -43,14 +39,29 @@
4339 #define QCA8K_MAX_DELAY 3
4440 #define QCA8K_PORT_PAD_RGMII_RX_DELAY_EN BIT(24)
4541 #define QCA8K_PORT_PAD_SGMII_EN BIT(7)
42
+#define QCA8K_REG_PWS 0x010
43
+#define QCA8K_PWS_SERDES_AEN_DIS BIT(7)
4644 #define QCA8K_REG_MODULE_EN 0x030
4745 #define QCA8K_MODULE_EN_MIB BIT(0)
4846 #define QCA8K_REG_MIB 0x034
4947 #define QCA8K_MIB_FLUSH BIT(24)
5048 #define QCA8K_MIB_CPU_KEEP BIT(20)
5149 #define QCA8K_MIB_BUSY BIT(17)
50
+#define QCA8K_MDIO_MASTER_CTRL 0x3c
51
+#define QCA8K_MDIO_MASTER_BUSY BIT(31)
52
+#define QCA8K_MDIO_MASTER_EN BIT(30)
53
+#define QCA8K_MDIO_MASTER_READ BIT(27)
54
+#define QCA8K_MDIO_MASTER_WRITE 0
55
+#define QCA8K_MDIO_MASTER_SUP_PRE BIT(26)
56
+#define QCA8K_MDIO_MASTER_PHY_ADDR(x) ((x) << 21)
57
+#define QCA8K_MDIO_MASTER_REG_ADDR(x) ((x) << 16)
58
+#define QCA8K_MDIO_MASTER_DATA(x) (x)
59
+#define QCA8K_MDIO_MASTER_DATA_MASK GENMASK(15, 0)
60
+#define QCA8K_MDIO_MASTER_MAX_PORTS 5
61
+#define QCA8K_MDIO_MASTER_MAX_REG 32
5262 #define QCA8K_GOL_MAC_ADDR0 0x60
5363 #define QCA8K_GOL_MAC_ADDR1 0x64
64
+#define QCA8K_MAX_FRAME_SIZE 0x78
5465 #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4)
5566 #define QCA8K_PORT_STATUS_SPEED GENMASK(1, 0)
5667 #define QCA8K_PORT_STATUS_SPEED_10 0
....@@ -64,6 +75,7 @@
6475 #define QCA8K_PORT_STATUS_LINK_UP BIT(8)
6576 #define QCA8K_PORT_STATUS_LINK_AUTO BIT(9)
6677 #define QCA8K_PORT_STATUS_LINK_PAUSE BIT(10)
78
+#define QCA8K_PORT_STATUS_FLOW_AUTO BIT(12)
6779 #define QCA8K_REG_PORT_HDR_CTRL(_i) (0x9c + (_i * 4))
6880 #define QCA8K_PORT_HDR_CTRL_RX_MASK GENMASK(3, 2)
6981 #define QCA8K_PORT_HDR_CTRL_RX_S 2
....@@ -72,6 +84,16 @@
7284 #define QCA8K_PORT_HDR_CTRL_ALL 2
7385 #define QCA8K_PORT_HDR_CTRL_MGMT 1
7486 #define QCA8K_PORT_HDR_CTRL_NONE 0
87
+#define QCA8K_REG_SGMII_CTRL 0x0e0
88
+#define QCA8K_SGMII_EN_PLL BIT(1)
89
+#define QCA8K_SGMII_EN_RX BIT(2)
90
+#define QCA8K_SGMII_EN_TX BIT(3)
91
+#define QCA8K_SGMII_EN_SD BIT(4)
92
+#define QCA8K_SGMII_CLK125M_DELAY BIT(7)
93
+#define QCA8K_SGMII_MODE_CTRL_MASK (BIT(22) | BIT(23))
94
+#define QCA8K_SGMII_MODE_CTRL_BASEX (0 << 22)
95
+#define QCA8K_SGMII_MODE_CTRL_PHY (1 << 22)
96
+#define QCA8K_SGMII_MODE_CTRL_MAC (2 << 22)
7597
7698 /* EEE control registers */
7799 #define QCA8K_REG_EEE_CTRL 0x100
....@@ -106,6 +128,19 @@
106128 #define QCA8K_ATU_FUNC_FULL BIT(12)
107129 #define QCA8K_ATU_FUNC_PORT_M 0xf
108130 #define QCA8K_ATU_FUNC_PORT_S 8
131
+#define QCA8K_REG_VTU_FUNC0 0x610
132
+#define QCA8K_VTU_FUNC0_VALID BIT(20)
133
+#define QCA8K_VTU_FUNC0_IVL_EN BIT(19)
134
+#define QCA8K_VTU_FUNC0_EG_MODE_S(_i) (4 + (_i) * 2)
135
+#define QCA8K_VTU_FUNC0_EG_MODE_MASK 3
136
+#define QCA8K_VTU_FUNC0_EG_MODE_UNMOD 0
137
+#define QCA8K_VTU_FUNC0_EG_MODE_UNTAG 1
138
+#define QCA8K_VTU_FUNC0_EG_MODE_TAG 2
139
+#define QCA8K_VTU_FUNC0_EG_MODE_NOT 3
140
+#define QCA8K_REG_VTU_FUNC1 0x614
141
+#define QCA8K_VTU_FUNC1_BUSY BIT(31)
142
+#define QCA8K_VTU_FUNC1_VID_S 16
143
+#define QCA8K_VTU_FUNC1_FULL BIT(4)
109144 #define QCA8K_REG_GLOBAL_FW_CTRL0 0x620
110145 #define QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN BIT(10)
111146 #define QCA8K_REG_GLOBAL_FW_CTRL1 0x624
....@@ -115,6 +150,11 @@
115150 #define QCA8K_GLOBAL_FW_CTRL1_UC_DP_S 0
116151 #define QCA8K_PORT_LOOKUP_CTRL(_i) (0x660 + (_i) * 0xc)
117152 #define QCA8K_PORT_LOOKUP_MEMBER GENMASK(6, 0)
153
+#define QCA8K_PORT_LOOKUP_VLAN_MODE GENMASK(9, 8)
154
+#define QCA8K_PORT_LOOKUP_VLAN_MODE_NONE (0 << 8)
155
+#define QCA8K_PORT_LOOKUP_VLAN_MODE_FALLBACK (1 << 8)
156
+#define QCA8K_PORT_LOOKUP_VLAN_MODE_CHECK (2 << 8)
157
+#define QCA8K_PORT_LOOKUP_VLAN_MODE_SECURE (3 << 8)
118158 #define QCA8K_PORT_LOOKUP_STATE_MASK GENMASK(18, 16)
119159 #define QCA8K_PORT_LOOKUP_STATE_DISABLED (0 << 16)
120160 #define QCA8K_PORT_LOOKUP_STATE_BLOCKING (1 << 16)
....@@ -158,6 +198,15 @@
158198 QCA8K_FDB_SEARCH = 7,
159199 };
160200
201
+enum qca8k_vlan_cmd {
202
+ QCA8K_VLAN_FLUSH = 1,
203
+ QCA8K_VLAN_LOAD = 2,
204
+ QCA8K_VLAN_PURGE = 3,
205
+ QCA8K_VLAN_REMOVE_PORT = 4,
206
+ QCA8K_VLAN_NEXT = 5,
207
+ QCA8K_VLAN_READ = 6,
208
+};
209
+
161210 struct ar8xxx_port_status {
162211 int enabled;
163212 };
....@@ -169,6 +218,9 @@
169218 struct dsa_switch *ds;
170219 struct mutex reg_mutex;
171220 struct device *dev;
221
+ struct dsa_switch_ops ops;
222
+ struct gpio_desc *reset_gpio;
223
+ unsigned int port_mtu[QCA8K_NUM_PORTS];
172224 };
173225
174226 struct qca8k_mib_desc {