From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbdKIAaQ (ORCPT ); Wed, 8 Nov 2017 19:30:16 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:39669 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753133AbdKIA3I (ORCPT ); Wed, 8 Nov 2017 19:29:08 -0500 From: "Andrew F. Davis" To: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland , =?UTF-8?q?Beno=C3=AEt=20Cousson?= , Tony Lindgren CC: , , , "Andrew F . Davis" Subject: [PATCH 11/17] ASoC: tlv320aic31xx: Reset registers during probe Date: Wed, 8 Nov 2017 18:27:35 -0600 Message-ID: <20171109002741.10897-12-afd@ti.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171109002741.10897-1-afd@ti.com> References: <20171109002741.10897-1-afd@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a reset function that toggles the reset line if available or uses the software reset command otherwise. Use this in probe to ensure the registers are in a sane state. This is useful when the driver module is reloaded, or after Kexec, warm-reboots, etc.. Signed-off-by: Andrew F. Davis --- sound/soc/codecs/tlv320aic31xx.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index e58b7a4e0402..98e9ba3ee708 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -1037,6 +1037,24 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } +static int aic31xx_reset(struct aic31xx_priv *aic31xx) +{ + int ret = 0; + + if (aic31xx->gpio_reset) { + gpiod_set_value(aic31xx->gpio_reset, 1); + ndelay(10); /* At least 10ns */ + gpiod_set_value(aic31xx->gpio_reset, 0); + } else { + ret = regmap_write(aic31xx->regmap, AIC31XX_RESET, 1); + if (ret < 0) + dev_err(aic31xx->dev, "Could not reset device\n"); + } + mdelay(1); /* At least 1ms */ + + return ret; +} + static int aic31xx_regulator_event(struct notifier_block *nb, unsigned long event, void *data) { @@ -1362,6 +1380,9 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, return ret; } + /* Reset device registers for a consistent power-on like state */ + aic31xx_reset(aic31xx); + if (aic31xx->codec_type & DAC31XX_BIT) return snd_soc_register_codec(&i2c->dev, &soc_codec_driver_aic31xx, -- 2.15.0