Debian Codegraph @

drivers/net/ethernet/intel/ice/ice_ptp_hw.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2021, Intel Corporation. */
3
4 #ifndef _ICE_PTP_HW_H_
5 #define _ICE_PTP_HW_H_
6 #include <linux/dpll.h>
7
8 enum ice_ptp_tmr_cmd {
9 ICE_PTP_INIT_TIME,
10 ICE_PTP_INIT_INCVAL,
11 ICE_PTP_ADJ_TIME,
12 ICE_PTP_ADJ_TIME_AT_TIME,
13 ICE_PTP_READ_TIME,
14 ICE_PTP_NOP,
15 };
16
17 enum ice_ptp_serdes {
18 ICE_PTP_SERDES_1G,
19 ICE_PTP_SERDES_10G,
20 ICE_PTP_SERDES_25G,
21 ICE_PTP_SERDES_40G,
22 ICE_PTP_SERDES_50G,
23 ICE_PTP_SERDES_100G
24 };
25
26 enum ice_ptp_link_spd {
27 ICE_PTP_LNK_SPD_1G,
28 ICE_PTP_LNK_SPD_10G,
29 ICE_PTP_LNK_SPD_25G,
30 ICE_PTP_LNK_SPD_25G_RS,
31 ICE_PTP_LNK_SPD_40G,
32 ICE_PTP_LNK_SPD_50G,
33 ICE_PTP_LNK_SPD_50G_RS,
34 ICE_PTP_LNK_SPD_100G_RS,
35 NUM_ICE_PTP_LNK_SPD /* Must be last */
36 };
37
38 enum ice_ptp_fec_mode {
39 ICE_PTP_FEC_MODE_NONE,
40 ICE_PTP_FEC_MODE_CLAUSE74,
41 ICE_PTP_FEC_MODE_RS_FEC
42 };
43
44 enum eth56g_res_type {
45 ETH56G_PHY_REG_PTP,
46 ETH56G_PHY_MEM_PTP,
47 ETH56G_PHY_REG_XPCS,
48 ETH56G_PHY_REG_MAC,
49 ETH56G_PHY_REG_GPCS,
50 NUM_ETH56G_PHY_RES
51 };
52
53 enum ice_eth56g_link_spd {
54 ICE_ETH56G_LNK_SPD_1G,
55 ICE_ETH56G_LNK_SPD_2_5G,
56 ICE_ETH56G_LNK_SPD_10G,
57 ICE_ETH56G_LNK_SPD_25G,
58 ICE_ETH56G_LNK_SPD_40G,
59 ICE_ETH56G_LNK_SPD_50G,
60 ICE_ETH56G_LNK_SPD_50G2,
61 ICE_ETH56G_LNK_SPD_100G,
62 ICE_ETH56G_LNK_SPD_100G2,
63 NUM_ICE_ETH56G_LNK_SPD /* Must be last */
64 };
65
66 /**
67 * struct ice_phy_reg_info_eth56g - ETH56G PHY register parameters
68 * @base_addr: base address for each PHY block
69 * @step: step between PHY lanes
70 *
71 * Characteristic information for the various PHY register parameters in the
72 * ETH56G devices
73 */
74 struct ice_phy_reg_info_eth56g {
75 u32 base_addr;
76 u32 step;
77 };
78
79 /**
80 * struct ice_time_ref_info_e82x
81 * @pll_freq: Frequency of PLL that drives timer ticks in Hz
82 * @nominal_incval: increment to generate nanoseconds in GLTSYN_TIME_L
83 *
84 * Characteristic information for the various TIME_REF sources possible in the
85 * E822 devices
86 */
87 struct ice_time_ref_info_e82x {
88 u64 pll_freq;
89 u64 nominal_incval;
90 };
91
92 /**
93 * struct ice_vernier_info_e82x
94 * @tx_par_clk: Frequency used to calculate P_REG_PAR_TX_TUS
95 * @rx_par_clk: Frequency used to calculate P_REG_PAR_RX_TUS
96 * @tx_pcs_clk: Frequency used to calculate P_REG_PCS_TX_TUS
97 * @rx_pcs_clk: Frequency used to calculate P_REG_PCS_RX_TUS
98 * @tx_desk_rsgb_par: Frequency used to calculate P_REG_DESK_PAR_TX_TUS
99 * @rx_desk_rsgb_par: Frequency used to calculate P_REG_DESK_PAR_RX_TUS
100 * @tx_desk_rsgb_pcs: Frequency used to calculate P_REG_DESK_PCS_TX_TUS
101 * @rx_desk_rsgb_pcs: Frequency used to calculate P_REG_DESK_PCS_RX_TUS
102 * @tx_fixed_delay: Fixed Tx latency measured in 1/100th nanoseconds
103 * @pmd_adj_divisor: Divisor used to calculate PDM alignment adjustment
104 * @rx_fixed_delay: Fixed Rx latency measured in 1/100th nanoseconds
105 *
106 * Table of constants used during as part of the Vernier calibration of the Tx
107 * and Rx timestamps. This includes frequency values used to compute TUs per
108 * PAR/PCS clock cycle, and static delay values measured during hardware
109 * design.
110 *
111 * Note that some values are not used for all link speeds, and the
112 * P_REG_DESK_PAR* registers may represent different clock markers at
113 * different link speeds, either the deskew marker for multi-lane link speeds
114 * or the Reed Solomon gearbox marker for RS-FEC.
115 */
116 struct ice_vernier_info_e82x {
117 u32 tx_par_clk;
118 u32 rx_par_clk;
119 u32 tx_pcs_clk;
120 u32 rx_pcs_clk;
121 u32 tx_desk_rsgb_par;
122 u32 rx_desk_rsgb_par;
123 u32 tx_desk_rsgb_pcs;
124 u32 rx_desk_rsgb_pcs;
125 u32 tx_fixed_delay;
126 u32 pmd_adj_divisor;
127 u32 rx_fixed_delay;
128 };
129
130 #define ICE_ETH56G_MAC_CFG_RX_OFFSET_INT GENMASK(19, 9)
131 #define ICE_ETH56G_MAC_CFG_RX_OFFSET_FRAC GENMASK(8, 0)
132 #define ICE_ETH56G_MAC_CFG_FRAC_W 9
133 /**
134 * struct ice_eth56g_mac_reg_cfg - MAC config values for specific PTP registers
135 * @tx_mode: Tx timestamp compensation mode
136 * @tx_mk_dly: Tx timestamp marker start strobe delay
137 * @tx_cw_dly: Tx timestamp codeword start strobe delay
138 * @rx_mode: Rx timestamp compensation mode
139 * @rx_mk_dly: Rx timestamp marker start strobe delay
140 * @rx_cw_dly: Rx timestamp codeword start strobe delay
141 * @blks_per_clk: number of blocks transferred per clock cycle
142 * @blktime: block time, fixed point
143 * @mktime: marker time, fixed point
144 * @tx_offset: total Tx offset, fixed point
145 * @rx_offset: total Rx offset, contains value for bitslip/deskew, fixed point
146 *
147 * All fixed point registers except Rx offset are 23 bit unsigned ints with
148 * a 9 bit fractional.
149 * Rx offset is 11 bit unsigned int with a 9 bit fractional.
150 */
151 struct ice_eth56g_mac_reg_cfg {
152 struct {
153 u8 def;
154 u8 rs;
155 } tx_mode;
156 u8 tx_mk_dly;
157 struct {
158 u8 def;
159 u8 onestep;
160 } tx_cw_dly;
161 struct {
162 u8 def;
163 u8 rs;
164 } rx_mode;
165 struct {
166 u8 def;
167 u8 rs;
168 } rx_mk_dly;
169 struct {
170 u8 def;
171 u8 rs;
172 } rx_cw_dly;
173 u8 blks_per_clk;
174 u16 blktime;
175 u16 mktime;
176 struct {
177 u32 serdes;
178 u32 no_fec;
179 u32 fc;
180 u32 rs;
181 u32 sfd;
182 u32 onestep;
183 } tx_offset;
184 struct {
185 u32 serdes;
186 u32 no_fec;
187 u32 fc;
188 u32 rs;
189 u32 sfd;
190 u32 bs_ds;
191 } rx_offset;
192 };
193
194 extern
195 const struct ice_eth56g_mac_reg_cfg eth56g_mac_cfg[NUM_ICE_ETH56G_LNK_SPD];
196
197 #define E810C_QSFP_C827_0_HANDLE 2
198 #define E810C_QSFP_C827_1_HANDLE 3
199 enum ice_e810_c827_idx {
200 C827_0,
201 C827_1
202 };
203
204 enum ice_phy_rclk_pins {
205 ICE_RCLKA_PIN = 0, /* SCL pin */
206 ICE_RCLKB_PIN, /* SDA pin */
207 };
208
209 #define ICE_E810_RCLK_PINS_NUM (ICE_RCLKB_PIN + 1)
210 #define ICE_E82X_RCLK_PINS_NUM (ICE_RCLKA_PIN + 1)
211 #define E810T_CGU_INPUT_C827(_phy, _pin) ((_phy) * ICE_E810_RCLK_PINS_NUM + \
212 (_pin) + ZL_REF1P)
213
214 enum ice_zl_cgu_in_pins {
215 ZL_REF0P = 0,
216 ZL_REF0N,
217 ZL_REF1P,
218 ZL_REF1N,
219 ZL_REF2P,
220 ZL_REF2N,
221 ZL_REF3P,
222 ZL_REF3N,
223 ZL_REF4P,
224 ZL_REF4N,
225 NUM_ZL_CGU_INPUT_PINS
226 };
227
228 enum ice_zl_cgu_out_pins {
229 ZL_OUT0 = 0,
230 ZL_OUT1,
231 ZL_OUT2,
232 ZL_OUT3,
233 ZL_OUT4,
234 ZL_OUT5,
235 ZL_OUT6,
236 NUM_ZL_CGU_OUTPUT_PINS
237 };
238
239 enum ice_si_cgu_in_pins {
240 SI_REF0P = 0,
241 SI_REF0N,
242 SI_REF1P,
243 SI_REF1N,
244 SI_REF2P,
245 SI_REF2N,
246 SI_REF3,
247 SI_REF4,
248 NUM_SI_CGU_INPUT_PINS
249 };
250
251 enum ice_si_cgu_out_pins {
252 SI_OUT0 = 0,
253 SI_OUT1,
254 SI_OUT2,
255 SI_OUT3,
256 SI_OUT4,
257 NUM_SI_CGU_OUTPUT_PINS
258 };
259
260 struct ice_cgu_pin_desc {
261 char *name;
262 u8 index;
263 enum dpll_pin_type type;
264 u32 freq_supp_num;
265 struct dpll_pin_frequency *freq_supp;
266 };
267
268 #define E810C_QSFP_C827_0_HANDLE 2
269 #define E810C_QSFP_C827_1_HANDLE 3
270
271 /* Table of constants related to possible ETH56G PHY resources */
272 extern const struct ice_phy_reg_info_eth56g eth56g_phy_res[NUM_ETH56G_PHY_RES];
273
274 /* Table of constants related to possible TIME_REF sources */
275 extern const struct ice_time_ref_info_e82x e82x_time_ref[NUM_ICE_TSPLL_FREQ];
276
277 /* Table of constants for Vernier calibration on E822 */
278 extern const struct ice_vernier_info_e82x e822_vernier[NUM_ICE_PTP_LNK_SPD];
279
280 /* Increment value to generate nanoseconds in the GLTSYN_TIME_L register for
281 * the E810 devices. Based off of a PLL with an 812.5 MHz frequency.
282 */
283 #define ICE_E810_PLL_FREQ 812500000
284 #define ICE_PTP_NOMINAL_INCVAL_E810 0x13b13b13bULL
285 #define ICE_E810_E830_SYNC_DELAY 0
286
287 /* Device agnostic functions */
288 u8 ice_get_ptp_src_clock_index(struct ice_hw *hw);
289 bool ice_ptp_lock(struct ice_hw *hw);
290 void ice_ptp_unlock(struct ice_hw *hw);
291 void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd);
292 int ice_ptp_init_time(struct ice_hw *hw, u64 time);
293 int ice_ptp_write_incval(struct ice_hw *hw, u64 incval);
294 int ice_ptp_write_incval_locked(struct ice_hw *hw, u64 incval);
295 int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj);
296 int ice_ptp_clear_phy_offset_ready_e82x(struct ice_hw *hw);
297 int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp);
298 int ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx);
299 void ice_ptp_reset_ts_memory(struct ice_hw *hw);
300 int ice_ptp_init_phc(struct ice_hw *hw);
301 void ice_ptp_init_hw(struct ice_hw *hw);
302 int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready);
303 int ice_check_phy_tx_tstamp_ready(struct ice_hw *hw);
304 int ice_ptp_one_port_cmd(struct ice_hw *hw, u8 configured_port,
305 enum ice_ptp_tmr_cmd configured_cmd);
306
307 /* E822 family functions */
308 int ice_read_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32 *val);
309 int ice_write_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32 val);
310 void ice_ptp_reset_ts_memory_quad_e82x(struct ice_hw *hw, u8 quad);
311
312 /**
313 * ice_e82x_time_ref - Get the current TIME_REF from capabilities
314 * @hw: pointer to the HW structure
315 *
316 * Returns the current TIME_REF from the capabilities structure.
317 */
318
319 static inline enum ice_tspll_freq ice_e82x_time_ref(const struct ice_hw *hw)
320 {
321 return hw->func_caps.ts_func_info.time_ref;
322 }
323
324 /**
325 * ice_set_e82x_time_ref - Set new TIME_REF
326 * @hw: pointer to the HW structure
327 * @time_ref: new TIME_REF to set
328 *
329 * Update the TIME_REF in the capabilities structure in response to some
330 * change, such as an update to the CGU registers.
331 */
332 static inline void
333 ice_set_e82x_time_ref(struct ice_hw *hw, enum ice_tspll_freq time_ref)
334 {
335 hw->func_caps.ts_func_info.time_ref = time_ref;
336 }
337
338 static inline u64 ice_e82x_pll_freq(enum ice_tspll_freq time_ref)
339 {
340 return e82x_time_ref[time_ref].pll_freq;
341 }
342
343 static inline u64 ice_e82x_nominal_incval(enum ice_tspll_freq time_ref)
344 {
345 return e82x_time_ref[time_ref].nominal_incval;
346 }
347
348 /* E822 Vernier calibration functions */
349 int ice_stop_phy_timer_e82x(struct ice_hw *hw, u8 port, bool soft_reset);
350 int ice_start_phy_timer_e82x(struct ice_hw *hw, u8 port);
351 int ice_phy_cfg_tx_offset_e82x(struct ice_hw *hw, u8 port);
352 int ice_phy_cfg_rx_offset_e82x(struct ice_hw *hw, u8 port);
353 int ice_phy_cfg_intr_e82x(struct ice_hw *hw, u8 quad, bool ena, u8 threshold);
354
355 /* E810 family functions */
356 int ice_read_sma_ctrl(struct ice_hw *hw, u8 *data);
357 int ice_write_sma_ctrl(struct ice_hw *hw, u8 data);
358 int ice_ptp_read_sdp_ac(struct ice_hw *hw, __le16 *entries, uint *num_entries);
359 int ice_cgu_get_num_pins(struct ice_hw *hw, bool input);
360 enum dpll_pin_type ice_cgu_get_pin_type(struct ice_hw *hw, u8 pin, bool input);
361 struct dpll_pin_frequency *
362 ice_cgu_get_pin_freq_supp(struct ice_hw *hw, u8 pin, bool input, u8 *num);
363 const char *ice_cgu_get_pin_name(struct ice_hw *hw, u8 pin, bool input);
364 int ice_get_cgu_state(struct ice_hw *hw, u8 dpll_idx,
365 enum dpll_lock_status last_dpll_state, u8 *pin,
366 u8 *ref_state, u8 *eec_mode, s64 *phase_offset,
367 enum dpll_lock_status *dpll_state);
368 int ice_get_cgu_rclk_pin_info(struct ice_hw *hw, u8 *base_idx, u8 *pin_num);
369 int ice_cgu_get_output_pin_state_caps(struct ice_hw *hw, u8 pin_id,
370 unsigned long *caps);
371
372 /* ETH56G family functions */
373 int ice_ptp_read_tx_hwtstamp_status_eth56g(struct ice_hw *hw, u32 *ts_status);
374 int ice_stop_phy_timer_eth56g(struct ice_hw *hw, u8 port, bool soft_reset);
375 int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port);
376 int ice_phy_cfg_intr_eth56g(struct ice_hw *hw, u8 port, bool ena, u8 threshold);
377 int ice_phy_cfg_ptp_1step_eth56g(struct ice_hw *hw, u8 port);
378 int ice_ptp_phy_soft_reset_eth56g(struct ice_hw *hw, u8 port);
379
380 #define ICE_ETH56G_NOMINAL_INCVAL 0x140000000ULL
381 #define ICE_ETH56G_NOMINAL_PCS_REF_TUS 0x100000000ULL
382 #define ICE_ETH56G_NOMINAL_PCS_REF_INC 0x300000000ULL
383 #define ICE_ETH56G_NOMINAL_THRESH4 0x7777
384 #define ICE_ETH56G_NOMINAL_TX_THRESH 0x6
385
386 /**
387 * ice_get_base_incval - Get base clock increment value
388 * @hw: pointer to the HW struct
389 *
390 * Return: base clock increment value for supported PHYs, 0 otherwise
391 */
392 static inline u64 ice_get_base_incval(struct ice_hw *hw)
393 {
394 switch (hw->mac_type) {
395 case ICE_MAC_E810:
396 case ICE_MAC_E830:
397 return ICE_PTP_NOMINAL_INCVAL_E810;
398 case ICE_MAC_GENERIC:
399 return ice_e82x_nominal_incval(ice_e82x_time_ref(hw));
400 case ICE_MAC_GENERIC_3K_E825:
401 return ICE_ETH56G_NOMINAL_INCVAL;
402 default:
403 return 0;
404 }
405 }
406
407 #define PFTSYN_SEM_BYTES 4
408
409 #define ICE_PTP_CLOCK_INDEX_0 0x00
410 #define ICE_PTP_CLOCK_INDEX_1 0x01
411
412 /* PHY timer commands */
413 #define SEL_CPK_SRC 8
414 #define SEL_PHY_SRC 3
415
416 /* Time Sync command Definitions */
417 #define GLTSYN_CMD_INIT_TIME BIT(0)
418 #define GLTSYN_CMD_INIT_INCVAL BIT(1)
419 #define GLTSYN_CMD_INIT_TIME_INCVAL (BIT(0) | BIT(1))
420 #define GLTSYN_CMD_ADJ_TIME BIT(2)
421 #define GLTSYN_CMD_ADJ_INIT_TIME (BIT(2) | BIT(3))
422 #define GLTSYN_CMD_READ_TIME BIT(7)
423
424 /* PHY port Time Sync command definitions */
425 #define PHY_CMD_INIT_TIME BIT(0)
426 #define PHY_CMD_INIT_INCVAL BIT(1)
427 #define PHY_CMD_ADJ_TIME (BIT(0) | BIT(1))
428 #define PHY_CMD_ADJ_TIME_AT_TIME (BIT(0) | BIT(2))
429 #define PHY_CMD_READ_TIME (BIT(0) | BIT(1) | BIT(2))
430
431 #define TS_CMD_MASK_E810 0xFF
432 #define TS_CMD_MASK 0xF
433 #define SYNC_EXEC_CMD 0x3
434 #define TS_CMD_RX_TYPE ICE_M(0x18, 0x4)
435
436 /* Macros to derive port low and high addresses on both quads */
437 #define P_Q0_L(a, p) ((((a) + (0x2000 * (p)))) & 0xFFFF)
438 #define P_Q0_H(a, p) ((((a) + (0x2000 * (p)))) >> 16)
439 #define P_Q1_L(a, p) ((((a) - (0x2000 * ((p) - ICE_PORTS_PER_QUAD)))) & 0xFFFF)
440 #define P_Q1_H(a, p) ((((a) - (0x2000 * ((p) - ICE_PORTS_PER_QUAD)))) >> 16)
441
442 /* PHY QUAD register base addresses */
443 #define Q_0_BASE 0x94000
444 #define Q_1_BASE 0x114000
445
446 /* Timestamp memory reset registers */
447 #define Q_REG_TS_CTRL 0x618
448 #define Q_REG_TS_CTRL_S 0
449 #define Q_REG_TS_CTRL_M BIT(0)
450
451 /* Timestamp availability status registers */
452 #define Q_REG_TX_MEMORY_STATUS_L 0xCF0
453 #define Q_REG_TX_MEMORY_STATUS_U 0xCF4
454
455 /* Tx FIFO status registers */
456 #define Q_REG_FIFO23_STATUS 0xCF8
457 #define Q_REG_FIFO01_STATUS 0xCFC
458 #define Q_REG_FIFO02_S 0
459 #define Q_REG_FIFO02_M ICE_M(0x3FF, 0)
460 #define Q_REG_FIFO13_S 10
461 #define Q_REG_FIFO13_M ICE_M(0x3FF, 10)
462
463 /* Interrupt control Config registers */
464 #define Q_REG_TX_MEM_GBL_CFG 0xC08
465 #define Q_REG_TX_MEM_GBL_CFG_LANE_TYPE_S 0
466 #define Q_REG_TX_MEM_GBL_CFG_LANE_TYPE_M BIT(0)
467 #define Q_REG_TX_MEM_GBL_CFG_TX_TYPE_M ICE_M(0xFF, 1)
468 #define Q_REG_TX_MEM_GBL_CFG_INTR_THR_M ICE_M(0x3F, 9)
469 #define Q_REG_TX_MEM_GBL_CFG_INTR_ENA_M BIT(15)
470
471 /* Tx Timestamp data registers */
472 #define Q_REG_TX_MEMORY_BANK_START 0xA00
473
474 /* PHY port register base addresses */
475 #define P_0_BASE 0x80000
476 #define P_4_BASE 0x106000
477
478 /* Timestamp init registers */
479 #define P_REG_RX_TIMER_INC_PRE_L 0x46C
480 #define P_REG_RX_TIMER_INC_PRE_U 0x470
481 #define P_REG_TX_TIMER_INC_PRE_L 0x44C
482 #define P_REG_TX_TIMER_INC_PRE_U 0x450
483
484 /* Timestamp match and adjust target registers */
485 #define P_REG_RX_TIMER_CNT_ADJ_L 0x474
486 #define P_REG_RX_TIMER_CNT_ADJ_U 0x478
487 #define P_REG_TX_TIMER_CNT_ADJ_L 0x454
488 #define P_REG_TX_TIMER_CNT_ADJ_U 0x458
489
490 /* Timestamp capture registers */
491 #define P_REG_RX_CAPTURE_L 0x4D8
492 #define P_REG_RX_CAPTURE_U 0x4DC
493 #define P_REG_TX_CAPTURE_L 0x4B4
494 #define P_REG_TX_CAPTURE_U 0x4B8
495
496 /* Timestamp PHY incval registers */
497 #define P_REG_TIMETUS_L 0x410
498 #define P_REG_TIMETUS_U 0x414
499
500 #define P_REG_40B_LOW_M GENMASK(7, 0)
501 #define P_REG_40B_HIGH_S 8
502
503 /* PHY window length registers */
504 #define P_REG_WL 0x40C
505
506 #define PTP_VERNIER_WL 0x111ed
507
508 /* PHY start registers */
509 #define P_REG_PS 0x408
510 #define P_REG_PS_START_S 0
511 #define P_REG_PS_START_M BIT(0)
512 #define P_REG_PS_BYPASS_MODE_S 1
513 #define P_REG_PS_BYPASS_MODE_M BIT(1)
514 #define P_REG_PS_ENA_CLK_S 2
515 #define P_REG_PS_ENA_CLK_M BIT(2)
516 #define P_REG_PS_LOAD_OFFSET_S 3
517 #define P_REG_PS_LOAD_OFFSET_M BIT(3)
518 #define P_REG_PS_SFT_RESET_S 11
519 #define P_REG_PS_SFT_RESET_M BIT(11)
520
521 /* PHY offset valid registers */
522 #define P_REG_TX_OV_STATUS 0x4D4
523 #define P_REG_TX_OV_STATUS_OV_S 0
524 #define P_REG_TX_OV_STATUS_OV_M BIT(0)
525 #define P_REG_RX_OV_STATUS 0x4F8
526 #define P_REG_RX_OV_STATUS_OV_S 0
527 #define P_REG_RX_OV_STATUS_OV_M BIT(0)
528
529 /* PHY offset ready registers */
530 #define P_REG_TX_OR 0x45C
531 #define P_REG_RX_OR 0x47C
532
533 /* PHY total offset registers */
534 #define P_REG_TOTAL_RX_OFFSET_L 0x460
535 #define P_REG_TOTAL_RX_OFFSET_U 0x464
536 #define P_REG_TOTAL_TX_OFFSET_L 0x440
537 #define P_REG_TOTAL_TX_OFFSET_U 0x444
538
539 /* Timestamp PAR/PCS registers */
540 #define P_REG_UIX66_10G_40G_L 0x480
541 #define P_REG_UIX66_10G_40G_U 0x484
542 #define P_REG_UIX66_25G_100G_L 0x488
543 #define P_REG_UIX66_25G_100G_U 0x48C
544 #define P_REG_DESK_PAR_RX_TUS_L 0x490
545 #define P_REG_DESK_PAR_RX_TUS_U 0x494
546 #define P_REG_DESK_PAR_TX_TUS_L 0x498
547 #define P_REG_DESK_PAR_TX_TUS_U 0x49C
548 #define P_REG_DESK_PCS_RX_TUS_L 0x4A0
549 #define P_REG_DESK_PCS_RX_TUS_U 0x4A4
550 #define P_REG_DESK_PCS_TX_TUS_L 0x4A8
551 #define P_REG_DESK_PCS_TX_TUS_U 0x4AC
552 #define P_REG_PAR_RX_TUS_L 0x420
553 #define P_REG_PAR_RX_TUS_U 0x424
554 #define P_REG_PAR_TX_TUS_L 0x428
555 #define P_REG_PAR_TX_TUS_U 0x42C
556 #define P_REG_PCS_RX_TUS_L 0x430
557 #define P_REG_PCS_RX_TUS_U 0x434
558 #define P_REG_PCS_TX_TUS_L 0x438
559 #define P_REG_PCS_TX_TUS_U 0x43C
560 #define P_REG_PAR_RX_TIME_L 0x4F0
561 #define P_REG_PAR_RX_TIME_U 0x4F4
562 #define P_REG_PAR_TX_TIME_L 0x4CC
563 #define P_REG_PAR_TX_TIME_U 0x4D0
564 #define P_REG_PAR_PCS_RX_OFFSET_L 0x4E8
565 #define P_REG_PAR_PCS_RX_OFFSET_U 0x4EC
566 #define P_REG_PAR_PCS_TX_OFFSET_L 0x4C4
567 #define P_REG_PAR_PCS_TX_OFFSET_U 0x4C8
568 #define P_REG_LINK_SPEED 0x4FC
569 #define P_REG_LINK_SPEED_SERDES_S 0
570 #define P_REG_LINK_SPEED_SERDES_M ICE_M(0x7, 0)
571 #define P_REG_LINK_SPEED_FEC_MODE_S 3
572 #define P_REG_LINK_SPEED_FEC_MODE_M ICE_M(0x3, 3)
573 #define P_REG_LINK_SPEED_FEC_MODE(reg) \
574 (((reg) & P_REG_LINK_SPEED_FEC_MODE_M) >> \
575 P_REG_LINK_SPEED_FEC_MODE_S)
576
577 /* PHY timestamp related registers */
578 #define P_REG_PMD_ALIGNMENT 0x0FC
579 #define P_REG_RX_80_TO_160_CNT 0x6FC
580 #define P_REG_RX_80_TO_160_CNT_RXCYC_S 0
581 #define P_REG_RX_80_TO_160_CNT_RXCYC_M BIT(0)
582 #define P_REG_RX_40_TO_160_CNT 0x8FC
583 #define P_REG_RX_40_TO_160_CNT_RXCYC_S 0
584 #define P_REG_RX_40_TO_160_CNT_RXCYC_M ICE_M(0x3, 0)
585
586 /* Rx FIFO status registers */
587 #define P_REG_RX_OV_FS 0x4F8
588 #define P_REG_RX_OV_FS_FIFO_STATUS_S 2
589 #define P_REG_RX_OV_FS_FIFO_STATUS_M ICE_M(0x3FF, 2)
590
591 /* Timestamp command registers */
592 #define P_REG_TX_TMR_CMD 0x448
593 #define P_REG_RX_TMR_CMD 0x468
594
595 /* E810 timesync enable register */
596 #define ETH_GLTSYN_ENA(_i) (0x03000348 + ((_i) * 4))
597
598 /* E810 shadow init time registers */
599 #define ETH_GLTSYN_SHTIME_0(i) (0x03000368 + ((i) * 32))
600 #define ETH_GLTSYN_SHTIME_L(i) (0x0300036C + ((i) * 32))
601
602 /* E810 shadow time adjust registers */
603 #define ETH_GLTSYN_SHADJ_L(_i) (0x03000378 + ((_i) * 32))
604 #define ETH_GLTSYN_SHADJ_H(_i) (0x0300037C + ((_i) * 32))
605
606 /* E810 timer command register */
607 #define E810_ETH_GLTSYN_CMD 0x03000344
608
609 /* E830 timer command register */
610 #define E830_ETH_GLTSYN_CMD 0x00088814
611
612 /* E810 PHC time register */
613 #define E830_GLTSYN_TIME_L(_tmr_idx) (0x0008A000 + 0x1000 * (_tmr_idx))
614
615 /* Source timer incval macros */
616 #define INCVAL_HIGH_M 0xFF
617
618 /* PHY 40b registers macros */
619 #define PHY_EXT_40B_LOW_M GENMASK(31, 0)
620 #define PHY_EXT_40B_HIGH_M GENMASK_ULL(39, 32)
621 #define PHY_40B_LOW_M GENMASK(7, 0)
622 #define PHY_40B_HIGH_M GENMASK_ULL(39, 8)
623 #define TS_VALID BIT(0)
624 #define TS_LOW_M 0xFFFFFFFF
625 #define TS_HIGH_M 0xFF
626 #define TS_HIGH_S 32
627
628 #define BYTES_PER_IDX_ADDR_L_U 8
629 #define BYTES_PER_IDX_ADDR_L 4
630
631 /* Tx timestamp low latency read definitions */
632 #define REG_LL_PROXY_H_TIMEOUT_US 2000
633 #define REG_LL_PROXY_H_PHY_TMR_CMD_M GENMASK(7, 6)
634 #define REG_LL_PROXY_H_PHY_TMR_CMD_ADJ 0x1
635 #define REG_LL_PROXY_H_PHY_TMR_CMD_FREQ 0x2
636 #define REG_LL_PROXY_H_TS_HIGH GENMASK(23, 16)
637 #define REG_LL_PROXY_H_PHY_TMR_IDX_M BIT(24)
638 #define REG_LL_PROXY_H_TS_IDX GENMASK(29, 24)
639 #define REG_LL_PROXY_H_TS_INTR_ENA BIT(30)
640 #define REG_LL_PROXY_H_EXEC BIT(31)
641
642 #define REG_LL_PROXY_L PF_SB_ATQBAH
643 #define REG_LL_PROXY_H PF_SB_ATQBAL
644
645 /* Internal PHY timestamp address */
646 #define TS_L(a, idx) ((a) + ((idx) * BYTES_PER_IDX_ADDR_L_U))
647 #define TS_H(a, idx) ((a) + ((idx) * BYTES_PER_IDX_ADDR_L_U + \
648 BYTES_PER_IDX_ADDR_L))
649
650 /* External PHY timestamp address */
651 #define TS_EXT(a, port, idx) ((a) + (0x1000 * (port)) + \
652 ((idx) * BYTES_PER_IDX_ADDR_L_U))
653
654 #define LOW_TX_MEMORY_BANK_START 0x03090000
655 #define HIGH_TX_MEMORY_BANK_START 0x03090004
656
657 /* SMA controller pin control */
658 #define ICE_SMA1_DIR_EN BIT(4)
659 #define ICE_SMA1_TX_EN BIT(5)
660 #define ICE_SMA2_UFL2_RX_DIS BIT(3)
661 #define ICE_SMA2_DIR_EN BIT(6)
662 #define ICE_SMA2_TX_EN BIT(7)
663
664 #define ICE_SMA1_MASK (ICE_SMA1_DIR_EN | ICE_SMA1_TX_EN)
665 #define ICE_SMA2_MASK (ICE_SMA2_UFL2_RX_DIS | ICE_SMA2_DIR_EN | \
666 ICE_SMA2_TX_EN)
667 #define ICE_SMA2_INACTIVE_MASK (ICE_SMA2_DIR_EN | ICE_SMA2_TX_EN)
668 #define ICE_ALL_SMA_MASK (ICE_SMA1_MASK | ICE_SMA2_MASK)
669
670 #define ICE_SMA_MIN_BIT 3
671 #define ICE_SMA_MAX_BIT 7
672 #define ICE_PCA9575_P1_OFFSET 8
673
674 /* PCA9575 IO controller registers */
675 #define ICE_PCA9575_P0_IN 0x0
676
677 /* PCA9575 IO controller pin control */
678 #define ICE_P0_GNSS_PRSNT_N BIT(4)
679
680 /* ETH56G PHY register addresses */
681 #define PHY_REG_GLOBAL 0x0
682 #define PHY_REG_GLOBAL_SOFT_RESET_M BIT(11)
683
684 /* Timestamp PHY incval registers */
685 #define PHY_REG_TIMETUS_L 0x8
686 #define PHY_REG_TIMETUS_U 0xC
687
688 /* Timestamp PCS registers */
689 #define PHY_PCS_REF_TUS_L 0x18
690 #define PHY_PCS_REF_TUS_U 0x1C
691
692 /* Timestamp PCS ref incval registers */
693 #define PHY_PCS_REF_INC_L 0x20
694 #define PHY_PCS_REF_INC_U 0x24
695
696 /* Timestamp init registers */
697 #define PHY_REG_RX_TIMER_INC_PRE_L 0x64
698 #define PHY_REG_RX_TIMER_INC_PRE_U 0x68
699 #define PHY_REG_TX_TIMER_INC_PRE_L 0x44
700 #define PHY_REG_TX_TIMER_INC_PRE_U 0x48
701
702 /* Timestamp match and adjust target registers */
703 #define PHY_REG_RX_TIMER_CNT_ADJ_L 0x6C
704 #define PHY_REG_RX_TIMER_CNT_ADJ_U 0x70
705 #define PHY_REG_TX_TIMER_CNT_ADJ_L 0x4C
706 #define PHY_REG_TX_TIMER_CNT_ADJ_U 0x50
707
708 /* Timestamp command registers */
709 #define PHY_REG_TX_TMR_CMD 0x40
710 #define PHY_REG_RX_TMR_CMD 0x60
711
712 /* Phy offset ready registers */
713 #define PHY_REG_TX_OFFSET_READY 0x54
714 #define PHY_REG_RX_OFFSET_READY 0x74
715
716 /* Phy total offset registers */
717 #define PHY_REG_TOTAL_TX_OFFSET_L 0x38
718 #define PHY_REG_TOTAL_TX_OFFSET_U 0x3C
719 #define PHY_REG_TOTAL_RX_OFFSET_L 0x58
720 #define PHY_REG_TOTAL_RX_OFFSET_U 0x5C
721
722 /* Timestamp capture registers */
723 #define PHY_REG_TX_CAPTURE_L 0x78
724 #define PHY_REG_TX_CAPTURE_U 0x7C
725 #define PHY_REG_RX_CAPTURE_L 0x8C
726 #define PHY_REG_RX_CAPTURE_U 0x90
727
728 /* Memory status registers */
729 #define PHY_REG_TX_MEMORY_STATUS_L 0x80
730 #define PHY_REG_TX_MEMORY_STATUS_U 0x84
731
732 /* Interrupt config register */
733 #define PHY_REG_TS_INT_CONFIG 0x88
734
735 /* XIF mode config register */
736 #define PHY_MAC_XIF_MODE 0x24
737 #define PHY_MAC_XIF_1STEP_ENA_M ICE_M(0x1, 5)
738 #define PHY_MAC_XIF_TS_BIN_MODE_M ICE_M(0x1, 11)
739 #define PHY_MAC_XIF_TS_SFD_ENA_M ICE_M(0x1, 20)
740 #define PHY_MAC_XIF_GMII_TS_SEL_M ICE_M(0x1, 21)
741
742 #define PHY_TS_INT_CONFIG_THRESHOLD_M ICE_M(0x3F, 0)
743 #define PHY_TS_INT_CONFIG_ENA_M BIT(6)
744
745 /* Macros to derive offsets for TimeStampLow and TimeStampHigh */
746 #define PHY_TSTAMP_L(x) (((x) * 8) + 0)
747 #define PHY_TSTAMP_U(x) (((x) * 8) + 4)
748
749 #define PHY_REG_DESKEW_0 0x94
750 #define PHY_REG_DESKEW_0_RLEVEL GENMASK(6, 0)
751 #define PHY_REG_DESKEW_0_RLEVEL_FRAC GENMASK(9, 7)
752 #define PHY_REG_DESKEW_0_RLEVEL_FRAC_W 3
753 #define PHY_REG_DESKEW_0_VALID GENMASK(10, 10)
754
755 #define PHY_REG_SD_BIT_SLIP(_port_offset) (0x29C + 4 * (_port_offset))
756 #define PHY_REVISION_ETH56G 0x10200
757 #define PHY_VENDOR_TXLANE_THRESH 0x2000C
758
759 #define PHY_MAC_TSU_CONFIG 0x40
760 #define PHY_MAC_TSU_CFG_RX_MODE_M ICE_M(0x7, 0)
761 #define PHY_MAC_TSU_CFG_RX_MII_CW_DLY_M ICE_M(0x7, 4)
762 #define PHY_MAC_TSU_CFG_RX_MII_MK_DLY_M ICE_M(0x7, 8)
763 #define PHY_MAC_TSU_CFG_TX_MODE_M ICE_M(0x7, 12)
764 #define PHY_MAC_TSU_CFG_TX_MII_CW_DLY_M ICE_M(0x1F, 16)
765 #define PHY_MAC_TSU_CFG_TX_MII_MK_DLY_M ICE_M(0x1F, 21)
766 #define PHY_MAC_TSU_CFG_BLKS_PER_CLK_M ICE_M(0x1, 28)
767 #define PHY_MAC_RX_MODULO 0x44
768 #define PHY_MAC_RX_OFFSET 0x48
769 #define PHY_MAC_RX_OFFSET_M ICE_M(0xFFFFFF, 0)
770 #define PHY_MAC_TX_MODULO 0x4C
771 #define PHY_MAC_BLOCKTIME 0x50
772 #define PHY_MAC_MARKERTIME 0x54
773 #define PHY_MAC_TX_OFFSET 0x58
774 #define PHY_GPCS_BITSLIP 0x5C
775
776 #define PHY_PTP_INT_STATUS 0x7FD140
777
778 /* ETH56G registers shared per quad */
779 /* GPCS config register */
780 #define PHY_GPCS_CONFIG_REG0 0x268
781 #define PHY_GPCS_CONFIG_REG0_TX_THR_M GENMASK(27, 24)
782 /* 1-step PTP config */
783 #define PHY_PTP_1STEP_CONFIG 0x270
784 #define PHY_PTP_1STEP_T1S_UP64_M GENMASK(7, 4)
785 #define PHY_PTP_1STEP_T1S_DELTA_M GENMASK(11, 8)
786 #define PHY_PTP_1STEP_PEER_DELAY(_quad_lane) (0x274 + 4 * (_quad_lane))
787 #define PHY_PTP_1STEP_PD_ADD_PD_M BIT(0)
788 #define PHY_PTP_1STEP_PD_DELAY_M GENMASK(30, 1)
789 #define PHY_PTP_1STEP_PD_DLY_V_M BIT(31)
790
791 #endif /* _ICE_PTP_HW_H_ */