* [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver
@ 2015-06-05 18:55 Sergey Kiselev
2015-06-08 9:23 ` Charles Keepax
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sergey Kiselev @ 2015-06-05 18:55 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel, Lars-Peter Clausen, patches, Liam Girdwood,
Charles Keepax, Richard Fitzgerald
From: Sergey Kiselev <sergey.kiselev@intel.com>
This patch moves the requesting supplies, hardware reset and
initialization from wm8731_probe to wm8731_i2c_probe and wm8731_spi_probe.
So that the codec hardware is initialized when loading the codec driver,
and not when loading the machine driver. This avoids unnecesary hardware
resets and re-initializations when re-loading the machine driver.
Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
---
sound/soc/codecs/wm8731.c | 74 +++++++++++++++++++++++++++--------------------
1 file changed, 42 insertions(+), 32 deletions(-)
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 915ea11..f22935a 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -84,7 +84,7 @@ static bool wm8731_writeable(struct device *dev, unsigned int reg)
return reg <= WM8731_RESET;
}
-#define wm8731_reset(c) snd_soc_write(c, WM8731_RESET, 0)
+#define wm8731_reset(m) regmap_write(m, WM8731_RESET, 0)
static const char *wm8731_input_select[] = {"Line In", "Mic"};
@@ -571,69 +571,63 @@ static struct snd_soc_dai_driver wm8731_dai = {
.symmetric_rates = 1,
};
-static int wm8731_probe(struct snd_soc_codec *codec)
+static int wm8731_request_supplies(struct device *dev,
+ struct wm8731_priv *wm8731)
{
- struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
int ret = 0, i;
for (i = 0; i < ARRAY_SIZE(wm8731->supplies); i++)
wm8731->supplies[i].supply = wm8731_supply_names[i];
- ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8731->supplies),
+ ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8731->supplies),
wm8731->supplies);
if (ret != 0) {
- dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
+ dev_err(dev, "Failed to request supplies: %d\n", ret);
return ret;
}
ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies),
wm8731->supplies);
if (ret != 0) {
- dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
+ dev_err(dev, "Failed to enable supplies: %d\n", ret);
return ret;
}
- ret = wm8731_reset(codec);
+ return 0;
+}
+
+static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
+{
+ int ret = 0;
+
+ ret = wm8731_reset(wm8731->regmap);
if (ret < 0) {
- dev_err(codec->dev, "Failed to issue reset: %d\n", ret);
+ dev_err(dev, "Failed to issue reset: %d\n", ret);
goto err_regulator_enable;
}
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY);
+ /* Clear POWEROFF, keep everything else disabled */
+ regmap_write(wm8731->regmap, WM8731_PWR, 0x7f);
/* Latch the update bits */
- snd_soc_update_bits(codec, WM8731_LOUT1V, 0x100, 0);
- snd_soc_update_bits(codec, WM8731_ROUT1V, 0x100, 0);
- snd_soc_update_bits(codec, WM8731_LINVOL, 0x100, 0);
- snd_soc_update_bits(codec, WM8731_RINVOL, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_LOUT1V, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_ROUT1V, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_LINVOL, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_RINVOL, 0x100, 0);
/* Disable bypass path by default */
- snd_soc_update_bits(codec, WM8731_APANA, 0x8, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_APANA, 0x8, 0);
- /* Regulators will have been enabled by bias management */
- regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
-
- return 0;
+ regcache_mark_dirty(wm8731->regmap);
err_regulator_enable:
+ /* Regulators will be enabled by bias management */
regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
return ret;
}
-/* power down chip */
-static int wm8731_remove(struct snd_soc_codec *codec)
-{
- struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
-
- regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
-
- return 0;
-}
-
static struct snd_soc_codec_driver soc_codec_dev_wm8731 = {
- .probe = wm8731_probe,
- .remove = wm8731_remove,
.set_bias_level = wm8731_set_bias_level,
.suspend_bias_off = true,
@@ -690,6 +684,12 @@ static int wm8731_spi_probe(struct spi_device *spi)
mutex_init(&wm8731->lock);
+ spi_set_drvdata(spi, wm8731);
+
+ ret = wm8731_request_supplies(&spi->dev, wm8731);
+ if (ret != 0)
+ return ret;
+
wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
if (IS_ERR(wm8731->regmap)) {
ret = PTR_ERR(wm8731->regmap);
@@ -698,7 +698,9 @@ static int wm8731_spi_probe(struct spi_device *spi)
return ret;
}
- spi_set_drvdata(spi, wm8731);
+ ret = wm8731_hw_init(&spi->dev, wm8731);
+ if (ret != 0)
+ return ret;
ret = snd_soc_register_codec(&spi->dev,
&soc_codec_dev_wm8731, &wm8731_dai, 1);
@@ -754,6 +756,12 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
mutex_init(&wm8731->lock);
+ i2c_set_clientdata(i2c, wm8731);
+
+ ret = wm8731_request_supplies(&i2c->dev, wm8731);
+ if (ret != 0)
+ return ret;
+
wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
if (IS_ERR(wm8731->regmap)) {
ret = PTR_ERR(wm8731->regmap);
@@ -762,7 +770,9 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
return ret;
}
- i2c_set_clientdata(i2c, wm8731);
+ ret = wm8731_hw_init(&i2c->dev, wm8731);
+ if (ret != 0)
+ return ret;
ret = snd_soc_register_codec(&i2c->dev,
&soc_codec_dev_wm8731, &wm8731_dai, 1);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver
2015-06-05 18:55 [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver Sergey Kiselev
@ 2015-06-08 9:23 ` Charles Keepax
2015-06-08 18:01 ` Mark Brown
2015-07-07 13:58 ` Applied "ASoC: wm8731: initialize the hardware when loading the codec driver" to the asoc tree Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2015-06-08 9:23 UTC (permalink / raw)
To: Sergey Kiselev
Cc: alsa-devel, Lars-Peter Clausen, patches, Liam Girdwood,
Mark Brown, Richard Fitzgerald
On Fri, Jun 05, 2015 at 11:55:27AM -0700, Sergey Kiselev wrote:
> From: Sergey Kiselev <sergey.kiselev@intel.com>
>
> This patch moves the requesting supplies, hardware reset and
> initialization from wm8731_probe to wm8731_i2c_probe and wm8731_spi_probe.
> So that the codec hardware is initialized when loading the codec driver,
> and not when loading the machine driver. This avoids unnecesary hardware
> resets and re-initializations when re-loading the machine driver.
>
> Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
> ---
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver
2015-06-05 18:55 [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver Sergey Kiselev
2015-06-08 9:23 ` Charles Keepax
@ 2015-06-08 18:01 ` Mark Brown
2015-06-08 19:34 ` Sergey Kiselev
2015-07-07 13:58 ` Applied "ASoC: wm8731: initialize the hardware when loading the codec driver" to the asoc tree Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2015-06-08 18:01 UTC (permalink / raw)
To: Sergey Kiselev
Cc: alsa-devel, Lars-Peter Clausen, patches, Liam Girdwood,
Charles Keepax, Richard Fitzgerald
[-- Attachment #1.1: Type: text/plain, Size: 331 bytes --]
On Fri, Jun 05, 2015 at 11:55:27AM -0700, Sergey Kiselev wrote:
> From: Sergey Kiselev <sergey.kiselev@intel.com>
>
> This patch moves the requesting supplies, hardware reset and
> initialization from wm8731_probe to wm8731_i2c_probe and wm8731_spi_probe.
This doesn't apply against current code, please check and resend.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver
2015-06-08 18:01 ` Mark Brown
@ 2015-06-08 19:34 ` Sergey Kiselev
2015-07-07 11:53 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Sergey Kiselev @ 2015-06-08 19:34 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel, Lars-Peter Clausen, patches, Liam Girdwood,
Charles Keepax, Richard Fitzgerald
On Mon, 8 Jun 2015 19:01:55 +0100
Mark Brown <broonie@kernel.org> wrote:
> On Fri, Jun 05, 2015 at 11:55:27AM -0700, Sergey Kiselev wrote:
> > From: Sergey Kiselev <sergey.kiselev@intel.com>
> >
> > This patch moves the requesting supplies, hardware reset and
> > initialization from wm8731_probe to wm8731_i2c_probe and wm8731_spi_probe.
>
> This doesn't apply against current code, please check and resend.
Weird. Works for me. I am using
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
for-next branch.
--
Sergey
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver
2015-06-08 19:34 ` Sergey Kiselev
@ 2015-07-07 11:53 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-07-07 11:53 UTC (permalink / raw)
To: Sergey Kiselev
Cc: alsa-devel, Lars-Peter Clausen, patches, Liam Girdwood,
Charles Keepax, Richard Fitzgerald
[-- Attachment #1.1: Type: text/plain, Size: 335 bytes --]
On Mon, Jun 08, 2015 at 12:34:50PM -0700, Sergey Kiselev wrote:
> Mark Brown <broonie@kernel.org> wrote:
> > This doesn't apply against current code, please check and resend.
> Weird. Works for me. I am using
> git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
> for-next branch.
Please note the "and resend" above...
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Applied "ASoC: wm8731: initialize the hardware when loading the codec driver" to the asoc tree
2015-06-05 18:55 [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver Sergey Kiselev
2015-06-08 9:23 ` Charles Keepax
2015-06-08 18:01 ` Mark Brown
@ 2015-07-07 13:58 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-07-07 13:58 UTC (permalink / raw)
To: Sergey Kiselev, Mark Brown; +Cc: alsa-devel
The patch
ASoC: wm8731: initialize the hardware when loading the codec driver
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 6702dfcc571d962df499f7466f54e07d044e6cd1 Mon Sep 17 00:00:00 2001
From: Sergey Kiselev <sergey.kiselev@intel.com>
Date: Fri, 5 Jun 2015 11:55:27 -0700
Subject: [PATCH] ASoC: wm8731: initialize the hardware when loading the codec
driver
This patch moves the requesting supplies, hardware reset and
initialization from wm8731_probe to wm8731_i2c_probe and wm8731_spi_probe.
So that the codec hardware is initialized when loading the codec driver,
and not when loading the machine driver. This avoids unnecesary hardware
resets and re-initializations when re-loading the machine driver.
Signed-off-by: Sergey Kiselev <sergey.kiselev@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/wm8731.c | 74 +++++++++++++++++++++++++++--------------------
1 file changed, 42 insertions(+), 32 deletions(-)
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 915ea11..f22935a 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -84,7 +84,7 @@ static bool wm8731_writeable(struct device *dev, unsigned int reg)
return reg <= WM8731_RESET;
}
-#define wm8731_reset(c) snd_soc_write(c, WM8731_RESET, 0)
+#define wm8731_reset(m) regmap_write(m, WM8731_RESET, 0)
static const char *wm8731_input_select[] = {"Line In", "Mic"};
@@ -571,69 +571,63 @@ static struct snd_soc_dai_driver wm8731_dai = {
.symmetric_rates = 1,
};
-static int wm8731_probe(struct snd_soc_codec *codec)
+static int wm8731_request_supplies(struct device *dev,
+ struct wm8731_priv *wm8731)
{
- struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
int ret = 0, i;
for (i = 0; i < ARRAY_SIZE(wm8731->supplies); i++)
wm8731->supplies[i].supply = wm8731_supply_names[i];
- ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8731->supplies),
+ ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8731->supplies),
wm8731->supplies);
if (ret != 0) {
- dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
+ dev_err(dev, "Failed to request supplies: %d\n", ret);
return ret;
}
ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies),
wm8731->supplies);
if (ret != 0) {
- dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
+ dev_err(dev, "Failed to enable supplies: %d\n", ret);
return ret;
}
- ret = wm8731_reset(codec);
+ return 0;
+}
+
+static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
+{
+ int ret = 0;
+
+ ret = wm8731_reset(wm8731->regmap);
if (ret < 0) {
- dev_err(codec->dev, "Failed to issue reset: %d\n", ret);
+ dev_err(dev, "Failed to issue reset: %d\n", ret);
goto err_regulator_enable;
}
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY);
+ /* Clear POWEROFF, keep everything else disabled */
+ regmap_write(wm8731->regmap, WM8731_PWR, 0x7f);
/* Latch the update bits */
- snd_soc_update_bits(codec, WM8731_LOUT1V, 0x100, 0);
- snd_soc_update_bits(codec, WM8731_ROUT1V, 0x100, 0);
- snd_soc_update_bits(codec, WM8731_LINVOL, 0x100, 0);
- snd_soc_update_bits(codec, WM8731_RINVOL, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_LOUT1V, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_ROUT1V, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_LINVOL, 0x100, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_RINVOL, 0x100, 0);
/* Disable bypass path by default */
- snd_soc_update_bits(codec, WM8731_APANA, 0x8, 0);
+ regmap_update_bits(wm8731->regmap, WM8731_APANA, 0x8, 0);
- /* Regulators will have been enabled by bias management */
- regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
-
- return 0;
+ regcache_mark_dirty(wm8731->regmap);
err_regulator_enable:
+ /* Regulators will be enabled by bias management */
regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
return ret;
}
-/* power down chip */
-static int wm8731_remove(struct snd_soc_codec *codec)
-{
- struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
-
- regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
-
- return 0;
-}
-
static struct snd_soc_codec_driver soc_codec_dev_wm8731 = {
- .probe = wm8731_probe,
- .remove = wm8731_remove,
.set_bias_level = wm8731_set_bias_level,
.suspend_bias_off = true,
@@ -690,6 +684,12 @@ static int wm8731_spi_probe(struct spi_device *spi)
mutex_init(&wm8731->lock);
+ spi_set_drvdata(spi, wm8731);
+
+ ret = wm8731_request_supplies(&spi->dev, wm8731);
+ if (ret != 0)
+ return ret;
+
wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
if (IS_ERR(wm8731->regmap)) {
ret = PTR_ERR(wm8731->regmap);
@@ -698,7 +698,9 @@ static int wm8731_spi_probe(struct spi_device *spi)
return ret;
}
- spi_set_drvdata(spi, wm8731);
+ ret = wm8731_hw_init(&spi->dev, wm8731);
+ if (ret != 0)
+ return ret;
ret = snd_soc_register_codec(&spi->dev,
&soc_codec_dev_wm8731, &wm8731_dai, 1);
@@ -754,6 +756,12 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
mutex_init(&wm8731->lock);
+ i2c_set_clientdata(i2c, wm8731);
+
+ ret = wm8731_request_supplies(&i2c->dev, wm8731);
+ if (ret != 0)
+ return ret;
+
wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
if (IS_ERR(wm8731->regmap)) {
ret = PTR_ERR(wm8731->regmap);
@@ -762,7 +770,9 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
return ret;
}
- i2c_set_clientdata(i2c, wm8731);
+ ret = wm8731_hw_init(&i2c->dev, wm8731);
+ if (ret != 0)
+ return ret;
ret = snd_soc_register_codec(&i2c->dev,
&soc_codec_dev_wm8731, &wm8731_dai, 1);
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-07-07 13:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05 18:55 [PATCH v2] ASoC: wm8731: initialize the hardware when loading the codec driver Sergey Kiselev
2015-06-08 9:23 ` Charles Keepax
2015-06-08 18:01 ` Mark Brown
2015-06-08 19:34 ` Sergey Kiselev
2015-07-07 11:53 ` Mark Brown
2015-07-07 13:58 ` Applied "ASoC: wm8731: initialize the hardware when loading the codec driver" to the asoc tree Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox