From patchwork Tue Mar 4 22:06:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Holler X-Patchwork-Id: 3768821 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 53187BF13A for ; Tue, 4 Mar 2014 22:08:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63A682022A for ; Tue, 4 Mar 2014 22:08:04 +0000 (UTC) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AED520222 for ; Tue, 4 Mar 2014 22:08:02 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s24M6hZc008417; Tue, 4 Mar 2014 16:06:43 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s24M6gB0004902; Tue, 4 Mar 2014 16:06:42 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Tue, 4 Mar 2014 16:06:41 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s24M6eIq031468; Tue, 4 Mar 2014 16:06:40 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 704E280627; Tue, 4 Mar 2014 16:06:40 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflxv17.itg.ti.com (dflxv17.itg.ti.com [128.247.5.93]) by linux.omap.com (Postfix) with ESMTP id CD61580626 for ; Tue, 4 Mar 2014 16:06:38 -0600 (CST) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflxv17.itg.ti.com (8.14.3/8.13.8) with ESMTP id s24M6c2I005940 for ; Tue, 4 Mar 2014 16:06:38 -0600 Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by red.ext.ti.com (8.13.7/8.13.7) with ESMTP id s24M6cOV007183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Mar 2014 16:06:38 -0600 Received: from [216.82.250.83:38859] by server-13.bemta-12.messagelabs.com id 13/94-24704-E6E46135; Tue, 04 Mar 2014 22:06:38 +0000 X-Env-Sender: holler@ahsoftware.de X-Msg-Ref: server-12.tower-120.messagelabs.com!1393970790!7077488!1 X-Originating-IP: [85.214.92.142] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28869 invoked from network); 4 Mar 2014 22:06:32 -0000 Received: from h1446028.stratoserver.net (HELO mail.ahsoftware.de) (85.214.92.142) by server-12.tower-120.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 4 Mar 2014 22:06:32 -0000 Received: by mail.ahsoftware.de (Postfix, from userid 65534) id BAD75423C2D4; Tue, 4 Mar 2014 23:06:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from eiche.ahsoftware (p57B21C17.dip0.t-ipconnect.de [87.178.28.23]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.ahsoftware.de (Postfix) with ESMTPSA id DE4C0423C2B1 for ; Tue, 4 Mar 2014 23:06:27 +0100 (CET) Received: by eiche.ahsoftware (Postfix, from userid 65534) id 07EDB92002; Tue, 4 Mar 2014 23:06:26 +0100 (CET) Received: from krabat.ahsoftware (unknown [192.168.207.2]) by eiche.ahsoftware (Postfix) with ESMTP id 6DC6D7FAAF; Tue, 4 Mar 2014 22:06:17 +0000 (UTC) From: Alexander Holler To: Subject: [PATCH] gpio: davinci: fix gpio selection for OF Date: Tue, 4 Mar 2014 23:06:02 +0100 Message-ID: <1393970762-5346-1-git-send-email-holler@ahsoftware.de> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <5315ED51.1000006@ti.com> References: <5315ED51.1000006@ti.com> CC: Alexandre Courbot , , , Linus Walleij , , Rob Herring , Grant Likely , X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Virus-Scanned: ClamAV using ClamSMTP The driver missed an of_xlate function to translate gpio numbers as found in the DT to the correct chip and number. While there I've set #gpio_cells to a fixed value of 2. I've used gpio-pxa.c as template for those changes and tested my changes successfully on a da850 board using entries for gpio-leds in a DT. So I didn't reinvent the wheel but just copied and tested stuff. Thanks to Grygorii Strashko for the hint of the existing code in gpio-pxa. Signed-off-by: Alexander Holler --- drivers/gpio/gpio-davinci.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 7629b4f..79f45c4 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -44,6 +44,9 @@ struct davinci_gpio_regs { static void __iomem *gpio_base; +static struct davinci_gpio_controller *davinci_gpio_chips; +static int davinci_last_gpio; + static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio) { void __iomem *ptr; @@ -172,6 +175,24 @@ of_err: return NULL; } +#ifdef CONFIG_OF_GPIO +static int davinci_gpio_of_xlate(struct gpio_chip *gc, + const struct of_phandle_args *gpiospec, + u32 *flags) +{ + if (gpiospec->args[0] > davinci_last_gpio) + return -EINVAL; + + if (gc != &davinci_gpio_chips[gpiospec->args[0] / 32].chip) + return -EINVAL; + + if (flags) + *flags = gpiospec->args[1]; + + return gpiospec->args[0] % 32; +} +#endif + static int davinci_gpio_probe(struct platform_device *pdev) { int i, base; @@ -236,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) chips[i].chip.ngpio = 32; #ifdef CONFIG_OF_GPIO + chips[i].chip.of_gpio_n_cells = 2; + chips[i].chip.of_xlate = davinci_gpio_of_xlate; chips[i].chip.of_node = dev->of_node; #endif spin_lock_init(&chips[i].lock); @@ -251,6 +274,10 @@ static int davinci_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, chips); davinci_gpio_irq_setup(pdev); + + davinci_gpio_chips = chips; + davinci_last_gpio = ngpio; + return 0; }