Re: [PATCH 2/2] power: bq25980: Add support for the BQ259xx family

2020-10-04 Thread Sebastian Reichel
Hi,

On Mon, Aug 31, 2020 at 11:48:49AM -0500, Dan Murphy wrote:
> Add support for the BQ25980, BQ25975 and BQ25960 family of flash
> chargers.
> 
> Signed-off-by: Dan Murphy 
> ---

Thanks, queued (together with the binding)

-- Sebastian

>  drivers/power/supply/Kconfig   |9 +
>  drivers/power/supply/Makefile  |1 +
>  drivers/power/supply/bq25980_charger.c | 1316 
>  drivers/power/supply/bq25980_charger.h |  178 
>  4 files changed, 1504 insertions(+)
>  create mode 100644 drivers/power/supply/bq25980_charger.c
>  create mode 100644 drivers/power/supply/bq25980_charger.h
> 
> diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
> index faf2830aa152..fbe974e4cff4 100644
> --- a/drivers/power/supply/Kconfig
> +++ b/drivers/power/supply/Kconfig
> @@ -631,6 +631,15 @@ config CHARGER_BQ25890
>   help
> Say Y to enable support for the TI BQ25890 battery charger.
>  
> +config CHARGER_BQ25980
> + tristate "TI BQ25980 battery charger driver"
> + depends on I2C
> + depends on GPIOLIB || COMPILE_TEST
> + select REGMAP_I2C
> + help
> +   Say Y to enable support for the TI BQ25980, BQ25975 and BQ25960
> +   series of fast battery chargers.
> +
>  config CHARGER_SMB347
>   tristate "Summit Microelectronics SMB347 Battery Charger"
>   depends on I2C
> diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
> index b3c694a65114..9b2f21fa6f94 100644
> --- a/drivers/power/supply/Makefile
> +++ b/drivers/power/supply/Makefile
> @@ -84,6 +84,7 @@ obj-$(CONFIG_CHARGER_BQ24257)   += bq24257_charger.o
>  obj-$(CONFIG_CHARGER_BQ24735)+= bq24735-charger.o
>  obj-$(CONFIG_CHARGER_BQ2515X)+= bq2515x_charger.o
>  obj-$(CONFIG_CHARGER_BQ25890)+= bq25890_charger.o
> +obj-$(CONFIG_CHARGER_BQ25980)+= bq25980_charger.o
>  obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o
>  obj-$(CONFIG_CHARGER_TPS65090)   += tps65090-charger.o
>  obj-$(CONFIG_CHARGER_TPS65217)   += tps65217_charger.o
> diff --git a/drivers/power/supply/bq25980_charger.c 
> b/drivers/power/supply/bq25980_charger.c
> new file mode 100644
> index ..3995fb7cf060
> --- /dev/null
> +++ b/drivers/power/supply/bq25980_charger.c
> @@ -0,0 +1,1316 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// BQ25980 Battery Charger Driver
> +// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "bq25980_charger.h"
> +
> +struct bq25980_state {
> + bool dischg;
> + bool ovp;
> + bool ocp;
> + bool wdt;
> + bool tflt;
> + bool online;
> + bool ce;
> + bool hiz;
> + bool bypass;
> +
> + u32 vbat_adc;
> + u32 vsys_adc;
> + u32 ibat_adc;
> +};
> +
> +enum bq25980_id {
> + BQ25980,
> + BQ25975,
> + BQ25960,
> +};
> +
> +struct bq25980_chip_info {
> +
> + int model_id;
> +
> + const struct regmap_config *regmap_config;
> +
> + int busocp_def;
> + int busocp_sc_max;
> + int busocp_byp_max;
> + int busocp_sc_min;
> + int busocp_byp_min;
> +
> + int busovp_sc_def;
> + int busovp_byp_def;
> + int busovp_sc_step;
> +
> + int busovp_sc_offset;
> + int busovp_byp_step;
> + int busovp_byp_offset;
> + int busovp_sc_min;
> + int busovp_sc_max;
> + int busovp_byp_min;
> + int busovp_byp_max;
> +
> + int batovp_def;
> + int batovp_max;
> + int batovp_min;
> + int batovp_step;
> + int batovp_offset;
> +
> + int batocp_def;
> + int batocp_max;
> +};
> +
> +struct bq25980_init_data {
> + u32 ichg;
> + u32 bypass_ilim;
> + u32 sc_ilim;
> + u32 vreg;
> + u32 iterm;
> + u32 iprechg;
> + u32 bypass_vlim;
> + u32 sc_vlim;
> + u32 ichg_max;
> + u32 vreg_max;
> +};
> +
> +struct bq25980_device {
> + struct i2c_client *client;
> + struct device *dev;
> + struct power_supply *charger;
> + struct power_supply *battery;
> + struct mutex lock;
> + struct regmap *regmap;
> +
> + char model_name[I2C_NAME_SIZE];
> +
> + struct bq25980_init_data init_data;
> + const struct bq25980_chip_info *chip_info;
> + struct bq25980_state state;
> + int watchdog_timer;
> +};
> +
> +static struct reg_default bq25980_reg_defs[] = {
> + {BQ25980_BATOVP, 0x5A},
> + {BQ25980_BATOVP_ALM, 0x46},
> + {BQ25980_BATOCP, 0x51},
> + {BQ25980_BATOCP_ALM, 0x50},
> + {BQ25980_BATUCP_ALM, 0x28},
> + {BQ25980_CHRGR_CTRL_1, 0x0},
> + {BQ25980_BUSOVP, 0x26},
> + {BQ25980_BUSOVP_ALM, 0x22},
> + {BQ25980_BUSOCP, 0xD},
> + {BQ25980_BUSOCP_ALM, 0xC},
> + {BQ25980_TEMP_CONTROL, 0x30},
> + {BQ25980_TDIE_ALM, 0xC8},
> + {BQ25980_TSBUS_FLT, 0x15},
> + 

Re: [PATCH 2/2] power: bq25980: Add support for the BQ259xx family

2020-09-22 Thread Dan Murphy

Hello

On 8/31/20 11:48 AM, Dan Murphy wrote:

Add support for the BQ25980, BQ25975 and BQ25960 family of flash
chargers.


Gentle Bump




[PATCH 2/2] power: bq25980: Add support for the BQ259xx family

2020-08-31 Thread Dan Murphy
Add support for the BQ25980, BQ25975 and BQ25960 family of flash
chargers.

Signed-off-by: Dan Murphy 
---
 drivers/power/supply/Kconfig   |9 +
 drivers/power/supply/Makefile  |1 +
 drivers/power/supply/bq25980_charger.c | 1316 
 drivers/power/supply/bq25980_charger.h |  178 
 4 files changed, 1504 insertions(+)
 create mode 100644 drivers/power/supply/bq25980_charger.c
 create mode 100644 drivers/power/supply/bq25980_charger.h

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index faf2830aa152..fbe974e4cff4 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -631,6 +631,15 @@ config CHARGER_BQ25890
help
  Say Y to enable support for the TI BQ25890 battery charger.
 
+config CHARGER_BQ25980
+   tristate "TI BQ25980 battery charger driver"
+   depends on I2C
+   depends on GPIOLIB || COMPILE_TEST
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the TI BQ25980, BQ25975 and BQ25960
+ series of fast battery chargers.
+
 config CHARGER_SMB347
tristate "Summit Microelectronics SMB347 Battery Charger"
depends on I2C
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index b3c694a65114..9b2f21fa6f94 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -84,6 +84,7 @@ obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_CHARGER_BQ2515X)  += bq2515x_charger.o
 obj-$(CONFIG_CHARGER_BQ25890)  += bq25890_charger.o
