Skip to contentSkip to conversation

pinctrl: msm: Fix set gpio setting

PATCH In review Axel Lin 2 participants 2 messages Dec 13, 2013 – Dec 20, 2013 Pin control

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 pinctrl: msm: Fix set gpio setting

Set g->out_bit bit for gpio output high, clear g->out_bit bit for gpio output low.

---
Hi Bjorn,
I don't have the datasheet, just found current code does not make sense because current code unconditionally set BIT(g->out_bit) in msm_gpio_set. I assume setting g->out_bit bit for gpio output high, clear the bit for gpio output low.
Please check if this patch is correct.

Thanks,
Axel

 drivers/pinctrl/pinctrl-msm.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-msm.c +10 -2
index 28b90ab..4537d0d 100644
@@ -435,7 +435,12 @@ static int msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, in
 
 	spin_lock_irqsave(&pctrl->lock, flags);
 
-	writel(value ? BIT(g->out_bit) : 0, pctrl->regs + g->io_reg);
+	val = readl(pctrl->regs + g->io_reg);
+	if (value)
+		val |= BIT(g->out_bit);
+	else
+		val &= ~BIT(g->out_bit);
+	writel(val, pctrl->regs + g->io_reg);
 
 	val = readl(pctrl->regs + g->ctl_reg);
 	val |= BIT(g->oe_bit);
@@ -476,7 +481,10 @@ static void msm_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	spin_lock_irqsave(&pctrl->lock, flags);
 
 	val = readl(pctrl->regs + g->io_reg);
-	val |= BIT(g->out_bit);
+	if (value)
+		val |= BIT(g->out_bit);
+	else
+		val &= ~BIT(g->out_bit);
 	writel(val, pctrl->regs + g->io_reg);
 
 	spin_unlock_irqrestore(&pctrl->lock, flags);
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 11 lines · Axel Lin

Set g->out_bit bit for gpio output high, clear g->out_bit bit for gpio output low.

---
Hi Bjorn,
I don't have the datasheet, just found current code does not make sense because current code unconditionally set BIT(g->out_bit) in msm_gpio_set. I assume setting g->out_bit bit for gpio output high, clear the bit for gpio output low.
Please check if this patch is correct.

I've tentatively applied this as Björn is busy right now, and I got a sort-of-ack over IRC. If it turns out to be problematic we can revisit this later.

Yours,
Linus Walleij