summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Granata <egranata@chromium.org>2018-09-28 15:51:13 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-02 05:19:35 -0700
commitd2d6f36adeab90692916b378839d71a09967fc5c (patch)
tree8fa9bc2f3281f14d70fb0dd41c80809c4aa2e3fc
parent3b4fc2b09524444b6d892c90d6c5d3150c94686a (diff)
downloadchrome-ec-d2d6f36adeab90692916b378839d71a09967fc5c.tar.gz
mkbp: add support for board-specific host notification
On Nocturne, we want to be able to decide whether MKBP events should be notified to the AP via host_set_single_event or gpio_set_level based upon runtime board-version detection instead of a static compile-time flag. Add support for this by marking the function that raises the actual IRQ to the host as weak, so that individual boards can override it with their own version. BRANCH=None BUG=b:112366846, b:112112483, b:112111610 TEST=see CL:1161546 for details Signed-off-by: Enrico Granata <egranata@chromium.org> Change-Id: Ide5ec12fbc6fea3cf23069f376066f225e1887b3 Reviewed-on: https://chromium-review.googlesource.com/1247000 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
-rw-r--r--common/mkbp_event.c30
-rw-r--r--include/mkbp_event.h3
2 files changed, 26 insertions, 7 deletions
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index 40a6e21066..08e88f287e 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -33,6 +33,28 @@ static int event_is_set(uint8_t event_type)
return events & (1 << event_type);
}
+#ifndef CONFIG_MKBP_USE_HOST_EVENT
+void send_mkbp_event_gpio(int active)
+{
+ gpio_set_level(GPIO_EC_INT_L, !active);
+}
+#endif
+
+void send_mkbp_event_host(int active)
+{
+ if (active)
+ host_set_single_event(EC_HOST_EVENT_MKBP);
+}
+
+__attribute__((weak)) void send_mkbp_event(int active)
+{
+#ifdef CONFIG_MKBP_USE_HOST_EVENT
+ send_mkbp_event_host(active);
+#else
+ send_mkbp_event_gpio(active);
+#endif
+}
+
/**
* Assert host keyboard interrupt line.
*/
@@ -45,13 +67,7 @@ static void set_host_interrupt(int active)
if (old_active == 0 && active == 1)
mkbp_last_event_time = __hw_clock_source_read();
- /* interrupt host by using active low EC_INT signal */
-#ifdef CONFIG_MKBP_USE_HOST_EVENT
- if (active)
- host_set_single_event(EC_HOST_EVENT_MKBP);
-#else
- gpio_set_level(GPIO_EC_INT_L, !active);
-#endif
+ send_mkbp_event(active);
old_active = active;
interrupt_enable();
diff --git a/include/mkbp_event.h b/include/mkbp_event.h
index 3764c40d5b..3639ffb326 100644
--- a/include/mkbp_event.h
+++ b/include/mkbp_event.h
@@ -28,6 +28,9 @@ extern uint32_t mkbp_last_event_time;
*/
int mkbp_send_event(uint8_t event_type);
+void send_mkbp_event_gpio(int active);
+void send_mkbp_event_host(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