From patchwork Mon Oct 20 23:27:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5108541 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 E1B459F30B for ; Mon, 20 Oct 2014 23:29:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0626B20154 for ; Mon, 20 Oct 2014 23:29:32 +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 1CF73201ED for ; Mon, 20 Oct 2014 23:29:31 +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 1XgMOI-0002sH-6b; Mon, 20 Oct 2014 23:29:30 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgMNN-0002ER-1Y for linux-rockchip@lists.infradead.org; Mon, 20 Oct 2014 23:28:36 +0000 Received: by mail-pa0-f45.google.com with SMTP id lj1so69040pab.32 for ; Mon, 20 Oct 2014 16:28:10 -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=62xhVfQvGVO4QH4MtDlHy0aiQRxEm/97X7NQcoSBzAk=; b=V2YjoSFuY0fjkV7T6RDuAhOQo2VU44eLtCWSORak4MUM4O2rER6udZPOgN2L5e+Fdb eC8Pk1WfQ3QheXE6hT5OD7EAVH3lWg+B/+zpNg1qaT998NlSw2qFANdXhwdiWpAAzAP7 WhMSr5VauawgmezyldNbbDC35czc5BGMzWmtc= 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=62xhVfQvGVO4QH4MtDlHy0aiQRxEm/97X7NQcoSBzAk=; b=YbMZWfOJlHEC/gjVTlgub8z7WTxoBi2XtLGJpCexy6ZCT5w2ByPkDvmGB4Bw4prZ6+ AqToP2h3lpTp6ycIM4Km39N/6TkAUJKaxVPq9t8BQMwoLC9jaMvbA+GF5CTKprOoSBqd G0U656x7ELhZTK8YIg96KhtvEvO+Vu1wr4CxSx9AZYG2HcaHpUCVwtIY/2Vj5y5/LgJe 3/jUkAkqhw8LfbxHiV5aJapAPvkt0ouHttZzr6Z10YGZJc18306KaeiYR+SL8CKxcIns +YXlvbbup3l8E8CS2jDjGGRvDnyjSHvVOiU0bkl1WhRitjyPQpm75MlvZ6GPCc6NUPer goig== X-Gm-Message-State: ALoCoQmg2EI+ipZ9wTIguyKyA/saxiauvOrCYajJXHBn+rFLl/a54Q4xfZNi5WlByfwCbUFLPnXG X-Received: by 10.70.40.134 with SMTP id x6mr30415538pdk.99.1413847689967; Mon, 20 Oct 2014 16:28:09 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.162.15]) by mx.google.com with ESMTPSA id tc5sm10080198pbc.51.2014.10.20.16.28.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 16:28:09 -0700 (PDT) From: Doug Anderson To: Linus Walleij , Heiko Stuebner Subject: [PATCH 2/4] pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set() Date: Mon, 20 Oct 2014 16:27:48 -0700 Message-Id: <1413847670-12245-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1413847670-12245-1-git-send-email-dianders@chromium.org> References: <1413847670-12245-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141020_162833_162306_51E1BD85 X-CRM114-Status: GOOD ( 13.21 ) X-Spam-Score: -0.1 (/) 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 --- drivers/pinctrl/pinctrl-rockchip.c | 42 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 230d8f3..65efb88 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -856,22 +856,16 @@ 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 *gc, + unsigned offset, bool input) { - struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); struct rockchip_pin_bank *bank; - struct gpio_chip *chip; int pin, ret; + unsigned long flags; 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"); + bank = gc_to_pin_bank(gc); + pin = offset - gc->base; ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO); if (ret < 0) @@ -888,6 +882,22 @@ 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(range->gc, offset, 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 +927,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 +968,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;