All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] power: supply: Add Support for RK817 Charger
@ 2021-08-24  4:09 ` Chris Morgan
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Morgan @ 2021-08-24  4:09 UTC (permalink / raw)
  To: linux-rockchip
  Cc: linux-pm, linux-arm-kernel, lee.jones, robh+dt, heiko, sre,
	maccraft123mc, devicetree, Chris Morgan

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 V3:

 - Corrected issues in device tree documentation.
 - Added additional logic to battery to correct for columb counter
   drift when the device stays plugged in at a full charge state.

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         |  38 +
 .../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          | 959 ++++++++++++++++++
 include/linux/mfd/rk808.h                     |  87 ++
 7 files changed, 1132 insertions(+), 1 deletion(-)
 create mode 100644 drivers/power/supply/rk817_charger.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH v4 3/4] power: supply: Add charger driver for Rockchip RK817
@ 2021-08-24 14:50 kernel test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2021-08-24 14:50 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4471 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210824040955.29112-4-macroalpha82@gmail.com>
References: <20210824040955.29112-4-macroalpha82@gmail.com>
TO: Chris Morgan <macroalpha82@gmail.com>
TO: linux-rockchip(a)lists.infradead.org
CC: linux-pm(a)vger.kernel.org
CC: linux-arm-kernel(a)lists.infradead.org
CC: lee.jones(a)linaro.org
CC: robh+dt(a)kernel.org
CC: heiko(a)sntech.de
CC: sre(a)kernel.org
CC: maccraft123mc(a)gmail.com
CC: devicetree(a)vger.kernel.org
CC: Chris Morgan <macromorgan@hotmail.com>

Hi Chris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on rockchip/for-next power-supply/for-next v5.14-rc7 next-20210824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Chris-Morgan/power-supply-Add-Support-for-RK817-Charger/20210824-121243
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: h8300-randconfig-m031-20210824 (attached as .config)
compiler: h8300-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/power/supply/rk817_charger.c:121 rk817_chg_cur_to_reg() warn: signedness bug returning '(-22)'

vim +121 drivers/power/supply/rk817_charger.c

e56667b68e1bb8 Chris Morgan 2021-08-23   85  
e56667b68e1bb8 Chris Morgan 2021-08-23   86  /* ADC coefficients extracted from BSP kernel */
e56667b68e1bb8 Chris Morgan 2021-08-23   87  #define ADC_TO_CURRENT(adc_value, res_div)	\
e56667b68e1bb8 Chris Morgan 2021-08-23   88  	(adc_value * 172 / res_div)
e56667b68e1bb8 Chris Morgan 2021-08-23   89  
e56667b68e1bb8 Chris Morgan 2021-08-23   90  #define CURRENT_TO_ADC(current, samp_res)	\
e56667b68e1bb8 Chris Morgan 2021-08-23   91  	(current * samp_res / 172)
e56667b68e1bb8 Chris Morgan 2021-08-23   92  
e56667b68e1bb8 Chris Morgan 2021-08-23   93  #define CHARGE_TO_ADC(capacity, res_div)	\
e56667b68e1bb8 Chris Morgan 2021-08-23   94  	(capacity * res_div * 3600 / 172 * 1000)
e56667b68e1bb8 Chris Morgan 2021-08-23   95  
e56667b68e1bb8 Chris Morgan 2021-08-23   96  #define ADC_TO_CHARGE_UAH(adc_value, res_div)	\
e56667b68e1bb8 Chris Morgan 2021-08-23   97  	(adc_value / 3600 * 172 / res_div)
e56667b68e1bb8 Chris Morgan 2021-08-23   98  
e56667b68e1bb8 Chris Morgan 2021-08-23   99  #define ADC_TO_CAPACITY(adc_value, res_div)	\
e56667b68e1bb8 Chris Morgan 2021-08-23  100  	(adc_value / 1000 * 172 / 3600 / res_div)
e56667b68e1bb8 Chris Morgan 2021-08-23  101  
e56667b68e1bb8 Chris Morgan 2021-08-23  102  static u8 rk817_chg_cur_to_reg(u32 chg_cur_ma)
e56667b68e1bb8 Chris Morgan 2021-08-23  103  {
e56667b68e1bb8 Chris Morgan 2021-08-23  104  	if (chg_cur_ma > 3500)
e56667b68e1bb8 Chris Morgan 2021-08-23  105  		return CHG_3_5A;
e56667b68e1bb8 Chris Morgan 2021-08-23  106  	else if (chg_cur_ma > 3000)
e56667b68e1bb8 Chris Morgan 2021-08-23  107  		return CHG_3A;
e56667b68e1bb8 Chris Morgan 2021-08-23  108  	else if (chg_cur_ma > 2750)
e56667b68e1bb8 Chris Morgan 2021-08-23  109  		return CHG_2_75A;
e56667b68e1bb8 Chris Morgan 2021-08-23  110  	else if (chg_cur_ma > 2500)
e56667b68e1bb8 Chris Morgan 2021-08-23  111  		return CHG_2_5A;
e56667b68e1bb8 Chris Morgan 2021-08-23  112  	else if (chg_cur_ma > 2000)
e56667b68e1bb8 Chris Morgan 2021-08-23  113  		return CHG_2A;
e56667b68e1bb8 Chris Morgan 2021-08-23  114  	else if (chg_cur_ma > 1500)
e56667b68e1bb8 Chris Morgan 2021-08-23  115  		return CHG_1_5A;
e56667b68e1bb8 Chris Morgan 2021-08-23  116  	else if (chg_cur_ma > 1000)
e56667b68e1bb8 Chris Morgan 2021-08-23  117  		return CHG_1A;
e56667b68e1bb8 Chris Morgan 2021-08-23  118  	else if (chg_cur_ma > 500)
e56667b68e1bb8 Chris Morgan 2021-08-23  119  		return CHG_0_5A;
e56667b68e1bb8 Chris Morgan 2021-08-23  120  	else
e56667b68e1bb8 Chris Morgan 2021-08-23 @121  		return -EINVAL;
e56667b68e1bb8 Chris Morgan 2021-08-23  122  }
e56667b68e1bb8 Chris Morgan 2021-08-23  123  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35766 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-08-24 14:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-24  4:09 [PATCH v4 0/4] power: supply: Add Support for RK817 Charger Chris Morgan
2021-08-24  4:09 ` Chris Morgan
2021-08-24  4:09 ` Chris Morgan
2021-08-24  4:09 ` [PATCH v4 1/4] dt-bindings: Add Rockchip rk817 battery charger support Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09 ` [PATCH v4 2/4] mfd: " Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09 ` [PATCH v4 3/4] power: supply: Add charger driver for Rockchip RK817 Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09 ` [PATCH v4 4/4] arm64: dts: rockchip: add rk817 charger to Odroid Go Advance Chris Morgan
2021-08-24  4:09   ` Chris Morgan
2021-08-24  4:09   ` Chris Morgan
  -- strict thread matches above, loose matches on Subject: below --
2021-08-24 14:50 [PATCH v4 3/4] power: supply: Add charger driver for Rockchip RK817 kernel test robot

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.