summaryrefslogtreecommitdiff
path: root/cs40l26/cs40l26.c
diff options
context:
space:
mode:
authorBen Bright <ben.bright@cirrus.com>2021-05-12 10:40:19 -0500
committerTai Kuo <taikuo@google.com>2021-06-10 18:07:01 +0800
commitc4754b5bdaf55a4c37ec7dac32b9d7a27dc98019 (patch)
tree289cdb3088a4266fffcb5466e1fdb69f6a1ace2b /cs40l26/cs40l26.c
parent995894c6b5c5941020fc1aef412af86560824ff8 (diff)
downloadamplifiers-c4754b5bdaf55a4c37ec7dac32b9d7a27dc98019.tar.gz
input: cs40l26: Add dcm-en control to device tree
Adding bst-dcm-en control to the device tree to allow users to specify whether or not to allow the boost converter to enter low-power (dcm) mode. Bug: 182970777 Test: OK to boot. Change-Id: I2161065beffa6c6c92d94cc7356627d047436484 Signed-off-by: Ben Bright <ben.bright@cirrus.com> Signed-off-by: Tai Kuo <taikuo@google.com>
Diffstat (limited to 'cs40l26/cs40l26.c')
-rw-r--r--cs40l26/cs40l26.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/cs40l26/cs40l26.c b/cs40l26/cs40l26.c
index 3b990db..4044cd0 100644
--- a/cs40l26/cs40l26.c
+++ b/cs40l26/cs40l26.c
@@ -2818,6 +2818,46 @@ err_free:
return ret;
}
+static int cs40l26_bst_dcm_config(struct cs40l26_private *cs40l26)
+{
+ int ret = 0;
+ u32 val;
+
+ if (cs40l26->pdata.bst_dcm_en != CS40L26_BST_DCM_EN_DEFAULT) {
+ ret = regmap_read(cs40l26->regmap, CS40L26_BST_DCM_CTL, &val);
+ if (ret) {
+ dev_err(cs40l26->dev, "Failed to read BST_DCM_CTL\n");
+ return ret;
+ }
+
+ val &= ~CS40L26_BST_DCM_EN_MASK;
+ val |= cs40l26->pdata.bst_dcm_en << CS40L26_BST_DCM_EN_SHIFT;
+
+ ret = regmap_write(cs40l26->regmap, CS40L26_BST_DCM_CTL, val);
+ if (ret) {
+ dev_err(cs40l26->dev, "Failed to write BST_DCM_CTL\n");
+ return ret;
+ }
+
+ switch (cs40l26->revid) {
+ case CS40L26_REVID_A0:
+ ret = cs40l26_pseq_v1_add_pair(cs40l26,
+ CS40L26_BST_DCM_CTL, val, true);
+ break;
+ case CS40L26_REVID_A1:
+ ret = cs40l26_pseq_v2_add_write_reg_full(cs40l26,
+ CS40L26_BST_DCM_CTL, val, true);
+ break;
+ default:
+ dev_err(cs40l26->dev, "Revid ID not supported: %02X\n",
+ cs40l26->revid);
+ ret = -EINVAL;
+ }
+ }
+
+ return ret;
+}
+
static int cs40l26_dsp_config(struct cs40l26_private *cs40l26)
{
struct regmap *regmap = cs40l26->regmap;
@@ -2877,6 +2917,10 @@ static int cs40l26_dsp_config(struct cs40l26_private *cs40l26)
if (ret)
goto err_out;
+ ret = cs40l26_bst_dcm_config(cs40l26);
+ if (ret)
+ goto err_out;
+
ret = cs40l26_brownout_prevention_init(cs40l26);
if (ret)
goto err_out;
@@ -3032,6 +3076,11 @@ static int cs40l26_handle_platform_data(struct cs40l26_private *cs40l26)
else
cs40l26->pdata.vpbr_rel_rate = CS40L26_VXBR_DEFAULT;
+ if (!of_property_read_u32(np, "cirrus,bst-dcm-en", &val))
+ cs40l26->pdata.bst_dcm_en = val;
+ else
+ cs40l26->pdata.bst_dcm_en = CS40L26_BST_DCM_EN_DEFAULT;
+
return 0;
}