Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2001-2023 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _ICE_PTP_HW_H_
6 : : #define _ICE_PTP_HW_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 : : /**
45 : : * struct ice_time_ref_info_e822
46 : : * @pll_freq: Frequency of PLL that drives timer ticks in Hz
47 : : * @nominal_incval: increment to generate nanoseconds in GLTSYN_TIME_L
48 : : * @pps_delay: propagation delay of the PPS output signal
49 : : *
50 : : * Characteristic information for the various TIME_REF sources possible in the
51 : : * E822 devices
52 : : */
53 : : struct ice_time_ref_info_e822 {
54 : : u64 pll_freq;
55 : : u64 nominal_incval;
56 : : u8 pps_delay;
57 : : };
58 : :
59 : : /**
60 : : * struct ice_vernier_info_e822
61 : : * @tx_par_clk: Frequency used to calculate P_REG_PAR_TX_TUS
62 : : * @rx_par_clk: Frequency used to calculate P_REG_PAR_RX_TUS
63 : : * @tx_pcs_clk: Frequency used to calculate P_REG_PCS_TX_TUS
64 : : * @rx_pcs_clk: Frequency used to calculate P_REG_PCS_RX_TUS
65 : : * @tx_desk_rsgb_par: Frequency used to calculate P_REG_DESK_PAR_TX_TUS
66 : : * @rx_desk_rsgb_par: Frequency used to calculate P_REG_DESK_PAR_RX_TUS
67 : : * @tx_desk_rsgb_pcs: Frequency used to calculate P_REG_DESK_PCS_TX_TUS
68 : : * @rx_desk_rsgb_pcs: Frequency used to calculate P_REG_DESK_PCS_RX_TUS
69 : : * @tx_fixed_delay: Fixed Tx latency measured in 1/100th nanoseconds
70 : : * @pmd_adj_divisor: Divisor used to calculate PDM alignment adjustment
71 : : * @rx_fixed_delay: Fixed Rx latency measured in 1/100th nanoseconds
72 : : *
73 : : * Table of constants used during as part of the Vernier calibration of the Tx
74 : : * and Rx timestamps. This includes frequency values used to compute TUs per
75 : : * PAR/PCS clock cycle, and static delay values measured during hardware
76 : : * design.
77 : : *
78 : : * Note that some values are not used for all link speeds, and the
79 : : * P_REG_DESK_PAR* registers may represent different clock markers at
80 : : * different link speeds, either the deskew marker for multi-lane link speeds
81 : : * or the Reed Solomon gearbox marker for RS-FEC.
82 : : */
83 : : struct ice_vernier_info_e822 {
84 : : u32 tx_par_clk;
85 : : u32 rx_par_clk;
86 : : u32 tx_pcs_clk;
87 : : u32 rx_pcs_clk;
88 : : u32 tx_desk_rsgb_par;
89 : : u32 rx_desk_rsgb_par;
90 : : u32 tx_desk_rsgb_pcs;
91 : : u32 rx_desk_rsgb_pcs;
92 : : u32 tx_fixed_delay;
93 : : u32 pmd_adj_divisor;
94 : : u32 rx_fixed_delay;
95 : : };
96 : :
97 : : /**
98 : : * struct ice_cgu_pll_params_e822
99 : : * @refclk_pre_div: Reference clock pre-divisor
100 : : * @feedback_div: Feedback divisor
101 : : * @frac_n_div: Fractional divisor
102 : : * @post_pll_div: Post PLL divisor
103 : : *
104 : : * Clock Generation Unit parameters used to program the PLL based on the
105 : : * selected TIME_REF frequency.
106 : : */
107 : : struct ice_cgu_pll_params_e822 {
108 : : u32 refclk_pre_div;
109 : : u32 feedback_div;
110 : : u32 frac_n_div;
111 : : u32 post_pll_div;
112 : : };
113 : :
114 : : extern const struct
115 : : ice_cgu_pll_params_e822 e822_cgu_params[NUM_ICE_TIME_REF_FREQ];
116 : :
117 : : /* Table of constants related to possible TIME_REF sources */
118 : : extern const struct ice_time_ref_info_e822 e822_time_ref[NUM_ICE_TIME_REF_FREQ];
119 : :
120 : : /* Table of constants for Vernier calibration on E822 */
121 : : extern const struct ice_vernier_info_e822 e822_vernier[NUM_ICE_PTP_LNK_SPD];
122 : :
123 : : /* Increment value to generate nanoseconds in the GLTSYN_TIME_L register for
124 : : * the E810 devices. Based off of a PLL with an 812.5 MHz frequency.
125 : : */
126 : : #define ICE_PTP_NOMINAL_INCVAL_E810 0x13b13b13bULL
127 : :
128 : : /* Device agnostic functions */
129 : : u8 ice_get_ptp_src_clock_index(struct ice_hw *hw);
130 : : u64 ice_ptp_read_src_incval(struct ice_hw *hw);
131 : : bool ice_ptp_lock(struct ice_hw *hw);
132 : : void ice_ptp_unlock(struct ice_hw *hw);
133 : : void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd);
134 : : enum ice_status ice_ptp_init_time(struct ice_hw *hw, u64 time);
135 : : enum ice_status ice_ptp_write_incval(struct ice_hw *hw, u64 incval);
136 : : enum ice_status ice_ptp_write_incval_locked(struct ice_hw *hw, u64 incval);
137 : : enum ice_status ice_ptp_adj_clock(struct ice_hw *hw, s32 adj, bool lock_sbq);
138 : : enum ice_status
139 : : ice_ptp_adj_clock_at_time(struct ice_hw *hw, u64 at_time, s32 adj);
140 : : enum ice_status
141 : : ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp);
142 : : enum ice_status
143 : : ice_clear_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx);
144 : : enum ice_status ice_ptp_init_phc(struct ice_hw *hw);
145 : :
146 : : /* E822 family functions */
147 : : enum ice_status
148 : : ice_read_phy_reg_e822(struct ice_hw *hw, u8 port, u16 offset, u32 *val);
149 : : enum ice_status
150 : : ice_write_phy_reg_e822(struct ice_hw *hw, u8 port, u16 offset, u32 val);
151 : : enum ice_status
152 : : ice_read_quad_reg_e822(struct ice_hw *hw, u8 quad, u16 offset, u32 *val);
153 : : enum ice_status
154 : : ice_write_quad_reg_e822(struct ice_hw *hw, u8 quad, u16 offset, u32 val);
155 : : enum ice_status
156 : : ice_ptp_prep_port_adj_e822(struct ice_hw *hw, u8 port, s64 time,
157 : : bool lock_sbq);
158 : : enum ice_status
159 : : ice_ptp_read_phy_incval_e822(struct ice_hw *hw, u8 port, u64 *incval);
160 : : enum ice_status
161 : : ice_ptp_read_port_capture_e822(struct ice_hw *hw, u8 port,
162 : : u64 *tx_ts, u64 *rx_ts);
163 : : enum ice_status
164 : : ice_ptp_one_port_cmd_e822(struct ice_hw *hw, u8 port,
165 : : enum ice_ptp_tmr_cmd cmd, bool lock_sbq);
166 : : enum ice_status
167 : : ice_cfg_cgu_pll_e822(struct ice_hw *hw, enum ice_time_ref_freq clk_freq,
168 : : enum ice_clk_src clk_src);
169 : :
170 : : /**
171 : : * ice_e822_time_ref - Get the current TIME_REF from capabilities
172 : : * @hw: pointer to the HW structure
173 : : *
174 : : * Returns the current TIME_REF from the capabilities structure.
175 : : */
176 : : static inline enum ice_time_ref_freq ice_e822_time_ref(struct ice_hw *hw)
177 : : {
178 : 0 : return hw->func_caps.ts_func_info.time_ref;
179 : : }
180 : :
181 : : /**
182 : : * ice_set_e822_time_ref - Set new TIME_REF
183 : : * @hw: pointer to the HW structure
184 : : * @time_ref: new TIME_REF to set
185 : : *
186 : : * Update the TIME_REF in the capabilities structure in response to some
187 : : * change, such as an update to the CGU registers.
188 : : */
189 : : static inline void
190 : : ice_set_e822_time_ref(struct ice_hw *hw, enum ice_time_ref_freq time_ref)
191 : : {
192 : : hw->func_caps.ts_func_info.time_ref = time_ref;
193 : : }
194 : :
195 : : static inline u64 ice_e822_pll_freq(enum ice_time_ref_freq time_ref)
196 : : {
197 : 0 : return e822_time_ref[time_ref].pll_freq;
198 : : }
199 : :
200 : : static inline u64 ice_e822_nominal_incval(enum ice_time_ref_freq time_ref)
201 : : {
202 : : return e822_time_ref[time_ref].nominal_incval;
203 : : }
204 : :
205 : : static inline u64 ice_e822_pps_delay(enum ice_time_ref_freq time_ref)
206 : : {
207 : : return e822_time_ref[time_ref].pps_delay;
208 : : }
209 : :
210 : : /* E822 Vernier calibration functions */
211 : : enum ice_status ice_ptp_set_vernier_wl(struct ice_hw *hw);
212 : : enum ice_status
213 : : ice_phy_get_speed_and_fec_e822(struct ice_hw *hw, u8 port,
214 : : enum ice_ptp_link_spd *link_out,
215 : : enum ice_ptp_fec_mode *fec_out);
216 : : void ice_phy_cfg_lane_e822(struct ice_hw *hw, u8 port);
217 : : enum ice_status
218 : : ice_stop_phy_timer_e822(struct ice_hw *hw, u8 port, bool soft_reset);
219 : : enum ice_status
220 : : ice_start_phy_timer_e822(struct ice_hw *hw, u8 port, bool bypass);
221 : : enum ice_status ice_phy_cfg_tx_offset_e822(struct ice_hw *hw, u8 port);
222 : : enum ice_status ice_phy_cfg_rx_offset_e822(struct ice_hw *hw, u8 port);
223 : : enum ice_status ice_phy_exit_bypass_e822(struct ice_hw *hw, u8 port);
224 : :
225 : : /* E810 family functions */
226 : : bool ice_is_gps_present_e810t(struct ice_hw *hw);
227 : : enum ice_status ice_ptp_init_phy_e810(struct ice_hw *hw);
228 : : enum ice_status
229 : : ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data);
230 : : enum ice_status
231 : : ice_write_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 data);
232 : : enum ice_status ice_read_sma_ctrl_e810t(struct ice_hw *hw, u8 *data);
233 : : enum ice_status ice_write_sma_ctrl_e810t(struct ice_hw *hw, u8 data);
234 : : bool ice_is_pca9575_present(struct ice_hw *hw);
235 : :
236 : : void
237 : : ice_ptp_process_cgu_err(struct ice_hw *hw, struct ice_rq_event_info *event);
238 : : /* ETH56G family functions */
239 : : enum ice_status
240 : : ice_read_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 offset, u32 *val);
241 : : enum ice_status
242 : : ice_write_phy_reg_eth56g(struct ice_hw *hw, u8 port, u16 offset, u32 val);
243 : : enum ice_status
244 : : ice_read_phy_mem_eth56g(struct ice_hw *hw, u8 port, u16 offset, u32 *val);
245 : : enum ice_status
246 : : ice_write_phy_mem_eth56g(struct ice_hw *hw, u8 port, u16 offset, u32 val);
247 : :
248 : : enum ice_status
249 : : ice_ptp_prep_port_adj_eth56g(struct ice_hw *hw, u8 port, s64 time,
250 : : bool lock_sbq);
251 : :
252 : : enum ice_status
253 : : ice_ptp_read_phy_incval_eth56g(struct ice_hw *hw, u8 port, u64 *incval);
254 : : enum ice_status
255 : : ice_ptp_read_port_capture_eth56g(struct ice_hw *hw, u8 port,
256 : : u64 *tx_ts, u64 *rx_ts);
257 : : enum ice_status
258 : : ice_ptp_one_port_cmd_eth56g(struct ice_hw *hw, u8 port,
259 : : enum ice_ptp_tmr_cmd cmd, bool lock_sbq);
260 : : enum ice_status
261 : : ice_ptp_read_tx_hwtstamp_status_eth56g(struct ice_hw *hw, u32 *ts_status);
262 : : enum ice_status
263 : : ice_stop_phy_timer_eth56g(struct ice_hw *hw, u8 port, bool soft_reset);
264 : : enum ice_status
265 : : ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port, bool bypass);
266 : : enum ice_status ice_phy_cfg_tx_offset_eth56g(struct ice_hw *hw, u8 port);
267 : : enum ice_status ice_phy_cfg_rx_offset_eth56g(struct ice_hw *hw, u8 port);
268 : :
269 : : enum ice_status ice_ptp_init_phy_cfg(struct ice_hw *hw);
270 : :
271 : : #define PFTSYN_SEM_BYTES 4
272 : :
273 : : #define ICE_PTP_CLOCK_INDEX_0 0x00
274 : : #define ICE_PTP_CLOCK_INDEX_1 0x01
275 : :
276 : : /* PHY timer commands */
277 : : #define SEL_CPK_SRC 8
278 : : #define SEL_PHY_SRC 3
279 : :
280 : : /* Time Sync command Definitions */
281 : : #define GLTSYN_CMD_INIT_TIME BIT(0)
282 : : #define GLTSYN_CMD_INIT_INCVAL BIT(1)
283 : : #define GLTSYN_CMD_INIT_TIME_INCVAL (BIT(0) | BIT(1))
284 : : #define GLTSYN_CMD_ADJ_TIME BIT(2)
285 : : #define GLTSYN_CMD_ADJ_INIT_TIME (BIT(2) | BIT(3))
286 : : #define GLTSYN_CMD_READ_TIME BIT(7)
287 : :
288 : : /* PHY port Time Sync command definitions */
289 : : #define PHY_CMD_INIT_TIME BIT(0)
290 : : #define PHY_CMD_INIT_INCVAL BIT(1)
291 : : #define PHY_CMD_ADJ_TIME (BIT(0) | BIT(1))
292 : : #define PHY_CMD_ADJ_TIME_AT_TIME (BIT(0) | BIT(2))
293 : : #define PHY_CMD_READ_TIME (BIT(0) | BIT(1) | BIT(2))
294 : :
295 : : #define TS_CMD_MASK_E810 0xFF
296 : : #define TS_CMD_MASK 0xF
297 : : #define SYNC_EXEC_CMD 0x3
298 : :
299 : : /* Macros to derive port low and high addresses on both quads */
300 : : #define P_Q0_L(a, p) ((((a) + (0x2000 * (p)))) & 0xFFFF)
301 : : #define P_Q0_H(a, p) ((((a) + (0x2000 * (p)))) >> 16)
302 : : #define P_Q1_L(a, p) ((((a) - (0x2000 * ((p) - ICE_PORTS_PER_QUAD)))) & 0xFFFF)
303 : : #define P_Q1_H(a, p) ((((a) - (0x2000 * ((p) - ICE_PORTS_PER_QUAD)))) >> 16)
304 : :
305 : : /* PHY QUAD register base addresses */
306 : : #define Q_0_BASE 0x94000
307 : : #define Q_1_BASE 0x114000
308 : :
309 : : /* Timestamp memory reset registers */
310 : : #define Q_REG_TS_CTRL 0x618
311 : : #define Q_REG_TS_CTRL_S 0
312 : : #define Q_REG_TS_CTRL_M BIT(0)
313 : :
314 : : /* Timestamp availability status registers */
315 : : #define Q_REG_TX_MEMORY_STATUS_L 0xCF0
316 : : #define Q_REG_TX_MEMORY_STATUS_U 0xCF4
317 : :
318 : : /* Tx FIFO status registers */
319 : : #define Q_REG_FIFO23_STATUS 0xCF8
320 : : #define Q_REG_FIFO01_STATUS 0xCFC
321 : : #define Q_REG_FIFO02_S 0
322 : : #define Q_REG_FIFO02_M MAKEMASK(0x3FF, 0)
323 : : #define Q_REG_FIFO13_S 10
324 : : #define Q_REG_FIFO13_M MAKEMASK(0x3FF, 10)
325 : :
326 : : /* Interrupt control Config registers */
327 : : #define Q_REG_TX_MEM_GBL_CFG 0xC08
328 : : #define Q_REG_TX_MEM_GBL_CFG_LANE_TYPE_S 0
329 : : #define Q_REG_TX_MEM_GBL_CFG_LANE_TYPE_M BIT(0)
330 : : #define Q_REG_TX_MEM_GBL_CFG_TX_TYPE_S 1
331 : : #define Q_REG_TX_MEM_GBL_CFG_TX_TYPE_M MAKEMASK(0xFF, 1)
332 : : #define Q_REG_TX_MEM_GBL_CFG_INTR_THR_S 9
333 : : #define Q_REG_TX_MEM_GBL_CFG_INTR_THR_M MAKEMASK(0x3F, 9)
334 : : #define Q_REG_TX_MEM_GBL_CFG_INTR_ENA_S 15
335 : : #define Q_REG_TX_MEM_GBL_CFG_INTR_ENA_M BIT(15)
336 : :
337 : : /* Tx Timestamp data registers */
338 : : #define Q_REG_TX_MEMORY_BANK_START 0xA00
339 : :
340 : : /* PHY port register base addresses */
341 : : #define P_0_BASE 0x80000
342 : : #define P_4_BASE 0x106000
343 : :
344 : : /* Timestamp init registers */
345 : : #define P_REG_RX_TIMER_INC_PRE_L 0x46C
346 : : #define P_REG_RX_TIMER_INC_PRE_U 0x470
347 : : #define P_REG_TX_TIMER_INC_PRE_L 0x44C
348 : : #define P_REG_TX_TIMER_INC_PRE_U 0x450
349 : :
350 : : /* Timestamp match and adjust target registers */
351 : : #define P_REG_RX_TIMER_CNT_ADJ_L 0x474
352 : : #define P_REG_RX_TIMER_CNT_ADJ_U 0x478
353 : : #define P_REG_TX_TIMER_CNT_ADJ_L 0x454
354 : : #define P_REG_TX_TIMER_CNT_ADJ_U 0x458
355 : :
356 : : /* Timestamp capture registers */
357 : : #define P_REG_RX_CAPTURE_L 0x4D8
358 : : #define P_REG_RX_CAPTURE_U 0x4DC
359 : : #define P_REG_TX_CAPTURE_L 0x4B4
360 : : #define P_REG_TX_CAPTURE_U 0x4B8
361 : :
362 : : /* Timestamp PHY incval registers */
363 : : #define P_REG_TIMETUS_L 0x410
364 : : #define P_REG_TIMETUS_U 0x414
365 : :
366 : : #define P_REG_40B_LOW_M 0xFF
367 : : #define P_REG_40B_HIGH_S 8
368 : :
369 : : /* PHY window length registers */
370 : : #define P_REG_WL 0x40C
371 : :
372 : : #define PTP_VERNIER_WL 0x111ed
373 : :
374 : : /* PHY start registers */
375 : : #define P_REG_PS 0x408
376 : : #define P_REG_PS_START_S 0
377 : : #define P_REG_PS_START_M BIT(0)
378 : : #define P_REG_PS_BYPASS_MODE_S 1
379 : : #define P_REG_PS_BYPASS_MODE_M BIT(1)
380 : : #define P_REG_PS_ENA_CLK_S 2
381 : : #define P_REG_PS_ENA_CLK_M BIT(2)
382 : : #define P_REG_PS_LOAD_OFFSET_S 3
383 : : #define P_REG_PS_LOAD_OFFSET_M BIT(3)
384 : : #define P_REG_PS_SFT_RESET_S 11
385 : : #define P_REG_PS_SFT_RESET_M BIT(11)
386 : :
387 : : /* PHY offset valid registers */
388 : : #define P_REG_TX_OV_STATUS 0x4D4
389 : : #define P_REG_TX_OV_STATUS_OV_S 0
390 : : #define P_REG_TX_OV_STATUS_OV_M BIT(0)
391 : : #define P_REG_RX_OV_STATUS 0x4F8
392 : : #define P_REG_RX_OV_STATUS_OV_S 0
393 : : #define P_REG_RX_OV_STATUS_OV_M BIT(0)
394 : :
395 : : /* PHY offset ready registers */
396 : : #define P_REG_TX_OR 0x45C
397 : : #define P_REG_RX_OR 0x47C
398 : :
399 : : /* PHY total offset registers */
400 : : #define P_REG_TOTAL_RX_OFFSET_L 0x460
401 : : #define P_REG_TOTAL_RX_OFFSET_U 0x464
402 : : #define P_REG_TOTAL_TX_OFFSET_L 0x440
403 : : #define P_REG_TOTAL_TX_OFFSET_U 0x444
404 : :
405 : : /* Timestamp PAR/PCS registers */
406 : : #define P_REG_UIX66_10G_40G_L 0x480
407 : : #define P_REG_UIX66_10G_40G_U 0x484
408 : : #define P_REG_UIX66_25G_100G_L 0x488
409 : : #define P_REG_UIX66_25G_100G_U 0x48C
410 : : #define P_REG_DESK_PAR_RX_TUS_L 0x490
411 : : #define P_REG_DESK_PAR_RX_TUS_U 0x494
412 : : #define P_REG_DESK_PAR_TX_TUS_L 0x498
413 : : #define P_REG_DESK_PAR_TX_TUS_U 0x49C
414 : : #define P_REG_DESK_PCS_RX_TUS_L 0x4A0
415 : : #define P_REG_DESK_PCS_RX_TUS_U 0x4A4
416 : : #define P_REG_DESK_PCS_TX_TUS_L 0x4A8
417 : : #define P_REG_DESK_PCS_TX_TUS_U 0x4AC
418 : : #define P_REG_PAR_RX_TUS_L 0x420
419 : : #define P_REG_PAR_RX_TUS_U 0x424
420 : : #define P_REG_PAR_TX_TUS_L 0x428
421 : : #define P_REG_PAR_TX_TUS_U 0x42C
422 : : #define P_REG_PCS_RX_TUS_L 0x430
423 : : #define P_REG_PCS_RX_TUS_U 0x434
424 : : #define P_REG_PCS_TX_TUS_L 0x438
425 : : #define P_REG_PCS_TX_TUS_U 0x43C
426 : : #define P_REG_PAR_RX_TIME_L 0x4F0
427 : : #define P_REG_PAR_RX_TIME_U 0x4F4
428 : : #define P_REG_PAR_TX_TIME_L 0x4CC
429 : : #define P_REG_PAR_TX_TIME_U 0x4D0
430 : : #define P_REG_PAR_PCS_RX_OFFSET_L 0x4E8
431 : : #define P_REG_PAR_PCS_RX_OFFSET_U 0x4EC
432 : : #define P_REG_PAR_PCS_TX_OFFSET_L 0x4C4
433 : : #define P_REG_PAR_PCS_TX_OFFSET_U 0x4C8
434 : : #define P_REG_LINK_SPEED 0x4FC
435 : : #define P_REG_LINK_SPEED_SERDES_S 0
436 : : #define P_REG_LINK_SPEED_SERDES_M MAKEMASK(0x7, 0)
437 : : #define P_REG_LINK_SPEED_FEC_MODE_S 3
438 : : #define P_REG_LINK_SPEED_FEC_MODE_M MAKEMASK(0x3, 3)
439 : : #define P_REG_LINK_SPEED_FEC_MODE(reg) \
440 : : (((reg) & P_REG_LINK_SPEED_FEC_MODE_M) >> \
441 : : P_REG_LINK_SPEED_FEC_MODE_S)
442 : :
443 : : /* PHY timestamp related registers */
444 : : #define P_REG_PMD_ALIGNMENT 0x0FC
445 : : #define P_REG_RX_80_TO_160_CNT 0x6FC
446 : : #define P_REG_RX_80_TO_160_CNT_RXCYC_S 0
447 : : #define P_REG_RX_80_TO_160_CNT_RXCYC_M BIT(0)
448 : : #define P_REG_RX_40_TO_160_CNT 0x8FC
449 : : #define P_REG_RX_40_TO_160_CNT_RXCYC_S 0
450 : : #define P_REG_RX_40_TO_160_CNT_RXCYC_M MAKEMASK(0x3, 0)
451 : :
452 : : /* Rx FIFO status registers */
453 : : #define P_REG_RX_OV_FS 0x4F8
454 : : #define P_REG_RX_OV_FS_FIFO_STATUS_S 2
455 : : #define P_REG_RX_OV_FS_FIFO_STATUS_M MAKEMASK(0x3FF, 2)
456 : :
457 : : /* Timestamp command registers */
458 : : #define P_REG_TX_TMR_CMD 0x448
459 : : #define P_REG_RX_TMR_CMD 0x468
460 : :
461 : : /* E810 timesync enable register */
462 : : #define ETH_GLTSYN_ENA(_i) (0x03000348 + ((_i) * 4))
463 : :
464 : : /* E810 shadow init time registers */
465 : : #define ETH_GLTSYN_SHTIME_0(i) (0x03000368 + ((i) * 32))
466 : : #define ETH_GLTSYN_SHTIME_L(i) (0x0300036C + ((i) * 32))
467 : :
468 : : /* E810 shadow time adjust registers */
469 : : #define ETH_GLTSYN_SHADJ_L(_i) (0x03000378 + ((_i) * 32))
470 : : #define ETH_GLTSYN_SHADJ_H(_i) (0x0300037C + ((_i) * 32))
471 : :
472 : : /* E810 timer command register */
473 : : #define ETH_GLTSYN_CMD 0x03000344
474 : :
475 : : /* Source timer incval macros */
476 : : #define INCVAL_HIGH_M 0xFF
477 : :
478 : : /* Timestamp block macros */
479 : : #define TS_VALID BIT(0)
480 : : #define TS_LOW_M 0xFFFFFFFF
481 : : #define TS_HIGH_S 32
482 : :
483 : : #define TS_PHY_LOW_M 0xFF
484 : : #define TS_PHY_HIGH_M 0xFFFFFFFF
485 : : #define TS_PHY_HIGH_S 8
486 : :
487 : : #define BYTES_PER_IDX_ADDR_L_U 8
488 : : #define BYTES_PER_IDX_ADDR_L 4
489 : :
490 : : /* Tx timestamp low latency read definitions */
491 : : #define TS_LL_READ_RETRIES 200
492 : : #define TS_LL_READ_TS BIT(31)
493 : : #define TS_LL_READ_TS_IDX_S 24
494 : : #define TS_LL_READ_TS_IDX_M MAKEMASK(0x3F, 0)
495 : : #define TS_LL_READ_TS_IDX(__idx) (TS_LL_READ_TS | \
496 : : (((__idx) & TS_LL_READ_TS_IDX_M) << \
497 : : TS_LL_READ_TS_IDX_S))
498 : : #define TS_LL_READ_TS_HIGH_S 16
499 : :
500 : : /* Internal PHY timestamp address */
501 : : #define TS_L(a, idx) ((a) + ((idx) * BYTES_PER_IDX_ADDR_L_U))
502 : : #define TS_H(a, idx) ((a) + ((idx) * BYTES_PER_IDX_ADDR_L_U + \
503 : : BYTES_PER_IDX_ADDR_L))
504 : :
505 : : /* External PHY timestamp address */
506 : : #define TS_EXT(a, port, idx) ((a) + (0x1000 * (port)) + \
507 : : ((idx) * BYTES_PER_IDX_ADDR_L_U))
508 : :
509 : : #define LOW_TX_MEMORY_BANK_START 0x03090000
510 : : #define HIGH_TX_MEMORY_BANK_START 0x03090004
511 : :
512 : : /* E810T PCA9575 IO controller registers */
513 : : #define ICE_PCA9575_P0_IN 0x0
514 : : #define ICE_PCA9575_P1_IN 0x1
515 : : #define ICE_PCA9575_P0_CFG 0x8
516 : : #define ICE_PCA9575_P1_CFG 0x9
517 : : #define ICE_PCA9575_P0_OUT 0xA
518 : : #define ICE_PCA9575_P1_OUT 0xB
519 : :
520 : : /* E810T PCA9575 IO controller pin control */
521 : : #define ICE_E810T_P0_GNSS_PRSNT_N BIT(4)
522 : : #define ICE_E810T_P1_SMA1_DIR_EN BIT(4)
523 : : #define ICE_E810T_P1_SMA1_TX_EN BIT(5)
524 : : #define ICE_E810T_P1_SMA2_UFL2_RX_DIS BIT(3)
525 : : #define ICE_E810T_P1_SMA2_DIR_EN BIT(6)
526 : : #define ICE_E810T_P1_SMA2_TX_EN BIT(7)
527 : :
528 : : #define ICE_E810T_SMA_MIN_BIT 3
529 : : #define ICE_E810T_SMA_MAX_BIT 7
530 : : #define ICE_E810T_P1_OFFSET 8
531 : : /* 56G PHY quad register base addresses */
532 : : #define ICE_PHY0_BASE 0x092000
533 : : #define ICE_PHY1_BASE 0x126000
534 : : #define ICE_PHY2_BASE 0x1BA000
535 : : #define ICE_PHY3_BASE 0x24E000
536 : : #define ICE_PHY4_BASE 0x2E2000
537 : :
538 : : /* Timestamp memory */
539 : : #define PHY_PTP_LANE_ADDR_STEP 0x98
540 : :
541 : : #define PHY_PTP_MEM_START 0x1000
542 : : #define PHY_PTP_MEM_LANE_STEP 0x04A0
543 : : #define PHY_PTP_MEM_LOCATIONS 0x40
544 : :
545 : : /* Number of PHY ports */
546 : : #define ICE_NUM_PHY_PORTS 5
547 : : /* Timestamp PHY incval registers */
548 : : #define PHY_REG_TIMETUS_L 0x8
549 : : #define PHY_REG_TIMETUS_U 0xC
550 : :
551 : : /* Timestamp init registers */
552 : : #define PHY_REG_RX_TIMER_INC_PRE_L 0x64
553 : : #define PHY_REG_RX_TIMER_INC_PRE_U 0x68
554 : :
555 : : #define PHY_REG_TX_TIMER_INC_PRE_L 0x44
556 : : #define PHY_REG_TX_TIMER_INC_PRE_U 0x48
557 : :
558 : : /* Timestamp match and adjust target registers */
559 : : #define PHY_REG_RX_TIMER_CNT_ADJ_L 0x6C
560 : : #define PHY_REG_RX_TIMER_CNT_ADJ_U 0x70
561 : :
562 : : #define PHY_REG_TX_TIMER_CNT_ADJ_L 0x4C
563 : : #define PHY_REG_TX_TIMER_CNT_ADJ_U 0x50
564 : :
565 : : /* Timestamp command registers */
566 : : #define PHY_REG_TX_TMR_CMD 0x40
567 : : #define PHY_REG_RX_TMR_CMD 0x60
568 : :
569 : : /* Phy offset ready registers */
570 : : #define PHY_REG_TX_OFFSET_READY 0x54
571 : : #define PHY_REG_RX_OFFSET_READY 0x74
572 : : /* Phy total offset registers */
573 : : #define PHY_REG_TOTAL_TX_OFFSET_L 0x38
574 : : #define PHY_REG_TOTAL_TX_OFFSET_U 0x3C
575 : :
576 : : #define PHY_REG_TOTAL_RX_OFFSET_L 0x58
577 : : #define PHY_REG_TOTAL_RX_OFFSET_U 0x5C
578 : :
579 : : /* Timestamp capture registers */
580 : : #define PHY_REG_TX_CAPTURE_L 0x78
581 : : #define PHY_REG_TX_CAPTURE_U 0x7C
582 : :
583 : : #define PHY_REG_RX_CAPTURE_L 0x8C
584 : : #define PHY_REG_RX_CAPTURE_U 0x90
585 : :
586 : : /* Memory status registers */
587 : : #define PHY_REG_TX_MEMORY_STATUS_L 0x80
588 : : #define PHY_REG_TX_MEMORY_STATUS_U 0x84
589 : :
590 : : /* Interrupt config register */
591 : : #define PHY_REG_TS_INT_CONFIG 0x88
592 : :
593 : : #define PHY_PTP_INT_STATUS 0x7FD140
594 : :
595 : : #define PHY_TS_INT_CONFIG_THRESHOLD_S 0
596 : : #define PHY_TS_INT_CONFIG_THRESHOLD_M MAKEMASK(0x3F, 0)
597 : : #define PHY_TS_INT_CONFIG_ENA_S 6
598 : : #define PHY_TS_INT_CONFIG_ENA_M BIT(6)
599 : :
600 : : /* Macros to derive offsets for TimeStampLow and TimeStampHigh */
601 : : #define PHY_TSTAMP_L(x) (((x) * 8) + 0)
602 : : #define PHY_TSTAMP_U(x) (((x) * 8) + 4)
603 : :
604 : : #define PHY_REG_REVISION 0x85000
605 : : #define PHY_REVISION_ETH56G 0x10200
606 : :
607 : : #endif /* _ICE_PTP_HW_H_ */
|