summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-05-18 09:11:49 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-21 21:17:51 -0700
commita93ed9b9aa51736ce48fd4bee5cf7b3bae346855 (patch)
treeba97ee494c885bab06ea379a762153617f0ce2a3
parent5fb2784fc4df774bdbefd11290fd7112b6b64bb2 (diff)
downloadchrome-ec-a93ed9b9aa51736ce48fd4bee5cf7b3bae346855.tar.gz
it8320: print error message if gpio triggers are misconfigured
If a GPIO interrupt is misconifgured print out a console message. BRANCH=none BUG=b:79942824 TEST=verified messages get printed if I try to configure both on GPH6 Change-Id: Ic7156bea7c4fb2ac0bf7d717d8b812a60d5ad16a Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1066223 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Dino Li <Dino.Li@ite.com.tw>
-rw-r--r--chip/it83xx/gpio.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/chip/it83xx/gpio.c b/chip/it83xx/gpio.c
index ecfc9caf8a..e9b87fb7ad 100644
--- a/chip/it83xx/gpio.c
+++ b/chip/it83xx/gpio.c
@@ -305,11 +305,33 @@ void gpio_kbs_pin_gpio_mode(uint32_t port, uint32_t mask, uint32_t flags)
IT83XX_KBS_KSIGCTRL |= mask;
}
+/* Returns true when the falling trigger bit actually mean both trigger. */
+static int group_falling_is_both(const int group)
+{
+ return group == 7 || group == 10 || group == 12;
+}
+
+static const char *get_gpio_string(const int port, const int mask)
+{
+ static char buffer[3];
+ int i;
+
+ buffer[0] = port - GPIO_A + 'A';
+ buffer[1] = '!';
+
+ for (i = 0; i < 8; ++i) {
+ if (mask & (1 << i)) {
+ buffer[1] = i + '0';
+ break;
+ }
+ }
+ return buffer;
+}
+
void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
{
uint32_t pin = 0;
uint32_t mask_copy = mask;
- int irq;
/*
* Select open drain first, so that we don't glitch the signal
@@ -363,25 +385,22 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
mask_copy >>= 1;
}
- /* Set rising edge interrupt. */
- if (flags & GPIO_INT_F_RISING) {
- irq = gpio_to_irq(port, mask);
-
- *(wuemr(gpio_irqs[irq].wuc_group)) &= ~gpio_irqs[irq].wuc_mask;
- }
-
- /*
- * Set falling edge or both edges interrupt. Note that pins in WUC
- * groups 7, 10, and 12 can only declare a falling edge trigger. All
- * other pins can only declare both edges as the trigger.
- *
- * TODO: use an assert to catch if a developer tries to declare one
- * type of interrupt on a pin that doesn't support that type.
- */
- if (flags & GPIO_INT_F_FALLING) {
+ if (flags & (GPIO_INT_F_RISING | GPIO_INT_F_FALLING)) {
+ int irq, wuc_group, wuc_mask;
irq = gpio_to_irq(port, mask);
-
- *(wuemr(gpio_irqs[irq].wuc_group)) |= gpio_irqs[irq].wuc_mask;
+ wuc_group = gpio_irqs[irq].wuc_group;
+ wuc_mask = gpio_irqs[irq].wuc_mask;
+
+ if (flags & GPIO_INT_F_FALLING) {
+ if (!!(flags & GPIO_INT_F_RISING) !=
+ group_falling_is_both(wuc_group)) {
+ ccprintf("!!Fix GPIO %s interrupt config!!\n",
+ get_gpio_string(port, mask));
+ }
+ *(wuemr(wuc_group)) |= wuc_mask;
+ } else {
+ *(wuemr(wuc_group)) &= ~wuc_mask;
+ }
}
}