From patchwork Fri Jun 19 12:58:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael van der Westhuizen X-Patchwork-Id: 486695 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 625831401F0 for ; Fri, 19 Jun 2015 22:58:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751733AbbFSM6e (ORCPT ); Fri, 19 Jun 2015 08:58:34 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:33044 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751494AbbFSM6d (ORCPT ); Fri, 19 Jun 2015 08:58:33 -0400 Received: by wgez8 with SMTP id z8so89091619wge.0 for ; Fri, 19 Jun 2015 05:58:32 -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:in-reply-to :references; bh=Iyo1hqpJHvSfyOt0zqU3OqpTJWwSR9D9ycesT4GzV9s=; b=GAEDXZbdR2KNokw6V0Zej0H9kBBLbAxrNP4kjXYl0YD0k/WG1dmBoDfC1BRXLa+L8k l+pHFRiCr8oq0WMy+4AD5lIAc6QcVtysB+6pa0VdaGlJtiFQBPz4guYOUvtY3WjNvtmd +ryxc0RXLuc1QFZ6UCrgKvG3Zj9LLsl/08xUuuikI8cYOYIDSPA6t9um5xq1+CBVJNeK NKbtB2i779MT8pObHrvEecxCugsfGLb0IofyWHaCtsxsqOpi+O7lqfgYOkY7ZOMt/B12 hz1b4cdpERjfcZL9EMHE1/BA7vf0bAtEcGC4iyntKyOpoenZnTOYRw+UuZb43m3hTCr3 oNTA== X-Gm-Message-State: ALoCoQlnjldL1dTqAl9SYTb+318BzeRhh0yPHyIad3mE4c49P5fEKz0OrrsVMLkaKYff98+UtRd2 X-Received: by 10.180.206.211 with SMTP id lq19mr6526591wic.81.1434718712340; Fri, 19 Jun 2015 05:58:32 -0700 (PDT) Received: from localhost.localdomain (105-237-212-12.access.mtnbusiness.co.za. [105.237.212.12]) by mx.google.com with ESMTPSA id fo13sm3633325wic.0.2015.06.19.05.58.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jun 2015 05:58:31 -0700 (PDT) From: Michael van der Westhuizen To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Alexandre Courbot , Jonas Jensen , Kamlakant Patel , Michael van der Westhuizen Subject: [PATCH 1/2] gpio: bgpio: Teach gpio-generic about the pinctrl subsystem Date: Fri, 19 Jun 2015 14:58:16 +0200 Message-Id: <1434718697-31335-2-git-send-email-michael@smart-africa.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434718697-31335-1-git-send-email-michael@smart-africa.com> References: <1434718697-31335-1-git-send-email-michael@smart-africa.com> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The basic MMIO gpio driver is unaware of the pinctrl subsystem, and this lack of pinctrl awareness extends to drivers using bgpio unless the drivers handle pinctrl interaction by overriding the request and free methods of gpiochip. Since pinctrl consumer interfaces are stubbed when pinctrl is not enabled this implementation is very simple, and there is no behaviour change when pinctrl is not enabled. Tested on picoXcell pc3x3 using gpio-dwapb. Signed-off-by: Michael van der Westhuizen --- drivers/gpio/gpio-generic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index b92a690..be28ba2 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -58,6 +58,7 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.` #include #include #include +#include #include #include #include @@ -467,11 +468,17 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc, static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin) { if (gpio_pin < chip->ngpio) - return 0; + return pinctrl_request_gpio(chip->base + gpio_pin); return -EINVAL; } +static void bgpio_free(struct gpio_chip *chip, unsigned gpio_pin) +{ + if (gpio_pin < chip->ngpio) + pinctrl_free_gpio(chip->base + gpio_pin); +} + int bgpio_remove(struct bgpio_chip *bgc) { gpiochip_remove(&bgc->gc); @@ -499,6 +506,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev, bgc->gc.base = -1; bgc->gc.ngpio = bgc->bits; bgc->gc.request = bgpio_request; + bgc->gc.free = bgpio_free; ret = bgpio_setup_io(bgc, dat, set, clr); if (ret)