ASoC: cs35l35: Correct handling of PDN_DONE with external boost
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thu, 6 Apr 2017 12:52:13 +0000 (13:52 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 6 Apr 2017 18:27:56 +0000 (19:27 +0100)
When using an external boost supply the PDN_DONE bit is not set, update
the handling in this case to use to use an appropriate fixed delay.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/cs35l35.h
sound/soc/codecs/cs35l35.c

index 983c610eba2e0243652cfc3298ff06beb1429a23..88744bbd6728ea4baae368087c285b8d20717d47 100644 (file)
@@ -96,6 +96,8 @@ struct cs35l35_platform_data {
        int adv_channel;
        /* Shared Boost for stereo */
        bool shared_bst;
+       /* Specifies this amp is using an external boost supply */
+       bool ext_bst;
        /* ClassH Algorithm */
        struct classh_cfg classh_algo;
        /* Monitor Config */
index 1db07a6296a416934c29c37eacb32bc70aa4e52a..6ecb7ddae9cf22a646a9f69163f4f22e63abc616 100644 (file)
@@ -162,6 +162,27 @@ static bool cs35l35_precious_register(struct device *dev, unsigned int reg)
        }
 }
 
+static int cs35l35_wait_for_pdn(struct cs35l35_private *cs35l35)
+{
+       int ret;
+
+       if (cs35l35->pdata.ext_bst) {
+               usleep_range(5000, 5500);
+               return 0;
+       }
+
+       reinit_completion(&cs35l35->pdn_done);
+
+       ret = wait_for_completion_timeout(&cs35l35->pdn_done,
+                                         msecs_to_jiffies(100));
+       if (ret == 0) {
+               dev_err(cs35l35->dev, "PDN_DONE did not complete\n");
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
 static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w,
                struct snd_kcontrol *kcontrol, int event)
 {
@@ -191,14 +212,7 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w,
                regmap_update_bits(cs35l35->regmap, CS35L35_AMP_DIG_VOL_CTL,
                                   CS35L35_AMP_DIGSFT_MASK, 0);
 
-               reinit_completion(&cs35l35->pdn_done);
-
-               ret = wait_for_completion_timeout(&cs35l35->pdn_done,
-                                                       msecs_to_jiffies(100));
-               if (ret == 0) {
-                       dev_err(codec->dev, "TIMEOUT PDN_DONE did not complete in 100ms\n");
-                       ret = -ETIMEDOUT;
-               }
+               ret = cs35l35_wait_for_pdn(cs35l35);
 
                regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1,
                                        CS35L35_MCLK_DIS_MASK,
@@ -1198,6 +1212,8 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
                                                "cirrus,shared-boost");
        }
 
+       pdata->ext_bst = of_property_read_bool(np, "cirrus,external-boost");
+
        pdata->gain_zc = of_property_read_bool(np, "cirrus,amp-gain-zc");
 
        classh = of_get_child_by_name(np, "cirrus,classh-internal-algo");