diff options
-rw-r--r-- | board/cyan/battery.c | 22 | ||||
-rw-r--r-- | board/cyan/board.h | 1 | ||||
-rw-r--r-- | board/falco/battery.c | 10 | ||||
-rw-r--r-- | board/falco/board.h | 4 | ||||
-rw-r--r-- | board/kunimitsu/battery.c | 18 | ||||
-rw-r--r-- | board/kunimitsu/board.h | 1 | ||||
-rw-r--r-- | board/rambi/battery.c | 18 | ||||
-rw-r--r-- | board/rambi/board.h | 1 | ||||
-rw-r--r-- | board/spring/battery.c | 35 | ||||
-rw-r--r-- | board/spring/board.h | 1 | ||||
-rw-r--r-- | board/squawks/battery.c | 22 | ||||
-rw-r--r-- | board/squawks/board.h | 1 | ||||
-rw-r--r-- | board/strago/battery.c | 22 | ||||
-rw-r--r-- | board/strago/board.h | 3 |
14 files changed, 31 insertions, 128 deletions
diff --git a/board/cyan/battery.c b/board/cyan/battery.c index bc3a63971e..d0e9dc78e9 100644 --- a/board/cyan/battery.c +++ b/board/cyan/battery.c @@ -7,10 +7,6 @@ #include "battery.h" #include "battery_smart.h" -#include "console.h" -#include "gpio.h" -#include "host_command.h" -#include "util.h" /* Shutdown mode parameter to write to manufacturer access register */ #define SB_SHUTDOWN_DATA 0x0010 @@ -33,7 +29,7 @@ const struct battery_info *battery_get_info(void) return &info; } -static int cutoff(void) +int board_cut_off_battery(void) { int rv; @@ -45,19 +41,3 @@ static int cutoff(void) return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); } - -static int battery_command_cut_off(struct host_cmd_handler_args *args) -{ - return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); - -static int command_battcutoff(int argc, char **argv) -{ - return cutoff(); -} -DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, - NULL, - "Enable battery cutoff (ship mode)", - NULL); diff --git a/board/cyan/board.h b/board/cyan/board.h index d5cc450192..320aa798a0 100644 --- a/board/cyan/board.h +++ b/board/cyan/board.h @@ -31,6 +31,7 @@ #define CONFIG_WAKE_PIN GPIO_POWER_BUTTON_L #define CONFIG_CHARGER +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ24770 diff --git a/board/falco/battery.c b/board/falco/battery.c index b2dd7fc00d..57ed576a44 100644 --- a/board/falco/battery.c +++ b/board/falco/battery.c @@ -7,7 +7,6 @@ #include "battery.h" #include "battery_smart.h" -#include "host_command.h" #define SB_SHIP_MODE_DATA 0x0010 @@ -33,16 +32,15 @@ const struct battery_info *battery_get_info(void) return &info; } -int battery_command_cut_off(struct host_cmd_handler_args *args) +int board_cut_off_battery(void) { int rv; /* Ship mode command must be sent twice. */ rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHIP_MODE_DATA); + if (rv != EC_SUCCESS) return rv; - rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHIP_MODE_DATA); - return rv; + + return sb_write(SB_MANUFACTURER_ACCESS, SB_SHIP_MODE_DATA); } -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); diff --git a/board/falco/board.h b/board/falco/board.h index 358f2a2235..b11f6a76f5 100644 --- a/board/falco/board.h +++ b/board/falco/board.h @@ -10,6 +10,7 @@ /* Optional features */ #define CONFIG_BACKLIGHT_REQ_GPIO GPIO_PCH_BKLTEN +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_BOARD_VERSION #define CONFIG_CHARGER @@ -39,6 +40,9 @@ #define CONFIG_VBOOT_HASH #define CONFIG_WIRELESS +#undef DEFERRABLE_MAX_COUNT +#define DEFERRABLE_MAX_COUNT 9 + #ifndef __ASSEMBLER__ /* I2C ports */ diff --git a/board/kunimitsu/battery.c b/board/kunimitsu/battery.c index 440bcaaacb..4cf4ce0dfe 100644 --- a/board/kunimitsu/battery.c +++ b/board/kunimitsu/battery.c @@ -33,7 +33,7 @@ const struct battery_info *battery_get_info(void) return &info; } -static int cutoff(void) +int board_cut_off_battery(void) { int rv; @@ -45,19 +45,3 @@ static int cutoff(void) return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); } - -static int battery_command_cut_off(struct host_cmd_handler_args *args) -{ - return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); - -static int command_battcutoff(int argc, char **argv) -{ - return cutoff(); -} -DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, - NULL, - "Enable battery cutoff (ship mode)", - NULL); diff --git a/board/kunimitsu/board.h b/board/kunimitsu/board.h index 5288471f83..cc03613cff 100644 --- a/board/kunimitsu/board.h +++ b/board/kunimitsu/board.h @@ -40,6 +40,7 @@ #define CONFIG_ALS #define CONFIG_ALS_ISL29035 #define CONFIG_CHARGER +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ24770 diff --git a/board/rambi/battery.c b/board/rambi/battery.c index 3c031d6480..9a8d955e9c 100644 --- a/board/rambi/battery.c +++ b/board/rambi/battery.c @@ -33,7 +33,7 @@ const struct battery_info *battery_get_info(void) return &info; } -static int cutoff(void) +int board_cut_off_battery(void) { int rv; @@ -45,19 +45,3 @@ static int cutoff(void) return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); } - -static int battery_command_cut_off(struct host_cmd_handler_args *args) -{ - return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); - -static int command_battcutoff(int argc, char **argv) -{ - return cutoff(); -} -DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, - NULL, - "Enable battery cutoff (ship mode)", - NULL); diff --git a/board/rambi/board.h b/board/rambi/board.h index 40b6515fd9..bd295615bf 100644 --- a/board/rambi/board.h +++ b/board/rambi/board.h @@ -11,6 +11,7 @@ /* Optional features */ #define CONFIG_AP_HANG_DETECT #define CONFIG_BACKLIGHT_LID +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_BOARD_VERSION #define CONFIG_CHARGER diff --git a/board/spring/battery.c b/board/spring/battery.c index f8d88a84d2..246552786e 100644 --- a/board/spring/battery.c +++ b/board/spring/battery.c @@ -7,12 +7,9 @@ #include "battery.h" #include "battery_smart.h" -#include "host_command.h" -#include "i2c.h" -#include "util.h" -#define PARAM_CUT_OFF_LOW 0x10 -#define PARAM_CUT_OFF_HIGH 0x00 +/* Shutdown mode parameter to write to manufacturer access register */ +#define SB_SHUTDOWN_DATA 0x0010 /* Battery temperature ranges in degrees C */ static const struct battery_info info = { @@ -29,25 +26,15 @@ const struct battery_info *battery_get_info(void) return &info; } -int battery_command_cut_off(struct host_cmd_handler_args *args) +int board_cut_off_battery(void) { int rv; - uint8_t buf[3]; - - buf[0] = SB_MANUFACTURER_ACCESS & 0xff; - buf[1] = PARAM_CUT_OFF_LOW; - buf[2] = PARAM_CUT_OFF_HIGH; - - i2c_lock(I2C_PORT_BATTERY, 1); - rv = i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0, - I2C_XFER_SINGLE); - rv = i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0, - I2C_XFER_SINGLE); - i2c_lock(I2C_PORT_BATTERY, 0); - - if (rv) - return EC_RES_ERROR; - return EC_RES_SUCCESS; + + /* 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); } -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); diff --git a/board/spring/board.h b/board/spring/board.h index ec31fa3107..4424817679 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -17,6 +17,7 @@ /* Optional features */ #define CONFIG_ADC +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_BOARD_PRE_INIT #define CONFIG_CHARGER_TPS65090 diff --git a/board/squawks/battery.c b/board/squawks/battery.c index 7c8d140d5b..518bb48e9b 100644 --- a/board/squawks/battery.c +++ b/board/squawks/battery.c @@ -7,10 +7,6 @@ #include "battery.h" #include "battery_smart.h" -#include "console.h" -#include "gpio.h" -#include "host_command.h" -#include "util.h" /* Shutdown mode parameter to write to manufacturer access register */ #define SB_SHUTDOWN_DATA 0x0010 @@ -38,7 +34,7 @@ const struct battery_info *battery_get_info(void) return &info; } -static int cutoff(void) +int board_cut_off_battery(void) { int rv; @@ -50,19 +46,3 @@ static int cutoff(void) return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); } - -static int battery_command_cut_off(struct host_cmd_handler_args *args) -{ - return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); - -static int command_battcutoff(int argc, char **argv) -{ - return cutoff(); -} -DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, - NULL, - "Enable battery cutoff (ship mode)", - NULL); diff --git a/board/squawks/board.h b/board/squawks/board.h index 25c5a50d8a..7bc3fecec4 100644 --- a/board/squawks/board.h +++ b/board/squawks/board.h @@ -11,6 +11,7 @@ /* Optional features */ #define CONFIG_AP_HANG_DETECT #define CONFIG_BACKLIGHT_LID +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_BOARD_VERSION #define CONFIG_CHARGER diff --git a/board/strago/battery.c b/board/strago/battery.c index 064f630f82..43fa956ced 100644 --- a/board/strago/battery.c +++ b/board/strago/battery.c @@ -7,10 +7,6 @@ #include "battery.h" #include "battery_smart.h" -#include "console.h" -#include "gpio.h" -#include "host_command.h" -#include "util.h" /* Shutdown mode parameter to write to manufacturer access register */ #define SB_SHUTDOWN_DATA 0x0010 @@ -33,7 +29,7 @@ const struct battery_info *battery_get_info(void) return &info; } -static int cutoff(void) +int board_cut_off_battery(void) { int rv; @@ -45,19 +41,3 @@ static int cutoff(void) return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); } - -static int battery_command_cut_off(struct host_cmd_handler_args *args) -{ - return cutoff() ? EC_RES_ERROR : EC_RES_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off, - EC_VER_MASK(0)); - -static int command_battcutoff(int argc, char **argv) -{ - return cutoff(); -} -DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, - NULL, - "Enable battery cutoff (ship mode)", - NULL); diff --git a/board/strago/board.h b/board/strago/board.h index 9d1a18cf42..45d49ddf0c 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -40,8 +40,9 @@ #define CONFIG_ALS #define CONFIG_ALS_ISL29035 -#define CONFIG_CHARGER +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART +#define CONFIG_CHARGER #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ24770 #define CONFIG_CHARGER_ILIM_PIN_DISABLED |