diff mbox series

[v2,2/2] ASoC: rt1015p: delay 300ms after SDB pulling high for calibration

Message ID 20201210033617.79300-3-tzungbi@google.com
State New
Headers show
Series None | expand

Commit Message

Tzung-Bi Shih Dec. 10, 2020, 3:36 a.m. UTC
RT1015p needs 300ms delay after SDB pulling high for internal
calibration during the power on sequence.

Delays 300ms right before data sends out to avoid data truncated.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/codecs/rt1015p.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Mark Brown Dec. 10, 2020, 3:42 p.m. UTC | #1
On Thu, Dec 10, 2020 at 11:36:17AM +0800, Tzung-Bi Shih wrote:

> +		if (!rt1015p->calib_done) {
> +			msleep(300);
> +			rt1015p->calib_done = true;
> +		}

Might we need to reset calib_done over suspend?  If the device looses
power I guess it forgets the calibration.
Mark Brown Dec. 10, 2020, 6:20 p.m. UTC | #2
On Fri, Dec 11, 2020 at 12:47:47AM +0800, Tzung-Bi Shih wrote:
> On Thu, Dec 10, 2020 at 11:42 PM Mark Brown <broonie@kernel.org> wrote:

> > Might we need to reset calib_done over suspend?  If the device looses
> > power I guess it forgets the calibration.

> In our environment, the power VBAT and AVDD are still on even if the
> system suspends.  In more low power mode, AVDD could probably lose.

> But agree with you, in general, suppose the device needs to calibrate
> again after suspend/resume is better.

Yeah, even on that system there might be a problem if the system goes
into hibernate instead of suspend (especially if it hibernates due to
running out of battery!).
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt1015p.c b/sound/soc/codecs/rt1015p.c
index 397083ee5b37..bba638e1eb6a 100644
--- a/sound/soc/codecs/rt1015p.c
+++ b/sound/soc/codecs/rt1015p.c
@@ -4,6 +4,7 @@ 
 //
 // Copyright 2020 The Linux Foundation. All rights reserved.
 
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
@@ -19,6 +20,7 @@ 
 
 struct rt1015p_priv {
 	struct gpio_desc *sdb;
+	bool calib_done;
 };
 
 static int rt1015p_sdb_event(struct snd_soc_dapm_widget *w,
@@ -36,6 +38,11 @@  static int rt1015p_sdb_event(struct snd_soc_dapm_widget *w,
 	case SND_SOC_DAPM_PRE_PMU:
 		gpiod_set_value(rt1015p->sdb, 1);
 		dev_dbg(component->dev, "set sdb to 1");
+
+		if (!rt1015p->calib_done) {
+			msleep(300);
+			rt1015p->calib_done = true;
+		}
 		break;
 	case SND_SOC_DAPM_POST_PMD:
 		gpiod_set_value(rt1015p->sdb, 0);