All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] power: supply: bq24190_charger: Fix bq24190_vbus_is_enabled() wrong false return
@ 2022-02-12 16:48 Hans de Goede
  2022-02-12 16:48 ` [PATCH 2/2] power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2022-02-12 16:48 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm, Bastien Nocera

The datasheet says that the BQ24190_REG_POC_CHG_CONFIG bits can
have a value of either 10(0x2) or 11(0x3) for OTG (5V boost regulator)
mode.

Sofar bq24190_vbus_is_enabled() was only checking for 10 but some BIOS-es
uses 11 when enabling the regulator at boot.

Make bq24190_vbus_is_enabled() also check for 11 so that it does not
wrongly returns false when the bits are set to 11.

Fixes: 66b6bef2c4e0 ("power: supply: bq24190_charger: Export 5V boost converter as regulator")
Cc: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/bq24190_charger.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 04aa25f2d033..dcbfd97a55be 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -39,6 +39,7 @@
 #define BQ24190_REG_POC_CHG_CONFIG_DISABLE		0x0
 #define BQ24190_REG_POC_CHG_CONFIG_CHARGE		0x1
 #define BQ24190_REG_POC_CHG_CONFIG_OTG			0x2
+#define BQ24190_REG_POC_CHG_CONFIG_OTG_ALT		0x3
 #define BQ24190_REG_POC_SYS_MIN_MASK		(BIT(3) | BIT(2) | BIT(1))
 #define BQ24190_REG_POC_SYS_MIN_SHIFT		1
 #define BQ24190_REG_POC_SYS_MIN_MIN			3000
@@ -555,7 +556,11 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
 	pm_runtime_mark_last_busy(bdi->dev);
 	pm_runtime_put_autosuspend(bdi->dev);
 
-	return ret ? ret : val == BQ24190_REG_POC_CHG_CONFIG_OTG;
+	if (ret)
+		return ret;
+
+	return (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
+		val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
 }
 
 static const struct regulator_ops bq24190_vbus_ops = {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on
  2022-02-12 16:48 [PATCH 1/2] power: supply: bq24190_charger: Fix bq24190_vbus_is_enabled() wrong false return Hans de Goede
@ 2022-02-12 16:48 ` Hans de Goede
  2022-02-25 16:47   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2022-02-12 16:48 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm, Bastien Nocera

Recently userspace has started switching power_supply class devices with
a charge_type psy-property between fast and trickle charge mode, see:
https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/85

Before this patch bq24190_charger_set_charge_type() would unconditionally
write charging or none to the BQ24190_REG_POC_CHG_CONFIG bits, replacing
the otg setting of those bits when the OTG 5V Vbus boost converter was on,
turning the 5V Vbus off, removing the power from any attached peripherals.

This fixes this by keeping track of otg_vbus_enabled and the requested
charger_type settings and when otg_vbus_enabled is true, delay applying
the charger_type until the 5V boost converter is turned off.

Cc: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/bq24190_charger.c | 41 +++++++++++++++++++-------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index dcbfd97a55be..aa1a589eb9f2 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -163,6 +163,8 @@ struct bq24190_dev_info {
 	char				model_name[I2C_NAME_SIZE];
 	bool				initialized;
 	bool				irq_event;
+	bool				otg_vbus_enabled;
+	int				charge_type;
 	u16				sys_min;
 	u16				iprechg;
 	u16				iterm;
@@ -176,6 +178,9 @@ struct bq24190_dev_info {
 	u8				watchdog;
 };
 
+static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
+					   const union power_supply_propval *val);
+
 static const unsigned int bq24190_usb_extcon_cable[] = {
 	EXTCON_USB,
 	EXTCON_NONE,
@@ -502,8 +507,9 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
 }
 #endif
 
-static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
+static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
 {
+	union power_supply_propval val = { .intval = bdi->charge_type };
 	int ret;
 
 	ret = pm_runtime_get_sync(bdi->dev);
@@ -513,9 +519,14 @@ static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
 		return ret;
 	}
 
