Skip to content

Commit

Permalink
mfd: intel-lpss: Save register context on suspend
Browse files Browse the repository at this point in the history
All configurations are lost and the registers will have
default values when the hardware is suspended and resumed,
so saving the private register space context on suspend, and
restoring it on resume.

Fixes: 4b45efe (mfd: Add support for Intel Sunrisepoint LPSS devices)
Cc: stable@vger.kernel.org # v4.3+
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Heikki Krogerus authored and Lee Jones committed May 9, 2016
1 parent 0e10d54 commit 41a3da2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion drivers/mfd/intel-lpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define LPSS_DEV_SIZE 0x200
#define LPSS_PRIV_OFFSET 0x200
#define LPSS_PRIV_SIZE 0x100
#define LPSS_PRIV_REG_COUNT (LPSS_PRIV_SIZE / 4)
#define LPSS_IDMA64_OFFSET 0x800
#define LPSS_IDMA64_SIZE 0x800

Expand Down Expand Up @@ -76,6 +77,7 @@ struct intel_lpss {
struct mfd_cell *cell;
struct device *dev;
void __iomem *priv;
u32 priv_ctx[LPSS_PRIV_REG_COUNT];
int devid;
u32 caps;
u32 active_ltr;
Expand Down Expand Up @@ -493,15 +495,30 @@ EXPORT_SYMBOL_GPL(intel_lpss_prepare);

int intel_lpss_suspend(struct device *dev)
{
struct intel_lpss *lpss = dev_get_drvdata(dev);
unsigned int i;

/* Save device context */
for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
lpss->priv_ctx[i] = readl(lpss->priv + i * 4);

/* Put the device into reset state */
writel(0, lpss->priv + LPSS_PRIV_RESETS);

return 0;
}
EXPORT_SYMBOL_GPL(intel_lpss_suspend);

int intel_lpss_resume(struct device *dev)
{
struct intel_lpss *lpss = dev_get_drvdata(dev);
unsigned int i;

intel_lpss_init_dev(lpss);
intel_lpss_deassert_reset(lpss);

/* Restore device context */
for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
writel(lpss->priv_ctx[i], lpss->priv + i * 4);

return 0;
}
Expand Down

0 comments on commit 41a3da2

Please sign in to comment.