summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-03-26 13:18:39 -0700
committerChromeBot <chrome-bot@google.com>2013-03-27 11:35:20 -0700
commitc2b94fd184e6f5df5e5d8fe4018055a29a96a064 (patch)
tree7ccb95f13ca0cf5ff21b67687b4bb8fe30ad06d3
parent0a2603e8ea234a9263a0a2e6be5daed362c12d72 (diff)
downloadchrome-ec-c2b94fd184e6f5df5e5d8fe4018055a29a96a064.tar.gz
Move files in preparation for merging keyboard_scan modules
This is part one of a series to merge the keyboard scan interface to be common across all platforms. This change just moves and renames files and APIs and removes some read code, and sets up protocol-specific CONFIG options. It makes the next CL which actually merges keyboard scanning easier to parse. BUG=chrome-os-partner:18360 BRANCH=none TEST=compile all boards; test keyboard on spring and link Change-Id: I815a40aae4e5d5f333b8501aff9656080533d913 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46549 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--board/daisy/board.c2
-rw-r--r--board/daisy/board.h5
-rw-r--r--board/link/board.h1
-rw-r--r--board/mccroskey/board.h8
-rw-r--r--board/snow/board.c2
-rw-r--r--board/snow/board.h2
-rw-r--r--board/spring/board.h1
-rw-r--r--board/spring/usb_charging.c4
-rw-r--r--chip/lm4/build.mk4
-rw-r--r--chip/lm4/switch.c6
-rw-r--r--chip/stm32/build.mk4
-rw-r--r--common/build.mk6
-rw-r--r--common/console_output.c1
-rw-r--r--common/gaia_power.c9
-rw-r--r--common/i8042.c6
-rw-r--r--common/keyboard_8042.c (renamed from common/keyboard.c)32
-rw-r--r--common/keyboard_mkbp.c (renamed from chip/stm32/keyboard_scan.c)40
-rw-r--r--common/keyboard_scan.c (renamed from chip/lm4/keyboard_scan.c)6
-rw-r--r--common/main.c3
-rw-r--r--include/console.h1
-rw-r--r--include/keyboard_8042.h (renamed from include/keyboard.h)37
-rw-r--r--include/keyboard_mkbp.h25
-rw-r--r--include/keyboard_protocol.h30
-rw-r--r--include/keyboard_scan.h23
24 files changed, 144 insertions, 114 deletions
diff --git a/board/daisy/board.c b/board/daisy/board.c
index 7052ec68fc..f48faeb852 100644
--- a/board/daisy/board.c
+++ b/board/daisy/board.c
@@ -181,7 +181,7 @@ void configure_board(void)
gpio_set_level(GPIO_EC_INT, 1);
}
-void board_keyboard_suppress_noise(void)
+void keyboard_suppress_noise(void)
{
/* notify audio codec of keypress for noise suppression */
gpio_set_level(GPIO_CODEC_INT, 0);
diff --git a/board/daisy/board.h b/board/daisy/board.h
index f32d2e86a9..1d0a19e5bb 100644
--- a/board/daisy/board.h
+++ b/board/daisy/board.h
@@ -21,6 +21,8 @@
/* Optional features */
#define CONFIG_CHIPSET_GAIA
#define CONFIG_I2C
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
+#define CONFIG_KEYBOARD_SUPPRESS_NOISE
/* Allow dangerous commands all the time, since we don't have a write protect
* switch. */
@@ -108,9 +110,6 @@ enum gpio_signal {
void configure_board(void);
-/* Signal to the AP that keyboard scan data is available */
-void board_keyboard_suppress_noise(void);
-
/* Auto detect EC i2c host port */
int board_i2c_host_port(void);
diff --git a/board/link/board.h b/board/link/board.h
index a7b6f2ae60..f986f132a0 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -20,6 +20,7 @@
#define CONFIG_CHIPSET_X86
#define CONFIG_CONSOLE_CMDHELP
#define CONFIG_EXTPOWER_GPIO
+#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_LPC
#define CONFIG_ONEWIRE
#define CONFIG_ONEWIRE_LED
diff --git a/board/mccroskey/board.h b/board/mccroskey/board.h
index 095a95fc42..2641885b36 100644
--- a/board/mccroskey/board.h
+++ b/board/mccroskey/board.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -21,13 +21,15 @@
#define CONFIG_CONSOLE_UART 1
/* Debug features */
-#define CONFIG_PANIC_HELP
#define CONFIG_ASSERT_HELP
#define CONFIG_CONSOLE_CMDHELP
-
+#define CONFIG_PANIC_HELP
#undef CONFIG_TASK_PROFILING
#define CONFIG_WATCHDOG_HELP
+/* Optional features */
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
+
/* use STOP mode when we have nothing to do */
/*
* FIXME(dhendrix): This causes the UART to drop characters and likely
diff --git a/board/snow/board.c b/board/snow/board.c
index a70a112b79..83a628ce7c 100644
--- a/board/snow/board.c
+++ b/board/snow/board.c
@@ -177,7 +177,7 @@ void configure_board_late(void)
#endif
}
-void board_keyboard_suppress_noise(void)
+void keyboard_suppress_noise(void)
{
/* notify audio codec of keypress for noise suppression */
gpio_set_level(GPIO_CODEC_INT, 0);
diff --git a/board/snow/board.h b/board/snow/board.h
index fe9883e7b1..010c2cde01 100644
--- a/board/snow/board.h
+++ b/board/snow/board.h
@@ -25,6 +25,8 @@
#define CONFIG_HOST_COMMAND_STATUS
#define CONFIG_I2C
#define CONFIG_I2C_ARBITRATION
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
+#define CONFIG_KEYBOARD_SUPPRESS_NOISE
#undef CONFIG_TASK_PROFILING
#define CONFIG_WATCHDOG_HELP
diff --git a/board/spring/board.h b/board/spring/board.h
index 31043b0f13..4387162df9 100644
--- a/board/spring/board.h
+++ b/board/spring/board.h
@@ -23,6 +23,7 @@
#define CONFIG_CHIPSET_GAIA
#define CONFIG_HOST_COMMAND_STATUS
#define CONFIG_I2C
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
#undef CONFIG_TASK_PROFILING
#define CONFIG_WATCHDOG_HELP
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c
index e57e6ebd46..72fcf54335 100644
--- a/board/spring/usb_charging.c
+++ b/board/spring/usb_charging.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,7 +12,7 @@
#include "console.h"
#include "hooks.h"
#include "gpio.h"
-#include "keyboard_scan.h"
+#include "keyboard_protocol.h"
#include "pmu_tpschrome.h"
#include "registers.h"
#include "smart_battery.h"
diff --git a/chip/lm4/build.mk b/chip/lm4/build.mk
index c3ab2bafa5..9c70e50f82 100644
--- a/chip/lm4/build.mk
+++ b/chip/lm4/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
@@ -22,6 +22,6 @@ chip-$(CONFIG_ONEWIRE)+=onewire.o
chip-$(CONFIG_PECI)+=peci.o
chip-$(CONFIG_PWM)+=pwm.o
chip-$(CONFIG_SPI)+=spi.o
-chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o keyboard_raw.o
+chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_raw.o
chip-$(CONFIG_TASK_SWITCH)+=switch.o
chip-$(CONFIG_WATCHDOG)+=watchdog.o
diff --git a/chip/lm4/switch.c b/chip/lm4/switch.c
index 94d41bed77..0e5c1542af 100644
--- a/chip/lm4/switch.c
+++ b/chip/lm4/switch.c
@@ -12,7 +12,7 @@
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
-#include "keyboard.h"
+#include "keyboard_protocol.h"
#include "keyboard_scan.h"
#include "pwm.h"
#include "switch.h"
@@ -514,7 +514,7 @@ void switch_task(void)
* no longer pressed.
*/
if (!raw_power_button_pressed())
- keyboard_enable_scanning(1);
+ keyboard_scan_enable(1);
if (raw_power_button_pressed() !=
debounced_power_pressed)
@@ -607,7 +607,7 @@ void switch_interrupt(enum gpio_signal signal)
* reduce the risk of false-reboot triggered by those
* keys on the same column with refresh key.
*/
- keyboard_enable_scanning(0);
+ keyboard_scan_enable(0);
}
break;
case GPIO_PCH_BKLTEN:
diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk
index 0125554a72..87e3a88d44 100644
--- a/chip/stm32/build.mk
+++ b/chip/stm32/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
@@ -14,7 +14,7 @@ chip-y+=jtag-$(CHIP_VARIANT).o clock-$(CHIP_VARIANT).o gpio-$(CHIP_VARIANT).o
chip-$(CONFIG_SPI)+=spi.o
chip-$(CONFIG_I2C)+=i2c.o
chip-$(CONFIG_WATCHDOG)+=watchdog.o
-chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o keyboard_raw.o
+chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_raw.o
chip-$(CONFIG_TASK_POWERLED)+=power_led.o
chip-$(CONFIG_FLASH)+=flash-$(CHIP_VARIANT).o
chip-$(CONFIG_ADC)+=adc.o
diff --git a/common/build.mk b/common/build.mk
index 99865dcfc4..1136015b7d 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -21,6 +21,10 @@ common-$(CONFIG_FLASH)+=flash_common.o fmap.o
common-$(CONFIG_I2C)+=i2c_commands.o
common-$(CONFIG_I2C_ARBITRATION)+=i2c_arbitration.o
common-$(CONFIG_IR357x)+=ir357x.o
+# TODO: combine common bits of keyboard_scan into one file
+# (coming in a follow-up CL)
+common-$(CONFIG_KEYBOARD_PROTOCOL_MKBP)+=keyboard_mkbp.o
+common-$(CONFIG_KEYBOARD_PROTOCOL_8042)+=keyboard_scan.o
common-$(CONFIG_KEYBOARD_TEST)+=keyboard_test.o
common-$(CONFIG_LP5562)+=lp5562.o lp5562_battery_led.o
common-$(CONFIG_LPC)+=port80.o
@@ -30,7 +34,7 @@ common-$(CONFIG_SMART_BATTERY)+=smart_battery.o smart_battery_stub.o
common-$(CONFIG_TASK_CHARGER)+=charge_state.o battery_precharge.o
common-$(CONFIG_TASK_CONSOLE)+=console.o
common-$(CONFIG_TASK_HOSTCMD)+=host_command.o host_event_commands.o
-common-$(CONFIG_TASK_I8042CMD)+=i8042.o keyboard.o
+common-$(CONFIG_TASK_I8042CMD)+=i8042.o keyboard_8042.o
common-$(CONFIG_TASK_LIGHTBAR)+=lightbar.o
common-$(CONFIG_TASK_THERMAL)+=thermal.o
common-$(CONFIG_TASK_VBOOTHASH)+=sha256.o vboot_hash.o
diff --git a/common/console_output.c b/common/console_output.c
index 12e35f55a3..b7985883cc 100644
--- a/common/console_output.c
+++ b/common/console_output.c
@@ -26,7 +26,6 @@ static const char *channel_names[CC_CHANNEL_COUNT] = {
"gpio",
"hostcmd",
"i2c",
- "i8042",
"keyboard",
"keyscan",
"lightbar",
diff --git a/common/gaia_power.c b/common/gaia_power.c
index 7f53dd800e..8252240aae 100644
--- a/common/gaia_power.c
+++ b/common/gaia_power.c
@@ -174,7 +174,7 @@ static int check_for_power_off_event(void)
/* Dis/Enable keyboard scanning when the power button state changes */
if (!pressed || pressed != power_button_was_pressed)
- keyboard_enable_scanning(!pressed);
+ keyboard_scan_enable(!pressed);
now = get_time();
@@ -263,13 +263,6 @@ static int gaia_power_init(void)
auto_power_on = 1;
}
- /* Auto power on if the recovery combination was pressed */
- if (keyboard_scan_recovery_pressed()) {
- CPRINTF("[%T auto_power_on is set due to "
- "keyboard_scan_recovery_pressed() ...]\n");
- auto_power_on = 1;
- }
-
return EC_SUCCESS;
}
diff --git a/common/i8042.c b/common/i8042.c
index 5c3b1bbf06..683bfbe1b1 100644
--- a/common/i8042.c
+++ b/common/i8042.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -11,7 +11,7 @@
#include "config.h"
#include "console.h"
#include "i8042.h"
-#include "keyboard.h"
+#include "keyboard_protocol.h"
#include "lpc.h"
#include "queue.h"
#include "task.h"
@@ -19,7 +19,7 @@
#include "util.h"
/* Console output macros */
-#define CPRINTF(format, args...) cprintf(CC_I8042, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_KEYBOARD, format, ## args)
static int i8042_irq_enabled;
diff --git a/common/keyboard.c b/common/keyboard_8042.c
index feda6d884a..1a991d7075 100644
--- a/common/keyboard.c
+++ b/common/keyboard_8042.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -12,8 +12,8 @@
#include "host_command.h"
#include "i8042.h"
#include "i8042_protocol.h"
-#include "keyboard.h"
#include "keyboard_config.h"
+#include "keyboard_protocol.h"
#include "lightbar.h"
#include "lpc.h"
#include "registers.h"
@@ -54,10 +54,10 @@ enum scancode_set_list {
/*
* i8042 global settings.
*/
-static int keyboard_enabled = 0; /* default the keyboard is disabled. */
-static int keystroke_enabled; /* output keystrokes */
+static int keyboard_enabled; /* default the keyboard is disabled. */
+static int keystroke_enabled; /* output keystrokes */
static uint8_t resend_command[MAX_SCAN_CODE_LEN];
-static uint8_t resend_command_len = 0;
+static uint8_t resend_command_len;
static uint8_t controller_ram_address;
static uint8_t controller_ram[0x20] = {
/* the so called "command byte" */
@@ -65,7 +65,7 @@ static uint8_t controller_ram[0x20] = {
/* 0x01 - 0x1f are controller RAM */
};
static uint8_t A20_status;
-static int power_button_pressed = 0;
+static int power_button_pressed;
static void keyboard_special(uint16_t k);
/*
@@ -93,7 +93,7 @@ static uint8_t typematic_value_from_host = DEFAULT_TYPEMATIC_VALUE;
static int refill_first_delay = DEFAULT_FIRST_DELAY; /* unit: ms */
static int refill_inter_delay = DEFAULT_INTER_DELAY; /* unit: ms */
static int typematic_delay; /* unit: us */
-static int typematic_len = 0; /* length of typematic_scan_code */
+static int typematic_len; /* length of typematic_scan_code */
static uint8_t typematic_scan_code[MAX_SCAN_CODE_LEN];
@@ -257,7 +257,7 @@ static void reset_rate_and_delay(void)
}
-void keyboard_clear_underlying_buffer(void)
+void keyboard_clear_buffer(void)
{
i8042_flush_buffer();
}
@@ -493,25 +493,25 @@ int handle_keyboard_data(uint8_t data, uint8_t *output)
case I8042_CMD_ENABLE:
output[out_len++] = I8042_RET_ACK;
keystroke_enable(1);
- keyboard_clear_underlying_buffer();
+ keyboard_clear_buffer();
break;
case I8042_CMD_RESET_DIS:
output[out_len++] = I8042_RET_ACK;
keystroke_enable(0);
reset_rate_and_delay();
- keyboard_clear_underlying_buffer();
+ keyboard_clear_buffer();
break;
case I8042_CMD_RESET_DEF:
output[out_len++] = I8042_RET_ACK;
reset_rate_and_delay();
- keyboard_clear_underlying_buffer();
+ keyboard_clear_buffer();
break;
case I8042_CMD_RESET_BAT:
reset_rate_and_delay();
- keyboard_clear_underlying_buffer();
+ keyboard_clear_buffer();
output[out_len++] = I8042_RET_ACK;
output[out_len++] = I8042_RET_BAT;
output[out_len++] = I8042_RET_BAT;
@@ -644,7 +644,7 @@ int handle_keyboard_command(uint8_t command, uint8_t *output)
} else {
CPRINTF("[%T KB unsupported cmd: 0x%02x]\n", command);
reset_rate_and_delay();
- keyboard_clear_underlying_buffer();
+ keyboard_clear_buffer();
output[out_len++] = I8042_RET_NAK;
data_port_state = STATE_NORMAL;
}
@@ -658,7 +658,7 @@ int handle_keyboard_command(uint8_t command, uint8_t *output)
/* U U D D L R L R b a */
static void keyboard_special(uint16_t k)
{
- static uint8_t s = 0;
+ static uint8_t s;
static const uint16_t a[] = {0xe048, 0xe048, 0xe050, 0xe050, 0xe04b,
0xe04d, 0xe04b, 0xe04d, 0x0030, 0x001e};
#ifdef CONFIG_TASK_LIGHTBAR
@@ -984,7 +984,7 @@ static void keyboard_preserve_state(void)
state.ctlram = controller_ram[0];
system_add_jump_tag(KB_SYSJUMP_TAG, KB_HOOK_VERSION,
- sizeof(state), &state);
+ sizeof(state), &state);
}
DECLARE_HOOK(HOOK_SYSJUMP, keyboard_preserve_state, HOOK_PRIO_DEFAULT);
@@ -997,7 +997,7 @@ static void keyboard_restore_state(void)
int version, size;
prev = (const struct kb_state *)system_get_jump_tag(KB_SYSJUMP_TAG,
- &version, &size);
+ &version, &size);
if (prev && version == KB_HOOK_VERSION && size == sizeof(*prev)) {
/* Coming back from a sysjump, so restore settings. */
scancode_set = prev->codeset;
diff --git a/chip/stm32/keyboard_scan.c b/common/keyboard_mkbp.c
index 1d8bf2819e..9d2613b187 100644
--- a/chip/stm32/keyboard_scan.c
+++ b/common/keyboard_mkbp.c
@@ -10,8 +10,8 @@
#include "console.h"
#include "gpio.h"
#include "host_command.h"
-#include "keyboard.h"
#include "keyboard_config.h"
+#include "keyboard_protocol.h"
#include "keyboard_raw.h"
#include "keyboard_scan.h"
#include "keyboard_test.h"
@@ -38,14 +38,6 @@ static uint8_t scan_edge_index[KEYBOARD_COLS][KEYBOARD_ROWS];
/*****************************************************************************/
-/* Provide a default function in case the board doesn't have one */
-void __board_keyboard_suppress_noise(void)
-{
-}
-
-void board_keyboard_suppress_noise(void)
- __attribute__((weak, alias("__board_keyboard_suppress_noise")));
-
#define KB_FIFO_DEPTH 16 /* FIXME: this is pretty huge */
static uint32_t kb_fifo_start; /* first entry */
static uint32_t kb_fifo_end; /* last entry */
@@ -71,9 +63,6 @@ static struct ec_mkbp_config config = {
.fifo_max_depth = KB_FIFO_DEPTH,
};
-/**
- * Clear keyboard state variables.
- */
void keyboard_clear_state(void)
{
int i;
@@ -86,12 +75,7 @@ void keyboard_clear_state(void)
memset(kb_fifo[i], 0, KEYBOARD_COLS);
}
-/**
- * Add keyboard state into FIFO
- *
- * @return EC_SUCCESS if entry added, EC_ERROR_OVERFLOW if FIFO is full
- */
-static int kb_fifo_add(uint8_t *buffp)
+int keyboard_fifo_add(const uint8_t *buffp)
{
int ret = EC_SUCCESS;
@@ -308,7 +292,9 @@ static int check_keys_changed(uint8_t *state)
}
if (any_change) {
- board_keyboard_suppress_noise();
+#ifdef CONFIG_KEYBOARD_SUPPRESS_NOISE
+ keyboard_suppress_noise();
+#endif
print_state(state, "state");
#ifdef PRINT_SCAN_TIMES
@@ -325,7 +311,7 @@ static int check_keys_changed(uint8_t *state)
/* Swallow special keys */
if (check_runtime_keys(state))
return 0;
- else if (kb_fifo_add(state) == EC_SUCCESS)
+ else if (keyboard_fifo_add(state) == EC_SUCCESS)
set_host_interrupt(1);
else
CPRINTF("dropped keystroke\n");
@@ -473,12 +459,6 @@ void keyboard_put_char(uint8_t chr, int send_irq)
/* TODO: needs to be implemented */
}
-int keyboard_scan_recovery_pressed(void)
-{
- return host_get_events() &
- EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY);
-}
-
static int keyboard_get_scan(struct host_cmd_handler_args *args)
{
kb_fifo_remove(args->response);
@@ -509,7 +489,7 @@ DECLARE_HOST_COMMAND(EC_CMD_MKBP_INFO,
keyboard_get_info,
EC_VER_MASK(0));
-void keyboard_enable_scanning(int enable)
+void keyboard_scan_enable(int enable)
{
if (enable) {
mutex_unlock(&scanning_enabled);
@@ -535,11 +515,11 @@ void keyboard_enable_scanning(int enable)
#define BATTERY_KEY_ROW 7
#define BATTERY_KEY_ROW_MASK (1 << BATTERY_KEY_ROW)
-void keyboard_send_battery_key()
+void keyboard_send_battery_key(void)
{
mutex_lock(&scanning_enabled);
debounced_state[BATTERY_KEY_COL] ^= BATTERY_KEY_ROW_MASK;
- if (kb_fifo_add(debounced_state) == EC_SUCCESS)
+ if (keyboard_fifo_add(debounced_state) == EC_SUCCESS)
set_host_interrupt(1);
else
CPRINTF("dropped battery keystroke\n");
@@ -575,7 +555,7 @@ static int command_keyboard_press(int argc, char **argv)
else
debounced_state[c] &= ~(1 << r);
- if (kb_fifo_add(debounced_state) == EC_SUCCESS)
+ if (keyboard_fifo_add(debounced_state) == EC_SUCCESS)
set_host_interrupt(1);
else
ccprintf("dropped keystroke\n");
diff --git a/chip/lm4/keyboard_scan.c b/common/keyboard_scan.c
index 950af73136..c01326d956 100644
--- a/chip/lm4/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -9,8 +9,8 @@
#include "common.h"
#include "console.h"
#include "host_command.h"
-#include "keyboard.h"
#include "keyboard_config.h"
+#include "keyboard_protocol.h"
#include "keyboard_raw.h"
#include "keyboard_scan.h"
#include "switch.h"
@@ -457,7 +457,7 @@ void keyboard_scan_task(void)
}
}
-void keyboard_enable_scanning(int enable)
+void keyboard_scan_enable(int enable)
{
enable_scanning = enable;
@@ -470,7 +470,7 @@ void keyboard_enable_scanning(int enable)
task_wake(TASK_ID_KEYSCAN);
} else {
keyboard_raw_drive_column(KEYBOARD_COLUMN_NONE);
- keyboard_clear_underlying_buffer();
+ keyboard_clear_buffer();
}
}
diff --git a/common/main.c b/common/main.c
index 0830cc6879..cb6b0b8bbb 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -15,7 +15,6 @@
#include "gpio.h"
#include "hooks.h"
#include "jtag.h"
-#include "keyboard.h"
#include "keyboard_scan.h"
#include "system.h"
#include "task.h"
diff --git a/include/console.h b/include/console.h
index 8bfdd579b0..90e46bd8cf 100644
--- a/include/console.h
+++ b/include/console.h
@@ -35,7 +35,6 @@ enum console_channel {
CC_GPIO,
CC_HOSTCMD,
CC_I2C,
- CC_I8042,
CC_KEYBOARD,
CC_KEYSCAN,
CC_LIGHTBAR,
diff --git a/include/keyboard.h b/include/keyboard_8042.h
index 8e218796a0..2dcd0367ee 100644
--- a/include/keyboard.h
+++ b/include/keyboard_8042.h
@@ -1,44 +1,47 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* The functions implemented by keyboard component of EC core.
*/
-#ifndef __CROS_EC_KEYBOARD_H
-#define __CROS_EC_KEYBOARD_H
+#ifndef __CROS_EC_KEYBOARD_8042_H
+#define __CROS_EC_KEYBOARD_8042_H
#include "common.h"
#define MAX_SCAN_CODE_LEN 4
-/* Called by keyboard scan code once any key state change (after de-bounce),
- *
- * This function will look up matrix table and convert scancode host.
- */
-void keyboard_state_changed(int row, int col, int is_pressed);
-
-
-/* Handle the port 0x60 writes from host.
+/**
+ * Handle the port 0x60 writes from host.
*
* This functions returns the number of bytes stored in *output buffer.
*/
int handle_keyboard_data(uint8_t data, uint8_t *output);
-/* Handle the port 0x64 writes from host.
+/**
+ * Handle the port 0x64 writes from host.
*
* This functions returns the number of bytes stored in *output buffer.
* BUT theose bytes will appear at port 0x60.
*/
int handle_keyboard_command(uint8_t command, uint8_t *output);
-/* Clear the keyboard buffer to host. */
-void keyboard_clear_underlying_buffer(void);
+/**
+ * Called by keyboard scan code once any key state change (after de-bounce),
+ *
+ * This function will look up matrix table and convert scancode host.
+ */
+void keyboard_state_changed(int row, int col, int is_pressed);
-/* Send make/break code of power button to host. */
+/**
+ * Send make/break code of power button to host.
+ */
void keyboard_set_power_button(int pressed);
-/* Log the keyboard-related information */
+/**
+ * Log the keyboard-related information
+ */
void kblog_put(char type, uint8_t byte);
-#endif /* __CROS_EC_KEYBOARD_H */
+#endif /* __CROS_EC_KEYBOARD_8042_H */
diff --git a/include/keyboard_mkbp.h b/include/keyboard_mkbp.h
new file mode 100644
index 0000000000..2fb9fc1273
--- /dev/null
+++ b/include/keyboard_mkbp.h
@@ -0,0 +1,25 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * MKBP keyboard protocol
+ */
+
+#ifndef __CROS_EC_KEYBOARD_MKBP_H
+#define __CROS_EC_KEYBOARD_MKBP_H
+
+#include "common.h"
+
+/**
+ * Add keyboard state into FIFO
+ *
+ * @return EC_SUCCESS if entry added, EC_ERROR_OVERFLOW if FIFO is full
+ */
+int keyboard_fifo_add(const uint8_t *buffp);
+
+/**
+ * Send KEY_BATTERY keystroke.
+ */
+void keyboard_send_battery_key(void);
+
+#endif /* __CROS_EC_KEYBOARD_MKBP_H */
diff --git a/include/keyboard_protocol.h b/include/keyboard_protocol.h
new file mode 100644
index 0000000000..866c58807b
--- /dev/null
+++ b/include/keyboard_protocol.h
@@ -0,0 +1,30 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Keyboard protocol interface
+ */
+
+#ifndef __CROS_EC_KEYBOARD_PROTOCOL_H
+#define __CROS_EC_KEYBOARD_PROTOCOL_H
+
+#include "common.h"
+
+/* Routines common to all protocols */
+
+/**
+ * Clear the keyboard buffer to host.
+ */
+void keyboard_clear_buffer(void);
+
+/* Protocol-specific includes */
+
+#ifdef CONFIG_KEYBOARD_PROTOCOL_8042
+#include "keyboard_8042.h"
+#endif
+
+#ifdef CONFIG_KEYBOARD_PROTOCOL_MKBP
+#include "keyboard_mkbp.h"
+#endif
+
+#endif /* __CROS_EC_KEYBOARD_PROTOCOL_H */
diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h
index e0f883375a..04a21838bb 100644
--- a/include/keyboard_scan.h
+++ b/include/keyboard_scan.h
@@ -26,29 +26,22 @@ enum boot_key {
/**
* Return the key held down at boot time in addition to the keyboard-controlled
* reset keys. Returns BOOT_KEY_OTHER if none of the keys specifically checked
- * was pressed, or reset was not caused by a keyboard-controlled reset, or if
- * the state has been cleared by keyboard_scan_clear_boot_key().
+ * was pressed, or reset was not caused by a keyboard-controlled reset.
*/
enum boot_key keyboard_scan_get_boot_key(void);
/**
- * Return non-zero if recovery key was pressed at boot.
- */
-int keyboard_scan_recovery_pressed(void);
-
-/**
- * Clear any saved keyboard state (empty FIFO, etc).
- */
-void keyboard_clear_state(void);
-
-/**
* Enables/disables keyboard matrix scan.
*/
-void keyboard_enable_scanning(int enable);
+void keyboard_scan_enable(int enable);
+#ifdef CONFIG_KEYBOARD_SUPPRESS_NOISE
/**
- * Sends KEY_BATTERY keystroke.
+ * Indicate to audio codec that a key has been pressed.
+ *
+ * Boards may supply this function to suppress audio noise.
*/
-void keyboard_send_battery_key(void);
+void keyboard_suppress_noise(void);
+#endif
#endif /* __CROS_EC_KEYBOARD_SCAN_H */