From: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
To: Mika Kahola <mika.kahola@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 04/13] drm/i915/mtl: C20 port clock calculation
Date: Tue, 25 Apr 2023 12:08:33 -0700 [thread overview]
Message-ID: <ZEglMWTBPmtoqar6@invictus> (raw)
In-Reply-To: <20230420124050.3617608-5-mika.kahola@intel.com>
On Thu, Apr 20, 2023 at 03:40:41PM +0300, Mika Kahola wrote:
> Calculate port clock with C20 phy.
>
> BSpec: 64568
> Signed-off-by: Mika Kahola <mika.kahola@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_cx0_phy.c | 45 +++++++++++++++++++
> drivers/gpu/drm/i915/display/intel_cx0_phy.h | 2 +
> .../gpu/drm/i915/display/intel_cx0_phy_regs.h | 4 ++
> drivers/gpu/drm/i915/display/intel_ddi.c | 4 +-
> drivers/gpu/drm/i915/display/intel_dpll.c | 2 +
> 5 files changed, 55 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy.c b/drivers/gpu/drm/i915/display/intel_cx0_phy.c
> index 144474540ef4..f7720acaf58c 100644
> --- a/drivers/gpu/drm/i915/display/intel_cx0_phy.c
> +++ b/drivers/gpu/drm/i915/display/intel_cx0_phy.c
> @@ -2274,6 +2274,51 @@ int intel_c10pll_calc_port_clock(struct intel_encoder *encoder,
> return tmpclk;
> }
>
> +int intel_c20pll_calc_port_clock(struct intel_encoder *encoder,
> + const struct intel_c20pll_state *pll_state)
> +{
> + unsigned int frac, frac_en, frac_quot, frac_rem, frac_den;
> + unsigned int multiplier, refclk = 38400;
> + unsigned int tx_clk_div;
> + unsigned int ref_clk_mpllb_div;
> + unsigned int fb_clk_div4_en;
> + unsigned int ref, vco;
> + unsigned int tx_rate_mult;
> + unsigned int tx_rate = REG_FIELD_GET(C20_PHY_TX_RATE, pll_state->tx[0]);
> +
> + if (pll_state->tx[0] & C20_PHY_USE_MPLLB) {
This method of judging mplla vs mpllb seems more appropriate than the one used
during intel_c20pll_readout_hw_state in patch 02/13.
Update 2/13 mplla vs mpllb selection based on this logic.
Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> + tx_rate_mult = 1;
> + frac_en = REG_FIELD_GET(C20_MPLLB_FRACEN, pll_state->mpllb[6]);
> + frac_quot = pll_state->mpllb[8];
> + frac_rem = pll_state->mpllb[9];
> + frac_den = pll_state->mpllb[7];
> + multiplier = REG_FIELD_GET(C20_MULTIPLIER_MASK, pll_state->mpllb[0]);
> + tx_clk_div = REG_FIELD_GET(C20_MPLLB_TX_CLK_DIV_MASK, pll_state->mpllb[0]);
> + ref_clk_mpllb_div = REG_FIELD_GET(C20_REF_CLK_MPLLB_DIV_MASK, pll_state->mpllb[6]);
> + fb_clk_div4_en = 0;
> + } else {
> + tx_rate_mult = 2;
> + frac_en = REG_FIELD_GET(C20_MPLLA_FRACEN, pll_state->mplla[6]);
> + frac_quot = pll_state->mplla[8];
> + frac_rem = pll_state->mplla[9];
> + frac_den = pll_state->mplla[7];
> + multiplier = REG_FIELD_GET(C20_MULTIPLIER_MASK, pll_state->mplla[0]);
> + tx_clk_div = REG_FIELD_GET(C20_MPLLA_TX_CLK_DIV_MASK, pll_state->mplla[1]);
> + ref_clk_mpllb_div = REG_FIELD_GET(C20_REF_CLK_MPLLB_DIV_MASK, pll_state->mplla[6]);
> + fb_clk_div4_en = REG_FIELD_GET(C20_FB_CLK_DIV4_EN, pll_state->mplla[0]);
> + }
> +
> + if (frac_en)
> + frac = frac_quot + DIV_ROUND_CLOSEST(frac_rem, frac_den);
> + else
> + frac = 0;
> +
> + ref = DIV_ROUND_CLOSEST(refclk * (1 << (1 + fb_clk_div4_en)), 1 << ref_clk_mpllb_div);
> + vco = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(ref, (multiplier << (17 - 2)) + frac) >> 17, 10);
> +
> + return vco << tx_rate_mult >> tx_clk_div >> tx_rate;
> +}
> +
> static void intel_program_port_clock_ctl(struct intel_encoder *encoder,
> const struct intel_crtc_state *crtc_state,
> bool lane_reversal)
> diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy.h b/drivers/gpu/drm/i915/display/intel_cx0_phy.h
> index c643aae27bac..83bd3500091b 100644
> --- a/drivers/gpu/drm/i915/display/intel_cx0_phy.h
> +++ b/drivers/gpu/drm/i915/display/intel_cx0_phy.h
> @@ -34,6 +34,8 @@ void intel_c20pll_readout_hw_state(struct intel_encoder *encoder,
> struct intel_c20pll_state *pll_state);
> void intel_c20pll_dump_hw_state(struct drm_i915_private *i915,
> const struct intel_c20pll_state *hw_state);
> +int intel_c20pll_calc_port_clock(struct intel_encoder *encoder,
> + const struct intel_c20pll_state *pll_state);
> void intel_cx0_phy_set_signal_levels(struct intel_encoder *encoder,
> const struct intel_crtc_state *crtc_state);
> int intel_cx0_phy_check_hdmi_link_rate(struct intel_hdmi *hdmi, int clock);
> diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h b/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h
> index 6fcb1680fb54..a5e5bee24533 100644
> --- a/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h
> +++ b/drivers/gpu/drm/i915/display/intel_cx0_phy_regs.h
> @@ -195,17 +195,21 @@
> #define PHY_C20_VDR_CUSTOM_WIDTH 0xD02
> #define PHY_C20_A_TX_CNTX_CFG(idx) (0xCF2E - (idx))
> #define PHY_C20_B_TX_CNTX_CFG(idx) (0xCF2A - (idx))
> +#define C20_PHY_TX_RATE REG_GENMASK(2, 0)
> #define PHY_C20_A_CMN_CNTX_CFG(idx) (0xCDAA - (idx))
> #define PHY_C20_B_CMN_CNTX_CFG(idx) (0xCDA5 - (idx))
> #define PHY_C20_A_MPLLA_CNTX_CFG(idx) (0xCCF0 - (idx))
> #define PHY_C20_B_MPLLA_CNTX_CFG(idx) (0xCCE5 - (idx))
> #define C20_MPLLA_FRACEN REG_BIT(14)
> +#define C20_FB_CLK_DIV4_EN REG_BIT(13)
> #define C20_MPLLA_TX_CLK_DIV_MASK REG_GENMASK(10, 8)
> #define PHY_C20_A_MPLLB_CNTX_CFG(idx) (0xCB5A - (idx))
> #define PHY_C20_B_MPLLB_CNTX_CFG(idx) (0xCB4E - (idx))
> #define C20_MPLLB_TX_CLK_DIV_MASK REG_GENMASK(15, 13)
> #define C20_MPLLB_FRACEN REG_BIT(13)
> +#define C20_REF_CLK_MPLLB_DIV_MASK REG_GENMASK(12, 10)
> #define C20_MULTIPLIER_MASK REG_GENMASK(11, 0)
> +#define C20_PHY_USE_MPLLB REG_BIT(7)
>
> #define RAWLANEAONX_DIG_TX_MPLLB_CAL_DONE_BANK(idx) (0x303D + (idx))
>
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index d414dd8c26bf..8e6d6afca400 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -3856,13 +3856,13 @@ static void mtl_ddi_get_config(struct intel_encoder *encoder,
> if (intel_is_c10phy(i915, phy)) {
> intel_c10pll_readout_hw_state(encoder, &crtc_state->cx0pll_state.c10);
> intel_c10pll_dump_hw_state(i915, &crtc_state->cx0pll_state.c10);
> + crtc_state->port_clock = intel_c10pll_calc_port_clock(encoder, &crtc_state->cx0pll_state.c10);
> } else {
> intel_c20pll_readout_hw_state(encoder, &crtc_state->cx0pll_state.c20);
> intel_c20pll_dump_hw_state(i915, &crtc_state->cx0pll_state.c20);
> + crtc_state->port_clock = intel_c20pll_calc_port_clock(encoder, &crtc_state->cx0pll_state.c20);
> }
>
> - crtc_state->port_clock = intel_c10pll_calc_port_clock(encoder, &crtc_state->cx0pll_state.c10);
> -
> intel_ddi_get_config(encoder, crtc_state);
> }
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dpll.c b/drivers/gpu/drm/i915/display/intel_dpll.c
> index a9fbef0fa817..ca0f362a40e3 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpll.c
> +++ b/drivers/gpu/drm/i915/display/intel_dpll.c
> @@ -1014,6 +1014,8 @@ static int mtl_crtc_compute_clock(struct intel_atomic_state *state,
> /* TODO: Do the readback via intel_compute_shared_dplls() */
> if (intel_is_c10phy(i915, phy))
> crtc_state->port_clock = intel_c10pll_calc_port_clock(encoder, &crtc_state->cx0pll_state.c10);
> + else
> + crtc_state->port_clock = intel_c20pll_calc_port_clock(encoder, &crtc_state->cx0pll_state.c20);
>
> crtc_state->hw.adjusted_mode.crtc_clock = intel_crtc_dotclock(crtc_state);
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2023-04-25 19:13 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 12:40 [Intel-gfx] [PATCH 00/13] drm/i915/mtl: Add support for C20 phy Mika Kahola
2023-04-20 12:40 ` [Intel-gfx] [PATCH 01/13] drm/i915/mtl: C20 PLL programming Mika Kahola
2023-04-21 23:24 ` Radhakrishna Sripada
2023-04-24 8:39 ` Kahola, Mika
2023-04-27 3:22 ` Murthy, Arun R
2023-04-28 9:07 ` Andi Shyti
2023-04-28 9:11 ` Kahola, Mika
2023-04-20 12:40 ` [Intel-gfx] [PATCH 02/13] drm/i915/mtl: C20 HW readout Mika Kahola
2023-04-24 20:56 ` Radhakrishna Sripada
2023-04-26 11:43 ` Kahola, Mika
2023-04-27 16:47 ` Sripada, Radhakrishna
2023-04-27 3:31 ` Murthy, Arun R
2023-04-27 10:25 ` Kahola, Mika
2023-04-28 9:14 ` Andi Shyti
2023-04-20 12:40 ` [Intel-gfx] [PATCH 03/13] drm/i915/mtl: Dump C20 pll hw state Mika Kahola
2023-04-24 21:18 ` Radhakrishna Sripada
2023-04-27 3:37 ` Murthy, Arun R
2023-04-28 9:15 ` Andi Shyti
2023-04-20 12:40 ` [Intel-gfx] [PATCH 04/13] drm/i915/mtl: C20 port clock calculation Mika Kahola
2023-04-25 19:08 ` Radhakrishna Sripada [this message]
2023-04-27 3:50 ` Murthy, Arun R
2023-04-20 12:40 ` [Intel-gfx] [PATCH 05/13] drm/i915/mtl: Add voltage swing sequence for C20 Mika Kahola
2023-04-27 4:29 ` Murthy, Arun R
2023-04-20 12:40 ` [Intel-gfx] [PATCH 06/13] drm/i915/mtl: For DP2.0 10G and 20G rates use MPLLA Mika Kahola
2023-04-24 18:09 ` Radhakrishna Sripada
2023-04-27 4:31 ` Murthy, Arun R
2023-04-27 9:14 ` Manna, Animesh
2023-05-03 8:25 ` Jani Nikula
2023-04-20 12:40 ` [Intel-gfx] [PATCH 07/13] drm/i915/mtl: Enabling/disabling sequence Thunderbolt pll Mika Kahola
2023-04-25 19:32 ` Radhakrishna Sripada
2023-04-28 9:20 ` Andi Shyti
2023-04-20 12:40 ` [Intel-gfx] [PATCH 08/13] drm/i915/mtl: Readout Thunderbolt HW state Mika Kahola
2023-04-25 20:11 ` Radhakrishna Sripada
2023-04-20 12:40 ` [Intel-gfx] [PATCH 09/13] drm/i915/mtl: Define mask for DDI AUX interrupts Mika Kahola
2023-04-25 20:29 ` Radhakrishna Sripada
2023-04-20 12:40 ` [Intel-gfx] [PATCH 10/13] drm/i915/mtl: Power up TCSS Mika Kahola
2023-04-27 16:09 ` Matt Atwood
2023-04-20 12:40 ` [Intel-gfx] [PATCH 11/13] drm/i915/mtl: TypeC HPD live status query Mika Kahola
2023-04-27 16:13 ` Matt Atwood
2023-04-20 12:40 ` [Intel-gfx] [PATCH 12/13] drm/i915/mtl: Pin assignment for TypeC Mika Kahola
2023-04-27 16:17 ` Matt Atwood
2023-04-20 12:40 ` [Intel-gfx] [PATCH 13/13] drm/i915/mtl: Enable TC ports Mika Kahola
2023-04-27 15:49 ` Clint Taylor
2023-04-20 15:36 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/mtl: Add support for C20 phy Patchwork
2023-04-20 15:36 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-04-20 15:53 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-04-20 21:38 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
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=ZEglMWTBPmtoqar6@invictus \
--to=radhakrishna.sripada@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mika.kahola@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