Skip to content

Commit 2edd644

Browse files
author
Ander Conselvan de Oliveira
committed
drm/i915: Use a table to initilize shared dplls
Use a table to store the per-platform shared dpll information in one place. This way, there is no need for platform specific init funtions. Signed-off-by: Ander Conselvan de Oliveira <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/1457451987-17466-8-git-send-email-ander.conselvan.de.oliveira@intel.com
1 parent c2a9fcd commit 2edd644

File tree

3 files changed

+108
-119
lines changed

3 files changed

+108
-119
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9309,8 +9309,8 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
93099309
intel_get_shared_dpll_by_id(dev_priv, pll_id);
93109310
pll = pipe_config->shared_dpll;
93119311

9312-
WARN_ON(!pll->get_hw_state(dev_priv, pll,
9313-
&pipe_config->dpll_hw_state));
9312+
WARN_ON(!pll->funcs.get_hw_state(dev_priv, pll,
9313+
&pipe_config->dpll_hw_state));
93149314

93159315
tmp = pipe_config->dpll_hw_state.dpll;
93169316
pipe_config->pixel_multiplier =
@@ -9856,8 +9856,8 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
98569856

98579857
pll = pipe_config->shared_dpll;
98589858
if (pll) {
9859-
WARN_ON(!pll->get_hw_state(dev_priv, pll,
9860-
&pipe_config->dpll_hw_state));
9859+
WARN_ON(!pll->funcs.get_hw_state(dev_priv, pll,
9860+
&pipe_config->dpll_hw_state));
98619861
}
98629862

