From patchwork Sun Feb 23 14:21:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3704101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4FEA89F370 for ; Sun, 23 Feb 2014 14:27:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BE18201BF for ; Sun, 23 Feb 2014 14:27:20 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1250020172 for ; Sun, 23 Feb 2014 14:27:19 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZzc-0004Lg-I9; Sun, 23 Feb 2014 14:25:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZyX-0001xG-TZ; Sun, 23 Feb 2014 14:24:14 +0000 Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZwI-0001hj-97 for linux-arm-kernel@lists.infradead.org; Sun, 23 Feb 2014 14:22:10 +0000 Received: by mail-ee0-f46.google.com with SMTP id d49so209576eek.5 for ; Sun, 23 Feb 2014 06:21:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hb0mVerIw/Oy+rvD0XozJ5gIEQMeO+2luHTqFftnFDw=; b=EUwIzhwZrP28hIittWfmQ7ur/JsxXMDbqNQ4mbK+OxiuReFq3xlAtVTaC8Uqr6ZtZT PvjhNSe5tzQ8lYvaphd/xJjZpqApQw6zRzJ0TaDD1/5f2NlKk74GwUDa2bmIK69T3ZIh +GRUOdLUJ4qdTtClILgLpqS8TVq7Drf/YhlYvwIow+8bOi0+dgzbQC+aucOiwM87FNbf yq86h5oDYPHHIWR5/YQVL2FfKCC/aDkVp6fs/tOLwl1463eMRA2382oD3axqbXv2kk/k e0k16qwg2q0ubNC19YlvEGdcNN5d8Vl6tAH5QK9f5siVQeV1i3AKlUXy6Ee/GVsIDa8i vVYg== X-Received: by 10.15.26.199 with SMTP id n47mr19732756eeu.30.1393165292184; Sun, 23 Feb 2014 06:21:32 -0800 (PST) Received: from topkick.lan (dslc-082-083-251-183.pools.arcor-ip.net. [82.83.251.183]) by mx.google.com with ESMTPSA id k6sm51639933eep.17.2014.02.23.06.21.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2014 06:21:31 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v4 16/16] pinctrl: mvebu: dove: reuse mpp_{set, get} in pmu callbacks Date: Sun, 23 Feb 2014 15:21:14 +0100 Message-Id: <1393165274-32492-17-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1393165274-32492-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1392220776-30851-1-git-send-email-sebastian.hesselbarth@gmail.com> <1393165274-32492-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140223_092154_548319_CDC72FDE X-CRM114-Status: GOOD ( 10.91 ) X-Spam-Score: -2.0 (--) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Linus Walleij , linux-kernel@vger.kernel.org, Ezequiel Garcia , Gregory Clement , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dove has pins that can be switched between normal and pmu functions. Rework pmu_mpp callbacks to reuse default mpp ctrl helpers. Signed-off-by: Sebastian Hesselbarth --- Changelog: v3->v4: - directly use generic mpp helpers instead of normal dove mpp functions Cc: Linus Walleij Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Thomas Petazzoni Cc: Ezequiel Garcia Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pinctrl/mvebu/pinctrl-dove.c | 37 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 89fd3a5a1df1..da9ca26360fd 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c @@ -70,14 +70,13 @@ static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long func; - if (pmu & (1 << pid)) { - func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); - *config = (func >> shift) & MVEBU_MPP_MASK; - *config |= CONFIG_PMU; - } else { - func = readl(DOVE_MPP_VIRT_BASE + off); - *config = (func >> shift) & MVEBU_MPP_MASK; - } + if ((pmu & BIT(pid)) == 0) + return default_mpp_ctrl_get(mpp_base, pid, config); + + func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); + *config = (func >> shift) & MVEBU_MPP_MASK; + *config |= CONFIG_PMU; + return 0; } @@ -88,19 +87,17 @@ static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long func; - if (config & CONFIG_PMU) { - writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); - func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); - func &= ~(MVEBU_MPP_MASK << shift); - func |= (config & MVEBU_MPP_MASK) << shift; - writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); - } else { - writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); - func = readl(DOVE_MPP_VIRT_BASE + off); - func &= ~(MVEBU_MPP_MASK << shift); - func |= (config & MVEBU_MPP_MASK) << shift; - writel(func, DOVE_MPP_VIRT_BASE + off); + if ((config & CONFIG_PMU) == 0) { + writel(pmu & ~BIT(pid), DOVE_PMU_MPP_GENERAL_CTRL); + return default_mpp_ctrl_set(mpp_base, pid, config); } + + writel(pmu | BIT(pid), DOVE_PMU_MPP_GENERAL_CTRL); + func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); + func &= ~(MVEBU_MPP_MASK << shift); + func |= (config & MVEBU_MPP_MASK) << shift; + writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); + return 0; }