* [PATCH v4] ASoC: tlv320adcx140: Add support for configuring GPIO pin
@ 2020-09-18 7:32 Camel Guo
2020-09-18 11:18 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Camel Guo @ 2020-09-18 7:32 UTC (permalink / raw)
To: lgirdwood, broonie, tiwai, dmurphy
Cc: alsa-devel, kernel, linux-kernel, Camel Guo
From: Camel Guo <camelg@axis.com>
Add support to configure the GPIO pin to the specific configuration.
The GPIO pin can be configured as GPO, IRQ, SDOUT2, PDMCLK, MICBASE_EN,
GPI, MCLK, SDIN, PDMDIN1, PDMDIN2, PDMDIN3 or PDMDIN4 and the output
drive can be configured with various configuration.
Signed-off-by: Camel Guo <camelg@axis.com>
Acked-by: Dan Murphy <dmurphy@ti.com>
---
v4:
- Rebase and fix merge conflict
- Add Acked-by from Dan
v3:
- Add ADCX140_NUM_GPIO_CFGS avoiding using magic number
- Remove unneeded check on ret in adcx140_configure_gpio
sound/soc/codecs/tlv320adcx140.c | 40 ++++++++++++++++++++++++++++++++
sound/soc/codecs/tlv320adcx140.h | 5 ++++
2 files changed, 45 insertions(+)
diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 28dbd7d5e149..53a80246aee1 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -861,6 +861,42 @@ static int adcx140_configure_gpo(struct adcx140_priv *adcx140)
}
+static int adcx140_configure_gpio(struct adcx140_priv *adcx140)
+{
+ int gpio_count = 0;
+ u32 gpio_outputs[ADCX140_NUM_GPIO_CFGS];
+ u32 gpio_output_val = 0;
+ int ret;
+
+ gpio_count = device_property_count_u32(adcx140->dev,
+ "ti,gpio-config");
+ if (gpio_count == 0)
+ return 0;
+
+ if (gpio_count != ADCX140_NUM_GPIO_CFGS)
+ return -EINVAL;
+
+ ret = device_property_read_u32_array(adcx140->dev, "ti,gpio-config",
+ gpio_outputs, gpio_count);
+ if (ret)
+ return ret;
+
+ if (gpio_outputs[0] > ADCX140_GPIO_CFG_MAX) {
+ dev_err(adcx140->dev, "GPIO config out of range\n");
+ return -EINVAL;
+ }
+
+ if (gpio_outputs[1] > ADCX140_GPIO_DRV_MAX) {
+ dev_err(adcx140->dev, "GPIO drive out of range\n");
+ return -EINVAL;
+ }
+
+ gpio_output_val = gpio_outputs[0] << ADCX140_GPIO_SHIFT
+ | gpio_outputs[1];
+
+ return regmap_write(adcx140->regmap, ADCX140_GPIO_CFG0, gpio_output_val);
+}
+
static int adcx140_codec_probe(struct snd_soc_component *component)
{
struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
@@ -958,6 +994,10 @@ static int adcx140_codec_probe(struct snd_soc_component *component)
return ret;
}
+ ret = adcx140_configure_gpio(adcx140);
+ if (ret)
+ return ret;
+
ret = adcx140_configure_gpo(adcx140);
if (ret)
goto out;
diff --git a/sound/soc/codecs/tlv320adcx140.h b/sound/soc/codecs/tlv320adcx140.h
index 107bd7927d9c..d7d4e3a88b5c 100644
--- a/sound/soc/codecs/tlv320adcx140.h
+++ b/sound/soc/codecs/tlv320adcx140.h
@@ -148,4 +148,9 @@
#define ADCX140_TX_FILL BIT(0)
+#define ADCX140_NUM_GPIO_CFGS 2
+#define ADCX140_GPIO_SHIFT 4
+#define ADCX140_GPIO_CFG_MAX 15
+#define ADCX140_GPIO_DRV_MAX 5
+
#endif /* _TLV320ADCX140_ */
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] ASoC: tlv320adcx140: Add support for configuring GPIO pin
2020-09-18 7:32 [PATCH v4] ASoC: tlv320adcx140: Add support for configuring GPIO pin Camel Guo
@ 2020-09-18 11:18 ` Mark Brown
2020-09-18 11:27 ` Camel Guo
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2020-09-18 11:18 UTC (permalink / raw)
To: Camel Guo
Cc: alsa-devel, Camel Guo, tiwai, linux-kernel, lgirdwood, kernel, dmurphy
[-- Attachment #1: Type: text/plain, Size: 477 bytes --]
On Fri, Sep 18, 2020 at 09:32:29AM +0200, Camel Guo wrote:
> From: Camel Guo <camelg@axis.com>
>
> Add support to configure the GPIO pin to the specific configuration.
> The GPIO pin can be configured as GPO, IRQ, SDOUT2, PDMCLK, MICBASE_EN,
> GPI, MCLK, SDIN, PDMDIN1, PDMDIN2, PDMDIN3 or PDMDIN4 and the output
> drive can be configured with various configuration.
This needs a DT bindings update for the new property (I thought there
was one in prior versions)?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] ASoC: tlv320adcx140: Add support for configuring GPIO pin
2020-09-18 11:18 ` Mark Brown
@ 2020-09-18 11:27 ` Camel Guo
2020-09-18 11:33 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Camel Guo @ 2020-09-18 11:27 UTC (permalink / raw)
To: Mark Brown, Camel Guo
Cc: alsa-devel, tiwai, linux-kernel, lgirdwood, kernel, dmurphy
Mark
On 9/18/20 1:18 PM, Mark Brown wrote:
> On Fri, Sep 18, 2020 at 09:32:29AM +0200, Camel Guo wrote:
>> From: Camel Guo <camelg@axis.com>
>>
>> Add support to configure the GPIO pin to the specific configuration.
>> The GPIO pin can be configured as GPO, IRQ, SDOUT2, PDMCLK, MICBASE_EN,
>> GPI, MCLK, SDIN, PDMDIN1, PDMDIN2, PDMDIN3 or PDMDIN4 and the output
>> drive can be configured with various configuration.
>
> This needs a DT bindings update for the new property (I thought there
> was one in prior versions)?
>
That patch for DT bindings has no change at all. Now I resent it anyway.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] ASoC: tlv320adcx140: Add support for configuring GPIO pin
2020-09-18 11:27 ` Camel Guo
@ 2020-09-18 11:33 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-09-18 11:33 UTC (permalink / raw)
To: Camel Guo
Cc: alsa-devel, tiwai, linux-kernel, lgirdwood, kernel, dmurphy, Camel Guo
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
On Fri, Sep 18, 2020 at 01:27:50PM +0200, Camel Guo wrote:
> On 9/18/20 1:18 PM, Mark Brown wrote:
> > This needs a DT bindings update for the new property (I thought there
> > was one in prior versions)?
> That patch for DT bindings has no change at all. Now I resent it anyway.
Any patch series you send should be self-contained, if some patches from
a previous version of the series are unchanged you should still resend
them. Picking some patches out of different versions of a series makes
everything less clear and more error prone.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-21 8:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18 7:32 [PATCH v4] ASoC: tlv320adcx140: Add support for configuring GPIO pin Camel Guo
2020-09-18 11:18 ` Mark Brown
2020-09-18 11:27 ` Camel Guo
2020-09-18 11:33 ` 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).