All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [net-next v2 09/13] ice: convert clk_freq capability into time_ref
Date: Thu,  1 Jul 2021 15:04:52 -0700	[thread overview]
Message-ID: <20210701220456.3882767-10-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20210701220456.3882767-1-jacob.e.keller@intel.com>

Convert the clk_freq value into the associated time_ref frequency value
for E822 devices. This simplifies determining the time reference value
for the clock.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_common.c | 12 +++++++++++
 drivers/net/ethernet/intel/ice/ice_type.h   | 23 ++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 2fb81e359cdf..f63912797548 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -2129,6 +2129,18 @@ ice_parse_1588_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
 	info->clk_freq = (number & ICE_TS_CLK_FREQ_M) >> ICE_TS_CLK_FREQ_S;
 	info->clk_src = ((number & ICE_TS_CLK_SRC_M) != 0);
 
+	if (info->clk_freq < NUM_ICE_TIME_REF_FREQ) {
+		info->time_ref = (enum ice_time_ref_freq)info->clk_freq;
+	} else {
+		/* Unknown clock frequency, so assume a (probably incorrect)
+		 * default to avoid out-of-bounds look ups of frequency
+		 * related information.
+		 */
+		ice_debug(hw, ICE_DBG_INIT, "1588 func caps: unknown clock frequency %u\n",
+			  info->clk_freq);
+		info->time_ref = ICE_TIME_REF_FREQ_25_000;
+	}
+
 	ice_debug(hw, ICE_DBG_INIT, "func caps: ieee_1588 = %u\n",
 		  func_p->common_cap.ieee_1588);
 	ice_debug(hw, ICE_DBG_INIT, "func caps: src_tmr_owned = %u\n",
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index b59076f2dbde..fadc68f74d95 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -294,9 +294,30 @@ struct ice_hw_common_caps {
 #define ICE_TS_TMR_IDX_ASSOC_S		24
 #define ICE_TS_TMR_IDX_ASSOC_M		BIT(24)
 
+/* TIME_REF clock rate specification */
+enum ice_time_ref_freq {
+	ICE_TIME_REF_FREQ_25_000	= 0,
+	ICE_TIME_REF_FREQ_122_880	= 1,
+	ICE_TIME_REF_FREQ_125_000	= 2,
+	ICE_TIME_REF_FREQ_153_600	= 3,
+	ICE_TIME_REF_FREQ_156_250	= 4,
+	ICE_TIME_REF_FREQ_245_760	= 5,
+
+	NUM_ICE_TIME_REF_FREQ
+};
+
+/* Clock source specification */
+enum ice_clk_src {
+	ICE_CLK_SRC_TCX0	= 0, /* Temperature compensated oscillator  */
+	ICE_CLK_SRC_TIME_REF	= 1, /* Use TIME_REF reference clock */
+
+	NUM_ICE_CLK_SRC
+};
+
 struct ice_ts_func_info {
 	/* Function specific info */
-	u32 clk_freq;
+	enum ice_time_ref_freq time_ref;
+	u8 clk_freq;
 	u8 clk_src;
 	u8 tmr_index_assoc;
 	u8 ena;
-- 
2.31.1.331.gb0c09ab8796f


  parent reply	other threads:[~2021-07-01 22:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 22:04 [Intel-wired-lan] [net-next v2 00/13] ice: implement support for PTP on E822 hardware Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 01/13] ice: fix Tx queue iteration for Tx timestamp enablement Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 02/13] ice: remove dead code for allocating pin_config Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 03/13] ice: add lock around Tx timestamp tracker flush Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 04/13] ice: restart periodic outputs around time changes Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 05/13] ice: introduce ice_base_incval function Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 06/13] ice: PTP: move setting of tstamp_config Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 07/13] ice: use 'int err' instead of 'int status' Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 08/13] ice: introduce ice_ptp_init_phc function Jacob Keller
2021-07-01 22:04 ` Jacob Keller [this message]
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 10/13] ice: implement basic E822 PTP support Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 11/13] ice: ensure the hardware Clock Generation Unit is configured Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 12/13] ice: exit bypass mode once hardware finishes timestamp calibration Jacob Keller
2021-07-01 22:04 ` [Intel-wired-lan] [net-next v2 13/13] ice: support crosstimestamping on E822 devices if supported Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210701220456.3882767-10-jacob.e.keller@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.