linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/2] power: bq27xxx: add bq78z100
@ 2021-02-05  7:10 LI Qingwu
  2021-02-05  7:10 ` [PATCH V4 1/2] dt-bindings: " LI Qingwu
  2021-02-05  7:10 ` [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100 LI Qingwu
  0 siblings, 2 replies; 6+ messages in thread
From: LI Qingwu @ 2021-02-05  7:10 UTC (permalink / raw)
  To: sre, robh+dt, dmurphy, pali, krzk, linux-pm, devicetree, linux-kernel
  Cc: grygorii.tertychnyi, andrey.zhizhikin, LI Qingwu

Changes in V4:
Correct the wrong part number in the subject, bq78z100 instead of
bq78z10.


LI Qingwu (2):
  dt-bindings: power: bq27xxx: add bq78z100
  power: supply: bq27xxx: Add support for BQ78Z100

 .../bindings/power/supply/bq27xxx.yaml        |  1 +
 drivers/power/supply/bq27xxx_battery.c        | 46 ++++++++++++++++++-
 drivers/power/supply/bq27xxx_battery_i2c.c    |  2 +
 include/linux/power/bq27xxx_battery.h         |  1 +
 4 files changed, 49 insertions(+), 1 deletion(-)

-- 
2.17.1


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

* [PATCH V4 1/2] dt-bindings: power: bq27xxx: add bq78z100
  2021-02-05  7:10 [PATCH V4 0/2] power: bq27xxx: add bq78z100 LI Qingwu
@ 2021-02-05  7:10 ` LI Qingwu
  2021-02-05  7:10 ` [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100 LI Qingwu
  1 sibling, 0 replies; 6+ messages in thread
From: LI Qingwu @ 2021-02-05  7:10 UTC (permalink / raw)
  To: sre, robh+dt, dmurphy, pali, krzk, linux-pm, devicetree, linux-kernel
  Cc: grygorii.tertychnyi, andrey.zhizhikin, LI Qingwu

Add bindings for TI BQ78Z100. An I2C interface gas gauge.
It provides a fully integrated safety protection
and authentication for 1 to 2-series cell Li-Ion and
Li-Polymer battery packs.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
index 45beefccf31a..712e974b28b6 100644
--- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
@@ -52,6 +52,7 @@ properties:
       - ti,bq27z561
       - ti,bq28z610
       - ti,bq34z100
+      - ti,bq78z100
 
   reg:
     maxItems: 1
-- 
2.17.1


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

* [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100
  2021-02-05  7:10 [PATCH V4 0/2] power: bq27xxx: add bq78z100 LI Qingwu
  2021-02-05  7:10 ` [PATCH V4 1/2] dt-bindings: " LI Qingwu
@ 2021-02-05  7:10 ` LI Qingwu
  2021-03-02 10:07   ` LI Qingwu
  2021-03-02 16:22   ` Sebastian Reichel
  1 sibling, 2 replies; 6+ messages in thread
From: LI Qingwu @ 2021-02-05  7:10 UTC (permalink / raw)
  To: sre, robh+dt, dmurphy, pali, krzk, linux-pm, devicetree, linux-kernel
  Cc: grygorii.tertychnyi, andrey.zhizhikin, LI Qingwu

Add support for TI BQ78Z100, I2C interface gas gauge.
It provides a fully integrated safety protection
and authentication for 1 to 2-series cell Li-Ion and
Li-Polymer battery packs.

The patch was tested with BQ78Z100 equipment.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/power/supply/bq27xxx_battery.c     | 46 +++++++++++++++++++++-
 drivers/power/supply/bq27xxx_battery_i2c.c |  2 +
 include/linux/power/bq27xxx_battery.h      |  1 +
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 315e0909e6a4..c8579ec7a4f8 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -39,6 +39,7 @@
  * https://www.ti.com/product/bq27z561
  * https://www.ti.com/product/bq28z610
  * https://www.ti.com/product/bq34z100-g1
+ * https://www.ti.com/product/bq78z100
  */
 
 #include <linux/device.h>
@@ -497,7 +498,27 @@ static u8
 		[BQ27XXX_REG_DCAP] = 0x3c,
 		[BQ27XXX_REG_AP] = 0x22,
 		BQ27XXX_DM_REG_ROWS,
-	};
+	},
+	bq78z100_regs[BQ27XXX_REG_MAX] = {
+		[BQ27XXX_REG_CTRL] = 0x00,
+		[BQ27XXX_REG_TEMP] = 0x06,
+		[BQ27XXX_REG_INT_TEMP] = 0x28,
+		[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,
@@ -792,6 +813,27 @@ static enum power_supply_property bq34z100_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
+static enum power_supply_property bq78z100_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_EMPTY_AVG,
+	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_ENERGY_NOW,
+	POWER_SUPPLY_PROP_POWER_AVG,
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_MANUFACTURER,
+};
+
 struct bq27xxx_dm_reg {
 	u8 subclass_id;
 	u8 offset;
@@ -890,6 +932,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
 #define bq27z561_dm_regs 0
 #define bq28z610_dm_regs 0
 #define bq34z100_dm_regs 0
+#define bq78z100_dm_regs 0
 
 #define BQ27XXX_O_ZERO		BIT(0)
 #define BQ27XXX_O_OTDC		BIT(1) /* has OTC/OTD overtemperature flags */
@@ -948,6 +991,7 @@ static struct {
 	[BQ28Z610]  = BQ27XXX_DATA(bq28z610,  0         , BQ27Z561_O_BITS),
 	[BQ34Z100]  = BQ27XXX_DATA(bq34z100,  0         , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \
 							  BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM),
+	[BQ78Z100]  = BQ27XXX_DATA(bq78z100,  0x00000000, BQ27Z561_O_BITS),
 };
 
 static DEFINE_MUTEX(bq27xxx_list_lock);
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index eb4f4284982f..46f078350fd3 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -248,6 +248,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27z561", BQ27Z561 },
 	{ "bq28z610", BQ28Z610 },
 	{ "bq34z100", BQ34Z100 },
+	{ "bq78z100", BQ78Z100 },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table);
@@ -284,6 +285,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
 	{ .compatible = "ti,bq27z561" },
 	{ .compatible = "ti,bq28z610" },
 	{ .compatible = "ti,bq34z100" },
+	{ .compatible = "ti,bq78z100" },
 	{},
 };
 MODULE_DEVICE_TABLE(of, bq27xxx_battery_i2c_of_match_table);
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index 111a40d0d3d5..ac17618043b1 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -33,6 +33,7 @@ enum bq27xxx_chip {
 	BQ27Z561,
 	BQ28Z610,
 	BQ34Z100,
+	BQ78Z100,
 };
 
 struct bq27xxx_device_info;
-- 
2.17.1


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

* RE: [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100
  2021-02-05  7:10 ` [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100 LI Qingwu
@ 2021-03-02 10:07   ` LI Qingwu
  2021-03-02 16:22   ` Sebastian Reichel
  1 sibling, 0 replies; 6+ messages in thread
From: LI Qingwu @ 2021-03-02 10:07 UTC (permalink / raw)
  To: LI Qingwu, sre, robh+dt, dmurphy, pali, krzk, linux-pm,
	devicetree, linux-kernel
  Cc: TERTYCHNYI Grygorii, ZHIZHIKIN Andrey

this is a friendly reminder.




Best Regards

**********************************************
Li Qingwu (Terry)
Senior Embedded Software Engineer 
Leica Geosystems(Shanghai)Co.,Limited
(Tel): +86 21 61061036
(FAX): +86 21 61061008
(Mobile): +86 187 0185 9600
E-mail: Qing-wu.Li@leica-geosystems.com.cn
Http: www.leica-geosystems.com.cn
**********************************************

-----Original Message-----
From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn> 
Sent: Friday, February 5, 2021 3:10 PM
To: sre@kernel.org; robh+dt@kernel.org; dmurphy@ti.com; pali@kernel.org; krzk@kernel.org; linux-pm@vger.kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: TERTYCHNYI Grygorii <grygorii.tertychnyi@leica-geosystems.com>; ZHIZHIKIN Andrey <andrey.zhizhikin@leica-geosystems.com>; LI Qingwu <qing-wu.li@leica-geosystems.com.cn>
Subject: [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100

Add support for TI BQ78Z100, I2C interface gas gauge.
It provides a fully integrated safety protection and authentication for 1 to 2-series cell Li-Ion and Li-Polymer battery packs.

The patch was tested with BQ78Z100 equipment.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
---
 drivers/power/supply/bq27xxx_battery.c     | 46 +++++++++++++++++++++-
 drivers/power/supply/bq27xxx_battery_i2c.c |  2 +
 include/linux/power/bq27xxx_battery.h      |  1 +
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 315e0909e6a4..c8579ec7a4f8 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -39,6 +39,7 @@
  * https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ti.com%2Fproduct%2Fbq27z561&amp;data=04%7C01%7C%7C9f9bd80e6c4c48b21f0208d8c9a5158b%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637481058152484173%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=m28d%2BWIxG3uVVBiA1GIYbahvhxe%2BqFFXHC9xFum17wc%3D&amp;reserved=0
  * https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ti.com%2Fproduct%2Fbq28z610&amp;data=04%7C01%7C%7C9f9bd80e6c4c48b21f0208d8c9a5158b%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637481058152484173%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5f7FlqKszetEP3Uq2rZFIvHAbSsVV%2FUAWS7gOKtdzts%3D&amp;reserved=0
  * https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ti.com%2Fproduct%2Fbq34z100-g1&amp;data=04%7C01%7C%7C9f9bd80e6c4c48b21f0208d8c9a5158b%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637481058152484173%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=IK%2Bfiq2ga7dciCQHO5%2FBqKRgRZDgNoM0NeVpjmT9YtY%3D&amp;reserved=0
+ * 
+ https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
+ ti.com%2Fproduct%2Fbq78z100&amp;data=04%7C01%7C%7C9f9bd80e6c4c48b21f02
+ 08d8c9a5158b%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637481058152
+ 484173%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJ
+ BTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ewaB4hkn%2Bx7EJPXIA5Uux0P
+ MolDcgFqTHYKCslVYDFs%3D&amp;reserved=0
  */
 
 #include <linux/device.h>
@@ -497,7 +498,27 @@ static u8
 		[BQ27XXX_REG_DCAP] = 0x3c,
 		[BQ27XXX_REG_AP] = 0x22,
 		BQ27XXX_DM_REG_ROWS,
-	};
+	},
+	bq78z100_regs[BQ27XXX_REG_MAX] = {
+		[BQ27XXX_REG_CTRL] = 0x00,
+		[BQ27XXX_REG_TEMP] = 0x06,
+		[BQ27XXX_REG_INT_TEMP] = 0x28,
+		[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,
@@ -792,6 +813,27 @@ static enum power_supply_property bq34z100_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
+static enum power_supply_property bq78z100_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_EMPTY_AVG,
+	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_ENERGY_NOW,
+	POWER_SUPPLY_PROP_POWER_AVG,
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_MANUFACTURER,
+};
+
 struct bq27xxx_dm_reg {
 	u8 subclass_id;
 	u8 offset;
@@ -890,6 +932,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {  #define bq27z561_dm_regs 0  #define bq28z610_dm_regs 0  #define bq34z100_dm_regs 0
+#define bq78z100_dm_regs 0
 
 #define BQ27XXX_O_ZERO		BIT(0)
 #define BQ27XXX_O_OTDC		BIT(1) /* has OTC/OTD overtemperature flags */
@@ -948,6 +991,7 @@ static struct {
 	[BQ28Z610]  = BQ27XXX_DATA(bq28z610,  0         , BQ27Z561_O_BITS),
 	[BQ34Z100]  = BQ27XXX_DATA(bq34z100,  0         , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \
 							  BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM),
+	[BQ78Z100]  = BQ27XXX_DATA(bq78z100,  0x00000000, BQ27Z561_O_BITS),
 };
 
 static DEFINE_MUTEX(bq27xxx_list_lock); diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index eb4f4284982f..46f078350fd3 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -248,6 +248,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27z561", BQ27Z561 },
 	{ "bq28z610", BQ28Z610 },
 	{ "bq34z100", BQ34Z100 },
+	{ "bq78z100", BQ78Z100 },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table); @@ -284,6 +285,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
 	{ .compatible = "ti,bq27z561" },
 	{ .compatible = "ti,bq28z610" },
 	{ .compatible = "ti,bq34z100" },
+	{ .compatible = "ti,bq78z100" },
 	{},
 };
 MODULE_DEVICE_TABLE(of, bq27xxx_battery_i2c_of_match_table);
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index 111a40d0d3d5..ac17618043b1 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -33,6 +33,7 @@ enum bq27xxx_chip {
 	BQ27Z561,
 	BQ28Z610,
 	BQ34Z100,
+	BQ78Z100,
 };
 
 struct bq27xxx_device_info;
--
2.17.1


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

* Re: [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100
  2021-02-05  7:10 ` [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100 LI Qingwu
  2021-03-02 10:07   ` LI Qingwu
@ 2021-03-02 16:22   ` Sebastian Reichel
  2021-03-05  6:56     ` LI Qingwu
  1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Reichel @ 2021-03-02 16:22 UTC (permalink / raw)
  To: LI Qingwu
  Cc: robh+dt, dmurphy, pali, krzk, linux-pm, devicetree, linux-kernel,
	grygorii.tertychnyi, andrey.zhizhikin

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

Hi,

On Fri, Feb 05, 2021 at 07:10:04AM +0000, LI Qingwu wrote:
> Add support for TI BQ78Z100, I2C interface gas gauge.
> It provides a fully integrated safety protection
> and authentication for 1 to 2-series cell Li-Ion and
> Li-Polymer battery packs.
> 
> The patch was tested with BQ78Z100 equipment.
> 
> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
> Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
> ---
>  drivers/power/supply/bq27xxx_battery.c     | 46 +++++++++++++++++++++-
>  drivers/power/supply/bq27xxx_battery_i2c.c |  2 +
>  include/linux/power/bq27xxx_battery.h      |  1 +
>  3 files changed, 48 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 315e0909e6a4..c8579ec7a4f8 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -39,6 +39,7 @@
>   * https://www.ti.com/product/bq27z561
>   * https://www.ti.com/product/bq28z610
>   * https://www.ti.com/product/bq34z100-g1
> + * https://www.ti.com/product/bq78z100
>   */
>  
>  #include <linux/device.h>
> @@ -497,7 +498,27 @@ static u8
>  		[BQ27XXX_REG_DCAP] = 0x3c,
>  		[BQ27XXX_REG_AP] = 0x22,
>  		BQ27XXX_DM_REG_ROWS,
> -	};
> +	},
> +	bq78z100_regs[BQ27XXX_REG_MAX] = {
> +		[BQ27XXX_REG_CTRL] = 0x00,
> +		[BQ27XXX_REG_TEMP] = 0x06,
> +		[BQ27XXX_REG_INT_TEMP] = 0x28,
> +		[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,

Datasheet states StandbyTimeToEmpty = 0x1C?

> +		[BQ27XXX_REG_TTECP] = INVALID_REG_ADDR,
> +		[BQ27XXX_REG_NAC] = INVALID_REG_ADDR,

missing BQ27XXX_REG_RC. Looks like chip has support for it at
address 0x10.

> +		[BQ27XXX_REG_FCC] = 0x12,
> +		[BQ27XXX_REG_CYCT] = 0x2a,
> +		[BQ27XXX_REG_AE] = 0x22,

REG_AE is available energy. REG_AP is average power. Obviously
two completley different things and cannot be the same register.
A quick glance at the datasheet suggests AE does not exist.

> +		[BQ27XXX_REG_SOC] = 0x2c,
> +		[BQ27XXX_REG_DCAP] = 0x3c,
> +		[BQ27XXX_REG_AP] = 0x22,
> +		BQ27XXX_DM_REG_ROWS,
> +};

Please fix indention of };

>  
>  static enum power_supply_property bq27000_props[] = {
>  	POWER_SUPPLY_PROP_STATUS,
> @@ -792,6 +813,27 @@ static enum power_supply_property bq34z100_props[] = {
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  };
>  
> +static enum power_supply_property bq78z100_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_EMPTY_AVG,

You are not providing data for this? (BQ27XXX_REG_TTECP is not set).
Please revisit the list of exposed properties and provide a dump of
/sys/class/power_supply/<your_battery>/uevent in your submission.
Currently you should see some -ENODATA.

> +	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_ENERGY_NOW,
> +	POWER_SUPPLY_PROP_POWER_AVG,
> +	POWER_SUPPLY_PROP_HEALTH,
> +	POWER_SUPPLY_PROP_MANUFACTURER,
> +};
> +
>  struct bq27xxx_dm_reg {
>  	u8 subclass_id;
>  	u8 offset;
> @@ -890,6 +932,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
>  #define bq27z561_dm_regs 0
>  #define bq28z610_dm_regs 0
>  #define bq34z100_dm_regs 0
> +#define bq78z100_dm_regs 0
>  
>  #define BQ27XXX_O_ZERO		BIT(0)
>  #define BQ27XXX_O_OTDC		BIT(1) /* has OTC/OTD overtemperature flags */
> @@ -948,6 +991,7 @@ static struct {
>  	[BQ28Z610]  = BQ27XXX_DATA(bq28z610,  0         , BQ27Z561_O_BITS),
>  	[BQ34Z100]  = BQ27XXX_DATA(bq34z100,  0         , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \
>  							  BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM),
> +	[BQ78Z100]  = BQ27XXX_DATA(bq78z100,  0x00000000, BQ27Z561_O_BITS),

why 0x00000000 instead of just '0' like in the other entries?

>  };
>  
>  static DEFINE_MUTEX(bq27xxx_list_lock);
> diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
> index eb4f4284982f..46f078350fd3 100644
> --- a/drivers/power/supply/bq27xxx_battery_i2c.c
> +++ b/drivers/power/supply/bq27xxx_battery_i2c.c
> @@ -248,6 +248,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
>  	{ "bq27z561", BQ27Z561 },
>  	{ "bq28z610", BQ28Z610 },
>  	{ "bq34z100", BQ34Z100 },
> +	{ "bq78z100", BQ78Z100 },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table);
> @@ -284,6 +285,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
>  	{ .compatible = "ti,bq27z561" },
>  	{ .compatible = "ti,bq28z610" },
>  	{ .compatible = "ti,bq34z100" },
> +	{ .compatible = "ti,bq78z100" },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, bq27xxx_battery_i2c_of_match_table);
> diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
> index 111a40d0d3d5..ac17618043b1 100644
> --- a/include/linux/power/bq27xxx_battery.h
> +++ b/include/linux/power/bq27xxx_battery.h
> @@ -33,6 +33,7 @@ enum bq27xxx_chip {
>  	BQ27Z561,
>  	BQ28Z610,
>  	BQ34Z100,
> +	BQ78Z100,
>  };
>  
>  struct bq27xxx_device_info;

Thanks,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* RE: [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100
  2021-03-02 16:22   ` Sebastian Reichel
@ 2021-03-05  6:56     ` LI Qingwu
  0 siblings, 0 replies; 6+ messages in thread
From: LI Qingwu @ 2021-03-05  6:56 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: robh+dt, dmurphy, pali, krzk, linux-pm, devicetree, linux-kernel,
	TERTYCHNYI Grygorii, ZHIZHIKIN Andrey

Hi Sebastian,

Thanks a lot for your input, I changed according your input in PATCH V5, please review.
About "why 0x00000000 instead of just '0' like in the other entries?", since I got an error from checkpatch.pl.

ERROR: space prohibited before that ',' (ctx:WxW)
#100: FILE: drivers/power/supply/bq27xxx_battery.c:1015:
+       [BQ78Z100]  = BQ27XXX_DATA(bq78z100,  0         , BQ27Z561_O_BITS),
                                                        ^




Best Regards

**********************************************
Li Qingwu (Terry)
Senior Embedded Software Engineer 
Leica Geosystems(Shanghai)Co.,Limited
(Tel): +86 21 61061036
(FAX): +86 21 61061008
(Mobile): +86 187 0185 9600
E-mail: Qing-wu.Li@leica-geosystems.com.cn
Http: www.leica-geosystems.com.cn
**********************************************

-----Original Message-----
From: Sebastian Reichel <sebastian.reichel@collabora.com> 
Sent: Wednesday, March 3, 2021 12:22 AM
To: LI Qingwu <qing-wu.li@leica-geosystems.com.cn>
Cc: robh+dt@kernel.org; dmurphy@ti.com; pali@kernel.org; krzk@kernel.org; linux-pm@vger.kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; TERTYCHNYI Grygorii <grygorii.tertychnyi@leica-geosystems.com>; ZHIZHIKIN Andrey <andrey.zhizhikin@leica-geosystems.com>
Subject: Re: [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100

Hi,

On Fri, Feb 05, 2021 at 07:10:04AM +0000, LI Qingwu wrote:
> Add support for TI BQ78Z100, I2C interface gas gauge.
> It provides a fully integrated safety protection and authentication 
> for 1 to 2-series cell Li-Ion and Li-Polymer battery packs.
> 
> The patch was tested with BQ78Z100 equipment.
> 
> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
> Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
> ---
>  drivers/power/supply/bq27xxx_battery.c     | 46 +++++++++++++++++++++-
>  drivers/power/supply/bq27xxx_battery_i2c.c |  2 +
>  include/linux/power/bq27xxx_battery.h      |  1 +
>  3 files changed, 48 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/bq27xxx_battery.c 
> b/drivers/power/supply/bq27xxx_battery.c
> index 315e0909e6a4..c8579ec7a4f8 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -39,6 +39,7 @@
>   * https://www.ti.com/product/bq27z561
>   * https://www.ti.com/product/bq28z610
>   * https://www.ti.com/product/bq34z100-g1
> + * https://www.ti.com/product/bq78z100
>   */
>  
>  #include <linux/device.h>
> @@ -497,7 +498,27 @@ static u8
>  		[BQ27XXX_REG_DCAP] = 0x3c,
>  		[BQ27XXX_REG_AP] = 0x22,
>  		BQ27XXX_DM_REG_ROWS,
> -	};
> +	},
> +	bq78z100_regs[BQ27XXX_REG_MAX] = {
> +		[BQ27XXX_REG_CTRL] = 0x00,
> +		[BQ27XXX_REG_TEMP] = 0x06,
> +		[BQ27XXX_REG_INT_TEMP] = 0x28,
> +		[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,

Datasheet states StandbyTimeToEmpty = 0x1C?

> +		[BQ27XXX_REG_TTECP] = INVALID_REG_ADDR,
> +		[BQ27XXX_REG_NAC] = INVALID_REG_ADDR,

missing BQ27XXX_REG_RC. Looks like chip has support for it at address 0x10.

> +		[BQ27XXX_REG_FCC] = 0x12,
> +		[BQ27XXX_REG_CYCT] = 0x2a,
> +		[BQ27XXX_REG_AE] = 0x22,

REG_AE is available energy. REG_AP is average power. Obviously two completley different things and cannot be the same register.
A quick glance at the datasheet suggests AE does not exist.

> +		[BQ27XXX_REG_SOC] = 0x2c,
> +		[BQ27XXX_REG_DCAP] = 0x3c,
> +		[BQ27XXX_REG_AP] = 0x22,
> +		BQ27XXX_DM_REG_ROWS,
> +};

Please fix indention of };

>  
>  static enum power_supply_property bq27000_props[] = {
>  	POWER_SUPPLY_PROP_STATUS,
> @@ -792,6 +813,27 @@ static enum power_supply_property bq34z100_props[] = {
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  };
>  
> +static enum power_supply_property bq78z100_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_EMPTY_AVG,

You are not providing data for this? (BQ27XXX_REG_TTECP is not set).
Please revisit the list of exposed properties and provide a dump of /sys/class/power_supply/<your_battery>/uevent in your submission.
Currently you should see some -ENODATA.

> +	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_ENERGY_NOW,
> +	POWER_SUPPLY_PROP_POWER_AVG,
> +	POWER_SUPPLY_PROP_HEALTH,
> +	POWER_SUPPLY_PROP_MANUFACTURER,
> +};
> +
>  struct bq27xxx_dm_reg {
>  	u8 subclass_id;
>  	u8 offset;
> @@ -890,6 +932,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {  
> #define bq27z561_dm_regs 0  #define bq28z610_dm_regs 0  #define 
> bq34z100_dm_regs 0
> +#define bq78z100_dm_regs 0
>  
>  #define BQ27XXX_O_ZERO		BIT(0)
>  #define BQ27XXX_O_OTDC		BIT(1) /* has OTC/OTD overtemperature flags */
> @@ -948,6 +991,7 @@ static struct {
>  	[BQ28Z610]  = BQ27XXX_DATA(bq28z610,  0         , BQ27Z561_O_BITS),
>  	[BQ34Z100]  = BQ27XXX_DATA(bq34z100,  0         , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \
>  							  BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM),
> +	[BQ78Z100]  = BQ27XXX_DATA(bq78z100,  0x00000000, BQ27Z561_O_BITS),

why 0x00000000 instead of just '0' like in the other entries?

>  };
>  
>  static DEFINE_MUTEX(bq27xxx_list_lock); diff --git 
> a/drivers/power/supply/bq27xxx_battery_i2c.c 
> b/drivers/power/supply/bq27xxx_battery_i2c.c
> index eb4f4284982f..46f078350fd3 100644
> --- a/drivers/power/supply/bq27xxx_battery_i2c.c
> +++ b/drivers/power/supply/bq27xxx_battery_i2c.c
> @@ -248,6 +248,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
>  	{ "bq27z561", BQ27Z561 },
>  	{ "bq28z610", BQ28Z610 },
>  	{ "bq34z100", BQ34Z100 },
> +	{ "bq78z100", BQ78Z100 },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table); @@ -284,6 +285,7 @@ 
> static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
>  	{ .compatible = "ti,bq27z561" },
>  	{ .compatible = "ti,bq28z610" },
>  	{ .compatible = "ti,bq34z100" },
> +	{ .compatible = "ti,bq78z100" },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, bq27xxx_battery_i2c_of_match_table);
> diff --git a/include/linux/power/bq27xxx_battery.h 
> b/include/linux/power/bq27xxx_battery.h
> index 111a40d0d3d5..ac17618043b1 100644
> --- a/include/linux/power/bq27xxx_battery.h
> +++ b/include/linux/power/bq27xxx_battery.h
> @@ -33,6 +33,7 @@ enum bq27xxx_chip {
>  	BQ27Z561,
>  	BQ28Z610,
>  	BQ34Z100,
> +	BQ78Z100,
>  };
>  
>  struct bq27xxx_device_info;

Thanks,

-- Sebastian

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

end of thread, other threads:[~2021-03-05  6:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05  7:10 [PATCH V4 0/2] power: bq27xxx: add bq78z100 LI Qingwu
2021-02-05  7:10 ` [PATCH V4 1/2] dt-bindings: " LI Qingwu
2021-02-05  7:10 ` [PATCH V4 2/2] power: supply: bq27xxx: Add support for BQ78Z100 LI Qingwu
2021-03-02 10:07   ` LI Qingwu
2021-03-02 16:22   ` Sebastian Reichel
2021-03-05  6:56     ` LI Qingwu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).