From 3b19b42503336f1bdcaf0f4e268c3c7fac6c0a1b Mon Sep 17 00:00:00 2001 From: weiweij Date: Tue, 12 Apr 2022 10:49:32 +0800 Subject: [PATCH] charger: add mux control for WLS in otg mode for SGM4154x In OTG mode, the output of VOUT from WLS should be disabled. So we use gpio to control WLS through mux. When VBUS boost starts, disabling WLS VOUT. And resuming it after VBUS boost stops. This change is for SGM4154x. Change-Id: I6749f58c7775d9cf8b351b63464a5dd42cf2cf8b Reviewed-on: https://gerrit.mot.com/2239293 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- .../power/sgm4154x_chg_mmi/sgm4154x_charger.c | 24 +++++++++++++++++++ .../power/sgm4154x_chg_mmi/sgm4154x_charger.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.c b/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.c index 6cdd5365339f..d382139ea1c6 100644 --- a/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.c +++ b/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.c @@ -2489,6 +2489,18 @@ static int sgm4154x_parse_dt(struct sgm4154x_device *sgm) } gpio_direction_output(chg_en_gpio,0);//default enable charge } + + /*wls outout en control*/ + sgm->wls_en_gpio = of_get_named_gpio(sgm->dev->of_node, "mmi,wls-en-gpio", 0); + if (gpio_is_valid(sgm->wls_en_gpio)) + { + ret = gpio_request(sgm->wls_en_gpio, "mmi wls en pin"); + if (ret) + dev_err(sgm->dev, "%s: %d gpio(wls en) request failed\n", __func__, sgm->wls_en_gpio); + else + gpio_direction_output(sgm->wls_en_gpio, 0);//default enable wls charge + } + /* sw jeita */ sgm->enable_sw_jeita = of_property_read_bool(sgm->dev->of_node, "enable_sw_jeita"); /* enable dynamic adjust battery voltage */ @@ -2656,6 +2668,12 @@ static int sgm4154x_enable_vbus(struct regulator_dev *rdev) struct sgm4154x_device *sgm = rdev_get_drvdata(rdev); int ret = 0; + /*disable wls output*/ + if (gpio_is_valid(sgm->wls_en_gpio)) { + pr_err("%s,set wls en\n",__func__); + gpio_direction_output(sgm->wls_en_gpio, 1); + } + ret = mmi_regmap_update_bits(sgm, SGM4154x_CHRG_CTRL_1, SGM4154x_OTG_EN, SGM4154x_OTG_EN); return ret; @@ -2669,6 +2687,12 @@ static int sgm4154x_disable_vbus(struct regulator_dev *rdev) ret = mmi_regmap_update_bits(sgm, SGM4154x_CHRG_CTRL_1, SGM4154x_OTG_EN, 0); + /*resume wls output*/ + if (gpio_is_valid(sgm->wls_en_gpio)) { + pr_err("%s,set wls dis\n",__func__); + gpio_direction_output(sgm->wls_en_gpio, 0); + } + return ret; } diff --git a/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.h b/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.h index bf1e66ecfb1e..960a4abbe18d 100644 --- a/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.h +++ b/drivers/power/sgm4154x_chg_mmi/sgm4154x_charger.h @@ -383,6 +383,9 @@ struct sgm4154x_device { #ifdef CONFIG_MMI_QC3P_WT6670_DETECTED struct iio_channel **ext_iio_chans; #endif + + /*wls output en/dis control*/ + int wls_en_gpio; }; #ifdef CONFIG_MMI_QC3P_WT6670_DETECTED