ice: Introduce ice_get_base_incval() helper
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 28 May 2024 23:03:56 +0000 (16:03 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 1 Jun 2024 22:51:51 +0000 (15:51 -0700)
Add a new helper for getting base clock increment value for specific HW.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20240528-next-2024-05-28-ptp-refactors-v1-6-c082739bb6f6@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_ptp.c
drivers/net/ethernet/intel/ice/ice_ptp_hw.h

index 4ed2213247f72995e1239fba163d74803da12ca6..923011c9609a149ae455a55362dcc6a04e544f76 100644 (file)
@@ -7,8 +7,6 @@
 
 #define E810_OUT_PROP_DELAY_NS 1
 
-#define UNKNOWN_INCVAL_E82X 0x100000000ULL
-
 static const struct ptp_pin_desc ice_pin_desc_e810t[] = {
        /* name    idx   func         chan */
        { "GNSS",  GNSS, PTP_PF_EXTTS, 0, { 0, } },
@@ -1210,12 +1208,7 @@ static u64 ice_base_incval(struct ice_pf *pf)
        struct ice_hw *hw = &pf->hw;
        u64 incval;
 
-       if (ice_is_e810(hw))
-               incval = ICE_PTP_NOMINAL_INCVAL_E810;
-       else if (ice_e82x_time_ref(hw) < NUM_ICE_TIME_REF_FREQ)
-               incval = ice_e82x_nominal_incval(ice_e82x_time_ref(hw));
-       else
-               incval = UNKNOWN_INCVAL_E82X;
+       incval = ice_get_base_incval(hw);
 
        dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n",
                incval);
index 2d8ba9c2251d300947b8cd7dd4bda9d451b077a0..3fe12a1694fc0f989ff8e808d71f55d23968cb28 100644 (file)
@@ -285,6 +285,24 @@ int ice_get_cgu_rclk_pin_info(struct ice_hw *hw, u8 *base_idx, u8 *pin_num);
 int ice_cgu_get_output_pin_state_caps(struct ice_hw *hw, u8 pin_id,
                                      unsigned long *caps);
 
+/**
+ * ice_get_base_incval - Get base clock increment value
+ * @hw: pointer to the HW struct
+ *
+ * Return: base clock increment value for supported PHYs, 0 otherwise
+ */
+static inline u64 ice_get_base_incval(struct ice_hw *hw)
+{
+       switch (hw->ptp.phy_model) {
+       case ICE_PHY_E810:
+               return ICE_PTP_NOMINAL_INCVAL_E810;
+       case ICE_PHY_E82X:
+               return ice_e82x_nominal_incval(ice_e82x_time_ref(hw));
+       default:
+               return 0;
+       }
+}
+
 #define PFTSYN_SEM_BYTES       4
 
 #define ICE_PTP_CLOCK_INDEX_0  0x00