From: eric.ernst@linux.intel.com
To: linus.walleij@linaro.org, linux-kernel@vger.kernel.org,
mark.gross@intel.com
Cc: eric.ernst@linux.intel.com
Subject: [PATCH 1/1] PINCTRL: Warn if direct IRQ GPIO set to output
Date: Tue, 27 May 2014 12:26:44 -0700 [thread overview]
Message-ID: <1401218804-77997-1-git-send-email-eric.ernst@linux.intel.com> (raw)
From: Eric Ernst <eric.ernst@linux.intel.com>
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>
---
drivers/pinctrl/pinctrl-baytrail.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index e59983423991..677f79a9efca 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -47,6 +47,7 @@
#define BYT_TRIG_POS BIT(25)
#define BYT_TRIG_LVL BIT(24)
#define BYT_PIN_MUX 0x07
+#define BYT_DIRECTIRQ BIT(27)
/* BYT_VAL_REG register bits */
#define BYT_INPUT_EN BIT(2) /* 0: input enabled (active low)*/
@@ -256,19 +257,26 @@ static int byt_gpio_direction_output(struct gpio_chip *chip,
unsigned gpio, int value)
{
struct byt_gpio *vg = to_byt_gpio(chip);
- void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG);
+ void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG);
+ void __iomem *value_reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG);
unsigned long flags;
u32 reg_val;
spin_lock_irqsave(&vg->lock, flags);
- reg_val = readl(reg) | BYT_DIR_MASK;
+ /* Before making any direction modifications, do a check if gpio
+ is set for direct IRQ. On baytrail, setting GPIO to output does
+ not make sense, so let's at least warn the caller before they shoot
+ themselves in the foot */
+ WARN((readl(conf_reg) & BYT_DIRECTIRQ), "Potential Error: Setting GPIO with direct_irq_en to output");
+
+ reg_val = readl(value_reg) | BYT_DIR_MASK;
reg_val &= ~BYT_OUTPUT_EN;
if (value)
- writel(reg_val | BYT_LEVEL, reg);
+ writel(reg_val | BYT_LEVEL, value_reg);
else
- writel(reg_val & ~BYT_LEVEL, reg);
+ writel(reg_val & ~BYT_LEVEL, value_reg);
spin_unlock_irqrestore(&vg->lock, flags);
--
1.7.9.5
next reply other threads:[~2014-05-27 19:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-27 19:26 eric.ernst [this message]
2014-05-29 13:44 ` [PATCH 1/1] PINCTRL: Warn if direct IRQ GPIO set to output Linus Walleij
2014-05-29 21:57 ` eric ernst
2014-05-30 8:48 ` Mika Westerberg
2014-06-02 18:35 ` eric ernst
2014-06-02 19:13 ` Mika Westerberg
2014-06-02 19:14 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401218804-77997-1-git-send-email-eric.ernst@linux.intel.com \
--to=eric.ernst@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.gross@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox