From patchwork Tue Jan 28 00:39:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3544371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45372C02DC for ; Tue, 28 Jan 2014 00:40:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E9FC200F2 for ; Tue, 28 Jan 2014 00:40:57 +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 6495C200E9 for ; Tue, 28 Jan 2014 00:40:56 +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 1W7wj8-0008B8-It; Tue, 28 Jan 2014 00:40:31 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W7wj0-0006Dc-4w; Tue, 28 Jan 2014 00:40:22 +0000 Received: from mail-ea0-x22a.google.com ([2a00:1450:4013:c01::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W7wii-00069K-Da for linux-arm-kernel@lists.infradead.org; Tue, 28 Jan 2014 00:40:05 +0000 Received: by mail-ea0-f170.google.com with SMTP id k10so2655256eaj.1 for ; Mon, 27 Jan 2014 16:39:47 -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=JNUSoANC1Mb3qINpAneu+i9ghWi8O+DqSWo2H/3V1E0=; b=ye7Ly434jiQlAeqbAREu0zItWdMPDLOr7PH5D1lTiau3ej9PjqDjU1wPi+7yrLkYAk BzZHy/YbK4yYIgyIhp6oSKPyItV/j8lFAa3kcq71byoMqmRT7/T8SzkFN9Jbv6x+b1ef +sFVdeunh+zeLtJuR/D6BoW1DuslSd7ResDNdYjQg2+RDtRiSApI0kpc18OzgqlJa9X1 wXkUaogaiNt9OiAoPcbol0jEhklfTwUdyMlri8RteXRVL4krZZSkC7UVH72y/2AV1QS8 gPwqeRsk8dmk5vmjhE3mVmVcW0Nuy4WKlLN3+jhXAYRLolGrv2oCrZlxzJdi303U0s16 IPeA== X-Received: by 10.14.177.200 with SMTP id d48mr27841472eem.8.1390869587008; Mon, 27 Jan 2014 16:39:47 -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 v7sm48802128eel.2.2014.01.27.16.39.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jan 2014 16:39:46 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v2 11/21] pinctrl: mvebu: armada-370: provide generic mpp callbacks Date: Tue, 28 Jan 2014 01:39:23 +0100 Message-Id: <1390869573-27624-12-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1390869573-27624-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1390674856-4993-1-git-send-email-sebastian.hesselbarth@gmail.com> <1390869573-27624-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140127_194004_692666_55ACB8DA X-CRM114-Status: GOOD ( 12.80 ) X-Spam-Score: -2.0 (--) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Linus Walleij , linux-kernel@vger.kernel.org, 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 We want to get rid of passing register addresses to common pinctrl driver, so provide set/get callbacks for generic mpp pins. Signed-off-by: Sebastian Hesselbarth --- Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Thomas Petazzoni Cc: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pinctrl/mvebu/pinctrl-armada-370.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-370.c b/drivers/pinctrl/mvebu/pinctrl-armada-370.c index 7586072e66c6..5e8e83f57b8e 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-370.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-370.c @@ -25,6 +25,30 @@ static void __iomem *mpp_base; +static int armada_370_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, + unsigned long *config) +{ + unsigned off = (ctrl->pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; + unsigned shift = (ctrl->pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; + + *config = (readl(mpp_base + off) >> shift) & MVEBU_MPP_MASK; + + return 0; +} + +static int armada_370_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl, + unsigned long config) +{ + unsigned off = (ctrl->pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; + unsigned shift = (ctrl->pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; + unsigned long reg; + + reg = readl(mpp_base + off) & ~(MVEBU_MPP_MASK << shift); + writel(reg | (config << shift), mpp_base + off); + + return 0; +} + static struct mvebu_mpp_mode mv88f6710_mpp_modes[] = { MPP_MODE(0, MPP_FUNCTION(0x0, "gpio", NULL), @@ -375,7 +399,7 @@ static struct of_device_id armada_370_pinctrl_of_match[] = { }; static struct mvebu_mpp_ctrl mv88f6710_mpp_controls[] = { - MPP_REG_CTRL(0, 65), + MPP_FUNC_CTRL(0, 65, NULL, armada_370_mpp_ctrl), }; static struct pinctrl_gpio_range mv88f6710_mpp_gpio_ranges[] = {