From 720f1980f554721f04aadd4514008bbb357acbd2 Mon Sep 17 00:00:00 2001 From: wangyq13 Date: Wed, 18 Aug 2021 19:02:41 +0800 Subject: [PATCH] dlkm/wl2866d: disable avdd1 when device shutdown Disable avdd1 when device shutdown for peripherals stability and current leak issue. Change-Id: I596899cff45f7da15a5339a122b47c7ad4e6fd01 Signed-off-by: wangyq13 Reviewed-on: https://gerrit.mot.com/2045126 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/regulator/wl2866d/wl2866d-regulator.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/regulator/wl2866d/wl2866d-regulator.c b/drivers/regulator/wl2866d/wl2866d-regulator.c index 078b93568fe1..3a6b085ca969 100644 --- a/drivers/regulator/wl2866d/wl2866d-regulator.c +++ b/drivers/regulator/wl2866d/wl2866d-regulator.c @@ -36,6 +36,7 @@ struct wl2866d { struct regulator_dev *rdev[WL2866D_MAX_REGULATORS]; int chip_cs_pin; int init_value; + bool shutdown_ldo; }; struct wl2866d_evt_sta { @@ -306,6 +307,7 @@ static int wl2866d_i2c_probe(struct i2c_client *client, } chip->init_value = value; dev_info(chip->dev, "wl2866d_i2c_probe init_value:%d...\n", value); + chip->shutdown_ldo = of_property_read_bool(dev->of_node, "semi,shutdown-ldo"); mdelay(10); @@ -358,6 +360,19 @@ static int wl2866d_i2c_remove(struct i2c_client *client) return ret; } +static void wl2866d_i2c_shutdown(struct i2c_client *client) +{ + struct wl2866d *chip = i2c_get_clientdata(client); + unsigned int val = 0; + + if (chip->shutdown_ldo) { + regmap_read(chip->regmap, WL2866D_LDO_EN, &val); + /* Disable AVDD1 when shutdown to meet device SPEC and avoid current leak */ + regmap_write(chip->regmap, WL2866D_LDO_EN, val & ~(1<<2)); + dev_info(chip->dev, "wl2866d_i2c_shutdown"); + } +} + static const struct i2c_device_id wl2866d_i2c_id[] = { {"wl2866d", 0}, {}, @@ -370,6 +385,7 @@ static struct i2c_driver wl2866d_regulator_driver = { }, .probe = wl2866d_i2c_probe, .remove = wl2866d_i2c_remove, + .shutdown = wl2866d_i2c_shutdown, .id_table = wl2866d_i2c_id, };