power/battery: Move the enumurate to the common place
so the userspace program can handle the different battery driver equally Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
b9d1fcb232
commit
77bc1d1bdf
@ -79,8 +79,8 @@ struct charger_dev_s
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int charger_get_status(FAR enum battery_charger_status_e *status);
|
||||
static int charger_get_health(FAR enum battery_charger_health_e *health);
|
||||
static int charger_get_status(FAR enum battery_status_e *status);
|
||||
static int charger_get_health(FAR enum battery_health_e *health);
|
||||
static int charger_online(FAR bool *online);
|
||||
static int charger_get_temptable(FAR struct battery_temp_table_s *table);
|
||||
static int charger_set_temptable(FAR struct battery_temp_table_s *table);
|
||||
@ -210,7 +210,7 @@ static int charger_therm2temp(int val)
|
||||
* Name: charger_get_status
|
||||
****************************************************************************/
|
||||
|
||||
static int charger_get_status(FAR enum battery_charger_status_e *status)
|
||||
static int charger_get_status(FAR enum battery_status_e *status)
|
||||
{
|
||||
uint8_t state;
|
||||
int ret;
|
||||
@ -269,7 +269,7 @@ static int charger_get_status(FAR enum battery_charger_status_e *status)
|
||||
* Name: charger_get_health
|
||||
****************************************************************************/
|
||||
|
||||
static int charger_get_health(FAR enum battery_charger_health_e *health)
|
||||
static int charger_get_health(FAR enum battery_health_e *health)
|
||||
{
|
||||
FAR struct pmic_gauge_s gauge;
|
||||
uint8_t state;
|
||||
@ -495,16 +495,16 @@ static int charger_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
case BATIOC_STATE:
|
||||
{
|
||||
FAR enum battery_charger_status_e *status =
|
||||
(FAR enum battery_charger_status_e *)(uintptr_t)arg;
|
||||
FAR enum battery_status_e *status =
|
||||
(FAR enum battery_status_e *)(uintptr_t)arg;
|
||||
ret = charger_get_status(status);
|
||||
}
|
||||
break;
|
||||
|
||||
case BATIOC_HEALTH:
|
||||
{
|
||||
FAR enum battery_charger_health_e *health =
|
||||
(FAR enum battery_charger_health_e *)(uintptr_t)arg;
|
||||
FAR enum battery_health_e *health =
|
||||
(FAR enum battery_health_e *)(uintptr_t)arg;
|
||||
ret = charger_get_health(health);
|
||||
}
|
||||
break;
|
||||
|
@ -111,7 +111,7 @@ static struct bat_gauge_dev_s g_gaugedev;
|
||||
* Name: gauge_get_status
|
||||
****************************************************************************/
|
||||
|
||||
static int gauge_get_status(FAR enum battery_gauge_status_e *status)
|
||||
static int gauge_get_status(FAR enum battery_status_e *status)
|
||||
{
|
||||
uint8_t state;
|
||||
int ret;
|
||||
@ -325,8 +325,8 @@ static int gauge_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
case BATIOC_STATE:
|
||||
{
|
||||
FAR enum battery_gauge_status_e *status =
|
||||
(FAR enum battery_gauge_status_e *)(uintptr_t)arg;
|
||||
FAR enum battery_status_e *status =
|
||||
(FAR enum battery_status_e *)(uintptr_t)arg;
|
||||
ret = gauge_get_status(status);
|
||||
}
|
||||
break;
|
||||
|
@ -61,10 +61,10 @@
|
||||
* lower half as summarized below:
|
||||
*
|
||||
* BATIOC_STATE - Return the current state of the battery (see
|
||||
* enum battery_charger_status_e).
|
||||
* enum battery_status_e).
|
||||
* Input value: A pointer to type int.
|
||||
* BATIOC_HEALTH - Return the current health of the battery (see
|
||||
* enum battery_charger_health_e).
|
||||
* enum battery_health_e).
|
||||
* Input value: A pointer to type int.
|
||||
* BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
|
||||
* Input value: A pointer to type bool.
|
||||
@ -79,54 +79,20 @@
|
||||
* batio_operate_msg_s.
|
||||
*/
|
||||
|
||||
/* Special input values for BATIOC_INPUT_CURRENT that may optionally
|
||||
* be supported by lower-half driver:
|
||||
*/
|
||||
|
||||
#define BATTERY_INPUT_CURRENT_EXT_LIM (-1) /* External input current limit */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Battery status */
|
||||
|
||||
enum battery_charger_status_e
|
||||
{
|
||||
BATTERY_UNKNOWN = 0, /* Battery state is not known */
|
||||
BATTERY_FAULT, /* Charger reported a fault, get health for more info */
|
||||
BATTERY_IDLE, /* Not full, not charging, not discharging */
|
||||
BATTERY_FULL, /* Full, not discharging */
|
||||
BATTERY_CHARGING, /* Not full, charging */
|
||||
BATTERY_DISCHARGING /* Probably not full, discharging */
|
||||
};
|
||||
|
||||
/* Battery Health status */
|
||||
|
||||
enum battery_charger_health_e
|
||||
{
|
||||
BATTERY_HEALTH_UNKNOWN = 0, /* Battery health state is not known */
|
||||
BATTERY_HEALTH_GOOD, /* Battery is in good condiction */
|
||||
BATTERY_HEALTH_DEAD, /* Battery is dead, nothing we can do */
|
||||
BATTERY_HEALTH_OVERHEAT, /* Battery is over recommended temperature */
|
||||
BATTERY_HEALTH_OVERVOLTAGE, /* Battery voltage is over recommended level */
|
||||
BATTERY_HEALTH_UNSPEC_FAIL, /* Battery charger reported an unspected failure */
|
||||
BATTERY_HEALTH_COLD, /* Battery is under recommended temperature */
|
||||
BATTERY_HEALTH_WD_TMR_EXP, /* Battery WatchDog Timer Expired */
|
||||
BATTERY_HEALTH_SAFE_TMR_EXP, /* Battery Safety Timer Expired */
|
||||
BATTERY_HEALTH_DISCONNECTED /* Battery is not connected */
|
||||
};
|
||||
|
||||
/* This structure defines the lower half battery interface */
|
||||
/* This structure defines the lower half battery interface */
|
||||
|
||||
struct battery_charger_dev_s;
|
||||
struct battery_charger_operations_s
|
||||
{
|
||||
/* Return the current battery state (see enum battery_charger_status_e) */
|
||||
/* Return the current battery state (see enum battery_status_e) */
|
||||
|
||||
int (*state)(struct battery_charger_dev_s *dev, int *status);
|
||||
|
||||
/* Return the current battery health (see enum battery_charger_health_e) */
|
||||
/* Return the current battery health (see enum battery_health_e) */
|
||||
|
||||
int (*health)(struct battery_charger_dev_s *dev, int *health);
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
||||
* lower half as summarized below:
|
||||
*
|
||||
* BATIOC_STATE - Return the current state of the battery (see
|
||||
* enum battery_gauge_status_e).
|
||||
* enum battery_status_e).
|
||||
* Input value: A pointer to type int.
|
||||
* BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
|
||||
* Input value: A pointer to type bool.
|
||||
@ -78,23 +78,12 @@
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Battery status */
|
||||
|
||||
enum battery_gauge_status_e
|
||||
{
|
||||
BATTERY_UNKNOWN = 0, /* Battery state is not known */
|
||||
BATTERY_IDLE, /* Not full, not charging, not discharging */
|
||||
BATTERY_FULL, /* Full, not discharging */
|
||||
BATTERY_CHARGING, /* Not full, charging */
|
||||
BATTERY_DISCHARGING /* Probably not full, discharging */
|
||||
};
|
||||
|
||||
/* This structure defines the lower half battery interface */
|
||||
|
||||
struct battery_gauge_dev_s;
|
||||
struct battery_gauge_operations_s
|
||||
{
|
||||
/* Return the current battery state (see enum battery_gauge_status_e) */
|
||||
/* Return the current battery state (see enum battery_status_e) */
|
||||
|
||||
int (*state)(struct battery_gauge_dev_s *dev, int *status);
|
||||
|
||||
|
@ -55,10 +55,49 @@
|
||||
#define BATIOC_CLEARFAULTS _BATIOC(0x000F)
|
||||
#define BATIOC_COULOMBS _BATIOC(0x0010)
|
||||
|
||||
/* Special input values for BATIOC_INPUT_CURRENT that may optionally
|
||||
* be supported by lower-half driver:
|
||||
*/
|
||||
|
||||
#define BATTERY_INPUT_CURRENT_EXT_LIM (-1) /* External input current limit */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Battery status */
|
||||
|
||||
enum battery_status_e
|
||||
{
|
||||
BATTERY_UNKNOWN = 0, /* Battery state is not known */
|
||||
BATTERY_FAULT, /* Charger reported a fault, get health for more info */
|
||||
BATTERY_IDLE, /* Not full, not charging, not discharging */
|
||||
BATTERY_FULL, /* Full, not discharging */
|
||||
BATTERY_CHARGING, /* Not full, charging */
|
||||
BATTERY_DISCHARGING /* Probably not full, discharging */
|
||||
};
|
||||
|
||||
/* Battery Health status */
|
||||
|
||||
enum battery_health_e
|
||||
{
|
||||
BATTERY_HEALTH_UNKNOWN = 0, /* Battery health state is not known */
|
||||
BATTERY_HEALTH_GOOD, /* Battery is in good condiction */
|
||||
BATTERY_HEALTH_DEAD, /* Battery is dead, nothing we can do */
|
||||
BATTERY_HEALTH_OVERHEAT, /* Battery is over recommended temperature */
|
||||
BATTERY_HEALTH_OVERVOLTAGE, /* Battery voltage is over recommended level */
|
||||
BATTERY_HEALTH_UNDERVOLTAGE, /* Battery monitor reported an unspecified failure */
|
||||
BATTERY_HEALTH_OVERCURRENT, /* Battery monitor reported an overcurrent event */
|
||||
BATTERY_HEALTH_SHORT_CIRCUIT, /* Battery monitor reported a short circuit event */
|
||||
BATTERY_HEALTH_UNSPEC_FAIL, /* Battery charger reported an unspected failure */
|
||||
BATTERY_HEALTH_COLD, /* Battery is under recommended temperature */
|
||||
BATTERY_HEALTH_WD_TMR_EXP, /* Battery WatchDog Timer Expired */
|
||||
BATTERY_HEALTH_SAFE_TMR_EXP, /* Battery Safety Timer Expired */
|
||||
BATTERY_HEALTH_DISCONNECTED /* Battery is not connected */
|
||||
};
|
||||
|
||||
/* Battery operation message */
|
||||
|
||||
struct batio_operate_msg_s
|
||||
{
|
||||
uint8_t operate_type; /* Really enum batio_operate_e */
|
||||
|
@ -62,10 +62,10 @@
|
||||
* lower half as summarized below:
|
||||
*
|
||||
* BATIOC_STATE - Return the current state of the battery (see
|
||||
* enum battery_monitor_status_e).
|
||||
* enum battery_status_e).
|
||||
* Input value: A pointer to type int.
|
||||
* BATIOC_HEALTH - Return the current health of the battery (see
|
||||
* enum battery_monitor_health_e).
|
||||
* enum battery_health_e).
|
||||
* Input value: A pointer to type int.
|
||||
* BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
|
||||
* Input value: A pointer to type bool.
|
||||
@ -101,46 +101,10 @@
|
||||
* batio_operate_msg_s.
|
||||
*/
|
||||
|
||||
/* Special input values for BATIOC_INPUT_CURRENT that may optionally
|
||||
* be supported by lower-half driver:
|
||||
*/
|
||||
|
||||
#define BATTERY_INPUT_CURRENT_EXT_LIM (-1) /* External input current limit */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Battery status */
|
||||
|
||||
enum battery_monitor_status_e
|
||||
{
|
||||
BATTERY_UNKNOWN = 0, /* Battery state is not known */
|
||||
BATTERY_FAULT, /* Charger reported a fault, get health for more info */
|
||||
BATTERY_IDLE, /* Not full, not charging, not discharging */
|
||||
BATTERY_FULL, /* Full, not discharging */
|
||||
BATTERY_CHARGING, /* Not full, charging */
|
||||
BATTERY_DISCHARGING /* Probably not full, discharging */
|
||||
};
|
||||
|
||||
/* Battery Health status */
|
||||
|
||||
enum battery_monitor_health_e
|
||||
{
|
||||
BATTERY_HEALTH_UNKNOWN = 0, /* Battery health state is not known */
|
||||
BATTERY_HEALTH_GOOD, /* Battery is in good condition */
|
||||
BATTERY_HEALTH_DEAD, /* Battery is dead, nothing we can do */
|
||||
BATTERY_HEALTH_OVERHEAT, /* Battery is over recommended temperature */
|
||||
BATTERY_HEALTH_OVERVOLTAGE, /* Battery voltage is over recommended level */
|
||||
BATTERY_HEALTH_UNDERVOLTAGE, /* Battery monitor reported an unspecified failure */
|
||||
BATTERY_HEALTH_OVERCURRENT, /* Battery monitor reported an overcurrent event */
|
||||
BATTERY_HEALTH_SHORT_CIRCUIT, /* Battery monitor reported a short circuit event */
|
||||
BATTERY_HEALTH_UNSPEC_FAIL, /* Battery monitor reported an unspecified failure */
|
||||
BATTERY_HEALTH_COLD, /* Battery is under recommended temperature */
|
||||
BATTERY_HEALTH_WD_TMR_EXP, /* Battery WatchDog Timer Expired */
|
||||
BATTERY_HEALTH_DISCONNECTED /* Battery is not connected */
|
||||
};
|
||||
|
||||
struct battery_monitor_voltage_s
|
||||
{
|
||||
/* Before call, contains the desired number of cells to read.
|
||||
@ -254,11 +218,11 @@ struct battery_monitor_dev_s;
|
||||
|
||||
struct battery_monitor_operations_s
|
||||
{
|
||||
/* Return the current battery state (see enum battery_monitor_status_e) */
|
||||
/* Return the current battery state (see enum battery_status_e) */
|
||||
|
||||
int (*state)(struct battery_monitor_dev_s *dev, int *status);
|
||||
|
||||
/* Return the current battery health (see enum battery_monitor_health_e) */
|
||||
/* Return the current battery health (see enum battery_health_e) */
|
||||
|
||||
int (*health)(struct battery_monitor_dev_s *dev, int *health);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user