mbox series

[v3,0/4] power: supply: Add Support for RK817 Charger

Message ID 20210810025436.23367-1-macroalpha82@gmail.com
Headers show
Series power: supply: Add Support for RK817 Charger | expand

Message

Chris Morgan Aug. 10, 2021, 2:54 a.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

This series is to add support for the Rockchip rk817 battery charger
which is present in all Rockchip RK817 PMICs. The driver was written
as a joint effort by Maya Matuszczyk <maccraft123mc@gmail.com> and
myself Chris Morgan <macromorgan@hotmail.com>.

The driver requires some basic parameters be described about the
battery in the devicetree such as the maximum capacity, the minimum
and maximum voltage for the battery, the maximum charge current, the
maximum charge voltage, and the value of sample resistors and sleep
currents.

The hardware itself contains an ADC capable of measuring the voltage,
current, and temperature of the battery (though my implementation of an
Odroid Go Advance lacks a thermistor for temperature). It also contains
a columb counter, registers for tracking the measured voltage and
current at boot, and a few bytes of nvram for storing data.

Changes from V2:

 - Updated devicetree bindings to use common property units.
 - Removed unneeded includes.
 - Updated rk817_chg_cur_to_reg to make more legible.
 - Simplified formula for displaying calibrated voltage.
 - Updated power supply type to POWER_SUPPLY_TYPE_USB.
 - Implemented get/put_unaligned macros for bulk reads and writes.
 - Changed numerous dev_err() to dev_err_probe().
 - Call power_supply_put_battery_info() at end of probe function.
 - Removed unneeded whitespace.

Changes from V1:

 - Fixed a CLANG warning regarding an uninitalized variable.
 - Fixed a CLANG warning regarding a pointer as a bool value always
   returning as true.
 - Added Maya Matuszczyk to the Signed-off-by.

Chris Morgan (4):
  dt-bindings: Add Rockchip rk817 battery charger support
  mfd: Add Rockchip rk817 battery charger support
  power: supply: Add charger driver for Rockchip RK817
  arm64: dts: rockchip: add rk817 charger to Odroid Go Advance

 .../devicetree/bindings/mfd/rk808.txt         |  36 +-
 .../boot/dts/rockchip/rk3326-odroid-go2.dts   |  26 +
 drivers/mfd/rk808.c                           |  16 +-
 drivers/power/supply/Kconfig                  |   6 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/rk817_charger.c          | 922 ++++++++++++++++++
 include/linux/mfd/rk808.h                     |  87 ++
 7 files changed, 1092 insertions(+), 2 deletions(-)
 create mode 100644 drivers/power/supply/rk817_charger.c

Comments

Rob Herring Aug. 17, 2021, 7:11 p.m. UTC | #1
On Mon, Aug 09, 2021 at 09:54:33PM -0500, Chris Morgan wrote:
> From: Chris Morgan <macromorgan@hotmail.com>

> 

> Create dt-binding documentation to document rk817 battery and charger

> usage. New device-tree properties have been added.

> 

> - rockchip,resistor-sense-micro-ohms: The value in microohms of the

> 				      sample resistor.

> - rockchip,sleep-enter-current-microamp: The value in microamps of the

> 					 sleep enter current.

> - rockchip,sleep-filter-current: The value in microamps of the sleep

> 				 filter current.

> 

> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>

> Signed-off-by: Maya Matuszczyk <maccraft123mc@gmail.com>

> ---

>  .../devicetree/bindings/mfd/rk808.txt         | 36 ++++++++++++++++++-

>  1 file changed, 35 insertions(+), 1 deletion(-)


Kind of a big change without converting this binding to DT schema first. 

> 

> diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt

> index 23a17a6663ec..89b9fa7e10b5 100644

> --- a/Documentation/devicetree/bindings/mfd/rk808.txt

> +++ b/Documentation/devicetree/bindings/mfd/rk808.txt

> @@ -70,13 +70,40 @@ Optional RK817 properties:

>  

>  - vcc8-supply:  The input supply for BOOST

>  - vcc9-supply:  The input supply for OTG_SWITCH

> +

>  - codec:	The child node for the codec to hold additional properties.

>  		If no additional properties are required for the codec, this

>  		node can be omitted.

> -


Unrelated whitespace changes.

>  - rockchip,mic-in-differential: Telling if the microphone uses differential

>  				mode. Should be under the codec child node.

>  

> +- battery:	The child node for the charger to hold additional properties.

> +		If a battery is not in use, this node can be omitted. If a

> +		battery node is used, the following values are required:

> +		rockchip,resistor-sense, rockchip,sleep-enter-current,

> +		rockchip,sleep-filter-current, and a phandle to a


Property names are out of date...

> +		monitored-battery node that contains a valid value for

> +		charge-full-design-microamp-hours,

> +		charge-term-current-microamp,

> +		constant-charge-current-max-microamp,

> +		constant-charge-voltage-max-microvolt,

> +		voltage-max-design-microvolt, voltage-min-design-microvolt,

> +		and a valid ocv-capacity table.


Please list these 1 per line and make it clearer this is the list of 
properties for the battery node.

> +- rockchip,resistor-sense-micro-ohms: Value in microohms of the battery sense

> +				      resistor. The PMIC only supports values

> +				      of either 10000 or 20000. This value is

> +				      used by the driver to set the correct

> +				      divisor value to translate ADC readings

> +				      into the proper units of measure.

> +- rockchip,sleep-enter-current-microamp: Value in microamps of the sleep enter

> +					 current for the charger. Value is used

> +					 by the driver to calibrate the relax

> +					 threshold.

> +- rockchip,sleep-filter-current-microamp: Value in microamps of the sleep

> +					  filter current for the charger.

> +					  Value is used by the driver to derive

> +					  the sleep sample current.

> +

>  Optional RK818 properties:

>  - vcc1-supply:  The input supply for DCDC_REG1

>  - vcc2-supply:  The input supply for DCDC_REG2

> @@ -459,6 +486,13 @@ Example:

>  			};

>  		};

>  

> +		rk817_battery: battery {

> +			monitored-battery = <&battery_cell>;

> +			rockchip,resistor-sense-micro-ohms = <10000>;

> +			rockchip,sleep-enter-current-microamp = <300000>;

> +			rockchip,sleep-filter-current-microamp = <100000>;

> +		};

> +

>  		rk817_codec: codec {

>  			rockchip,mic-in-differential;

>  		};

> -- 

> 2.25.1

> 

>