Skip to contentSkip to conversation

X-Power AXP288 PMIC Fuel Gauge Driver

PATCH In review Todd Brandt 3 participants 8 messages Feb 5, 2015 – Mar 10, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v4 cover X-Power AXP288 PMIC Fuel Gauge Driver

New power_supply driver at driver/power which interfaces with the axp20x mfd driver as a cell. Provides battery info, monitors for changes, and generates alerts on temperature and capacity issues

Sebestian, please review the patch set and consider it for 3.20 rc1. I've applied it over git.infradead.org/battery-2.6.git/master and verified that it works. Thanks.

Todd Brandt (3):
mfd/axp20x: change battery cell name to fuel gauge mfd/axp20x: add support for fuel gauge cell X-Power AXP288 PMIC Fuel Gauge Driver

v1: 01/07/15
v2: 01/22/15
- replaced the const in axp20x_acpi_match declaration
- reformatted the commit text
- added IIO as driver dependency
- moved debug info to debugfs in file fuelgauge
- added HEALTH_COLD value to health calculation
- added better cleanup to remove call
cancelling any delayed work calls
unregistration of the power_supply
v3: 01/28/15
- moved debugs create and init config regs after error case
- freed the virqs in the remove function
- remove .owner field as it is populated automatically
v4: 02/04/15
- re-applied to Sebastian Reichel's repo git.infradead.org/battery-2.6.git

 drivers/mfd/axp20x.c              |    8 +-
 drivers/power/Kconfig             |    9 +
 drivers/power/Makefile            |    1 +
 drivers/power/axp288_fuel_gauge.c | 1151 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h        |   43 +-
 5 files changed, 1206 insertions(+), 6 deletions(-)
 create mode 100644 drivers/power/axp288_fuel_gauge.c
Signature · 1 line
2.1.0
#1 lore raw

PATCH v4 1/3 mfd/axp20x: change battery cell name to fuel gauge

Name changes to the battery cell structure to a more generic cell type: fuel gauge.

---
 drivers/mfd/axp20x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

v1: 01/07/14
v2: 01/22/14
- replaced the const in axp20x_acpi_match declaration
v4: same as v2-3

drivers/mfd/axp20x.c +4 -4
index b1b580a..0acbe52 100644
@@ -87,7 +87,7 @@ static struct resource axp20x_pek_resources[] = {
 	},
 };
 
