diff options
author | Eric Ernst <eric.ernst@linux.intel.com> | 2014-06-12 14:06:20 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-07-11 08:08:35 -0400 |
commit | ff998356b644ebe723127bd9eec6040b59a4a4f6 (patch) | |
tree | 33f8f7087d5a77afaf99533dd4be2790b6325e5f /drivers/pinctrl | |
parent | 1f978217a0c687a4cfed6ad698a3173826be4c3f (diff) |
pinctrl: baytrail: Warn if direct IRQ GPIO set to output
For Baytrail, you should never set a GPIO set to direct_irq
to output mode. When direct_irq_en is set for a GPIO, it is
tied directly to an APIC internally, and making the pad output
does not make any sense. Assert a WARN() in the event this happens.
Signed-off-by: Eric Ernst <eric.ernst@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-baytrail.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c index 975572e2f260..701a646a3d10 100644 --- a/drivers/pinctrl/pinctrl-baytrail.c +++ b/drivers/pinctrl/pinctrl-baytrail.c | |||
@@ -44,6 +44,7 @@ | |||
44 | 44 | ||
45 | /* BYT_CONF0_REG register bits */ | 45 | /* BYT_CONF0_REG register bits */ |
46 | #define BYT_IODEN BIT(31) | 46 | #define BYT_IODEN BIT(31) |
47 | #define BYT_DIRECT_IRQ_EN BIT(27) | ||
47 | #define BYT_TRIG_NEG BIT(26) | 48 | #define BYT_TRIG_NEG BIT(26) |
48 | #define BYT_TRIG_POS BIT(25) | 49 | #define BYT_TRIG_POS BIT(25) |
49 | #define BYT_TRIG_LVL BIT(24) | 50 | #define BYT_TRIG_LVL BIT(24) |
@@ -303,12 +304,22 @@ static int byt_gpio_direction_output(struct gpio_chip *chip, | |||
303 | unsigned gpio, int value) | 304 | unsigned gpio, int value) |
304 | { | 305 | { |
305 | struct byt_gpio *vg = to_byt_gpio(chip); | 306 | struct byt_gpio *vg = to_byt_gpio(chip); |
307 | void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG); | ||
306 | void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG); | 308 | void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG); |
307 | unsigned long flags; | 309 | unsigned long flags; |
308 | u32 reg_val; | 310 | u32 reg_val; |
309 | 311 | ||
310 | spin_lock_irqsave(&vg->lock, flags); | 312 | spin_lock_irqsave(&vg->lock, flags); |
311 | 313 | ||
314 | /* | ||
315 | * Before making any direction modifications, do a check if gpio | ||
316 | * is set for direct IRQ. On baytrail, setting GPIO to output does | ||
317 | * not make sense, so let's at least warn the caller before they shoot | ||
318 | * themselves in the foot. | ||
319 | */ | ||
320 | WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN, | ||
321 | "Potential Error: Setting GPIO with direct_irq_en to output"); | ||
322 | |||
312 | reg_val = readl(reg) | BYT_DIR_MASK; | 323 | reg_val = readl(reg) | BYT_DIR_MASK; |
313 | reg_val &= ~BYT_OUTPUT_EN; | 324 | reg_val &= ~BYT_OUTPUT_EN; |
314 | 325 | ||