From patchwork Sun Feb 23 14:21:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3704061 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 413EFBF13A for ; Sun, 23 Feb 2014 14:26:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10BAB201C0 for ; Sun, 23 Feb 2014 14:26:07 +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 8283D201BF for ; Sun, 23 Feb 2014 14:26:05 +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 1WHZyB-0003Zv-30; Sun, 23 Feb 2014 14:23:53 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZxc-0001sg-3E; Sun, 23 Feb 2014 14:23:16 +0000 Received: from mail-ee0-x22a.google.com ([2a00:1450:4013:c00::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WHZwA-0001hX-OA for linux-arm-kernel@lists.infradead.org; Sun, 23 Feb 2014 14:21:58 +0000 Received: by mail-ee0-f42.google.com with SMTP id e53so1016483eek.15 for ; Sun, 23 Feb 2014 06:21:24 -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=OpbZUrcPAMcaduyY7HQy1jafqCmP3Nso8moOKrA0EEE=; b=wOTAjLq7mIPFM1uwrUgcvLoGamgsDtFiEguueZ7p///UpyoHmxkDEAjFcpgW5XFdpG 1f88VLs5wPSi5mtCDMvxOXrMDxHvnJor4zHIXWtHOiG+ihMRwaWqARGuQmXVsi1p2JqL Fu+piEwsgMVqITAhc1dvrdjPEZEsgXkYvH+Sn0Ts3otHPVATFkWdCP9uCMA/bzL0qL82 YJmiVnISifUYVNbDJgv0DKB/wjAr16FopG5d1hpuv/sncS41Calmfdu8iy8N9xwax3pL tJfSlUqgS+nQ+OjD2C6dHEJJjrybkY2A390tQOT5r4XcPyiuhgtt404DJdGFiXeGF7Tp +k1Q== X-Received: by 10.14.47.133 with SMTP id t5mr19653593eeb.96.1393165284562; Sun, 23 Feb 2014 06:21:24 -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 k41sm51641397een.19.2014.02.23.06.21.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2014 06:21:23 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v4 04/16] pinctrl: mvebu: remove passing mvebu_mpp_ctrl to callbacks Date: Sun, 23 Feb 2014 15:21:02 +0100 Message-Id: <1393165274-32492-5-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_092147_128566_252558D5 X-CRM114-Status: GOOD ( 13.51 ) 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 The only valuable information a special callback can derive from mvebu_mpp_ctrl passed to it, is the pin id. Instead of passing the struct, pass the pid directly. Signed-off-by: Sebastian Hesselbarth Tested-by: Andrew Lunn Tested-by: Thomas Petazzoni --- 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 | 61 ++++++++++++++--------------------- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 8 ++--- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 8 ++--- 3 files changed, 32 insertions(+), 45 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 47268393af34..c7d365f9009c 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c @@ -55,15 +55,14 @@ #define CONFIG_PMU BIT(4) -static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, - unsigned long *config) +static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) { - unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS; - unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS; + unsigned off = (pid / MPPS_PER_REG) * MPP_BITS; + unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS; unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long func; - if (pmu & (1 << ctrl->pid)) { + if (pmu & (1 << pid)) { func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); *config = (func >> shift) & MPP_MASK; *config |= CONFIG_PMU; @@ -74,22 +73,21 @@ static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl, - unsigned long config) +static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) { - unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS; - unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS; + unsigned off = (pid / MPPS_PER_REG) * MPP_BITS; + unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS; unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long func; if (config & CONFIG_PMU) { - writel(pmu | (1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL); + writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); func &= ~(MPP_MASK << shift); func |= (config & MPP_MASK) << shift; writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); } else { - writel(pmu & ~(1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL); + writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); func = readl(DOVE_MPP_VIRT_BASE + off); func &= ~(MPP_MASK << shift); func |= (config & MPP_MASK) << shift; @@ -98,13 +96,12 @@ static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl, - unsigned long *config) +static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config) { unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mask; - switch (ctrl->pid) { + switch (pid) { case 24: /* mpp_camera */ mask = DOVE_CAM_GPIO_SEL; break; @@ -129,13 +126,12 @@ static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl, - unsigned long config) +static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config) { unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mask; - switch (ctrl->pid) { + switch (pid) { case 24: /* mpp_camera */ mask = DOVE_CAM_GPIO_SEL; break; @@ -164,8 +160,7 @@ static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl, - unsigned long *config) +static int dove_nand_ctrl_get(unsigned pid, unsigned long *config) { unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); @@ -174,8 +169,7 @@ static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl, - unsigned long config) +static int dove_nand_ctrl_set(unsigned pid, unsigned long config) { unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); @@ -188,8 +182,7 @@ static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl, - unsigned long *config) +static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config) { unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); @@ -198,8 +191,7 @@ static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl, - unsigned long config) +static int dove_audio0_ctrl_set(unsigned pid, unsigned long config) { unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); @@ -211,8 +203,7 @@ static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl, - unsigned long *config) +static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config) { unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); @@ -238,8 +229,7 @@ static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl, - unsigned long config) +static int dove_audio1_ctrl_set(unsigned pid, unsigned long config) { unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); @@ -276,11 +266,11 @@ static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl, * break other functions. If you require all mpps as gpio * enforce gpio setting by pinctrl mapping. */ -static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid) +static int dove_audio1_ctrl_gpio_req(unsigned pid) { unsigned long config; - dove_audio1_ctrl_get(ctrl, &config); + dove_audio1_ctrl_get(pid, &config); switch (config) { case 0x02: /* i2s1 : gpio[56:57] */ @@ -303,16 +293,14 @@ static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid) } /* mpp[52:57] has gpio pins capable of in and out */ -static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl *ctrl, u8 pid, - bool input) +static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input) { if (pid < 52 || pid > 57) return -ENOTSUPP; return 0; } -static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl, - unsigned long *config) +static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config) { unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); @@ -328,8 +316,7 @@ static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl, return 0; } -static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl, - unsigned long config) +static int dove_twsi_ctrl_set(unsigned pid, unsigned long config) { unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 2be432444124..873aef5bdd9c 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -185,7 +185,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev, return -EINVAL; if (grp->ctrl->mpp_get) - return grp->ctrl->mpp_get(grp->ctrl, config); + return grp->ctrl->mpp_get(grp->pins[0], config); return mvebu_common_mpp_get(pctl, grp, config); } @@ -203,7 +203,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev, for (i = 0; i < num_configs; i++) { if (grp->ctrl->mpp_set) - ret = grp->ctrl->mpp_set(grp->ctrl, configs[i]); + ret = grp->ctrl->mpp_set(grp->pins[0], configs[i]); else ret = mvebu_common_mpp_set(pctl, grp, configs[i]); @@ -347,7 +347,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev, return -EINVAL; if (grp->ctrl->mpp_gpio_req) - return grp->ctrl->mpp_gpio_req(grp->ctrl, offset); + return grp->ctrl->mpp_gpio_req(offset); setting = mvebu_pinctrl_find_gpio_setting(pctl, grp); if (!setting) @@ -370,7 +370,7 @@ static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev, return -EINVAL; if (grp->ctrl->mpp_gpio_dir) - return grp->ctrl->mpp_gpio_dir(grp->ctrl, offset, input); + return grp->ctrl->mpp_gpio_dir(offset, input); setting = mvebu_pinctrl_find_gpio_setting(pctl, grp); if (!setting) diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.h b/drivers/pinctrl/mvebu/pinctrl-mvebu.h index 90bd3beee860..b20d1d778c75 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.h +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.h @@ -38,10 +38,10 @@ struct mvebu_mpp_ctrl { u8 pid; u8 npins; unsigned *pins; - int (*mpp_get)(struct mvebu_mpp_ctrl *ctrl, unsigned long *config); - int (*mpp_set)(struct mvebu_mpp_ctrl *ctrl, unsigned long config); - int (*mpp_gpio_req)(struct mvebu_mpp_ctrl *ctrl, u8 pid); - int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl *ctrl, u8 pid, bool input); + int (*mpp_get)(unsigned pid, unsigned long *config); + int (*mpp_set)(unsigned pid, unsigned long config); + int (*mpp_gpio_req)(unsigned pid); + int (*mpp_gpio_dir)(unsigned pid, bool input); }; /**