98639863
/*
@@ -12935,7 +12935,7 @@ check_shared_dpll_state(struct drm_device *dev)
1293512935

1293612936
DRM_DEBUG_KMS("%s\n", pll->name);
1293712937

12938-
active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state);
12938+
active = pll->funcs.get_hw_state(dev_priv, pll, &dpll_hw_state);
1293912939

1294012940
I915_STATE_WARN(pll->active > hweight32(pll->config.crtc_mask),
1294112941
"more active pll users than references: %i vs %i\n",
@@ -15686,8 +15686,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
1568615686
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
1568715687
struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
1568815688

15689-
pll->on = pll->get_hw_state(dev_priv, pll,
15690-
&pll->config.hw_state);
15689+
pll->on = pll->funcs.get_hw_state(dev_priv, pll,
15690+
&pll->config.hw_state);
1569115691
pll->active = 0;
1569215692
pll->config.crtc_mask = 0;
1569315693
for_each_intel_crtc(dev, crtc) {
@@ -15824,7 +15824,7 @@ intel_modeset_setup_hw_state(struct drm_device *dev)
1582415824

1582515825
DRM_DEBUG_KMS("%s enabled but not in use, disabling\n", pll->name);
1582615826

15827-
pll->disable(dev_priv, pll);
15827+
pll->funcs.disable(dev_priv, pll);
1582815828
pll->on = false;
1582915829
}
1583015830

drivers/gpu/drm/i915/intel_dpll_mgr.c

Lines changed: 86 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void assert_shared_dpll(struct drm_i915_private *dev_priv,
7474
if (WARN(!pll, "asserting DPLL %s with no DPLL\n", onoff(state)))
7575
return;
7676

77-
cur_state = pll->get_hw_state(dev_priv, pll, &hw_state);
77+
cur_state = pll->funcs.get_hw_state(dev_priv, pll, &hw_state);
7878
I915_STATE_WARN(cur_state != state,
7979
"%s assertion failure (expected %s, current %s)\n",
8080
pll->name, onoff(state), onoff(cur_state));
@@ -95,7 +95,7 @@ void intel_prepare_shared_dpll(struct intel_crtc *crtc)
9595
WARN_ON(pll->on);
9696
assert_shared_dpll_disabled(dev_priv, pll);
9797

98-
pll->mode_set(dev_priv, pll);
98+
pll->funcs.mode_set(dev_priv, pll);
9999
}
100100
}
101101

@@ -133,7 +133,7 @@ void intel_enable_shared_dpll(struct intel_crtc *crtc)
133133
intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS);
134134

135135
DRM_DEBUG_KMS("enabling %s\n", pll->name);
136-
pll->enable(dev_priv, pll);
136+
pll->funcs.enable(dev_priv, pll);
137137
pll->on = true;
138138
}
139139

@@ -168,7 +168,7 @@ void intel_disable_shared_dpll(struct intel_crtc *crtc)
168168
return;
169169

170170
DRM_DEBUG_KMS("disabling %s\n", pll->name);
171-
pll->disable(dev_priv, pll);
171+
pll->funcs.disable(dev_priv, pll);
172172
pll->on = false;
173173

174174
intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
@@ -398,29 +398,13 @@ static void ibx_pch_dpll_disable(struct drm_i915_private *dev_priv,
398398
udelay(200);
399399
}
400400

401-
static char *ibx_pch_dpll_names[] = {
402-
"PCH DPLL A",
403-
"PCH DPLL B",
401+
static const struct intel_shared_dpll_funcs ibx_pch_dpll_funcs = {
402+
.mode_set = ibx_pch_dpll_mode_set,
403+
.enable = ibx_pch_dpll_enable,
404+
.disable = ibx_pch_dpll_disable,
405+
.get_hw_state = ibx_pch_dpll_get_hw_state,
404406
};
405407

406-
static void ibx_pch_dpll_init(struct drm_device *dev)
407-
{
408-
struct drm_i915_private *dev_priv = dev->dev_private;
409-
int i;
410-
411-
dev_priv->num_shared_dpll = 2;
412-
413-
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
414-
dev_priv->shared_dplls[i].id = i;
415-
dev_priv->shared_dplls[i].name = ibx_pch_dpll_names[i];
416-
dev_priv->shared_dplls[i].mode_set = ibx_pch_dpll_mode_set;
417-
dev_priv->shared_dplls[i].enable = ibx_pch_dpll_enable;
418-
dev_priv->shared_dplls[i].disable = ibx_pch_dpll_disable;
419-
dev_priv->shared_dplls[i].get_hw_state =
420-
ibx_pch_dpll_get_hw_state;
421-
}
422-
}
423-
424408
static void hsw_ddi_wrpll_enable(struct drm_i915_private *dev_priv,
425409
struct intel_shared_dpll *pll)
426410
{
@@ -492,40 +476,16 @@ static bool hsw_ddi_spll_get_hw_state(struct drm_i915_private *dev_priv,
492476
}
493477

494478

495-
static const char * const hsw_ddi_pll_names[] = {
496-
"WRPLL 1",
497-
"WRPLL 2",
498-
"SPLL"
479+
static const struct intel_shared_dpll_funcs hsw_ddi_wrpll_funcs = {
480+
.enable = hsw_ddi_wrpll_enable,
481+
.disable = hsw_ddi_wrpll_disable,
482+
.get_hw_state = hsw_ddi_wrpll_get_hw_state,
499483
};
500484

501-
static void hsw_shared_dplls_init(struct drm_i915_private *dev_priv)
502-
{
503-
int i;
504-
505-
dev_priv->num_shared_dpll = 3;
506-
507-
for (i = 0; i < 2; i++) {
508-
dev_priv->shared_dplls[i].id = i;
509-
dev_priv->shared_dplls[i].name = hsw_ddi_pll_names[i];
510-
dev_priv->shared_dplls[i].disable = hsw_ddi_wrpll_disable;
511-
dev_priv->shared_dplls[i].enable = hsw_ddi_wrpll_enable;
512-
dev_priv->shared_dplls[i].get_hw_state =
513-
hsw_ddi_wrpll_get_hw_state;
514-
}
515-
516-
/* SPLL is special, but needs to be initialized anyway.. */
517-
dev_priv->shared_dplls[i].id = i;
518-
dev_priv->shared_dplls[i].name = hsw_ddi_pll_names[i];
519-
dev_priv->shared_dplls[i].disable = hsw_ddi_spll_disable;
520-
dev_priv->shared_dplls[i].enable = hsw_ddi_spll_enable;
521-
dev_priv->shared_dplls[i].get_hw_state = hsw_ddi_spll_get_hw_state;
522-
523-
}
524-
525-
static const char * const skl_ddi_pll_names[] = {
526-
"DPLL 1",
527-
"DPLL 2",
528-
"DPLL 3",
485+
static const struct intel_shared_dpll_funcs hsw_ddi_spll_funcs = {
486+
.enable = hsw_ddi_spll_enable,
487+
.disable = hsw_ddi_spll_disable,
488+
.get_hw_state = hsw_ddi_spll_get_hw_state,
529489
};
530490

531491
struct skl_dpll_regs {
@@ -634,26 +594,10 @@ static bool skl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
634594
return ret;
635595
}
636596

637-
static void skl_shared_dplls_init(struct drm_i915_private *dev_priv)
638-
{
639-
int i;
640-
641-
dev_priv->num_shared_dpll = 3;
642-
643-
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
644-
dev_priv->shared_dplls[i].id = i;
645-
dev_priv->shared_dplls[i].name = skl_ddi_pll_names[i];
646-
dev_priv->shared_dplls[i].disable = skl_ddi_pll_disable;
647-
dev_priv->shared_dplls[i].enable = skl_ddi_pll_enable;
648-
dev_priv->shared_dplls[i].get_hw_state =
649-
skl_ddi_pll_get_hw_state;
650-
}
651-
}
652-
653-
static const char * const bxt_ddi_pll_names[] = {
654-
"PORT PLL A",
655-
"PORT PLL B",
656-
"PORT PLL C",
597+
static const struct intel_shared_dpll_funcs skl_ddi_pll_funcs = {
598+
.enable = skl_ddi_pll_enable,
599+
.disable = skl_ddi_pll_disable,
600+
.get_hw_state = skl_ddi_pll_get_hw_state,
657601
};
658602

659603
static void bxt_ddi_pll_enable(struct drm_i915_private *dev_priv,
@@ -838,34 +782,17 @@ static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
838782
return ret;
839783
}
840784

841-
static void bxt_shared_dplls_init(struct drm_i915_private *dev_priv)
842-
{
843-
int i;
844-
845-
dev_priv->num_shared_dpll = 3;
846-
847-
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
848-
dev_priv->shared_dplls[i].id = i;
849-
dev_priv->shared_dplls[i].name = bxt_ddi_pll_names[i];
850-
dev_priv->shared_dplls[i].disable = bxt_ddi_pll_disable;
851-
dev_priv->shared_dplls[i].enable = bxt_ddi_pll_enable;
852-
dev_priv->shared_dplls[i].get_hw_state =
853-
bxt_ddi_pll_get_hw_state;
854-
}
855-
}
785+
static const struct intel_shared_dpll_funcs bxt_ddi_pll_funcs = {
786+
.enable = bxt_ddi_pll_enable,
787+
.disable = bxt_ddi_pll_disable,
788+
.get_hw_state = bxt_ddi_pll_get_hw_state,
789+
};
856790

