Skip to content

Commit 7abd4b3

Browse files
author
Ander Conselvan de Oliveira
committed
drm/i915: Move shared dpll code to a new file
Create the new file intel_dpll_mgr.c and move the shared dpll code to it. Follow up patches that reorganize pll handling will move more code there and tweak the interface. No functional changes. Signed-off-by: Ander Conselvan de Oliveira <[email protected]> Reviewed-by: Maarten Lankhorst <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/1457451987-17466-2-git-send-email-ander.conselvan.de.oliveira@intel.com
1 parent 71f0a62 commit 7abd4b3

File tree

4 files changed

+379
-346
lines changed

4 files changed

+379
-346
lines changed

drivers/gpu/drm/i915/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ i915-y += intel_audio.o \
5656
intel_atomic_plane.o \
5757
intel_bios.o \
5858
intel_display.o \
59+
intel_dpll_mgr.o \
5960
intel_fbc.o \
6061
intel_fifo_underrun.o \
6162
intel_frontbuffer.o \

drivers/gpu/drm/i915/intel_display.c

Lines changed: 2 additions & 346 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,34 +1197,6 @@ static void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state)
11971197
#define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
11981198
#define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
11991199

1200-
struct intel_shared_dpll *
1201-
intel_crtc_to_shared_dpll(struct intel_crtc *crtc)
1202-
{
1203-
struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
1204-
1205-
if (crtc->config->shared_dpll < 0)
1206-
return NULL;
1207-
1208-
return &dev_priv->shared_dplls[crtc->config->shared_dpll];
1209-
}
1210-
1211-
/* For ILK+ */
1212-
void assert_shared_dpll(struct drm_i915_private *dev_priv,
1213-
struct intel_shared_dpll *pll,
1214-
bool state)
1215-
{
1216-
bool cur_state;
1217-
struct intel_dpll_hw_state hw_state;
1218-
1219-
if (WARN(!pll, "asserting DPLL %s with no DPLL\n", onoff(state)))
1220-
return;
1221-
1222-
cur_state = pll->get_hw_state(dev_priv, pll, &hw_state);
1223-
I915_STATE_WARN(cur_state != state,
1224-
"%s assertion failure (expected %s, current %s)\n",
1225-
pll->name, onoff(state), onoff(cur_state));
1226-
}
1227-
12281200
static void assert_fdi_tx(struct drm_i915_private *dev_priv,
12291201
enum pipe pipe, bool state)
12301202
{
@@ -1461,21 +1433,8 @@ static void assert_vblank_disabled(struct drm_crtc *crtc)
14611433
drm_crtc_vblank_put(crtc);
14621434
}
14631435

1464-
static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
1465-
{
1466-
u32 val;
1467-
bool enabled;
1468-
1469-
I915_STATE_WARN_ON(!(HAS_PCH_IBX(dev_priv->dev) || HAS_PCH_CPT(dev_priv->dev)));
1470-
1471-
val = I915_READ(PCH_DREF_CONTROL);
1472-
enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
1473-
DREF_SUPERSPREAD_SOURCE_MASK));
1474-
I915_STATE_WARN(!enabled, "PCH refclk assertion failure, should be active but is disabled\n");
1475-
}
1476-
1477-
static void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
1478-
enum pipe pipe)
1436+
void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
1437+
enum pipe pipe)
14791438
{
14801439
u32 val;
14811440
bool enabled;
@@ -1871,100 +1830,6 @@ void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
18711830
port_name(dport->port), I915_READ(dpll_reg) & port_mask, expected_mask);
18721831
}
18731832

