From patchwork Tue Mar 15 07:55:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8586041 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4D89B9F6E1 for ; Tue, 15 Mar 2016 07:57:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 623592020F for ; Tue, 15 Mar 2016 07:57:32 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B456201FE for ; Tue, 15 Mar 2016 07:57: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 1afjqr-0000Wh-8O; Tue, 15 Mar 2016 07:57:13 +0000 Received: from mail-pf0-f193.google.com ([209.85.192.193]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afjqo-0000O1-EV for linux-rockchip@lists.infradead.org; Tue, 15 Mar 2016 07:57:12 +0000 Received: by mail-pf0-f193.google.com with SMTP id u190so1681571pfb.2 for ; Tue, 15 Mar 2016 00:56:50 -0700 (PDT) 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; bh=RCa2tTzqVikEbvIvfVhdXBE6Q5VIG9YdcrkJEaoeYEE=; b=OhEDgkxpTZOosoOiyGG9A40LmKF7zRCR0lO4au+hGMatdoz3sEWjZ4Txiiu0XxVlNc 0x8mNd6XmyHlEd+xiIh0AJWko0kcS/pjt8G5wZNHs9ilyvykci60t6pCmXD0G7Vhxa4d tBCvS/PAV93A6bOKQeGvwo7fRTEUI0qOyvpThpzxAExVvnvvP/j4fBX1m/eVO3qzbs1l tlPUZpTeQ6W74FH3dcPQTXkz4czphUJ2qHf5yOJRuzrU3nDX6KvuoB+EsmXUecj1TFy9 vTTl68WyZH0L/RJaVwd9uC8hRsozDUawR60dUICJP4ntHjJT2BPLRvuqrWNUDcLW++ig AZlg== X-Gm-Message-State: AD7BkJKsT/sOzbo+j8MjE+zOu2MDbrWK8ZJhlHe5nCWDJthP3oEaB1N0iW1NZRLDIBOrEg== X-Received: by 10.98.9.27 with SMTP id e27mr36632739pfd.59.1458028609680; Tue, 15 Mar 2016 00:56:49 -0700 (PDT) Received: from localhost.localdomain ([104.37.5.173]) by smtp.gmail.com with ESMTPSA id r68sm37306928pfb.51.2016.03.15.00.56.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Mar 2016 00:56:48 -0700 (PDT) From: Caesar Wang To: linus.walleij@linaro.org, heiko@sntech.de Subject: [PATCH v2] pinctrl: rockchip: add support the get_direction Date: Tue, 15 Mar 2016 15:55:45 +0800 Message-Id: <1458028545-1202-1-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160315_005710_576658_75B62168 X-CRM114-Status: GOOD ( 13.62 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Caesar Wang 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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RDNS_NONE,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 This patch adds the get_direction to support the gpio interface. The gpio direction is not used on rockchip platform when use the gpio debugfs. Tested on kylin board. (RK3036 SoCs) The repro steps: $/sys/class/gpio/ echo 53 > export $/sys/class/gpio/gpio53# cat direction in In general, the gpio53 should be out value, but the direction is the default value 'in', since the get_direction didn't supported in rockchip pinctrl. So, we should add this patch to support it. Reported-by: Jeffy Chen Signed-off-by: Caesar Wang Cc: Linus Walleij Cc: Heiko Stuebner Cc: linux-gpio@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Reviewed-by: Heiko Stuebner --- Changes in v2: - As Heiko comments on (https://patchwork.kernel.org/patch/8576661/), fixes the wrong offset from original patch. drivers/pinctrl/pinctrl-rockchip.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index bf032b9..0b3fd02 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -1208,6 +1208,16 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, return 0; } +static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset) +{ + struct rockchip_pin_bank *bank = gpiochip_get_data(chip); + u32 data; + + data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); + + return !(data & BIT(offset)); +} + /* * The calls to gpio_direction_output() and gpio_direction_input() * leads to this function call (via the pinctrl_gpio_direction_{input|output}() @@ -1741,6 +1751,7 @@ static const struct gpio_chip rockchip_gpiolib_chip = { .free = gpiochip_generic_free, .set = rockchip_gpio_set, .get = rockchip_gpio_get, + .get_direction = rockchip_gpio_get_direction, .direction_input = rockchip_gpio_direction_input, .direction_output = rockchip_gpio_direction_output, .to_irq = rockchip_gpio_to_irq,