123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- #ifndef __INCLUDE_POWER_SUPPLY_H__
- #define __INCLUDE_POWER_SUPPLY_H__
- #include <stdint.h>
- #include <device.h>
- #include <board_cfg.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BATTERY_CAPCTR_STA_PASSED (1)
- #define BATTERY_CAPCTR_STA_FAILED (0)
- #define BATTERY_CAPCTR_DISABLE (0)
- #define BATTERY_CAPCTR_ENABLE (1)
- enum power_supply_status{
-
- POWER_SUPPLY_STATUS_UNKNOWN = 0,
-
- POWER_SUPPLY_STATUS_BAT_NOTEXIST,
-
- POWER_SUPPLY_STATUS_DISCHARGE,
-
- POWER_SUPPLY_STATUS_CHARGING,
-
- POWER_SUPPLY_STATUS_FULL,
-
- POWER_SUPPLY_STATUS_DC5V_OUT,
-
- POWER_SUPPLY_STATUS_DC5V_IN,
-
- POWER_SUPPLY_STATUS_DC5V_PENDING,
-
- POWER_SUPPLY_STATUS_DC5V_STANDBY,
-
- POWER_SUPPLY_STATUS_BAT_ERROR,
-
- POWER_SUPPLY_STATUS_BAT_LOWPOWER
- };
- enum power_supply_property {
-
- POWER_SUPPLY_PROP_STATUS = 0,
-
- POWER_SUPPLY_PROP_ONLINE,
-
- POWER_SUPPLY_PROP_VOLTAGE_NOW,
-
- POWER_SUPPLY_PROP_CAPACITY,
-
- POWER_SUPPLY_PROP_DC5V,
-
- POWER_SUPPLY_PROP_DC5V_STATUS,
-
- POWER_SUPPLY_PROP_DC5V_VOLTAGE,
-
- POWER_SUPPLY_SET_PROP_FEATURE,
-
- POWER_SUPPLY_SET_DC5V_PULLDOWM,
-
- POWER_SUPPLY_WAKE_CHARGER_BOX,
-
- POWER_SUPPLY_SET_INIT_VOL,
-
- POWER_SUPPLY_SET_CONSUME_MA,
-
- POWER_SUPPLY_SET_BEFORE_ENTER_S4,
- };
- typedef enum
- {
-
- BAT_CHG_EVENT_DC5V_IN = 1,
-
- BAT_CHG_EVENT_DC5V_OUT,
-
- BAT_CHG_EVENT_DC5V_STANDBY,
-
- BAT_CHG_EVENT_CHARGE_START,
-
- BAT_CHG_EVENT_CHARGE_STOP,
-
- BAT_CHG_EVENT_CHARGE_FULL,
-
- BAT_CHG_EVENT_VOLTAGE_CHANGE,
-
- BAT_CHG_EVENT_CAP_CHANGE,
-
- BAT_CHG_EVENT_BATTERY_LOW,
-
- BAT_CHG_EVENT_BATTERY_LOW_EX,
-
- BAT_CHG_EVENT_BATTERY_TOO_LOW,
-
- BAT_CHG_EVENT_BATTERY_FULL,
-
- BAT_CHG_EVENT_EXIT_MINI_CHARGE,
- } bat_charge_event_t;
- typedef union {
- uint32_t voltage_val;
- uint32_t cap;
- } bat_charge_event_para_t;
- typedef void (*bat_charge_callback_t)(bat_charge_event_t event, bat_charge_event_para_t *para);
- union power_supply_propval {
-
- int intval;
-
- const char *strval;
- };
- struct battery_capctr_info {
- uint8_t capctr_enable_flag;
- uint8_t capctr_minval;
- uint8_t capctr_maxval;
- };
- struct power_supply_driver_api {
-
- int (*get_property)(struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val);
-
- void (*set_property)(struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val);
-
- void (*register_notify)(struct device *dev, bat_charge_callback_t cb);
-
- void (*enable)(struct device *dev);
-
- void (*disable)(struct device *dev);
- };
- static inline int power_supply_get_property(struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val)
- {
- const struct power_supply_driver_api *api = (const struct power_supply_driver_api *) dev->api;
- return api->get_property(dev, psp, val);
- }
- static inline void power_supply_set_property(struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val)
- {
- const struct power_supply_driver_api *api = (const struct power_supply_driver_api *) dev->api;
- api->set_property(dev, psp, val);
- }
- static inline void power_supply_register_notify(struct device *dev, bat_charge_callback_t cb)
- {
- const struct power_supply_driver_api *api = (const struct power_supply_driver_api *) dev->api;
- api->register_notify(dev, cb);
- }
- static inline void power_supply_enable(struct device *dev)
- {
- const struct power_supply_driver_api *api = (const struct power_supply_driver_api *) dev->api;
- api->enable(dev);
- }
- static inline void power_supply_disable(struct device *dev)
- {
- const struct power_supply_driver_api *api = (const struct power_supply_driver_api *) dev->api;
- api->disable(dev);
- }
- #ifdef CONFIG_ACTS_BATTERY_SUPPLY_EXT_COULOMETER
- struct coulometer_driver_api {
-
- int (*get_property)(const struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val);
-
- void (*set_property)(const struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val);
-
- void (*enable)(const struct device *dev);
-
- void (*disable)(const struct device *dev);
- };
- static inline int coulometer_get_property(const struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val)
- {
- const struct coulometer_driver_api *api = dev->api;
- return api->get_property(dev, psp, val);
- }
- static inline void coulometer_set_property(const struct device *dev, enum power_supply_property psp,
- union power_supply_propval *val)
- {
- const struct coulometer_driver_api *api = dev->api;
- api->set_property(dev, psp, val);
- }
- static inline void coulometer_enable(const struct device *dev)
- {
- const struct coulometer_driver_api *api = dev->api;
- api->enable(dev);
- }
- static inline void coulometer_disable(const struct device *dev)
- {
- const struct coulometer_driver_api *api = dev->api;
- api->disable(dev);
- }
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|