1874-
static void intel_prepare_shared_dpll(struct intel_crtc *crtc)
1875-
{
1876-
struct drm_device *dev = crtc->base.dev;
1877-
struct drm_i915_private *dev_priv = dev->dev_private;
1878-
struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
1879-
1880-
if (WARN_ON(pll == NULL))
1881-
return;
1882-
1883-
WARN_ON(!pll->config.crtc_mask);
1884-
if (pll->active == 0) {
1885-
DRM_DEBUG_DRIVER("setting up %s\n", pll->name);
1886-
WARN_ON(pll->on);
1887-
assert_shared_dpll_disabled(dev_priv, pll);
1888-
1889-
pll->mode_set(dev_priv, pll);
1890-
}
1891-
}
1892-
1893-
/**
1894-
* intel_enable_shared_dpll - enable PCH PLL
1895-
* @dev_priv: i915 private structure
1896-
* @pipe: pipe PLL to enable
1897-
*
1898-
* The PCH PLL needs to be enabled before the PCH transcoder, since it
1899-
* drives the transcoder clock.
1900-
*/
1901-
static void intel_enable_shared_dpll(struct intel_crtc *crtc)
1902-
{
1903-
struct drm_device *dev = crtc->base.dev;
1904-
struct drm_i915_private *dev_priv = dev->dev_private;
1905-
struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
1906-
1907-
if (WARN_ON(pll == NULL))
1908-
return;
1909-
1910-
if (WARN_ON(pll->config.crtc_mask == 0))
1911-
return;
1912-
1913-
DRM_DEBUG_KMS("enable %s (active %d, on? %d) for crtc %d\n",
1914-
pll->name, pll->active, pll->on,
1915-
crtc->base.base.id);
1916-
1917-
if (pll->active++) {
1918-
WARN_ON(!pll->on);
1919-
assert_shared_dpll_enabled(dev_priv, pll);
1920-
return;
1921-
}
1922-
WARN_ON(pll->on);
1923-
1924-
intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS);
1925-
1926-
DRM_DEBUG_KMS("enabling %s\n", pll->name);
1927-
pll->enable(dev_priv, pll);
1928-
pll->on = true;
1929-
}
1930-
1931-
static void intel_disable_shared_dpll(struct intel_crtc *crtc)
1932-
{
1933-
struct drm_device *dev = crtc->base.dev;
1934-
struct drm_i915_private *dev_priv = dev->dev_private;
1935-
struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
1936-
1937-
/* PCH only available on ILK+ */
1938-
if (INTEL_INFO(dev)->gen < 5)
1939-
return;
1940-
1941-
if (pll == NULL)
1942-
return;
1943-
1944-
if (WARN_ON(!(pll->config.crtc_mask & (1 << drm_crtc_index(&crtc->base)))))
1945-
return;
1946-
1947-
DRM_DEBUG_KMS("disable %s (active %d, on? %d) for crtc %d\n",
1948-
pll->name, pll->active, pll->on,
1949-
crtc->base.base.id);
1950-
1951-
if (WARN_ON(pll->active == 0)) {
1952-
assert_shared_dpll_disabled(dev_priv, pll);
1953-
return;
1954-
}
1955-
1956-
assert_shared_dpll_enabled(dev_priv, pll);
1957-
WARN_ON(!pll->on);
1958-
if (--pll->active)
1959-
return;
1960-
1961-
DRM_DEBUG_KMS("disabling %s\n", pll->name);
1962-
pll->disable(dev_priv, pll);
1963-
pll->on = false;
1964-
1965-
intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
1966-
}
1967-
19681833
static void ironlake_enable_pch_transcoder(struct drm_i915_private *dev_priv,
19691834
enum pipe pipe)
19701835
{
@@ -4361,113 +4226,6 @@ static void lpt_pch_enable(struct drm_crtc *crtc)
43614226
lpt_enable_pch_transcoder(dev_priv, cpu_transcoder);
43624227
}
43634228

