netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>,
	 Anthony Nguyen <anthony.l.nguyen@intel.com>,
	 netdev <netdev@vger.kernel.org>
Cc: Jacob Keller <jacob.e.keller@intel.com>,
	 Michal Kubiak <michal.kubiak@intel.com>,
	 Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	 Karol Kolacinski <karol.kolacinski@intel.com>,
	 Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	 Milena Olech <milena.olech@intel.com>,
	Paul Menzel <pmenzel@molgen.mpg.de>
Subject: [PATCH v4 03/15] ice: fix E825-C TSPLL register definitions
Date: Thu, 01 May 2025 15:54:14 -0700	[thread overview]
Message-ID: <20250501-kk-tspll-improvements-alignment-v4-3-24c83d0ce7a8@intel.com> (raw)
In-Reply-To: <20250501-kk-tspll-improvements-alignment-v4-0-24c83d0ce7a8@intel.com>

The E825-C hardware has a slightly different register layout for register
19 of the Clock Generation Unit and TSPLL. The fbdiv_intgr value can be 10
bits wide.

Additionally, most of the fields that were in register 24 are made
available in register 23 instead. The programming logic already has a
corrected definition for register 23, but it incorrectly still used the
8-bit definition of fbdiv_intgr. This results in truncating some of the
values of fbdiv_intgr, including the value used for the 156.25MHz signal.

The driver only used register 24 to obtain the enable status, which we
should read from register 23. This results in an incorrect output for the
log messages, but does not change any functionality besides
disabled-by-default dynamic debug messages.

Fix the register definitions, and adjust the code to properly reflect the
enable/disable status in the log messages.

Co-developed-by: Karol Kolacinski <karol.kolacinski@intel.com>
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_common.h | 17 ++++++++++++++++-
 drivers/net/ethernet/intel/ice/ice_tspll.c  | 17 +++++++----------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index af88e274e989a03b3e2f793186a2b662c226bf83..86b34fb02d41b01640ee8b913ff2fc82fde85b68 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -74,7 +74,7 @@ union ice_cgu_r16 {
 };
 
 #define ICE_CGU_R19 0x4c
