mbox series

[v2,00/16] add support for AXP813 ADC and battery power supply

Message ID cover.1e46d70f7931be8154b450a2fcdf066450a1aa6f.1515486346.git-series.quentin.schulz@free-electrons.com
Headers show
Series add support for AXP813 ADC and battery power supply | expand

Message

Quentin Schulz Jan. 9, 2018, 9:33 a.m. UTC
The AXP813 PMIC is relatively close to the already supported AXP20X and
AXP22X. It provides three different power outputs: battery, AC and USB, and
measures a few different things: temperature, power supply status, current
current and voltage supplied, maximum current limit, battery capacity, min
and max voltage limits.

One of its two GPIOs can be used as an ADC.

There are a few differences with AXP20X/AXP22X PMICs though:
  - a different constant charge current formula,
  - battery temperature, GPIO0 and battery voltages are the only voltages
  measurable,
  - all data are stored on 12 bits (AXP20X/AXP22X had one type of data that
  was stored on 13 bits),
  - different scales and offsets,
  - a different ADC rate formula and register,

This patch series adds support for the PMIC's ADC and battery power supply
in the existing drivers.

Make the axp20x MFD automatically probe the ADC driver, add the battery
power supply node in axp81x node and enable it for the TBS A711 since it
has a soldered battery.

v2:
  - introduce data structure instead of ID for variant specific code in
  battery driver,
  - add DT binding for ADC driver,
  - make mfd probe the ADC driver via DT as well so that its IIO channels
  can be consumed by other drivers via DT mapping,

Thanks,
Quentin

Quentin Schulz (16):
  iio: adc: axp20x_adc: put ADC rate setting in a per-variant function
  dt-bindings: iio: adc: add binding for X-Powers AXP PMICs ADC
  iio: adc: axp20x_adc: make it possible to probe from DT
  ARM: dtsi: axp209: add node for ADC
  ARM: dtsi: axp22x: add node for ADC
  mfd: axp20x: make AXP209/22x cells probe their ADC via DT
  dt-bindings: iio: adc: axp20x_adc: add AXP813 variant
  iio: adc: axp20x_adc: add support for AXP813 ADC
  ARM: dtsi: axp81x: add node for ADC
  mfd: axp20x: probe axp20x_adc driver for AXP813
  power: supply: axp20x_battery: use data structure instead of ID for variant specific code
  dt-bindings: power: supply: axp20x: add AXP813 battery DT binding
  power: supply: axp20x_battery: add support for AXP813
  mfd: axp20x: add battery power supply cell for AXP813
  ARM: dtsi: axp81x: add battery power supply subnode
  ARM: dtsi: sun8i: a711: enable battery power supply subnode

 Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt          |  48 ++++++++++++++++++++++-
 Documentation/devicetree/bindings/power/supply/axp20x_battery.txt |   8 ++--
 arch/arm/boot/dts/axp209.dtsi                                     |   5 ++-
 arch/arm/boot/dts/axp22x.dtsi                                     |   5 ++-
 arch/arm/boot/dts/axp81x.dtsi                                     |  10 +++++-
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts                         |   4 ++-
 drivers/iio/adc/axp20x_adc.c                                      | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 drivers/mfd/axp20x.c                                              |  13 +++++-
 drivers/power/supply/axp20x_battery.c                             | 134 ++++++++++++++++++++++++++++++++++++++++++++++--------------
 include/linux/mfd/axp20x.h                                        |   2 +-
 10 files changed, 345 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt

base-commit: 895c0dde398510a5b5ded60e5064c11b94bd30ca

Comments

