From patchwork Sun Jun 26 05:21:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9199071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 198B060754 for ; Sun, 26 Jun 2016 05:23:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B4A928514 for ; Sun, 26 Jun 2016 05:23:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F406C2852D; Sun, 26 Jun 2016 05:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, SUSPICIOUS_RECIPS, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BCB5D28514 for ; Sun, 26 Jun 2016 05:23:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bH2WF-00053C-DC; Sun, 26 Jun 2016 05:22:07 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bH2W5-00050B-HP for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2016 05:21:58 +0000 Received: by mail-pa0-x22a.google.com with SMTP id bz2so49062943pad.1 for ; Sat, 25 Jun 2016 22:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=irvV5lv4ZjiHCLSfEFgwnbBdlpUKjFiTgem8JTWzp20=; b=NzPH5vSRUsQWX7PfTGt7cyy6ai2IZ9RpjuuZuIBGzCqeqDWIzktimLUEm3NHv8rOi0 mshCTk3uHUJjcam7p8tr58+sYz/SaSQzIu3z5hGoOm0D9wPojXsucMUWc3BkHpWvdSKQ u89XPCnbSLjqW2tnooqBtz8SkmjN9ad4IvYFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=irvV5lv4ZjiHCLSfEFgwnbBdlpUKjFiTgem8JTWzp20=; b=UmY77OeLA3h7PMIU0cdu2cXNvV5sT49tOvuS3CO4Bul/UPwghwmV5iyHxnxK1Xx1zl HIjMAqgQYWT+NLQpSTlwZto/EwPGHc/dh7lXn1MQDMBRzccuWc2+5208QeIZ+/SUYAjV Z303Kn9xlxHkWcjtHRv0ewoklymaftXpNRRunDJF96fa2nrTVn4YVS0jZD3pRBNGM+Z/ fE8fDdIH20q+gSWKfI6sjOzpvMAtTYFgHWUORxtcT5W5Qy698vmPqu/cwdQxO8j6aro5 0e3A1s8vxSDZHTT7jj2wCIIJnJFXjEXu2h4BkhoPxKPLIr7vu10sbtJfHH9IJ+zPaZ4O Vsxg== X-Gm-Message-State: ALyK8tKHuAh5MtkT3LjRBM1QZCR23vac/lrdH/38LExVXOaFSvEH+M5lH3Oa0BAf61MaUDQh X-Received: by 10.66.66.108 with SMTP id e12mr22039189pat.95.1466918496281; Sat, 25 Jun 2016 22:21:36 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id v126sm3033700pfb.60.2016.06.25.22.21.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Jun 2016 22:21:35 -0700 (PDT) From: Stephen Boyd To: Linus Walleij Subject: [PATCH 1/2] pinctrl: qcom: Clear all function selection bits Date: Sat, 25 Jun 2016 22:21:31 -0700 Message-Id: <20160626052132.7178-2-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160626052132.7178-1-stephen.boyd@linaro.org> References: <20160626052132.7178-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160625_222157_626405_BC1AF25A X-CRM114-Status: GOOD ( 12.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Stephen Boyd --- drivers/pinctrl/qcom/pinctrl-msm.c | 6 ++++-- 1 file 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 @@ #include #include #include +#include #include "../core.h" #include "../pinconf.h" @@ -138,10 +139,11 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); const struct msm_pingroup *g; unsigned long flags; - u32 val; + u32 val, mask; int i; g = &pctrl->soc->groups[group]; + mask = GENMASK(g->mux_bit + order_base_2(g->nfuncs) - 1, g->mux_bit); for (i = 0; i < g->nfuncs; i++) { if (g->funcs[i] == function) @@ -154,7 +156,7 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev, spin_lock_irqsave(&pctrl->lock, flags); val = readl(pctrl->regs + g->ctl_reg); - val &= ~(0x7 << g->mux_bit); + val &= mask; val |= i << g->mux_bit; writel(val, pctrl->regs + g->ctl_reg);