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: 397948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 865DA14007D for ; Thu, 9 Oct 2014 20:43:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754558AbaJIJna (ORCPT ); Thu, 9 Oct 2014 05:43:30 -0400 Received: from mail-oi0-f53.google.com ([209.85.218.53]:51484 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754506AbaJIJn3 (ORCPT ); Thu, 9 Oct 2014 05:43:29 -0400 Received: by mail-oi0-f53.google.com with SMTP id v63so1899680oia.40 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=jI+O+b+ZP1eKfAHgrIreRSiDJU4nkZuSyxTVfVwZDw5AZBQkSepMrrPtqCyqgqjhsm 8yu8UahETc90AKypy02pebKSp1bAADt56heHHJZVZgKGLwz30I5Bopu4xu32fuZBh9z/ 4W9gxzsUysR6AtkOueA8PyrFw+sp5AG+X9gqPuUQSlFO1d1Leh8YDRp+pofrFhEhOA4x h0NA4xuomrtW6SUwM/VeGaQrmf1VGNm+gDE4Bpu1NbInGqsHL9SW1TyffRWegHVzHm2h ohFohG5+tFY1iFOStG5k9bHHGdkenTvkOQ1RHHYhp0cvGflfN6VR8PpgrOqrjQZWVr2N u2hA== X-Gm-Message-State: ALoCoQmO+B2ri0vNLvpQSoLh6AawzjXLa2z53mwJOqEuQFqsdx46NiizX6KbBqQx73u+a+ygHV5b 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 Cc: Haojian Zhuang 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 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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;