-union ice_cgu_r19 {
+union ice_cgu_r19_e82x {
 	struct {
 		u32 fbdiv_intgr : 8;
 		u32 fdpll_ulck_thr : 5;
@@ -89,6 +89,21 @@ union ice_cgu_r19 {
 	u32 val;
 };
 
+union ice_cgu_r19_e825 {
+	struct {
+		u32 tspll_fbdiv_intgr : 10;
+		u32 fdpll_ulck_thr : 5;
+		u32 misc15 : 1;
+		u32 tspll_ndivratio : 4;
+		u32 tspll_iref_ndivratio : 3;
+		u32 misc19 : 1;
+		u32 japll_ndivratio : 4;
+		u32 japll_postdiv_pdivratio : 3;
+		u32 misc27 : 1;
+	};
+	u32 val;
+};
+
 #define ICE_CGU_R22 0x58
 union ice_cgu_r22 {
 	struct {
diff --git a/drivers/net/ethernet/intel/ice/ice_tspll.c b/drivers/net/ethernet/intel/ice/ice_tspll.c
index 2fe619214a1a15d8d1d7bd5ac350c6ab58b75e81..74a9fc35fb1a6bc1011fe8142566a14673e867d9 100644
--- a/drivers/net/ethernet/intel/ice/ice_tspll.c
+++ b/drivers/net/ethernet/intel/ice/ice_tspll.c
@@ -230,7 +230,7 @@ static int ice_tspll_cfg_e82x(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 			      enum ice_clk_src clk_src)
 {
 	union tspll_ro_bwm_lf bwm_lf;
-	union ice_cgu_r19 dw19;
+	union ice_cgu_r19_e82x dw19;
 	union ice_cgu_r22 dw22;
 	union ice_cgu_r24 dw24;
 	union ice_cgu_r9 dw9;
@@ -398,9 +398,9 @@ static int ice_tspll_cfg_e825c(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 			       enum ice_clk_src clk_src)
 {
 	union tspll_ro_lock_e825c ro_lock;
+	union ice_cgu_r19_e825 dw19;
 	union ice_cgu_r16 dw16;
 	union ice_cgu_r23 dw23;
-	union ice_cgu_r19 dw19;
 	union ice_cgu_r22 dw22;
 	union ice_cgu_r24 dw24;
 	union ice_cgu_r9 dw9;
@@ -428,10 +428,6 @@ static int ice_tspll_cfg_e825c(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 	if (err)
 		return err;
 
-	err = ice_read_cgu_reg(hw, ICE_CGU_R24, &dw24.val);
-	if (err)
-		return err;
-
 	err = ice_read_cgu_reg(hw, ICE_CGU_R16, &dw16.val);
 	if (err)
 		return err;
@@ -446,7 +442,7 @@ static int ice_tspll_cfg_e825c(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 
 	/* Log the current clock configuration */
 	ice_debug(hw, ICE_DBG_PTP, "Current TSPLL configuration -- %s, clk_src %s, clk_freq %s, PLL %s\n",
-		  str_enabled_disabled(dw24.ts_pll_enable),
+		  str_enabled_disabled(dw23.ts_pll_enable),
 		  ice_tspll_clk_src_str(dw23.time_ref_sel),
 		  ice_tspll_clk_freq_str(dw9.time_ref_freq_sel),
 		  ro_lock.plllock_true_lock_cri ? "locked" : "unlocked");
@@ -486,8 +482,8 @@ static int ice_tspll_cfg_e825c(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 	if (err)
 		return err;
 
-	dw19.fbdiv_intgr = e825c_tspll_params[clk_freq].fbdiv_intgr;
-	dw19.ndivratio = e825c_tspll_params[clk_freq].ndivratio;
+	dw19.tspll_fbdiv_intgr = e825c_tspll_params[clk_freq].fbdiv_intgr;
+	dw19.tspll_ndivratio = e825c_tspll_params[clk_freq].ndivratio;
 
 	err = ice_write_cgu_reg(hw, ICE_CGU_R19, dw19.val);
 	if (err)
@@ -518,6 +514,7 @@ static int ice_tspll_cfg_e825c(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 	if (err)
 		return err;
 
+	dw24.val = 0;
 	dw24.fbdiv_frac = e825c_tspll_params[clk_freq].fbdiv_frac;
 
 	err = ice_write_cgu_reg(hw, ICE_CGU_R24, dw24.val);
@@ -545,7 +542,7 @@ static int ice_tspll_cfg_e825c(struct ice_hw *hw, enum ice_tspll_freq clk_freq,
 
 	/* Log the current clock configuration */
 	ice_debug(hw, ICE_DBG_PTP, "New TSPLL configuration -- %s, clk_src %s, clk_freq %s, PLL %s\n",
-		  str_enabled_disabled(dw24.ts_pll_enable),
+		  str_enabled_disabled(dw23.ts_pll_enable),
 		  ice_tspll_clk_src_str(dw23.time_ref_sel),
 		  ice_tspll_clk_freq_str(dw9.time_ref_freq_sel),
 		  ro_lock.plllock_true_lock_cri ? "locked" : "unlocked");

-- 
2.48.1.397.gec9d649cc640


  parent reply	other threads:[~2025-05-01 22:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 22:54 [PATCH v4 00/15] ice: Separate TSPLL from PTP and clean up Jacob Keller
2025-05-01 22:54 ` [PATCH v4 01/15] ice: move TSPLL functions to a separate file Jacob Keller
2025-05-22 14:13   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 02/15] ice: rename TSPLL and CGU functions and definitions Jacob Keller
2025-05-22 14:15   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` Jacob Keller [this message]
2025-05-22 14:18   ` [Intel-wired-lan] [PATCH v4 03/15] ice: fix E825-C TSPLL register definitions Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 04/15] ice: remove ice_tspll_params_e825 definitions Jacob Keller
2025-05-22 14:19   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 05/15] ice: use designated initializers for TSPLL consts Jacob Keller
2025-05-22 14:21   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 06/15] ice: add TSPLL log config helper Jacob Keller
2025-05-22 14:23   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 07/15] ice: add ICE_READ/WRITE_CGU_REG_OR_DIE helpers Jacob Keller
2025-05-22 14:24   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 08/15] ice: clear time_sync_en field for E825-C during reprogramming Jacob Keller
2025-05-22 14:27   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 09/15] ice: read TSPLL registers again before reporting status Jacob Keller
2025-05-22 14:28   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 10/15] ice: use bitfields instead of unions for CGU regs Jacob Keller
2025-05-22 14:30   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 11/15] ice: add multiple TSPLL helpers Jacob Keller
2025-05-22 14:32   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 12/15] ice: wait before enabling TSPLL Jacob Keller
2025-05-22 14:34   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 13/15] ice: fall back to TCXO on TSPLL lock fail Jacob Keller
2025-05-22 14:36   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 14/15] ice: move TSPLL init calls to ice_ptp.c Jacob Keller
2025-05-22 14:38   ` [Intel-wired-lan] " Rinitha, SX
2025-05-01 22:54 ` [PATCH v4 15/15] ice: default to TIME_REF instead of TXCO on E825-C Jacob Keller
2025-05-22 14:40   ` [Intel-wired-lan] " Rinitha, SX

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=20250501-kk-tspll-improvements-alignment-v4-3-24c83d0ce7a8@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=karol.kolacinski@intel.com \
    --cc=michal.kubiak@intel.com \
    --cc=milena.olech@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pmenzel@molgen.mpg.de \
    --cc=przemyslaw.kitszel@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).