From patchwork Tue Nov 26 19:40:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 3240921 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 78459C045B for ; Tue, 26 Nov 2013 19:47:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5195A20142 for ; Tue, 26 Nov 2013 19:47:00 +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 1FDCE200E8 for ; Tue, 26 Nov 2013 19:46:59 +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 rAQJk1ox013342; Tue, 26 Nov 2013 13:46:01 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAQJk08Z010007; Tue, 26 Nov 2013 13:46:01 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Tue, 26 Nov 2013 13:46:00 -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 rAQJk0q1024803; Tue, 26 Nov 2013 13:46:00 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id A338A8062B; Tue, 26 Nov 2013 13:46:00 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflxv15.itg.ti.com (dflxv15.itg.ti.com [128.247.5.124]) by linux.omap.com (Postfix) with ESMTP id 87E0580631 for ; Tue, 26 Nov 2013 13:44:09 -0600 (CST) Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAQJi9e6018368; Tue, 26 Nov 2013 13:44:09 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Tue, 26 Nov 2013 13:44:07 -0600 Received: from localhost (uglx0174654.ucm2.emeaucm.ext.ti.com [10.167.145.75]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAQJi6JH022289; Tue, 26 Nov 2013 13:44:07 -0600 From: Grygorii Strashko To: Linus Walleij , Santosh Shilimkar , , Subject: [RFC v1 5/9] gpio: davinci: reuse for Keystone SoC Date: Tue, 26 Nov 2013 21:40:11 +0200 Message-ID: <1385494815-15740-6-git-send-email-grygorii.strashko@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1385494815-15740-1-git-send-email-grygorii.strashko@ti.com> References: <1385494815-15740-1-git-send-email-grygorii.strashko@ti.com> MIME-Version: 1.0 CC: , 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: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The similar GPIO HW block is used by keystone SoCs as in Davinci SoCs. Hence, reuse Davinci GPIO driver for Keystone. Documentation: http://www.ti.com/lit/ug/sprugv1/sprugv1.pdf Signed-off-by: Grygorii Strashko --- .../devicetree/bindings/gpio/gpio-davinci.txt | 4 +- drivers/gpio/gpio-davinci.c | 55 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt index a2e839d..4ce9862 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt @@ -1,7 +1,7 @@ -Davinci GPIO controller bindings +Davinci/Keystone GPIO controller bindings Required Properties: -- compatible: should be "ti,dm6441-gpio" +- compatible: should be "ti,dm6441-gpio", "ti,keystone-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 6a48bf8..545f25c 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -542,11 +542,65 @@ static int davinci_gpio_banked_irq_init(struct platform_device *pdev) return 0; } +static int keystone_gpio_unbanked_irq_init(struct platform_device *pdev) +{ + int base_irq, irq; + unsigned gpio, ngpio; + struct davinci_gpio_regs __iomem *g; + struct device *dev = &pdev->dev; + struct davinci_gpio_controller *chips = platform_get_drvdata(pdev); + struct davinci_gpio_platform_data *pdata = dev->platform_data; + + static struct irq_chip gpio_unbanked; + + if (pdata->gpio_unbanked > chips[0].chip.ngpio) { + dev_err(dev, "Invalid IRQ configuration\n"); + return -EINVAL; + } + + ngpio = pdata->ngpio; + + base_irq = platform_get_irq(pdev, 0); + if (base_irq <= 0) { + dev_err(dev, "Invalid first banked IRQ number %d\n", base_irq); + return base_irq < 0 ? base_irq : -EINVAL; + } + + /* pass "bank 0" GPIO IRQs to GIC */ + chips[0].chip.to_irq = gpio_to_irq_unbanked; + chips[0].gpio_irq = base_irq; + chips[0].gpio_unbanked = pdata->gpio_unbanked; + + /* GIC handles mask/unmask; GPIO handles triggering */ + gpio_unbanked = *irq_get_chip(base_irq); + gpio_unbanked.name = "GPIO-GIC"; + gpio_unbanked.irq_set_type = gpio_irq_type_unbanked; + + /* default trigger: both edges */ + g = gpio2regs(0); + writel(~0, &g->set_falling); + writel(~0, &g->set_rising); + + irq = base_irq; + /* set the direct IRQs up to use that irqchip */ + for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++, irq++) { + irq_set_chip(irq, &gpio_unbanked); + irq_set_handler_data(irq, &chips[gpio / 32]); + irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH); + } + + return 0; +}; + static const struct davinci_gpio_init_data davinci_gpio_pdata = { .unbanked_irq_init = davinci_gpio_unbanked_irq_init, .banked_irq_init = davinci_gpio_banked_irq_init, }; +static const struct davinci_gpio_init_data keystone_gpio_pdata = { + .unbanked_irq_init = keystone_gpio_unbanked_irq_init, +}; + /* * NOTE: for suspend/resume, probably best to make a platform_device with * suspend_late/resume_resume calls hooking into results of the set_wake() @@ -622,6 +676,7 @@ done: #if IS_ENABLED(CONFIG_OF) static const struct of_device_id davinci_gpio_ids[] = { { .compatible = "ti,dm6441-gpio", &davinci_gpio_pdata}, + { .compatible = "ti,keystone-gpio", &keystone_gpio_pdata}, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, davinci_gpio_ids);