Skip to content

Commit

Permalink
drm/tilcdc: Use drm_atomic_helper_resume/suspend()
Browse files Browse the repository at this point in the history
commit 514d1a1 upstream.

Use drm_atomic_helper_resume/suspend() and get rid off all the obsolete
register level context restoring code.

Signed-off-by: Jyri Sarha <[email protected]>
  • Loading branch information
Jyri Sarha committed Aug 17, 2016
1 parent 6b49c65 commit 91df99d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 53 deletions.
56 changes: 7 additions & 49 deletions drivers/gpu/drm/tilcdc/tilcdc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ static int tilcdc_unload(struct drm_device *dev)
return 0;
}

static size_t tilcdc_num_regs(void);

static int tilcdc_load(struct drm_device *dev, unsigned long flags)
{
struct platform_device *pdev = dev->platformdev;
Expand All @@ -228,11 +226,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
int ret;

priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL);
if (priv)
priv->saved_register =
devm_kcalloc(dev->dev, tilcdc_num_regs(),
sizeof(*priv->saved_register), GFP_KERNEL);
if (!priv || !priv->saved_register) {
if (!priv) {
dev_err(dev->dev, "failed to allocate private data\n");
return -ENOMEM;
}
Expand Down Expand Up @@ -444,7 +438,7 @@ static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
return;
}

#if defined(CONFIG_DEBUG_FS) || defined(CONFIG_PM_SLEEP)
#if defined(CONFIG_DEBUG_FS)
static const struct {
const char *name;
uint8_t rev;
Expand Down Expand Up @@ -475,15 +469,6 @@ static const struct {
#undef REG
};

static size_t tilcdc_num_regs(void)
{
return ARRAY_SIZE(registers);
}
#else
static size_t tilcdc_num_regs(void)
{
return 0;
}
#endif

#ifdef CONFIG_DEBUG_FS
Expand Down Expand Up @@ -617,55 +602,28 @@ static int tilcdc_pm_suspend(struct device *dev)
{
struct drm_device *ddev = dev_get_drvdata(dev);
struct tilcdc_drm_private *priv = ddev->dev_private;
unsigned i, n = 0;

drm_kms_helper_poll_disable(ddev);
priv->saved_state = drm_atomic_helper_suspend(ddev);

/* Select sleep pin state */
pinctrl_pm_select_sleep_state(dev);

if (pm_runtime_suspended(dev)) {
priv->ctx_valid = false;
return 0;
}

/* Disable the LCDC controller, to avoid locking up the PRCM */
priv->saved_dpms_state = tilcdc_crtc_current_dpms_state(priv->crtc);
tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF);

/* Save register state: */
for (i = 0; i < ARRAY_SIZE(registers); i++)
if (registers[i].save && (priv->rev >= registers[i].rev))
priv->saved_register[n++] = tilcdc_read(ddev, registers[i].reg);

priv->ctx_valid = true;

return 0;
}

static int tilcdc_pm_resume(struct device *dev)
{
struct drm_device *ddev = dev_get_drvdata(dev);
struct tilcdc_drm_private *priv = ddev->dev_private;
unsigned i, n = 0;
int ret = 0;

/* Select default pin state */
pinctrl_pm_select_default_state(dev);

if (priv->ctx_valid == true) {
/* Restore register state: */
for (i = 0; i < ARRAY_SIZE(registers); i++)
if (registers[i].save &&
(priv->rev >= registers[i].rev))
tilcdc_write(ddev, registers[i].reg,
priv->saved_register[n++]);
if (priv->saved_state)
ret = drm_atomic_helper_resume(ddev, priv->saved_state);

tilcdc_crtc_dpms(priv->crtc, priv->saved_dpms_state);
}

drm_kms_helper_poll_enable(ddev);

return 0;
return ret;
}
#endif

Expand Down
6 changes: 2 additions & 4 deletions drivers/gpu/drm/tilcdc/tilcdc_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ struct tilcdc_drm_private {
*/
uint32_t max_width;

/* register contents saved across suspend/resume: */
u32 *saved_register;
int saved_dpms_state;
bool ctx_valid;
/* The context for pm susped/resume cycle is stored here */
struct drm_atomic_state *saved_state;

#ifdef CONFIG_CPU_FREQ
struct notifier_block freq_transition;
Expand Down

0 comments on commit 91df99d

Please sign in to comment.