From patchwork Tue Oct 21 17:47:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5127321 Return-Path: X-Original-To: patchwork-linux-rockchip@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 C484D9F387 for ; Tue, 21 Oct 2014 17:54:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3BC820221 for ; Tue, 21 Oct 2014 17:54:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 D690D2021F for ; Tue, 21 Oct 2014 17:54:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xgddp-0003tW-Mv; Tue, 21 Oct 2014 17:54:41 +0000 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgdXV-0004VF-Pq for linux-rockchip@lists.infradead.org; Tue, 21 Oct 2014 17:48:10 +0000 Received: by mail-pa0-f49.google.com with SMTP id hz1so1861486pad.22 for ; Tue, 21 Oct 2014 10:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/nkNQUZCkuRww6FdpAAZbK/1Z55k43XS2AtzPuiWti8=; b=IFGFdTKGlOWmwZ4Z+asOzVxRa51uqsI/ho0y3rRMtYfi5OOdlOVRM0dD0Igofqz3sw QG+ra5dAr2XuhaLXC0uLqwfb/4Ksuf+rXcA3/OuBuFGzw/SbM7Sdu8OrMIlrTY/1ugly YL2V2PRMP2M9Wli13Pp9IjcDtn55vofMvYX60= 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=/nkNQUZCkuRww6FdpAAZbK/1Z55k43XS2AtzPuiWti8=; b=gG6ku6R9owiimpUG/nVqaRbM59CXORJxkSsp8lIiaq7HXVFXdfXDFZ11Sslg4aZJff wALhHg05PN2DfnHYMkMDC1lJ1zP4qBxzp0oRk0ySRF87/Wf9oiUXfXVCZLyCnLigawRL e22xVsi1dQ61ElI6ZfZV7br0Ym153WAfqyk0trSFfF3eHJ/MVgsP5xx9lLQ1s1R1ae4h XIuOakreaZ8gdA0CWsG6agq7Haz1mmqA1UoFxQdNKE1ZcYslcamAsdbjU5t0o2VcWff1 M/9gY6H+lb2c+W+HHoUJ30aMAEPV6JI48JEKBKFx7said/GC8Gj3lNxZqzwyw9+Rjrrm cSug== X-Gm-Message-State: ALoCoQl48J5fnwiOG52kUwzRq83iJ07RBrFnrUOBXZwkyCyFWXamS98rZrg7yY3jWHQFfVzPLdEi X-Received: by 10.66.138.47 with SMTP id qn15mr36832885pab.82.1413913664960; Tue, 21 Oct 2014 10:47:44 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.162.15]) by mx.google.com with ESMTPSA id ky4sm12336911pbc.55.2014.10.21.10.47.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 10:47:44 -0700 (PDT) From: Doug Anderson To: Linus Walleij , Heiko Stuebner Subject: [PATCH v2 2/4] pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set() Date: Tue, 21 Oct 2014 10:47:33 -0700 Message-Id: <1413913655-22351-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1413913655-22351-1-git-send-email-dianders@chromium.org> References: <1413913655-22351-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141021_104809_908026_39A61E2D X-CRM114-Status: GOOD ( 13.59 ) X-Spam-Score: -0.8 (/) Cc: Doug Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Chris Zhong , Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,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 Rockchip pinctrl driver was calling rockchip_gpio_direction_output() in the pin_config_set() callback. This was just a shortcut for: * rockchip_gpio_set() * pinctrl_gpio_direction_output() Unfortunately it's not so good to call pinctrl_gpio_direction_output() from pin_config_set(). Specifically when initting hogs you'll get an error. Let's refactor a little so we can call _rockchip_pmx_gpio_set_direction() directly. Signed-off-by: Doug Anderson Tested-by: Chris Zhong Reviewed-by: Heiko Stuebner --- Changes in v2: - The 'flags' variable is now in the locking patch. - Fix confusion between 'pin' and 'offset'. drivers/pinctrl/pinctrl-rockchip.c | 41 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 230d8f3..8a3c582 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -856,22 +856,14 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, * leads to this function call (via the pinctrl_gpio_direction_{input|output}() * function called from the gpiolib interface). */ -static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, - struct pinctrl_gpio_range *range, - unsigned offset, bool input) +static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *chip, + int pin, bool input) { - struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); struct rockchip_pin_bank *bank; - struct gpio_chip *chip; - int pin, ret; + int ret; u32 data; - chip = range->gc; bank = gc_to_pin_bank(chip); - pin = offset - chip->base; - - dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n", - offset, range->name, pin, input ? "input" : "output"); ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO); if (ret < 0) @@ -888,6 +880,23 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, return 0; } +static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, + struct pinctrl_gpio_range *range, + unsigned offset, bool input) +{ + struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); + struct gpio_chip *chip; + int pin; + + chip = range->gc; + pin = offset - chip->base; + dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n", + offset, range->name, pin, input ? "input" : "output"); + + return _rockchip_pmx_gpio_set_direction(chip, offset - chip->base, + input); +} + static const struct pinmux_ops rockchip_pmx_ops = { .get_functions_count = rockchip_pmx_get_funcs_count, .get_function_name = rockchip_pmx_get_func_name, @@ -917,8 +926,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, return false; } -static int rockchip_gpio_direction_output(struct gpio_chip *gc, - unsigned offset, int value); +static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value); static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset); /* set the pin config settings for a specified pin */ @@ -959,9 +967,10 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, return rc; break; case PIN_CONFIG_OUTPUT: - rc = rockchip_gpio_direction_output(&bank->gpio_chip, - pin - bank->pin_base, - arg); + rockchip_gpio_set(&bank->gpio_chip, + pin - bank->pin_base, arg); + rc = _rockchip_pmx_gpio_set_direction(&bank->gpio_chip, + pin - bank->pin_base, false); if (rc) return rc; break;