aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Niederprüm <niederp@physik.uni-kl.de>2015-01-21 18:01:54 -0500
committerMark Brown <broonie@kernel.org>2015-01-27 12:13:22 -0500
commitb66a29808e1fac7fc5c8174e3ec0f014bd418280 (patch)
tree55c7014d30cac75db0437437cc7abd1fc4cac763
parenta1be4cead9b9504aa6fc93b624975601cec8c188 (diff)
ASoC: sta32x: make sta32x a gpio consumer for the reset GPIO
The reset GPIO on the STA32X Codecs is used to reset the Codec and clear all registers. Also taking it down puts the IC in power save mode, so we put the device in reset mode when we go to sleep. Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/sta32x.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index 4517453b33b6..ae9283781bb6 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -26,6 +26,7 @@
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/regmap.h> 27#include <linux/regmap.h>
28#include <linux/regulator/consumer.h> 28#include <linux/regulator/consumer.h>
29#include <linux/gpio/consumer.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/workqueue.h> 31#include <linux/workqueue.h>
31#include <sound/core.h> 32#include <sound/core.h>
@@ -151,6 +152,7 @@ struct sta32x_priv {
151 u32 coef_shadow[STA32X_COEF_COUNT]; 152 u32 coef_shadow[STA32X_COEF_COUNT];
152 struct delayed_work watchdog_work; 153 struct delayed_work watchdog_work;
153 int shutdown; 154 int shutdown;
155 struct gpio_desc *gpiod_nreset;
154 struct mutex coeff_lock; 156 struct mutex coeff_lock;
155}; 157};
156 158
@@ -804,6 +806,16 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream,
804 806
805 return 0; 807 return 0;
806} 808}
809
810static int sta32x_startup_sequence(struct sta32x_priv *sta32x)
811{
812 if (sta32x->gpiod_nreset) {
813 gpiod_set_value(sta32x->gpiod_nreset, 0);
814 mdelay(1);
815 gpiod_set_value(sta32x->gpiod_nreset, 1);
816 mdelay(1);
817 }
818
807 return 0; 819 return 0;
808} 820}
809 821
@@ -844,6 +856,7 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec,
844 return ret; 856 return ret;
845 } 857 }
846 858
859 sta32x_startup_sequence(sta32x);
847 sta32x_cache_sync(codec); 860 sta32x_cache_sync(codec);
848 sta32x_watchdog_start(sta32x); 861 sta32x_watchdog_start(sta32x);
849 } 862 }
@@ -861,6 +874,10 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec,
861 STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, 0); 874 STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, 0);
862 msleep(300); 875 msleep(300);
863 sta32x_watchdog_stop(sta32x); 876 sta32x_watchdog_stop(sta32x);
877
878 if (sta32x->gpiod_nreset)
879 gpiod_set_value(sta32x->gpiod_nreset, 0);
880
864 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), 881 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies),
865 sta32x->supplies); 882 sta32x->supplies);
866 break; 883 break;
@@ -899,6 +916,11 @@ static int sta32x_probe(struct snd_soc_codec *codec)
899 return ret; 916 return ret;
900 } 917 }
901 918
919 ret = sta32x_startup_sequence(sta32x);
920 if (ret < 0) {
921 dev_err(codec->dev, "Failed to startup device\n");
922 return ret;
923 }
902 /* set thermal warning adjustment and recovery */ 924 /* set thermal warning adjustment and recovery */
903 if (!pdata->thermal_warning_recovery) 925 if (!pdata->thermal_warning_recovery)
904 thermal |= STA32X_CONFA_TWAB; 926 thermal |= STA32X_CONFA_TWAB;
@@ -999,6 +1021,19 @@ static int sta32x_i2c_probe(struct i2c_client *i2c,
999 1021
1000 mutex_init(&sta32x->coeff_lock); 1022 mutex_init(&sta32x->coeff_lock);
1001 sta32x->pdata = dev_get_platdata(dev); 1023 sta32x->pdata = dev_get_platdata(dev);
1024
1025 /* GPIOs */
1026 sta32x->gpiod_nreset = devm_gpiod_get(dev, "reset");
1027 if (IS_ERR(sta32x->gpiod_nreset)) {
1028 ret = PTR_ERR(sta32x->gpiod_nreset);
1029 if (ret != -ENOENT && ret != -ENOSYS)
1030 return ret;
1031
1032 sta32x->gpiod_nreset = NULL;
1033 } else {
1034 gpiod_direction_output(sta32x->gpiod_nreset, 0);
1035 }
1036
1002 /* regulators */ 1037 /* regulators */
1003 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) 1038 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++)
1004 sta32x->supplies[i].supply = sta32x_supply_names[i]; 1039 sta32x->supplies[i].supply = sta32x_supply_names[i];