1
0
Fork 0

bq27441: Driver in kernel

Used to be an out-of-tree module
eirik/updates-from-linux-fsl
Lars Ivar Miljeteig 2018-06-19 14:09:15 +02:00 committed by Eirik Schultz
parent 71016330f2
commit c540d1d16a
No known key found for this signature in database
GPG Key ID: CA85F5BFB83767F3
8 changed files with 1321 additions and 0 deletions

View File

@ -146,6 +146,8 @@ CONFIG_SPI=y
CONFIG_GPIO_SYSFS=y
CONFIG_POWER_SUPPLY=y
CONFIG_BATTERY_BQ27XXX=y
CONFIG_BATTERY_BQ27XXX_I2C=y
CONFIG_BATTERY_BQ27441_ZEROGRAVITAS=y
CONFIG_CHARGER_GPIO=y
CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_SYSCON=y

View File

@ -178,6 +178,14 @@ config BATTERY_BQ27XXX_I2C
Say Y here to enable support for batteries with BQ27xxx chips
connected over an I2C bus.
config BATTERY_BQ27441_ZEROGRAVITAS
tristate "BQ27441 support for zero-gravitas"
depends on BATTERY_BQ27XXX_I2C
default n
help
Say Y here to enable support for the bq27441 fuel gauge driver
for zero-gravitas
config BATTERY_DA9030
tristate "DA9030 battery driver"
depends on PMIC_DA903X

View File

@ -33,6 +33,7 @@ obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o
obj-$(CONFIG_BATTERY_BQ27XXX) += bq27xxx_battery.o
obj-$(CONFIG_BATTERY_BQ27XXX_I2C) += bq27xxx_battery_i2c.o
obj-$(CONFIG_BATTERY_BQ27441_ZEROGRAVITAS) += bq27441_battery.o
obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o
obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o

File diff suppressed because it is too large Load Diff

View File

@ -51,6 +51,10 @@
#include <linux/power/bq27xxx_battery.h>
#ifdef CONFIG_BATTERY_BQ27441_ZEROGRAVITAS
#include <linux/power/bq27441_battery.h>
#endif
#define DRIVER_VERSION "1.2.0"
#define BQ27XXX_MANUFACTURER "Texas Instruments"
@ -1037,6 +1041,10 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION);
#ifdef CONFIG_BATTERY_BQ27441_ZEROGRAVITAS
bq27441_init(di);
#endif
bq27xxx_battery_update(di);
mutex_lock(&bq27xxx_list_lock);
@ -1141,6 +1149,10 @@ static int bq27xxx_battery_platform_remove(struct platform_device *pdev)
{
struct bq27xxx_device_info *di = platform_get_drvdata(pdev);
#ifdef CONFIG_BATTERY_BQ27441_ZEROGRAVITAS
bq27441_exit(di);
#endif
bq27xxx_battery_teardown(di);
return 0;

View File

@ -18,6 +18,8 @@
#include <linux/interrupt.h>
#include <linux/module.h>
#include <asm/unaligned.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/power/bq27xxx_battery.h>
@ -33,6 +35,31 @@ static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
return IRQ_HANDLED;
}
static int bq27xxx_battery_i2c_write(struct bq27xxx_device_info *di, u8 reg,
const u8 *data, size_t len)
{
struct i2c_client *client = to_i2c_client(di->dev);
int ret;
unsigned char *buf;
if (!client->adapter)
return -ENODEV;
buf = kzalloc(len + sizeof(reg), GFP_KERNEL);
if (!buf)
return -ENOMEM;
buf[0] = reg;
memcpy (&buf[1], data, len);
ret = i2c_master_send(client, buf, len + sizeof(reg));
kfree(buf);
return ret;
}
static int bq27xxx_battery_i2c_read(struct bq27xxx_device_info *di, u8 reg,
bool single)
{
@ -96,6 +123,7 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
di->chip = id->driver_data;
di->name = name;
di->bus.read = bq27xxx_battery_i2c_read;
di->bus.write = bq27xxx_battery_i2c_write;
ret = bq27xxx_battery_setup(di);
if (ret)

View File

@ -0,0 +1,7 @@
#ifndef _BQ27441_BATTERY_H
#define _BQ27441_BATTERY_H
int bq27441_init(struct bq27xxx_device_info *di);
int bq27441_exit(struct bq27xxx_device_info *di);
#endif /* _BQ27441_BATTERY_H */

View File

@ -32,6 +32,7 @@ struct bq27xxx_platform_data {
struct bq27xxx_device_info;
struct bq27xxx_access_methods {
int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
int (*write)(struct bq27xxx_device_info *di, u8 reg, const u8 *data, size_t len);
};
struct bq27xxx_reg_cache {
@ -48,6 +49,8 @@ struct bq27xxx_reg_cache {
int health;
};
struct dentry;
struct bq27xxx_device_info {
struct device *dev;
int id;
@ -62,6 +65,7 @@ struct bq27xxx_device_info {
struct list_head list;
struct mutex lock;
u8 *regs;
struct dentry *dfs_dir;
};
void bq27xxx_battery_update(struct bq27xxx_device_info *di);