Re: [PATCH v5 2/4] power: supply: bq27xxx_battery: Add the BQ27z561 Battery monitor

2020-07-29 Thread Dan Murphy

Sebastian

On 7/29/20 11:56 AM, Sebastian Reichel wrote:

Hi,

On Wed, Jul 29, 2020 at 10:55:54AM -0500, Dan Murphy wrote:

+<<< HEAD

Need to remove this artifact from a rebase.

Not sure how this got here as it does not appear in my source.

You don't see it in your source, since you removed it in patch 4.


OK I have v6 ready but I noticed a lot of checkpatch issues.

total: 20 errors, 8 warnings, 1923 lines checked

So I will submit v6 and fix the style issues in a follow up patch

Dan



-- Sebastian


Re: [PATCH v5 2/4] power: supply: bq27xxx_battery: Add the BQ27z561 Battery monitor

2020-07-29 Thread Sebastian Reichel
Hi,

On Wed, Jul 29, 2020 at 10:55:54AM -0500, Dan Murphy wrote:
> > +<<< HEAD
> 
> Need to remove this artifact from a rebase.
> 
> Not sure how this got here as it does not appear in my source.

You don't see it in your source, since you removed it in patch 4.

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCH v5 2/4] power: supply: bq27xxx_battery: Add the BQ27z561 Battery monitor

2020-07-29 Thread Dan Murphy

Hello

On 7/29/20 7:06 AM, Dan Murphy wrote:

Add the Texas Instruments BQ27z561 battery monitor.  The register address
map is laid out the same as compared to other devices within the file.
The battery status register has differing bits to determine if the
battery is full, discharging or dead.

Signed-off-by: Dan Murphy 
---
  drivers/power/supply/bq27xxx_battery.c | 69 +-
  drivers/power/supply/bq27xxx_battery_i2c.c |  2 +
  include/linux/power/bq27xxx_battery.h  |  1 +
  3 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index acaafed037be..a858e3b2a0ee 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -18,6 +18,7 @@
   * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   *
   * Datasheets:
+<<< HEAD


Need to remove this artifact from a rebase.

Not sure how this got here as it does not appear in my source.

Dan




[PATCH v5 2/4] power: supply: bq27xxx_battery: Add the BQ27z561 Battery monitor

2020-07-29 Thread Dan Murphy
Add the Texas Instruments BQ27z561 battery monitor.  The register address
map is laid out the same as compared to other devices within the file.
The battery status register has differing bits to determine if the
battery is full, discharging or dead.

Signed-off-by: Dan Murphy 
---
 drivers/power/supply/bq27xxx_battery.c | 69 +-
 drivers/power/supply/bq27xxx_battery_i2c.c |  2 +
 include/linux/power/bq27xxx_battery.h  |  1 +
 3 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index acaafed037be..a858e3b2a0ee 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -18,6 +18,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * Datasheets:
+<<< HEAD
  * https://www.ti.com/product/bq27000
  * https://www.ti.com/product/bq27200
  * https://www.ti.com/product/bq27010
@@ -43,6 +44,7 @@
  * https://www.ti.com/product/bq27411-g1
  * https://www.ti.com/product/bq27441-g1
  * https://www.ti.com/product/bq27621-g1
+ * https://www.ti.com/lit/gpn/bq27z561
  */
 
 #include 
@@ -79,6 +81,11 @@
 #define BQ27000_FLAG_FCBIT(5)
 #define BQ27000_FLAG_CHGS  BIT(7) /* Charge state flag */
 
+/* BQ27Z561 has different layout for Flags register */
+#define BQ27Z561_FLAG_FDC  BIT(4) /* Battery fully discharged */
+#define BQ27Z561_FLAG_FC   BIT(5) /* Battery fully charged */
+#define BQ27Z561_FLAG_DIS_CH   BIT(6) /* Battery is discharging */
+
 /* control register params */
 #define BQ27XXX_SEALED 0x20
 #define BQ27XXX_SET_CFGUPDATE  0x13
@@ -431,12 +438,32 @@ static u8
[BQ27XXX_REG_DCAP] = 0x3c,
[BQ27XXX_REG_AP] = 0x18,
BQ27XXX_DM_REG_ROWS,
-   };
+   },
 #define bq27411_regs bq27421_regs
 #define bq27425_regs bq27421_regs
 #define bq27426_regs bq27421_regs
 #define bq27441_regs bq27421_regs
 #define bq27621_regs bq27421_regs
+   bq27z561_regs[BQ27XXX_REG_MAX] = {
+   [BQ27XXX_REG_CTRL] = 0x00,
+   [BQ27XXX_REG_TEMP] = 0x06,
+   [BQ27XXX_REG_INT_TEMP] = INVALID_REG_ADDR,
+   [BQ27XXX_REG_VOLT] = 0x08,
+   [BQ27XXX_REG_AI] = 0x14,
+   [BQ27XXX_REG_FLAGS] = 0x0a,
+   [BQ27XXX_REG_TTE] = 0x16,
+   [BQ27XXX_REG_TTF] = 0x18,
+   [BQ27XXX_REG_TTES] = INVALID_REG_ADDR,
+   [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR,
+   [BQ27XXX_REG_NAC] = INVALID_REG_ADDR,
+   [BQ27XXX_REG_FCC] = 0x12,
+   [BQ27XXX_REG_CYCT] = 0x2a,
+   [BQ27XXX_REG_AE] = 0x22,
+   [BQ27XXX_REG_SOC] = 0x2c,
+   [BQ27XXX_REG_DCAP] = 0x3c,
+   [BQ27XXX_REG_AP] = 0x22,
+   BQ27XXX_DM_REG_ROWS,
+   };
 
 static enum power_supply_property bq27000_props[] = {
POWER_SUPPLY_PROP_STATUS,
@@ -672,6 +699,25 @@ static enum power_supply_property bq27421_props[] = {
 #define bq27441_props bq27421_props
 #define bq27621_props bq27421_props
 
+static enum power_supply_property bq27z561_props[] = {
+   POWER_SUPPLY_PROP_STATUS,
+   POWER_SUPPLY_PROP_PRESENT,
+   POWER_SUPPLY_PROP_VOLTAGE_NOW,
+   POWER_SUPPLY_PROP_CURRENT_NOW,
+   POWER_SUPPLY_PROP_CAPACITY,
+   POWER_SUPPLY_PROP_CAPACITY_LEVEL,
+   POWER_SUPPLY_PROP_TEMP,
+   POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
+   POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
+   POWER_SUPPLY_PROP_TECHNOLOGY,
+   POWER_SUPPLY_PROP_CHARGE_FULL,
+   POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+   POWER_SUPPLY_PROP_CYCLE_COUNT,
+   POWER_SUPPLY_PROP_POWER_AVG,
+   POWER_SUPPLY_PROP_HEALTH,
+   POWER_SUPPLY_PROP_MANUFACTURER,
+};
+
 struct bq27xxx_dm_reg {
u8 subclass_id;
u8 offset;
@@ -767,11 +813,14 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
 #define bq27621_dm_regs 0
 #endif
 
+#define bq27z561_dm_regs 0
+
 #define BQ27XXX_O_ZERO 0x0001
 #define BQ27XXX_O_OTDC 0x0002 /* has OTC/OTD overtemperature flags */
 #define BQ27XXX_O_UTOT  0x0004 /* has OT overtemperature flag */
 #define BQ27XXX_O_CFGUP0x0008
 #define BQ27XXX_O_RAM  0x0010
+#define BQ27Z561_O_BITS0x0020
 
 #define BQ27XXX_DATA(ref, key, opt) {  \
.opts = (opt),  \
@@ -816,6 +865,7 @@ static struct {
[BQ27426]   = BQ27XXX_DATA(bq27426,   0x80008000, BQ27XXX_O_UTOT | 
BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
[BQ27441]   = BQ27XXX_DATA(bq27441,   0x80008000, BQ27XXX_O_UTOT | 
BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
[BQ27621]   = BQ27XXX_DATA(bq27621,   0x80008000, BQ27XXX_O_UTOT | 
BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
+   [BQ27Z561]  = BQ27XXX_DATA(bq27z561,   0 , BQ27Z561_O_BITS),
 };
 
 static DEFINE_MUTEX(bq27xxx_list_lock);
@@ -1551,6 +1601,8 @@ static bool bq27xxx_battery_dead(struct