* [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type
@ 2021-08-05 8:58 Linus Walleij
2021-08-05 8:58 ` [PATCH 2/2 v2] power: supply: core: Parse battery type/technology Linus Walleij
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Linus Walleij @ 2021-08-05 8:58 UTC (permalink / raw)
To: Sebastian Reichel, Marcus Cooper; +Cc: linux-pm, Linus Walleij, devicetree
This adds a battery-type property and bindings for the different
"technologies" that are used in Linux. More types can be added.
This is needed to convert the custom ST-Ericsson AB8500 battery
properties over to the generic battery bindings.
Cc: devicetree@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Add devicetree list to Cc
- Use "device-chemistry" instead of "battery-type" as this
has precedence in standards.
I need a bunch of new bindings for switch the STE AB8500 custom
bindings out, but I need to start somewhere, this is as good as
any place to start.
---
.../devicetree/bindings/power/supply/battery.yaml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/devicetree/bindings/power/supply/battery.yaml b/Documentation/devicetree/bindings/power/supply/battery.yaml
index c3b4b7543591..d56ac484fec5 100644
--- a/Documentation/devicetree/bindings/power/supply/battery.yaml
+++ b/Documentation/devicetree/bindings/power/supply/battery.yaml
@@ -31,6 +31,20 @@ properties:
compatible:
const: simple-battery
+ device-chemistry:
+ description: This describes the chemical technology of the battery.
+ oneOf:
+ - const: nickel-cadmium
+ - const: nickel-metal-hydride
+ - const: lithium-ion
+ description: This is a blanket type for all lithium-ion batteries,
+ including those below. If possible, a precise compatible string
+ from below should be used, but sometimes it is unknown which specific
+ lithium ion battery is employed and this wide compatible can be used.
+ - const: lithium-ion-polymer
+ - const: lithium-ion-iron-phosphate
+ - const: lithium-ion-manganese-oxide
+
over-voltage-threshold-microvolt:
description: battery over-voltage limit
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/2 v2] power: supply: core: Parse battery type/technology 2021-08-05 8:58 [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Linus Walleij @ 2021-08-05 8:58 ` Linus Walleij 2021-08-05 16:04 ` Sebastian Reichel 2021-08-05 16:03 ` [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Sebastian Reichel 2021-08-13 18:26 ` Rob Herring 2 siblings, 1 reply; 7+ messages in thread From: Linus Walleij @ 2021-08-05 8:58 UTC (permalink / raw) To: Sebastian Reichel, Marcus Cooper; +Cc: linux-pm, Linus Walleij This extends the struct power_supply_battery_info with a "technology" field makes the core DT parser optionally obtain this from the device tree. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- ChangeLog v1->v2: - Drop the accidental double assignment of err as reported by the kernel test robot et al. - Switch to "device-chemistry" instead of "battery-type" to indicate the type. This is needed to migrate the STE AB8500 custom battery bindings and parser to the generic parser. --- drivers/power/supply/power_supply_core.c | 20 ++++++++++++++++++++ include/linux/power_supply.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index d99e2f11c183..dd62c871b2b5 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -571,6 +571,7 @@ int power_supply_get_battery_info(struct power_supply *psy, int err, len, index; const __be32 *list; + info->technology = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; info->energy_full_design_uwh = -EINVAL; info->charge_full_design_uah = -EINVAL; info->voltage_min_design_uv = -EINVAL; @@ -618,6 +619,25 @@ int power_supply_get_battery_info(struct power_supply *psy, * Documentation/power/power_supply_class.rst. */ + err = of_property_read_string(battery_np, "device-chemistry", &value); + if (!err) { + if (!strcmp("nickel-cadmium", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_NiCd; + else if (!strcmp("nickel-metal-hydride", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_NiMH; + else if (!strcmp("lithium-ion", value)) + /* Imprecise lithium-ion type */ + info->technology = POWER_SUPPLY_TECHNOLOGY_LION; + else if (!strcmp("lithium-ion-polymer", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_LIPO; + else if (!strcmp("lithium-ion-iron-phosphate", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_LiFe; + else if (!strcmp("lithium-ion-manganese-oxide", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_LiMn; + else + dev_warn(&psy->dev, "%s unknown battery type\n", value); + } + of_property_read_u32(battery_np, "energy-full-design-microwatt-hours", &info->energy_full_design_uwh); of_property_read_u32(battery_np, "charge-full-design-microamp-hours", diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index be203985ecdd..9ca1f120a211 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -352,6 +352,7 @@ struct power_supply_resistance_temp_table { */ struct power_supply_battery_info { + unsigned int technology; /* from the enum above */ int energy_full_design_uwh; /* microWatt-hours */ int charge_full_design_uah; /* microAmp-hours */ int voltage_min_design_uv; /* microVolts */ -- 2.31.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2 v2] power: supply: core: Parse battery type/technology 2021-08-05 8:58 ` [PATCH 2/2 v2] power: supply: core: Parse battery type/technology Linus Walleij @ 2021-08-05 16:04 ` Sebastian Reichel 0 siblings, 0 replies; 7+ messages in thread From: Sebastian Reichel @ 2021-08-05 16:04 UTC (permalink / raw) To: Linus Walleij; +Cc: Marcus Cooper, linux-pm [-- Attachment #1: Type: text/plain, Size: 3272 bytes --] Hi, On Thu, Aug 05, 2021 at 10:58:28AM +0200, Linus Walleij wrote: > This extends the struct power_supply_battery_info with a > "technology" field makes the core DT parser optionally obtain > this from the device tree. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> -- Sebastian > ChangeLog v1->v2: > - Drop the accidental double assignment of err as reported > by the kernel test robot et al. > - Switch to "device-chemistry" instead of "battery-type" > to indicate the type. > This is needed to migrate the STE AB8500 custom battery bindings > and parser to the generic parser. > --- > drivers/power/supply/power_supply_core.c | 20 ++++++++++++++++++++ > include/linux/power_supply.h | 1 + > 2 files changed, 21 insertions(+) > > diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c > index d99e2f11c183..dd62c871b2b5 100644 > --- a/drivers/power/supply/power_supply_core.c > +++ b/drivers/power/supply/power_supply_core.c > @@ -571,6 +571,7 @@ int power_supply_get_battery_info(struct power_supply *psy, > int err, len, index; > const __be32 *list; > > + info->technology = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; > info->energy_full_design_uwh = -EINVAL; > info->charge_full_design_uah = -EINVAL; > info->voltage_min_design_uv = -EINVAL; > @@ -618,6 +619,25 @@ int power_supply_get_battery_info(struct power_supply *psy, > * Documentation/power/power_supply_class.rst. > */ > > + err = of_property_read_string(battery_np, "device-chemistry", &value); > + if (!err) { > + if (!strcmp("nickel-cadmium", value)) > + info->technology = POWER_SUPPLY_TECHNOLOGY_NiCd; > + else if (!strcmp("nickel-metal-hydride", value)) > + info->technology = POWER_SUPPLY_TECHNOLOGY_NiMH; > + else if (!strcmp("lithium-ion", value)) > + /* Imprecise lithium-ion type */ > + info->technology = POWER_SUPPLY_TECHNOLOGY_LION; > + else if (!strcmp("lithium-ion-polymer", value)) > + info->technology = POWER_SUPPLY_TECHNOLOGY_LIPO; > + else if (!strcmp("lithium-ion-iron-phosphate", value)) > + info->technology = POWER_SUPPLY_TECHNOLOGY_LiFe; > + else if (!strcmp("lithium-ion-manganese-oxide", value)) > + info->technology = POWER_SUPPLY_TECHNOLOGY_LiMn; > + else > + dev_warn(&psy->dev, "%s unknown battery type\n", value); > + } > + > of_property_read_u32(battery_np, "energy-full-design-microwatt-hours", > &info->energy_full_design_uwh); > of_property_read_u32(battery_np, "charge-full-design-microamp-hours", > diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h > index be203985ecdd..9ca1f120a211 100644 > --- a/include/linux/power_supply.h > +++ b/include/linux/power_supply.h > @@ -352,6 +352,7 @@ struct power_supply_resistance_temp_table { > */ > > struct power_supply_battery_info { > + unsigned int technology; /* from the enum above */ > int energy_full_design_uwh; /* microWatt-hours */ > int charge_full_design_uah; /* microAmp-hours */ > int voltage_min_design_uv; /* microVolts */ > -- > 2.31.1 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type 2021-08-05 8:58 [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Linus Walleij 2021-08-05 8:58 ` [PATCH 2/2 v2] power: supply: core: Parse battery type/technology Linus Walleij @ 2021-08-05 16:03 ` Sebastian Reichel 2021-08-13 18:26 ` Rob Herring 2 siblings, 0 replies; 7+ messages in thread From: Sebastian Reichel @ 2021-08-05 16:03 UTC (permalink / raw) To: Linus Walleij; +Cc: Marcus Cooper, linux-pm, devicetree [-- Attachment #1: Type: text/plain, Size: 2232 bytes --] Hi, On Thu, Aug 05, 2021 at 10:58:27AM +0200, Linus Walleij wrote: > This adds a battery-type property and bindings for the different > "technologies" that are used in Linux. More types can be added. > > This is needed to convert the custom ST-Ericsson AB8500 battery > properties over to the generic battery bindings. > > Cc: devicetree@vger.kernel.org > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > ChangeLog v1->v2: > - Add devicetree list to Cc > - Use "device-chemistry" instead of "battery-type" as this > has precedence in standards. > I need a bunch of new bindings for switch the STE AB8500 custom > bindings out, but I need to start somewhere, this is as good as > any place to start. > --- Waiting a bit to give Rob a chance to review this. From my side it looks good. Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> -- Sebastian > .../devicetree/bindings/power/supply/battery.yaml | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/Documentation/devicetree/bindings/power/supply/battery.yaml b/Documentation/devicetree/bindings/power/supply/battery.yaml > index c3b4b7543591..d56ac484fec5 100644 > --- a/Documentation/devicetree/bindings/power/supply/battery.yaml > +++ b/Documentation/devicetree/bindings/power/supply/battery.yaml > @@ -31,6 +31,20 @@ properties: > compatible: > const: simple-battery > > + device-chemistry: > + description: This describes the chemical technology of the battery. > + oneOf: > + - const: nickel-cadmium > + - const: nickel-metal-hydride > + - const: lithium-ion > + description: This is a blanket type for all lithium-ion batteries, > + including those below. If possible, a precise compatible string > + from below should be used, but sometimes it is unknown which specific > + lithium ion battery is employed and this wide compatible can be used. > + - const: lithium-ion-polymer > + - const: lithium-ion-iron-phosphate > + - const: lithium-ion-manganese-oxide > + > over-voltage-threshold-microvolt: > description: battery over-voltage limit > > -- > 2.31.1 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type 2021-08-05 8:58 [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Linus Walleij 2021-08-05 8:58 ` [PATCH 2/2 v2] power: supply: core: Parse battery type/technology Linus Walleij 2021-08-05 16:03 ` [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Sebastian Reichel @ 2021-08-13 18:26 ` Rob Herring 2021-08-13 21:46 ` Linus Walleij 2 siblings, 1 reply; 7+ messages in thread From: Rob Herring @ 2021-08-13 18:26 UTC (permalink / raw) To: Linus Walleij; +Cc: Sebastian Reichel, Marcus Cooper, linux-pm, devicetree On Thu, Aug 05, 2021 at 10:58:27AM +0200, Linus Walleij wrote: > This adds a battery-type property and bindings for the different s/battery-type/"device-chemistry"/ Otherwise, Reviewed-by: Rob Herring <robh@kernel.org> > "technologies" that are used in Linux. More types can be added. > > This is needed to convert the custom ST-Ericsson AB8500 battery > properties over to the generic battery bindings. > > Cc: devicetree@vger.kernel.org > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > ChangeLog v1->v2: > - Add devicetree list to Cc > - Use "device-chemistry" instead of "battery-type" as this > has precedence in standards. > I need a bunch of new bindings for switch the STE AB8500 custom > bindings out, but I need to start somewhere, this is as good as > any place to start. > --- > .../devicetree/bindings/power/supply/battery.yaml | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type 2021-08-13 18:26 ` Rob Herring @ 2021-08-13 21:46 ` Linus Walleij 2021-08-14 10:55 ` Sebastian Reichel 0 siblings, 1 reply; 7+ messages in thread From: Linus Walleij @ 2021-08-13 21:46 UTC (permalink / raw) To: Rob Herring Cc: Sebastian Reichel, Marcus Cooper, Linux PM list, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS On Fri, Aug 13, 2021 at 8:26 PM Rob Herring <robh@kernel.org> wrote: > On Thu, Aug 05, 2021 at 10:58:27AM +0200, Linus Walleij wrote: > > This adds a battery-type property and bindings for the different > > s/battery-type/"device-chemistry"/ > > Otherwise, > > Reviewed-by: Rob Herring <robh@kernel.org> Thanks Rob, Sebastian tell me if you can fix this when applying or if you want me to respin the patch. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type 2021-08-13 21:46 ` Linus Walleij @ 2021-08-14 10:55 ` Sebastian Reichel 0 siblings, 0 replies; 7+ messages in thread From: Sebastian Reichel @ 2021-08-14 10:55 UTC (permalink / raw) To: Linus Walleij Cc: Rob Herring, Marcus Cooper, Linux PM list, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS [-- Attachment #1: Type: text/plain, Size: 629 bytes --] Hi, On Fri, Aug 13, 2021 at 11:46:52PM +0200, Linus Walleij wrote: > On Fri, Aug 13, 2021 at 8:26 PM Rob Herring <robh@kernel.org> wrote: > > On Thu, Aug 05, 2021 at 10:58:27AM +0200, Linus Walleij wrote: > > > This adds a battery-type property and bindings for the different > > > > s/battery-type/"device-chemistry"/ > > > > Otherwise, > > > > Reviewed-by: Rob Herring <robh@kernel.org> > > Thanks Rob, Sebastian tell me if you can fix this when applying > or if you want me to respin the patch. No, that's fine. I queued both patches with type changed to chemistry in the commit messages. -- Sebastian [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-08-14 10:55 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-08-05 8:58 [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Linus Walleij 2021-08-05 8:58 ` [PATCH 2/2 v2] power: supply: core: Parse battery type/technology Linus Walleij 2021-08-05 16:04 ` Sebastian Reichel 2021-08-05 16:03 ` [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Sebastian Reichel 2021-08-13 18:26 ` Rob Herring 2021-08-13 21:46 ` Linus Walleij 2021-08-14 10:55 ` 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.