-	ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
-				 BQ24190_REG_POC_CHG_CONFIG_MASK,
-				 BQ24190_REG_POC_CHG_CONFIG_SHIFT, val);
+	bdi->otg_vbus_enabled = enable;
+	if (enable)
+		ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
+					 BQ24190_REG_POC_CHG_CONFIG_MASK,
+					 BQ24190_REG_POC_CHG_CONFIG_SHIFT,
+					 BQ24190_REG_POC_CHG_CONFIG_OTG);
+	else
+		ret = bq24190_charger_set_charge_type(bdi, &val);
 
 	pm_runtime_mark_last_busy(bdi->dev);
 	pm_runtime_put_autosuspend(bdi->dev);
@@ -526,14 +537,12 @@ static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
 #ifdef CONFIG_REGULATOR
 static int bq24190_vbus_enable(struct regulator_dev *dev)
 {
-	return bq24190_set_charge_mode(rdev_get_drvdata(dev),
-				       BQ24190_REG_POC_CHG_CONFIG_OTG);
+	return bq24190_set_otg_vbus(rdev_get_drvdata(dev), true);
 }
 
 static int bq24190_vbus_disable(struct regulator_dev *dev)
 {
-	return bq24190_set_charge_mode(rdev_get_drvdata(dev),
-				       BQ24190_REG_POC_CHG_CONFIG_CHARGE);
+	return bq24190_set_otg_vbus(rdev_get_drvdata(dev), false);
 }
 
 static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
@@ -559,8 +568,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
 	if (ret)
 		return ret;
 