Maxime Ripard Jan. 9, 2018, 9:48 a.m. UTC | #1
On Tue, Jan 09, 2018 at 10:33:35AM +0100, Quentin Schulz wrote:
> This adds a DT node for the ADC of the PMIC so that there can be
> consumers of its IIO channels declaring their consumptions via DT.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  arch/arm/boot/dts/axp209.dtsi | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/axp209.dtsi b/arch/arm/boot/dts/axp209.dtsi
> index 897103e..a2e0052 100644
> --- a/arch/arm/boot/dts/axp209.dtsi
> +++ b/arch/arm/boot/dts/axp209.dtsi
> @@ -58,6 +58,11 @@
>  		status = "disabled";
>  	};
>  
> +	axp_adc: axp-adc {

The node nade should be adc.

> +		compatible = "x-powers,axp20x-adc";

And your compatible shouldn't have a wildcard but the first design
that introduced that IP.

Maxime
Julian Calaby Jan. 9, 2018, 12:53 p.m. UTC | #2
Hi Quentin,

On Tue, Jan 9, 2018 at 8:33 PM, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:
> The X-Powers AXP813 PMIC has got some slight differences from
> AXP20X/AXP22X PMICs:
>  - the maximum voltage supplied by the PMIC is 4.35 instead of 4.36/4.24
>  for AXP20X/AXP22X,
>  - the constant charge current formula is different,
>
> It also has a bit to tell whether the battery percentage returned by the
> PMIC is valid.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  drivers/power/supply/axp20x_battery.c | 42 ++++++++++++++++++++++++++++-
>  1 file changed, 42 insertions(+)
>
> diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
> index d73c78f..dad72a5 100644
> --- a/drivers/power/supply/axp20x_battery.c
> +++ b/drivers/power/supply/axp20x_battery.c
> @@ -46,6 +46,8 @@
>  #define AXP20X_CHRG_CTRL1_TGT_4_2V     (2 << 5)
>  #define AXP20X_CHRG_CTRL1_TGT_4_36V    (3 << 5)
>
> +#define AXP813_CHRG_CTRL1_TGT_4_35V    (3 << 5)
> +
>  #define AXP22X_CHRG_CTRL1_TGT_4_22V    (1 << 5)
>  #define AXP22X_CHRG_CTRL1_TGT_4_24V    (3 << 5)

Should these be "alphabetical", i.e. AXP20X, AXP22X, AXP813?

Thanks,
Jonathan Cameron Jan. 14, 2018, 1:56 p.m. UTC | #3
On Tue,  9 Jan 2018 10:33:31 +0100
Quentin Schulz <quentin.schulz@free-electrons.com> wrote:

> The AXP813 PMIC is relatively close to the already supported AXP20X and
> AXP22X. It provides three different power outputs: battery, AC and USB, and
> measures a few different things: temperature, power supply status, current
> current and voltage supplied, maximum current limit, battery capacity, min
> and max voltage limits.
> 
> One of its two GPIOs can be used as an ADC.
> 
> There are a few differences with AXP20X/AXP22X PMICs though:
>   - a different constant charge current formula,
>   - battery temperature, GPIO0 and battery voltages are the only voltages
>   measurable,
>   - all data are stored on 12 bits (AXP20X/AXP22X had one type of data that
>   was stored on 13 bits),
>   - different scales and offsets,
>   - a different ADC rate formula and register,
> 
> This patch series adds support for the PMIC's ADC and battery power supply
> in the existing drivers.
> 
> Make the axp20x MFD automatically probe the ADC driver, add the battery
> power supply node in axp81x node and enable it for the TBS A711 since it
> has a soldered battery.
> 
> v2:
>   - introduce data structure instead of ID for variant specific code in
>   battery driver,
>   - add DT binding for ADC driver,
>   - make mfd probe the ADC driver via DT as well so that its IIO channels
>   can be consumed by other drivers via DT mapping,
Other than that minor comment on V1 about churn risk in the dt binding
that Rob pointed out hadn't been addressed (I'd completely forgotten about it :)

I'm happy once the points others have raised have been addressed.

My assumption is that this will ultimately go through the IIO tree so
I'll be needing a good selection of Acks to take it.

The dts bits should be fine to go via normal paths though once the
driver is in place.

If it's going via mfd which might make sense in a 'logical' way rather
than amount of code, let me know and I'll give tags for v3 iio parts.

Jonathan

> 
> Thanks,
> Quentin
> 
> Quentin Schulz (16):
>   iio: adc: axp20x_adc: put ADC rate setting in a per-variant function
>   dt-bindings: iio: adc: add binding for X-Powers AXP PMICs ADC
>   iio: adc: axp20x_adc: make it possible to probe from DT
>   ARM: dtsi: axp209: add node for ADC
>   ARM: dtsi: axp22x: add node for ADC
>   mfd: axp20x: make AXP209/22x cells probe their ADC via DT
>   dt-bindings: iio: adc: axp20x_adc: add AXP813 variant
>   iio: adc: axp20x_adc: add support for AXP813 ADC
>   ARM: dtsi: axp81x: add node for ADC
>   mfd: axp20x: probe axp20x_adc driver for AXP813
>   power: supply: axp20x_battery: use data structure instead of ID for variant specific code
>   dt-bindings: power: supply: axp20x: add AXP813 battery DT binding
>   power: supply: axp20x_battery: add support for AXP813
>   mfd: axp20x: add battery power supply cell for AXP813
>   ARM: dtsi: axp81x: add battery power supply subnode
>   ARM: dtsi: sun8i: a711: enable battery power supply subnode
> 
>  Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt          |  48 ++++++++++++++++++++++-
>  Documentation/devicetree/bindings/power/supply/axp20x_battery.txt |   8 ++--
>  arch/arm/boot/dts/axp209.dtsi                                     |   5 ++-
>  arch/arm/boot/dts/axp22x.dtsi                                     |   5 ++-
>  arch/arm/boot/dts/axp81x.dtsi                                     |  10 +++++-
>  arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts                         |   4 ++-
>  drivers/iio/adc/axp20x_adc.c                                      | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
>  drivers/mfd/axp20x.c                                              |  13 +++++-
>  drivers/power/supply/axp20x_battery.c                             | 134 ++++++++++++++++++++++++++++++++++++++++++++++--------------
>  include/linux/mfd/axp20x.h                                        |   2 +-
>  10 files changed, 345 insertions(+), 44 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt
> 
> base-commit: 895c0dde398510a5b5ded60e5064c11b94bd30ca

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html