* [alsa-devel] [PATCH 0/2] ASoC: pcm3168a: Poor man's RST gpio handling @ 2019-11-13 12:47 Peter Ujfalusi 2019-11-13 12:47 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Peter Ujfalusi 2019-11-13 12:47 ` [alsa-devel] [PATCH 2/2] ASoC: pcm3168a: Add support for optional RST gpio handling Peter Ujfalusi 0 siblings, 2 replies; 9+ messages in thread From: Peter Ujfalusi @ 2019-11-13 12:47 UTC (permalink / raw) To: broonie, lgirdwood Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, linux-kernel, robh+dt Hi, when the codec RST input is connected to a GPIO it needs to be pulled high in order to take the pcm3168a out from reset and to make it respond to register accesses via i2c. I have a board where one GPIO line is connected to two pcm3168a codec so runtime handling of the RST gpio is not possible (one codec would place the other codec to reset as well). The only possible solution is to request the gpio with GPIOD_FLAGS_BIT_NONEXCLUSIVE flag, ask it to be high initially and never touch it again. If the optinal GPIO is not described then issue the reset as the driver did. Regards, Peter --- Peter Ujfalusi (2): bindings: sound: pcm3168a: Document optional RST gpio ASoC: pcm3168a: Add support for optional RST gpio handling .../devicetree/bindings/sound/ti,pcm3168a.txt | 7 ++++ sound/soc/codecs/pcm3168a.c | 38 +++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio 2019-11-13 12:47 [alsa-devel] [PATCH 0/2] ASoC: pcm3168a: Poor man's RST gpio handling Peter Ujfalusi @ 2019-11-13 12:47 ` Peter Ujfalusi 2019-11-18 13:08 ` Mark Brown ` (2 more replies) 2019-11-13 12:47 ` [alsa-devel] [PATCH 2/2] ASoC: pcm3168a: Add support for optional RST gpio handling Peter Ujfalusi 1 sibling, 3 replies; 9+ messages in thread From: Peter Ujfalusi @ 2019-11-13 12:47 UTC (permalink / raw) To: broonie, lgirdwood Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, linux-kernel, robh+dt On boards where the RST line is not pulled up, but it is connected to a GPIO line this property must present in order to be able to enable the codec. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> --- Documentation/devicetree/bindings/sound/ti,pcm3168a.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt index 5d9cb84c661d..f30aebc7603a 100644 --- a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt +++ b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt @@ -25,6 +25,12 @@ Required properties: For required properties on SPI/I2C, consult SPI/I2C device tree documentation +Optional properties: + + - rst-gpios : Optional RST gpio line for the codec + RST = low: device power-down + RST = high: device is enabled + Examples: i2c0: i2c0@0 { @@ -34,6 +40,7 @@ i2c0: i2c0@0 { pcm3168a: audio-codec@44 { compatible = "ti,pcm3168a"; reg = <0x44>; + rst-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; clocks = <&clk_core CLK_AUDIO>; clock-names = "scki"; VDD1-supply = <&supply3v3>; -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio 2019-11-13 12:47 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Peter Ujfalusi @ 2019-11-18 13:08 ` Mark Brown 2019-11-18 14:46 ` Peter Ujfalusi 2019-11-18 13:09 ` [alsa-devel] Applied "ASoC: pcm3168a: Document optional RST gpio" to the asoc tree Mark Brown 2019-11-18 21:32 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Rob Herring 2 siblings, 1 reply; 9+ messages in thread From: Mark Brown @ 2019-11-18 13:08 UTC (permalink / raw) To: Peter Ujfalusi Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, lgirdwood, linux-kernel, robh+dt [-- Attachment #1.1: Type: text/plain, Size: 551 bytes --] On Wed, Nov 13, 2019 at 02:47:33PM +0200, Peter Ujfalusi wrote: > On boards where the RST line is not pulled up, but it is connected to a > GPIO line this property must present in order to be able to enable the > codec. Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 161 bytes --] _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio 2019-11-18 13:08 ` Mark Brown @ 2019-11-18 14:46 ` Peter Ujfalusi 2019-11-18 16:01 ` Mark Brown 0 siblings, 1 reply; 9+ messages in thread From: Peter Ujfalusi @ 2019-11-18 14:46 UTC (permalink / raw) To: Mark Brown Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, lgirdwood, linux-kernel, robh+dt Mark, On 18/11/2019 15.08, Mark Brown wrote: > On Wed, Nov 13, 2019 at 02:47:33PM +0200, Peter Ujfalusi wrote: >> On boards where the RST line is not pulled up, but it is connected to a >> GPIO line this property must present in order to be able to enable the >> codec. > > Please submit patches using subject lines reflecting the style for the > subsystem, this makes it easier for people to identify relevant patches. > Look at what existing commits in the area you're changing are doing and > make sure your subject lines visually resemble what they're doing. > There's no need to resubmit to fix this alone. What would be the appropriate subject line for Documentation/devicetree/bindings/sound Oops, I have missed the dt- prefix for the bindings for sure. - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio 2019-11-18 14:46 ` Peter Ujfalusi @ 2019-11-18 16:01 ` Mark Brown 0 siblings, 0 replies; 9+ messages in thread From: Mark Brown @ 2019-11-18 16:01 UTC (permalink / raw) To: Peter Ujfalusi Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, lgirdwood, linux-kernel, robh+dt [-- Attachment #1.1: Type: text/plain, Size: 655 bytes --] On Mon, Nov 18, 2019 at 04:46:26PM +0200, Peter Ujfalusi wrote: > On 18/11/2019 15.08, Mark Brown wrote: > > Please submit patches using subject lines reflecting the style for the > > subsystem, this makes it easier for people to identify relevant patches. > > Look at what existing commits in the area you're changing are doing and > > make sure your subject lines visually resemble what they're doing. > > There's no need to resubmit to fix this alone. > What would be the appropriate subject line for > Documentation/devicetree/bindings/sound > Oops, I have missed the dt- prefix for the bindings for sure. I prefer ASoC: but yeah, you missed dt-. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 161 bytes --] _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* [alsa-devel] Applied "ASoC: pcm3168a: Document optional RST gpio" to the asoc tree 2019-11-13 12:47 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Peter Ujfalusi 2019-11-18 13:08 ` Mark Brown @ 2019-11-18 13:09 ` Mark Brown 2019-11-18 21:32 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Rob Herring 2 siblings, 0 replies; 9+ messages in thread From: Mark Brown @ 2019-11-18 13:09 UTC (permalink / raw) To: Peter Ujfalusi Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, lgirdwood, robh+dt, linux-kernel, Mark Brown The patch ASoC: pcm3168a: Document optional RST gpio has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5 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 cdacc761dae1cbd6475ac79f0e732f2b1ca021e0 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi <peter.ujfalusi@ti.com> Date: Wed, 13 Nov 2019 14:47:33 +0200 Subject: [PATCH] ASoC: pcm3168a: Document optional RST gpio On boards where the RST line is not pulled up, but it is connected to a GPIO line this property must present in order to be able to enable the codec. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Link: https://lore.kernel.org/r/20191113124734.27984-2-peter.ujfalusi@ti.com Signed-off-by: Mark Brown <broonie@kernel.org> --- Documentation/devicetree/bindings/sound/ti,pcm3168a.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt index 5d9cb84c661d..f30aebc7603a 100644 --- a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt +++ b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt @@ -25,6 +25,12 @@ Required properties: For required properties on SPI/I2C, consult SPI/I2C device tree documentation +Optional properties: + + - rst-gpios : Optional RST gpio line for the codec + RST = low: device power-down + RST = high: device is enabled + Examples: i2c0: i2c0@0 { @@ -34,6 +40,7 @@ i2c0: i2c0@0 { pcm3168a: audio-codec@44 { compatible = "ti,pcm3168a"; reg = <0x44>; + rst-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; clocks = <&clk_core CLK_AUDIO>; clock-names = "scki"; VDD1-supply = <&supply3v3>; -- 2.20.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio 2019-11-13 12:47 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Peter Ujfalusi 2019-11-18 13:08 ` Mark Brown 2019-11-18 13:09 ` [alsa-devel] Applied "ASoC: pcm3168a: Document optional RST gpio" to the asoc tree Mark Brown @ 2019-11-18 21:32 ` Rob Herring 2 siblings, 0 replies; 9+ messages in thread From: Rob Herring @ 2019-11-18 21:32 UTC (permalink / raw) To: Peter Ujfalusi Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, lgirdwood, linux-kernel, broonie On Wed, Nov 13, 2019 at 02:47:33PM +0200, Peter Ujfalusi wrote: > On boards where the RST line is not pulled up, but it is connected to a > GPIO line this property must present in order to be able to enable the > codec. > > Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> > --- > Documentation/devicetree/bindings/sound/ti,pcm3168a.txt | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt > index 5d9cb84c661d..f30aebc7603a 100644 > --- a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt > +++ b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt > @@ -25,6 +25,12 @@ Required properties: > > For required properties on SPI/I2C, consult SPI/I2C device tree documentation > > +Optional properties: > + > + - rst-gpios : Optional RST gpio line for the codec > + RST = low: device power-down > + RST = high: device is enabled 'reset-gpios' is the standard naming for reset lines. > + > Examples: > > i2c0: i2c0@0 { > @@ -34,6 +40,7 @@ i2c0: i2c0@0 { > pcm3168a: audio-codec@44 { > compatible = "ti,pcm3168a"; > reg = <0x44>; > + rst-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; > clocks = <&clk_core CLK_AUDIO>; > clock-names = "scki"; > VDD1-supply = <&supply3v3>; > -- > Peter > > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 9+ messages in thread
* [alsa-devel] [PATCH 2/2] ASoC: pcm3168a: Add support for optional RST gpio handling 2019-11-13 12:47 [alsa-devel] [PATCH 0/2] ASoC: pcm3168a: Poor man's RST gpio handling Peter Ujfalusi 2019-11-13 12:47 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Peter Ujfalusi @ 2019-11-13 12:47 ` Peter Ujfalusi 2019-11-18 13:09 ` [alsa-devel] Applied "ASoC: pcm3168a: Add support for optional RST gpio handling" to the asoc tree Mark Brown 1 sibling, 1 reply; 9+ messages in thread From: Peter Ujfalusi @ 2019-11-13 12:47 UTC (permalink / raw) To: broonie, lgirdwood Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, linux-kernel, robh+dt In case the RST line is connected to a GPIO line it needs to be pulled high when the driver probes to be able to use the codec. Add support also for cases when more than one codec is is controlled by the same GPIO line by requesting the gpio with GPIOD_FLAGS_BIT_NONEXCLUSIVE. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> --- asoc: pcm3168a rst --- sound/soc/codecs/pcm3168a.c | 38 +++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c index 313500ab36df..f3475134b519 100644 --- a/sound/soc/codecs/pcm3168a.c +++ b/sound/soc/codecs/pcm3168a.c @@ -9,7 +9,9 @@ #include <linux/clk.h> #include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/of_gpio.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> @@ -59,6 +61,7 @@ struct pcm3168a_priv { struct regulator_bulk_data supplies[PCM3168A_NUM_SUPPLIES]; struct regmap *regmap; struct clk *scki; + struct gpio_desc *gpio_rst; unsigned long sysclk; struct pcm3168a_io_params io_params[2]; @@ -643,6 +646,7 @@ static bool pcm3168a_readable_register(struct device *dev, unsigned int reg) static bool pcm3168a_volatile_register(struct device *dev, unsigned int reg) { switch (reg) { + case PCM3168A_RST_SMODE: case PCM3168A_DAC_ZERO: case PCM3168A_ADC_OV: return true; @@ -702,6 +706,21 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, pcm3168a); + /* + * Request the RST gpio line as non exclusive as the same reset line + * might be connected to multiple pcm3168a codec + */ + pcm3168a->gpio_rst = devm_gpiod_get_optional(dev, "rst", + GPIOD_OUT_HIGH | + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(pcm3168a->gpio_rst)) { + ret = PTR_ERR(pcm3168a->gpio_rst); + if (ret != -EPROBE_DEFER ) + dev_err(dev, "failed to acquire RST gpio: %d\n", ret); + + return ret; + } + pcm3168a->scki = devm_clk_get(dev, "scki"); if (IS_ERR(pcm3168a->scki)) { ret = PTR_ERR(pcm3168a->scki); @@ -743,10 +762,18 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) goto err_regulator; } - ret = pcm3168a_reset(pcm3168a); - if (ret) { - dev_err(dev, "Failed to reset device: %d\n", ret); - goto err_regulator; + if (pcm3168a->gpio_rst) { + /* + * The device is taken out from reset via GPIO line, wait for + * 3846 SCKI clock cycles for the internal reset de-assertion + */ + msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk)); + } else { + ret = pcm3168a_reset(pcm3168a); + if (ret) { + dev_err(dev, "Failed to reset device: %d\n", ret); + goto err_regulator; + } } pm_runtime_set_active(dev); @@ -785,6 +812,9 @@ static void pcm3168a_disable(struct device *dev) void pcm3168a_remove(struct device *dev) { + struct pcm3168a_priv *pcm3168a = dev_get_drvdata(dev); + + gpiod_set_value_cansleep(pcm3168a->gpio_rst, 0); pm_runtime_disable(dev); #ifndef CONFIG_PM pcm3168a_disable(dev); -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [alsa-devel] Applied "ASoC: pcm3168a: Add support for optional RST gpio handling" to the asoc tree 2019-11-13 12:47 ` [alsa-devel] [PATCH 2/2] ASoC: pcm3168a: Add support for optional RST gpio handling Peter Ujfalusi @ 2019-11-18 13:09 ` Mark Brown 0 siblings, 0 replies; 9+ messages in thread From: Mark Brown @ 2019-11-18 13:09 UTC (permalink / raw) To: Peter Ujfalusi Cc: devicetree, alsa-devel, kuninori.morimoto.gx, linus.walleij, lgirdwood, robh+dt, linux-kernel, Mark Brown The patch ASoC: pcm3168a: Add support for optional RST gpio handling has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5 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 79f6c108c87b470aacf25fc25a86f48694d03ae8 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi <peter.ujfalusi@ti.com> Date: Wed, 13 Nov 2019 14:47:34 +0200 Subject: [PATCH] ASoC: pcm3168a: Add support for optional RST gpio handling In case the RST line is connected to a GPIO line it needs to be pulled high when the driver probes to be able to use the codec. Add support also for cases when more than one codec is is controlled by the same GPIO line by requesting the gpio with GPIOD_FLAGS_BIT_NONEXCLUSIVE. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Link: https://lore.kernel.org/r/20191113124734.27984-3-peter.ujfalusi@ti.com Signed-off-by: Mark Brown <broonie@kernel.org> --- sound/soc/codecs/pcm3168a.c | 38 +++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c index 313500ab36df..f3475134b519 100644 --- a/sound/soc/codecs/pcm3168a.c +++ b/sound/soc/codecs/pcm3168a.c @@ -9,7 +9,9 @@ #include <linux/clk.h> #include <linux/delay.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/of_gpio.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> @@ -59,6 +61,7 @@ struct pcm3168a_priv { struct regulator_bulk_data supplies[PCM3168A_NUM_SUPPLIES]; struct regmap *regmap; struct clk *scki; + struct gpio_desc *gpio_rst; unsigned long sysclk; struct pcm3168a_io_params io_params[2]; @@ -643,6 +646,7 @@ static bool pcm3168a_readable_register(struct device *dev, unsigned int reg) static bool pcm3168a_volatile_register(struct device *dev, unsigned int reg) { switch (reg) { + case PCM3168A_RST_SMODE: case PCM3168A_DAC_ZERO: case PCM3168A_ADC_OV: return true; @@ -702,6 +706,21 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, pcm3168a); + /* + * Request the RST gpio line as non exclusive as the same reset line + * might be connected to multiple pcm3168a codec + */ + pcm3168a->gpio_rst = devm_gpiod_get_optional(dev, "rst", + GPIOD_OUT_HIGH | + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(pcm3168a->gpio_rst)) { + ret = PTR_ERR(pcm3168a->gpio_rst); + if (ret != -EPROBE_DEFER ) + dev_err(dev, "failed to acquire RST gpio: %d\n", ret); + + return ret; + } + pcm3168a->scki = devm_clk_get(dev, "scki"); if (IS_ERR(pcm3168a->scki)) { ret = PTR_ERR(pcm3168a->scki); @@ -743,10 +762,18 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) goto err_regulator; } - ret = pcm3168a_reset(pcm3168a); - if (ret) { - dev_err(dev, "Failed to reset device: %d\n", ret); - goto err_regulator; + if (pcm3168a->gpio_rst) { + /* + * The device is taken out from reset via GPIO line, wait for + * 3846 SCKI clock cycles for the internal reset de-assertion + */ + msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk)); + } else { + ret = pcm3168a_reset(pcm3168a); + if (ret) { + dev_err(dev, "Failed to reset device: %d\n", ret); + goto err_regulator; + } } pm_runtime_set_active(dev); @@ -785,6 +812,9 @@ static void pcm3168a_disable(struct device *dev) void pcm3168a_remove(struct device *dev) { + struct pcm3168a_priv *pcm3168a = dev_get_drvdata(dev); + + gpiod_set_value_cansleep(pcm3168a->gpio_rst, 0); pm_runtime_disable(dev); #ifndef CONFIG_PM pcm3168a_disable(dev); -- 2.20.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-11-18 21:33 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-11-13 12:47 [alsa-devel] [PATCH 0/2] ASoC: pcm3168a: Poor man's RST gpio handling Peter Ujfalusi 2019-11-13 12:47 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Peter Ujfalusi 2019-11-18 13:08 ` Mark Brown 2019-11-18 14:46 ` Peter Ujfalusi 2019-11-18 16:01 ` Mark Brown 2019-11-18 13:09 ` [alsa-devel] Applied "ASoC: pcm3168a: Document optional RST gpio" to the asoc tree Mark Brown 2019-11-18 21:32 ` [alsa-devel] [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Rob Herring 2019-11-13 12:47 ` [alsa-devel] [PATCH 2/2] ASoC: pcm3168a: Add support for optional RST gpio handling Peter Ujfalusi 2019-11-18 13:09 ` [alsa-devel] Applied "ASoC: pcm3168a: Add support for optional RST gpio handling" 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; as well as URLs for NNTP newsgroup(s).