Commit 0bfdd6da authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Carve up struct intel_dpll_hw_state

struct intel_dpll_hw_state has a spot for all possible
PLL registers across all platforms (well, apart from
cx0/snps). This makes it rather confusing when trying to
figure out which members belong to which platform(s).

Split the struct up into five different platform specific
sub-structures. For now this will actually increase the size
a little bit as we have to duplicate a few members from
skl to icl, but that will be remedied soon when we turn
the thing into a union.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240412182703.19916-17-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent e8ba9204
...@@ -3074,13 +3074,13 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc, ...@@ -3074,13 +3074,13 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
i9xx_dpll_get_hw_state(crtc, &pipe_config->dpll_hw_state); i9xx_dpll_get_hw_state(crtc, &pipe_config->dpll_hw_state);
if (DISPLAY_VER(dev_priv) >= 4) { if (DISPLAY_VER(dev_priv) >= 4) {
tmp = pipe_config->dpll_hw_state.dpll_md; tmp = pipe_config->dpll_hw_state.i9xx.dpll_md;
pipe_config->pixel_multiplier = pipe_config->pixel_multiplier =
((tmp & DPLL_MD_UDI_MULTIPLIER_MASK) ((tmp & DPLL_MD_UDI_MULTIPLIER_MASK)
>> DPLL_MD_UDI_MULTIPLIER_SHIFT) + 1; >> DPLL_MD_UDI_MULTIPLIER_SHIFT) + 1;
} else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) || } else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) ||
IS_G33(dev_priv) || IS_PINEVIEW(dev_priv)) { IS_G33(dev_priv) || IS_PINEVIEW(dev_priv)) {
tmp = pipe_config->dpll_hw_state.dpll; tmp = pipe_config->dpll_hw_state.i9xx.dpll;
pipe_config->pixel_multiplier = pipe_config->pixel_multiplier =
((tmp & SDVO_MULTIPLIER_MASK) ((tmp & SDVO_MULTIPLIER_MASK)
>> SDVO_MULTIPLIER_SHIFT_HIRES) + 1; >> SDVO_MULTIPLIER_SHIFT_HIRES) + 1;
......
...@@ -372,7 +372,7 @@ int chv_calc_dpll_params(int refclk, struct dpll *clock) ...@@ -372,7 +372,7 @@ int chv_calc_dpll_params(int refclk, struct dpll *clock)
static int i9xx_pll_refclk(const struct intel_crtc_state *crtc_state) static int i9xx_pll_refclk(const struct intel_crtc_state *crtc_state)
{ {
struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
if ((hw_state->dpll & PLL_REF_INPUT_MASK) == PLLB_REF_INPUT_SPREADSPECTRUMIN) if ((hw_state->dpll & PLL_REF_INPUT_MASK) == PLLB_REF_INPUT_SPREADSPECTRUMIN)
return i915->display.vbt.lvds_ssc_freq; return i915->display.vbt.lvds_ssc_freq;
...@@ -385,9 +385,10 @@ static int i9xx_pll_refclk(const struct intel_crtc_state *crtc_state) ...@@ -385,9 +385,10 @@ static int i9xx_pll_refclk(const struct intel_crtc_state *crtc_state)
} }
void i9xx_dpll_get_hw_state(struct intel_crtc *crtc, void i9xx_dpll_get_hw_state(struct intel_crtc *crtc,
struct intel_dpll_hw_state *hw_state) struct intel_dpll_hw_state *dpll_hw_state)
{ {
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
struct i9xx_dpll_hw_state *hw_state = &dpll_hw_state->i9xx;
if (DISPLAY_VER(dev_priv) >= 4) { if (DISPLAY_VER(dev_priv) >= 4) {
u32 tmp; u32 tmp;
...@@ -419,7 +420,7 @@ void i9xx_crtc_clock_get(struct intel_crtc_state *crtc_state) ...@@ -419,7 +420,7 @@ void i9xx_crtc_clock_get(struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
u32 dpll = hw_state->dpll; u32 dpll = hw_state->dpll;
u32 fp; u32 fp;
struct dpll clock; struct dpll clock;
...@@ -512,7 +513,7 @@ void vlv_crtc_clock_get(struct intel_crtc_state *crtc_state) ...@@ -512,7 +513,7 @@ void vlv_crtc_clock_get(struct intel_crtc_state *crtc_state)
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
enum dpio_phy phy = vlv_pipe_to_phy(crtc->pipe); enum dpio_phy phy = vlv_pipe_to_phy(crtc->pipe);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
struct dpll clock; struct dpll clock;
u32 mdiv; u32 mdiv;
int refclk = 100000; int refclk = 100000;
...@@ -540,7 +541,7 @@ void chv_crtc_clock_get(struct intel_crtc_state *crtc_state) ...@@ -540,7 +541,7 @@ void chv_crtc_clock_get(struct intel_crtc_state *crtc_state)
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
enum dpio_channel port = vlv_pipe_to_channel(crtc->pipe); enum dpio_channel port = vlv_pipe_to_channel(crtc->pipe);
enum dpio_phy phy = vlv_pipe_to_phy(crtc->pipe); enum dpio_phy phy = vlv_pipe_to_phy(crtc->pipe);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
struct dpll clock; struct dpll clock;
u32 cmn_dw13, pll_dw0, pll_dw1, pll_dw2, pll_dw3; u32 cmn_dw13, pll_dw0, pll_dw1, pll_dw2, pll_dw3;
int refclk = 100000; int refclk = 100000;
...@@ -1068,7 +1069,7 @@ static void i9xx_compute_dpll(struct intel_crtc_state *crtc_state, ...@@ -1068,7 +1069,7 @@ static void i9xx_compute_dpll(struct intel_crtc_state *crtc_state,
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
if (IS_PINEVIEW(dev_priv)) { if (IS_PINEVIEW(dev_priv)) {
hw_state->fp0 = pnv_dpll_compute_fp(clock); hw_state->fp0 = pnv_dpll_compute_fp(clock);
...@@ -1136,7 +1137,7 @@ static void i8xx_compute_dpll(struct intel_crtc_state *crtc_state, ...@@ -1136,7 +1137,7 @@ static void i8xx_compute_dpll(struct intel_crtc_state *crtc_state,
const struct dpll *clock, const struct dpll *clock,
const struct dpll *reduced_clock) const struct dpll *reduced_clock)
{ {
struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
hw_state->fp0 = i9xx_dpll_compute_fp(clock); hw_state->fp0 = i9xx_dpll_compute_fp(clock);
hw_state->fp1 = i9xx_dpll_compute_fp(reduced_clock); hw_state->fp1 = i9xx_dpll_compute_fp(reduced_clock);
...@@ -1337,7 +1338,7 @@ static void ilk_compute_dpll(struct intel_crtc_state *crtc_state, ...@@ -1337,7 +1338,7 @@ static void ilk_compute_dpll(struct intel_crtc_state *crtc_state,
const struct dpll *clock, const struct dpll *clock,
const struct dpll *reduced_clock) const struct dpll *reduced_clock)
{ {
struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
int factor = ilk_fb_cb_factor(crtc_state); int factor = ilk_fb_cb_factor(crtc_state);
hw_state->fp0 = ilk_dpll_compute_fp(clock, factor); hw_state->fp0 = ilk_dpll_compute_fp(clock, factor);
...@@ -1436,7 +1437,7 @@ static u32 vlv_dpll(const struct intel_crtc_state *crtc_state) ...@@ -1436,7 +1437,7 @@ static u32 vlv_dpll(const struct intel_crtc_state *crtc_state)
void vlv_compute_dpll(struct intel_crtc_state *crtc_state) void vlv_compute_dpll(struct intel_crtc_state *crtc_state)
{ {
struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
hw_state->dpll = vlv_dpll(crtc_state); hw_state->dpll = vlv_dpll(crtc_state);
hw_state->dpll_md = i965_dpll_md(crtc_state); hw_state->dpll_md = i965_dpll_md(crtc_state);
...@@ -1462,7 +1463,7 @@ static u32 chv_dpll(const struct intel_crtc_state *crtc_state) ...@@ -1462,7 +1463,7 @@ static u32 chv_dpll(const struct intel_crtc_state *crtc_state)
void chv_compute_dpll(struct intel_crtc_state *crtc_state) void chv_compute_dpll(struct intel_crtc_state *crtc_state)
{ {
struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
hw_state->dpll = chv_dpll(crtc_state); hw_state->dpll = chv_dpll(crtc_state);
hw_state->dpll_md = i965_dpll_md(crtc_state); hw_state->dpll_md = i965_dpll_md(crtc_state);
...@@ -1821,7 +1822,7 @@ void i9xx_enable_pll(const struct intel_crtc_state *crtc_state) ...@@ -1821,7 +1822,7 @@ void i9xx_enable_pll(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
int i; int i;
...@@ -1989,7 +1990,7 @@ static void _vlv_enable_pll(const struct intel_crtc_state *crtc_state) ...@@ -1989,7 +1990,7 @@ static void _vlv_enable_pll(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
intel_de_write(dev_priv, DPLL(pipe), hw_state->dpll); intel_de_write(dev_priv, DPLL(pipe), hw_state->dpll);
...@@ -2004,7 +2005,7 @@ void vlv_enable_pll(const struct intel_crtc_state *crtc_state) ...@@ -2004,7 +2005,7 @@ void vlv_enable_pll(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder); assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder);
...@@ -2124,7 +2125,7 @@ static void _chv_enable_pll(const struct intel_crtc_state *crtc_state) ...@@ -2124,7 +2125,7 @@ static void _chv_enable_pll(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
enum dpio_channel port = vlv_pipe_to_channel(pipe); enum dpio_channel port = vlv_pipe_to_channel(pipe);
enum dpio_phy phy = vlv_pipe_to_phy(crtc->pipe); enum dpio_phy phy = vlv_pipe_to_phy(crtc->pipe);
...@@ -2156,7 +2157,7 @@ void chv_enable_pll(const struct intel_crtc_state *crtc_state) ...@@ -2156,7 +2157,7 @@ void chv_enable_pll(const struct intel_crtc_state *crtc_state)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
const struct intel_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state; const struct i9xx_dpll_hw_state *hw_state = &crtc_state->dpll_hw_state.i9xx;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder); assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder);
......
...@@ -24,7 +24,7 @@ int intel_dpll_crtc_get_shared_dpll(struct intel_atomic_state *state, ...@@ -24,7 +24,7 @@ int intel_dpll_crtc_get_shared_dpll(struct intel_atomic_state *state,
int i9xx_calc_dpll_params(int refclk, struct dpll *clock); int i9xx_calc_dpll_params(int refclk, struct dpll *clock);
u32 i9xx_dpll_compute_fp(const struct dpll *dpll); u32 i9xx_dpll_compute_fp(const struct dpll *dpll);
void i9xx_dpll_get_hw_state(struct intel_crtc *crtc, void i9xx_dpll_get_hw_state(struct intel_crtc *crtc,
struct intel_dpll_hw_state *hw_state); struct intel_dpll_hw_state *dpll_hw_state);
void vlv_compute_dpll(struct intel_crtc_state *crtc_state); void vlv_compute_dpll(struct intel_crtc_state *crtc_state);
void chv_compute_dpll(struct intel_crtc_state *crtc_state); void chv_compute_dpll(struct intel_crtc_state *crtc_state);
......
...@@ -181,18 +181,19 @@ enum icl_port_dpll_id { ...@@ -181,18 +181,19 @@ enum icl_port_dpll_id {
ICL_PORT_DPLL_COUNT, ICL_PORT_DPLL_COUNT,
}; };
struct intel_dpll_hw_state { struct i9xx_dpll_hw_state {
/* i9xx, pch plls */
u32 dpll; u32 dpll;
u32 dpll_md; u32 dpll_md;
u32 fp0; u32 fp0;
u32 fp1; u32 fp1;
};
/* hsw, bdw */ struct hsw_dpll_hw_state {
u32 wrpll; u32 wrpll;
u32 spll; u32 spll;
};
/* skl */ struct skl_dpll_hw_state {
/* /*
* DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in * DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in
* lower part of ctrl1 and they get shifted into position when writing * lower part of ctrl1 and they get shifted into position when writing
...@@ -202,20 +203,18 @@ struct intel_dpll_hw_state { ...@@ -202,20 +203,18 @@ struct intel_dpll_hw_state {
u32 ctrl1; u32 ctrl1;
/* HDMI only, 0 when used for DP */ /* HDMI only, 0 when used for DP */
u32 cfgcr1, cfgcr2; u32 cfgcr1, cfgcr2;
};
struct bxt_dpll_hw_state {
u32 ebb0, ebb4, pll0, pll1, pll2, pll3, pll6, pll8, pll9, pll10, pcsdw12;
};
/* icl */ struct icl_dpll_hw_state {
u32 cfgcr0; u32 cfgcr0, cfgcr1;
/* tgl */ /* tgl */
u32 div0; u32 div0;
/* bxt */
u32 ebb0, ebb4, pll0, pll1, pll2, pll3, pll6, pll8, pll9, pll10, pcsdw12;
/*
* ICL uses the following, already defined:
* u32 cfgcr0, cfgcr1;
*/
u32 mg_refclkin_ctl; u32 mg_refclkin_ctl;
u32 mg_clktop2_coreclkctl1; u32 mg_clktop2_coreclkctl1;
u32 mg_clktop2_hsclkctl; u32 mg_clktop2_hsclkctl;
...@@ -230,6 +229,14 @@ struct intel_dpll_hw_state { ...@@ -230,6 +229,14 @@ struct intel_dpll_hw_state {
u32 mg_pll_tdc_coldst_bias_mask; u32 mg_pll_tdc_coldst_bias_mask;
}; };
struct intel_dpll_hw_state {
struct i9xx_dpll_hw_state i9xx;
struct hsw_dpll_hw_state hsw;
struct skl_dpll_hw_state skl;
struct bxt_dpll_hw_state bxt;
struct icl_dpll_hw_state icl;
};
/** /**
* struct intel_shared_dpll_state - hold the DPLL atomic state * struct intel_shared_dpll_state - hold the DPLL atomic state
* *
......
...@@ -529,7 +529,7 @@ void ilk_pch_get_config(struct intel_crtc_state *crtc_state) ...@@ -529,7 +529,7 @@ void ilk_pch_get_config(struct intel_crtc_state *crtc_state)
&crtc_state->dpll_hw_state); &crtc_state->dpll_hw_state);
drm_WARN_ON(&dev_priv->drm, !pll_active); drm_WARN_ON(&dev_priv->drm, !pll_active);
tmp = crtc_state->dpll_hw_state.dpll; tmp = crtc_state->dpll_hw_state.i9xx.dpll;
crtc_state->pixel_multiplier = crtc_state->pixel_multiplier =
((tmp & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK) ((tmp & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK)
>> PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT) + 1; >> PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT) + 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment