@@ -436,7 +436,7 @@ static void ice_clear_ptp_clock_index(struct ice_pf *pf)
436436 int err ;
437437
438438 /* Do not clear the index if we don't own the timer */
439- if (!hw -> func_caps . ts_func_info . src_tmr_owned )
439+ if (!ice_pf_src_tmr_owned ( pf ) )
440440 return ;
441441
442442 tmr_idx = hw -> func_caps .ts_func_info .tmr_index_assoc ;
@@ -1366,6 +1366,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)
13661366void ice_ptp_link_change (struct ice_pf * pf , u8 port , bool linkup )
13671367{
13681368 struct ice_ptp_port * ptp_port ;
1369+ struct ice_hw * hw = & pf -> hw ;
13691370
13701371 if (!test_bit (ICE_FLAG_PTP , pf -> flags ))
13711372 return ;
@@ -1380,11 +1381,16 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
13801381 /* Update cached link status for this port immediately */
13811382 ptp_port -> link_up = linkup ;
13821383
1383- /* E810 devices do not need to reconfigure the PHY */
1384- if (ice_is_e810 (& pf -> hw ))
1384+ switch (hw -> phy_model ) {
1385+ case ICE_PHY_E810 :
1386+ /* Do not reconfigure E810 PHY */
13851387 return ;
1386-
1387- ice_ptp_port_phy_restart (ptp_port );
1388+ case ICE_PHY_E822 :
1389+ ice_ptp_port_phy_restart (ptp_port );
1390+ return ;
1391+ default :
1392+ dev_warn (ice_pf_to_dev (pf ), "%s: Unknown PHY type\n" , __func__ );
1393+ }
13881394}
13891395
13901396/**
@@ -1976,21 +1982,32 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
19761982 u32 hh_lock , hh_art_ctl ;
19771983 int i ;
19781984
1979- /* Get the HW lock */
1980- hh_lock = rd32 (hw , PFHH_SEM + (PFTSYN_SEM_BYTES * hw -> pf_id ));
1985+ #define MAX_HH_HW_LOCK_TRIES 5
1986+ #define MAX_HH_CTL_LOCK_TRIES 100
1987+
1988+ for (i = 0 ; i < MAX_HH_HW_LOCK_TRIES ; i ++ ) {
1989+ /* Get the HW lock */
1990+ hh_lock = rd32 (hw , PFHH_SEM + (PFTSYN_SEM_BYTES * hw -> pf_id ));
1991+ if (hh_lock & PFHH_SEM_BUSY_M ) {
1992+ usleep_range (10000 , 15000 );
1993+ continue ;
1994+ }
1995+ break ;
1996+ }
19811997 if (hh_lock & PFHH_SEM_BUSY_M ) {
19821998 dev_err (ice_pf_to_dev (pf ), "PTP failed to get hh lock\n" );
1983- return - EFAULT ;
1999+ return - EBUSY ;
19842000 }
19852001
2002+ /* Program cmd to master timer */
2003+ ice_ptp_src_cmd (hw , ICE_PTP_READ_TIME );
2004+
19862005 /* Start the ART and device clock sync sequence */
19872006 hh_art_ctl = rd32 (hw , GLHH_ART_CTL );
19882007 hh_art_ctl = hh_art_ctl | GLHH_ART_CTL_ACTIVE_M ;
19892008 wr32 (hw , GLHH_ART_CTL , hh_art_ctl );
19902009
1991- #define MAX_HH_LOCK_TRIES 100
1992-
1993- for (i = 0 ; i < MAX_HH_LOCK_TRIES ; i ++ ) {
2010+ for (i = 0 ; i < MAX_HH_CTL_LOCK_TRIES ; i ++ ) {
19942011 /* Wait for sync to complete */
19952012 hh_art_ctl = rd32 (hw , GLHH_ART_CTL );
19962013 if (hh_art_ctl & GLHH_ART_CTL_ACTIVE_M ) {
@@ -2014,34 +2031,38 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
20142031 break ;
20152032 }
20162033 }
2034+
2035+ /* Clear the master timer */
2036+ ice_ptp_src_cmd (hw , ICE_PTP_NOP );
2037+
20172038 /* Release HW lock */
20182039 hh_lock = rd32 (hw , PFHH_SEM + (PFTSYN_SEM_BYTES * hw -> pf_id ));
20192040 hh_lock = hh_lock & ~PFHH_SEM_BUSY_M ;
20202041 wr32 (hw , PFHH_SEM + (PFTSYN_SEM_BYTES * hw -> pf_id ), hh_lock );
20212042
2022- if (i == MAX_HH_LOCK_TRIES )
2043+ if (i == MAX_HH_CTL_LOCK_TRIES )
20232044 return - ETIMEDOUT ;
20242045
20252046 return 0 ;
20262047}
20272048
20282049/**
2029- * ice_ptp_getcrosststamp_e822 - Capture a device cross timestamp
2050+ * ice_ptp_getcrosststamp_e82x - Capture a device cross timestamp
20302051 * @info: the driver's PTP info structure
20312052 * @cts: The memory to fill the cross timestamp info
20322053 *
20332054 * Capture a cross timestamp between the ART and the device PTP hardware
20342055 * clock. Fill the cross timestamp information and report it back to the
20352056 * caller.
20362057 *
2037- * This is only valid for E822 devices which have support for generating the
2038- * cross timestamp via PCIe PTM.
2058+ * This is only valid for E822 and E823 devices which have support for
2059+ * generating the cross timestamp via PCIe PTM.
20392060 *
20402061 * In order to correctly correlate the ART timestamp back to the TSC time, the
20412062 * CPU must have X86_FEATURE_TSC_KNOWN_FREQ.
20422063 */
20432064static int
2044- ice_ptp_getcrosststamp_e822 (struct ptp_clock_info * info ,
2065+ ice_ptp_getcrosststamp_e82x (struct ptp_clock_info * info ,
20452066 struct system_device_crosststamp * cts )
20462067{
20472068 struct ice_pf * pf = ptp_info_to_pf (info );
@@ -2246,18 +2267,20 @@ ice_ptp_setup_sma_pins_e810t(struct ice_pf *pf, struct ptp_clock_info *info)
22462267static void
22472268ice_ptp_setup_pins_e810 (struct ice_pf * pf , struct ptp_clock_info * info )
22482269{
2249- info -> n_per_out = N_PER_OUT_E810 ;
2250-
2251- if (ice_is_feature_supported (pf , ICE_F_PTP_EXTTS ))
2252- info -> n_ext_ts = N_EXT_TS_E810 ;
2253-
22542270 if (ice_is_feature_supported (pf , ICE_F_SMA_CTRL )) {
22552271 info -> n_ext_ts = N_EXT_TS_E810 ;
2272+ info -> n_per_out = N_PER_OUT_E810T ;
22562273 info -> n_pins = NUM_PTP_PINS_E810T ;
22572274 info -> verify = ice_verify_pin_e810t ;
22582275
22592276 /* Complete setup of the SMA pins */
22602277 ice_ptp_setup_sma_pins_e810t (pf , info );
2278+ } else if (ice_is_e810t (& pf -> hw )) {
2279+ info -> n_ext_ts = N_EXT_TS_NO_SMA_E810T ;
2280+ info -> n_per_out = N_PER_OUT_NO_SMA_E810T ;
2281+ } else {
2282+ info -> n_per_out = N_PER_OUT_E810 ;
2283+ info -> n_ext_ts = N_EXT_TS_E810 ;
22612284 }
22622285}
22632286
@@ -2275,22 +2298,22 @@ ice_ptp_setup_pins_e823(struct ice_pf *pf, struct ptp_clock_info *info)
22752298}
22762299
22772300/**
2278- * ice_ptp_set_funcs_e822 - Set specialized functions for E822 support
2301+ * ice_ptp_set_funcs_e82x - Set specialized functions for E82x support
22792302 * @pf: Board private structure
22802303 * @info: PTP info to fill
22812304 *
2282- * Assign functions to the PTP capabiltiies structure for E822 devices.
2305+ * Assign functions to the PTP capabiltiies structure for E82x devices.
22832306 * Functions which operate across all device families should be set directly
2284- * in ice_ptp_set_caps. Only add functions here which are distinct for E822
2307+ * in ice_ptp_set_caps. Only add functions here which are distinct for E82x
22852308 * devices.
22862309 */
22872310static void
2288- ice_ptp_set_funcs_e822 (struct ice_pf * pf , struct ptp_clock_info * info )
2311+ ice_ptp_set_funcs_e82x (struct ice_pf * pf , struct ptp_clock_info * info )
22892312{
22902313#ifdef CONFIG_ICE_HWTS
22912314 if (boot_cpu_has (X86_FEATURE_ART ) &&
22922315 boot_cpu_has (X86_FEATURE_TSC_KNOWN_FREQ ))
2293- info -> getcrosststamp = ice_ptp_getcrosststamp_e822 ;
2316+ info -> getcrosststamp = ice_ptp_getcrosststamp_e82x ;
22942317#endif /* CONFIG_ICE_HWTS */
22952318}
22962319
@@ -2324,6 +2347,8 @@ ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info)
23242347static void
23252348ice_ptp_set_funcs_e823 (struct ice_pf * pf , struct ptp_clock_info * info )
23262349{
2350+ ice_ptp_set_funcs_e82x (pf , info );
2351+
23272352 info -> enable = ice_ptp_gpio_enable_e823 ;
23282353 ice_ptp_setup_pins_e823 (pf , info );
23292354}
@@ -2351,7 +2376,7 @@ static void ice_ptp_set_caps(struct ice_pf *pf)
23512376 else if (ice_is_e823 (& pf -> hw ))
23522377 ice_ptp_set_funcs_e823 (pf , info );
23532378 else
2354- ice_ptp_set_funcs_e822 (pf , info );
2379+ ice_ptp_set_funcs_e82x (pf , info );
23552380}
23562381
23572382/**
@@ -2474,7 +2499,7 @@ void ice_ptp_reset(struct ice_pf *pf)
24742499 if (test_bit (ICE_PFR_REQ , pf -> state ))
24752500 goto pfr ;
24762501
2477- if (!hw -> func_caps . ts_func_info . src_tmr_owned )
2502+ if (!ice_pf_src_tmr_owned ( pf ) )
24782503 goto reset_ts ;
24792504
24802505 err = ice_ptp_init_phc (hw );
@@ -2685,14 +2710,22 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)
26852710 */
26862711static int ice_ptp_init_port (struct ice_pf * pf , struct ice_ptp_port * ptp_port )
26872712{
2713+ struct ice_hw * hw = & pf -> hw ;
2714+
26882715 mutex_init (& ptp_port -> ps_lock );
26892716
2690- if (ice_is_e810 (& pf -> hw ))
2717+ switch (hw -> phy_model ) {
2718+ case ICE_PHY_E810 :
26912719 return ice_ptp_init_tx_e810 (pf , & ptp_port -> tx );
2720+ case ICE_PHY_E822 :
2721+ kthread_init_delayed_work (& ptp_port -> ov_work ,
2722+ ice_ptp_wait_for_offsets );
26922723
2693- kthread_init_delayed_work (& ptp_port -> ov_work ,
2694- ice_ptp_wait_for_offsets );
2695- return ice_ptp_init_tx_e822 (pf , & ptp_port -> tx , ptp_port -> port_num );
2724+ return ice_ptp_init_tx_e822 (pf , & ptp_port -> tx ,
2725+ ptp_port -> port_num );
2726+ default :
2727+ return - ENODEV ;
2728+ }
26962729}
26972730
26982731/**
@@ -2713,10 +2746,12 @@ void ice_ptp_init(struct ice_pf *pf)
27132746 struct ice_hw * hw = & pf -> hw ;
27142747 int err ;
27152748
2749+ ice_ptp_init_phy_model (hw );
2750+
27162751 /* If this function owns the clock hardware, it must allocate and
27172752 * configure the PTP clock device to represent it.
27182753 */
2719- if (hw -> func_caps . ts_func_info . src_tmr_owned ) {
2754+ if (ice_pf_src_tmr_owned ( pf ) ) {
27202755 err = ice_ptp_init_owner (pf );
27212756 if (err )
27222757 goto err ;
0 commit comments