From patchwork Wed Mar 5 11:21:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Holler X-Patchwork-Id: 3773211 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 C3331BF13A for ; Wed, 5 Mar 2014 11:22:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD39320256 for ; Wed, 5 Mar 2014 11:22:39 +0000 (UTC) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A30692024C for ; Wed, 5 Mar 2014 11:22:38 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s25BMcJ8021615 for ; Wed, 5 Mar 2014 05:22:38 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s25BMbVo014083 for ; Wed, 5 Mar 2014 05:22:37 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Wed, 5 Mar 2014 05:22:37 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s25BMbgH008522 for ; Wed, 5 Mar 2014 05:22:37 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id B792F80626 for ; Wed, 5 Mar 2014 05:22:37 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlelxv84.itg.ti.com (dlelxv84.itg.ti.com [172.17.0.246]) by linux.omap.com (Postfix) with ESMTP id C5E3C80626 for ; Wed, 5 Mar 2014 05:21:42 -0600 (CST) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dlelxv84.itg.ti.com (8.14.3/8.13.8) with ESMTP id s25BLgVQ008340 for ; Wed, 5 Mar 2014 05:21:42 -0600 Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id s25BLgXF010949 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Mar 2014 05:21:42 -0600 Received: from [216.82.241.195:38113] by server-4.bemta-8.messagelabs.com id D3/0C-07043-5C807135; Wed, 05 Mar 2014 11:21:41 +0000 X-Env-Sender: holler@ahsoftware.de X-Msg-Ref: server-4.tower-119.messagelabs.com!1394018500!24669027!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 8432 invoked from network); 5 Mar 2014 11:21:41 -0000 Received: from h1446028.stratoserver.net (HELO mail.ahsoftware.de) (85.214.92.142) by server-4.tower-119.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 5 Mar 2014 11:21:41 -0000 Received: by mail.ahsoftware.de (Postfix, from userid 65534) id 68AE5423C2E2; Wed, 5 Mar 2014 12:21:37 +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=ham version=3.3.1 Received: from eiche.ahsoftware (p57B21F90.dip0.t-ipconnect.de [87.178.31.144]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.ahsoftware.de (Postfix) with ESMTPSA id 6CA71423C2CD for ; Wed, 5 Mar 2014 12:21:36 +0100 (CET) Received: by eiche.ahsoftware (Postfix, from userid 65534) id A1AF17FAAF; Wed, 5 Mar 2014 12:21:35 +0100 (CET) Received: from krabat.ahsoftware (unknown [192.168.207.2]) by eiche.ahsoftware (Postfix) with ESMTP id DF1777FAAE; Wed, 5 Mar 2014 11:21:22 +0000 (UTC) From: Alexander Holler To: Subject: [PATCH v2] gpio: davinci: fix gpio selection for OF Date: Wed, 5 Mar 2014 12:21:01 +0100 Message-ID: <1394018461-757-1-git-send-email-holler@ahsoftware.de> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <5316FFCE.1060603@ti.com> References: <5316FFCE.1060603@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+patchwork-davinci=patchwork.kernel.org@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 to the existing code in gpio-pxa. Signed-off-by: Alexander Holler Signed-off-by: Grygorii Strashko Tested-by: Sekhar Nori --- drivers/gpio/gpio-davinci.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) Changes in v2: replaced static variables by indirections. diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 7629b4f..92574a0 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -172,6 +172,27 @@ 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) +{ + struct davinci_gpio_controller *chips = dev_get_drvdata(gc->dev); + struct davinci_gpio_platform_data *pdata = dev_get_platdata(gc->dev); + + if (gpiospec->args[0] > pdata->ngpio) + return -EINVAL; + + if (gc != &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,9 @@ 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.dev = dev; chips[i].chip.of_node = dev->of_node; #endif spin_lock_init(&chips[i].lock);