ASoC: cs35l41: Only disable internal boost
authorLucas Tanure <lucas.tanure@collabora.com>
Thu, 23 Feb 2023 08:43:21 +0000 (08:43 +0000)
committerMark Brown <broonie@kernel.org>
Sun, 5 Mar 2023 23:36:41 +0000 (23:36 +0000)
In error situations, only the internal boost case should be disabled and
re-enabled.
Also, for other boost cases re-enabling the boost to the default internal
boost config is incorrect.

Fixes: 6450ef559056 ("ASoC: cs35l41: CS35L41 Boosted Smart Amplifier")
Signed-off-by: Lucas Tanure <lucas.tanure@collabora.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: David Rhodes <david.rhodes@cirrus.com>
Link: https://lore.kernel.org/r/20230223084324.9076-2-lucas.tanure@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs35l41.c

index c223d83..f2b5032 100644 (file)
@@ -356,6 +356,19 @@ static const struct snd_kcontrol_new cs35l41_aud_controls[] = {
        WM_ADSP_FW_CONTROL("DSP1", 0),
 };
 
+static void cs35l41_boost_enable(struct cs35l41_private *cs35l41, unsigned int enable)
+{
+       switch (cs35l41->hw_cfg.bst_type) {
+       case CS35L41_INT_BOOST:
+               enable = enable ? CS35L41_BST_EN_DEFAULT : CS35L41_BST_DIS_FET_OFF;
+               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, CS35L41_BST_EN_MASK,
+                               enable << CS35L41_BST_EN_SHIFT);
+               break;
+       default:
+               break;
+       }
+}
+
 static irqreturn_t cs35l41_irq(int irq, void *data)
 {
        struct cs35l41_private *cs35l41 = data;
@@ -431,8 +444,7 @@ static irqreturn_t cs35l41_irq(int irq, void *data)
 
        if (status[0] & CS35L41_BST_OVP_ERR) {
                dev_crit_ratelimited(cs35l41->dev, "VBST Over Voltage error\n");
-               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2,
-                                  CS35L41_BST_EN_MASK, 0);
+               cs35l41_boost_enable(cs35l41, 0);
                regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS1,
                             CS35L41_BST_OVP_ERR);
                regmap_write(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN, 0);
@@ -441,16 +453,13 @@ static irqreturn_t cs35l41_irq(int irq, void *data)
                                   CS35L41_BST_OVP_ERR_RLS);
                regmap_update_bits(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN,
                                   CS35L41_BST_OVP_ERR_RLS, 0);
-               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2,
-                                  CS35L41_BST_EN_MASK,
-                                  CS35L41_BST_EN_DEFAULT << CS35L41_BST_EN_SHIFT);
+               cs35l41_boost_enable(cs35l41, 1);
                ret = IRQ_HANDLED;
        }
 
        if (status[0] & CS35L41_BST_DCM_UVP_ERR) {
                dev_crit_ratelimited(cs35l41->dev, "DCM VBST Under Voltage Error\n");
-               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2,
-                                  CS35L41_BST_EN_MASK, 0);
+               cs35l41_boost_enable(cs35l41, 0);
                regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS1,
                             CS35L41_BST_DCM_UVP_ERR);
                regmap_write(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN, 0);
@@ -459,16 +468,13 @@ static irqreturn_t cs35l41_irq(int irq, void *data)
                                   CS35L41_BST_UVP_ERR_RLS);
                regmap_update_bits(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN,
                                   CS35L41_BST_UVP_ERR_RLS, 0);
-               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2,
-                                  CS35L41_BST_EN_MASK,
-                                  CS35L41_BST_EN_DEFAULT << CS35L41_BST_EN_SHIFT);
+               cs35l41_boost_enable(cs35l41, 1);
                ret = IRQ_HANDLED;
        }
 
        if (status[0] & CS35L41_BST_SHORT_ERR) {
                dev_crit_ratelimited(cs35l41->dev, "LBST error: powering off!\n");
-               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2,
-                                  CS35L41_BST_EN_MASK, 0);
+               cs35l41_boost_enable(cs35l41, 0);
                regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS1,
                             CS35L41_BST_SHORT_ERR);
                regmap_write(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN, 0);
@@ -477,9 +483,7 @@ static irqreturn_t cs35l41_irq(int irq, void *data)
                                   CS35L41_BST_SHORT_ERR_RLS);
                regmap_update_bits(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN,
                                   CS35L41_BST_SHORT_ERR_RLS, 0);
-               regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2,
-                                  CS35L41_BST_EN_MASK,
-                                  CS35L41_BST_EN_DEFAULT << CS35L41_BST_EN_SHIFT);
+               cs35l41_boost_enable(cs35l41, 1);
                ret = IRQ_HANDLED;
        }