aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2014-03-25 19:57:00 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-04-14 03:39:33 -0400
commit14797189b35e9ec4344eeb75bdca4120cba88b69 (patch)
tree050b2d80aca96113b66bef6d1a0da03a692736a6 /drivers/pinctrl
parent22c0d7e36f74352f7b80679003bf7edf85736b2b (diff)
pinctrl: rockchip: add return value to rockchip_set_mux
In a following change, rockchip_set_mux gets the possibility to fail. Therefore add a return value to it and honor error codes in functions using rockchip_set_mux. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 23e8812d3115..2ac194370b73 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -342,7 +342,7 @@ static const struct pinctrl_ops rockchip_pctrl_ops = {
342 * @pin: pin to change 342 * @pin: pin to change
343 * @mux: new mux function to set 343 * @mux: new mux function to set
344 */ 344 */
345static void rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) 345static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
346{ 346{
347 struct rockchip_pinctrl *info = bank->drvdata; 347 struct rockchip_pinctrl *info = bank->drvdata;
348 void __iomem *reg = info->reg_base + info->ctrl->mux_offset; 348 void __iomem *reg = info->reg_base + info->ctrl->mux_offset;
@@ -365,6 +365,8 @@ static void rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
365 writel(data, reg); 365 writel(data, reg);
366 366
367 spin_unlock_irqrestore(&bank->slock, flags); 367 spin_unlock_irqrestore(&bank->slock, flags);
368
369 return 0;
368} 370}
369 371
370#define RK2928_PULL_OFFSET 0x118 372#define RK2928_PULL_OFFSET 0x118
@@ -560,7 +562,7 @@ static int rockchip_pmx_enable(struct pinctrl_dev *pctldev, unsigned selector,
560 const unsigned int *pins = info->groups[group].pins; 562 const unsigned int *pins = info->groups[group].pins;
561 const struct rockchip_pin_config *data = info->groups[group].data; 563 const struct rockchip_pin_config *data = info->groups[group].data;
562 struct rockchip_pin_bank *bank; 564 struct rockchip_pin_bank *bank;
563 int cnt; 565 int cnt, ret = 0;
564 566
565 dev_dbg(info->dev, "enable function %s group %s\n", 567 dev_dbg(info->dev, "enable function %s group %s\n",
566 info->functions[selector].name, info->groups[group].name); 568 info->functions[selector].name, info->groups[group].name);
@@ -571,8 +573,18 @@ static int rockchip_pmx_enable(struct pinctrl_dev *pctldev, unsigned selector,
571 */ 573 */
572 for (cnt = 0; cnt < info->groups[group].npins; cnt++) { 574 for (cnt = 0; cnt < info->groups[group].npins; cnt++) {
573 bank = pin_to_bank(info, pins[cnt]); 575 bank = pin_to_bank(info, pins[cnt]);
574 rockchip_set_mux(bank, pins[cnt] - bank->pin_base, 576 ret = rockchip_set_mux(bank, pins[cnt] - bank->pin_base,
575 data[cnt].func); 577 data[cnt].func);
578 if (ret)
579 break;
580 }
581
582 if (ret) {
583 /* revert the already done pin settings */
584 for (cnt--; cnt >= 0; cnt--)
585 rockchip_set_mux(bank, pins[cnt] - bank->pin_base, 0);
586
587 return ret;
576 } 588 }
577 589
578 return 0; 590 return 0;
@@ -607,7 +619,7 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
607 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 619 struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
608 struct rockchip_pin_bank *bank; 620 struct rockchip_pin_bank *bank;
609 struct gpio_chip *chip; 621 struct gpio_chip *chip;
610 int pin; 622 int pin, ret;
611 u32 data; 623 u32 data;
612 624
613 chip = range->gc; 625 chip = range->gc;
@@ -617,7 +629,9 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
617 dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n", 629 dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
618 offset, range->name, pin, input ? "input" : "output"); 630 offset, range->name, pin, input ? "input" : "output");
619 631
620 rockchip_set_mux(bank, pin, RK_FUNC_GPIO); 632 ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO);
633 if (ret < 0)
634 return ret;
621 635
622 data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); 636 data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR);
623 /* set bit to 1 for output, 0 for input */ 637 /* set bit to 1 for output, 0 for input */
@@ -1144,9 +1158,13 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
1144 u32 polarity; 1158 u32 polarity;
1145 u32 level; 1159 u32 level;
1146 u32 data; 1160 u32 data;
1161 int ret;
1147 1162
1148 /* make sure the pin is configured as gpio input */ 1163 /* make sure the pin is configured as gpio input */
1149 rockchip_set_mux(bank, d->hwirq, RK_FUNC_GPIO); 1164 ret = rockchip_set_mux(bank, d->hwirq, RK_FUNC_GPIO);
1165 if (ret < 0)
1166 return ret;
1167
1150 data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); 1168 data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR);
1151 data &= ~mask; 1169 data &= ~mask;
1152 writel_relaxed(data, bank->reg_base + GPIO_SWPORT_DDR); 1170 writel_relaxed(data, bank->reg_base + GPIO_SWPORT_DDR);