aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8960.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8960.c')
-rw-r--r--sound/soc/codecs/wm8960.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 499604f1e178..0d167238a369 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -14,6 +14,7 @@
#include <linux/pm.h>
#include <linux/clk.h>
#include <linux/i2c.h>
+#include <linux/acpi.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
@@ -45,6 +46,8 @@
#define WM8960_DISOP 0x40
#define WM8960_DRES_MASK 0x30
+#define WM8960_DSCH_TOUT 600 /* discharge timeout, ms */
+
static bool is_pll_freq_available(unsigned int source, unsigned int target);
static int wm8960_set_pll(struct snd_soc_component *component,
unsigned int freq_in, unsigned int freq_out);
@@ -133,6 +136,7 @@ struct wm8960_priv {
int freq_in;
bool is_stream_in_use[2];
struct wm8960_data pdata;
+ ktime_t dsch_start;
};
#define wm8960_reset(c) regmap_write(c, WM8960_RESET, 0)
@@ -898,6 +902,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
u16 pm2 = snd_soc_component_read(component, WM8960_POWER2);
int ret;
+ ktime_t tout;
switch (level) {
case SND_SOC_BIAS_ON:
@@ -944,6 +949,11 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
case SND_SOC_BIAS_STANDBY:
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
+ /* ensure discharge is complete */
+ tout = WM8960_DSCH_TOUT - ktime_ms_delta(ktime_get(), wm8960->dsch_start);
+ if (tout > 0)
+ msleep(tout);
+
regcache_sync(wm8960->regmap);
/* Enable anti-pop features */
@@ -973,9 +983,9 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN | WM8960_BUFIOEN);
- /* Disable VMID and VREF, let them discharge */
+ /* Disable VMID and VREF, mark discharge */
snd_soc_component_write(component, WM8960_POWER1, 0);
- msleep(600);
+ wm8960->dsch_start = ktime_get();
break;
}
@@ -1368,7 +1378,6 @@ static const struct snd_soc_component_driver soc_component_dev_wm8960 = {
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
- .non_legacy_dai_naming = 1,
};
static const struct regmap_config wm8960_regmap = {
@@ -1401,8 +1410,7 @@ static void wm8960_set_pdata_from_of(struct i2c_client *i2c,
ARRAY_SIZE(pdata->hp_cfg));
}
-static int wm8960_i2c_probe(struct i2c_client *i2c,
- const struct i2c_device_id *id)
+static int wm8960_i2c_probe(struct i2c_client *i2c)
{
struct wm8960_data *pdata = dev_get_platdata(&i2c->dev);
struct wm8960_priv *wm8960;
@@ -1478,10 +1486,8 @@ static int wm8960_i2c_probe(struct i2c_client *i2c,
return ret;
}
-static int wm8960_i2c_remove(struct i2c_client *client)
-{
- return 0;
-}
+static void wm8960_i2c_remove(struct i2c_client *client)
+{}
static const struct i2c_device_id wm8960_i2c_id[] = {
{ "wm8960", 0 },
@@ -1489,18 +1495,30 @@ static const struct i2c_device_id wm8960_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, wm8960_i2c_id);
+#if defined(CONFIG_OF)
static const struct of_device_id wm8960_of_match[] = {
{ .compatible = "wlf,wm8960", },
{ }
};
MODULE_DEVICE_TABLE(of, wm8960_of_match);
+#endif
+
+#if defined(CONFIG_ACPI)
+static const struct acpi_device_id wm8960_acpi_match[] = {
+ { "1AEC8960", 0 }, /* Wolfson PCI ID + part ID */
+ { "10138960", 0 }, /* Cirrus Logic PCI ID + part ID */
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, wm8960_acpi_match);
+#endif
static struct i2c_driver wm8960_i2c_driver = {
.driver = {
.name = "wm8960",
- .of_match_table = wm8960_of_match,
+ .of_match_table = of_match_ptr(wm8960_of_match),
+ .acpi_match_table = ACPI_PTR(wm8960_acpi_match),
},
- .probe = wm8960_i2c_probe,
+ .probe_new = wm8960_i2c_probe,
.remove = wm8960_i2c_remove,
.id_table = wm8960_i2c_id,
};