summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/imx-ak4458.c
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2018-02-06 18:38:24 +0800
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:50:32 +0800
commit476e8f9e9a2fb0df4eacf456c1e6edeaf2f657d7 (patch)
tree745628644fbfb0a57b7b8e9ed6afbc96569cfd4f /sound/soc/fsl/imx-ak4458.c
parent81ef35e6453513d876bca4cde180a64f6277793d (diff)
MLK-17515-1: ASoC: imx-ak4458: add pdn gpio for machine driver
There is two ak4458 codecs which share some pdn gpio. If assign the pdn gpio to one codec, will cause the another codec error: ak4458 1-0012: Unable to sync registers 0x0-0x0. -6 The reason is that if the codec driver is trying to do regcache_sync, but another codec is resetting the pdn gpio in same time, the regcache_sync will fail. So Move the pdn gpio to machine driver, machine driver will control this gpio for two codecs. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Cosmin Samoila <cosmin.samoila@nxp.com>
Diffstat (limited to 'sound/soc/fsl/imx-ak4458.c')
-rw-r--r--sound/soc/fsl/imx-ak4458.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/sound/soc/fsl/imx-ak4458.c b/sound/soc/fsl/imx-ak4458.c
index 6b86777e8706..83d4a4e801a8 100644
--- a/sound/soc/fsl/imx-ak4458.c
+++ b/sound/soc/fsl/imx-ak4458.c
@@ -16,6 +16,7 @@
#include <linux/gpio/consumer.h>
#include <linux/of_device.h>
#include <linux/i2c.h>
+#include <linux/of_gpio.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
#include <sound/pcm.h>
@@ -26,6 +27,7 @@ struct imx_ak4458_data {
int num_codec_conf;
struct snd_soc_codec_conf *codec_conf;
bool tdm_mode;
+ int pdn_gpio;
};
static struct snd_soc_dapm_widget imx_ak4458_dapm_widgets[] = {
@@ -225,9 +227,10 @@ static int imx_ak4458_probe(struct platform_device *pdev)
priv->codec_conf = devm_kzalloc(&pdev->dev,
priv->num_codec_conf * sizeof(struct snd_soc_codec_conf),
GFP_KERNEL);
- if (!priv->codec_conf)
- return -ENOMEM;
-
+ if (!priv->codec_conf) {
+ ret = -ENOMEM;
+ goto fail;
+ }
priv->codec_conf[0].name_prefix = "0";
priv->codec_conf[0].of_node = codec_np_0;
@@ -249,6 +252,21 @@ static int imx_ak4458_probe(struct platform_device *pdev)
priv->card.codec_conf = priv->codec_conf;
priv->card.num_configs = priv->num_codec_conf;
+ priv->pdn_gpio = of_get_named_gpio(pdev->dev.of_node, "ak4458,pdn-gpio", 0);
+ if (gpio_is_valid(priv->pdn_gpio)) {
+ ret = devm_gpio_request_one(&pdev->dev, priv->pdn_gpio,
+ GPIOF_OUT_INIT_LOW, "ak4458,pdn");
+ if (ret) {
+ dev_err(&pdev->dev, "unable to get pdn gpio\n");
+ goto fail;
+ }
+
+ gpio_set_value_cansleep(priv->pdn_gpio, 0);
+ usleep_range(1000, 2000);
+ gpio_set_value_cansleep(priv->pdn_gpio, 1);
+ usleep_range(1000, 2000);
+ }
+
ret = snd_soc_of_parse_card_name(&priv->card, "model");
if (ret)
goto fail;