]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
pinctrl/amd: fix gpio irq level in debugfs
authorDaniel Kurtz <djkurtz@chromium.org>
Tue, 17 Jul 2018 01:07:41 +0000 (19:07 -0600)
committerLinus Walleij <linus.walleij@linaro.org>
Sun, 29 Jul 2018 20:20:15 +0000 (22:20 +0200)
According to the AMD BKDG, the GPIO ActiveLevel bits (10:9) map to:
 00 Active High
 01 Active Low
 10 Active on both edges iff LevelTrig (bit 8) == 0
 11 Reserved

The current code has a bug where it interprets 00 => Active Low, and
01 => Active High.

Fix the bug, restrict "Active on both" to just the edge trigger case, and
refactor a bit to make the logic more readable.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-amd.c
drivers/pinctrl/pinctrl-amd.h

index 04ae139671c8a82c3963991c4cf0916897e3577d..5df5e8d64c57e7a9ee99e4afd896f28bc24419c7 100644 (file)
@@ -247,16 +247,16 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
                        raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
 
                        if (pin_reg & BIT(INTERRUPT_ENABLE_OFF)) {
+                               u8 level = (pin_reg >> ACTIVE_LEVEL_OFF) &
+                                               ACTIVE_LEVEL_MASK;
                                interrupt_enable = "interrupt is enabled|";
 
-                               if (!(pin_reg & BIT(ACTIVE_LEVEL_OFF)) &&
-                                   !(pin_reg & BIT(ACTIVE_LEVEL_OFF + 1)))
-                                       active_level = "Active low|";
-                               else if (pin_reg & BIT(ACTIVE_LEVEL_OFF) &&
-                                        !(pin_reg & BIT(ACTIVE_LEVEL_OFF + 1)))
+                               if (level == ACTIVE_LEVEL_HIGH)
                                        active_level = "Active high|";
-                               else if (!(pin_reg & BIT(ACTIVE_LEVEL_OFF)) &&
-                                        pin_reg & BIT(ACTIVE_LEVEL_OFF + 1))
+                               else if (level == ACTIVE_LEVEL_LOW)
+                                       active_level = "Active low|";
+                               else if (!(pin_reg & BIT(LEVEL_TRIG_OFF)) &&
+                                        level == ACTIVE_LEVEL_BOTH)
                                        active_level = "Active on both|";
                                else
                                        active_level = "Unknown Active level|";
index 8fa453a59da5e657a3cd7732171a639f6fd57d19..22af7edfdb38e82fea61bc364b5748714203eea6 100644 (file)
 #define ACTIVE_LEVEL_MASK      0x3UL
 #define DRV_STRENGTH_SEL_MASK  0x3UL
 
+#define ACTIVE_LEVEL_HIGH      0x0UL
+#define ACTIVE_LEVEL_LOW       0x1UL
+#define ACTIVE_LEVEL_BOTH      0x2UL
+
 #define DB_TYPE_NO_DEBOUNCE               0x0UL
 #define DB_TYPE_PRESERVE_LOW_GLITCH       0x1UL
 #define DB_TYPE_PRESERVE_HIGH_GLITCH      0x2UL