857791
static void intel_ddi_pll_init(struct drm_device *dev)
858792
{
859793
struct drm_i915_private *dev_priv = dev->dev_private;
860794
uint32_t val = I915_READ(LCPLL_CTL);
861795

862-
if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
863-
skl_shared_dplls_init(dev_priv);
864-
else if (IS_BROXTON(dev))
865-
bxt_shared_dplls_init(dev_priv);
866-
else
867-
hsw_shared_dplls_init(dev_priv);
868-
869796
if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) {
870797
int cdclk_freq;
871798

@@ -893,16 +820,72 @@ static void intel_ddi_pll_init(struct drm_device *dev)
893820
}
894821
}
895822

823+
struct dpll_info {
824+
const char *name;
825+
const int id;
826+
const struct intel_shared_dpll_funcs *funcs;
827+
};
828+
829+
static const struct dpll_info pch_plls[] = {
830+
{ "PCH DPLL A", DPLL_ID_PCH_PLL_A, &ibx_pch_dpll_funcs },
831+
{ "PCH DPLL B", DPLL_ID_PCH_PLL_B, &ibx_pch_dpll_funcs },
832+
{ NULL, -1, NULL },
833+
};
834+
835+
static const struct dpll_info hsw_plls[] = {
836+
{ "WRPLL 1", DPLL_ID_WRPLL1, &hsw_ddi_wrpll_funcs },
837+
{ "WRPLL 2", DPLL_ID_WRPLL2, &hsw_ddi_wrpll_funcs },
838+
{ "SPLL", DPLL_ID_SPLL, &hsw_ddi_spll_funcs },
839+
{ NULL, -1, NULL, },
840+
};
841+
842+
static const struct dpll_info skl_plls[] = {
843+
{ "DPPL 1", DPLL_ID_SKL_DPLL1, &skl_ddi_pll_funcs },
844+
{ "DPPL 2", DPLL_ID_SKL_DPLL2, &skl_ddi_pll_funcs },
845+
{ "DPPL 3", DPLL_ID_SKL_DPLL3, &skl_ddi_pll_funcs },
846+
{ NULL, -1, NULL, },
847+
};
848+
849+
static const struct dpll_info bxt_plls[] = {
850+
{ "PORT PLL A", 0, &bxt_ddi_pll_funcs },
851+
{ "PORT PLL B", 1, &bxt_ddi_pll_funcs },
852+
{ "PORT PLL C", 2, &bxt_ddi_pll_funcs },
853+
{ NULL, -1, NULL, },
854+
};
855+
896856
void intel_shared_dpll_init(struct drm_device *dev)
897857
{
898858
struct drm_i915_private *dev_priv = dev->dev_private;
859+
const struct dpll_info *dpll_info = NULL;
860+
int i;
899861

900-
if (HAS_DDI(dev))
901-
intel_ddi_pll_init(dev);
862+
if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev))
863+
dpll_info = skl_plls;
864+
else if IS_BROXTON(dev)
865+
dpll_info = bxt_plls;
866+
else if (HAS_DDI(dev))
867+
dpll_info = hsw_plls;
902868
else if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
903-
ibx_pch_dpll_init(dev);
904-
else
869+
dpll_info = pch_plls;
870+
871+
if (!dpll_info) {
905872
dev_priv->num_shared_dpll = 0;
873+
return;
874+
}
875+
876+
for (i = 0; dpll_info[i].id >= 0; i++) {
877+
WARN_ON(i != dpll_info[i].id);
878+
879+
dev_priv->shared_dplls[i].id = dpll_info[i].id;
880+
dev_priv->shared_dplls[i].name = dpll_info[i].name;
881+
dev_priv->shared_dplls[i].funcs = *dpll_info[i].funcs;
882+
}
883+
884+
dev_priv->num_shared_dpll = i;
906885

