Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1553993 > unrolled thread

[PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support

Started byChris Lapa <chris@lapa.com.au>
First post2017-01-09 01:50 +0100
Last post2017-01-10 04:00 +0100
Articles 7 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 00/11]  power: supply: bq275xx: implement individual chip revision support Chris Lapa <chris@lapa.com.au> - 2017-01-09 01:50 +0100
    [PATCH v3 08/11] power: supplies: bq275xx: adds specific support for bq27520-g2 revision. Chris Lapa <chris@lapa.com.au> - 2017-01-09 01:50 +0100
    [PATCH v3 09/11] power: supplies: bq275xx: adds specific support for bq27520-g3 revision. Chris Lapa <chris@lapa.com.au> - 2017-01-09 01:50 +0100
    [PATCH v3 02/11] power: supplies: bq275xx: rename BQ27500 allow for deprecation in future. Chris Lapa <chris@lapa.com.au> - 2017-01-09 02:00 +0100
    [PATCH v3 05/11] power: supplies: bq275xx: adds specific support for bq27510-g2 revision. Chris Lapa <chris@lapa.com.au> - 2017-01-09 02:00 +0100
    Re: [PATCH v3 00/11]  power: supply: bq275xx: implement individual  chip revision support Pali Rohár <pali.rohar@gmail.com> - 2017-01-09 09:30 +0100
    Re: [PATCH v3 00/11]  power: supply: bq275xx: implement individual  chip revision support Sebastian Reichel <sre@kernel.org> - 2017-01-10 04:00 +0100

#1553993 — [PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support

FromChris Lapa <chris@lapa.com.au>
Date2017-01-09 01:50 +0100
Subject[PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support
Message-ID<sXwjT-5mL-3@gated-at.bofh.it>
From: Chris Lapa <chris@lapa.com.au>

This patch series separates out support for each revision chip in
the bq27500, bq27510 and bq27520 family. Each revision has enough
register address changes to justify individual register mappings.

The series also cleans up the large overtemp if statement to
improve readability and adds devicetree documentation for all
the support bq27xxx series chips.

I had a chance to test the deprecated bq27500/10/20 support which still
behaves the same. I also tested the new specific bq27510g3 support
on a custom board I have here and it worked correctly.

Chris Lapa (11):
  power: supplies: bq275xx: move overtemp tests to a switch statement.
  power: supplies: bq275xx: rename BQ27500 allow for deprecation in
    future.
  power: supplies: bq275xx: adds specific support for bq27500/1
    revision.
  power: supplies: bq275xx: adds specific support for bq27510-g1
    revision.
  power: supplies: bq275xx: adds specific support for bq27510-g2
    revision.
  power: supplies: bq275xx: adds specific support for bq27510-g3
    revision.
  power: supplies: bq275xx: adds specific support for bq27520-g1
    revision.
  power: supplies: bq275xx: adds specific support for bq27520-g2
    revision.
  power: supplies: bq275xx: adds specific support for bq27520-g3
    revision.
  power: supplies: bq275xx: adds specific support for bq27520-g4
    revision.
  power: supplies: bq27xxx: adds device tree binding documentation.

 .../devicetree/bindings/power/supply/bq27xxx.txt   |  36 +++
 drivers/power/supply/bq27xxx_battery.c             | 348 ++++++++++++++++++++-
 drivers/power/supply/bq27xxx_battery_i2c.c         |  22 +-
 include/linux/power/bq27xxx_battery.h              |  10 +-
 4 files changed, 407 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq27xxx.txt

-- 
2.1.4

[toc] | [next] | [standalone]


#1553994 — [PATCH v3 08/11] power: supplies: bq275xx: adds specific support for bq27520-g2 revision.

FromChris Lapa <chris@lapa.com.au>
Date2017-01-09 01:50 +0100
Subject[PATCH v3 08/11] power: supplies: bq275xx: adds specific support for bq27520-g2 revision.
Message-ID<sXwjT-5mL-21@gated-at.bofh.it>
In reply to#1553993
From: Chris Lapa <chris@lapa.com.au>

This commit adds the BQ27520G2 chip definition to specifically match the
bq27520-G2 functionality as described in the datasheet.

tested: no

Signed-off-by: Chris Lapa <chris@lapa.com.au>
---
 drivers/power/supply/bq27xxx_battery.c     | 43 ++++++++++++++++++++++++++++++
 drivers/power/supply/bq27xxx_battery_i2c.c |  2 ++
 include/linux/power/bq27xxx_battery.h      |  1 +
 3 files changed, 46 insertions(+)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 676fbe6..ac59c24 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -27,6 +27,7 @@
  * http://www.ti.com/product/bq27510-g3
  * http://www.ti.com/product/bq27520-g4
  * http://www.ti.com/product/bq27520-g1
+ * http://www.ti.com/product/bq27520-g2
  * http://www.ti.com/product/bq27530-g1
  * http://www.ti.com/product/bq27531-g1
  * http://www.ti.com/product/bq27541-g1
@@ -262,6 +263,25 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
 		[BQ27XXX_REG_DCAP] = 0x3c,
 		[BQ27XXX_REG_AP] = 0x24,
 	},
