diff options
Diffstat (limited to 'board')
-rw-r--r-- | board/big/battery.c | 10 | ||||
-rw-r--r-- | board/big/board.h | 1 | ||||
-rw-r--r-- | board/blaze/battery.c | 26 | ||||
-rw-r--r-- | board/blaze/board.h | 1 | ||||
-rw-r--r-- | board/nyan/battery.c | 10 | ||||
-rw-r--r-- | board/nyan/board.h | 1 |
6 files changed, 23 insertions, 26 deletions
diff --git a/board/big/battery.c b/board/big/battery.c index 1ac9991bef..b795206bfc 100644 --- a/board/big/battery.c +++ b/board/big/battery.c @@ -20,7 +20,7 @@ #define SB_SHIP_MODE_DATA 0xc574 static struct battery_info *battery_info; -static int battery_cut_off; +static int support_cut_off; struct battery_device { char manuf[9]; @@ -293,7 +293,7 @@ const struct battery_info *battery_get_info(void) (support_batteries[i].design_mv == design_mv)) { CPRINTF("[%T battery Manuf:%s, Device=%s, design=%u]\n", manuf, device, design_mv); - battery_cut_off = support_batteries[i].support_cut_off; + support_cut_off = support_batteries[i].support_cut_off; battery_info = support_batteries[i].battery_info; return battery_info; } @@ -304,12 +304,10 @@ const struct battery_info *battery_get_info(void) return &info_precharge; } -int battery_command_cut_off(struct host_cmd_handler_args *args) +int board_cut_off_battery(void) { - if (battery_cut_off) + if (support_cut_off) return sb_write(SB_SHIP_MODE_ADDR, SB_SHIP_MODE_DATA); else return EC_RES_INVALID_COMMAND; } -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); diff --git a/board/big/board.h b/board/big/board.h index dd1373b50c..6c39da3d58 100644 --- a/board/big/board.h +++ b/board/big/board.h @@ -11,6 +11,7 @@ /* Optional features */ #define CONFIG_AP_HANG_DETECT #define CONFIG_BATTERY_SMART +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_CHARGER #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ24725 diff --git a/board/blaze/battery.c b/board/blaze/battery.c index 7701aed74e..2944f97119 100644 --- a/board/blaze/battery.c +++ b/board/blaze/battery.c @@ -19,7 +19,7 @@ #define SB_SHUTDOWN_DATA 0x0010 static struct battery_info *battery_info; -static int battery_cut_off; +static int support_cut_off; struct battery_device { char manuf[9]; @@ -218,7 +218,7 @@ const struct battery_info *battery_get_info(void) (support_batteries[i].design_mv == design_mv)) { CPRINTF("[%T battery Manuf:%s, Device=%s, design=%u]\n", manuf, device, design_mv); - battery_cut_off = support_batteries[i].support_cut_off; + support_cut_off = support_batteries[i].support_cut_off; battery_info = support_batteries[i].battery_info; return battery_info; } @@ -229,25 +229,23 @@ const struct battery_info *battery_get_info(void) return &info_precharge; } -static int cutoff(void) +int board_cut_off_battery(void) { int rv; + if (!support_cut_off) + return EC_RES_INVALID_COMMAND; + /* Ship mode command must be sent twice to take effect */ rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); if (rv != EC_SUCCESS) - return rv; - - return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); -} + goto out; -int battery_command_cut_off(struct host_cmd_handler_args *args) -{ - if (battery_cut_off) - return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS; + rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); +out: + if (rv) + return EC_RES_ERROR; else - return EC_RES_INVALID_COMMAND; + return EC_RES_SUCCESS; } -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); diff --git a/board/blaze/board.h b/board/blaze/board.h index 3a4fdcff5e..23fc04395a 100644 --- a/board/blaze/board.h +++ b/board/blaze/board.h @@ -11,6 +11,7 @@ /* Optional features */ #define CONFIG_AP_HANG_DETECT #define CONFIG_BATTERY_SMART +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_CHARGER #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ24725 diff --git a/board/nyan/battery.c b/board/nyan/battery.c index 7ebfd594da..fa8ff5792b 100644 --- a/board/nyan/battery.c +++ b/board/nyan/battery.c @@ -20,7 +20,7 @@ #define SB_SHIP_MODE_DATA 0xc574 static struct battery_info *battery_info; -static int battery_cut_off; +static int support_cut_off; struct battery_device { char manuf[9]; @@ -255,7 +255,7 @@ const struct battery_info *battery_get_info(void) (support_batteries[i].design_mv == design_mv)) { CPRINTF("[%T battery Manuf:%s, Device=%s, design=%u]\n", manuf, device, design_mv); - battery_cut_off = support_batteries[i].support_cut_off; + support_cut_off = support_batteries[i].support_cut_off; battery_info = support_batteries[i].battery_info; return battery_info; } @@ -266,12 +266,10 @@ const struct battery_info *battery_get_info(void) return &info_precharge; } -int battery_command_cut_off(struct host_cmd_handler_args *args) +int board_cut_off_battery(void) { - if (battery_cut_off) + if (support_cut_off) return sb_write(SB_SHIP_MODE_ADDR, SB_SHIP_MODE_DATA); else return EC_RES_INVALID_COMMAND; } -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); diff --git a/board/nyan/board.h b/board/nyan/board.h index d8ae98bd77..5faa31f61f 100644 --- a/board/nyan/board.h +++ b/board/nyan/board.h @@ -11,6 +11,7 @@ /* Optional features */ #define CONFIG_AP_HANG_DETECT #define CONFIG_BATTERY_SMART +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_CHARGER #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ24725 |