diff options
author | Yilun Lin <yllin@google.com> | 2019-02-25 19:05:32 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-07 20:21:39 -0800 |
commit | 8b1b74c10a87c8477bc65b7be1f6943676bd56bb (patch) | |
tree | 3f2edb77977ee4aeaf0c1cb3da1a4c73769dcf07 | |
parent | 1641ef6a6e12ca4e26764ad0a083fc07a08da96d (diff) | |
download | chrome-ec-8b1b74c10a87c8477bc65b7be1f6943676bd56bb.tar.gz |
mkbp_event,include/config.h: Clarify MKBP delivery method.
Now we have two MKBP delivery methods:
1. define CONFIG_MKBP_USE_HOST_EVENT to notify via host event
2. undef CONFIG_MKBP_USE_HOST_EVENT to notify via GPIO interrupt
It may become more complicated if new notification methods introduced.
e.g.: mt_scp uses IPI, rather than host event and GPIO interrupt.
This CL does:
1. add CONFIG_MKBP_USE_GPIO to explicilty declare that MKBP event are
sent via GPIO interrupt.
2. CONFIG_MKBP_USE_CUSTOM for boards which have custmized methods.
3. Remove weak attribute in mkbp_set_host_active (which can be done
with CONFIG_MKBP_USE_CUSTOM now.
4. Removes mkbp_set_host_active function in board Nocturne. It only
deliver MKBP events through GPIO interrupt now.
BRANCH=None
BUG=b:120808999
TEST=grep -rn "CONFIG_MKBP_USE_GPIO\|EC_INT_L" board/ baseboard/ and
see the result is reasonable:
1. EC_INT_L must be 1-to-1 mapped to define CONFIG_MKBP_USE_GPIO in
every board, except that meep, yorp, ampton which are defined in
baseboard octopus.
2. undef CONFIG_MKBP_USE_GPIO in bip and casta, which use host
event, but also have baseboard octopus.
Change-Id: I4af6110e4fd3c009968075c3623ef2d91cbd770b
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1490794
Commit-Ready: Jett Rink <jettrink@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | baseboard/octopus/baseboard.h | 3 | ||||
-rw-r--r-- | board/aleena/board.h | 2 | ||||
-rw-r--r-- | board/bip/board.h | 1 | ||||
-rw-r--r-- | board/casta/board.h | 1 | ||||
-rw-r--r-- | board/cheza/board.h | 1 | ||||
-rw-r--r-- | board/elm/board.h | 1 | ||||
-rw-r--r-- | board/flapjack/board.h | 1 | ||||
-rw-r--r-- | board/jerry/board.h | 1 | ||||
-rw-r--r-- | board/kukui/board.h | 1 | ||||
-rw-r--r-- | board/nocturne/board.c | 20 | ||||
-rw-r--r-- | board/nocturne/board.h | 1 | ||||
-rw-r--r-- | board/nocturne_fp/board.h | 1 | ||||
-rw-r--r-- | board/npcx_evb_arm/board.h | 1 | ||||
-rw-r--r-- | board/oak/board.h | 1 | ||||
-rw-r--r-- | board/rainier/board.h | 1 | ||||
-rw-r--r-- | board/rowan/board.h | 1 | ||||
-rw-r--r-- | board/scarlet/board.h | 1 | ||||
-rw-r--r-- | common/mkbp_event.c | 12 | ||||
-rw-r--r-- | include/config.h | 24 | ||||
-rw-r--r-- | include/mkbp_event.h | 7 | ||||
-rw-r--r-- | test/test_config.h | 2 |
21 files changed, 58 insertions, 26 deletions
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 94c0197ec6..fc34912096 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -282,9 +282,10 @@ /* * Sensor stack in EC/Kernel depends on a hardware interrupt pin from EC->AP, so * do not define CONFIG_MKBP_USE_HOST_EVENT since all octopus boards use - * hardware pin to send interrupt from EC -> AP (except bip). + * hardware pin to send interrupt from EC -> AP (except bip and casta). */ #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #ifndef __ASSEMBLER__ diff --git a/board/aleena/board.h b/board/aleena/board.h index aeb75404a6..3c5cf048b7 100644 --- a/board/aleena/board.h +++ b/board/aleena/board.h @@ -29,6 +29,8 @@ /* KB backlight driver */ #define CONFIG_LED_DRIVER_LM3630A +#define CONFIG_MKBP_USE_GPIO + /* Motion sensing drivers */ #define CONFIG_ACCELGYRO_BMI160 #define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4) diff --git a/board/bip/board.h b/board/bip/board.h index 3a618e982e..a7671902f9 100644 --- a/board/bip/board.h +++ b/board/bip/board.h @@ -29,6 +29,7 @@ #undef CONFIG_PWM_KBLIGHT /* Old hardware does not support dedicated EC->AP interrupt for MKBP */ +#undef CONFIG_MKBP_USE_GPIO #define CONFIG_MKBP_USE_HOST_EVENT #undef CONFIG_UART_TX_BUF_SIZE diff --git a/board/casta/board.h b/board/casta/board.h index 554a36e3f0..c99ae1e696 100644 --- a/board/casta/board.h +++ b/board/casta/board.h @@ -37,6 +37,7 @@ #define CONFIG_STEINHART_HART_3V3_13K7_47K_4050B #define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B #define CONFIG_MKBP_EVENT +#undef CONFIG_MKBP_USE_GPIO #define CONFIG_MKBP_USE_HOST_EVENT /* Battery W/A */ diff --git a/board/cheza/board.h b/board/cheza/board.h index d005f624d1..174cce0c15 100644 --- a/board/cheza/board.h +++ b/board/cheza/board.h @@ -55,6 +55,7 @@ #define CONFIG_HOSTCMD_SECTION_SORTED /* Host commands are sorted. */ #define CONFIG_MKBP_EVENT #define CONFIG_KEYBOARD_PROTOCOL_MKBP +#define CONFIG_MKBP_USE_GPIO #define CONFIG_BOARD_VERSION_GPIO #define CONFIG_POWER_BUTTON diff --git a/board/elm/board.h b/board/elm/board.h index b2036896e4..8d1283244c 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -65,6 +65,7 @@ #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #define CONFIG_POWER_BUTTON #define CONFIG_POWER_COMMON #define CONFIG_USB_CHARGER diff --git a/board/flapjack/board.h b/board/flapjack/board.h index a281d4fdec..acdce43d54 100644 --- a/board/flapjack/board.h +++ b/board/flapjack/board.h @@ -202,6 +202,7 @@ #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO /* Define the MKBP events which are allowed to wakeup AP in S3. */ #define CONFIG_MKBP_WAKEUP_MASK \ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ diff --git a/board/jerry/board.h b/board/jerry/board.h index ad8fdceeb8..da5de695df 100644 --- a/board/jerry/board.h +++ b/board/jerry/board.h @@ -37,6 +37,7 @@ #define CONFIG_LED_POWER_ACTIVE_LOW #define CONFIG_LOW_POWER_IDLE #define CONFIG_LOW_POWER_S0 +#define CONFIG_MKBP_USE_GPIO #define CONFIG_POWER_BUTTON #define CONFIG_POWER_BUTTON_ACTIVE_STATE 1 #define CONFIG_POWER_COMMON diff --git a/board/kukui/board.h b/board/kukui/board.h index 76196b8a12..6e1ef13b61 100644 --- a/board/kukui/board.h +++ b/board/kukui/board.h @@ -192,6 +192,7 @@ #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO /* Define the MKBP events which are allowed to wakeup AP in S3. */ #define CONFIG_MKBP_WAKEUP_MASK \ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ diff --git a/board/nocturne/board.c b/board/nocturne/board.c index 3b170dd06f..de373e417f 100644 --- a/board/nocturne/board.c +++ b/board/nocturne/board.c @@ -402,26 +402,6 @@ void board_hibernate(void) ; } -static int mkbp_uses_gpio(void) -{ - return board_get_version() >= 2; -} - -void mkbp_set_host_active(int active) -{ - if (mkbp_uses_gpio()) - mkbp_set_host_active_via_gpio(active); - - /* - * Always send the host event for compatibility. - * On board versions 2 and newer, the firmware is configured - * to not actually trigger an SCI on MKBP events. This means that - * the EC can send host event notifications without concern for the - * board version and expect the right thing to happen. - */ - mkbp_set_host_active_via_event(active); -} - static void board_init(void) { /* Enable USB Type-C interrupts. */ diff --git a/board/nocturne/board.h b/board/nocturne/board.h index fcd9adb5fd..15464dfba7 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -86,6 +86,7 @@ /* MKBP */ #define CONFIG_MKBP_EVENT #define CONFIG_KEYBOARD_PROTOCOL_MKBP +#define CONFIG_MKBP_USE_GPIO /* Sensors */ #define CONFIG_ALS diff --git a/board/nocturne_fp/board.h b/board/nocturne_fp/board.h index 5d3807c709..82fa7805b7 100644 --- a/board/nocturne_fp/board.h +++ b/board/nocturne_fp/board.h @@ -87,6 +87,7 @@ #undef CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #define CONFIG_PRINTF_LEGACY_LI_FORMAT #define CONFIG_SHA256 #define CONFIG_SHA256_UNROLLED diff --git a/board/npcx_evb_arm/board.h b/board/npcx_evb_arm/board.h index c6c09b1c58..0b3ab503e9 100644 --- a/board/npcx_evb_arm/board.h +++ b/board/npcx_evb_arm/board.h @@ -22,6 +22,7 @@ #define CONFIG_I2C_MASTER #define CONFIG_KEYBOARD_BOARD_CONFIG #define CONFIG_KEYBOARD_PROTOCOL_MKBP /* Instead of 8042 protocol of keyboard */ +#define CONFIG_MKBP_USE_GPIO #define CONFIG_POWER_BUTTON #define CONFIG_VBOOT_HASH #define CONFIG_PWM_KBLIGHT diff --git a/board/oak/board.h b/board/oak/board.h index 3e8dbd0698..b84b852679 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -83,6 +83,7 @@ #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #define CONFIG_POWER_BUTTON #define CONFIG_POWER_COMMON #define CONFIG_USB_CHARGER diff --git a/board/rainier/board.h b/board/rainier/board.h index 7c56a8c2c7..2fc5ac63a1 100644 --- a/board/rainier/board.h +++ b/board/rainier/board.h @@ -129,6 +129,7 @@ #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO /* Define the MKBP events which are allowed to wakeup AP in S3. */ #define CONFIG_MKBP_WAKEUP_MASK \ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ diff --git a/board/rowan/board.h b/board/rowan/board.h index 839dbdf262..95f34d9e3d 100644 --- a/board/rowan/board.h +++ b/board/rowan/board.h @@ -70,6 +70,7 @@ #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #define CONFIG_POWER_BUTTON #define CONFIG_POWER_COMMON #define CONFIG_USB_CHARGER diff --git a/board/scarlet/board.h b/board/scarlet/board.h index c5698fd096..e440ef4948 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -179,6 +179,7 @@ #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO /* Define the MKBP events which are allowed to wakeup AP in S3. */ #define CONFIG_MKBP_WAKEUP_MASK \ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ diff --git a/common/mkbp_event.c b/common/mkbp_event.c index 9dddcab519..b4b163121d 100644 --- a/common/mkbp_event.c +++ b/common/mkbp_event.c @@ -33,24 +33,28 @@ static int event_is_set(uint8_t event_type) return events & (1 << event_type); } -#ifndef CONFIG_MKBP_USE_HOST_EVENT +#ifdef CONFIG_MKBP_USE_GPIO void mkbp_set_host_active_via_gpio(int active) { gpio_set_level(GPIO_EC_INT_L, !active); } #endif +#ifdef CONFIG_MKBP_USE_HOST_EVENT void mkbp_set_host_active_via_event(int active) { if (active) host_set_single_event(EC_HOST_EVENT_MKBP); } +#endif -__attribute__((weak)) void mkbp_set_host_active(int active) +void mkbp_set_host_active(int active) { -#ifdef CONFIG_MKBP_USE_HOST_EVENT +#if defined(CONFIG_MKBP_USE_CUSTOM) + mkbp_set_host_active_via_custom(active); +#elif defined(CONFIG_MKBP_USE_HOST_EVENT) mkbp_set_host_active_via_event(active); -#else +#elif defined(CONFIG_MKBP_USE_GPIO) mkbp_set_host_active_via_gpio(active); #endif } diff --git a/include/config.h b/include/config.h index 0ca81be60b..0f87f97784 100644 --- a/include/config.h +++ b/include/config.h @@ -2496,9 +2496,15 @@ /* Support MKBP event */ #undef CONFIG_MKBP_EVENT -/* MKBP events are sent using host event */ +/* MKBP events are sent by using host event */ #undef CONFIG_MKBP_USE_HOST_EVENT +/* MKBP events are sent by using GPIO */ +#undef CONFIG_MKBP_USE_GPIO + +/* MKBP events are sent by using custom method */ +#undef CONFIG_MKBP_USE_CUSTOM + /* * With this option, we can define the MKBP wakeup events in this mask (as a * white list) in board level, those events allow to interrupt AP during S3. @@ -3968,6 +3974,22 @@ #endif /******************************************************************************/ +/* MKBP events delivery methods. */ +#ifdef CONFIG_MKBP_EVENT +#if !defined(CONFIG_MKBP_USE_CUSTOM) && \ + !defined(CONFIG_MKBP_USE_HOST_EVENT) && \ + !defined(CONFIG_MKBP_USE_GPIO) +#error Please define one of CONFIG_MKBP_USE_* macro. +#endif + +#if defined(CONFIG_MKBP_USE_CUSTOM) + \ + defined(CONFIG_MKBP_USE_GPIO) + \ + defined(CONFIG_MKBP_USE_HOST_EVENT) > 1 +#error Must select only one type of MKBP event delivery method. +#endif +#endif /* CONFIG_MKBP_EVENT */ + +/******************************************************************************/ /* Set generic orientation config if a specific orientation config is set. */ #if defined(CONFIG_KX022_ORIENTATION_SENSOR) || \ defined(CONFIG_BMI160_ORIENTATION_SENSOR) diff --git a/include/mkbp_event.h b/include/mkbp_event.h index 61eb2c9052..c1f3a238dc 100644 --- a/include/mkbp_event.h +++ b/include/mkbp_event.h @@ -58,6 +58,13 @@ void mkbp_set_host_active_via_gpio(int active); void mkbp_set_host_active_via_event(int active); /* + * Communicate an MKBP event to the AP via custom method. + * + * This can be used if a board has a custom method. + */ +void mkbp_set_host_active_via_custom(int active); + +/* * The struct to store the event source definition. The get_data routine is * responsible for returning the event data when queried by the AP. The * parameter 'data' points to where the event data needs to be stored, and diff --git a/test/test_config.h b/test/test_config.h index 63cdfa6a9e..12331461e6 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -43,11 +43,13 @@ #ifdef TEST_KB_MKBP #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #endif #ifdef TEST_KB_SCAN #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_GPIO #endif #ifdef TEST_MATH_UTIL |