From b2db230e0cebde377deb88667a4e50e37c91ca27 Mon Sep 17 00:00:00 2001 From: Todd Broch Date: Mon, 11 Mar 2013 11:30:40 -0700 Subject: spring: stm32: Generate battery key when charging status changes. In order to update charger status we have added a virtual keystroke to signal change to the kernel via the MKBP interface. CL creates the virtual key press and calls it from within the USB charging code. Signed-off-by: Todd Broch BUG=chrome-os-partner:17927 BRANCH=spring TEST=manual 1. Compile for daisy,snow,spring. 2. Test on spring. Change-Id: I0afa0fc82c96fa3fd8119523a113b5028c8f64a3 Reviewed-on: https://gerrit.chromium.org/gerrit/45249 Reviewed-by: Vincent Palatin Commit-Queue: Todd Broch Tested-by: Todd Broch --- board/spring/usb_charging.c | 3 +++ chip/stm32/keyboard_scan.c | 18 ++++++++++++++++++ include/keyboard_scan.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index 464732c593..d7ba332047 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -11,6 +11,7 @@ #include "hooks.h" #include "gpio.h" #include "lp5562.h" +#include "keyboard_scan.h" #include "pmu_tpschrome.h" #include "registers.h" #include "smart_battery.h" @@ -420,6 +421,8 @@ static void usb_device_change(int dev_type) else CPRINTF("Unknown]\n"); + keyboard_send_battery_key(); + current_dev_type = dev_type; } diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c index db4263fd91..1e7298e3e7 100644 --- a/chip/stm32/keyboard_scan.c +++ b/chip/stm32/keyboard_scan.c @@ -678,6 +678,24 @@ void keyboard_enable_scanning(int enable) } } +/* Changes to col,row here need to also be reflected in kernel. + * drivers/input/mkbp.c ... see KEY_BATTERY. + */ +#define BATTERY_KEY_COL 0 +#define BATTERY_KEY_ROW 7 +#define BATTERY_KEY_ROW_MASK (1 << BATTERY_KEY_ROW) + +void keyboard_send_battery_key() +{ + mutex_lock(&scanning_enabled); + debounced_state[BATTERY_KEY_COL] ^= BATTERY_KEY_ROW_MASK; + if (kb_fifo_add(debounced_state) == EC_SUCCESS) + board_interrupt_host(1); + else + CPRINTF("dropped battery keystroke\n"); + mutex_unlock(&scanning_enabled); +} + static int command_keyboard_press(int argc, char **argv) { int r, c, p; diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h index 63384b10fb..8bdbd6905c 100644 --- a/include/keyboard_scan.h +++ b/include/keyboard_scan.h @@ -38,4 +38,7 @@ void keyboard_clear_state(void); /* Enables/disables keyboard matrix scan. */ void keyboard_enable_scanning(int enable); +/* Sends KEY_BATTERY keystroke */ +void keyboard_send_battery_key(void); + #endif /* __CROS_EC_KEYBOARD_SCAN_H */ -- cgit v1.2.1