+	[BQ27520G2] = {
+		[BQ27XXX_REG_CTRL] = 0x00,
+		[BQ27XXX_REG_TEMP] = 0x06,
+		[BQ27XXX_REG_INT_TEMP] = 0x36,
+		[BQ27XXX_REG_VOLT] = 0x08,
+		[BQ27XXX_REG_AI] = 0x14,
+		[BQ27XXX_REG_FLAGS] = 0x0a,
+		[BQ27XXX_REG_TTE] = 0x16,
+		[BQ27XXX_REG_TTF] = 0x18,
+		[BQ27XXX_REG_TTES] = 0x1c,
+		[BQ27XXX_REG_TTECP] = 0x26,
+		[BQ27XXX_REG_NAC] = 0x0c,
+		[BQ27XXX_REG_FCC] = 0x12,
+		[BQ27XXX_REG_CYCT] = 0x2a,
+		[BQ27XXX_REG_AE] = 0x22,
+		[BQ27XXX_REG_SOC] = 0x2c,
+		[BQ27XXX_REG_DCAP] = 0x3c,
+		[BQ27XXX_REG_AP] = 0x24,
+	},
 	[BQ27530] = {
 		[BQ27XXX_REG_CTRL] = 0x00,
 		[BQ27XXX_REG_TEMP] = 0x06,
@@ -501,6 +521,27 @@ static enum power_supply_property bq27520g1_battery_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
+static enum power_supply_property bq27520g2_battery_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_NOW,
+	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,
+};
+
 static enum power_supply_property bq27530_battery_props[] = {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_PRESENT,
@@ -589,6 +630,7 @@ static struct {
 	BQ27XXX_PROP(BQ27510G2, bq27510g2_battery_props),
 	BQ27XXX_PROP(BQ27510G3, bq27510g3_battery_props),
 	BQ27XXX_PROP(BQ27520G1, bq27520g1_battery_props),
+	BQ27XXX_PROP(BQ27520G2, bq27520g2_battery_props),
 	BQ27XXX_PROP(BQ27530, bq27530_battery_props),
 	BQ27XXX_PROP(BQ27541, bq27541_battery_props),
 	BQ27XXX_PROP(BQ27545, bq27545_battery_props),
@@ -846,6 +888,7 @@ static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
 	case BQ27510G2:
 	case BQ27510G3:
 	case BQ27520G1:
+	case BQ27520G2:
 	case BQ27541:
 	case BQ27545:
 		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 33a7d18..4835523 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -156,6 +156,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27510g2", BQ27510G2 },
 	{ "bq27510g3", BQ27510G3 },
 	{ "bq27520g1", BQ27520G1 },
+	{ "bq27520g2", BQ27520G2 },
 	{ "bq27530", BQ27530 },
 	{ "bq27531", BQ27530 },
 	{ "bq27541", BQ27541 },
@@ -183,6 +184,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
 	{ .compatible = "ti,bq27510g2" },
 	{ .compatible = "ti,bq27510g3" },
 	{ .compatible = "ti,bq27520g1" },
+	{ .compatible = "ti,bq27520g2" },
 	{ .compatible = "ti,bq27530" },
 	{ .compatible = "ti,bq27531" },
 	{ .compatible = "ti,bq27541" },
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index b971401..6a1a4ab 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -10,6 +10,7 @@ enum bq27xxx_chip {
 	BQ27510G2, /* bq27510G2 */
 	BQ27510G3, /* bq27510G3 */
 	BQ27520G1, /* bq27520G1 */
+	BQ27520G2, /* bq27520G2 */
 	BQ27530, /* bq27530, bq27531 */
 	BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
 	BQ27545, /* bq27545 */
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1553995 — [PATCH v3 09/11] power: supplies: bq275xx: adds specific support for bq27520-g3 revision.

FromChris Lapa <chris@lapa.com.au>
Date2017-01-09 01:50 +0100
Subject[PATCH v3 09/11] power: supplies: bq275xx: adds specific support for bq27520-g3 revision.
Message-ID<sXwjT-5mL-23@gated-at.bofh.it>
In reply to#1553993
From: Chris Lapa <chris@lapa.com.au>

This commit adds the BQ27520G3 chip definition to specifically match the
bq27520-G3 functionality as described in the datasheet.

tested: no

Signed-off-by: Chris Lapa <chris@lapa.com.au>
---
 drivers/power/supply/bq27xxx_battery.c     | 42 ++++++++++++++++++++++++++++++
 drivers/power/supply/bq27xxx_battery_i2c.c |  2 ++
 include/linux/power/bq27xxx_battery.h      |  1 +
 3 files changed, 45 insertions(+)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index ac59c24..0dca4ee 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -28,6 +28,7 @@
  * http://www.ti.com/product/bq27520-g4
  * http://www.ti.com/product/bq27520-g1
  * http://www.ti.com/product/bq27520-g2
+ * http://www.ti.com/product/bq27520-g3
  * http://www.ti.com/product/bq27530-g1
  * http://www.ti.com/product/bq27531-g1
  * http://www.ti.com/product/bq27541-g1
@@ -282,6 +283,25 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
 		[BQ27XXX_REG_DCAP] = 0x3c,
 		[BQ27XXX_REG_AP] = 0x24,
 	},
+	[BQ27520G3] = {
+		[BQ27XXX_REG_CTRL] = 0x00,
+		[BQ27XXX_REG_TEMP] = 0x06,
+		[BQ27XXX_REG_INT_TEMP] = 0x36,
+		[BQ27XXX_REG_VOLT] = 0x08,
+		[BQ27XXX_REG_AI] = 0x14,
+		[BQ27XXX_REG_FLAGS] = 0x0a,
+		[BQ27XXX_REG_TTE] = 0x16,
+		[BQ27XXX_REG_TTF] = INVALID_REG_ADDR,
+		[BQ27XXX_REG_TTES] = 0x1c,
+		[BQ27XXX_REG_TTECP] = 0x26,
+		[BQ27XXX_REG_NAC] = 0x0c,
+		[BQ27XXX_REG_FCC] = 0x12,
+		[BQ27XXX_REG_CYCT] = 0x2a,
+		[BQ27XXX_REG_AE] = 0x22,
+		[BQ27XXX_REG_SOC] = 0x2c,
+		[BQ27XXX_REG_DCAP] = 0x3c,
+		[BQ27XXX_REG_AP] = 0x24,
+	},
 	[BQ27530] = {
 		[BQ27XXX_REG_CTRL] = 0x00,
 		[BQ27XXX_REG_TEMP] = 0x06,
@@ -542,6 +562,26 @@ static enum power_supply_property bq27520g2_battery_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
+static enum power_supply_property bq27520g3_battery_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_TECHNOLOGY,
+	POWER_SUPPLY_PROP_CHARGE_FULL,
+	POWER_SUPPLY_PROP_CHARGE_NOW,
+	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,
+};
+
 static enum power_supply_property bq27530_battery_props[] = {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_PRESENT,
@@ -631,6 +671,7 @@ static struct {
 	BQ27XXX_PROP(BQ27510G3, bq27510g3_battery_props),
 	BQ27XXX_PROP(BQ27520G1, bq27520g1_battery_props),
 	BQ27XXX_PROP(BQ27520G2, bq27520g2_battery_props),
+	BQ27XXX_PROP(BQ27520G3, bq27520g3_battery_props),
 	BQ27XXX_PROP(BQ27530, bq27530_battery_props),
 	BQ27XXX_PROP(BQ27541, bq27541_battery_props),
 	BQ27XXX_PROP(BQ27545, bq27545_battery_props),
@@ -889,6 +930,7 @@ static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
 	case BQ27510G3:
 	case BQ27520G1:
 	case BQ27520G2:
+	case BQ27520G3:
 	case BQ27541:
 	case BQ27545:
 		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 4835523..899a846 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -157,6 +157,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27510g3", BQ27510G3 },
 	{ "bq27520g1", BQ27520G1 },
 	{ "bq27520g2", BQ27520G2 },
+	{ "bq27520g3", BQ27520G3 },
 	{ "bq27530", BQ27530 },
 	{ "bq27531", BQ27530 },
 	{ "bq27541", BQ27541 },
@@ -185,6 +186,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
 	{ .compatible = "ti,bq27510g3" },
 	{ .compatible = "ti,bq27520g1" },
 	{ .compatible = "ti,bq27520g2" },
+	{ .compatible = "ti,bq27520g3" },
 	{ .compatible = "ti,bq27530" },
 	{ .compatible = "ti,bq27531" },
 	{ .compatible = "ti,bq27541" },
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index 6a1a4ab..e61f4fa 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -11,6 +11,7 @@ enum bq27xxx_chip {
 	BQ27510G3, /* bq27510G3 */
 	BQ27520G1, /* bq27520G1 */
 	BQ27520G2, /* bq27520G2 */
+	BQ27520G3, /* bq27520G3 */
 	BQ27530, /* bq27530, bq27531 */
 	BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
 	BQ27545, /* bq27545 */
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1553996 — [PATCH v3 02/11] power: supplies: bq275xx: rename BQ27500 allow for deprecation in future.

FromChris Lapa <chris@lapa.com.au>
Date2017-01-09 02:00 +0100
Subject[PATCH v3 02/11] power: supplies: bq275xx: rename BQ27500 allow for deprecation in future.
Message-ID<sXwtz-5pU-1@gated-at.bofh.it>
In reply to#1553993
From: Chris Lapa <chris@lapa.com.au>

The BQ275XX definition exists only to satisfy backwards compatibility.

tested: yes

Signed-off-by: Chris Lapa <chris@lapa.com.au>
---
 drivers/power/supply/bq27xxx_battery.c     | 8 ++++----
 drivers/power/supply/bq27xxx_battery_i2c.c | 6 +++---
 include/linux/power/bq27xxx_battery.h      | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index fd4cc4e..b94091e 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -145,7 +145,7 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
 		[BQ27XXX_REG_DCAP] = 0x76,
 		[BQ27XXX_REG_AP] = INVALID_REG_ADDR,
 	},
-	[BQ27500] = {
+	[BQ275XX] = {
 		[BQ27XXX_REG_CTRL] = 0x00,
 		[BQ27XXX_REG_TEMP] = 0x06,
 		[BQ27XXX_REG_INT_TEMP] = 0x28,
@@ -284,7 +284,7 @@ static enum power_supply_property bq27010_battery_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
-static enum power_supply_property bq27500_battery_props[] = {
+static enum power_supply_property bq275xx_battery_props[] = {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -384,7 +384,7 @@ static struct {
 } bq27xxx_battery_props[] = {
 	BQ27XXX_PROP(BQ27000, bq27000_battery_props),
 	BQ27XXX_PROP(BQ27010, bq27010_battery_props),
-	BQ27XXX_PROP(BQ27500, bq27500_battery_props),
+	BQ27XXX_PROP(BQ275XX, bq275xx_battery_props),
 	BQ27XXX_PROP(BQ27530, bq27530_battery_props),
 	BQ27XXX_PROP(BQ27541, bq27541_battery_props),
 	BQ27XXX_PROP(BQ27545, bq27545_battery_props),
@@ -636,7 +636,7 @@ static int bq27xxx_battery_read_pwr_avg(struct bq27xxx_device_info *di)
 static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
 {
 	switch (di->chip) {
-	case BQ27500:
+	case BQ275XX:
 	case BQ27541:
 	case BQ27545:
 		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 85d4ea2..762d96e 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -148,9 +148,9 @@ static int bq27xxx_battery_i2c_remove(struct i2c_client *client)
 static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27200", BQ27000 },
 	{ "bq27210", BQ27010 },
-	{ "bq27500", BQ27500 },
-	{ "bq27510", BQ27500 },
-	{ "bq27520", BQ27500 },
+	{ "bq27500", BQ275XX },
+	{ "bq27510", BQ275XX },
+	{ "bq27520", BQ275XX },
 	{ "bq27530", BQ27530 },
 	{ "bq27531", BQ27530 },
 	{ "bq27541", BQ27541 },
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index e30deb0..c452b94 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -4,7 +4,7 @@
 enum bq27xxx_chip {
 	BQ27000 = 1, /* bq27000, bq27200 */
 	BQ27010, /* bq27010, bq27210 */
-	BQ27500, /* bq27500, bq27510, bq27520 */
+	BQ275XX, /* bq27500, bq27510, bq27520 deprecated alias */
 	BQ27530, /* bq27530, bq27531 */
 	BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
 	BQ27545, /* bq27545 */
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1553998 — [PATCH v3 05/11] power: supplies: bq275xx: adds specific support for bq27510-g2 revision.

FromChris Lapa <chris@lapa.com.au>
Date2017-01-09 02:00 +0100
Subject[PATCH v3 05/11] power: supplies: bq275xx: adds specific support for bq27510-g2 revision.
Message-ID<sXwtz-5pU-9@gated-at.bofh.it>
In reply to#1553993
From: Chris Lapa <chris@lapa.com.au>

This commit adds the BQ27510G2 chip definition to specifically match the
bq27510-G2 functionality as described in the datasheet.

tested: no

Signed-off-by: Chris Lapa <chris@lapa.com.au>
---
 drivers/power/supply/bq27xxx_battery.c     | 43 ++++++++++++++++++++++++++++++
 drivers/power/supply/bq27xxx_battery_i2c.c |  2 ++
 include/linux/power/bq27xxx_battery.h      |  1 +
 3 files changed, 46 insertions(+)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 84d04bb..e2c28da 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -23,6 +23,7 @@
  * http://www.ti.com/product/bq27210
  * http://www.ti.com/product/bq27500
  * http://www.ti.com/product/bq27510-g1
+ * http://www.ti.com/product/bq27510-g2
  * http://www.ti.com/product/bq27510-g3
  * http://www.ti.com/product/bq27520-g4
  * http://www.ti.com/product/bq27530-g1
@@ -203,6 +204,25 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
 		[BQ27XXX_REG_DCAP] = 0x3c,
 		[BQ27XXX_REG_AP] = 0x24,
 	},
+	[BQ27510G2] = {
+		[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] = 0x1c,
+		[BQ27XXX_REG_TTECP] = 0x26,
+		[BQ27XXX_REG_NAC] = 0x0c,
+		[BQ27XXX_REG_FCC] = 0x12,
+		[BQ27XXX_REG_CYCT] = 0x2a,
+		[BQ27XXX_REG_AE] = 0x22,
+		[BQ27XXX_REG_SOC] = 0x2c,
+		[BQ27XXX_REG_DCAP] = 0x3c,
+		[BQ27XXX_REG_AP] = 0x24,
+	},
 	[BQ27530] = {
 		[BQ27XXX_REG_CTRL] = 0x00,
 		[BQ27XXX_REG_TEMP] = 0x06,
@@ -383,6 +403,27 @@ static enum power_supply_property bq27510g1_battery_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
+static enum power_supply_property bq27510g2_battery_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_NOW,
+	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,
+};
+
 static enum power_supply_property bq27530_battery_props[] = {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_PRESENT,
@@ -468,6 +509,7 @@ static struct {
 	BQ27XXX_PROP(BQ275XX, bq275xx_battery_props),
 	BQ27XXX_PROP(BQ27500, bq27500_battery_props),
 	BQ27XXX_PROP(BQ27510G1, bq27510g1_battery_props),
+	BQ27XXX_PROP(BQ27510G2, bq27510g2_battery_props),
 	BQ27XXX_PROP(BQ27530, bq27530_battery_props),
 	BQ27XXX_PROP(BQ27541, bq27541_battery_props),
 	BQ27XXX_PROP(BQ27545, bq27545_battery_props),
@@ -722,6 +764,7 @@ static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
 	case BQ275XX:
 	case BQ27500:
 	case BQ27510G1:
+	case BQ27510G2:
 	case BQ27541:
 	case BQ27545:
 		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 61f13fd..5f30d6a 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -153,6 +153,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27520", BQ275XX },
 	{ "bq27500-1", BQ27500 },
 	{ "bq27510g1", BQ27510G1 },
+	{ "bq27510g2", BQ27510G2 },
 	{ "bq27530", BQ27530 },
 	{ "bq27531", BQ27530 },
 	{ "bq27541", BQ27541 },
@@ -177,6 +178,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
 	{ .compatible = "ti,bq27520" },
 	{ .compatible = "ti,bq27500-1" },
 	{ .compatible = "ti,bq27510g1" },
+	{ .compatible = "ti,bq27510g2" },
 	{ .compatible = "ti,bq27530" },
 	{ .compatible = "ti,bq27531" },
 	{ .compatible = "ti,bq27541" },
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index 9fa7c86..dd5df1e 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -7,6 +7,7 @@ enum bq27xxx_chip {
 	BQ275XX, /* bq27500, bq27510, bq27520 deprecated alias */
 	BQ27500, /* bq27500/1 */
 	BQ27510G1, /* bq27510G1 */
+	BQ27510G2, /* bq27510G2 */
 	BQ27530, /* bq27530, bq27531 */
 	BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
 	BQ27545, /* bq27545 */
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1554146 — Re: [PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support

FromPali Rohár <pali.rohar@gmail.com>
Date2017-01-09 09:30 +0100
SubjectRe: [PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support
Message-ID<sXDv3-1Id-21@gated-at.bofh.it>
In reply to#1553993
On Monday 09 January 2017 11:47:34 Chris Lapa wrote:
> From: Chris Lapa <chris@lapa.com.au>
> 
> This patch series separates out support for each revision chip in
> the bq27500, bq27510 and bq27520 family. Each revision has enough
> register address changes to justify individual register mappings.
> 
> The series also cleans up the large overtemp if statement to
> improve readability and adds devicetree documentation for all
> the support bq27xxx series chips.
> 
> I had a chance to test the deprecated bq27500/10/20 support which still
> behaves the same. I also tested the new specific bq27510g3 support
> on a custom board I have here and it worked correctly.
> 
> Chris Lapa (11):
>   power: supplies: bq275xx: move overtemp tests to a switch statement.
>   power: supplies: bq275xx: rename BQ27500 allow for deprecation in
>     future.
>   power: supplies: bq275xx: adds specific support for bq27500/1
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27510-g1
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27510-g2
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27510-g3
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27520-g1
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27520-g2
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27520-g3
>     revision.
>   power: supplies: bq275xx: adds specific support for bq27520-g4
>     revision.
>   power: supplies: bq27xxx: adds device tree binding documentation.
> 
>  .../devicetree/bindings/power/supply/bq27xxx.txt   |  36 +++
>  drivers/power/supply/bq27xxx_battery.c             | 348 ++++++++++++++++++++-
>  drivers/power/supply/bq27xxx_battery_i2c.c         |  22 +-
>  include/linux/power/bq27xxx_battery.h              |  10 +-
>  4 files changed, 407 insertions(+), 9 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/bq27xxx.txt

Much better now! You can add my Acked-by.

-- 
Pali Rohár
pali.rohar@gmail.com

[toc] | [prev] | [next] | [standalone]


#1554892 — Re: [PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support

FromSebastian Reichel <sre@kernel.org>
Date2017-01-10 04:00 +0100
SubjectRe: [PATCH v3 00/11] power: supply: bq275xx: implement individual chip revision support
Message-ID<sXUPf-3V1-9@gated-at.bofh.it>
In reply to#1553993

[Multipart message — attachments visible in raw view] — view raw

Hi Chris,

On Mon, Jan 09, 2017 at 11:47:34AM +1100, Chris Lapa wrote:
> This patch series separates out support for each revision chip in
> the bq27500, bq27510 and bq27520 family. Each revision has enough
> register address changes to justify individual register mappings.
> 
> The series also cleans up the large overtemp if statement to
> improve readability and adds devicetree documentation for all
> the support bq27xxx series chips.
> 
> I had a chance to test the deprecated bq27500/10/20 support which still
> behaves the same. I also tested the new specific bq27510g3 support
> on a custom board I have here and it worked correctly.

I tried to queue the patches, but they do not apply on top of
power-supply's for-next branch [0]. I applied the first one, but
please do the rebasing work for the other patches and resend.
While being at it you can add the following to all patches:

Acked-by: Pali Rohár <pali.rohar@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>

Ah and last but not least: Please use the following as
patch subject prefix: "power: supply: bq27xxx:"

[0] https://git.kernel.org/cgit/linux/kernel/git/sre/linux-power-supply.git/?h=for-next

-- Sebastian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web