forked from MarvellEmbeddedProcessors/mvpp2x-marvell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmv_gop110_hw.h
executable file
·475 lines (411 loc) · 15.9 KB
/
mv_gop110_hw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/*
* ***************************************************************************
* Copyright (C) 2016 Marvell International Ltd.
* ***************************************************************************
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 2 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ***************************************************************************
*/
#ifndef _MV_GOP_HW_H_
#define _MV_GOP_HW_H_
/* Sets the field located at the specified in data. */
#define U32_SET_FIELD(data, mask, val) ((data) = (((data) & ~(mask)) | (val)))
/* port related */
enum mv_reset {RESET, UNRESET};
enum mv_port_speed {
MV_PORT_SPEED_AN,
MV_PORT_SPEED_10,
MV_PORT_SPEED_100,
MV_PORT_SPEED_1000,
MV_PORT_SPEED_2500,
MV_PORT_SPEED_10000
};
enum mv_port_duplex {
MV_PORT_DUPLEX_AN,
MV_PORT_DUPLEX_HALF,
MV_PORT_DUPLEX_FULL
};
enum mv_port_fc {
MV_PORT_FC_AN_NO,
MV_PORT_FC_AN_SYM,
MV_PORT_FC_AN_ASYM,
MV_PORT_FC_DISABLE,
MV_PORT_FC_TX_DISABLE,
MV_PORT_FC_RX_DISABLE,
MV_PORT_FC_ENABLE,
MV_PORT_FC_TX_ENABLE,
MV_PORT_FC_RX_ENABLE,
MV_PORT_FC_ACTIVE
};
struct mv_port_link_status {
int linkup; /*flag*/
enum mv_port_speed speed;
enum mv_port_duplex duplex;
enum mv_port_fc rx_fc;
enum mv_port_fc tx_fc;
enum mv_port_fc autoneg_fc;
};
/* different loopback types can be configure on different levels:
* MAC, PCS, SERDES
*/
enum mv_lb_type {
MV_DISABLE_LB,
MV_RX_2_TX_LB,
MV_TX_2_RX_LB, /* on SERDES level - analog loopback */
MV_TX_2_RX_DIGITAL_LB /* on SERDES level - digital loopback */
};
enum sd_media_mode {MV_RXAUI, MV_XAUI};
/* Net Complex */
enum mv_netc_topology {
MV_NETC_GE_MAC0_RXAUI_L23 = BIT(0),
MV_NETC_GE_MAC0_RXAUI_L45 = BIT(1),
MV_NETC_GE_MAC0_XAUI = BIT(2),
MV_NETC_GE_MAC2_SGMII = BIT(3),
MV_NETC_GE_MAC3_SGMII = BIT(4),
MV_NETC_GE_MAC3_RGMII = BIT(5),
};
enum mv_netc_phase {
MV_NETC_FIRST_PHASE,
MV_NETC_SECOND_PHASE,
};
enum mv_netc_sgmii_xmi_mode {
MV_NETC_GBE_SGMII,
MV_NETC_GBE_XMII,
};
enum mv_netc_mii_mode {
MV_NETC_GBE_RGMII,
MV_NETC_GBE_MII,
};
enum mv_netc_lanes {
MV_NETC_LANE_23,
MV_NETC_LANE_45,
};
enum mv_gop_port {
MV_GOP_PORT0 = 0,
MV_GOP_PORT1 = 1,
MV_GOP_PORT2 = 2,
MV_GOP_PORT3 = 3,
};
#define MV_RGMII_TX_FIFO_MIN_TH (0x41)
#define MV_SGMII_TX_FIFO_MIN_TH (0x5)
#define MV_SGMII2_5_TX_FIFO_MIN_TH (0xB)
static inline u32 mv_gop_gen_read(void __iomem *base, u32 offset)
{
void *reg_ptr = base + offset;
u32 val;
val = readl(reg_ptr);
return val;
}
static inline void mv_gop_gen_write(void __iomem *base, u32 offset, u32 data)
{
void *reg_ptr = base + offset;
writel(data, reg_ptr);
}
/* GOP port configuration functions */
int mv_gop110_port_init(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_port_reset(struct gop_hw *gop, struct mv_mac_data *mac);
void mv_gop110_port_enable(struct gop_hw *gop, struct mv_mac_data *mac, struct phy *comphy);
void mv_gop110_port_disable(struct gop_hw *gop, struct mv_mac_data *mac, struct phy *comphy);
void mv_gop110_port_periodic_xon_set(struct gop_hw *gop,
struct mv_mac_data *mac,
int enable);
bool mv_gop110_port_is_link_up(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_port_link_status(struct gop_hw *gop, struct mv_mac_data *mac,
struct mv_port_link_status *pstatus);
bool mv_gop110_port_autoneg_status(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_check_port_type(struct gop_hw *gop, int port_num);
void mv_gop110_gmac_set_autoneg(struct gop_hw *gop, struct mv_mac_data *mac,
bool auto_neg);
int mv_gop110_port_regs(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_port_events_mask(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_port_events_unmask(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_port_events_clear(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_status_show(struct gop_hw *gop, struct mv_pp2x *pp2, int port_num);
int mv_gop110_speed_duplex_get(struct gop_hw *gop, struct mv_mac_data *mac,
enum mv_port_speed *speed,
enum mv_port_duplex *duplex);
int mv_gop110_speed_duplex_set(struct gop_hw *gop, struct mv_mac_data *mac,
enum mv_port_speed speed,
enum mv_port_duplex duplex);
int mv_gop110_autoneg_restart(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_fl_cfg(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_force_link_mode_set(struct gop_hw *gop, struct mv_mac_data *mac,
bool force_link_up,
bool force_link_down);
int mv_gop110_force_link_mode_get(struct gop_hw *gop, struct mv_mac_data *mac,
bool *force_link_up,
bool *force_link_down);
int mv_gop110_loopback_set(struct gop_hw *gop, struct mv_mac_data *mac,
bool lb);
void mv_gop_reg_print(char *reg_name, u32 reg);
/* Gig PCS Functions */
int mv_gop110_gpcs_mode_cfg(struct gop_hw *gop, int pcs_num, bool en);
int mv_gop110_gpcs_reset(struct gop_hw *gop, int pcs_num, enum mv_reset act);
/* MPCS Functions */
static inline u32 mv_gop110_mpcs_global_read(struct gop_hw *gop, u32 offset)
{
return mv_gop_gen_read(gop->gop_110.mspg_base, offset);
}
static inline void mv_gop110_mpcs_global_write(struct gop_hw *gop, u32 offset,
u32 data)
{
mv_gop_gen_write(gop->gop_110.mspg_base, offset, data);
}
static inline void mv_gop110_mpcs_global_print(struct gop_hw *gop,
char *reg_name, u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_mpcs_global_read(gop, reg));
}
/* XPCS Functions */
static inline u32 mv_gop110_xpcs_global_read(struct gop_hw *gop, u32 offset)
{
return mv_gop_gen_read(gop->gop_110.xpcs_base, offset);
}
static inline void mv_gop110_xpcs_global_write(struct gop_hw *gop, u32 offset,
u32 data)
{
mv_gop_gen_write(gop->gop_110.xpcs_base, offset, data);
}
static inline void mv_gop110_xpcs_global_print(struct gop_hw *gop,
char *reg_name, u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_xpcs_global_read(gop, reg));
}
static inline u32 mv_gop110_xpcs_lane_read(struct gop_hw *gop, int lane_num,
u32 offset)
{
return mv_gop_gen_read(gop->gop_110.xpcs_base, offset);
}
static inline void mv_gop110_xpcs_lane_write(struct gop_hw *gop, int lane_num,
u32 offset, u32 data)
{
mv_gop_gen_write(gop->gop_110.xpcs_base, offset, data);
}
static inline void mv_gop110_xpcs_lane_print(struct gop_hw *gop,
char *reg_name,
int lane_num, u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_xpcs_lane_read(gop, lane_num, reg));
}
void mv_gop110_xpcs_gl_regs_dump(struct gop_hw *gop);
void mv_gop110_xpcs_lane_regs_dump(struct gop_hw *gop, int lane);
int mv_gop110_xpcs_reset(struct gop_hw *gop, enum mv_reset reset);
int mv_gop110_xpcs_mode(struct gop_hw *gop, int num_of_lanes);
int mv_gop110_mpcs_mode(struct gop_hw *gop);
void mv_gop110_mpcs_clock_reset(struct gop_hw *gop, enum mv_reset reset);
/* XLG MAC Functions */
static inline u32 mv_gop110_xlg_mac_read(struct gop_hw *gop, int mac_num,
u32 offset)
{
return(mv_gop_gen_read(gop->gop_110.xlg_mac.base,
mac_num * gop->gop_110.xlg_mac.obj_size + offset));
}
static inline void mv_gop110_xlg_mac_write(struct gop_hw *gop, int mac_num,
u32 offset, u32 data)
{
mv_gop_gen_write(gop->gop_110.xlg_mac.base,
mac_num * gop->gop_110.xlg_mac.obj_size + offset, data);
}
static inline void mv_gop110_xlg_mac_print(struct gop_hw *gop, char *reg_name,
int mac_num, u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_xlg_mac_read(gop, mac_num, reg));
}
/* MIB MAC Functions */
static inline u32 mv_gop110_xmib_mac_read(struct gop_hw *gop, int mac_num,
u32 offset)
{
return(mv_gop_gen_read(gop->gop_110.xmib.base,
mac_num * gop->gop_110.xmib.obj_size + offset));
}
static inline void mv_gop110_xmib_mac_write(struct gop_hw *gop, int mac_num,
u32 offset, u32 data)
{
mv_gop_gen_write(gop->gop_110.xmib.base,
mac_num * gop->gop_110.xmib.obj_size + offset, data);
}
static inline void mv_gop110_xmib_mac_print(struct gop_hw *gop, char *reg_name,
int mac_num, u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_xmib_mac_read(gop, mac_num, reg));
}
void mv_gop110_xlg_mac_regs_dump(struct gop_hw *gop, int port);
int mv_gop110_xlg_mac_reset(struct gop_hw *gop, int mac_num,
enum mv_reset reset);
int mv_gop110_xlg_mac_mode_cfg(struct gop_hw *gop, int mac_num,
int num_of_act_lanes);
int mv_gop110_xlg_mac_loopback_cfg(struct gop_hw *gop, int mac_num,
enum mv_lb_type type);
bool mv_gop110_xlg_mac_link_status_get(struct gop_hw *gop, int mac_num);
void mv_gop110_xlg_mac_port_enable(struct gop_hw *gop, int mac_num);
void mv_gop110_xlg_mac_port_disable(struct gop_hw *gop, int mac_num);
void mv_gop110_xlg_mac_port_periodic_xon_set(struct gop_hw *gop,
int mac_num,
int enable);
int mv_gop110_xlg_mac_link_status(struct gop_hw *gop, int mac_num,
struct mv_port_link_status *pstatus);
int mv_gop110_xlg_mac_max_rx_size_set(struct gop_hw *gop, int mac_num,
int max_rx_size);
int mv_gop110_xlg_mac_force_link_mode_set(struct gop_hw *gop, int mac_num,
bool force_link_up,
bool force_link_down);
int mv_gop110_xlg_mac_speed_duplex_set(struct gop_hw *gop, int mac_num,
enum mv_port_speed speed,
enum mv_port_duplex duplex);
int mv_gop110_xlg_mac_speed_duplex_get(struct gop_hw *gop, int mac_num,
enum mv_port_speed *speed,
enum mv_port_duplex *duplex);
int mv_gop110_xlg_mac_fc_set(struct gop_hw *gop, int mac_num,
enum mv_port_fc fc);
void mv_gop110_xlg_mac_fc_get(struct gop_hw *gop, int mac_num,
enum mv_port_fc *fc);
int mv_gop110_xlg_mac_port_link_speed_fc(struct gop_hw *gop, int mac_num,
enum mv_port_speed speed,
int force_link_up);
void mv_gop110_xlg_port_link_event_mask(struct gop_hw *gop, int mac_num);
void mv_gop110_xlg_port_external_event_unmask(struct gop_hw *gop,
int mac_num,
int bit_2_open);
void mv_gop110_xlg_port_link_event_clear(struct gop_hw *gop, int mac_num);
void mv_gop110_xlg_2_gig_mac_cfg(struct gop_hw *gop, int mac_num);
/* GMAC Functions */
static inline u32 mv_gop110_gmac_read(struct gop_hw *gop, int mac_num,
u32 offset)
{
return(mv_gop_gen_read(gop->gop_110.gmac.base,
mac_num * gop->gop_110.gmac.obj_size + offset));
}
static inline void mv_gop110_gmac_write(struct gop_hw *gop, int mac_num,
u32 offset, u32 data)
{
mv_gop_gen_write(gop->gop_110.gmac.base,
mac_num * gop->gop_110.gmac.obj_size + offset, data);
}
static inline void mv_gop110_gmac_print(struct gop_hw *gop, char *reg_name,
int mac_num, u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_gmac_read(gop, mac_num, reg));
}
void mv_gop110_register_bases_dump(struct gop_hw *gop);
void mv_gop110_gmac_regs_dump(struct gop_hw *gop, int port);
int mv_gop110_gmac_reset(struct gop_hw *gop, int mac_num,
enum mv_reset reset);
int mv_gop110_gmac_mode_cfg(struct gop_hw *gop, struct mv_mac_data *mac);
int mv_gop110_gmac_loopback_cfg(struct gop_hw *gop, int mac_num,
enum mv_lb_type type);
bool mv_gop110_gmac_link_status_get(struct gop_hw *gop, int mac_num);
void mv_gop110_gmac_port_enable(struct gop_hw *gop, int mac_num);
void mv_gop110_gmac_port_disable(struct gop_hw *gop, int mac_num);
void mv_gop110_gmac_port_periodic_xon_set(struct gop_hw *gop, int mac_num,
int enable);
int mv_gop110_gmac_link_status(struct gop_hw *gop, int mac_num,
struct mv_port_link_status *pstatus);
int mv_gop110_gmac_max_rx_size_set(struct gop_hw *gop, int mac_num,
int max_rx_size);
int mv_gop110_gmac_force_link_mode_set(struct gop_hw *gop, int mac_num,
bool force_link_up,
bool force_link_down);
int mv_gop110_gmac_force_link_mode_get(struct gop_hw *gop, int mac_num,
bool *force_link_up,
bool *force_link_down);
int mv_gop110_gmac_speed_duplex_set(struct gop_hw *gop, int mac_num,
enum mv_port_speed speed,
enum mv_port_duplex duplex);
int mv_gop110_gmac_speed_duplex_get(struct gop_hw *gop, int mac_num,
enum mv_port_speed *speed,
enum mv_port_duplex *duplex);
int mv_gop110_gmac_fc_set(struct gop_hw *gop, int mac_num,
enum mv_port_fc fc);
void mv_gop110_gmac_fc_get(struct gop_hw *gop, int mac_num,
enum mv_port_fc *fc);
int mv_gop110_gmac_port_link_speed_fc(struct gop_hw *gop, int mac_num,
enum mv_port_speed speed,
int force_link_up);
void mv_gop110_gmac_port_link_event_mask(struct gop_hw *gop, int mac_num);
void mv_gop110_gmac_port_link_event_unmask(struct gop_hw *gop, int mac_num);
void mv_gop110_gmac_port_link_event_clear(struct gop_hw *gop, int mac_num);
int mv_gop110_gmac_port_autoneg_restart(struct gop_hw *gop, int mac_num);
/* SMI Functions */
static inline u32 mv_gop110_smi_read(struct gop_hw *gop, u32 offset)
{
return mv_gop_gen_read(gop->gop_110.smi_base, offset);
}
static inline void mv_gop110_smi_write(struct gop_hw *gop, u32 offset,
u32 data)
{
mv_gop_gen_write(gop->gop_110.smi_base, offset, data);
}
static inline void mv_gop110_smi_print(struct gop_hw *gop, char *reg_name,
u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_smi_read(gop, reg));
}
/* RFU1 Functions */
static inline u32 mv_gop110_rfu1_read(struct gop_hw *gop, u32 offset)
{
return mv_gop_gen_read(gop->gop_110.rfu1_base, offset);
}
static inline void mv_gop110_rfu1_write(struct gop_hw *gop, u32 offset,
u32 data)
{
mv_gop_gen_write(gop->gop_110.rfu1_base, offset, data);
}
static inline void mv_gop110_rfu1_print(struct gop_hw *gop, char *reg_name,
u32 reg)
{
pr_info(" %-32s: 0x%x = 0x%08x\n", reg_name, reg,
mv_gop110_rfu1_read(gop, reg));
}
int mv_gop110_smi_init(struct gop_hw *gop);
int mv_gop110_smi_phy_addr_cfg(struct gop_hw *gop, int port, int addr);
/* MIB Functions */
u64 mv_gop110_mib_read64(struct gop_hw *gop, int port, unsigned int offset);
void mv_gop110_mib_counters_show(struct gop_hw *gop, int port);
void mv_gop110_mib_counters_stat_update(struct gop_hw *gop, int port,
struct gop_stat *gop_statistics);
void mv_gop110_mib_counters_clear(struct gop_hw *gop, int port);
/* PTP Functions */
void mv_gop110_ptp_enable(struct gop_hw *gop, int port, bool state);
/*RFU Functions */
int mv_gop110_netc_init(struct gop_hw *gop,
u32 net_comp_config, enum mv_netc_phase phase);
void mv_gop110_netc_active_port(struct gop_hw *gop, u32 port, u32 val);
void mv_gop110_netc_xon_set(struct gop_hw *gop, enum mv_gop_port port, bool en);
/* FCA Functions */
void mv_gop110_fca_send_periodic(struct gop_hw *gop, int mac_num, bool en);
void mv_gop110_fca_set_periodic_timer(struct gop_hw *gop, int mac_num, u64 timer);
void mv_gop110_fca_tx_enable(struct gop_hw *gop, int mac_num, bool en);
bool mv_gop110_check_fca_tx_state(struct gop_hw *gop, int mac_num);
static inline u32 mv_gop110_fca_read(struct gop_hw *gop, int mac_num,
u32 offset)
{
return mv_gop_gen_read(gop->gop_110.fca.base,
mac_num * gop->gop_110.fca.obj_size + offset);
}
static inline void mv_gop110_fca_write(struct gop_hw *gop, int mac_num,
u32 offset, u32 data)
{
mv_gop_gen_write(gop->gop_110.fca.base,
mac_num * gop->gop_110.fca.obj_size + offset, data);
}
/*Ethtool Functions */
void mv_gop110_gmac_registers_dump(struct mv_pp2x_port *port, u32 *regs_buff);
void mv_gop110_xlg_registers_dump(struct mv_pp2x_port *port, u32 *regs_buff);
int mv_gop110_update_comphy(struct mv_pp2x_port *port, u32 speed);
#endif /* _MV_GOP_HW_H_ */