devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible
@ 2024-11-16 20:36 Hans de Goede
  2024-11-16 20:36 ` [PATCH 2/3] power: supply: bq24190: Fix BQ24296 Vbus regulator support Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hans de Goede @ 2024-11-16 20:36 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: Hans de Goede, Hermes Zhang, linux-pm, devicetree

The BQ24297 is identical to the BQ24296 except that it uses USB D+ / D-
data-lines for charger-type (max. input-current) detection instead of
a PSEL input pin.

This is the same difference as between the already supported BQ24190
(D+ / D-) and the BQ24192 (PSEL).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 Documentation/devicetree/bindings/power/supply/bq24190.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.yaml b/Documentation/devicetree/bindings/power/supply/bq24190.yaml
index 131b7e57d22f..07adf88997b4 100644
--- a/Documentation/devicetree/bindings/power/supply/bq24190.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq24190.yaml
@@ -21,6 +21,7 @@ properties:
       - ti,bq24192i
       - ti,bq24196
       - ti,bq24296
+      - ti,bq24297
 
   reg:
     maxItems: 1
-- 
2.47.0


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

* [PATCH 2/3] power: supply: bq24190: Fix BQ24296 Vbus regulator support
  2024-11-16 20:36 [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Hans de Goede
@ 2024-11-16 20:36 ` Hans de Goede
  2024-11-16 20:36 ` [PATCH 3/3] power: supply: bq24190: Add BQ24297 support Hans de Goede
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2024-11-16 20:36 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: Hans de Goede, Hermes Zhang, linux-pm, devicetree

There are 2 issues with bq24296_set_otg_vbus():

1. When writing the OTG_CONFIG bit it uses POC_CHG_CONFIG_SHIFT which
   should be POC_OTG_CONFIG_SHIFT.

2. When turning the regulator off it never turns charging back on. Note
   this must be done through bq24190_charger_set_charge_type(), to ensure
   that the charge_type property value of none/trickle/fast is honored.

Resolve both issues to fix BQ24296 Vbus regulator support not working.

Fixes: b150a703b56f ("power: supply: bq24190_charger: Add support for BQ24296")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/bq24190_charger.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 0101aaca1a97..4881cbd0e672 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -567,6 +567,7 @@ static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
 
 static int bq24296_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
 {
+	union power_supply_propval val = { .intval = bdi->charge_type };
 	int ret;
 
 	ret = pm_runtime_resume_and_get(bdi->dev);
@@ -587,13 +588,18 @@ static int bq24296_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
 
 		ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
 					 BQ24296_REG_POC_OTG_CONFIG_MASK,
-					 BQ24296_REG_POC_CHG_CONFIG_SHIFT,
+					 BQ24296_REG_POC_OTG_CONFIG_SHIFT,
 					 BQ24296_REG_POC_OTG_CONFIG_OTG);
-	} else
+	} else {
 		ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
 					 BQ24296_REG_POC_OTG_CONFIG_MASK,
-					 BQ24296_REG_POC_CHG_CONFIG_SHIFT,
+					 BQ24296_REG_POC_OTG_CONFIG_SHIFT,
 					 BQ24296_REG_POC_OTG_CONFIG_DISABLE);
+		if (ret < 0)
+			goto out;
+
+		ret = bq24190_charger_set_charge_type(bdi, &val);
+	}
 
 out:
 	pm_runtime_mark_last_busy(bdi->dev);
-- 
2.47.0


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

* [PATCH 3/3] power: supply: bq24190: Add BQ24297 support
  2024-11-16 20:36 [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Hans de Goede
  2024-11-16 20:36 ` [PATCH 2/3] power: supply: bq24190: Fix BQ24296 Vbus regulator support Hans de Goede