907886
BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
887+
888+
/* FIXME: Move this to a more suitable place */
889+
if (HAS_DDI(dev))
890+
intel_ddi_pll_init(dev);
908891
}

drivers/gpu/drm/i915/intel_dpll_mgr.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
struct drm_i915_private;
2929
struct intel_crtc;
3030
struct intel_crtc_state;
31+
struct intel_shared_dpll;
3132

3233
enum intel_dpll_id {
3334
DPLL_ID_PRIVATE = -1, /* non-shared dpll in use */
@@ -78,14 +79,7 @@ struct intel_shared_dpll_config {
7879
struct intel_dpll_hw_state hw_state;
7980
};
8081

81-
struct intel_shared_dpll {
82-
struct intel_shared_dpll_config config;
83-
84-
int active; /* count of number of active CRTCs (i.e. DPMS on) */
85-
bool on; /* is the PLL actually active? Disabled during modeset */
86-
const char *name;
87-
/* should match the index in the dev_priv->shared_dplls array */
88-
enum intel_dpll_id id;
82+
struct intel_shared_dpll_funcs {
8983
/* The mode_set hook is optional and should be used together with the
9084
* intel_prepare_shared_dpll function. */
9185
void (*mode_set)(struct drm_i915_private *dev_priv,
@@ -99,6 +93,18 @@ struct intel_shared_dpll {
9993
struct intel_dpll_hw_state *hw_state);
10094
};
10195

96+
struct intel_shared_dpll {
97+
struct intel_shared_dpll_config config;
98+
99+
int active; /* count of number of active CRTCs (i.e. DPMS on) */
100+
bool on; /* is the PLL actually active? Disabled during modeset */
101+
const char *name;
102+
/* should match the index in the dev_priv->shared_dplls array */
103+
enum intel_dpll_id id;
104+
105+
struct intel_shared_dpll_funcs funcs;
106+
};
107+
102108
#define SKL_DPLL0 0
103109
#define SKL_DPLL1 1
104110
#define SKL_DPLL2 2

0 commit comments

Comments
 (0)