diff options
author | Yilun Lin <yllin@google.com> | 2019-02-25 19:05:32 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-10 23:13:37 +0000 |
commit | a16638995b503e0444e403d350831b36a1941ef4 (patch) | |
tree | f66628474dd6b8509399aad8457b35a0a6bf908e | |
parent | eb8f1c18f9f2962a2990d7258e0f972118134fa7 (diff) | |
download | chrome-ec-a16638995b503e0444e403d350831b36a1941ef4.tar.gz |
BACKPORT: 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=rammus
BUG=b:120808999,b:139001152
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.
Conflicts: octupus boards not updated.
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>
(cherry picked from commit 8b1b74c10a87c8477bc65b7be1f6943676bd56bb)
Change-Id: I4af6110e4fd3c009968075c3623ef2d91cbd770b
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1776337
-rw-r--r-- | board/aleena/board.h | 2 | ||||
-rw-r--r-- | board/cheza/board.h | 1 | ||||
-rw-r--r-- | board/elm/board.h | 1 | ||||
-rw-r--r-- | board/jerry/board.h | 1 | ||||
-rw-r--r-- | board/kukui/board.h | 1 | ||||
-rw-r--r-- | board/meowth_fp/board.h | 1 | ||||
-rw-r--r-- | board/nocturne/board.c | 20 | ||||
-rw-r--r-- | board/nocturne/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 |
17 files changed, 53 insertions, 25 deletions
diff --git a/board/aleena/board.h b/board/aleena/board.h index 12e6869821..7756d5b181 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 + #ifndef __ASSEMBLER__ enum pwm_channel { diff --git a/board/cheza/board.h b/board/cheza/board.h index 4fce7868fe..cb1bd0a068 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/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 276bb0f1ea..2dc8daa64d 100644 --- a/board/kukui/board.h +++ b/board/kukui/board.h @@ -191,6 +191,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/meowth_fp/board.h b/board/meowth_fp/board.h index 5d3807c709..82fa7805b7 100644 --- a/board/meowth_fp/board.h +++ b/board/meowth_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/nocturne/board.c b/board/nocturne/board.c index ffa8c65920..31ebebd4e8 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 63c409678b..83770875bb 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/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 1c5e9b6a03..957c679a75 100644 --- a/board/rainier/board.h +++ b/board/rainier/board.h @@ -128,6 +128,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 d6110c5ba3..74fc1ae2b2 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -180,6 +180,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 c1f1457c21..709e7e5e74 100644 --- a/include/config.h +++ b/include/config.h @@ -2441,9 +2441,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. @@ -3888,6 +3894,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 1dfe0a2ffd..a27da10187 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 |