All of lore.kernel.org
 help / color / mirror / Atom feed
From: eric.ernst@linux.intel.com
To: linus.walleij@linaro.org, linux-kernel@vger.kernel.org,
	mark.gross@intel.com, mika.westerberg@linux.intel.com
Cc: eric.ernst@linux.intel.com
Subject: [PATCH v3 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
Date: Tue,  3 Jun 2014 15:25:16 -0700	[thread overview]
Message-ID: <1401834316-199359-1-git-send-email-eric.ernst@linux.intel.com> (raw)
In-Reply-To: <20140603110600.GG1730@lahna.fi.intel.com>

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 |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index e59983423991..7f0a2bac7c82 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -43,6 +43,7 @@
 #define BYT_INT_STAT_REG	0x800
 
 /* BYT_CONF0_REG register bits */
+#define BYT_DIRECT_IRQ_EN	BIT(27)
 #define BYT_TRIG_NEG		BIT(26)
 #define BYT_TRIG_POS		BIT(25)
 #define BYT_TRIG_LVL		BIT(24)
@@ -256,12 +257,22 @@ static int byt_gpio_direction_output(struct gpio_chip *chip,
 				     unsigned gpio, int value)
 {
 	struct byt_gpio *vg = to_byt_gpio(chip);
+	void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG);
 	void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG);
 	unsigned long flags;
 	u32 reg_val;
 
 	spin_lock_irqsave(&vg->lock, flags);
 
+	/*
+	 * 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_DIRECT_IRQ_EN,
+		"Potential Error: Setting GPIO with direct_irq_en to output");
+
 	reg_val = readl(reg) | BYT_DIR_MASK;
 	reg_val &= ~BYT_OUTPUT_EN;
 
-- 
1.7.9.5


  reply	other threads:[~2014-06-03 22:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0140602191416.GD1730@lahna.fi.intel.com>
2014-06-02 21:12 ` [PATCH v2 1/1] PINCTRL: Warn if direct IRQ GPIO set to output eric.ernst
2014-06-03 11:06   ` Mika Westerberg
2014-06-03 22:25     ` eric.ernst [this message]
2014-06-04  8:22       ` [PATCH v3 1/1] pinctrl: baytrail: " Mika Westerberg
2014-06-12  7:49       ` Linus Walleij
2014-06-12 18:06         ` [PATCH v4 " eric.ernst
2014-07-07 10:19           ` Linus Walleij
2014-07-07 21:14           ` Linus Walleij
2014-07-09  0:33             ` eric ernst
2014-06-03 12:49   ` [PATCH v2 1/1] PINCTRL: " 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=1401834316-199359-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 \
    --cc=mika.westerberg@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.