* [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function
@ 2014-02-19 13:05 Daniel Mack
2014-02-19 16:08 ` Austin, Brian
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Daniel Mack @ 2014-02-19 13:05 UTC (permalink / raw)
To: broonie, subaparts; +Cc: brian.austin, alsa-devel, Paul.Handrigan, Daniel Mack
Move the GPIO acquisition from the codec to the bus probe functions.
Signed-off-by: Daniel Mack <zonque@gmail.com>
---
sound/soc/codecs/cs4271.c | 60 +++++++++++++++++++++++++++++++----------------
1 file changed, 40 insertions(+), 20 deletions(-)
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index ce05fd9..6bfe021 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -540,14 +540,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
struct cs4271_platform_data *cs4271plat = codec->dev->platform_data;
int ret;
- int gpio_nreset = -EINVAL;
bool amutec_eq_bmutec = false;
#ifdef CONFIG_OF
if (of_match_device(cs4271_dt_ids, codec->dev)) {
- gpio_nreset = of_get_named_gpio(codec->dev->of_node,
- "reset-gpio", 0);
-
if (of_get_property(codec->dev->of_node,
"cirrus,amutec-eq-bmutec", NULL))
amutec_eq_bmutec = true;
@@ -559,27 +555,19 @@ static int cs4271_probe(struct snd_soc_codec *codec)
#endif
if (cs4271plat) {
- if (gpio_is_valid(cs4271plat->gpio_nreset))
- gpio_nreset = cs4271plat->gpio_nreset;
-
amutec_eq_bmutec = cs4271plat->amutec_eq_bmutec;
cs4271->enable_soft_reset = cs4271plat->enable_soft_reset;
}
- if (gpio_nreset >= 0)
- if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
- gpio_nreset = -EINVAL;
- if (gpio_nreset >= 0) {
+ if (gpio_is_valid(cs4271->gpio_nreset)) {
/* Reset codec */
- gpio_direction_output(gpio_nreset, 0);
+ gpio_direction_output(cs4271->gpio_nreset, 0);
udelay(1);
- gpio_set_value(gpio_nreset, 1);
+ gpio_set_value(cs4271->gpio_nreset, 1);
/* Give the codec time to wake up */
udelay(1);
}
- cs4271->gpio_nreset = gpio_nreset;
-
ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
CS4271_MODE2_PDN | CS4271_MODE2_CPEN,
CS4271_MODE2_PDN | CS4271_MODE2_CPEN);
@@ -641,14 +629,45 @@ static const struct regmap_config cs4271_spi_regmap = {
.volatile_reg = cs4271_volatile_reg,
};
-static int cs4271_spi_probe(struct spi_device *spi)
+static int cs4271_common_probe(struct device *dev,
+ struct cs4271_private **c)
{
+ struct cs4271_platform_data *cs4271plat = dev->platform_data;
struct cs4271_private *cs4271;
- cs4271 = devm_kzalloc(&spi->dev, sizeof(*cs4271), GFP_KERNEL);
+ cs4271 = devm_kzalloc(dev, sizeof(*cs4271), GFP_KERNEL);
if (!cs4271)
return -ENOMEM;
+ if (of_match_device(cs4271_dt_ids, dev))
+ cs4271->gpio_nreset =
+ of_get_named_gpio(dev->of_node, "reset-gpio", 0);
+
+ if (cs4271plat)
+ cs4271->gpio_nreset = cs4271plat->gpio_nreset;
+
+ if (gpio_is_valid(cs4271->gpio_nreset)) {
+ int ret;
+
+ ret = devm_gpio_request(dev, cs4271->gpio_nreset,
+ "CS4271 Reset");
+ if (ret < 0)
+ return ret;
+ }
+
+ *c = cs4271;
+ return 0;
+}
+
+static int cs4271_spi_probe(struct spi_device *spi)
+{
+ struct cs4271_private *cs4271;
+ int ret;
+
+ ret = cs4271_common_probe(&spi->dev, &cs4271);
+ if (ret < 0)
+ return ret;
+
spi_set_drvdata(spi, cs4271);
cs4271->regmap = devm_regmap_init_spi(spi, &cs4271_spi_regmap);
if (IS_ERR(cs4271->regmap))
@@ -698,10 +717,11 @@ static int cs4271_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct cs4271_private *cs4271;
+ int ret;
- cs4271 = devm_kzalloc(&client->dev, sizeof(*cs4271), GFP_KERNEL);
- if (!cs4271)
- return -ENOMEM;
+ ret = cs4271_common_probe(&client->dev, &cs4271);
+ if (ret < 0)
+ return ret;
i2c_set_clientdata(client, cs4271);
cs4271->regmap = devm_regmap_init_i2c(client, &cs4271_i2c_regmap);
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function
2014-02-19 13:05 [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function Daniel Mack
@ 2014-02-19 16:08 ` Austin, Brian
2014-02-19 16:17 ` Daniel Mack
2014-02-19 16:30 ` Austin, Brian
2014-02-19 16:36 ` Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Austin, Brian @ 2014-02-19 16:08 UTC (permalink / raw)
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
subaparts@yandex.ru, Handrigan, Paul, Daniel Mack
> On Feb 19, 2014, at 7:06, "Daniel Mack" <zonque@gmail.com> wrote:
>
> Move the GPIO acquisition from the codec to the bus probe functions.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> ---
> sound/soc/codecs/cs4271.c | 60 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 40 insertions(+), 20 deletions(-)
>
> diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
> index ce05fd9..6bfe021 100644
> --- a/sound/soc/codecs/cs4271.c
> +++ b/sound/soc/codecs/cs4271.c
> @@ -540,14 +540,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
> struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
> struct cs4271_platform_data *cs4271plat = codec->dev->platform_data;
> int ret;
> - int gpio_nreset = -EINVAL;
> bool amutec_eq_bmutec = false;
>
> #ifdef CONFIG_OF
> if (of_match_device(cs4271_dt_ids, codec->dev)) {
> - gpio_nreset = of_get_named_gpio(codec->dev->of_node,
> - "reset-gpio", 0);
> -
> if (of_get_property(codec->dev->of_node,
> "cirrus,amutec-eq-bmutec", NULL))
> amutec_eq_bmutec = true;
> @@ -559,27 +555,19 @@ static int cs4271_probe(struct snd_soc_codec *codec)
> #endif
>
> if (cs4271plat) {
> - if (gpio_is_valid(cs4271plat->gpio_nreset))
> - gpio_nreset = cs4271plat->gpio_nreset;
> -
> amutec_eq_bmutec = cs4271plat->amutec_eq_bmutec;
> cs4271->enable_soft_reset = cs4271plat->enable_soft_reset;
> }
>
> - if (gpio_nreset >= 0)
> - if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
> - gpio_nreset = -EINVAL;
> - if (gpio_nreset >= 0) {
> + if (gpio_is_valid(cs4271->gpio_nreset)) {
> /* Reset codec */
> - gpio_direction_output(gpio_nreset, 0);
> + gpio_direction_output(cs4271->gpio_nreset, 0);
> udelay(1);
> - gpio_set_value(gpio_nreset, 1);
> + gpio_set_value(cs4271->gpio_nreset, 1);
> /* Give the codec time to wake up */
> udelay(1);
> }
>
Since your moving all the GPIO reset code into a new function that's called from the bus probes why not put the reset in there as well?
> - cs4271->gpio_nreset = gpio_nreset;
> -
> ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
> CS4271_MODE2_PDN | CS4271_MODE2_CPEN,
> CS4271_MODE2_PDN | CS4271_MODE2_CPEN);
> @@ -641,14 +629,45 @@ static const struct regmap_config cs4271_spi_regmap = {
> .volatile_reg = cs4271_volatile_reg,
> };
>
> -static int cs4271_spi_probe(struct spi_device *spi)
> +static int cs4271_common_probe(struct device *dev,
> + struct cs4271_private **c)
> {
> + struct cs4271_platform_data *cs4271plat = dev->platform_data;
> struct cs4271_private *cs4271;
>
> - cs4271 = devm_kzalloc(&spi->dev, sizeof(*cs4271), GFP_KERNEL);
> + cs4271 = devm_kzalloc(dev, sizeof(*cs4271), GFP_KERNEL);
> if (!cs4271)
> return -ENOMEM;
>
> + if (of_match_device(cs4271_dt_ids, dev))
> + cs4271->gpio_nreset =
> + of_get_named_gpio(dev->of_node, "reset-gpio", 0);
> +
> + if (cs4271plat)
> + cs4271->gpio_nreset = cs4271plat->gpio_nreset;
> +
> + if (gpio_is_valid(cs4271->gpio_nreset)) {
> + int ret;
> +
> + ret = devm_gpio_request(dev, cs4271->gpio_nreset,
> + "CS4271 Reset");
> + if (ret < 0)
> + return ret;
> + }
> +
> + *c = cs4271;
> + return 0;
> +}
> +
> +static int cs4271_spi_probe(struct spi_device *spi)
> +{
> + struct cs4271_private *cs4271;
> + int ret;
> +
> + ret = cs4271_common_probe(&spi->dev, &cs4271);
> + if (ret < 0)
> + return ret;
> +
> spi_set_drvdata(spi, cs4271);
> cs4271->regmap = devm_regmap_init_spi(spi, &cs4271_spi_regmap);
> if (IS_ERR(cs4271->regmap))
> @@ -698,10 +717,11 @@ static int cs4271_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> struct cs4271_private *cs4271;
> + int ret;
>
> - cs4271 = devm_kzalloc(&client->dev, sizeof(*cs4271), GFP_KERNEL);
> - if (!cs4271)
> - return -ENOMEM;
> + ret = cs4271_common_probe(&client->dev, &cs4271);
> + if (ret < 0)
> + return ret;
>
> i2c_set_clientdata(client, cs4271);
> cs4271->regmap = devm_regmap_init_i2c(client, &cs4271_i2c_regmap);
> --
> 1.8.5.3
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function
2014-02-19 16:08 ` Austin, Brian
@ 2014-02-19 16:17 ` Daniel Mack
2014-02-19 16:27 ` Austin, Brian
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Mack @ 2014-02-19 16:17 UTC (permalink / raw)
To: Austin, Brian
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
subaparts@yandex.ru, Handrigan, Paul
On 02/19/2014 05:08 PM, Austin, Brian wrote:
>> On Feb 19, 2014, at 7:06, "Daniel Mack" <zonque@gmail.com> wrote:
>> - if (gpio_nreset >= 0)
>> - if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
>> - gpio_nreset = -EINVAL;
>> - if (gpio_nreset >= 0) {
>> + if (gpio_is_valid(cs4271->gpio_nreset)) {
>> /* Reset codec */
>> - gpio_direction_output(gpio_nreset, 0);
>> + gpio_direction_output(cs4271->gpio_nreset, 0);
>> udelay(1);
>> - gpio_set_value(gpio_nreset, 1);
>> + gpio_set_value(cs4271->gpio_nreset, 1);
>> /* Give the codec time to wake up */
>> udelay(1);
>> }
>
> Since your moving all the GPIO reset code into a new function that's
> called from the bus probes why not put the reset in there as well?
Because I want the codec to stay in reset until it is actually used, and
the machine drivers builds the DAI link.
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function
2014-02-19 16:17 ` Daniel Mack
@ 2014-02-19 16:27 ` Austin, Brian
0 siblings, 0 replies; 6+ messages in thread
From: Austin, Brian @ 2014-02-19 16:27 UTC (permalink / raw)
To: Daniel Mack
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
subaparts@yandex.ru, Handrigan, Paul
> On Feb 19, 2014, at 10:17, "Daniel Mack" <daniel@zonque.org> wrote:
>
> On 02/19/2014 05:08 PM, Austin, Brian wrote:
>>> On Feb 19, 2014, at 7:06, "Daniel Mack" <zonque@gmail.com> wrote:
>
>>> - if (gpio_nreset >= 0)
>>> - if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
>>> - gpio_nreset = -EINVAL;
>>> - if (gpio_nreset >= 0) {
>>> + if (gpio_is_valid(cs4271->gpio_nreset)) {
>>> /* Reset codec */
>>> - gpio_direction_output(gpio_nreset, 0);
>>> + gpio_direction_output(cs4271->gpio_nreset, 0);
>>> udelay(1);
>>> - gpio_set_value(gpio_nreset, 1);
>>> + gpio_set_value(cs4271->gpio_nreset, 1);
>>> /* Give the codec time to wake up */
>>> udelay(1);
>>> }
>>
>> Since your moving all the GPIO reset code into a new function that's
>> called from the bus probes why not put the reset in there as well?
>
> Because I want the codec to stay in reset until it is actually used, and
> the machine drivers builds the DAI link.
>
>
> Daniel
Ok, fair enough
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function
2014-02-19 13:05 [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function Daniel Mack
2014-02-19 16:08 ` Austin, Brian
@ 2014-02-19 16:30 ` Austin, Brian
2014-02-19 16:36 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Austin, Brian @ 2014-02-19 16:30 UTC (permalink / raw)
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
subaparts@yandex.ru, Handrigan, Paul, Daniel Mack
> On Feb 19, 2014, at 7:06, "Daniel Mack" <zonque@gmail.com> wrote:
>
> Move the GPIO acquisition from the codec to the bus probe functions.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> ---
Acked-by: Brian Austin <brian.austin@cirrus.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function
2014-02-19 13:05 [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function Daniel Mack
2014-02-19 16:08 ` Austin, Brian
2014-02-19 16:30 ` Austin, Brian
@ 2014-02-19 16:36 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2014-02-19 16:36 UTC (permalink / raw)
To: Daniel Mack; +Cc: brian.austin, subaparts, alsa-devel, Paul.Handrigan
[-- Attachment #1.1: Type: text/plain, Size: 150 bytes --]
On Wed, Feb 19, 2014 at 02:05:54PM +0100, Daniel Mack wrote:
> Move the GPIO acquisition from the codec to the bus probe functions.
Applied, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-19 16:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 13:05 [PATCH] ASoC: cs4271: claim reset GPIO in bus probe function Daniel Mack
2014-02-19 16:08 ` Austin, Brian
2014-02-19 16:17 ` Daniel Mack
2014-02-19 16:27 ` Austin, Brian
2014-02-19 16:30 ` Austin, Brian
2014-02-19 16:36 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox