mbox series

[RFC,v2,0/5] Support ROHM BD99954 charger IC

Message ID cover.1581597365.git.matti.vaittinen@fi.rohmeurope.com
Headers show
Series Support ROHM BD99954 charger IC | expand

Message

Matti Vaittinen Feb. 14, 2020, 7:29 a.m. UTC
Support ROHM BD99954 Battery Management IC

ROHM BD99954 is a Battery Management IC for 1-4 cell Lithium-Ion
secondary battery. BD99954 is intended to be used in space-constraint
equipment such as Low profile Notebook PC, Tablets and other
applications.

Series introduces "linear ranges" helper intended to help converting
real-world values to register values when conversion is linear. This
version just meld the helpers in power/supply. Idea is stolen from
regulator framework's linear-ranges handling.

This version of series introduces new battry DT binding entries and
adds the parsing in power_supply_get_battery_info(). These properties
can be converted to ROHM specific properties and parsing can be moved
to the BD99954 driver if this does not seem like a right thing to do.
I just have a feeling the the BD99954 is not the only charger which
could utilize these.

We also add ROHM specific charger parameters for limiting the input
current(s). I think these parameters are pretty common and maybe the
"rohm,"-prefix should be dropped and we should try having common
input limiting properties for different chips?

Series is based on v5.5-rc7

Changelog RFC-v2:
 DT-bindings:
   - Used the battery parameters described in battery.txt
   - Added few new parameters to battery.txt
   - Added ASCII art charging profile chart for BD99954 to explain
     states and limits.
 Linear ranges:
   - Fixed division by zero error from linear-ranges code if step 0 is
     used.
 Power-supply core:
   - Added parsing of new battery parameters.
 BD99954 driver:
   - converted to use battery parameters from battery node
   - Added step 0 ranges for reg values which do not change voltage
   - added dt-node to psy-config

Patch 1:
	DT binding docs for the new battery parameters
Patch 2:
	BD99954 charger DT binding docs
Patch 3:
	Linear ranges helpers
Patch 4:
	Parsing of new battery parameters
Patch 5:
	BD99954 driver

---

Matti Vaittinen (5):
  dt-bindings: battry: add new battery parameters
  dt_bindings: ROHM BD99954 Charger
  power: Add linear_range helper
  power: supply: add battery parameters
  power: supply: Support ROHM bd99954 charger

 .../bindings/power/supply/battery.txt         |    6 +
 .../bindings/power/supply/rohm,bd9995x.yaml   |  167 +++
 drivers/power/supply/Kconfig                  |   14 +
 drivers/power/supply/Makefile                 |    2 +
 drivers/power/supply/bd70528-charger.c        |   65 +-
 drivers/power/supply/bd99954-charger.c        | 1140 +++++++++++++++++
 drivers/power/supply/linear-ranges.h          |   36 +
 drivers/power/supply/linear_ranges.c          |   92 ++
 drivers/power/supply/power_supply_core.c      |    8 +
 include/linux/power/bd99954-charger.h         | 1075 ++++++++++++++++
 include/linux/power_supply.h                  |    4 +
 11 files changed, 2552 insertions(+), 57 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml
 create mode 100644 drivers/power/supply/bd99954-charger.c
 create mode 100644 drivers/power/supply/linear-ranges.h
 create mode 100644 drivers/power/supply/linear_ranges.c
 create mode 100644 include/linux/power/bd99954-charger.h

Comments

Linus Walleij Feb. 21, 2020, 1:49 p.m. UTC | #1
On Fri, Feb 14, 2020 at 8:37 AM Matti Vaittinen
<matti.vaittinen@fi.rohmeurope.com> wrote:

> Many devices have control registers which control some measurable
> property. Often a register contains control field so that change in
> this field causes linear change in the controlled property. It is not
> a rare case that user wants to give 'meaningfull' control values and
> driver needs to convert them to register field values. Even more
> often user wants to 'see' the currently set value - again in
> meaningfull units - and driver needs to convert the values it reads
> from register to these meaningfull units.

Rename meaningfull -> meaningful

> This ideas is stol... borrowed from regulator framework's
> regulator_linear_ranges handling.

Hehe maybe one day we can move the whole thing to lib/
but let's take one step at a time.

> Provide a linear_range helper which can do conversion from user value
> to register value 'selector'.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> ---
>
> Where should we put these?

This works.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij Feb. 21, 2020, 1:50 p.m. UTC | #2
On Fri, Feb 14, 2020 at 8:38 AM Matti Vaittinen
<matti.vaittinen@fi.rohmeurope.com> wrote:

> Add parsing of new device-tree battery bindings.
>
>      - tricklecharge-current-microamp
>      - precharge-upper-limit-microvolt
>      - re-charge-voltage-microvolt
>      - over-voltage-threshold-microvolt
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Matti Vaittinen Feb. 22, 2020, 8:33 a.m. UTC | #3
Morning Linus,

On Fri, 2020-02-21 at 14:49 +0100, Linus Walleij wrote:
> On Fri, Feb 14, 2020 at 8:37 AM Matti Vaittinen
> <matti.vaittinen@fi.rohmeurope.com> wrote:
> 
> > Many devices have control registers which control some measurable
> > property. Often a register contains control field so that change in
> > this field causes linear change in the controlled property. It is
> > not
> > a rare case that user wants to give 'meaningfull' control values
> > and
> > driver needs to convert them to register field values. Even more
> > often user wants to 'see' the currently set value - again in
> > meaningfull units - and driver needs to convert the values it reads
> > from register to these meaningfull units.
> 
> Rename meaningfull -> meaningful
> 
> > This ideas is stol... borrowed from regulator framework's
> > regulator_linear_ranges handling.
> 
> Hehe maybe one day we can move the whole thing to lib/
> but let's take one step at a time.
> 
> > Provide a linear_range helper which can do conversion from user
> > value
> > to register value 'selector'.
> > 
> > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> > ---
> > 
> > Where should we put these?
> 
> This works.
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Uh.. Sorry but I did already send v3 where I changed the approach to
what was suggested by Mark. Eg, I tried pulling the range code out of
regulator framework and used that in power/supply too.

Basic idea is still the same - but instead of using min_sel + amount of
values in range, the version 3 uses min_sel and max_sel as regulators
did. That minimized changes to numerous regulator drivers defining
ranges.

Sorry for making you to do unnecessary reviewing.

Best Regards
    Matti Vaittinen