Skip to content

Commit

Permalink
ASoC: nau8825: add pm function
Browse files Browse the repository at this point in the history
This patch adds pm function and fixes following issues
1.i2c timeout after resume, after resume we saw interrupt handler
is called prior to i2c controller is resumed.This causes i2c timeout
2.no audio after resume

Signed-off-by: Fang, Yang A <[email protected]>
Signed-off-by: Yong Zhi <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
yongzhi1 authored and broonie committed Nov 16, 2015
1 parent 8005c49 commit 4454a83
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions sound/soc/codecs/nau8825.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,36 @@ static int nau8825_i2c_remove(struct i2c_client *client)
return 0;
}

#ifdef CONFIG_PM_SLEEP
static int nau8825_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct nau8825 *nau8825 = dev_get_drvdata(dev);

disable_irq(client->irq);
regcache_cache_only(nau8825->regmap, true);
regcache_mark_dirty(nau8825->regmap);

return 0;
}

static int nau8825_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct nau8825 *nau8825 = dev_get_drvdata(dev);

regcache_cache_only(nau8825->regmap, false);
regcache_sync(nau8825->regmap);
enable_irq(client->irq);

return 0;
}
#endif

static const struct dev_pm_ops nau8825_pm = {
SET_SYSTEM_SLEEP_PM_OPS(nau8825_suspend, nau8825_resume)
};

static const struct i2c_device_id nau8825_i2c_ids[] = {
{ "nau8825", 0 },
{ }
Expand All @@ -1297,6 +1327,7 @@ static struct i2c_driver nau8825_driver = {
.name = "nau8825",
.of_match_table = of_match_ptr(nau8825_of_ids),
.acpi_match_table = ACPI_PTR(nau8825_acpi_match),
.pm = &nau8825_pm,
},
.probe = nau8825_i2c_probe,
.remove = nau8825_i2c_remove,
Expand Down

0 comments on commit 4454a83

Please sign in to comment.