@ 2024-11-16 20:36 ` Hans de Goede
  2024-11-19 17:29 ` [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Rob Herring (Arm)
  2024-12-18 23:36 ` (subset) " Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2024-11-16 20:36 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: Hans de Goede, Hermes Zhang, linux-pm, devicetree

The BQ24297 is identical to the BQ24296 except that it uses USB D+ / D-
data-lines for charger-type (max. input-current) detection instead of
a PSEL input pin.

This is the same difference as between the already supported BQ24190
(D+ / D-) and the BQ24192 (PSEL).

Note just like with the BQ24190 vs BQ24192 there is no difference how
the charger-IC works at the register-level. The only difference is in
the external hardware interface.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/bq24190_charger.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 4881cbd0e672..a6a9f3ede34a 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -152,6 +152,7 @@
 #define BQ24296_REG_VPRS_PN_MASK		(BIT(7) | BIT(6) | BIT(5))
 #define BQ24296_REG_VPRS_PN_SHIFT		5
 #define BQ24296_REG_VPRS_PN_24296		0x1
+#define BQ24296_REG_VPRS_PN_24297		0x3
 #define BQ24190_REG_VPRS_TS_PROFILE_MASK	BIT(2)
 #define BQ24190_REG_VPRS_TS_PROFILE_SHIFT	2
 #define BQ24190_REG_VPRS_DEV_REG_MASK		(BIT(1) | BIT(0))
@@ -208,6 +209,7 @@ enum bq24190_chip {
 	BQ24192i,
 	BQ24196,
 	BQ24296,
+	BQ24297,
 };
 
 /*
@@ -1904,6 +1906,7 @@ static int bq24296_check_chip(struct bq24190_dev_info *bdi)
 
 	switch (v) {
 	case BQ24296_REG_VPRS_PN_24296:
+	case BQ24296_REG_VPRS_PN_24297:
 		break;
 	default:
 		dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v);
@@ -2033,6 +2036,17 @@ static const struct bq24190_chip_info bq24190_chip_info_tbl[] = {
 		.ichg_array_size = BQ24296_CCC_ICHG_VALUES_LEN,
 #ifdef CONFIG_REGULATOR
 		.vbus_desc = &bq24296_vbus_desc,
+#endif
+		.check_chip = bq24296_check_chip,
+		.set_chg_config = bq24296_battery_set_chg_config,
+		.ntc_fault_mask = BQ24296_REG_F_NTC_FAULT_MASK,
+		.get_ntc_status = bq24296_charger_get_ntc_status,
+		.set_otg_vbus = bq24296_set_otg_vbus,
+	},
+	[BQ24297] = {
+		.ichg_array_size = BQ24296_CCC_ICHG_VALUES_LEN,
+#ifdef CONFIG_REGULATOR
+		.vbus_desc = &bq24296_vbus_desc,
 #endif
 		.check_chip = bq24296_check_chip,
 		.set_chg_config = bq24296_battery_set_chg_config,
@@ -2296,6 +2310,7 @@ static const struct i2c_device_id bq24190_i2c_ids[] = {
 	{ "bq24192i", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24192i] },
 	{ "bq24196", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24196] },
 	{ "bq24296", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24296] },
+	{ "bq24297", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24297] },
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids);
@@ -2306,6 +2321,7 @@ static const struct of_device_id bq24190_of_match[] = {
 	{ .compatible = "ti,bq24192i", .data = &bq24190_chip_info_tbl[BQ24192i] },
 	{ .compatible = "ti,bq24196", .data = &bq24190_chip_info_tbl[BQ24196] },
 	{ .compatible = "ti,bq24296", .data = &bq24190_chip_info_tbl[BQ24296] },
+	{ .compatible = "ti,bq24297", .data = &bq24190_chip_info_tbl[BQ24297] },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, bq24190_of_match);
-- 
2.47.0


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

* Re: [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible
  2024-11-16 20:36 [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Hans de Goede
  2024-11-16 20:36 ` [PATCH 2/3] power: supply: bq24190: Fix BQ24296 Vbus regulator support Hans de Goede
  2024-11-16 20:36 ` [PATCH 3/3] power: supply: bq24190: Add BQ24297 support Hans de Goede
@ 2024-11-19 17:29 ` Rob Herring (Arm)
  2024-12-18 23:36 ` (subset) " Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Rob Herring (Arm) @ 2024-11-19 17:29 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Hermes Zhang, Sebastian Reichel, linux-pm, Conor Dooley,
	devicetree, Krzysztof Kozlowski


On Sat, 16 Nov 2024 21:36:46 +0100, Hans de Goede wrote:
> The BQ24297 is identical to the BQ24296 except that it uses USB D+ / D-
> data-lines for charger-type (max. input-current) detection instead of
> a PSEL input pin.
> 
> This is the same difference as between the already supported BQ24190
> (D+ / D-) and the BQ24192 (PSEL).
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  Documentation/devicetree/bindings/power/supply/bq24190.yaml | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>


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

* Re: (subset) [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible
  2024-11-16 20:36 [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Hans de Goede
                   ` (2 preceding siblings ...)
  2024-11-19 17:29 ` [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Rob Herring (Arm)
@ 2024-12-18 23:36 ` Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2024-12-18 23:36 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Hans de Goede
  Cc: Hermes Zhang, linux-pm, devicetree


On Sat, 16 Nov 2024 21:36:46 +0100, Hans de Goede wrote:
> The BQ24297 is identical to the BQ24296 except that it uses USB D+ / D-
> data-lines for charger-type (max. input-current) detection instead of
> a PSEL input pin.
> 
> This is the same difference as between the already supported BQ24190
> (D+ / D-) and the BQ24192 (PSEL).
> 
> [...]

Applied, thanks!

[2/3] power: supply: bq24190: Fix BQ24296 Vbus regulator support
      commit: b3ded6072c5600704cfa3ce3a8dc8718d34bda66

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


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

end of thread, other threads:[~2024-12-18 23:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-16 20:36 [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Hans de Goede
2024-11-16 20:36 ` [PATCH 2/3] power: supply: bq24190: Fix BQ24296 Vbus regulator support Hans de Goede
2024-11-16 20:36 ` [PATCH 3/3] power: supply: bq24190: Add BQ24297 support Hans de Goede
2024-11-19 17:29 ` [PATCH 1/3] dt-bindings: power: supply: bq24190: Add BQ24297 compatible Rob Herring (Arm)
2024-12-18 23:36 ` (subset) " Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).