Add support for DA9150 Fuel-Gauge
v4 cover Add support for DA9150 Fuel-Gauge
This patch set adds support for the Dialog DA9150 Fuel-Gauge.
In this patch set the following is provided:
- MFD Core and DT bindings updates.
- Power Supply Fuel-Gauge support and DT bindings documentation.
This patch set is baselined against the v4.2-rc5 kernel version.
Changes in v4:
- MFD, Power, DT: Update DT compatible & driver name strings for Fuel Gauge, in line with maintainers request.
- Power: Update Kconfig and Makefile to use BATTERY_* for config entry instead of FG_*. Also fuel-gauge module now depends on MFD not Charger.
- Power: Added helper function to simplify single attribute accesses using QIF interface of fuel-gauge.
- Power: Use of devm_* functions for IRQ and power_supply registration.
- Power: Added checking of result from platform_get_irq_byname().
Changes in v3:
- MFD: Some tidy up of code (gotos, dropped FG header, DEFINE_RES_IRQ_NAMED)
- MFD & Power: Drop use of callback function for temperature reading, as requested by Lee Jones.
- MFD (DT): Binding doc update to flesh out example text.
- MFD (DT): New patch to change MFD binding doc to use relative paths.
- MFD: New patch to use DEFINE_RES_IRQ_NAMED for all other IRQ resources.
Changes in v2:
- Moved temp callback function prototype to be part of power fuel-gauge patch, as requested by Lee Jones.
Adam Thomson (6):
mfd: da9150: Add support for Fuel-Gauge
mfd: da9150: Update DT bindings for Fuel-Gauge support
power: Add support for DA9150 Fuel-Gauge
power: da9150: Add DT bindings documentation for Fuel-Gauge
mfd: da9150: Use relative paths in DT bindings document
mfd: da9150: Use DEFINE_RES_IRQ_NAMED() help macro for IRQ resource
Documentation/devicetree/bindings/mfd/da9150.txt | 33 +- .../devicetree/bindings/power/da9150-fg.txt | 23 + drivers/mfd/da9150-core.c | 191 +++++-- drivers/power/Kconfig | 10 + drivers/power/Makefile | 1 + drivers/power/da9150-fg.c | 578 +++++++++++++++++++++ include/linux/mfd/da9150/core.h | 19 +- 7 files changed, 810 insertions(+), 45 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/da9150-fg.txt create mode 100644 drivers/power/da9150-fg.c
--
1.9.3
PATCH v4 1/6 mfd: da9150: Add support for Fuel-Gauge
---
Changes in v4:
- Update compatible string of fuel-gauge to "dlg, da9150-fuel-gauge". Also made similar change to driver name to keep things consistent.
Changes in v3:
- Use DEFINE_RES_IRQ_NAMED() helper for defining FG IRQ resource.
- Unwanted new line & comments removed.
- Remove gotos which can be replaced with straight forward return calls.
- Add enum for indexing MFD cells list, which is used to assign pdata for FG sub-device.
- Remove use of function pointers for QIF related read/write functions as currently only I2C supported, so call I2C functions directly.
- Fold fg.h contents into core.h.
Changes in v2:
- Moved temp callback function prototype to be part of power fuel-gauge patch, as requested by Lee Jones.
drivers/mfd/da9150-core.c | 156 ++++++++++++++++++++++++++++++++++++++-- include/linux/mfd/da9150/core.h | 19 ++++- 2 files changed, 167 insertions(+), 8 deletions(-)
drivers/mfd/da9150-core.c +149 -7
@@ -23,6 +23,77 @@#include <linux/mfd/da9150/core.h> #include <linux/mfd/da9150/registers.h> +/* Raw device access, used for QIF */ +static int da9150_i2c_read_device (struct i2c_client *client,u8 addr,int count, +u8 *buf) +{ +struct i2c_msg xfer; +int ret; + +/* +* Read is split into two transfers as device expects STOP/START rather +* than repeated start to carry out this kind of access. +*/ + +/* Write address */ + xfer.addr = client->addr; + xfer.flags =0 ; + xfer.len =1 ; + xfer.buf = &addr; + + ret =i2c_transfer (client->adapter, &xfer,1 ); +if (ret !=1 ) { +if (ret <0 ) +return ret; +else +return -EIO ; + } + +/* Read data */ + xfer.addr = client->addr; + xfer.flags =I2C_M_RD ; + xfer.len = count; + xfer.buf = buf; + + ret =i2c_transfer (client->adapter, &xfer,1 ); +if (ret ==1 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} + +static int da9150_i2c_write_device (struct i2c_client *client,u8 addr, +int count,const u8 *buf) +{ +struct i2c_msg xfer; +u8 *reg_data; +int ret; + + reg_data =kzalloc (1 + count,GFP_KERNEL ); +if (!reg_data) +return -ENOMEM ; + + reg_data[0 ] = addr; +memcpy (®_data[1 ], buf, count); + +/* Write address & data */ + xfer.addr = client->addr; + xfer.flags =0 ; + xfer.len =1 + count; + xfer.buf = reg_data; + + ret =i2c_transfer (client->adapter, &xfer,1 ); +kfree (reg_data); +if (ret ==1 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} +static bool da9150_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {
@@ -107,6 +178,28 @@ static const struct regmap_config da9150_regmap_config = { .volatile_reg = da9150_volatile_reg, }; +void da9150_read_qif (struct da9150 *da9150,u8 addr,int count,u8 *buf) +{ +int ret; + + ret =da9150_i2c_read_device (da9150->core_qif, addr, count, buf); +if (ret <0 ) +dev_err (da9150->dev,"Failed to read from QIF 0x%x: %d\n" , + addr, ret); +} +EXPORT_SYMBOL_GPL (da9150_read_qif); + +void da9150_write_qif (struct da9150 *da9150,u8 addr,int count,const u8 *buf) +{ +int ret; + + ret =da9150_i2c_write_device (da9150->core_qif, addr, count, buf); +if (ret <0 ) +dev_err (da9150->dev,"Failed to write to QIF 0x%x: %d\n" , + addr, ret); +} +EXPORT_SYMBOL_GPL (da9150_write_qif); +u8 da9150_reg_read (struct da9150 *da9150,u16 reg) {int val, ret;
@@ -297,19 +390,35 @@ static struct resource da9150_charger_resources[] = { }, }; +static struct resource da9150_fg_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_FG ,"FG" ), +}; + +enum da9150_dev_idx { +DA9150_GPADC_IDX =0 , +DA9150_CHARGER_IDX , +DA9150_FG_IDX , +}; +static struct mfd_cell da9150_devs[] = { - { + [DA9150_GPADC_IDX ] = { .name ="da9150-gpadc" , .of_compatible ="dlg,da9150-gpadc" , .resources = da9150_gpadc_resources, .num_resources =ARRAY_SIZE (da9150_gpadc_resources), }, - { + [DA9150_CHARGER_IDX ] = { .name ="da9150-charger" , .of_compatible ="dlg,da9150-charger" , .resources = da9150_charger_resources, .num_resources =ARRAY_SIZE (da9150_charger_resources), }, + [DA9150_FG_IDX ] = { + .name ="da9150-fuel-gauge" , + .of_compatible ="dlg,da9150-fuel-gauge" , + .resources = da9150_fg_resources, + .num_resources =ARRAY_SIZE (da9150_fg_resources), + }, }; static int da9150_probe(struct i2c_client *client,
@@ -317,6 +426,7 @@ static int da9150_probe(struct i2c_client *client, {struct da9150 *da9150;struct da9150_pdata *pdata =dev_get_platdata (&client->dev); +int qif_addr;int ret; da9150 =devm_kzalloc (&client->dev,sizeof (*da9150),GFP_KERNEL );
@@ -335,16 +445,41 @@ static int da9150_probe(struct i2c_client *client,return ret; } - da9150->irq_base = pdata ? pdata->irq_base :-1 ; +/* Setup secondary I2C interface for QIF access */ + qif_addr =da9150_reg_read (da9150,DA9150_CORE2WIRE_CTRL_A ); + qif_addr = (qif_addr &DA9150_CORE_BASE_ADDR_MASK ) >>1 ; + qif_addr |=DA9150_QIF_I2C_ADDR_LSB ; + da9150->core_qif =i2c_new_dummy (client->adapter, qif_addr); +if (!da9150->core_qif) { +dev_err (da9150->dev,"Failed to attach QIF client\n" ); +return -ENODEV ; + } + +i2c_set_clientdata (da9150->core_qif, da9150); + +if (pdata) { + da9150->irq_base = pdata->irq_base; + + da9150_devs[DA9150_FG_IDX ].platform_data = pdata->fg_pdata; + da9150_devs[DA9150_FG_IDX ].pdata_size = +sizeof (struct da9150_fg_pdata ); + }else { + da9150->irq_base =-1 ; + } ret =regmap_add_irq_chip (da9150->regmap, da9150->irq,IRQF_TRIGGER_LOW |IRQF_ONESHOT , da9150->irq_base, &da9150_regmap_irq_chip, &da9150->regmap_irq_data); -if (ret) -return ret; +if (ret) { +dev_err (da9150->dev,"Failed to add regmap irq chip: %d\n" , + ret); + goto regmap_irq_fail; + } + da9150->irq_base =regmap_irq_chip_get_base (da9150->regmap_irq_data); +enable_irq_wake (da9150->irq); ret = mfd_add_devices(da9150->dev, -1, da9150_devs,
@@ -352,11 +487,17 @@ static int da9150_probe(struct i2c_client *client, da9150->irq_base, NULL);if (ret) {dev_err (da9150->dev,"Failed to add child devices: %d\n" , ret); -regmap_del_irq_chip (da9150->irq, da9150->regmap_irq_data); -return ret; + goto mfd_fail; }return 0 ; + +mfd_fail: +regmap_del_irq_chip (da9150->irq, da9150->regmap_irq_data); +regmap_irq_fail: +i2c_unregister_device (da9150->core_qif); + +return ret; }static int da9150_remove (struct i2c_client *client)
@@ -365,6 +506,7 @@ static int da9150_remove(struct i2c_client *client)regmap_del_irq_chip (da9150->irq, da9150->regmap_irq_data);mfd_remove_devices (da9150->dev); +i2c_unregister_device (da9150->core_qif);return 0 ; }
include/linux/mfd/da9150/core.h +18 -1
@@ -15,6 +15,7 @@#define __DA9150_CORE_H#include <linux/device.h> +#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/regmap.h>
@@ -46,23 +47,39 @@#define DA9150_IRQ_GPADC 19#define DA9150_IRQ_WKUP 20 +/* I2C sub-device address */ +#define DA9150_QIF_I2C_ADDR_LSB 0x5 + +struct da9150_fg_pdata { +u32 update_interval;/* msecs */ +u8 warn_soc_lvl;/* % value */ +u8 crit_soc_lvl;/* % value */ +}; +struct da9150_pdata {int irq_base; +struct da9150_fg_pdata *fg_pdata; };struct da9150 {struct device *dev;struct regmap *regmap; +struct i2c_client *core_qif; +struct regmap_irq_chip_data *regmap_irq_data;int irq;int irq_base; }; -/* Device I/O */ +/* Device I/O - Query Interface for FG and standard register access */ +void da9150_read_qif (struct da9150 *da9150,u8 addr,int count,u8 *buf); +void da9150_write_qif (struct da9150 *da9150,u8 addr,int count,const u8 *buf); +u8 da9150_reg_read (struct da9150 *da9150,u16 reg);void da9150_reg_write (struct da9150 *da9150,u16 reg,u8 val);void da9150_set_bits (struct da9150 *da9150,u16 reg,u8 mask,u8 val);void da9150_bulk_read (struct da9150 *da9150,u16 reg,int count,u8 *buf);void da9150_bulk_write (struct da9150 *da9150,u16 reg,int count,const u8 *buf); +#endif /* __DA9150_CORE_H */
--
1.9.3
Re: [PATCH v4 1/6] mfd: da9150: Add support for Fuel-Gauge
Quoted 7 lines · Adam Thomson
Signed-off-by Adam Thomson <[email protected]>---
Changes in v4:
- Update compatible string of fuel-gauge to "dlg, da9150-fuel-gauge". Also made similar change to driver name to keep things consistent.
Quoted 9 lines
Changes in v3:
- UseDEFINE_RES_IRQ_NAMED()helper for defining FG IRQ resource.
- Unwanted new line & comments removed.
- Remove gotos which can be replaced with straight forward return calls.
- Add enum for indexing MFD cells list, which is used to assign pdata for FG sub-device.
- Remove use of function pointers for QIF related read/write functions as currently only I2C supported, so call I2C functions directly.
- Foldfg.hcontents intocore.h.
Assuming these have all been taken care of:
Quoted 291 lines
Changes in v2:
- Moved temp callback function prototype to be part of power fuel-gauge patch, as requested by Lee Jones.drivers/mfd/da9150-core.c | 156 ++++++++++++++++++++++++++++++++++++++-- include/linux/mfd/da9150/core.h | 19 ++++- 2 files changed, 167 insertions(+), 8 deletions(-)drivers/mfd/da9150-core.c +149
-7@@ -23,6 +23,77 @@#include <linux/mfd/da9150/core.h> #include <linux/mfd/da9150/registers.h> +/* Raw device access, used for QIF */ +static int da9150_i2c_read_device (struct i2c_client *client,u8 addr,int count, +u8 *buf) +{ +struct i2c_msg xfer; +int ret; + +/* +* Read is split into two transfers as device expects STOP/START rather +* than repeated start to carry out this kind of access. +*/ + +/* Write address */ + xfer.addr = client->addr; + xfer.flags =0 ; + xfer.len =1 ; + xfer.buf = &addr; + + ret =i2c_transfer (client->adapter, &xfer,1 ); +if (ret !=1 ) { +if (ret <0 ) +return ret; +else +return -EIO ; + } + +/* Read data */ + xfer.addr = client->addr; + xfer.flags =I2C_M_RD ; + xfer.len = count; + xfer.buf = buf; + + ret =i2c_transfer (client->adapter, &xfer,1 ); +if (ret ==1 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} + +static int da9150_i2c_write_device (struct i2c_client *client,u8 addr, +int count,const u8 *buf) +{ +struct i2c_msg xfer; +u8 *reg_data; +int ret; + + reg_data =kzalloc (1 + count,GFP_KERNEL ); +if (!reg_data) +return -ENOMEM ; + + reg_data[0 ] = addr; +memcpy (®_data[1 ], buf, count); + +/* Write address & data */ + xfer.addr = client->addr; + xfer.flags =0 ; + xfer.len =1 + count; + xfer.buf = reg_data; + + ret =i2c_transfer (client->adapter, &xfer,1 ); +kfree (reg_data); +if (ret ==1 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} +static bool da9150_volatile_reg (struct device *dev,unsigned int reg) {switch (reg) {@@ -107,6 +178,28 @@ static const struct regmap_config da9150_regmap_config = { .volatile_reg = da9150_volatile_reg, }; +void da9150_read_qif (struct da9150 *da9150,u8 addr,int count,u8 *buf) +{ +int ret; + + ret =da9150_i2c_read_device (da9150->core_qif, addr, count, buf); +if (ret <0 ) +dev_err (da9150->dev,"Failed to read from QIF 0x%x: %d\n" , + addr, ret); +} +EXPORT_SYMBOL_GPL (da9150_read_qif); + +void da9150_write_qif (struct da9150 *da9150,u8 addr,int count,const u8 *buf) +{ +int ret; + + ret =da9150_i2c_write_device (da9150->core_qif, addr, count, buf); +if (ret <0 ) +dev_err (da9150->dev,"Failed to write to QIF 0x%x: %d\n" , + addr, ret); +} +EXPORT_SYMBOL_GPL (da9150_write_qif); +u8 da9150_reg_read (struct da9150 *da9150,u16 reg) {int val, ret;@@ -297,19 +390,35 @@ static struct resource da9150_charger_resources[] = { }, }; +static struct resource da9150_fg_resources[] = { +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_FG ,"FG" ), +}; + +enum da9150_dev_idx { +DA9150_GPADC_IDX =0 , +DA9150_CHARGER_IDX , +DA9150_FG_IDX , +}; +static struct mfd_cell da9150_devs[] = { - { + [DA9150_GPADC_IDX ] = { .name ="da9150-gpadc" , .of_compatible ="dlg,da9150-gpadc" , .resources = da9150_gpadc_resources, .num_resources =ARRAY_SIZE (da9150_gpadc_resources), }, - { + [DA9150_CHARGER_IDX ] = { .name ="da9150-charger" , .of_compatible ="dlg,da9150-charger" , .resources = da9150_charger_resources, .num_resources =ARRAY_SIZE (da9150_charger_resources), }, + [DA9150_FG_IDX ] = { + .name ="da9150-fuel-gauge" , + .of_compatible ="dlg,da9150-fuel-gauge" , + .resources = da9150_fg_resources, + .num_resources =ARRAY_SIZE (da9150_fg_resources), + }, }; static int da9150_probe(struct i2c_client *client,@@ -317,6 +426,7 @@ static int da9150_probe(struct i2c_client *client, {struct da9150 *da9150;struct da9150_pdata *pdata =dev_get_platdata (&client->dev); +int qif_addr;int ret; da9150 =devm_kzalloc (&client->dev,sizeof (*da9150),GFP_KERNEL );@@ -335,16 +445,41 @@ static int da9150_probe(struct i2c_client *client,return ret; } - da9150->irq_base = pdata ? pdata->irq_base :-1 ; +/* Setup secondary I2C interface for QIF access */ + qif_addr =da9150_reg_read (da9150,DA9150_CORE2WIRE_CTRL_A ); + qif_addr = (qif_addr &DA9150_CORE_BASE_ADDR_MASK ) >>1 ; + qif_addr |=DA9150_QIF_I2C_ADDR_LSB ; + da9150->core_qif =i2c_new_dummy (client->adapter, qif_addr); +if (!da9150->core_qif) { +dev_err (da9150->dev,"Failed to attach QIF client\n" ); +return -ENODEV ; + } + +i2c_set_clientdata (da9150->core_qif, da9150); + +if (pdata) { + da9150->irq_base = pdata->irq_base; + + da9150_devs[DA9150_FG_IDX ].platform_data = pdata->fg_pdata; + da9150_devs[DA9150_FG_IDX ].pdata_size = +sizeof (struct da9150_fg_pdata ); + }else { + da9150->irq_base =-1 ; + } ret =regmap_add_irq_chip (da9150->regmap, da9150->irq,IRQF_TRIGGER_LOW |IRQF_ONESHOT , da9150->irq_base, &da9150_regmap_irq_chip, &da9150->regmap_irq_data); -if (ret) -return ret; +if (ret) { +dev_err (da9150->dev,"Failed to add regmap irq chip: %d\n" , + ret); + goto regmap_irq_fail; + } + da9150->irq_base =regmap_irq_chip_get_base (da9150->regmap_irq_data); +enable_irq_wake (da9150->irq); ret = mfd_add_devices(da9150->dev, -1, da9150_devs,@@ -352,11 +487,17 @@ static int da9150_probe(struct i2c_client *client, da9150->irq_base, NULL);if (ret) {dev_err (da9150->dev,"Failed to add child devices: %d\n" , ret); -regmap_del_irq_chip (da9150->irq, da9150->regmap_irq_data); -return ret; + goto mfd_fail; }return 0 ; + +mfd_fail: +regmap_del_irq_chip (da9150->irq, da9150->regmap_irq_data); +regmap_irq_fail: +i2c_unregister_device (da9150->core_qif); + +return ret; }static int da9150_remove (struct i2c_client *client)@@ -365,6 +506,7 @@ static int da9150_remove(struct i2c_client *client)regmap_del_irq_chip (da9150->irq, da9150->regmap_irq_data);mfd_remove_devices (da9150->dev); +i2c_unregister_device (da9150->core_qif);return 0 ; }include/linux/mfd/da9150/core.h +18
-1@@ -15,6 +15,7 @@#define __DA9150_CORE_H#include <linux/device.h> +#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/regmap.h> @@ -46,23 +47,39 @@#define DA9150_IRQ_GPADC 19#define DA9150_IRQ_WKUP 20 +/* I2C sub-device address */ +#define DA9150_QIF_I2C_ADDR_LSB 0x5 + +struct da9150_fg_pdata { +u32 update_interval;/* msecs */ +u8 warn_soc_lvl;/* % value */ +u8 crit_soc_lvl;/* % value */ +}; +struct da9150_pdata {int irq_base; +struct da9150_fg_pdata *fg_pdata; };struct da9150 {struct device *dev;struct regmap *regmap; +struct i2c_client *core_qif; +struct regmap_irq_chip_data *regmap_irq_data;int irq;int irq_base; }; -/* Device I/O */ +/* Device I/O - Query Interface for FG and standard register access */ +void da9150_read_qif (struct da9150 *da9150,u8 addr,int count,u8 *buf); +void da9150_write_qif (struct da9150 *da9150,u8 addr,int count,const u8 *buf); +u8 da9150_reg_read (struct da9150 *da9150,u16 reg);void da9150_reg_write (struct da9150 *da9150,u16 reg,u8 val);void da9150_set_bits (struct da9150 *da9150,u16 reg,u8 mask,u8 val);void da9150_bulk_read (struct da9150 *da9150,u16 reg,int count,u8 *buf);void da9150_bulk_write (struct da9150 *da9150,u16 reg,int count,const u8 *buf); +#endif /* __DA9150_CORE_H */
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
RE: [PATCH v4 1/6] mfd: da9150: Add support for Fuel-Gauge
Quoted 19 lines · Lee Jones
Quoted 7 lines · Adam Thomson
Signed-off-by Adam Thomson <[email protected]>---
Changes in v4:
- Update compatible string of fuel-gauge to "dlg, da9150-fuel-gauge". Also made similar change to driver name to keep things consistent.Quoted 9 lines
Changes in v3:
- UseDEFINE_RES_IRQ_NAMED()helper for defining FG IRQ resource.
- Unwanted new line & comments removed.
- Remove gotos which can be replaced with straight forward return calls.
- Add enum for indexing MFD cells list, which is used to assign pdata for FG sub-device.
- Remove use of function pointers for QIF related read/write functions as currently only I2C supported, so call I2C functions directly.
- Foldfg.hcontents intocore.h.
Quoted 4 lines
Assuming these have all been taken care of:
Acked-by Lee Jones <[email protected]>
Thanks for your time on this patch set.
PATCH v4 2/6 mfd: da9150: Update DT bindings for Fuel-Gauge support
In reply to Adam Thomson---
Changes in v4:
- Update compatible string of fuel-gauge to "da9150-fuel-gauge".
- Node name tidy up, relating to maintainer comments on fuel-gauge DT binding doc.
- Removed Ack to patch from Lee Jones, as this has now been modified slightly and didn't want to make assumptions of approval.
Changes in v3:
- Removal of unwanted new-line.
- Flesh out example bindings usage.
Changes in v2:
- N/A
Documentation/devicetree/bindings/mfd/da9150.txt | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/mfd/da9150.txt +23 -4
@@ -6,6 +6,7 @@ Device Description ------ ----------- da9150-gpadc : General Purpose ADC da9150-charger : Battery Charger +da9150-fg : Battery Fuel-Gauge ======
@@ -22,7 +23,7 @@ Required properties: Sub-devices: - da9150-gpadc: See Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt - da9150-charger: See Documentation/devicetree/bindings/power/da9150-charger.txt - +- da9150-fg: See Documentation/devicetree/bindings/power/da9150-fg.txt Example:
@@ -34,10 +35,28 @@ Example: interrupt-controller; gpadc: da9150-gpadc { - ... + compatible = "dlg,da9150-gpadc"; + #io-channel-cells = <1>; + }; + + charger { + compatible = "dlg,da9150-charger"; + + io-channels = <&gpadc 0>, + <&gpadc 2>, + <&gpadc 8>, + <&gpadc 5>; + io-channel-names = "CHAN_IBUS", + "CHAN_VBUS", + "CHAN_TJUNC", + "CHAN_VBAT"; }; - da9150-charger { - ... + fuel-gauge { + compatible = "dlg,da9150-fuel-gauge"; + + dlg,update-interval = <10000>; + dlg,warn-soc-level = /bits/ 8 <15>; + dlg,crit-soc-level = /bits/ 8 <5> }; };
--
1.9.3
Re: [PATCH v4 2/6] mfd: da9150: Update DT bindings for Fuel-Gauge support
Quoted 9 lines · Adam Thomson
Signed-off-by Adam Thomson <[email protected]>---
Changes in v4:
- Update compatible string of fuel-gauge to "da9150-fuel-gauge".
- Node name tidy up, relating to maintainer comments on fuel-gauge DT binding doc.
- Removed Ack to patch from Lee Jones, as this has now been modified slightly and didn't want to make assumptions of approval.
Seems okay:
Quoted 63 lines
Changes in v3:
- Removal of unwanted new-line.
- Flesh out example bindings usage.Changes in v2:
- N/ADocumentation/devicetree/bindings/mfd/da9150.txt | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/mfd/da9150.txt +23
-4@@ -6,6 +6,7 @@ Device Description ------ ----------- da9150-gpadc : General Purpose ADC da9150-charger : Battery Charger +da9150-fg : Battery Fuel-Gauge ======@@ -22,7 +23,7 @@ Required properties: Sub-devices: - da9150-gpadc: See Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt - da9150-charger: See Documentation/devicetree/bindings/power/da9150-charger.txt - +- da9150-fg: See Documentation/devicetree/bindings/power/da9150-fg.txt Example:@@ -34,10 +35,28 @@ Example: interrupt-controller; gpadc: da9150-gpadc { - ... + compatible = "dlg,da9150-gpadc"; + #io-channel-cells = <1>; + }; + + charger { + compatible = "dlg,da9150-charger"; + + io-channels = <&gpadc 0>, + <&gpadc 2>, + <&gpadc 8>, + <&gpadc 5>; + io-channel-names = "CHAN_IBUS", + "CHAN_VBUS", + "CHAN_TJUNC", + "CHAN_VBAT"; }; - da9150-charger { - ... + fuel-gauge { + compatible = "dlg,da9150-fuel-gauge"; + + dlg,update-interval = <10000>; + dlg,warn-soc-level = /bits/ 8 <15>; + dlg,crit-soc-level = /bits/ 8 <5> }; };
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v4 3/6 power: Add support for DA9150 Fuel-Gauge
In reply to Adam ThomsonThis adds power supply driver support for the Fuel-Gauge part of the DA9150 combined Charger and Fuel-Gauge device.
---
Changes in v4:
- Update compatible string of fuel-gauge to "dlg,da9150-fuel-gauge". Also updated driver name string to keep consistency.
- Update Kconfig and Makefile to use BATTERY_* for config entry instead of FG_*. Also fuel-gauge module now depends on MFD not Charger.
- Added helper function to simplify single attribute accesses using QIF interface of fuel-gauge.
- Use of devm_* functions for IRQ and power_supply registration.
- Added checking of result from platform_get_irq_byname().
Changes in v3:
- Removed use of temp callback function, at request of Lee Jones.
- Comment added to clarify limitation of temperature reading functionality that remains.
Changes in v2:
- Moved temp callback function prototype to be part of power fuel-gauge patch, rather than MFD, as requested by Lee Jones.
drivers/power/Kconfig | 10 + drivers/power/Makefile | 1 + drivers/power/da9150-fg.c | 578 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 589 insertions(+) create mode 100644 drivers/power/da9150-fg.c
drivers/power/Kconfig +10 -0
@@ -204,6 +204,16 @@ config CHARGER_DA9150 This driver can also be built as a module. If so, the module will be called da9150-charger. +config BATTERY_DA9150 + tristate "Dialog Semiconductor DA9150 Fuel Gauge support" + depends on MFD_DA9150 + help + Say Y here to enable support for the Fuel-Gauge unit of the DA9150 + Integrated Charger & Fuel-Gauge IC + + This driver can also be built as a module. If so, the module will be + called da9150-fg. + config AXP288_CHARGER tristate "X-Powers AXP288 Charger" depends on MFD_AXP20X && EXTCON_AXP288
drivers/power/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o +obj-$(CONFIG_BATTERY_DA9150) += da9150-fg.o obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
drivers/power/da9150-fg.c new file +578 -0
578 lines not on this page · raw message
--
1.9.3
RE: [PATCH v4 3/6] power: Add support for DA9150 Fuel-Gauge
Quoted 5 lines · Adam Thomson
This adds power supply driver support for the Fuel-Gauge part of the DA9150 combined Charger and Fuel-Gauge device.
Signed-off-by Adam Thomson <[email protected]>---
Hi Sebastian,
Just wondered when you might be able to review the power-supply parts of this patch? Lee has Acked the MFD patches, so it's just these left.
Thanks
Adam
PATCH v4 4/6 power: da9150: Add DT bindings documentation for Fuel-Gauge
In reply to Adam Thomson---
Changes in v4:
- Update compatible string of fuel-gauge to "dlg,da9150-fuel-gauge".
- Changed example node name to "fuel-gauge".
Changes in v3:
- N/A
Changes in v2:
- N/A
.../devicetree/bindings/power/da9150-fg.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/da9150-fg.txt
Documentation/devicetree/bindings/power/da9150-fg.txt new file +23 -0
@@ -0,0 +1,23 @@ +Dialog Semiconductor DA9150 Fuel-Gauge Power Supply bindings + +Required properties: +- compatible: "dlg,da9150-fuel-gauge" for DA9150 Fuel-Gauge Power Supply + +Optional properties: +- dlg,update-interval: Interval time (milliseconds) between battery level checks. +- dlg,warn-soc-level: Battery discharge level (%) where warning event raised. + [1 - 100] +- dlg,crit-soc-level: Battery discharge level (%) where critical event raised. + This value should be lower than the warning level. + [1 - 100] + + +Example: + + fuel-gauge { + compatible = "dlg,da9150-fuel-gauge"; + + dlg,update-interval = <10000>; + dlg,warn-soc-level = /bits/ 8 <15>; + dlg,crit-soc-level = /bits/ 8 <5>; + };
--
1.9.3
PATCH v4 5/6 mfd: da9150: Use relative paths in DT bindings document
In reply to Adam ThomsonWhen referencing other DT bindings documentation, use relative path rather than absolute.
---
Changes in v4:
- N/A
Changes in v3:
- Initial version.
Changes in v2:
- N/A
Documentation/devicetree/bindings/mfd/da9150.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/mfd/da9150.txt +4 -4
@@ -17,13 +17,13 @@ Required properties: the IRQs from da9150 are delivered to. - interrupts: IRQ line info for da9150 chip. - interrupt-controller: da9150 has internal IRQs (own IRQ domain). - (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for + (See ../interrupt-controller/interrupts.txt for further information relating to interrupt properties) Sub-devices: -- da9150-gpadc: See Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt -- da9150-charger: See Documentation/devicetree/bindings/power/da9150-charger.txt -- da9150-fg: See Documentation/devicetree/bindings/power/da9150-fg.txt +- da9150-gpadc: See ../iio/adc/da9150-gpadc.txt +- da9150-charger: See ../power/da9150-charger.txt +- da9150-fg: See ../power/da9150-fg.txt Example:
--
1.9.3
Re: [PATCH v4 5/6] mfd: da9150: Use relative paths in DT bindings document
Quoted 9 lines · Adam Thomson
When referencing other DT bindings documentation, use relative path rather than absolute.
Signed-off-by Adam Thomson <[email protected]>---
Changes in v4:
- N/A
Quoted 8 lines
Changes in v3:
- Initial version.Changes in v2:
- N/ADocumentation/devicetree/bindings/mfd/da9150.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Much better:
Quoted 22 lines
Documentation/devicetree/bindings/mfd/da9150.txt +4
-4@@ -17,13 +17,13 @@ Required properties: the IRQs from da9150 are delivered to. - interrupts: IRQ line info for da9150 chip. - interrupt-controller: da9150 has internal IRQs (own IRQ domain). - (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for + (See ../interrupt-controller/interrupts.txt for further information relating to interrupt properties) Sub-devices: -- da9150-gpadc: See Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt -- da9150-charger: See Documentation/devicetree/bindings/power/da9150-charger.txt -- da9150-fg: See Documentation/devicetree/bindings/power/da9150-fg.txt +- da9150-gpadc: See ../iio/adc/da9150-gpadc.txt +- da9150-charger: See ../power/da9150-charger.txt +- da9150-fg: See ../power/da9150-fg.txt Example:
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v4 6/6 mfd: da9150: Use DEFINE_RES_IRQ_NAMED() help macro for IRQ resource
In reply to Adam Thomson---
Changes in v4:
- N/A
Changes in v3:
- Initial version.
Changes in v2:
- N/A
drivers/mfd/da9150-core.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-)
drivers/mfd/da9150-core.c +5 -30
@@ -355,39 +355,14 @@ static const struct regmap_irq_chip da9150_regmap_irq_chip = { };static struct resource da9150_gpadc_resources[] = { - { - .name ="GPADC" , - .start =DA9150_IRQ_GPADC , - .end =DA9150_IRQ_GPADC , - .flags =IORESOURCE_IRQ , - }, +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_GPADC ,"GPADC" ), };static struct resource da9150_charger_resources[] = { - { - .name ="CHG_STATUS" , - .start =DA9150_IRQ_CHG , - .end =DA9150_IRQ_CHG , - .flags =IORESOURCE_IRQ , - }, - { - .name ="CHG_TJUNC" , - .start =DA9150_IRQ_TJUNC , - .end =DA9150_IRQ_TJUNC , - .flags =IORESOURCE_IRQ , - }, - { - .name ="CHG_VFAULT" , - .start =DA9150_IRQ_VFAULT , - .end =DA9150_IRQ_VFAULT , - .flags =IORESOURCE_IRQ , - }, - { - .name ="CHG_VBUS" , - .start =DA9150_IRQ_VBUS , - .end =DA9150_IRQ_VBUS , - .flags =IORESOURCE_IRQ , - }, +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_CHG ,"CHG_STATUS" ), +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_TJUNC ,"CHG_TJUNC" ), +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_VFAULT ,"CHG_VFAULT" ), +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_VBUS ,"CHG_VBUS" ), };static struct resource da9150_fg_resources[] = {
--
1.9.3
Re: [PATCH v4 6/6] mfd: da9150: Use DEFINE_RES_IRQ_NAMED() help macro for IRQ resource
Quoted 6 lines · Adam Thomson
Signed-off-by Adam Thomson <[email protected]>---
Changes in v4:
- N/A
Quoted 8 lines
Changes in v3:
- Initial version.Changes in v2:
- N/Adrivers/mfd/da9150-core.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-)
Perhaps a Suggested-by for this and the relative paths patch wouldn't go amiss, but it's not a show stopper.
Quoted 49 lines
drivers/mfd/da9150-core.c +5
-30@@ -355,39 +355,14 @@ static const struct regmap_irq_chip da9150_regmap_irq_chip = { };static struct resource da9150_gpadc_resources[] = { - { - .name ="GPADC" , - .start =DA9150_IRQ_GPADC , - .end =DA9150_IRQ_GPADC , - .flags =IORESOURCE_IRQ , - }, +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_GPADC ,"GPADC" ), };static struct resource da9150_charger_resources[] = { - { - .name ="CHG_STATUS" , - .start =DA9150_IRQ_CHG , - .end =DA9150_IRQ_CHG , - .flags =IORESOURCE_IRQ , - }, - { - .name ="CHG_TJUNC" , - .start =DA9150_IRQ_TJUNC , - .end =DA9150_IRQ_TJUNC , - .flags =IORESOURCE_IRQ , - }, - { - .name ="CHG_VFAULT" , - .start =DA9150_IRQ_VFAULT , - .end =DA9150_IRQ_VFAULT , - .flags =IORESOURCE_IRQ , - }, - { - .name ="CHG_VBUS" , - .start =DA9150_IRQ_VBUS , - .end =DA9150_IRQ_VBUS , - .flags =IORESOURCE_IRQ , - }, +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_CHG ,"CHG_STATUS" ), +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_TJUNC ,"CHG_TJUNC" ), +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_VFAULT ,"CHG_VFAULT" ), +DEFINE_RES_IRQ_NAMED (DA9150_IRQ_VBUS ,"CHG_VBUS" ), };static struct resource da9150_fg_resources[] = {
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog