Skip to content

Commit

Permalink
power: add driver for TI bq2429x battery charger. TODO: Untested. Doe…
Browse files Browse the repository at this point in the history
…s not have poll() support.
  • Loading branch information
juniskane authored and gregory-nutt committed Aug 25, 2017
1 parent 1be5f0a commit cc1f7a6
Show file tree
Hide file tree
Showing 8 changed files with 1,652 additions and 6 deletions.
23 changes: 23 additions & 0 deletions drivers/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,25 @@ config BQ2425X
---help---
The BQ24250/BQ24251 are battery charger for lithium-ion batteries.

config BQ2429X
bool "BQ2429X Battery charger support"
default n
select I2C
select I2C_BQ2429X
depends on BATTERY_CHARGER
---help---
The BQ24296/BQ24297/BQ24296M are battery charger for lithium-ion batteries.

if BQ2429X

config DEBUG_BQ2429X
bool "BQ2429X Debug Features"
default n
---help---
Enable BQ2429X battery management debug features.

endif # BQ2429X

config BATTERY_GAUGE
bool "Battery Fuel Gauge support"
default n
Expand All @@ -312,6 +331,10 @@ config I2C_BQ2425X
bool
default y if BQ2425X

config I2C_BQ2429X
bool
default y if BQ2429X

config I2C_MAX1704X
bool
default y if MAX1704X
Expand Down
6 changes: 6 additions & 0 deletions drivers/power/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ ifeq ($(CONFIG_I2C_BQ2425X),y)
CSRCS += bq2425x.c
endif

# Add the BQ2429x I2C-based battery charger driver

ifeq ($(CONFIG_I2C_BQ2429X),y)
CSRCS += bq2429x.c
endif

endif

# Include power support in the build
Expand Down
14 changes: 12 additions & 2 deletions drivers/power/battery_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
FAR struct battery_charger_dev_s *dev = inode->i_private;
int ret;

/* Inforce mutually exclusive access to the battery driver */
/* Enforce mutually exclusive access to the battery driver */

ret = sem_wait(&dev->batsem);
if (ret < 0)
{
return -errno; /* Probably EINTR */
}

/* Procss the IOCTL command */
/* Process the IOCTL command */

ret = -EINVAL; /* Assume a bad argument */
switch (cmd)
Expand Down Expand Up @@ -239,6 +239,16 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
}
break;

case BATIOC_OPERATE:
{
FAR int *ptr = (FAR int *)((uintptr_t)arg);
if (ptr)
{
ret = dev->ops->operate(dev, (uintptr_t)arg);
}
}
break;

default:
_err("ERROR: Unrecognized cmd: %d\n", cmd);
ret = -ENOTTY;
Expand Down
17 changes: 16 additions & 1 deletion drivers/power/bq2425x.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static int bq2425x_online(struct battery_charger_dev_s *dev, bool *status);
static int bq2425x_voltage(struct battery_charger_dev_s *dev, int value);
static int bq2425x_current(struct battery_charger_dev_s *dev, int value);
static int bq2425x_input_current(struct battery_charger_dev_s *dev, int value);
static int bq2425x_operate(struct battery_charger_dev_s *dev, uintptr_t param);

/****************************************************************************
* Private Data
Expand All @@ -146,7 +147,8 @@ static const struct battery_charger_operations_s g_bq2425xops =
bq2425x_online,
bq2425x_voltage,
bq2425x_current,
bq2425x_input_current
bq2425x_input_current,
bq2425x_operate
};

/****************************************************************************
Expand Down Expand Up @@ -728,6 +730,19 @@ static int bq2425x_input_current(struct battery_charger_dev_s *dev, int value)
return OK;
}

/****************************************************************************
* Name: bq2425x_operate
*
* Description:
* Do miscellaneous battery ioctl()
*
****************************************************************************/

static int bq2425x_operate(struct battery_charger_dev_s *dev, uintptr_t param)
{
return -ENOSYS;
}

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down
Loading

0 comments on commit cc1f7a6

Please sign in to comment.