-	return (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
-		val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
+	bdi->otg_vbus_enabled = (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
+				 val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
+	return bdi->otg_vbus_enabled;
 }
 
 static const struct regulator_ops bq24190_vbus_ops = {
@@ -807,6 +817,14 @@ static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
 		return -EINVAL;
 	}
 
+	bdi->charge_type = val->intval;
+	/*
+	 * If the 5V Vbus boost regulator is enabled delay setting
+	 * the charge-type until its gets disabled.
+	 */
+	if (bdi->otg_vbus_enabled)
+		return 0;
+
 	if (chg_config) { /* Enabling the charger */
 		ret = bq24190_write_mask(bdi, BQ24190_REG_CCC,
 				BQ24190_REG_CCC_FORCE_20PCT_MASK,
@@ -1788,6 +1806,7 @@ static int bq24190_probe(struct i2c_client *client,
 	bdi->dev = dev;
 	strncpy(bdi->model_name, id->name, I2C_NAME_SIZE);
 	mutex_init(&bdi->f_reg_lock);
+	bdi->charge_type = POWER_SUPPLY_CHARGE_TYPE_FAST;
 	bdi->f_reg = 0;
 	bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
 	INIT_DELAYED_WORK(&bdi->input_current_limit_work,
@@ -1925,7 +1944,7 @@ static void bq24190_shutdown(struct i2c_client *client)
 	struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
 
 	/* Turn off 5V boost regulator on shutdown */
-	bq24190_set_charge_mode(bdi, BQ24190_REG_POC_CHG_CONFIG_CHARGE);
+	bq24190_set_otg_vbus(bdi, false);
 }
 
 static __maybe_unused int bq24190_runtime_suspend(struct device *dev)
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on
  2022-02-12 16:48 ` [PATCH 2/2] power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on Hans de Goede
@ 2022-02-25 16:47   ` Andy Shevchenko
  2022-02-25 19:10     ` Sebastian Reichel
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-02-25 16:47 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Sebastian Reichel, linux-pm, Bastien Nocera

On Sat, Feb 12, 2022 at 05:48:17PM +0100, Hans de Goede wrote:
> Recently userspace has started switching power_supply class devices with
> a charge_type psy-property between fast and trickle charge mode, see:
> https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/85
> 
> Before this patch bq24190_charger_set_charge_type() would unconditionally
> write charging or none to the BQ24190_REG_POC_CHG_CONFIG bits, replacing
> the otg setting of those bits when the OTG 5V Vbus boost converter was on,
> turning the 5V Vbus off, removing the power from any attached peripherals.
> 
> This fixes this by keeping track of otg_vbus_enabled and the requested
> charger_type settings and when otg_vbus_enabled is true, delay applying
> the charger_type until the 5V boost converter is turned off.

Both of them looks good to me, FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Cc: Bastien Nocera <hadess@hadess.net>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/power/supply/bq24190_charger.c | 41 +++++++++++++++++++-------
>  1 file changed, 30 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index dcbfd97a55be..aa1a589eb9f2 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -163,6 +163,8 @@ struct bq24190_dev_info {
>  	char				model_name[I2C_NAME_SIZE];
>  	bool				initialized;
>  	bool				irq_event;
> +	bool				otg_vbus_enabled;
> +	int				charge_type;
>  	u16				sys_min;
>  	u16				iprechg;
>  	u16				iterm;
> @@ -176,6 +178,9 @@ struct bq24190_dev_info {
>  	u8				watchdog;
>  };
>  
> +static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
> +					   const union power_supply_propval *val);
> +
>  static const unsigned int bq24190_usb_extcon_cable[] = {
>  	EXTCON_USB,
>  	EXTCON_NONE,
> @@ -502,8 +507,9 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
>  }
>  #endif
>  
> -static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
> +static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
>  {
> +	union power_supply_propval val = { .intval = bdi->charge_type };
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(bdi->dev);
> @@ -513,9 +519,14 @@ static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
>  		return ret;
>  	}
>  
> -	ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
> -				 BQ24190_REG_POC_CHG_CONFIG_MASK,
> -				 BQ24190_REG_POC_CHG_CONFIG_SHIFT, val);
> +	bdi->otg_vbus_enabled = enable;
> +	if (enable)
> +		ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
> +					 BQ24190_REG_POC_CHG_CONFIG_MASK,
> +					 BQ24190_REG_POC_CHG_CONFIG_SHIFT,
> +					 BQ24190_REG_POC_CHG_CONFIG_OTG);
> +	else
> +		ret = bq24190_charger_set_charge_type(bdi, &val);
>  
>  	pm_runtime_mark_last_busy(bdi->dev);
>  	pm_runtime_put_autosuspend(bdi->dev);
> @@ -526,14 +537,12 @@ static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
>  #ifdef CONFIG_REGULATOR
>  static int bq24190_vbus_enable(struct regulator_dev *dev)
>  {
> -	return bq24190_set_charge_mode(rdev_get_drvdata(dev),
> -				       BQ24190_REG_POC_CHG_CONFIG_OTG);
> +	return bq24190_set_otg_vbus(rdev_get_drvdata(dev), true);
>  }
>  
>  static int bq24190_vbus_disable(struct regulator_dev *dev)
>  {
> -	return bq24190_set_charge_mode(rdev_get_drvdata(dev),
> -				       BQ24190_REG_POC_CHG_CONFIG_CHARGE);
> +	return bq24190_set_otg_vbus(rdev_get_drvdata(dev), false);
>  }
>  
>  static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
> @@ -559,8 +568,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
>  	if (ret)
>  		return ret;
>  
> -	return (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
> -		val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
> +	bdi->otg_vbus_enabled = (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
> +				 val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
> +	return bdi->otg_vbus_enabled;
>  }
>  
>  static const struct regulator_ops bq24190_vbus_ops = {
> @@ -807,6 +817,14 @@ static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
>  		return -EINVAL;
>  	}
>  
> +	bdi->charge_type = val->intval;
> +	/*
> +	 * If the 5V Vbus boost regulator is enabled delay setting
> +	 * the charge-type until its gets disabled.
> +	 */
> +	if (bdi->otg_vbus_enabled)
> +		return 0;
> +
>  	if (chg_config) { /* Enabling the charger */
>  		ret = bq24190_write_mask(bdi, BQ24190_REG_CCC,
>  				BQ24190_REG_CCC_FORCE_20PCT_MASK,
> @@ -1788,6 +1806,7 @@ static int bq24190_probe(struct i2c_client *client,
>  	bdi->dev = dev;
>  	strncpy(bdi->model_name, id->name, I2C_NAME_SIZE);
>  	mutex_init(&bdi->f_reg_lock);
> +	bdi->charge_type = POWER_SUPPLY_CHARGE_TYPE_FAST;
>  	bdi->f_reg = 0;
>  	bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
>  	INIT_DELAYED_WORK(&bdi->input_current_limit_work,
> @@ -1925,7 +1944,7 @@ static void bq24190_shutdown(struct i2c_client *client)
>  	struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
>  
>  	/* Turn off 5V boost regulator on shutdown */
> -	bq24190_set_charge_mode(bdi, BQ24190_REG_POC_CHG_CONFIG_CHARGE);
> +	bq24190_set_otg_vbus(bdi, false);
>  }
>  
>  static __maybe_unused int bq24190_runtime_suspend(struct device *dev)
> -- 
> 2.33.1
> 
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on
  2022-02-25 16:47   ` Andy Shevchenko
@ 2022-02-25 19:10     ` Sebastian Reichel
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2022-02-25 19:10 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Hans de Goede, linux-pm, Bastien Nocera

[-- Attachment #1: Type: text/plain, Size: 5926 bytes --]

Hi,

On Fri, Feb 25, 2022 at 06:47:19PM +0200, Andy Shevchenko wrote:
> On Sat, Feb 12, 2022 at 05:48:17PM +0100, Hans de Goede wrote:
> > Recently userspace has started switching power_supply class devices with
> > a charge_type psy-property between fast and trickle charge mode, see:
> > https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/85
> > 
> > Before this patch bq24190_charger_set_charge_type() would unconditionally
> > write charging or none to the BQ24190_REG_POC_CHG_CONFIG bits, replacing
> > the otg setting of those bits when the OTG 5V Vbus boost converter was on,
> > turning the 5V Vbus off, removing the power from any attached peripherals.
> > 
> > This fixes this by keeping track of otg_vbus_enabled and the requested
> > charger_type settings and when otg_vbus_enabled is true, delay applying
> > the charger_type until the 5V boost converter is turned off.
> 
> Both of them looks good to me, FWIW,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks, queued.

-- Sebastian

> > Cc: Bastien Nocera <hadess@hadess.net>
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > ---
> >  drivers/power/supply/bq24190_charger.c | 41 +++++++++++++++++++-------
> >  1 file changed, 30 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> > index dcbfd97a55be..aa1a589eb9f2 100644
> > --- a/drivers/power/supply/bq24190_charger.c
> > +++ b/drivers/power/supply/bq24190_charger.c
> > @@ -163,6 +163,8 @@ struct bq24190_dev_info {
> >  	char				model_name[I2C_NAME_SIZE];
> >  	bool				initialized;
> >  	bool				irq_event;
> > +	bool				otg_vbus_enabled;
> > +	int				charge_type;
> >  	u16				sys_min;
> >  	u16				iprechg;
> >  	u16				iterm;
> > @@ -176,6 +178,9 @@ struct bq24190_dev_info {
> >  	u8				watchdog;
> >  };
> >  
> > +static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
> > +					   const union power_supply_propval *val);
> > +
> >  static const unsigned int bq24190_usb_extcon_cable[] = {
> >  	EXTCON_USB,
> >  	EXTCON_NONE,
> > @@ -502,8 +507,9 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
> >  }
> >  #endif
> >  
> > -static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
> > +static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
> >  {
> > +	union power_supply_propval val = { .intval = bdi->charge_type };
> >  	int ret;
> >  
> >  	ret = pm_runtime_get_sync(bdi->dev);
> > @@ -513,9 +519,14 @@ static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
> >  		return ret;
> >  	}
> >  
> > -	ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
> > -				 BQ24190_REG_POC_CHG_CONFIG_MASK,
> > -				 BQ24190_REG_POC_CHG_CONFIG_SHIFT, val);
> > +	bdi->otg_vbus_enabled = enable;
> > +	if (enable)
> > +		ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
> > +					 BQ24190_REG_POC_CHG_CONFIG_MASK,
> > +					 BQ24190_REG_POC_CHG_CONFIG_SHIFT,
> > +					 BQ24190_REG_POC_CHG_CONFIG_OTG);
> > +	else
> > +		ret = bq24190_charger_set_charge_type(bdi, &val);
> >  
> >  	pm_runtime_mark_last_busy(bdi->dev);
> >  	pm_runtime_put_autosuspend(bdi->dev);
> > @@ -526,14 +537,12 @@ static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val)
> >  #ifdef CONFIG_REGULATOR
> >  static int bq24190_vbus_enable(struct regulator_dev *dev)
> >  {
> > -	return bq24190_set_charge_mode(rdev_get_drvdata(dev),
> > -				       BQ24190_REG_POC_CHG_CONFIG_OTG);
> > +	return bq24190_set_otg_vbus(rdev_get_drvdata(dev), true);
> >  }
> >  
> >  static int bq24190_vbus_disable(struct regulator_dev *dev)
> >  {
> > -	return bq24190_set_charge_mode(rdev_get_drvdata(dev),
> > -				       BQ24190_REG_POC_CHG_CONFIG_CHARGE);
> > +	return bq24190_set_otg_vbus(rdev_get_drvdata(dev), false);
> >  }
> >  
> >  static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
> > @@ -559,8 +568,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
> >  	if (ret)
> >  		return ret;
> >  
> > -	return (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
> > -		val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
> > +	bdi->otg_vbus_enabled = (val == BQ24190_REG_POC_CHG_CONFIG_OTG ||
> > +				 val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT);
> > +	return bdi->otg_vbus_enabled;
> >  }
> >  
> >  static const struct regulator_ops bq24190_vbus_ops = {
> > @@ -807,6 +817,14 @@ static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
> >  		return -EINVAL;
> >  	}
> >  
> > +	bdi->charge_type = val->intval;
> > +	/*
> > +	 * If the 5V Vbus boost regulator is enabled delay setting
> > +	 * the charge-type until its gets disabled.
> > +	 */
> > +	if (bdi->otg_vbus_enabled)
> > +		return 0;
> > +
> >  	if (chg_config) { /* Enabling the charger */
> >  		ret = bq24190_write_mask(bdi, BQ24190_REG_CCC,
> >  				BQ24190_REG_CCC_FORCE_20PCT_MASK,
> > @@ -1788,6 +1806,7 @@ static int bq24190_probe(struct i2c_client *client,
> >  	bdi->dev = dev;
> >  	strncpy(bdi->model_name, id->name, I2C_NAME_SIZE);
> >  	mutex_init(&bdi->f_reg_lock);
> > +	bdi->charge_type = POWER_SUPPLY_CHARGE_TYPE_FAST;
> >  	bdi->f_reg = 0;
> >  	bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
> >  	INIT_DELAYED_WORK(&bdi->input_current_limit_work,
> > @@ -1925,7 +1944,7 @@ static void bq24190_shutdown(struct i2c_client *client)
> >  	struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
> >  
> >  	/* Turn off 5V boost regulator on shutdown */
> > -	bq24190_set_charge_mode(bdi, BQ24190_REG_POC_CHG_CONFIG_CHARGE);
> > +	bq24190_set_otg_vbus(bdi, false);
> >  }
> >  
> >  static __maybe_unused int bq24190_runtime_suspend(struct device *dev)
> > -- 
> > 2.33.1
> > 
> > 
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-25 19:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-12 16:48 [PATCH 1/2] power: supply: bq24190_charger: Fix bq24190_vbus_is_enabled() wrong false return Hans de Goede
2022-02-12 16:48 ` [PATCH 2/2] power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on Hans de Goede
2022-02-25 16:47   ` Andy Shevchenko
2022-02-25 19:10     ` Sebastian Reichel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.