From patchwork Wed Oct 19 05:33:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 9383615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 183AE60762 for ; Wed, 19 Oct 2016 05:34:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AE9028DB1 for ; Wed, 19 Oct 2016 05:34:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3B2628DE4; Wed, 19 Oct 2016 05:34:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EFCC28DB1 for ; Wed, 19 Oct 2016 05:34:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755895AbcJSFew (ORCPT ); Wed, 19 Oct 2016 01:34:52 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:34032 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755723AbcJSFev (ORCPT ); Wed, 19 Oct 2016 01:34:51 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9J5Ym34031260; Wed, 19 Oct 2016 00:34:48 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9J5YmqE023409; Wed, 19 Oct 2016 00:34:48 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Wed, 19 Oct 2016 00:34:47 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9J5YQl2017393; Wed, 19 Oct 2016 00:34:45 -0500 From: Keerthy To: CC: , , , , , , , , Subject: [PATCH 5/5] gpio: davinci: Add a separate compatible for k2g Date: Wed, 19 Oct 2016 11:03:59 +0530 Message-ID: <1476855239-32730-6-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476855239-32730-1-git-send-email-j-keerthy@ti.com> References: <1476855239-32730-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the case of k2g the clocks are handled differently as when compared with other keystones. Hence adding a separate compatible and match tables accordingly. Signed-off-by: Keerthy --- .../devicetree/bindings/gpio/gpio-davinci.txt | 2 +- drivers/gpio/gpio-davinci.c | 45 ++++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt index 5079ba7..a76abd2 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt @@ -1,7 +1,7 @@ Davinci/Keystone GPIO controller bindings Required Properties: -- compatible: should be "ti,dm6441-gpio", "ti,keystone-gpio" +- compatible: should be "ti,dm6441-gpio", "ti,keystone-gpio", "ti,k2g-gpio" - reg: Physical base address of the controller and the size of memory mapped registers. diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index f7c506b..d91a9a8 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -452,6 +452,26 @@ static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq) static const struct of_device_id davinci_gpio_ids[]; +struct gpio_driver_data { + gpio_get_irq_chip_cb_t gpio_get_irq_chip; + bool clk_optional; +}; + +static struct gpio_driver_data davinci_data = { + .gpio_get_irq_chip = davinci_gpio_get_irq_chip, + .clk_optional = false, +}; + +static struct gpio_driver_data keystone_data = { + .gpio_get_irq_chip = keystone_gpio_get_irq_chip, + .clk_optional = false, +}; + +static struct gpio_driver_data k2g_data = { + .gpio_get_irq_chip = keystone_gpio_get_irq_chip, + .clk_optional = true, +}; + /* * NOTE: for suspend/resume, probably best to make a platform_device with * suspend_late/resume_resume calls hooking into results of the set_wake() @@ -475,6 +495,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) struct irq_domain *irq_domain = NULL; const struct of_device_id *match; struct irq_chip *irq_chip; + struct gpio_driver_data *driver_data = NULL; gpio_get_irq_chip_cb_t gpio_get_irq_chip; /* @@ -483,8 +504,10 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) gpio_get_irq_chip = davinci_gpio_get_irq_chip; match = of_match_device(of_match_ptr(davinci_gpio_ids), dev); - if (match) - gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data; + if (match) { + driver_data = (struct gpio_driver_data *)match->data; + gpio_get_irq_chip = driver_data->gpio_get_irq_chip; + } ngpio = pdata->ngpio; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); @@ -500,6 +523,9 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) return -ENODEV; } + if (driver_data && driver_data->clk_optional) + goto skip_clk_handling; + clk = devm_clk_get(dev, "gpio"); if (IS_ERR(clk)) { printk(KERN_ERR "Error %ld getting gpio clock?\n", @@ -508,6 +534,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) } clk_prepare_enable(clk); +skip_clk_handling: if (!pdata->gpio_unbanked) { irq = irq_alloc_descs(-1, 0, ngpio, 0); if (irq < 0) { @@ -607,8 +634,18 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) #if IS_ENABLED(CONFIG_OF) static const struct of_device_id davinci_gpio_ids[] = { - { .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip}, - { .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip}, + { + .compatible = "ti,keystone-gpio", + .data = &keystone_data, + }, + { + .compatible = "ti,dm6441-gpio", + .data = &davinci_data, + }, + { + .compatible = "ti,k2g-gpio", + .data = &k2g_data, + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, davinci_gpio_ids);