* [PATCH 2/7] power: supply: bq27xxx: report "not charging" on all types
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
@ 2020-09-08 20:13 ` Krzysztof Kozlowski
2020-09-08 20:54 ` Dan Murphy
2020-09-08 20:13 ` [PATCH 3/7] power: supply: bq27xxx: adjust whitespace Krzysztof Kozlowski
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-08 20:13 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Andrew F. Davis, Pali Rohár,
Dan Murphy, Krzysztof Kozlowski, linux-pm, devicetree,
linux-kernel
Commit 6f24ff97e323 ("power: supply: bq27xxx_battery: Add the
BQ27Z561 Battery monitor") and commit d74534c27775 ("power:
bq27xxx_battery: Add support for additional bq27xxx family devices")
added support for new device types by copying most of the code and
adding necessary quirks.
However they did not copy the code in bq27xxx_battery_status()
responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING.
Unify the bq27xxx_battery_status() so for all types when charger is
supplied, it will return "not charging" status.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
Not tested on BQ27Z561 or other types of batteries. Tested however on
bq34z100.
---
drivers/power/supply/bq27xxx_battery.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 92de7b720182..65806f668b1f 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1765,8 +1765,6 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
status = POWER_SUPPLY_STATUS_FULL;
else if (di->cache.flags & BQ27000_FLAG_CHGS)
status = POWER_SUPPLY_STATUS_CHARGING;
- else if (power_supply_am_i_supplied(di->bat) > 0)
- status = POWER_SUPPLY_STATUS_NOT_CHARGING;
else
status = POWER_SUPPLY_STATUS_DISCHARGING;
} else if (di->opts & BQ27Z561_O_BITS) {
@@ -1785,6 +1783,10 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
status = POWER_SUPPLY_STATUS_CHARGING;
}
+ if ((status == POWER_SUPPLY_STATUS_DISCHARGING) &&
+ (power_supply_am_i_supplied(di->bat) > 0))
+ status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+
val->intval = status;
return 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/7] power: supply: bq27xxx: report "not charging" on all types
2020-09-08 20:13 ` [PATCH 2/7] power: supply: bq27xxx: report "not charging" on all types Krzysztof Kozlowski
@ 2020-09-08 20:54 ` Dan Murphy
2020-09-09 6:35 ` Krzysztof Kozlowski
0 siblings, 1 reply; 12+ messages in thread
From: Dan Murphy @ 2020-09-08 20:54 UTC (permalink / raw)
To: Krzysztof Kozlowski, Sebastian Reichel, Rob Herring,
Pali Rohár, linux-pm, devicetree, linux-kernel
Krzysztof
On 9/8/20 3:13 PM, Krzysztof Kozlowski wrote:
> Commit 6f24ff97e323 ("power: supply: bq27xxx_battery: Add the
> BQ27Z561 Battery monitor") and commit d74534c27775 ("power:
> bq27xxx_battery: Add support for additional bq27xxx family devices")
> added support for new device types by copying most of the code and
> adding necessary quirks.
>
> However they did not copy the code in bq27xxx_battery_status()
> responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING.
>
> Unify the bq27xxx_battery_status() so for all types when charger is
> supplied, it will return "not charging" status.
If this is a fix then please populate the Fixes tag.
But not sure how both commits are tied here
Dan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/7] power: supply: bq27xxx: report "not charging" on all types
2020-09-08 20:54 ` Dan Murphy
@ 2020-09-09 6:35 ` Krzysztof Kozlowski
0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-09 6:35 UTC (permalink / raw)
To: Dan Murphy
Cc: Sebastian Reichel, Rob Herring, Pali Rohár, linux-pm,
devicetree, linux-kernel
On Tue, 8 Sep 2020 at 22:54, Dan Murphy <dmurphy@ti.com> wrote:
>
> Krzysztof
>
> On 9/8/20 3:13 PM, Krzysztof Kozlowski wrote:
> > Commit 6f24ff97e323 ("power: supply: bq27xxx_battery: Add the
> > BQ27Z561 Battery monitor") and commit d74534c27775 ("power:
> > bq27xxx_battery: Add support for additional bq27xxx family devices")
> > added support for new device types by copying most of the code and
> > adding necessary quirks.
> >
> > However they did not copy the code in bq27xxx_battery_status()
> > responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING.
> >
> > Unify the bq27xxx_battery_status() so for all types when charger is
> > supplied, it will return "not charging" status.
>
> If this is a fix then please populate the Fixes tag.
>
> But not sure how both commits are tied here
I am not convinced that it is a fix. It's rather missing functionality
on these new devices. The commits did not break anything. They just
did not implement "not charging" for new types.
Best Regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/7] power: supply: bq27xxx: adjust whitespace
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
2020-09-08 20:13 ` [PATCH 2/7] power: supply: bq27xxx: report "not charging" on all types Krzysztof Kozlowski
@ 2020-09-08 20:13 ` Krzysztof Kozlowski
2020-09-08 20:13 ` [PATCH 4/7] power: supply: bq27xxx: use BIT() for bit flags Krzysztof Kozlowski
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-08 20:13 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Andrew F. Davis, Pali Rohár,
Dan Murphy, Krzysztof Kozlowski, linux-pm, devicetree,
linux-kernel
No functional change.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/power/supply/bq27xxx_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 65806f668b1f..2deac3fbb036 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -76,7 +76,7 @@
/* BQ27Z561 has different layout for Flags register */
#define BQ27Z561_FLAG_FDC BIT(4) /* Battery fully discharged */
-#define BQ27Z561_FLAG_FC BIT(5) /* Battery fully charged */
+#define BQ27Z561_FLAG_FC BIT(5) /* Battery fully charged */
#define BQ27Z561_FLAG_DIS_CH BIT(6) /* Battery is discharging */
/* control register params */
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/7] power: supply: bq27xxx: use BIT() for bit flags
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
2020-09-08 20:13 ` [PATCH 2/7] power: supply: bq27xxx: report "not charging" on all types Krzysztof Kozlowski
2020-09-08 20:13 ` [PATCH 3/7] power: supply: bq27xxx: adjust whitespace Krzysztof Kozlowski
@ 2020-09-08 20:13 ` Krzysztof Kozlowski
2020-09-08 20:53 ` Dan Murphy
2020-09-08 20:13 ` [PATCH 5/7] power: supply: bq27xxx: add separate flag for single SoC register Krzysztof Kozlowski
` (3 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-08 20:13 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Andrew F. Davis, Pali Rohár,
Dan Murphy, Krzysztof Kozlowski, linux-pm, devicetree,
linux-kernel
BIT() is a preferred way to toggle bit-like flags: no problems with 32/64
bit systems, less chances for mistakes.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/power/supply/bq27xxx_battery.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 2deac3fbb036..e971af43dd45 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -847,13 +847,14 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
#define bq27z561_dm_regs 0
#define bq28z610_dm_regs 0
-
-#define BQ27XXX_O_ZERO 0x00000001
-#define BQ27XXX_O_OTDC 0x00000002 /* has OTC/OTD overtemperature flags */
-#define BQ27XXX_O_UTOT 0x00000004 /* has OT overtemperature flag */
-#define BQ27XXX_O_CFGUP 0x00000008
-#define BQ27XXX_O_RAM 0x00000010
-#define BQ27Z561_O_BITS 0x00000020
+#define bq34z100_dm_regs 0
+
+#define BQ27XXX_O_ZERO BIT(0)
+#define BQ27XXX_O_OTDC BIT(1) /* has OTC/OTD overtemperature flags */
+#define BQ27XXX_O_UTOT BIT(2) /* has OT overtemperature flag */
+#define BQ27XXX_O_CFGUP BIT(3)
+#define BQ27XXX_O_RAM BIT(4)
+#define BQ27Z561_O_BITS BIT(5)
#define BQ27XXX_DATA(ref, key, opt) { \
.opts = (opt), \
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/7] power: supply: bq27xxx: use BIT() for bit flags
2020-09-08 20:13 ` [PATCH 4/7] power: supply: bq27xxx: use BIT() for bit flags Krzysztof Kozlowski
@ 2020-09-08 20:53 ` Dan Murphy
2020-09-09 6:38 ` Krzysztof Kozlowski
0 siblings, 1 reply; 12+ messages in thread
From: Dan Murphy @ 2020-09-08 20:53 UTC (permalink / raw)
To: Krzysztof Kozlowski, Sebastian Reichel, Rob Herring,
Pali Rohár, linux-pm, devicetree, linux-kernel
Krzysztof
On 9/8/20 3:13 PM, Krzysztof Kozlowski wrote:
> BIT() is a preferred way to toggle bit-like flags: no problems with 32/64
> bit systems, less chances for mistakes.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
> drivers/power/supply/bq27xxx_battery.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 2deac3fbb036..e971af43dd45 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -847,13 +847,14 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
>
> #define bq27z561_dm_regs 0
> #define bq28z610_dm_regs 0
> -
> -#define BQ27XXX_O_ZERO 0x00000001
> -#define BQ27XXX_O_OTDC 0x00000002 /* has OTC/OTD overtemperature flags */
> -#define BQ27XXX_O_UTOT 0x00000004 /* has OT overtemperature flag */
> -#define BQ27XXX_O_CFGUP 0x00000008
> -#define BQ27XXX_O_RAM 0x00000010
> -#define BQ27Z561_O_BITS 0x00000020
> +#define bq34z100_dm_regs 0
> +
> +#define BQ27XXX_O_ZERO BIT(0)
> +#define BQ27XXX_O_OTDC BIT(1) /* has OTC/OTD overtemperature flags */
> +#define BQ27XXX_O_UTOT BIT(2) /* has OT overtemperature flag */
> +#define BQ27XXX_O_CFGUP BIT(3)
> +#define BQ27XXX_O_RAM BIT(4)
> +#define BQ27Z561_O_BITS BIT(5)
>
It seems you have added whitespaces that you submitted a patch to fix in
3/7.
Also squash 3 and 4.
Dan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/7] power: supply: bq27xxx: use BIT() for bit flags
2020-09-08 20:53 ` Dan Murphy
@ 2020-09-09 6:38 ` Krzysztof Kozlowski
0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-09 6:38 UTC (permalink / raw)
To: Dan Murphy
Cc: Sebastian Reichel, Rob Herring, Pali Rohár, linux-pm,
devicetree, linux-kernel
On Tue, 8 Sep 2020 at 22:53, Dan Murphy <dmurphy@ti.com> wrote:
>
> Krzysztof
>
> On 9/8/20 3:13 PM, Krzysztof Kozlowski wrote:
> > BIT() is a preferred way to toggle bit-like flags: no problems with 32/64
> > bit systems, less chances for mistakes.
> >
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > ---
> > drivers/power/supply/bq27xxx_battery.c | 15 ++++++++-------
> > 1 file changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> > index 2deac3fbb036..e971af43dd45 100644
> > --- a/drivers/power/supply/bq27xxx_battery.c
> > +++ b/drivers/power/supply/bq27xxx_battery.c
> > @@ -847,13 +847,14 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
> >
> > #define bq27z561_dm_regs 0
> > #define bq28z610_dm_regs 0
> > -
> > -#define BQ27XXX_O_ZERO 0x00000001
> > -#define BQ27XXX_O_OTDC 0x00000002 /* has OTC/OTD overtemperature flags */
> > -#define BQ27XXX_O_UTOT 0x00000004 /* has OT overtemperature flag */
> > -#define BQ27XXX_O_CFGUP 0x00000008
> > -#define BQ27XXX_O_RAM 0x00000010
> > -#define BQ27Z561_O_BITS 0x00000020
> > +#define bq34z100_dm_regs 0
> > +
> > +#define BQ27XXX_O_ZERO BIT(0)
> > +#define BQ27XXX_O_OTDC BIT(1) /* has OTC/OTD overtemperature flags */
> > +#define BQ27XXX_O_UTOT BIT(2) /* has OT overtemperature flag */
> > +#define BQ27XXX_O_CFGUP BIT(3)
> > +#define BQ27XXX_O_RAM BIT(4)
> > +#define BQ27Z561_O_BITS BIT(5)
> >
>
> It seems you have added whitespaces that you submitted a patch to fix in
> 3/7.
I shouldn't... 3/7 is different #define: BQ27Z561_FLAG_FC
Here it might look like not indented properly due to the patch format.
In the file, when applying, the entries are aligned correctly.
>
> Also squash 3 and 4.
Whitespace with BIT conversion? Sure, I can. These are separate places
and different types of cleanup, but no problem to squash them.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 5/7] power: supply: bq27xxx: add separate flag for single SoC register
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
` (2 preceding siblings ...)
2020-09-08 20:13 ` [PATCH 4/7] power: supply: bq27xxx: use BIT() for bit flags Krzysztof Kozlowski
@ 2020-09-08 20:13 ` Krzysztof Kozlowski
2020-09-08 20:13 ` [PATCH 6/7] power: supply: bq27xxx: add separate flag for capacity inaccurate Krzysztof Kozlowski
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-08 20:13 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Andrew F. Davis, Pali Rohár,
Dan Murphy, Krzysztof Kozlowski, linux-pm, devicetree,
linux-kernel
bq27000, bq27010 and upcoming bq34z100 have a single byte SoC
register. However except this similarity, bq34z100 is quite different
than bq27000/bq27010, so flag BQ27XXX_O_ZERO cannot be reused here. Add
a new bit flag describing that SoC is a single byte register.
No functional change for bq27000 and bq27010.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/power/supply/bq27xxx_battery.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index e971af43dd45..88cdad0ecb08 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -855,6 +855,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
#define BQ27XXX_O_CFGUP BIT(3)
#define BQ27XXX_O_RAM BIT(4)
#define BQ27Z561_O_BITS BIT(5)
+#define BQ27XXX_O_SOC_SI BIT(6) /* SoC is single register */
#define BQ27XXX_DATA(ref, key, opt) { \
.opts = (opt), \
@@ -872,8 +873,8 @@ static struct {
enum power_supply_property *props;
size_t props_size;
} bq27xxx_chip_data[] = {
- [BQ27000] = BQ27XXX_DATA(bq27000, 0 , BQ27XXX_O_ZERO),
- [BQ27010] = BQ27XXX_DATA(bq27010, 0 , BQ27XXX_O_ZERO),
+ [BQ27000] = BQ27XXX_DATA(bq27000, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI),
+ [BQ27010] = BQ27XXX_DATA(bq27010, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI),
[BQ2750X] = BQ27XXX_DATA(bq2750x, 0 , BQ27XXX_O_OTDC),
[BQ2751X] = BQ27XXX_DATA(bq2751x, 0 , BQ27XXX_O_OTDC),
[BQ2752X] = BQ27XXX_DATA(bq2752x, 0 , BQ27XXX_O_OTDC),
@@ -1420,7 +1421,7 @@ static int bq27xxx_battery_read_soc(struct bq27xxx_device_info *di)
{
int soc;
- if (di->opts & BQ27XXX_O_ZERO)
+ if (di->opts & BQ27XXX_O_SOC_SI)
soc = bq27xxx_read(di, BQ27XXX_REG_SOC, true);
else
soc = bq27xxx_read(di, BQ27XXX_REG_SOC, false);
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/7] power: supply: bq27xxx: add separate flag for capacity inaccurate
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
` (3 preceding siblings ...)
2020-09-08 20:13 ` [PATCH 5/7] power: supply: bq27xxx: add separate flag for single SoC register Krzysztof Kozlowski
@ 2020-09-08 20:13 ` Krzysztof Kozlowski
2020-09-08 20:13 ` [PATCH 7/7] power: supply: bq27xxx: add support for TI bq34z100 Krzysztof Kozlowski
2020-09-15 17:12 ` [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Rob Herring
6 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-08 20:13 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Andrew F. Davis, Pali Rohár,
Dan Murphy, Krzysztof Kozlowski, linux-pm, devicetree,
linux-kernel
bq27000, bq27010 and upcoming bq34z100 have a Capacity Inaccurate flag.
However except this similarity, bq34z100 is quite different than
bq27000/bq27010, so flag BQ27XXX_O_ZERO cannot be reused here. Add
a new bit flag describing this capability.
No functional change for bq27000 and bq27010.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/power/supply/bq27xxx_battery.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 88cdad0ecb08..cda03e1f9586 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -856,6 +856,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
#define BQ27XXX_O_RAM BIT(4)
#define BQ27Z561_O_BITS BIT(5)
#define BQ27XXX_O_SOC_SI BIT(6) /* SoC is single register */
+#define BQ27XXX_O_HAS_CI BIT(7) /* has Capacity Inaccurate flag */
#define BQ27XXX_DATA(ref, key, opt) { \
.opts = (opt), \
@@ -873,8 +874,8 @@ static struct {
enum power_supply_property *props;
size_t props_size;
} bq27xxx_chip_data[] = {
- [BQ27000] = BQ27XXX_DATA(bq27000, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI),
- [BQ27010] = BQ27XXX_DATA(bq27010, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI),
+ [BQ27000] = BQ27XXX_DATA(bq27000, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI | BQ27XXX_O_HAS_CI),
+ [BQ27010] = BQ27XXX_DATA(bq27010, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI | BQ27XXX_O_HAS_CI),
[BQ2750X] = BQ27XXX_DATA(bq2750x, 0 , BQ27XXX_O_OTDC),
[BQ2751X] = BQ27XXX_DATA(bq2751x, 0 , BQ27XXX_O_OTDC),
[BQ2752X] = BQ27XXX_DATA(bq2752x, 0 , BQ27XXX_O_OTDC),
@@ -1659,7 +1660,7 @@ static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
void bq27xxx_battery_update(struct bq27xxx_device_info *di)
{
struct bq27xxx_reg_cache cache = {0, };
- bool has_ci_flag = di->opts & BQ27XXX_O_ZERO;
+ bool has_ci_flag = di->opts & BQ27XXX_O_HAS_CI;
bool has_singe_flag = di->opts & BQ27XXX_O_ZERO;
cache.flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag);
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/7] power: supply: bq27xxx: add support for TI bq34z100
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
` (4 preceding siblings ...)
2020-09-08 20:13 ` [PATCH 6/7] power: supply: bq27xxx: add separate flag for capacity inaccurate Krzysztof Kozlowski
@ 2020-09-08 20:13 ` Krzysztof Kozlowski
2020-09-15 17:12 ` [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Rob Herring
6 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-08 20:13 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Andrew F. Davis, Pali Rohár,
Dan Murphy, Krzysztof Kozlowski, linux-pm, devicetree,
linux-kernel
Add support for new device: the TI bq34z100-G1, a Wide Range Fuel Gauge
for Li-Ion, PbA, NiMH, and NiCd batteries. The device shares a lot with
other models, although it has its own differences requiring new quirks.
This patch was tested on a system equipped with NiMH batteries.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/power/supply/bq27xxx_battery.c | 50 +++++++++++++++++++++-
drivers/power/supply/bq27xxx_battery_i2c.c | 2 +
include/linux/power/bq27xxx_battery.h | 1 +
3 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index cda03e1f9586..315e0909e6a4 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -38,6 +38,7 @@
* https://www.ti.com/product/bq27621-g1
* https://www.ti.com/product/bq27z561
* https://www.ti.com/product/bq28z610
+ * https://www.ti.com/product/bq34z100-g1
*/
#include <linux/device.h>
@@ -476,6 +477,26 @@ static u8
[BQ27XXX_REG_DCAP] = 0x3c,
[BQ27XXX_REG_AP] = 0x22,
BQ27XXX_DM_REG_ROWS,
+ },
+ bq34z100_regs[BQ27XXX_REG_MAX] = {
+ [BQ27XXX_REG_CTRL] = 0x00,
+ [BQ27XXX_REG_TEMP] = 0x0c,
+ [BQ27XXX_REG_INT_TEMP] = 0x2a,
+ [BQ27XXX_REG_VOLT] = 0x08,
+ [BQ27XXX_REG_AI] = 0x0a,
+ [BQ27XXX_REG_FLAGS] = 0x0e,
+ [BQ27XXX_REG_TTE] = 0x18,
+ [BQ27XXX_REG_TTF] = 0x1a,
+ [BQ27XXX_REG_TTES] = 0x1e,
+ [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR,
+ [BQ27XXX_REG_NAC] = INVALID_REG_ADDR,
+ [BQ27XXX_REG_FCC] = 0x06,
+ [BQ27XXX_REG_CYCT] = 0x2c,
+ [BQ27XXX_REG_AE] = 0x24,
+ [BQ27XXX_REG_SOC] = 0x02,
+ [BQ27XXX_REG_DCAP] = 0x3c,
+ [BQ27XXX_REG_AP] = 0x22,
+ BQ27XXX_DM_REG_ROWS,
};
static enum power_supply_property bq27000_props[] = {
@@ -750,6 +771,27 @@ static enum power_supply_property bq28z610_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
};
+static enum power_supply_property bq34z100_props[] = {
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_PRESENT,
+ POWER_SUPPLY_PROP_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_CAPACITY_LEVEL,
+ POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
+ POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
+ POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
+ POWER_SUPPLY_PROP_TECHNOLOGY,
+ POWER_SUPPLY_PROP_CHARGE_FULL,
+ POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+ POWER_SUPPLY_PROP_CYCLE_COUNT,
+ POWER_SUPPLY_PROP_ENERGY_NOW,
+ POWER_SUPPLY_PROP_POWER_AVG,
+ POWER_SUPPLY_PROP_HEALTH,
+ POWER_SUPPLY_PROP_MANUFACTURER,
+};
+
struct bq27xxx_dm_reg {
u8 subclass_id;
u8 offset;
@@ -857,6 +899,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
#define BQ27Z561_O_BITS BIT(5)
#define BQ27XXX_O_SOC_SI BIT(6) /* SoC is single register */
#define BQ27XXX_O_HAS_CI BIT(7) /* has Capacity Inaccurate flag */
+#define BQ27XXX_O_MUL_CHEM BIT(8) /* multiple chemistries supported */
#define BQ27XXX_DATA(ref, key, opt) { \
.opts = (opt), \
@@ -903,6 +946,8 @@ static struct {
[BQ27621] = BQ27XXX_DATA(bq27621, 0x80008000, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
[BQ27Z561] = BQ27XXX_DATA(bq27z561, 0 , BQ27Z561_O_BITS),
[BQ28Z610] = BQ27XXX_DATA(bq28z610, 0 , BQ27Z561_O_BITS),
+ [BQ34Z100] = BQ27XXX_DATA(bq34z100, 0 , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \
+ BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM),
};
static DEFINE_MUTEX(bq27xxx_list_lock);
@@ -1914,7 +1959,10 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
ret = bq27xxx_simple_value(di->cache.time_to_full, val);
break;
case POWER_SUPPLY_PROP_TECHNOLOGY:
- val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+ if (di->opts & BQ27XXX_O_MUL_CHEM)
+ val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
+ else
+ val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
break;
case POWER_SUPPLY_PROP_CHARGE_NOW:
ret = bq27xxx_simple_value(bq27xxx_battery_read_nac(di), val);
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 765873dfc495..eb4f4284982f 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -247,6 +247,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
{ "bq27621", BQ27621 },
{ "bq27z561", BQ27Z561 },
{ "bq28z610", BQ28Z610 },
+ { "bq34z100", BQ34Z100 },
{},
};
MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table);
@@ -282,6 +283,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
{ .compatible = "ti,bq27621" },
{ .compatible = "ti,bq27z561" },
{ .compatible = "ti,bq28z610" },
+ { .compatible = "ti,bq34z100" },
{},
};
MODULE_DEVICE_TABLE(of, bq27xxx_battery_i2c_of_match_table);
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index 987d9652aa4e..111a40d0d3d5 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -32,6 +32,7 @@ enum bq27xxx_chip {
BQ27621,
BQ27Z561,
BQ28Z610,
+ BQ34Z100,
};
struct bq27xxx_device_info;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100
2020-09-08 20:13 [PATCH 1/7] dt-bindings: power: bq27xxx: add bq34z100 Krzysztof Kozlowski
` (5 preceding siblings ...)
2020-09-08 20:13 ` [PATCH 7/7] power: supply: bq27xxx: add support for TI bq34z100 Krzysztof Kozlowski
@ 2020-09-15 17:12 ` Rob Herring
6 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2020-09-15 17:12 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Pali Rohár, linux-pm, Sebastian Reichel, Dan Murphy,
devicetree, Andrew F. Davis, linux-kernel, Rob Herring
On Tue, 08 Sep 2020 22:13:13 +0200, Krzysztof Kozlowski wrote:
> Add compatible for bq34z100 charger.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
> Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread