* [PATCH v2 1/1] PINCTRL: Warn if direct IRQ GPIO set to output
[not found] <0140602191416.GD1730@lahna.fi.intel.com>
@ 2014-06-02 21:12 ` eric.ernst
2014-06-03 11:06 ` Mika Westerberg
2014-06-03 12:49 ` [PATCH v2 1/1] PINCTRL: " Mika Westerberg
0 siblings, 2 replies; 10+ messages in thread
From: eric.ernst @ 2014-06-02 21:12 UTC (permalink / raw)
To: linus.walleij, linux-kernel, mark.gross, mika.westerberg; +Cc: eric.ernst
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 | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index e59983423991..fde3767df254 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,29 @@ 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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] PINCTRL: Warn if direct IRQ GPIO set to output
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 ` [PATCH v3 1/1] pinctrl: baytrail: " eric.ernst
2014-06-03 12:49 ` [PATCH v2 1/1] PINCTRL: " Mika Westerberg
1 sibling, 1 reply; 10+ messages in thread
From: Mika Westerberg @ 2014-06-03 11:06 UTC (permalink / raw)
To: eric.ernst; +Cc: linus.walleij, linux-kernel, mark.gross
On Mon, Jun 02, 2014 at 02:12:07PM -0700, eric.ernst@linux.intel.com wrote:
> 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.
Subject should probably be:
pinctrl: baytrail: Warn if direct IRQ GPIO is set to output
> Signed-off-by: Eric Ernst <eric.ernst@linux.intel.com>
> ---
> drivers/pinctrl/pinctrl-baytrail.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
> index e59983423991..fde3767df254 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)
Please move this definition to be first, like:
/* BYT_CONF0_REG register bits */
#define BYT_DIRECT_IRQ_EN BIT(27)
#define BYT_TRIG_NEG BIT(26)
#define BYT_TRIG_POS BIT(25)
and I would call it BYT_DIRECT_IRQ_EN since it's name in datasheet is
"direct_irq_en".
>
> /* BYT_VAL_REG register bits */
> #define BYT_INPUT_EN BIT(2) /* 0: input enabled (active low)*/
> @@ -256,19 +257,29 @@ 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);
Not sure if it is necessary to rename reg -> value_reg. It just makes
the patch bigger than it has to be since you also need to rename stuff
below.
Otherwise looks good.
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] PINCTRL: Warn if direct IRQ GPIO set to output
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 12:49 ` Mika Westerberg
1 sibling, 0 replies; 10+ messages in thread
From: Mika Westerberg @ 2014-06-03 12:49 UTC (permalink / raw)
To: eric.ernst; +Cc: linus.walleij, linux-kernel, mark.gross
On Mon, Jun 02, 2014 at 02:12:07PM -0700, eric.ernst@linux.intel.com wrote:
> + WARN((readl(conf_reg) & BYT_DIRECTIRQ),
> + "Potential Error: Setting GPIO with direct_irq_en to output");
Also you don't need parentheses here.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
2014-06-03 11:06 ` Mika Westerberg
@ 2014-06-03 22:25 ` eric.ernst
2014-06-04 8:22 ` Mika Westerberg
2014-06-12 7:49 ` Linus Walleij
0 siblings, 2 replies; 10+ messages in thread
From: eric.ernst @ 2014-06-03 22:25 UTC (permalink / raw)
To: linus.walleij, linux-kernel, mark.gross, mika.westerberg; +Cc: eric.ernst
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
2014-06-03 22:25 ` [PATCH v3 1/1] pinctrl: baytrail: " eric.ernst
@ 2014-06-04 8:22 ` Mika Westerberg
2014-06-12 7:49 ` Linus Walleij
1 sibling, 0 replies; 10+ messages in thread
From: Mika Westerberg @ 2014-06-04 8:22 UTC (permalink / raw)
To: eric.ernst; +Cc: linus.walleij, linux-kernel, mark.gross
On Tue, Jun 03, 2014 at 03:25:16PM -0700, eric.ernst@linux.intel.com wrote:
> 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>
Looks good now thanks,
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
2014-06-03 22:25 ` [PATCH v3 1/1] pinctrl: baytrail: " eric.ernst
2014-06-04 8:22 ` Mika Westerberg
@ 2014-06-12 7:49 ` Linus Walleij
2014-06-12 18:06 ` [PATCH v4 " eric.ernst
1 sibling, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2014-06-12 7:49 UTC (permalink / raw)
To: eric.ernst; +Cc: linux-kernel, Mark Gross, Mika Westerberg
On Wed, Jun 4, 2014 at 12:25 AM, <eric.ernst@linux.intel.com> wrote:
> 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>
This does not apply to my devel branch or Torvald's HEAD.
Please rebase and repost, and include Mika's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
2014-06-12 7:49 ` Linus Walleij
@ 2014-06-12 18:06 ` eric.ernst
2014-07-07 10:19 ` Linus Walleij
2014-07-07 21:14 ` Linus Walleij
0 siblings, 2 replies; 10+ messages in thread
From: eric.ernst @ 2014-06-12 18:06 UTC (permalink / raw)
To: linus.walleij, linux-kernel, mark.gross, mika.westerberg; +Cc: eric.ernst
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>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/pinctrl/pinctrl-baytrail.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index 975572e2f260..c34add934216 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -303,12 +303,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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
2014-06-12 18:06 ` [PATCH v4 " eric.ernst
@ 2014-07-07 10:19 ` Linus Walleij
2014-07-07 21:14 ` Linus Walleij
1 sibling, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2014-07-07 10:19 UTC (permalink / raw)
To: eric.ernst; +Cc: linux-kernel, Mark Gross, Mika Westerberg
On Thu, Jun 12, 2014 at 8:06 PM, <eric.ernst@linux.intel.com> wrote:
> 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>
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Patch applied.
Sorry for the delay.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
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
1 sibling, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2014-07-07 21:14 UTC (permalink / raw)
To: eric.ernst; +Cc: linux-kernel, Mark Gross, Mika Westerberg
On Thu, Jun 12, 2014 at 8:06 PM, <eric.ernst@linux.intel.com> wrote:
> + WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN,
> + "Potential Error: Setting GPIO with direct_irq_en to output");
Hm in the v4 version you somehow managed to drop the definition
of BYT_DIRECT_IRQ_EN...
I patched it back in. Let's hope it compiles now.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/1] pinctrl: baytrail: Warn if direct IRQ GPIO set to output
2014-07-07 21:14 ` Linus Walleij
@ 2014-07-09 0:33 ` eric ernst
0 siblings, 0 replies; 10+ messages in thread
From: eric ernst @ 2014-07-09 0:33 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-kernel, Mark Gross, Mika Westerberg
Mea culpa - thanks Linus. I saw a note from kbuild test
robot indicating an issue, but given your response, I am
assuming it was from your first build attempt. Thanks.
On 14-07-07 02:14 PM, Linus Walleij wrote:
> On Thu, Jun 12, 2014 at 8:06 PM, <eric.ernst@linux.intel.com> wrote:
>
>> + WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN,
>> + "Potential Error: Setting GPIO with direct_irq_en to output");
> Hm in the v4 version you somehow managed to drop the definition
> of BYT_DIRECT_IRQ_EN...
>
> I patched it back in. Let's hope it compiles now.
>
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-07-09 0:36 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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 ` [PATCH v3 1/1] pinctrl: baytrail: " eric.ernst
2014-06-04 8:22 ` 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
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.