From patchwork Mon Mar 14 06:01:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8576661 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BBE92C0553 for ; Mon, 14 Mar 2016 06:02:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D305420443 for ; Mon, 14 Mar 2016 06:02:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [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 E49ED20431 for ; Mon, 14 Mar 2016 06:02:03 +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 1afLZr-0006m2-K9; Mon, 14 Mar 2016 06:02:03 +0000 Received: from mail-pf0-f171.google.com ([209.85.192.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afLZq-0006eV-0k for linux-rockchip@lists.infradead.org; Mon, 14 Mar 2016 06:02:02 +0000 Received: by mail-pf0-f171.google.com with SMTP id x3so35367732pfb.1 for ; Sun, 13 Mar 2016 23:01:40 -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=+Crb5jorM0D435hzsEoZ4To6JXZDR44lL5DJSrPZoow=; b=aL9Zc1amONHp6ycob3do6mUk7pK1fGeWpaADosCUoKVd8L8sqMqCagPYR5KlQ0uOXj NJRMmpniL7Q6Y8djwzK8VDQ3YVsgkOM1dJdfqswbGUGw88buqTdPW2yyWDmdl+busVP8 djF39eaq+ufQaE98Ef9VJtzIizUkyXxjQaI1sNQAgSqRihLVLZWz/vqpdKuCvg+G/5Io 4iBunjjO67q3zfDaoWZb/oREeQqjVYNl7yqBhSrnDgOgeVofElUVJu4XEVLq6NX2hcoe mjwNXj54cNgmBIEvJVZOXmA1ai0LBBAnsi6P3kfTHVWE2QvlhoAXtuXSO1GaVQYTaZ54 vmEw== X-Gm-Message-State: AD7BkJKobXfADmm4GaCrl0LT0+LnZ2VOrEcgNUIbIkoNkM1KAM4I3nhxOp9ewhroobs9Lg== X-Received: by 10.98.32.136 with SMTP id m8mr25007520pfj.11.1457935300450; Sun, 13 Mar 2016 23:01:40 -0700 (PDT) Received: from localhost.localdomain ([104.37.5.155]) by smtp.gmail.com with ESMTPSA id 8sm26478758pfk.69.2016.03.13.23.01.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Mar 2016 23:01:39 -0700 (PDT) From: Caesar Wang To: linus.walleij@linaro.org, heiko@sntech.de Subject: [RESEND PATCH] pinctrl: rockchip: add support the get_direction Date: Mon, 14 Mar 2016 14:01:19 +0800 Message-Id: <1457935279-7881-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-20160313_230202_101575_F4218F8E X-CRM114-Status: GOOD ( 13.19 ) 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-rockchip@lists.infradead.org, Caesar Wang , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 --- Changes in RESEND: - Remove the change-id drivers/pinctrl/pinctrl-rockchip.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index bf032b9..f22a186 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -1208,6 +1208,18 @@ 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); + int pin; + u32 data; + + pin = offset - chip->base; + data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); + + return !!(data & BIT(pin)); +} + /* * The calls to gpio_direction_output() and gpio_direction_input() * leads to this function call (via the pinctrl_gpio_direction_{input|output}() @@ -1741,6 +1753,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,