summaryrefslogtreecommitdiff
path: root/driver/battery/samus.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/battery/samus.c')
-rw-r--r--driver/battery/samus.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/driver/battery/samus.c b/driver/battery/samus.c
index 89f6dc9b68..88ee48310d 100644
--- a/driver/battery/samus.c
+++ b/driver/battery/samus.c
@@ -10,6 +10,7 @@
#include "console.h"
#include "ec_commands.h"
#include "extpower.h"
+#include "i2c.h"
#include "util.h"
static const struct battery_info info = {
@@ -220,3 +221,26 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
return BATTERY_NOT_DISCONNECTED;
}
#endif /* CONFIG_BATTERY_REVIVE_DISCONNECT */
+
+#define PARAM_CUT_OFF_LOW 0x10
+#define PARAM_CUT_OFF_HIGH 0x00
+
+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);
+
+ return rv;
+}
+