cleanup: mkbp keyboard module

Rather than compile it by default for host-based tests, only compile
it for the few tests that actually use it.  Since those (and all
boards) now only use if if they also have a keyscan task, we can get
rid of the #ifdefs in keyboard_mkbp.c as well.

And remove a TODO we'll never do...

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests.  These pass:
     util/make_all.sh
     make BOARD=pit tests

Change-Id: I44d1806cfb375027a7ed0b33a5e9bdbbed8ccddc
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174513
This commit is contained in:
Randall Spangler
2013-10-24 10:19:55 -07:00
committed by chrome-internal-fetch
parent e48a9d9c21
commit d16a246ea9
6 changed files with 18 additions and 13 deletions

View File

@@ -11,7 +11,6 @@
/* Optional features */
#define CONFIG_EXTPOWER_GPIO
#undef CONFIG_FMAP
#define CONFIG_KEYBOARD_PROTOCOL_MKBP
#define CONFIG_POWER_BUTTON
#undef CONFIG_WATCHDOG
#define CONFIG_SWITCH

View File

@@ -16,7 +16,7 @@
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
#include "keyboard_protocol.h"
#include "keyboard_mkbp.h"
#include "pmu_tpschrome.h"
#include "pwm.h"
/* TODO(rspangler): files in common should not use chip registers directly */

View File

@@ -156,12 +156,8 @@ void keyboard_send_battery_key(void)
{
uint8_t state[KEYBOARD_COLS];
#ifdef HAS_TASK_KEYSCAN
/* Copy debounced state and add battery pseudo-key */
memcpy(state, keyboard_scan_get_state(), sizeof(state));
#else
memset(state, 0, sizeof(state));
#endif
state[BATTERY_KEY_COL] ^= BATTERY_KEY_ROW_MASK;
/* Add to FIFO only if AP is on or else it will wake from suspend */
@@ -206,7 +202,6 @@ static void set_keyscan_config(const struct ec_mkbp_config *src,
struct ec_mkbp_protocol_config *dst,
uint32_t valid_mask, uint8_t new_flags)
{
#ifdef HAS_TASK_KEYSCAN
struct keyboard_scan_config *ksc = keyboard_scan_get_config();
if (valid_mask & EC_MKBP_VALID_SCAN_PERIOD)
@@ -241,12 +236,10 @@ static void set_keyscan_config(const struct ec_mkbp_config *src,
if ((new_flags & EC_MKBP_FLAGS_ENABLE) &&
!(dst->flags & EC_MKBP_FLAGS_ENABLE))
task_wake(TASK_ID_KEYSCAN);
#endif
}
static void get_keyscan_config(struct ec_mkbp_config *dst)
{
#ifdef HAS_TASK_KEYSCAN
const struct keyboard_scan_config *ksc = keyboard_scan_get_config();
/* Copy fields from keyscan config to mkbp config */
@@ -256,7 +249,6 @@ static void get_keyscan_config(struct ec_mkbp_config *dst)
dst->scan_period_us = ksc->scan_period_us;
dst->min_post_scan_delay_us = ksc->min_post_scan_delay_us;
dst->poll_timeout_us = ksc->poll_timeout_us;
#endif
}
/**
@@ -265,8 +257,6 @@ static void get_keyscan_config(struct ec_mkbp_config *dst)
* This is like a structure copy, except that only selected fields are
* copied.
*
* TODO(sjg@chromium.org): Consider making this table driven as ectool.
*
* @param src Source config
* @param dst Destination config
* @param valid_mask Bits representing which fields to copy - each bit is

View File

@@ -774,6 +774,11 @@
*/
#endif
#ifndef HAS_TASK_KEYSCAN
#undef CONFIG_KEYBOARD_PROTOCOL_8042
#undef CONFIG_KEYBOARD_PROTOCOL_MKBP
#endif
/*****************************************************************************/
/*
* Apply test config overrides last, since tests need to override some of the

View File

@@ -20,6 +20,10 @@ int keyboard_fifo_add(const uint8_t *buffp);
/**
* Send KEY_BATTERY keystroke.
*/
#ifdef CONFIG_KEYBOARD_PROTOCOL_MKBP
void keyboard_send_battery_key(void);
#else
static inline void keyboard_send_battery_key(void) { }
#endif
#endif /* __CROS_EC_KEYBOARD_MKBP_H */

View File

@@ -23,10 +23,17 @@
#endif
#ifdef TEST_kb_8042
#undef CONFIG_KEYBOARD_PROTOCOL_MKBP
#define CONFIG_KEYBOARD_PROTOCOL_8042
#endif
#ifdef TEST_kb_mkbp
#define CONFIG_KEYBOARD_PROTOCOL_MKBP
#endif
#ifdef TEST_kb_scan
#define CONFIG_KEYBOARD_PROTOCOL_MKBP
#endif
#ifdef TEST_led_spring
#define CONFIG_BATTERY_MOCK
#define CONFIG_BATTERY_SMART