From patchwork Mon Mar 14 05:44:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8576551 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 0D73A9F54C for ; Mon, 14 Mar 2016 05:45:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CA072043C for ; Mon, 14 Mar 2016 05:45:17 +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 4080120412 for ; Mon, 14 Mar 2016 05:45:16 +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 1afLJX-0001M9-9e; Mon, 14 Mar 2016 05:45:11 +0000 Received: from mail-pf0-f176.google.com ([209.85.192.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afLJU-00009d-5X for linux-rockchip@lists.infradead.org; Mon, 14 Mar 2016 05:45:10 +0000 Received: by mail-pf0-f176.google.com with SMTP id x3so35089975pfb.1 for ; Sun, 13 Mar 2016 22:44:47 -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=U3GMMVT9b0AZMFmr6kIGFQ2+GM949rDbcyLaJekpEbM=; b=R32Sag5BFM8ifhhjXqzZz0OnA1LMyZHZCMG2iAeDPUb/UvUVTIRdqv37aYHXxe6H0S hXCLcWChNhilxLA0mG5TFXWcD/GAF6OldvqgXBipBISZMxmg1FYsd1B7DkFx7zsWK23s zYjlLYqOR1DSxRrlWzaaT3l2iCqLd7YqI41OZW9R2Wq3/4wgnzAP0/uP3AILvdGIVB3s Umyd0u+HSXD1yhaODdmNHWo6pEg/5qb2can4Z2OS3lzZqdcuH11Wi/fJ23x3DuzKTB2P UeamJVXweT+rVjij0JUmgkOZ28yqAJbqGjmVsn/YfL0CqWPtY1DPpcjTFe2nr2RQ7uSK k3Bg== X-Gm-Message-State: AD7BkJJAi/hs7s0uGbd7Sqr/4ViiwOzQjSyERAMqjWY3c2o47sLNMM2dpVBmjbgw/psJsA== X-Received: by 10.98.10.156 with SMTP id 28mr25697024pfk.130.1457934286907; Sun, 13 Mar 2016 22:44:46 -0700 (PDT) Received: from localhost.localdomain ([104.37.5.155]) by smtp.gmail.com with ESMTPSA id ac1sm28798360pad.41.2016.03.13.22.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Mar 2016 22:44:45 -0700 (PDT) From: Caesar Wang To: linus.walleij@linaro.org, heiko@sntech.de Subject: [PATCH] pinctrl: rockchip: add support the get_direction Date: Mon, 14 Mar 2016 13:44:26 +0800 Message-Id: <1457934266-29862-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_224508_247636_26F5474F X-CRM114-Status: GOOD ( 12.97 ) 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, Caesar Wang , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.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. Change-Id: I237c2e85ac7680b3d0de15bbbb923985b4827def 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 --- 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,