1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
3 * Microsemi Ocelot Switch driver
5 * Copyright (c) 2017 Microsemi Corporation
9 static const u32 ocelot_ana_regmap[] = {
10 REG(ANA_ADVLEARN, 0x009000),
11 REG(ANA_VLANMASK, 0x009004),
12 REG(ANA_PORT_B_DOMAIN, 0x009008),
13 REG(ANA_ANAGEFIL, 0x00900c),
14 REG(ANA_ANEVENTS, 0x009010),
15 REG(ANA_STORMLIMIT_BURST, 0x009014),
16 REG(ANA_STORMLIMIT_CFG, 0x009018),
17 REG(ANA_ISOLATED_PORTS, 0x009028),
18 REG(ANA_COMMUNITY_PORTS, 0x00902c),
19 REG(ANA_AUTOAGE, 0x009030),
20 REG(ANA_MACTOPTIONS, 0x009034),
21 REG(ANA_LEARNDISC, 0x009038),
22 REG(ANA_AGENCTRL, 0x00903c),
23 REG(ANA_MIRRORPORTS, 0x009040),
24 REG(ANA_EMIRRORPORTS, 0x009044),
25 REG(ANA_FLOODING, 0x009048),
26 REG(ANA_FLOODING_IPMC, 0x00904c),
27 REG(ANA_SFLOW_CFG, 0x009050),
28 REG(ANA_PORT_MODE, 0x009080),
29 REG(ANA_PGID_PGID, 0x008c00),
30 REG(ANA_TABLES_ANMOVED, 0x008b30),
31 REG(ANA_TABLES_MACHDATA, 0x008b34),
32 REG(ANA_TABLES_MACLDATA, 0x008b38),
33 REG(ANA_TABLES_MACACCESS, 0x008b3c),
34 REG(ANA_TABLES_MACTINDX, 0x008b40),
35 REG(ANA_TABLES_VLANACCESS, 0x008b44),
36 REG(ANA_TABLES_VLANTIDX, 0x008b48),
37 REG(ANA_TABLES_ISDXACCESS, 0x008b4c),
38 REG(ANA_TABLES_ISDXTIDX, 0x008b50),
39 REG(ANA_TABLES_ENTRYLIM, 0x008b00),
40 REG(ANA_TABLES_PTP_ID_HIGH, 0x008b54),
41 REG(ANA_TABLES_PTP_ID_LOW, 0x008b58),
42 REG(ANA_MSTI_STATE, 0x008e00),
43 REG(ANA_PORT_VLAN_CFG, 0x007000),
44 REG(ANA_PORT_DROP_CFG, 0x007004),
45 REG(ANA_PORT_QOS_CFG, 0x007008),
46 REG(ANA_PORT_VCAP_CFG, 0x00700c),
47 REG(ANA_PORT_VCAP_S1_KEY_CFG, 0x007010),
48 REG(ANA_PORT_VCAP_S2_CFG, 0x00701c),
49 REG(ANA_PORT_PCP_DEI_MAP, 0x007020),
50 REG(ANA_PORT_CPU_FWD_CFG, 0x007060),
51 REG(ANA_PORT_CPU_FWD_BPDU_CFG, 0x007064),
52 REG(ANA_PORT_CPU_FWD_GARP_CFG, 0x007068),
53 REG(ANA_PORT_CPU_FWD_CCM_CFG, 0x00706c),
54 REG(ANA_PORT_PORT_CFG, 0x007070),
55 REG(ANA_PORT_POL_CFG, 0x007074),
56 REG(ANA_PORT_PTP_CFG, 0x007078),
57 REG(ANA_PORT_PTP_DLY1_CFG, 0x00707c),
58 REG(ANA_OAM_UPM_LM_CNT, 0x007c00),
59 REG(ANA_PORT_PTP_DLY2_CFG, 0x007080),
60 REG(ANA_PFC_PFC_CFG, 0x008800),
61 REG(ANA_PFC_PFC_TIMER, 0x008804),
62 REG(ANA_IPT_OAM_MEP_CFG, 0x008000),
63 REG(ANA_IPT_IPT, 0x008004),
64 REG(ANA_PPT_PPT, 0x008ac0),
65 REG(ANA_FID_MAP_FID_MAP, 0x000000),
66 REG(ANA_AGGR_CFG, 0x0090b4),
67 REG(ANA_CPUQ_CFG, 0x0090b8),
68 REG(ANA_CPUQ_CFG2, 0x0090bc),
69 REG(ANA_CPUQ_8021_CFG, 0x0090c0),
70 REG(ANA_DSCP_CFG, 0x009100),
71 REG(ANA_DSCP_REWR_CFG, 0x009200),
72 REG(ANA_VCAP_RNG_TYPE_CFG, 0x009240),
73 REG(ANA_VCAP_RNG_VAL_CFG, 0x009260),
74 REG(ANA_VRAP_CFG, 0x009280),
75 REG(ANA_VRAP_HDR_DATA, 0x009284),
76 REG(ANA_VRAP_HDR_MASK, 0x009288),
77 REG(ANA_DISCARD_CFG, 0x00928c),
78 REG(ANA_FID_CFG, 0x009290),
79 REG(ANA_POL_PIR_CFG, 0x004000),
80 REG(ANA_POL_CIR_CFG, 0x004004),
81 REG(ANA_POL_MODE_CFG, 0x004008),
82 REG(ANA_POL_PIR_STATE, 0x00400c),
83 REG(ANA_POL_CIR_STATE, 0x004010),
84 REG(ANA_POL_STATE, 0x004014),
85 REG(ANA_POL_FLOWC, 0x008b80),
86 REG(ANA_POL_HYST, 0x008bec),
87 REG(ANA_POL_MISC_CFG, 0x008bf0),
90 static const u32 ocelot_qs_regmap[] = {
91 REG(QS_XTR_GRP_CFG, 0x000000),
92 REG(QS_XTR_RD, 0x000008),
93 REG(QS_XTR_FRM_PRUNING, 0x000010),
94 REG(QS_XTR_FLUSH, 0x000018),
95 REG(QS_XTR_DATA_PRESENT, 0x00001c),
96 REG(QS_XTR_CFG, 0x000020),
97 REG(QS_INJ_GRP_CFG, 0x000024),
98 REG(QS_INJ_WR, 0x00002c),
99 REG(QS_INJ_CTRL, 0x000034),
100 REG(QS_INJ_STATUS, 0x00003c),
101 REG(QS_INJ_ERR, 0x000040),
102 REG(QS_INH_DBG, 0x000048),
105 static const u32 ocelot_qsys_regmap[] = {
106 REG(QSYS_PORT_MODE, 0x011200),
107 REG(QSYS_SWITCH_PORT_MODE, 0x011234),
108 REG(QSYS_STAT_CNT_CFG, 0x011264),
109 REG(QSYS_EEE_CFG, 0x011268),
110 REG(QSYS_EEE_THRES, 0x011294),
111 REG(QSYS_IGR_NO_SHARING, 0x011298),
112 REG(QSYS_EGR_NO_SHARING, 0x01129c),
113 REG(QSYS_SW_STATUS, 0x0112a0),
114 REG(QSYS_EXT_CPU_CFG, 0x0112d0),
115 REG(QSYS_PAD_CFG, 0x0112d4),
116 REG(QSYS_CPU_GROUP_MAP, 0x0112d8),
117 REG(QSYS_QMAP, 0x0112dc),
118 REG(QSYS_ISDX_SGRP, 0x011400),
119 REG(QSYS_TIMED_FRAME_ENTRY, 0x014000),
120 REG(QSYS_TFRM_MISC, 0x011310),
121 REG(QSYS_TFRM_PORT_DLY, 0x011314),
122 REG(QSYS_TFRM_TIMER_CFG_1, 0x011318),
123 REG(QSYS_TFRM_TIMER_CFG_2, 0x01131c),
124 REG(QSYS_TFRM_TIMER_CFG_3, 0x011320),
125 REG(QSYS_TFRM_TIMER_CFG_4, 0x011324),
126 REG(QSYS_TFRM_TIMER_CFG_5, 0x011328),
127 REG(QSYS_TFRM_TIMER_CFG_6, 0x01132c),
128 REG(QSYS_TFRM_TIMER_CFG_7, 0x011330),
129 REG(QSYS_TFRM_TIMER_CFG_8, 0x011334),
130 REG(QSYS_RED_PROFILE, 0x011338),
131 REG(QSYS_RES_QOS_MODE, 0x011378),
132 REG(QSYS_RES_CFG, 0x012000),
133 REG(QSYS_RES_STAT, 0x012004),
134 REG(QSYS_EGR_DROP_MODE, 0x01137c),
135 REG(QSYS_EQ_CTRL, 0x011380),
136 REG(QSYS_EVENTS_CORE, 0x011384),
137 REG(QSYS_CIR_CFG, 0x000000),
138 REG(QSYS_EIR_CFG, 0x000004),
139 REG(QSYS_SE_CFG, 0x000008),
140 REG(QSYS_SE_DWRR_CFG, 0x00000c),
141 REG(QSYS_SE_CONNECT, 0x00003c),
142 REG(QSYS_SE_DLB_SENSE, 0x000040),
143 REG(QSYS_CIR_STATE, 0x000044),
144 REG(QSYS_EIR_STATE, 0x000048),
145 REG(QSYS_SE_STATE, 0x00004c),
146 REG(QSYS_HSCH_MISC_CFG, 0x011388),
149 static const u32 ocelot_rew_regmap[] = {
150 REG(REW_PORT_VLAN_CFG, 0x000000),
151 REG(REW_TAG_CFG, 0x000004),
152 REG(REW_PORT_CFG, 0x000008),
153 REG(REW_DSCP_CFG, 0x00000c),
154 REG(REW_PCP_DEI_QOS_MAP_CFG, 0x000010),
155 REG(REW_PTP_CFG, 0x000050),
156 REG(REW_PTP_DLY1_CFG, 0x000054),
157 REG(REW_DSCP_REMAP_DP1_CFG, 0x000690),
158 REG(REW_DSCP_REMAP_CFG, 0x000790),
159 REG(REW_STAT_CFG, 0x000890),
160 REG(REW_PPT, 0x000680),
163 static const u32 ocelot_sys_regmap[] = {
164 REG(SYS_COUNT_RX_OCTETS, 0x000000),
165 REG(SYS_COUNT_RX_UNICAST, 0x000004),
166 REG(SYS_COUNT_RX_MULTICAST, 0x000008),
167 REG(SYS_COUNT_RX_BROADCAST, 0x00000c),
168 REG(SYS_COUNT_RX_SHORTS, 0x000010),
169 REG(SYS_COUNT_RX_FRAGMENTS, 0x000014),
170 REG(SYS_COUNT_RX_JABBERS, 0x000018),
171 REG(SYS_COUNT_RX_CRC_ALIGN_ERRS, 0x00001c),
172 REG(SYS_COUNT_RX_SYM_ERRS, 0x000020),
173 REG(SYS_COUNT_RX_64, 0x000024),
174 REG(SYS_COUNT_RX_65_127, 0x000028),
175 REG(SYS_COUNT_RX_128_255, 0x00002c),
176 REG(SYS_COUNT_RX_256_1023, 0x000030),
177 REG(SYS_COUNT_RX_1024_1526, 0x000034),
178 REG(SYS_COUNT_RX_1527_MAX, 0x000038),
179 REG(SYS_COUNT_RX_PAUSE, 0x00003c),
180 REG(SYS_COUNT_RX_CONTROL, 0x000040),
181 REG(SYS_COUNT_RX_LONGS, 0x000044),
182 REG(SYS_COUNT_RX_CLASSIFIED_DROPS, 0x000048),
183 REG(SYS_COUNT_TX_OCTETS, 0x000100),
184 REG(SYS_COUNT_TX_UNICAST, 0x000104),
185 REG(SYS_COUNT_TX_MULTICAST, 0x000108),
186 REG(SYS_COUNT_TX_BROADCAST, 0x00010c),
187 REG(SYS_COUNT_TX_COLLISION, 0x000110),
188 REG(SYS_COUNT_TX_DROPS, 0x000114),
189 REG(SYS_COUNT_TX_PAUSE, 0x000118),
190 REG(SYS_COUNT_TX_64, 0x00011c),
191 REG(SYS_COUNT_TX_65_127, 0x000120),
192 REG(SYS_COUNT_TX_128_511, 0x000124),
193 REG(SYS_COUNT_TX_512_1023, 0x000128),
194 REG(SYS_COUNT_TX_1024_1526, 0x00012c),
195 REG(SYS_COUNT_TX_1527_MAX, 0x000130),
196 REG(SYS_COUNT_TX_AGING, 0x000170),
197 REG(SYS_RESET_CFG, 0x000508),
198 REG(SYS_CMID, 0x00050c),
199 REG(SYS_VLAN_ETYPE_CFG, 0x000510),
200 REG(SYS_PORT_MODE, 0x000514),
201 REG(SYS_FRONT_PORT_MODE, 0x000548),
202 REG(SYS_FRM_AGING, 0x000574),
203 REG(SYS_STAT_CFG, 0x000578),
204 REG(SYS_SW_STATUS, 0x00057c),
205 REG(SYS_MISC_CFG, 0x0005ac),
206 REG(SYS_REW_MAC_HIGH_CFG, 0x0005b0),
207 REG(SYS_REW_MAC_LOW_CFG, 0x0005dc),
208 REG(SYS_CM_ADDR, 0x000500),
209 REG(SYS_CM_DATA, 0x000504),
210 REG(SYS_PAUSE_CFG, 0x000608),
211 REG(SYS_PAUSE_TOT_CFG, 0x000638),
212 REG(SYS_ATOP, 0x00063c),
213 REG(SYS_ATOP_TOT_CFG, 0x00066c),
214 REG(SYS_MAC_FC_CFG, 0x000670),
215 REG(SYS_MMGT, 0x00069c),
216 REG(SYS_MMGT_FAST, 0x0006a0),
217 REG(SYS_EVENTS_DIF, 0x0006a4),
218 REG(SYS_EVENTS_CORE, 0x0006b4),
219 REG(SYS_CNT, 0x000000),
220 REG(SYS_PTP_STATUS, 0x0006b8),
221 REG(SYS_PTP_TXSTAMP, 0x0006bc),
222 REG(SYS_PTP_NXT, 0x0006c0),
223 REG(SYS_PTP_CFG, 0x0006c4),
226 static const u32 *ocelot_regmap[] = {
227 [ANA] = ocelot_ana_regmap,
228 [QS] = ocelot_qs_regmap,
229 [QSYS] = ocelot_qsys_regmap,
230 [REW] = ocelot_rew_regmap,
231 [SYS] = ocelot_sys_regmap,
234 static const struct reg_field ocelot_regfields[] = {
235 [ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 11, 11),
236 [ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 10),
237 [ANA_ANEVENTS_MSTI_DROP] = REG_FIELD(ANA_ANEVENTS, 27, 27),
238 [ANA_ANEVENTS_ACLKILL] = REG_FIELD(ANA_ANEVENTS, 26, 26),
239 [ANA_ANEVENTS_ACLUSED] = REG_FIELD(ANA_ANEVENTS, 25, 25),
240 [ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24),
241 [ANA_ANEVENTS_VS2TTL1] = REG_FIELD(ANA_ANEVENTS, 23, 23),
242 [ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22),
243 [ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21),
244 [ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20),
245 [ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19),
246 [ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18),
247 [ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17),
248 [ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16),
249 [ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15),
250 [ANA_ANEVENTS_DROPPED] = REG_FIELD(ANA_ANEVENTS, 14, 14),
251 [ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13),
252 [ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12),
253 [ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11),
254 [ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10),
255 [ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9),
256 [ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8),
257 [ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7),
258 [ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6),
259 [ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5),
260 [ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4),
261 [ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3),
262 [ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2),
263 [ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1),
264 [ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0),
265 [ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 18, 18),
266 [ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 10, 11),
267 [ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 9),
268 [QSYS_TIMED_FRAME_ENTRY_TFRM_VLD] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 20, 20),
269 [QSYS_TIMED_FRAME_ENTRY_TFRM_FP] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 8, 19),
270 [QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 4, 7),
271 [QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 1, 3),
272 [QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 0, 0),
273 [SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 2, 2),
274 [SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 1, 1),
275 [SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 0, 0),
278 static const struct ocelot_stat_layout ocelot_stats_layout[] = {
279 { .name = "rx_octets", .offset = 0x00, },
280 { .name = "rx_unicast", .offset = 0x01, },
281 { .name = "rx_multicast", .offset = 0x02, },
282 { .name = "rx_broadcast", .offset = 0x03, },
283 { .name = "rx_shorts", .offset = 0x04, },
284 { .name = "rx_fragments", .offset = 0x05, },
285 { .name = "rx_jabbers", .offset = 0x06, },
286 { .name = "rx_crc_align_errs", .offset = 0x07, },
287 { .name = "rx_sym_errs", .offset = 0x08, },
288 { .name = "rx_frames_below_65_octets", .offset = 0x09, },
289 { .name = "rx_frames_65_to_127_octets", .offset = 0x0A, },
290 { .name = "rx_frames_128_to_255_octets", .offset = 0x0B, },
291 { .name = "rx_frames_256_to_511_octets", .offset = 0x0C, },
292 { .name = "rx_frames_512_to_1023_octets", .offset = 0x0D, },
293 { .name = "rx_frames_1024_to_1526_octets", .offset = 0x0E, },
294 { .name = "rx_frames_over_1526_octets", .offset = 0x0F, },
295 { .name = "rx_pause", .offset = 0x10, },
296 { .name = "rx_control", .offset = 0x11, },
297 { .name = "rx_longs", .offset = 0x12, },
298 { .name = "rx_classified_drops", .offset = 0x13, },
299 { .name = "rx_red_prio_0", .offset = 0x14, },
300 { .name = "rx_red_prio_1", .offset = 0x15, },
301 { .name = "rx_red_prio_2", .offset = 0x16, },
302 { .name = "rx_red_prio_3", .offset = 0x17, },
303 { .name = "rx_red_prio_4", .offset = 0x18, },
304 { .name = "rx_red_prio_5", .offset = 0x19, },
305 { .name = "rx_red_prio_6", .offset = 0x1A, },
306 { .name = "rx_red_prio_7", .offset = 0x1B, },
307 { .name = "rx_yellow_prio_0", .offset = 0x1C, },
308 { .name = "rx_yellow_prio_1", .offset = 0x1D, },
309 { .name = "rx_yellow_prio_2", .offset = 0x1E, },
310 { .name = "rx_yellow_prio_3", .offset = 0x1F, },
311 { .name = "rx_yellow_prio_4", .offset = 0x20, },
312 { .name = "rx_yellow_prio_5", .offset = 0x21, },
313 { .name = "rx_yellow_prio_6", .offset = 0x22, },
314 { .name = "rx_yellow_prio_7", .offset = 0x23, },
315 { .name = "rx_green_prio_0", .offset = 0x24, },
316 { .name = "rx_green_prio_1", .offset = 0x25, },
317 { .name = "rx_green_prio_2", .offset = 0x26, },
318 { .name = "rx_green_prio_3", .offset = 0x27, },
319 { .name = "rx_green_prio_4", .offset = 0x28, },
320 { .name = "rx_green_prio_5", .offset = 0x29, },
321 { .name = "rx_green_prio_6", .offset = 0x2A, },
322 { .name = "rx_green_prio_7", .offset = 0x2B, },
323 { .name = "tx_octets", .offset = 0x40, },
324 { .name = "tx_unicast", .offset = 0x41, },
325 { .name = "tx_multicast", .offset = 0x42, },
326 { .name = "tx_broadcast", .offset = 0x43, },
327 { .name = "tx_collision", .offset = 0x44, },
328 { .name = "tx_drops", .offset = 0x45, },
329 { .name = "tx_pause", .offset = 0x46, },
330 { .name = "tx_frames_below_65_octets", .offset = 0x47, },
331 { .name = "tx_frames_65_to_127_octets", .offset = 0x48, },
332 { .name = "tx_frames_128_255_octets", .offset = 0x49, },
333 { .name = "tx_frames_256_511_octets", .offset = 0x4A, },
334 { .name = "tx_frames_512_1023_octets", .offset = 0x4B, },
335 { .name = "tx_frames_1024_1526_octets", .offset = 0x4C, },
336 { .name = "tx_frames_over_1526_octets", .offset = 0x4D, },
337 { .name = "tx_yellow_prio_0", .offset = 0x4E, },
338 { .name = "tx_yellow_prio_1", .offset = 0x4F, },
339 { .name = "tx_yellow_prio_2", .offset = 0x50, },
340 { .name = "tx_yellow_prio_3", .offset = 0x51, },
341 { .name = "tx_yellow_prio_4", .offset = 0x52, },
342 { .name = "tx_yellow_prio_5", .offset = 0x53, },
343 { .name = "tx_yellow_prio_6", .offset = 0x54, },
344 { .name = "tx_yellow_prio_7", .offset = 0x55, },
345 { .name = "tx_green_prio_0", .offset = 0x56, },
346 { .name = "tx_green_prio_1", .offset = 0x57, },
347 { .name = "tx_green_prio_2", .offset = 0x58, },
348 { .name = "tx_green_prio_3", .offset = 0x59, },
349 { .name = "tx_green_prio_4", .offset = 0x5A, },
350 { .name = "tx_green_prio_5", .offset = 0x5B, },
351 { .name = "tx_green_prio_6", .offset = 0x5C, },
352 { .name = "tx_green_prio_7", .offset = 0x5D, },
353 { .name = "tx_aged", .offset = 0x5E, },
354 { .name = "drop_local", .offset = 0x80, },
355 { .name = "drop_tail", .offset = 0x81, },
356 { .name = "drop_yellow_prio_0", .offset = 0x82, },
357 { .name = "drop_yellow_prio_1", .offset = 0x83, },
358 { .name = "drop_yellow_prio_2", .offset = 0x84, },
359 { .name = "drop_yellow_prio_3", .offset = 0x85, },
360 { .name = "drop_yellow_prio_4", .offset = 0x86, },
361 { .name = "drop_yellow_prio_5", .offset = 0x87, },
362 { .name = "drop_yellow_prio_6", .offset = 0x88, },
363 { .name = "drop_yellow_prio_7", .offset = 0x89, },
364 { .name = "drop_green_prio_0", .offset = 0x8A, },
365 { .name = "drop_green_prio_1", .offset = 0x8B, },
366 { .name = "drop_green_prio_2", .offset = 0x8C, },
367 { .name = "drop_green_prio_3", .offset = 0x8D, },
368 { .name = "drop_green_prio_4", .offset = 0x8E, },
369 { .name = "drop_green_prio_5", .offset = 0x8F, },
370 { .name = "drop_green_prio_6", .offset = 0x90, },
371 { .name = "drop_green_prio_7", .offset = 0x91, },
374 static void ocelot_pll5_init(struct ocelot *ocelot)
376 /* Configure PLL5. This will need a proper CCF driver
377 * The values are coming from the VTSS API for Ocelot
379 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG4,
380 HSIO_PLL5G_CFG4_IB_CTRL(0x7600) |
381 HSIO_PLL5G_CFG4_IB_BIAS_CTRL(0x8));
382 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG0,
383 HSIO_PLL5G_CFG0_CORE_CLK_DIV(0x11) |
384 HSIO_PLL5G_CFG0_CPU_CLK_DIV(2) |
385 HSIO_PLL5G_CFG0_ENA_BIAS |
386 HSIO_PLL5G_CFG0_ENA_VCO_BUF |
387 HSIO_PLL5G_CFG0_ENA_CP1 |
388 HSIO_PLL5G_CFG0_SELCPI(2) |
389 HSIO_PLL5G_CFG0_LOOP_BW_RES(0xe) |
390 HSIO_PLL5G_CFG0_SELBGV820(4) |
391 HSIO_PLL5G_CFG0_DIV4 |
392 HSIO_PLL5G_CFG0_ENA_CLKTREE |
393 HSIO_PLL5G_CFG0_ENA_LANE);
394 regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG2,
395 HSIO_PLL5G_CFG2_EN_RESET_FRQ_DET |
396 HSIO_PLL5G_CFG2_EN_RESET_OVERRUN |
397 HSIO_PLL5G_CFG2_GAIN_TEST(0x8) |
398 HSIO_PLL5G_CFG2_ENA_AMPCTRL |
399 HSIO_PLL5G_CFG2_PWD_AMPCTRL_N |
400 HSIO_PLL5G_CFG2_AMPC_SEL(0x10));
403 int ocelot_chip_init(struct ocelot *ocelot)
407 ocelot->map = ocelot_regmap;
408 ocelot->stats_layout = ocelot_stats_layout;
409 ocelot->num_stats = ARRAY_SIZE(ocelot_stats_layout);
410 ocelot->shared_queue_sz = 224 * 1024;
412 ret = ocelot_regfields_init(ocelot, ocelot_regfields);
416 ocelot_pll5_init(ocelot);
418 eth_random_addr(ocelot->base_mac);
419 ocelot->base_mac[5] &= 0xf0;
423 EXPORT_SYMBOL(ocelot_chip_init);