aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <stephen.boyd@linaro.org>2016-06-26 01:21:31 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-06-29 04:13:44 -0400
commit47a01ee9a6c39fe1f5b14f5d88f6591baeb03e95 (patch)
tree3bf755410b9a02b7f760359b1061d9afaa0a7128
parentcdd5b3485cd59cb7d9004874d2ac99522da5e624 (diff)
pinctrl: qcom: Clear all function selection bits
The function selection bitfield is not always 3 bits wide. Sometimes it is 4 bits wide. Let's use the npins struct member to determine how many bits wide the function selection bitfield is so we clear the correct amount of bits in the register while remuxing the pins. Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/qcom/pinctrl-msm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 1a44e1d03390..51c42d746883 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -29,6 +29,7 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/reboot.h> 30#include <linux/reboot.h>
31#include <linux/pm.h> 31#include <linux/pm.h>
32#include <linux/log2.h>
32 33
33#include "../core.h" 34#include "../core.h"
34#include "../pinconf.h" 35#include "../pinconf.h"
@@ -138,10 +139,11 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev,
138 struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 139 struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
139 const struct msm_pingroup *g; 140 const struct msm_pingroup *g;
140 unsigned long flags; 141 unsigned long flags;
141 u32 val; 142 u32 val, mask;
142 int i; 143 int i;
143 144
144 g = &pctrl->soc->groups[group]; 145 g = &pctrl->soc->groups[group];
146 mask = GENMASK(g->mux_bit + order_base_2(g->nfuncs) - 1, g->mux_bit);
145 147
146 for (i = 0; i < g->nfuncs; i++) { 148 for (i = 0; i < g->nfuncs; i++) {
147 if (g->funcs[i] == function) 149 if (g->funcs[i] == function)
@@ -154,7 +156,7 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev,
154 spin_lock_irqsave(&pctrl->lock, flags); 156 spin_lock_irqsave(&pctrl->lock, flags);
155 157
156 val = readl(pctrl->regs + g->ctl_reg); 158 val = readl(pctrl->regs + g->ctl_reg);
157 val &= ~(0x7 << g->mux_bit); 159 val &= mask;
158 val |= i << g->mux_bit; 160 val |= i << g->mux_bit;
159 writel(val, pctrl->regs + g->ctl_reg); 161 writel(val, pctrl->regs + g->ctl_reg);
160 162