4364-
struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
4365-
struct intel_crtc_state *crtc_state)
4366-
{
4367-
struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
4368-
struct intel_shared_dpll *pll;
4369-
struct intel_shared_dpll_config *shared_dpll;
4370-
enum intel_dpll_id i;
4371-
int max = dev_priv->num_shared_dpll;
4372-
4373-
shared_dpll = intel_atomic_get_shared_dpll_state(crtc_state->base.state);
4374-
4375-
if (HAS_PCH_IBX(dev_priv->dev)) {
4376-
/* Ironlake PCH has a fixed PLL->PCH pipe mapping. */
4377-
i = (enum intel_dpll_id) crtc->pipe;
4378-
pll = &dev_priv->shared_dplls[i];
4379-
4380-
DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n",
4381-
crtc->base.base.id, pll->name);
4382-
4383-
WARN_ON(shared_dpll[i].crtc_mask);
4384-
4385-
goto found;
4386-
}
4387-
4388-
if (IS_BROXTON(dev_priv->dev)) {
4389-
/* PLL is attached to port in bxt */
4390-
struct intel_encoder *encoder;
4391-
struct intel_digital_port *intel_dig_port;
4392-
4393-
encoder = intel_ddi_get_crtc_new_encoder(crtc_state);
4394-
if (WARN_ON(!encoder))
4395-
return NULL;
4396-
4397-
intel_dig_port = enc_to_dig_port(&encoder->base);
4398-
/* 1:1 mapping between ports and PLLs */
4399-
i = (enum intel_dpll_id)intel_dig_port->port;
4400-
pll = &dev_priv->shared_dplls[i];
4401-
DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n",
4402-
crtc->base.base.id, pll->name);
4403-
WARN_ON(shared_dpll[i].crtc_mask);
4404-
4405-
goto found;
4406-
} else if (INTEL_INFO(dev_priv)->gen < 9 && HAS_DDI(dev_priv))
4407-
/* Do not consider SPLL */
4408-
max = 2;
4409-
4410-
for (i = 0; i < max; i++) {
4411-
pll = &dev_priv->shared_dplls[i];
4412-
4413-
/* Only want to check enabled timings first */
4414-
if (shared_dpll[i].crtc_mask == 0)
4415-
continue;
4416-
4417-
if (memcmp(&crtc_state->dpll_hw_state,
4418-
&shared_dpll[i].hw_state,
4419-
sizeof(crtc_state->dpll_hw_state)) == 0) {
4420-
DRM_DEBUG_KMS("CRTC:%d sharing existing %s (crtc mask 0x%08x, ative %d)\n",
4421-
crtc->base.base.id, pll->name,
4422-
shared_dpll[i].crtc_mask,
4423-
pll->active);
4424-
goto found;
4425-
}
4426-
}
4427-
4428-
/* Ok no matching timings, maybe there's a free one? */
4429-
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
4430-
pll = &dev_priv->shared_dplls[i];
4431-
if (shared_dpll[i].crtc_mask == 0) {
4432-
DRM_DEBUG_KMS("CRTC:%d allocated %s\n",
4433-
crtc->base.base.id, pll->name);
4434-
goto found;
4435-
}
4436-
}
4437-
4438-
return NULL;
4439-
4440-
found:
4441-
if (shared_dpll[i].crtc_mask == 0)
4442-
shared_dpll[i].hw_state =
4443-
crtc_state->dpll_hw_state;
4444-
4445-
crtc_state->shared_dpll = i;
4446-
DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name,
4447-
pipe_name(crtc->pipe));
4448-
4449-
shared_dpll[i].crtc_mask |= 1 << crtc->pipe;
4450-
4451-
return pll;
4452-
}
4453-
4454-
static void intel_shared_dpll_commit(struct drm_atomic_state *state)
4455-
{
4456-
struct drm_i915_private *dev_priv = to_i915(state->dev);
4457-
struct intel_shared_dpll_config *shared_dpll;
4458-
struct intel_shared_dpll *pll;
4459-
enum intel_dpll_id i;
4460-
4461-
if (!to_intel_atomic_state(state)->dpll_set)
4462-
return;
4463-
4464-
shared_dpll = to_intel_atomic_state(state)->shared_dpll;
4465-
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
4466-
pll = &dev_priv->shared_dplls[i];
4467-
pll->config = shared_dpll[i];
4468-
}
4469-
}
4470-
44714229
static void cpt_verify_modeset(struct drm_device *dev, int pipe)
44724230
{
44734231
struct drm_i915_private *dev_priv = dev->dev_private;
@@ -13887,108 +13645,6 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
1388713645
.atomic_destroy_state = intel_crtc_destroy_state,
1388813646
};
1388913647

