ASoC: tlv320aic3x: Add reset inverted DT property
Add reset inverted property to allow reset signal
as active high instead of the default active low
polarity.
Change-Id: I27ae32ba296f71b1d989837ada8b4ad8766ba8ba
Signed-off-by: Rajesha Kini <rkini@codeaurora.org>
Signed-off-by: Gustavo Solaira <gustavos@codeaurora.org>
diff --git a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
index 47a213c..de028b6 100644
--- a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
+++ b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
@@ -17,7 +17,8 @@
Optional properties:
-- gpio-reset - gpio pin number used for codec reset
+- gpio-reset - gpio pin number used for codec reset, default active low
+- reset-inverted - set the reset gpio mode as active high
- ai3x-gpio-func - <array of 2 int> - AIC3X_GPIO1 & AIC3X_GPIO2 Functionality
- Not supported on tlv320aic3104
- ai3x-micbias-vg - MicBias Voltage required.
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index fe45a16..ad11aa0 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -84,6 +84,7 @@
struct list_head list;
int master;
int gpio_reset;
+ bool reset_inverted;
int power;
#define AIC3X_MODEL_3X 0
#define AIC3X_MODEL_33 1
@@ -1353,7 +1354,8 @@
* of the supplies was disabled
*/
if (gpio_is_valid(aic3x->gpio_reset))
- gpio_set_value(aic3x->gpio_reset, 0);
+ gpio_set_value(aic3x->gpio_reset,
+ aic3x->reset_inverted);
regcache_mark_dirty(aic3x->regmap);
}
@@ -1375,7 +1377,8 @@
if (gpio_is_valid(aic3x->gpio_reset)) {
udelay(1);
- gpio_set_value(aic3x->gpio_reset, 1);
+ gpio_set_value(aic3x->gpio_reset,
+ !aic3x->reset_inverted);
}
/* Sync reg_cache with the hardware */
@@ -1761,6 +1764,9 @@
else
aic3x->gpio_reset = -1;
+ aic3x->reset_inverted =
+ of_property_read_bool(np, "reset-inverted");
+
if (of_property_read_u32_array(np, "ai3x-gpio-func",
ai3x_setup->gpio_func, 2) >= 0) {
aic3x->setup = ai3x_setup;
@@ -1797,7 +1803,8 @@
ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset");
if (ret != 0)
goto err;
- gpio_direction_output(aic3x->gpio_reset, 0);
+ gpio_direction_output(aic3x->gpio_reset,
+ aic3x->reset_inverted);
}
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
@@ -1843,7 +1850,7 @@
snd_soc_unregister_codec(&client->dev);
if (gpio_is_valid(aic3x->gpio_reset) &&
!aic3x_is_shared_reset(aic3x)) {
- gpio_set_value(aic3x->gpio_reset, 0);
+ gpio_set_value(aic3x->gpio_reset, aic3x->reset_inverted);
gpio_free(aic3x->gpio_reset);
}
return 0;