aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSonny Rao <sonnyrao@chromium.org>2014-08-01 01:58:00 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-08-17 10:15:43 -0400
commit99e872d953fb4484029c12dce909f514ae095d8d (patch)
tree0a0ce3736255c5a49862b5552e7c92a03fef83c6 /drivers
parent302fb1781783ded370f515e8e649b8285ee29cdc (diff)
pinctrl: rockchip: fix rk3288 gpio0 configuration
On rk3288, for gpio bank 0, the registers which configure pull-up, iomux, and drive strength don't implement the enable bits in the upper half of the register, unlike the other gpio configuration registers, and so the kernel must perform a read-modify-write of the register to update a particular gpio in that bank. The current code is actually clobbering the contents of the register, so this fixes it by using regmap_update_bits and masking out only the bits which require updating. In the case of bank0 on rk3288 the upper enable bits will just get ignored, and the other configurations won't get clobbered. Signed-off-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 5e8b2e04cd7a..0c372a300cb8 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -438,7 +438,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
438 int reg, ret, mask; 438 int reg, ret, mask;
439 unsigned long flags; 439 unsigned long flags;
440 u8 bit; 440 u8 bit;
441 u32 data; 441 u32 data, rmask;
442 442
443 if (iomux_num > 3) 443 if (iomux_num > 3)
444 return -EINVAL; 444 return -EINVAL;
@@ -478,8 +478,9 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
478 spin_lock_irqsave(&bank->slock, flags); 478 spin_lock_irqsave(&bank->slock, flags);
479 479
480 data = (mask << (bit + 16)); 480 data = (mask << (bit + 16));
481 rmask = data | (data >> 16);
481 data |= (mux & mask) << bit; 482 data |= (mux & mask) << bit;
482 ret = regmap_write(regmap, reg, data); 483 ret = regmap_update_bits(regmap, reg, rmask, data);
483 484
484 spin_unlock_irqrestore(&bank->slock, flags); 485 spin_unlock_irqrestore(&bank->slock, flags);
485 486
@@ -634,7 +635,7 @@ static int rk3288_set_drive(struct rockchip_pin_bank *bank, int pin_num,
634 struct regmap *regmap; 635 struct regmap *regmap;
635 unsigned long flags; 636 unsigned long flags;
636 int reg, ret, i; 637 int reg, ret, i;
637 u32 data; 638 u32 data, rmask;
638 u8 bit; 639 u8 bit;
639 640
640 rk3288_calc_drv_reg_and_bit(bank, pin_num, &regmap, &reg, &bit); 641 rk3288_calc_drv_reg_and_bit(bank, pin_num, &regmap, &reg, &bit);
@@ -657,9 +658,10 @@ static int rk3288_set_drive(struct rockchip_pin_bank *bank, int pin_num,
657 658
658 /* enable the write to the equivalent lower bits */ 659 /* enable the write to the equivalent lower bits */
659 data = ((1 << RK3288_DRV_BITS_PER_PIN) - 1) << (bit + 16); 660 data = ((1 << RK3288_DRV_BITS_PER_PIN) - 1) << (bit + 16);
661 rmask = data | (data >> 16);
660 data |= (ret << bit); 662 data |= (ret << bit);
661 663
662 ret = regmap_write(regmap, reg, data); 664 ret = regmap_update_bits(regmap, reg, rmask, data);
663 spin_unlock_irqrestore(&bank->slock, flags); 665 spin_unlock_irqrestore(&bank->slock, flags);
664 666
665 return ret; 667 return ret;
@@ -722,7 +724,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
722 int reg, ret; 724 int reg, ret;
723 unsigned long flags; 725 unsigned long flags;
724 u8 bit; 726 u8 bit;
725 u32 data; 727 u32 data, rmask;
726 728
727 dev_dbg(info->dev, "setting pull of GPIO%d-%d to %d\n", 729 dev_dbg(info->dev, "setting pull of GPIO%d-%d to %d\n",
728 bank->bank_num, pin_num, pull); 730 bank->bank_num, pin_num, pull);
@@ -750,6 +752,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
750 752
751 /* enable the write to the equivalent lower bits */ 753 /* enable the write to the equivalent lower bits */
752 data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16); 754 data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16);
755 rmask = data | (data >> 16);
753 756
754 switch (pull) { 757 switch (pull) {
755 case PIN_CONFIG_BIAS_DISABLE: 758 case PIN_CONFIG_BIAS_DISABLE:
@@ -770,7 +773,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
770 return -EINVAL; 773 return -EINVAL;
771 } 774 }
772 775
773 ret = regmap_write(regmap, reg, data); 776 ret = regmap_update_bits(regmap, reg, rmask, data);
774 777
775 spin_unlock_irqrestore(&bank->slock, flags); 778 spin_unlock_irqrestore(&bank->slock, flags);
776 break; 779 break;