-static struct resource axp288_battery_resources[] = {
+static struct resource axp288_fuel_gauge_resources[] = {
 	{
 		.start = AXP288_IRQ_QWBTU,
 		.end   = AXP288_IRQ_QWBTU,
@@ -350,9 +350,9 @@ static struct mfd_cell axp288_cells[] = {
 		.resources = axp288_charger_resources,
 	},
 	{
-		.name = "axp288_battery",
-		.num_resources = ARRAY_SIZE(axp288_battery_resources),
-		.resources = axp288_battery_resources,
+		.name = "axp288_fuel_gauge",
+		.num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
+		.resources = axp288_fuel_gauge_resources,
 	},
 	{
 		.name = "axp288_pmic_acpi",
Signature · 1 line
2.1.0
#2 lore raw

PATCH v4 2/3 mfd/axp20x: add support for fuel gauge cell

In reply to Todd Brandt

Register definitions and platform data structure
for fuel gauge cell devices.

---
 include/linux/mfd/axp20x.h | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

v4: same as v1-3 and is already accepted, re-included for continuity

include/linux/mfd/axp20x.h +41 -2
index 81589d1..dfabd6d 100644
@@ -124,10 +124,27 @@ enum {
 #define AXP288_PMIC_ADC_H               0x56
 #define AXP288_PMIC_ADC_L               0x57
 #define AXP288_ADC_TS_PIN_CTRL          0x84
-
 #define AXP288_PMIC_ADC_EN              0x84
-#define AXP288_FG_TUNE5			0xed
 
+/* Fuel Gauge */
+#define AXP288_FG_RDC1_REG          0xba
+#define AXP288_FG_RDC0_REG          0xbb
+#define AXP288_FG_OCVH_REG          0xbc
+#define AXP288_FG_OCVL_REG          0xbd
+#define AXP288_FG_OCV_CURVE_REG     0xc0
+#define AXP288_FG_DES_CAP1_REG      0xe0
+#define AXP288_FG_DES_CAP0_REG      0xe1
+#define AXP288_FG_CC_MTR1_REG       0xe2
+#define AXP288_FG_CC_MTR0_REG       0xe3
+#define AXP288_FG_OCV_CAP_REG       0xe4
+#define AXP288_FG_CC_CAP_REG        0xe5
+#define AXP288_FG_LOW_CAP_REG       0xe6
+#define AXP288_FG_TUNE0             0xe8
+#define AXP288_FG_TUNE1             0xe9
+#define AXP288_FG_TUNE2             0xea
+#define AXP288_FG_TUNE3             0xeb
+#define AXP288_FG_TUNE4             0xec
+#define AXP288_FG_TUNE5             0xed
 
 /* Regulators IDs */
 enum {
@@ -236,4 +253,26 @@ struct axp20x_dev {
 	const struct regmap_irq_chip	*regmap_irq_chip;
 };
 
+#define BATTID_LEN				64
+#define OCV_CURVE_SIZE			32
+#define MAX_THERM_CURVE_SIZE	25
+#define PD_DEF_MIN_TEMP			0
+#define PD_DEF_MAX_TEMP			55
+
+struct axp20x_fg_pdata {
+	char battid[BATTID_LEN + 1];
+	int design_cap;
+	int min_volt;
+	int max_volt;
+	int max_temp;
+	int min_temp;
+	int cap1;
+	int cap0;
+	int rdc1;
+	int rdc0;
+	int ocv_curve[OCV_CURVE_SIZE];
+	int tcsz;
+	int thermistor_curve[MAX_THERM_CURVE_SIZE][2];
+};
+
 #endif /* __LINUX_MFD_AXP20X_H */
Signature · 1 line
2.1.0
#3 lore raw

PATCH v4 3/3 X-Power AXP288 PMIC Fuel Gauge Driver

In reply to Todd Brandt

New power_supply driver at driver/power which interfaces with the axp20x mfd driver as a cell. Provides battery info, monitors for changes, and generates alerts on temperature and capacity issues

---
 drivers/power/Kconfig             |    9 +
 drivers/power/Makefile            |    1 +
 drivers/power/axp288_fuel_gauge.c | 1151 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1161 insertions(+)
 create mode 100644 drivers/power/axp288_fuel_gauge.c

v1: 01/07/14
v2: 01/22/14
- reformatted the commit text
- added IIO as driver dependency
- moved debug info to debugfs in file fuelgauge
- added HEALTH_COLD value to health calculation
- added better cleanup to remove call
cancelling any delayed work calls
unregistration of the power_supply
v3: 01/28/14
- moved debugs create and init config regs after error case
- freed the virqs in the remove function
- remove .owner field as it is populated automatically
v4: 02/04/15
- re-applied to Sebastian Reichel's repo git.infradead.org/battery-2.6.git

drivers/power/Kconfig +9 -0
index 27b751b..1a3d892 100644
@@ -192,6 +192,15 @@ config BATTERY_DA9052
 	  Say Y here to enable support for batteries charger integrated into
 	  DA9052 PMIC.
 
+config AXP288_FUEL_GAUGE
+	tristate "X-Powers AXP288 Fuel Gauge"
+	depends on MFD_AXP20X && IIO
+	help
+	  Say yes here to have support for X-Power power management IC (PMIC)
+	  Fuel Gauge. The device provides battery statistics and status
+	  monitoring as well as alerts for battery over/under voltage and
+	  over/under temperature.
+
 config BATTERY_MAX17040
 	tristate "Maxim MAX17040 Fuel Gauge"
 	depends on I2C
drivers/power/Makefile +1 -0
index 36f9e0d..57ce861 100644
@@ -62,3 +62,4 @@ obj-$(CONFIG_POWER_AVS)		+= avs/
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090)	+= tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)	+= reset/
+obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o
drivers/power/axp288_fuel_gauge.c new file +1151 -0

1,151 lines not on this page · raw message

Signature · 1 line
2.1.0
#4 lore raw
In reply to Todd Brandt

Hi,

Quoted 7 lines · Todd Brandt

New power_supply driver at driver/power which interfaces with the axp20x mfd driver as a cell. Provides battery info, monitors for changes, and generates alerts on temperature and capacity issues

Sebestian, please review the patch set and consider it for 3.20 rc1. I've applied it over git.infradead.org/battery-2.6.git/master and verified that it works. Thanks.

Lee, are you ok with patches 1+2 going through power supply subsystem?

-- Sebastian

#5 lore raw
Quoted 7 lines · Sebastian Reichel

Hi,

Quoted 4 lines · Todd Brandt

New power_supply driver at driver/power which interfaces with the axp20x mfd driver as a cell. Provides battery info, monitors for changes, and generates alerts on temperature and capacity issues

Quoted 6 lines
Quoted 3 lines

Sebestian, please review the patch set and consider it for 3.20 rc1. I've applied it over git.infradead.org/battery-2.6.git/master and verified that it works. Thanks.

Lee, are you ok with patches 1+2 going through power supply subsystem?

Yeah, go for it.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw
In reply to Todd Brandt

Hi,

Quoted 4 lines · Todd Brandt

New power_supply driver at driver/power which interfaces with the axp20x mfd driver as a cell. Provides battery info, monitors for changes, and generates alerts on temperature and capacity issues

Quoted 8 lines

Sebestian, please review the patch set and consider it for 3.20 rc1. I've applied it over git.infradead.org/battery-2.6.git/master and verified that it works. Thanks.

Todd Brandt (3):
mfd/axp20x: change battery cell name to fuel gauge mfd/axp20x: add support for fuel gauge cell X-Power AXP288 PMIC Fuel Gauge Driver

Thanks, queued for 4.1:

http://git.infradead.org/battery-2.6.git/commit/5a5bf49088f4c92f36786a2e4c20e17f715f0827

-- Sebastian

#7 lore raw
Quoted 16 lines · Sebastian Reichel

Hi,

Quoted 4 lines · Todd Brandt

New power_supply driver at driver/power which interfaces with the axp20x mfd driver as a cell. Provides battery info, monitors for changes, and generates alerts on temperature and capacity issues

Quoted 8 lines

Sebestian, please review the patch set and consider it for 3.20 rc1. I've applied it over git.infradead.org/battery-2.6.git/master and verified that it works. Thanks.

Todd Brandt (3):
mfd/axp20x: change battery cell name to fuel gauge mfd/axp20x: add support for fuel gauge cell X-Power AXP288 PMIC Fuel Gauge Driver

Quoted 5 lines

Thanks, queued for 4.1:

http://git.infradead.org/battery-2.6.git/commit/5a5bf49088f4c92f36786a2e4c20e17f715f0827

-- Sebastian

Excellent, thanks! Also, I should also mention that Ramakrishna Pallala was the author of the original draft of the XPower fuel gauge driver. I ported and tested it for upstream use. He can also serve as a maintainer.