13890-
static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
13891-
struct intel_shared_dpll *pll,
13892-
struct intel_dpll_hw_state *hw_state)
13893-
{
13894-
uint32_t val;
13895-
13896-
if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
13897-
return false;
13898-
13899-
val = I915_READ(PCH_DPLL(pll->id));
13900-
hw_state->dpll = val;
13901-
hw_state->fp0 = I915_READ(PCH_FP0(pll->id));
13902-
hw_state->fp1 = I915_READ(PCH_FP1(pll->id));
13903-
13904-
intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
13905-
13906-
return val & DPLL_VCO_ENABLE;
13907-
}
13908-
13909-
static void ibx_pch_dpll_mode_set(struct drm_i915_private *dev_priv,
13910-
struct intel_shared_dpll *pll)
13911-
{
13912-
I915_WRITE(PCH_FP0(pll->id), pll->config.hw_state.fp0);
13913-
I915_WRITE(PCH_FP1(pll->id), pll->config.hw_state.fp1);
13914-
}
13915-
13916-
static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv,
13917-
struct intel_shared_dpll *pll)
13918-
{
13919-
/* PCH refclock must be enabled first */
13920-
ibx_assert_pch_refclk_enabled(dev_priv);
13921-
13922-
I915_WRITE(PCH_DPLL(pll->id), pll->config.hw_state.dpll);
13923-
13924-
/* Wait for the clocks to stabilize. */
13925-
POSTING_READ(PCH_DPLL(pll->id));
13926-
udelay(150);
13927-
13928-
/* The pixel multiplier can only be updated once the
13929-
* DPLL is enabled and the clocks are stable.
13930-
*
13931-
* So write it again.
13932-
*/
13933-
I915_WRITE(PCH_DPLL(pll->id), pll->config.hw_state.dpll);
13934-
POSTING_READ(PCH_DPLL(pll->id));
13935-
udelay(200);
13936-
}
13937-
13938-
static void ibx_pch_dpll_disable(struct drm_i915_private *dev_priv,
13939-
struct intel_shared_dpll *pll)
13940-
{
13941-
struct drm_device *dev = dev_priv->dev;
13942-
struct intel_crtc *crtc;
13943-
13944-
/* Make sure no transcoder isn't still depending on us. */
13945-
for_each_intel_crtc(dev, crtc) {
13946-
if (intel_crtc_to_shared_dpll(crtc) == pll)
13947-
assert_pch_transcoder_disabled(dev_priv, crtc->pipe);
13948-
}
13949-
13950-
I915_WRITE(PCH_DPLL(pll->id), 0);
13951-
POSTING_READ(PCH_DPLL(pll->id));
13952-
udelay(200);
13953-
}
13954-
13955-
static char *ibx_pch_dpll_names[] = {
13956-
"PCH DPLL A",
13957-
"PCH DPLL B",
13958-
};
13959-
13960-
static void ibx_pch_dpll_init(struct drm_device *dev)
13961-
{
13962-
struct drm_i915_private *dev_priv = dev->dev_private;
13963-
int i;
13964-
13965-
dev_priv->num_shared_dpll = 2;
13966-
13967-
for (i = 0; i < dev_priv->num_shared_dpll; i++) {
13968-
dev_priv->shared_dplls[i].id = i;
13969-
dev_priv->shared_dplls[i].name = ibx_pch_dpll_names[i];
13970-
dev_priv->shared_dplls[i].mode_set = ibx_pch_dpll_mode_set;
13971-
dev_priv->shared_dplls[i].enable = ibx_pch_dpll_enable;
13972-
dev_priv->shared_dplls[i].disable = ibx_pch_dpll_disable;
13973-
dev_priv->shared_dplls[i].get_hw_state =
13974-
ibx_pch_dpll_get_hw_state;
13975-
}
13976-
}
13977-
13978-
static void intel_shared_dpll_init(struct drm_device *dev)
13979-
{
13980-
struct drm_i915_private *dev_priv = dev->dev_private;
13981-
13982-
if (HAS_DDI(dev))
13983-
intel_ddi_pll_init(dev);
13984-
else if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
13985-
ibx_pch_dpll_init(dev);
13986-
else
13987-
dev_priv->num_shared_dpll = 0;
13988-
13989-
BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
13990-
}
13991-
1399213648
/**
1399313649
* intel_prepare_plane_fb - Prepare fb for usage on plane
1399413650
* @plane: drm plane to prepare for

0 commit comments

Comments
 (0)