+obj-$(CONFIG_CHARGER_BQ25980)  += bq25980_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o
diff --git a/drivers/power/supply/bq25980_charger.c 
b/drivers/power/supply/bq25980_charger.c
new file mode 100644
index ..3995fb7cf060
--- /dev/null
+++ b/drivers/power/supply/bq25980_charger.c
@@ -0,0 +1,1316 @@
+// SPDX-License-Identifier: GPL-2.0
+// BQ25980 Battery Charger Driver
+// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bq25980_charger.h"
+
+struct bq25980_state {
+   bool dischg;
+   bool ovp;
+   bool ocp;
+   bool wdt;
+   bool tflt;
+   bool online;
+   bool ce;
+   bool hiz;
+   bool bypass;
+
+   u32 vbat_adc;
+   u32 vsys_adc;
+   u32 ibat_adc;
+};
+
+enum bq25980_id {
+   BQ25980,
+   BQ25975,
+   BQ25960,
+};
+
+struct bq25980_chip_info {
+
+   int model_id;
+
+   const struct regmap_config *regmap_config;
+
+   int busocp_def;
+   int busocp_sc_max;
+   int busocp_byp_max;
+   int busocp_sc_min;
+   int busocp_byp_min;
+
+   int busovp_sc_def;
+   int busovp_byp_def;
+   int busovp_sc_step;
+
+   int busovp_sc_offset;
+   int busovp_byp_step;
+   int busovp_byp_offset;
+   int busovp_sc_min;
+   int busovp_sc_max;
+   int busovp_byp_min;
+   int busovp_byp_max;
+
+   int batovp_def;
+   int batovp_max;
+   int batovp_min;
+   int batovp_step;
+   int batovp_offset;
+
+   int batocp_def;
+   int batocp_max;
+};
+
+struct bq25980_init_data {
+   u32 ichg;
+   u32 bypass_ilim;
+   u32 sc_ilim;
+   u32 vreg;
+   u32 iterm;
+   u32 iprechg;
+   u32 bypass_vlim;
+   u32 sc_vlim;
+   u32 ichg_max;
+   u32 vreg_max;
+};
+
+struct bq25980_device {
+   struct i2c_client *client;
+   struct device *dev;
+   struct power_supply *charger;
+   struct power_supply *battery;
+   struct mutex lock;
+   struct regmap *regmap;
+
+   char model_name[I2C_NAME_SIZE];
+
+   struct bq25980_init_data init_data;
+   const struct bq25980_chip_info *chip_info;
+   struct bq25980_state state;
+   int watchdog_timer;
+};
+
+static struct reg_default bq25980_reg_defs[] = {
+   {BQ25980_BATOVP, 0x5A},
+   {BQ25980_BATOVP_ALM, 0x46},
+   {BQ25980_BATOCP, 0x51},
+   {BQ25980_BATOCP_ALM, 0x50},
+   {BQ25980_BATUCP_ALM, 0x28},
+   {BQ25980_CHRGR_CTRL_1, 0x0},
+   {BQ25980_BUSOVP, 0x26},
+   {BQ25980_BUSOVP_ALM, 0x22},
+   {BQ25980_BUSOCP, 0xD},
+   {BQ25980_BUSOCP_ALM, 0xC},
+   {BQ25980_TEMP_CONTROL, 0x30},
+   {BQ25980_TDIE_ALM, 0xC8},
+   {BQ25980_TSBUS_FLT, 0x15},
+   {BQ25980_TSBAT_FLG, 0x15},
+   {BQ25980_VAC_CONTROL, 0x0},
+   {BQ25980_CHRGR_CTRL_2, 0x0},
+   {BQ25980_CHRGR_CTRL_3, 0x20},
+   {BQ25980_CHRGR_CTRL_4, 0x1D},
+   {BQ25980_CHRGR_CTRL_5, 0x18},
+   {BQ25980_STAT1, 0x0},
+   {BQ25980_STAT2, 0x0},
+   {BQ25980_STAT3, 0x0},
+   {BQ25980_STAT4, 0x0},
+   {BQ25980_STAT5,