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 07/13] drm/i915/mtl: Enabling/disabling sequence Thunderbolt pll
Date: Tue, 25 Apr 2023 12:32:33 -0700 [thread overview]
Message-ID: <ZEgq0ZP7kxfoeX1r@invictus> (raw)
In-Reply-To: <20230420124050.3617608-8-mika.kahola@intel.com>
On Thu, Apr 20, 2023 at 03:40:44PM +0300, Mika Kahola wrote:
> Enabling and disabling sequence for Thunderbolt PLL.
>
Bspec: 64568
> Signed-off-by: Mika Kahola <mika.kahola@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_cx0_phy.c | 135 ++++++++++++++++++-
> drivers/gpu/drm/i915/display/intel_cx0_phy.h | 7 +-
> drivers/gpu/drm/i915/display/intel_ddi.c | 4 +-
> 3 files changed, 138 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy.c b/drivers/gpu/drm/i915/display/intel_cx0_phy.c
> index 4231ba98f075..9722d3f1b926 100644
> --- a/drivers/gpu/drm/i915/display/intel_cx0_phy.c
> +++ b/drivers/gpu/drm/i915/display/intel_cx0_phy.c
> @@ -2600,8 +2600,8 @@ static u32 intel_cx0_get_pclk_pll_ack(u8 lane_mask)
> return val;
> }
>
> -void intel_cx0pll_enable(struct intel_encoder *encoder,
> - const struct intel_crtc_state *crtc_state)
> +static void intel_cx0pll_enable(struct intel_encoder *encoder,
> + const struct intel_crtc_state *crtc_state)
> {
> struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> enum phy phy = intel_port_to_phy(i915, encoder->port);
> @@ -2676,7 +2676,86 @@ void intel_cx0pll_enable(struct intel_encoder *encoder,
> intel_cx0_phy_transaction_end(encoder, wakeref);
> }
>
> -void intel_cx0pll_disable(struct intel_encoder *encoder)
> +static int intel_mtl_tbt_clock_select(struct drm_i915_private *i915, int clock)
> +{
> + switch (clock) {
> + case 162000:
> + return XELPDP_DDI_CLOCK_SELECT_TBT_162;
> + case 270000:
> + return XELPDP_DDI_CLOCK_SELECT_TBT_270;
> + case 540000:
> + return XELPDP_DDI_CLOCK_SELECT_TBT_540;
> + case 810000:
> + return XELPDP_DDI_CLOCK_SELECT_TBT_810;
> + default:
> + MISSING_CASE(clock);
> + return XELPDP_DDI_CLOCK_SELECT_TBT_162;
> + }
> +}
> +
> +static void intel_mtl_tbt_pll_enable(struct intel_encoder *encoder,
> + const struct intel_crtc_state *crtc_state)
> +{
> + struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> + enum phy phy = intel_port_to_phy(i915, encoder->port);
> + u32 val = 0;
> +
> + /*
> + * 1. Program PORT_CLOCK_CTL REGISTER to configure
> + * clock muxes, gating and SSC
> + */
> + val |= XELPDP_DDI_CLOCK_SELECT(intel_mtl_tbt_clock_select(i915, crtc_state->port_clock));
> + val |= XELPDP_FORWARD_CLOCK_UNGATE;
> + intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port),
> + XELPDP_DDI_CLOCK_SELECT_MASK | XELPDP_FORWARD_CLOCK_UNGATE, val);
> +
> + /* 2. Read back PORT_CLOCK_CTL REGISTER */
> + val = intel_de_read(i915, XELPDP_PORT_CLOCK_CTL(encoder->port));
> +
> + /*
> + * 3. Follow the Display Voltage Frequency Switching - Sequence
> + * Before Frequency Change. We handle this step in bxt_set_cdclk().
> + */
> +
> + /*
> + * 4. Set PORT_CLOCK_CTL register TBT CLOCK Request to "1" to enable PLL.
> + */
> + val |= XELPDP_TBT_CLOCK_REQUEST;
> + intel_de_write(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), val);
> +
> + /* 5. Poll on PORT_CLOCK_CTL TBT CLOCK Ack == "1". */
> + if (__intel_wait_for_register(&i915->uncore, XELPDP_PORT_CLOCK_CTL(encoder->port),
intel_de_wait_for_register can be used here.
> + XELPDP_TBT_CLOCK_ACK,
> + XELPDP_TBT_CLOCK_ACK,
> + 100, 0, NULL))
> + drm_warn(&i915->drm, "[ENCODER:%d:%s][%c] PHY PLL not locked after 100us.\n",
> + encoder->base.base.id, encoder->base.name, phy_name(phy));
> +
> + /*
> + * 6. Follow the Display Voltage Frequency Switching Sequence After
> + * Frequency Change. We handle this step in bxt_set_cdclk().
> + */
> +
> + /*
> + * 7. Program DDI_CLK_VALFREQ to match intended DDI
> + * clock frequency.
> + */
> + intel_de_write(i915, DDI_CLK_VALFREQ(encoder->port),
> + crtc_state->port_clock);
> +}
> +
> +void intel_mtl_pll_enable(struct intel_encoder *encoder,
> + const struct intel_crtc_state *crtc_state)
> +{
> + struct intel_digital_port *dig_port = enc_to_dig_port(encoder);
> +
> + if (intel_tc_port_in_tbt_alt_mode(dig_port))
> + intel_mtl_tbt_pll_enable(encoder, crtc_state);
> + else
> + intel_cx0pll_enable(encoder, crtc_state);
> +}
> +
> +static void intel_cx0pll_disable(struct intel_encoder *encoder)
> {
> struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> enum phy phy = intel_port_to_phy(i915, encoder->port);
> @@ -2728,6 +2807,56 @@ void intel_cx0pll_disable(struct intel_encoder *encoder)
> intel_cx0_phy_transaction_end(encoder, wakeref);
> }
>
> +static void intel_mtl_tbt_pll_disable(struct intel_encoder *encoder)
> +{
> + struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> + enum phy phy = intel_port_to_phy(i915, encoder->port);
> +
> + /*
> + * 1. Follow the Display Voltage Frequency Switching Sequence Before
> + * Frequency Change. We handle this step in bxt_set_cdclk().
> + */
> +
> + /*
> + * 2. Set PORT_CLOCK_CTL register TBT CLOCK Request to "0" to disable PLL.
> + */
> + intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port),
> + XELPDP_TBT_CLOCK_REQUEST, 0);
> +
> + /* 3. Poll on PORT_CLOCK_CTL TBT CLOCK Ack == "0". */
> + if (__intel_wait_for_register(&i915->uncore, XELPDP_PORT_CLOCK_CTL(encoder->port),
intel_de_wait_for_register can be used here.
With that,
Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> + XELPDP_TBT_CLOCK_ACK,
> + ~XELPDP_TBT_CLOCK_ACK,
> + 10, 0, NULL))
> + drm_warn(&i915->drm, "[ENCODER:%d:%s][%c] PHY PLL not unlocked after 10us.\n",
> + encoder->base.base.id, encoder->base.name, phy_name(phy));
> +
> + /*
> + * 4. Follow the Display Voltage Frequency Switching Sequence After
> + * Frequency Change. We handle this step in bxt_set_cdclk().
> + */
> +
> + /*
> + * 5. Program PORT CLOCK CTRL register to disable and gate clocks
> + */
> + intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port),
> + XELPDP_DDI_CLOCK_SELECT_MASK |
> + XELPDP_FORWARD_CLOCK_UNGATE, 0);
> +
> + /* 6. Program DDI_CLK_VALFREQ to 0. */
> + intel_de_write(i915, DDI_CLK_VALFREQ(encoder->port), 0);
> +}
> +
> +void intel_mtl_pll_disable(struct intel_encoder *encoder)
> +{
> + struct intel_digital_port *dig_port = enc_to_dig_port(encoder);
> +
> + if (intel_tc_port_in_tbt_alt_mode(dig_port))
> + intel_mtl_tbt_pll_disable(encoder);
> + else
> + intel_cx0pll_disable(encoder);
> +}
> +
> void intel_c10pll_state_verify(struct intel_atomic_state *state,
> struct intel_crtc_state *new_crtc_state)
> {
> diff --git a/drivers/gpu/drm/i915/display/intel_cx0_phy.h b/drivers/gpu/drm/i915/display/intel_cx0_phy.h
> index 83bd3500091b..9ea6310b6d79 100644
> --- a/drivers/gpu/drm/i915/display/intel_cx0_phy.h
> +++ b/drivers/gpu/drm/i915/display/intel_cx0_phy.h
> @@ -19,9 +19,9 @@ struct intel_crtc_state;
> enum phy;
>
> bool intel_is_c10phy(struct drm_i915_private *dev_priv, enum phy phy);
> -void intel_cx0pll_enable(struct intel_encoder *encoder,
> - const struct intel_crtc_state *crtc_state);
> -void intel_cx0pll_disable(struct intel_encoder *encoder);
> +void intel_mtl_pll_enable(struct intel_encoder *encoder,
> + const struct intel_crtc_state *crtc_state);
> +void intel_mtl_pll_disable(struct intel_encoder *encoder);
> void intel_c10pll_readout_hw_state(struct intel_encoder *encoder, struct intel_c10pll_state *pll_state);
> int intel_cx0pll_calc_state(struct intel_crtc_state *crtc_state, struct intel_encoder *encoder);
> void intel_c10pll_dump_hw_state(struct drm_i915_private *dev_priv,
> @@ -42,4 +42,5 @@ int intel_cx0_phy_check_hdmi_link_rate(struct intel_hdmi *hdmi, int clock);
> void intel_cx0_phy_ddi_vswing_sequence(struct intel_encoder *encoder,
> const struct intel_crtc_state *crtc_state,
> u32 level);
> +int intel_mtl_tbt_readout_hw_state(struct intel_encoder *encoder);
> #endif /* __INTEL_CX0_PHY_H__ */
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 8e6d6afca400..c18226edacac 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -4779,8 +4779,8 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
> encoder->pipe_mask = ~0;
>
> if (DISPLAY_VER(dev_priv) >= 14) {
> - encoder->enable_clock = intel_cx0pll_enable;
> - encoder->disable_clock = intel_cx0pll_disable;
> + encoder->enable_clock = intel_mtl_pll_enable;
> + encoder->disable_clock = intel_mtl_pll_disable;
> encoder->get_config = mtl_ddi_get_config;
> } else if (IS_DG2(dev_priv)) {
> encoder->enable_clock = intel_mpllb_enable;
> --
> 2.34.1
>
next prev parent reply other threads:[~2023-04-25 19:33 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
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 [this message]
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=ZEgq0ZP7kxfoeX1r@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