diff --git a/drivers/power/battery/battery_gauge.c b/drivers/power/battery/battery_gauge.c index 498654a404..442e29f133 100644 --- a/drivers/power/battery/battery_gauge.c +++ b/drivers/power/battery/battery_gauge.c @@ -354,6 +354,16 @@ static int bat_gauge_ioctl(FAR struct file *filep, } break; + case BATIOC_OPERATE: + { + FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) + { + ret = dev->ops->operate(dev, ptr); + } + } + break; + default: _err("ERROR: Unrecognized cmd: %d\n", cmd); ret = -ENOTTY; diff --git a/include/nuttx/power/battery_gauge.h b/include/nuttx/power/battery_gauge.h index e0d9db905e..ee5a62d267 100644 --- a/include/nuttx/power/battery_gauge.h +++ b/include/nuttx/power/battery_gauge.h @@ -120,6 +120,10 @@ struct battery_gauge_operations_s CODE int (*chipid)(FAR struct battery_gauge_dev_s *dev, FAR unsigned int *value); + + /* Do device specific operation */ + + CODE int (*operate)(FAR struct battery_gauge_dev_s *dev, FAR int *param); }; /* This structure defines the battery driver state structure */ diff --git a/include/nuttx/power/battery_ioctl.h b/include/nuttx/power/battery_ioctl.h index 45dc694daa..0d9f71005e 100644 --- a/include/nuttx/power/battery_ioctl.h +++ b/include/nuttx/power/battery_ioctl.h @@ -146,6 +146,8 @@ enum batio_operate_e BATIO_OPRTN_WDOG, BATIO_OPRTN_SHIPMODE, BATIO_OPRTN_CUTOFF_CURRENT, + BATIO_OPRTN_VBUS_STATE, + BATIO_OPRTN_CAPACITY, BATIO_OPRTN_END };