From patchwork Thu Oct 9 09:42:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 5057211 Return-Path: X-Original-To: patchwork-linux-arm@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 EA2979F295 for ; Thu, 9 Oct 2014 09:45:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED3542017D for ; Thu, 9 Oct 2014 09:45:53 +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 17A142018E for ; Thu, 9 Oct 2014 09:45:53 +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 1XcAGJ-0005s2-8r; Thu, 09 Oct 2014 09:43:55 +0000 Received: from mail-oi0-f49.google.com ([209.85.218.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcAGF-0005lU-G1 for linux-arm-kernel@lists.infradead.org; Thu, 09 Oct 2014 09:43:52 +0000 Received: by mail-oi0-f49.google.com with SMTP id a3so1830002oib.8 for ; Thu, 09 Oct 2014 02:43:29 -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=jH5it5+of4SQOw9g+fvJaH2MmH/Ktci0VKdrVyUpUcM=; b=fjX3K7kpLxriC+96YqM5e/LcF0ptIDEmQZcDMACtAycoP3PMcGiliru7u9R0rGIF5/ fd3Tw4RCs9fTs8Fuo7Lp+UHmHHYIY2naY54uC5QyGzJeeMlvcIMof98XF8fHGxTMelgh aKf44MlNNn7O154hyoyoU2E04MRAmekw8fjmmCqPwxSi5LuE3N3aOv2qEeF3vSpcu+tm 08FcMvOiUx73LcImHALb7WUxBggSms/JjxkF9Bbkqy3nQHdQL8RGn+4rwH7UW/8qdFB8 dmY4p8b6nz3PSxtmJKtZf0htlwiClc0UGytECfYO0QaWHorxuZrNqSuz4ZvjgSewFW/L wLVg== X-Gm-Message-State: ALoCoQkVHzpiInQpijEX0h4LA44klnzZ9x0vDxc4FJ9pz3L4m+9Bp45h5mRZXIhyd1Q/hDFJK+Fb X-Received: by 10.182.133.104 with SMTP id pb8mr20732618obb.37.1412847809331; Thu, 09 Oct 2014 02:43:29 -0700 (PDT) Received: from localhost.localdomain ([61.172.253.147]) by mx.google.com with ESMTPSA id mq4sm3123104obb.22.2014.10.09.02.43.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Oct 2014 02:43:28 -0700 (PDT) From: Haojian Zhuang To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linus.walleij@linaro.org Subject: [PATCH] gpio: pl061: hook request if gpio-ranges avaiable Date: Thu, 9 Oct 2014 17:42:15 +0800 Message-Id: <1412847735-498-1-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141009_024351_608034_5E09C1C4 X-CRM114-Status: GOOD ( 13.80 ) X-Spam-Score: -0.7 (/) Cc: Haojian Zhuang X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_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 gpio-ranges property could binds gpio to pinctrl. But there may be some gpios without pinctrl operation. So check whether gpio-ranges property exists in device node first. Signed-off-by: Haojian Zhuang --- drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 84b49cf..d1813f0 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -52,28 +52,34 @@ struct pl061_gpio { void __iomem *base; struct gpio_chip gc; + int uses_pinctrl; #ifdef CONFIG_PM struct pl061_context_save_regs csave_regs; #endif }; -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset) +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset) { /* * Map back to global GPIO space and request muxing, the direction * parameter does not matter for this controller. */ - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - return pinctrl_request_gpio(gpio); + if (chip->uses_pinctrl) + return pinctrl_request_gpio(gpio); + return 0; } -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset) +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset) { - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - pinctrl_free_gpio(gpio); + if (chip->uses_pinctrl) + pinctrl_free_gpio(gpio); } static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&chip->lock); + /* Hook the request()/free() for pinctrl operation */ + if (of_property_read_bool(dev->of_node, "gpio-ranges")) + chip->uses_pinctrl = true; chip->gc.request = pl061_gpio_request; chip->gc.free = pl061_gpio_free; chip->gc.direction_input = pl061_direction_input;