1e9b4ece7SMD Danish Anwar // SPDX-License-Identifier: GPL-2.0
2e9b4ece7SMD Danish Anwar /* Texas Instruments ICSSG Ethernet Driver
3e9b4ece7SMD Danish Anwar *
4e9b4ece7SMD Danish Anwar * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
5e9b4ece7SMD Danish Anwar *
6e9b4ece7SMD Danish Anwar */
7e9b4ece7SMD Danish Anwar
8e9b4ece7SMD Danish Anwar #include <linux/etherdevice.h>
9e9b4ece7SMD Danish Anwar #include <linux/types.h>
10e9b4ece7SMD Danish Anwar #include <linux/regmap.h>
11e9b4ece7SMD Danish Anwar
12e9b4ece7SMD Danish Anwar #include "icssg_prueth.h"
13e9b4ece7SMD Danish Anwar
14e9b4ece7SMD Danish Anwar #define ICSSG_NUM_CLASSIFIERS 16
15e9b4ece7SMD Danish Anwar #define ICSSG_NUM_FT1_SLOTS 8
16e9b4ece7SMD Danish Anwar #define ICSSG_NUM_FT3_SLOTS 16
17e9b4ece7SMD Danish Anwar
18e9b4ece7SMD Danish Anwar #define ICSSG_NUM_CLASSIFIERS_IN_USE 5
19e9b4ece7SMD Danish Anwar
20e9b4ece7SMD Danish Anwar /* Filter 1 - FT1 */
21e9b4ece7SMD Danish Anwar #define FT1_NUM_SLOTS 8
22e9b4ece7SMD Danish Anwar #define FT1_SLOT_SIZE 0x10 /* bytes */
23e9b4ece7SMD Danish Anwar
24e9b4ece7SMD Danish Anwar /* offsets from FT1 slot base i.e. slot 1 start */
25e9b4ece7SMD Danish Anwar #define FT1_DA0 0x0
26e9b4ece7SMD Danish Anwar #define FT1_DA1 0x4
27e9b4ece7SMD Danish Anwar #define FT1_DA0_MASK 0x8
28e9b4ece7SMD Danish Anwar #define FT1_DA1_MASK 0xc
29e9b4ece7SMD Danish Anwar
30e9b4ece7SMD Danish Anwar #define FT1_N_REG(slize, n, reg) \
31e9b4ece7SMD Danish Anwar (offs[slice].ft1_slot_base + FT1_SLOT_SIZE * (n) + (reg))
32e9b4ece7SMD Danish Anwar
33e9b4ece7SMD Danish Anwar #define FT1_LEN_MASK GENMASK(19, 16)
34e9b4ece7SMD Danish Anwar #define FT1_LEN_SHIFT 16
35e9b4ece7SMD Danish Anwar #define FT1_LEN(len) (((len) << FT1_LEN_SHIFT) & FT1_LEN_MASK)
36e9b4ece7SMD Danish Anwar #define FT1_START_MASK GENMASK(14, 0)
37e9b4ece7SMD Danish Anwar #define FT1_START(start) ((start) & FT1_START_MASK)
38e9b4ece7SMD Danish Anwar #define FT1_MATCH_SLOT(n) (GENMASK(23, 16) & (BIT(n) << 16))
39e9b4ece7SMD Danish Anwar
40e9b4ece7SMD Danish Anwar /* FT1 config type */
41e9b4ece7SMD Danish Anwar enum ft1_cfg_type {
42e9b4ece7SMD Danish Anwar FT1_CFG_TYPE_DISABLED = 0,
43e9b4ece7SMD Danish Anwar FT1_CFG_TYPE_EQ,
44e9b4ece7SMD Danish Anwar FT1_CFG_TYPE_GT,
45e9b4ece7SMD Danish Anwar FT1_CFG_TYPE_LT,
46e9b4ece7SMD Danish Anwar };
47e9b4ece7SMD Danish Anwar
48e9b4ece7SMD Danish Anwar #define FT1_CFG_SHIFT(n) (2 * (n))
49e9b4ece7SMD Danish Anwar #define FT1_CFG_MASK(n) (0x3 << FT1_CFG_SHIFT((n)))
50e9b4ece7SMD Danish Anwar
51e9b4ece7SMD Danish Anwar /* Filter 3 - FT3 */
52e9b4ece7SMD Danish Anwar #define FT3_NUM_SLOTS 16
53e9b4ece7SMD Danish Anwar #define FT3_SLOT_SIZE 0x20 /* bytes */
54e9b4ece7SMD Danish Anwar
55e9b4ece7SMD Danish Anwar /* offsets from FT3 slot n's base */
56e9b4ece7SMD Danish Anwar #define FT3_START 0
57e9b4ece7SMD Danish Anwar #define FT3_START_AUTO 0x4
58e9b4ece7SMD Danish Anwar #define FT3_START_OFFSET 0x8
59e9b4ece7SMD Danish Anwar #define FT3_JUMP_OFFSET 0xc
60e9b4ece7SMD Danish Anwar #define FT3_LEN 0x10
61e9b4ece7SMD Danish Anwar #define FT3_CFG 0x14
62e9b4ece7SMD Danish Anwar #define FT3_T 0x18
63e9b4ece7SMD Danish Anwar #define FT3_T_MASK 0x1c
64e9b4ece7SMD Danish Anwar
65e9b4ece7SMD Danish Anwar #define FT3_N_REG(slize, n, reg) \
66e9b4ece7SMD Danish Anwar (offs[slice].ft3_slot_base + FT3_SLOT_SIZE * (n) + (reg))
67e9b4ece7SMD Danish Anwar
68e9b4ece7SMD Danish Anwar /* offsets from rx_class n's base */
69e9b4ece7SMD Danish Anwar #define RX_CLASS_AND_EN 0
70e9b4ece7SMD Danish Anwar #define RX_CLASS_OR_EN 0x4
71e9b4ece7SMD Danish Anwar #define RX_CLASS_NUM_SLOTS 16
72e9b4ece7SMD Danish Anwar #define RX_CLASS_EN_SIZE 0x8 /* bytes */
73e9b4ece7SMD Danish Anwar
74e9b4ece7SMD Danish Anwar #define RX_CLASS_N_REG(slice, n, reg) \
75e9b4ece7SMD Danish Anwar (offs[slice].rx_class_base + RX_CLASS_EN_SIZE * (n) + (reg))
76e9b4ece7SMD Danish Anwar
77e9b4ece7SMD Danish Anwar /* RX Class Gates */
78e9b4ece7SMD Danish Anwar #define RX_CLASS_GATES_SIZE 0x4 /* bytes */
79e9b4ece7SMD Danish Anwar
80e9b4ece7SMD Danish Anwar #define RX_CLASS_GATES_N_REG(slice, n) \
81e9b4ece7SMD Danish Anwar (offs[slice].rx_class_gates_base + RX_CLASS_GATES_SIZE * (n))
82e9b4ece7SMD Danish Anwar
83e9b4ece7SMD Danish Anwar #define RX_CLASS_GATES_ALLOW_MASK BIT(6)
84e9b4ece7SMD Danish Anwar #define RX_CLASS_GATES_RAW_MASK BIT(5)
85e9b4ece7SMD Danish Anwar #define RX_CLASS_GATES_PHASE_MASK BIT(4)
86e9b4ece7SMD Danish Anwar
87e9b4ece7SMD Danish Anwar /* RX Class traffic data matching bits */
88e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_UC BIT(31)
89e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_MC BIT(30)
90e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_BC BIT(29)
91e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_FW BIT(28)
92e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_RCV BIT(27)
93e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_VLAN BIT(26)
94e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_DA_P BIT(25)
95e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_DA_I BIT(24)
96e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_FT1_MATCH_MASK GENMASK(23, 16)
97e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_FT1_MATCH_SHIFT 16
98e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_FT3_MATCH_MASK GENMASK(15, 0)
99e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_FT3_MATCH_SHIFT 0
100e9b4ece7SMD Danish Anwar
101e9b4ece7SMD Danish Anwar #define RX_CLASS_FT_FT1_MATCH(slot) \
102e9b4ece7SMD Danish Anwar ((BIT(slot) << RX_CLASS_FT_FT1_MATCH_SHIFT) & \
103e9b4ece7SMD Danish Anwar RX_CLASS_FT_FT1_MATCH_MASK)
104e9b4ece7SMD Danish Anwar
105e9b4ece7SMD Danish Anwar /* RX class type */
106e9b4ece7SMD Danish Anwar enum rx_class_sel_type {
107e9b4ece7SMD Danish Anwar RX_CLASS_SEL_TYPE_OR = 0,
108e9b4ece7SMD Danish Anwar RX_CLASS_SEL_TYPE_AND = 1,
109e9b4ece7SMD Danish Anwar RX_CLASS_SEL_TYPE_OR_AND_AND = 2,
110e9b4ece7SMD Danish Anwar RX_CLASS_SEL_TYPE_OR_OR_AND = 3,
111e9b4ece7SMD Danish Anwar };
112e9b4ece7SMD Danish Anwar
113e9b4ece7SMD Danish Anwar #define FT1_CFG_SHIFT(n) (2 * (n))
114e9b4ece7SMD Danish Anwar #define FT1_CFG_MASK(n) (0x3 << FT1_CFG_SHIFT((n)))
115e9b4ece7SMD Danish Anwar
116e9b4ece7SMD Danish Anwar #define RX_CLASS_SEL_SHIFT(n) (2 * (n))
117e9b4ece7SMD Danish Anwar #define RX_CLASS_SEL_MASK(n) (0x3 << RX_CLASS_SEL_SHIFT((n)))
118e9b4ece7SMD Danish Anwar
119e9b4ece7SMD Danish Anwar #define ICSSG_CFG_OFFSET 0
120e9b4ece7SMD Danish Anwar #define MAC_INTERFACE_0 0x18
121e9b4ece7SMD Danish Anwar #define MAC_INTERFACE_1 0x1c
122e9b4ece7SMD Danish Anwar
123e9b4ece7SMD Danish Anwar #define ICSSG_CFG_RX_L2_G_EN BIT(2)
124e9b4ece7SMD Danish Anwar
125e9b4ece7SMD Danish Anwar /* These are register offsets per PRU */
126e9b4ece7SMD Danish Anwar struct miig_rt_offsets {
127e9b4ece7SMD Danish Anwar u32 mac0;
128e9b4ece7SMD Danish Anwar u32 mac1;
129e9b4ece7SMD Danish Anwar u32 ft1_start_len;
130e9b4ece7SMD Danish Anwar u32 ft1_cfg;
131e9b4ece7SMD Danish Anwar u32 ft1_slot_base;
132e9b4ece7SMD Danish Anwar u32 ft3_slot_base;
133e9b4ece7SMD Danish Anwar u32 ft3_p_base;
134e9b4ece7SMD Danish Anwar u32 ft_rx_ptr;
135e9b4ece7SMD Danish Anwar u32 rx_class_base;
136e9b4ece7SMD Danish Anwar u32 rx_class_cfg1;
137e9b4ece7SMD Danish Anwar u32 rx_class_cfg2;
138e9b4ece7SMD Danish Anwar u32 rx_class_gates_base;
139e9b4ece7SMD Danish Anwar u32 rx_green;
140e9b4ece7SMD Danish Anwar u32 rx_rate_cfg_base;
141e9b4ece7SMD Danish Anwar u32 rx_rate_src_sel0;
142e9b4ece7SMD Danish Anwar u32 rx_rate_src_sel1;
143e9b4ece7SMD Danish Anwar u32 tx_rate_cfg_base;
144e9b4ece7SMD Danish Anwar u32 stat_base;
145e9b4ece7SMD Danish Anwar u32 tx_hsr_tag;
146e9b4ece7SMD Danish Anwar u32 tx_hsr_seq;
147e9b4ece7SMD Danish Anwar u32 tx_vlan_type;
148e9b4ece7SMD Danish Anwar u32 tx_vlan_ins;
149e9b4ece7SMD Danish Anwar };
150e9b4ece7SMD Danish Anwar
151e9b4ece7SMD Danish Anwar /* These are the offset values for miig_rt_offsets registers */
152e9b4ece7SMD Danish Anwar static const struct miig_rt_offsets offs[] = {
153e9b4ece7SMD Danish Anwar /* PRU0 */
154e9b4ece7SMD Danish Anwar {
155e9b4ece7SMD Danish Anwar 0x8,
156e9b4ece7SMD Danish Anwar 0xc,
157e9b4ece7SMD Danish Anwar 0x80,
158e9b4ece7SMD Danish Anwar 0x84,
159e9b4ece7SMD Danish Anwar 0x88,
160e9b4ece7SMD Danish Anwar 0x108,
161e9b4ece7SMD Danish Anwar 0x308,
162e9b4ece7SMD Danish Anwar 0x408,
163e9b4ece7SMD Danish Anwar 0x40c,
164e9b4ece7SMD Danish Anwar 0x48c,
165e9b4ece7SMD Danish Anwar 0x490,
166e9b4ece7SMD Danish Anwar 0x494,
167e9b4ece7SMD Danish Anwar 0x4d4,
168e9b4ece7SMD Danish Anwar 0x4e4,
169e9b4ece7SMD Danish Anwar 0x504,
170e9b4ece7SMD Danish Anwar 0x508,
171e9b4ece7SMD Danish Anwar 0x50c,
172e9b4ece7SMD Danish Anwar 0x54c,
173e9b4ece7SMD Danish Anwar 0x63c,
174e9b4ece7SMD Danish Anwar 0x640,
175e9b4ece7SMD Danish Anwar 0x644,
176e9b4ece7SMD Danish Anwar 0x648,
177e9b4ece7SMD Danish Anwar },
178e9b4ece7SMD Danish Anwar /* PRU1 */
179e9b4ece7SMD Danish Anwar {
180e9b4ece7SMD Danish Anwar 0x10,
181e9b4ece7SMD Danish Anwar 0x14,
182e9b4ece7SMD Danish Anwar 0x64c,
183e9b4ece7SMD Danish Anwar 0x650,
184e9b4ece7SMD Danish Anwar 0x654,
185e9b4ece7SMD Danish Anwar 0x6d4,
186e9b4ece7SMD Danish Anwar 0x8d4,
187e9b4ece7SMD Danish Anwar 0x9d4,
188e9b4ece7SMD Danish Anwar 0x9d8,
189e9b4ece7SMD Danish Anwar 0xa58,
190e9b4ece7SMD Danish Anwar 0xa5c,
191e9b4ece7SMD Danish Anwar 0xa60,
192e9b4ece7SMD Danish Anwar 0xaa0,
193e9b4ece7SMD Danish Anwar 0xab0,
194e9b4ece7SMD Danish Anwar 0xad0,
195e9b4ece7SMD Danish Anwar 0xad4,
196e9b4ece7SMD Danish Anwar 0xad8,
197e9b4ece7SMD Danish Anwar 0xb18,
198e9b4ece7SMD Danish Anwar 0xc08,
199e9b4ece7SMD Danish Anwar 0xc0c,
200e9b4ece7SMD Danish Anwar 0xc10,
201e9b4ece7SMD Danish Anwar 0xc14,
202e9b4ece7SMD Danish Anwar },
203e9b4ece7SMD Danish Anwar };
204e9b4ece7SMD Danish Anwar
rx_class_ft1_set_start_len(struct regmap * miig_rt,int slice,u16 start,u8 len)205e9b4ece7SMD Danish Anwar static void rx_class_ft1_set_start_len(struct regmap *miig_rt, int slice,
206e9b4ece7SMD Danish Anwar u16 start, u8 len)
207e9b4ece7SMD Danish Anwar {
208e9b4ece7SMD Danish Anwar u32 offset, val;
209e9b4ece7SMD Danish Anwar
210e9b4ece7SMD Danish Anwar offset = offs[slice].ft1_start_len;
211e9b4ece7SMD Danish Anwar val = FT1_LEN(len) | FT1_START(start);
212e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, val);
213e9b4ece7SMD Danish Anwar }
214e9b4ece7SMD Danish Anwar
rx_class_ft1_set_da(struct regmap * miig_rt,int slice,int n,const u8 * addr)215e9b4ece7SMD Danish Anwar static void rx_class_ft1_set_da(struct regmap *miig_rt, int slice,
216e9b4ece7SMD Danish Anwar int n, const u8 *addr)
217e9b4ece7SMD Danish Anwar {
218e9b4ece7SMD Danish Anwar u32 offset;
219e9b4ece7SMD Danish Anwar
220e9b4ece7SMD Danish Anwar offset = FT1_N_REG(slice, n, FT1_DA0);
221e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, (u32)(addr[0] | addr[1] << 8 |
222e9b4ece7SMD Danish Anwar addr[2] << 16 | addr[3] << 24));
223e9b4ece7SMD Danish Anwar offset = FT1_N_REG(slice, n, FT1_DA1);
224e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, (u32)(addr[4] | addr[5] << 8));
225e9b4ece7SMD Danish Anwar }
226e9b4ece7SMD Danish Anwar
rx_class_ft1_set_da_mask(struct regmap * miig_rt,int slice,int n,const u8 * addr)227e9b4ece7SMD Danish Anwar static void rx_class_ft1_set_da_mask(struct regmap *miig_rt, int slice,
228e9b4ece7SMD Danish Anwar int n, const u8 *addr)
229e9b4ece7SMD Danish Anwar {
230e9b4ece7SMD Danish Anwar u32 offset;
231e9b4ece7SMD Danish Anwar
232e9b4ece7SMD Danish Anwar offset = FT1_N_REG(slice, n, FT1_DA0_MASK);
233e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, (u32)(addr[0] | addr[1] << 8 |
234e9b4ece7SMD Danish Anwar addr[2] << 16 | addr[3] << 24));
235e9b4ece7SMD Danish Anwar offset = FT1_N_REG(slice, n, FT1_DA1_MASK);
236e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, (u32)(addr[4] | addr[5] << 8));
237e9b4ece7SMD Danish Anwar }
238e9b4ece7SMD Danish Anwar
rx_class_ft1_cfg_set_type(struct regmap * miig_rt,int slice,int n,enum ft1_cfg_type type)239e9b4ece7SMD Danish Anwar static void rx_class_ft1_cfg_set_type(struct regmap *miig_rt, int slice, int n,
240e9b4ece7SMD Danish Anwar enum ft1_cfg_type type)
241e9b4ece7SMD Danish Anwar {
242e9b4ece7SMD Danish Anwar u32 offset;
243e9b4ece7SMD Danish Anwar
244e9b4ece7SMD Danish Anwar offset = offs[slice].ft1_cfg;
245e9b4ece7SMD Danish Anwar regmap_update_bits(miig_rt, offset, FT1_CFG_MASK(n),
246e9b4ece7SMD Danish Anwar type << FT1_CFG_SHIFT(n));
247e9b4ece7SMD Danish Anwar }
248e9b4ece7SMD Danish Anwar
rx_class_sel_set_type(struct regmap * miig_rt,int slice,int n,enum rx_class_sel_type type)249e9b4ece7SMD Danish Anwar static void rx_class_sel_set_type(struct regmap *miig_rt, int slice, int n,
250e9b4ece7SMD Danish Anwar enum rx_class_sel_type type)
251e9b4ece7SMD Danish Anwar {
252e9b4ece7SMD Danish Anwar u32 offset;
253e9b4ece7SMD Danish Anwar
254e9b4ece7SMD Danish Anwar offset = offs[slice].rx_class_cfg1;
255e9b4ece7SMD Danish Anwar regmap_update_bits(miig_rt, offset, RX_CLASS_SEL_MASK(n),
256e9b4ece7SMD Danish Anwar type << RX_CLASS_SEL_SHIFT(n));
257e9b4ece7SMD Danish Anwar }
258e9b4ece7SMD Danish Anwar
rx_class_set_and(struct regmap * miig_rt,int slice,int n,u32 data)259e9b4ece7SMD Danish Anwar static void rx_class_set_and(struct regmap *miig_rt, int slice, int n,
260e9b4ece7SMD Danish Anwar u32 data)
261e9b4ece7SMD Danish Anwar {
262e9b4ece7SMD Danish Anwar u32 offset;
263e9b4ece7SMD Danish Anwar
264e9b4ece7SMD Danish Anwar offset = RX_CLASS_N_REG(slice, n, RX_CLASS_AND_EN);
265e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, data);
266e9b4ece7SMD Danish Anwar }
267e9b4ece7SMD Danish Anwar
rx_class_set_or(struct regmap * miig_rt,int slice,int n,u32 data)268e9b4ece7SMD Danish Anwar static void rx_class_set_or(struct regmap *miig_rt, int slice, int n,
269e9b4ece7SMD Danish Anwar u32 data)
270e9b4ece7SMD Danish Anwar {
271e9b4ece7SMD Danish Anwar u32 offset;
272e9b4ece7SMD Danish Anwar
273e9b4ece7SMD Danish Anwar offset = RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN);
274e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, data);
275e9b4ece7SMD Danish Anwar }
276e9b4ece7SMD Danish Anwar
icssg_class_set_host_mac_addr(struct regmap * miig_rt,const u8 * mac)277e9b4ece7SMD Danish Anwar void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac)
278e9b4ece7SMD Danish Anwar {
279e9b4ece7SMD Danish Anwar regmap_write(miig_rt, MAC_INTERFACE_0, (u32)(mac[0] | mac[1] << 8 |
280e9b4ece7SMD Danish Anwar mac[2] << 16 | mac[3] << 24));
281e9b4ece7SMD Danish Anwar regmap_write(miig_rt, MAC_INTERFACE_1, (u32)(mac[4] | mac[5] << 8));
282e9b4ece7SMD Danish Anwar }
283e9b4ece7SMD Danish Anwar
icssg_class_set_mac_addr(struct regmap * miig_rt,int slice,u8 * mac)284e9b4ece7SMD Danish Anwar void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac)
285e9b4ece7SMD Danish Anwar {
286e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offs[slice].mac0, (u32)(mac[0] | mac[1] << 8 |
287e9b4ece7SMD Danish Anwar mac[2] << 16 | mac[3] << 24));
288e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offs[slice].mac1, (u32)(mac[4] | mac[5] << 8));
289e9b4ece7SMD Danish Anwar }
290e9b4ece7SMD Danish Anwar
291e9b4ece7SMD Danish Anwar /* disable all RX traffic */
icssg_class_disable(struct regmap * miig_rt,int slice)292e9b4ece7SMD Danish Anwar void icssg_class_disable(struct regmap *miig_rt, int slice)
293e9b4ece7SMD Danish Anwar {
294e9b4ece7SMD Danish Anwar u32 data, offset;
295e9b4ece7SMD Danish Anwar int n;
296e9b4ece7SMD Danish Anwar
297e9b4ece7SMD Danish Anwar /* Enable RX_L2_G */
298e9b4ece7SMD Danish Anwar regmap_update_bits(miig_rt, ICSSG_CFG_OFFSET, ICSSG_CFG_RX_L2_G_EN,
299e9b4ece7SMD Danish Anwar ICSSG_CFG_RX_L2_G_EN);
300e9b4ece7SMD Danish Anwar
301e9b4ece7SMD Danish Anwar for (n = 0; n < ICSSG_NUM_CLASSIFIERS; n++) {
302e9b4ece7SMD Danish Anwar /* AND_EN = 0 */
303e9b4ece7SMD Danish Anwar rx_class_set_and(miig_rt, slice, n, 0);
304e9b4ece7SMD Danish Anwar /* OR_EN = 0 */
305e9b4ece7SMD Danish Anwar rx_class_set_or(miig_rt, slice, n, 0);
306e9b4ece7SMD Danish Anwar
307e9b4ece7SMD Danish Anwar /* set CFG1 to OR */
308e9b4ece7SMD Danish Anwar rx_class_sel_set_type(miig_rt, slice, n, RX_CLASS_SEL_TYPE_OR);
309e9b4ece7SMD Danish Anwar
310e9b4ece7SMD Danish Anwar /* configure gate */
311e9b4ece7SMD Danish Anwar offset = RX_CLASS_GATES_N_REG(slice, n);
312e9b4ece7SMD Danish Anwar regmap_read(miig_rt, offset, &data);
313e9b4ece7SMD Danish Anwar /* clear class_raw so we go through filters */
314e9b4ece7SMD Danish Anwar data &= ~RX_CLASS_GATES_RAW_MASK;
315e9b4ece7SMD Danish Anwar /* set allow and phase mask */
316e9b4ece7SMD Danish Anwar data |= RX_CLASS_GATES_ALLOW_MASK | RX_CLASS_GATES_PHASE_MASK;
317e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offset, data);
318e9b4ece7SMD Danish Anwar }
319e9b4ece7SMD Danish Anwar
320e9b4ece7SMD Danish Anwar /* FT1 Disabled */
321e9b4ece7SMD Danish Anwar for (n = 0; n < ICSSG_NUM_FT1_SLOTS; n++) {
322e9b4ece7SMD Danish Anwar const u8 addr[] = { 0, 0, 0, 0, 0, 0, };
323e9b4ece7SMD Danish Anwar
324e9b4ece7SMD Danish Anwar rx_class_ft1_cfg_set_type(miig_rt, slice, n,
325e9b4ece7SMD Danish Anwar FT1_CFG_TYPE_DISABLED);
326e9b4ece7SMD Danish Anwar rx_class_ft1_set_da(miig_rt, slice, n, addr);
327e9b4ece7SMD Danish Anwar rx_class_ft1_set_da_mask(miig_rt, slice, n, addr);
328e9b4ece7SMD Danish Anwar }
329e9b4ece7SMD Danish Anwar
330e9b4ece7SMD Danish Anwar /* clear CFG2 */
331e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0);
332e9b4ece7SMD Danish Anwar }
333e9b4ece7SMD Danish Anwar
icssg_class_default(struct regmap * miig_rt,int slice,bool allmulti)334e9b4ece7SMD Danish Anwar void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti)
335e9b4ece7SMD Danish Anwar {
336e9b4ece7SMD Danish Anwar u32 data;
337e9b4ece7SMD Danish Anwar
338e9b4ece7SMD Danish Anwar /* defaults */
339e9b4ece7SMD Danish Anwar icssg_class_disable(miig_rt, slice);
340e9b4ece7SMD Danish Anwar
341e9b4ece7SMD Danish Anwar /* Setup Classifier */
342e9b4ece7SMD Danish Anwar /* match on Broadcast or MAC_PRU address */
343e9b4ece7SMD Danish Anwar data = RX_CLASS_FT_BC | RX_CLASS_FT_DA_P;
344e9b4ece7SMD Danish Anwar
345e9b4ece7SMD Danish Anwar /* multicast */
346e9b4ece7SMD Danish Anwar if (allmulti)
347e9b4ece7SMD Danish Anwar data |= RX_CLASS_FT_MC;
348e9b4ece7SMD Danish Anwar
349e9b4ece7SMD Danish Anwar rx_class_set_or(miig_rt, slice, 0, data);
350e9b4ece7SMD Danish Anwar
351e9b4ece7SMD Danish Anwar /* set CFG1 for OR_OR_AND for classifier */
352e9b4ece7SMD Danish Anwar rx_class_sel_set_type(miig_rt, slice, 0, RX_CLASS_SEL_TYPE_OR_OR_AND);
353e9b4ece7SMD Danish Anwar
354e9b4ece7SMD Danish Anwar /* clear CFG2 */
355e9b4ece7SMD Danish Anwar regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0);
356e9b4ece7SMD Danish Anwar }
357e9b4ece7SMD Danish Anwar
358e9b4ece7SMD Danish Anwar /* required for SAV check */
icssg_ft1_set_mac_addr(struct regmap * miig_rt,int slice,u8 * mac_addr)359e9b4ece7SMD Danish Anwar void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr)
360e9b4ece7SMD Danish Anwar {
361e9b4ece7SMD Danish Anwar const u8 mask_addr[] = { 0, 0, 0, 0, 0, 0, };
362e9b4ece7SMD Danish Anwar
363*75bc6bc5SMD Danish Anwar rx_class_ft1_set_start_len(miig_rt, slice, ETH_ALEN, ETH_ALEN);
364e9b4ece7SMD Danish Anwar rx_class_ft1_set_da(miig_rt, slice, 0, mac_addr);
365e9b4ece7SMD Danish Anwar rx_class_ft1_set_da_mask(miig_rt, slice, 0, mask_addr);
366e9b4ece7SMD Danish Anwar rx_class_ft1_cfg_set_type(miig_rt, slice, 0, FT1_CFG_TYPE_EQ);
367e9b4ece7SMD Danish Anwar }
368