From patchwork Wed Sep 26 13:44:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 1509601 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9651A3FDAE for ; Wed, 26 Sep 2012 13:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756522Ab2IZNpY (ORCPT ); Wed, 26 Sep 2012 09:45:24 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:49412 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756524Ab2IZNod (ORCPT ); Wed, 26 Sep 2012 09:44:33 -0400 Received: by mail-ie0-f174.google.com with SMTP id k13so1392367iea.19 for ; Wed, 26 Sep 2012 06:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=JRbYmE9x1U5OfJ8T7xJKHvsS6OC8uc8xBUWtbcLMrB8=; b=go00E/IKVRhtDtBLPigI4mgNU+aUhbdmkgUvlgLjbsxuoW1GAj+T4H07cXbDWja5/v 7qwTt370VsWQ2JGyBN/3PpXDIiiJx7C0VFJ0ZEKBCU0KPE9UzXfOpCH2/C4MTNzHXT3A iZE2iOcfcKbSQAEFlERBn5eTSzxKiSEYzeAIo8z6j74KGwp+gyjzUEezpfZdsIKQl63x vpF4mb6MpP0gQnHDQjcyhhmGxf8X/VuEz0N3NO1M0lMHsIQP+hNxpyDIp8Il/jWH4z61 7EvauTIRcPce7IwWCrLgik23gZyV7jf6MXHLLenkgIqpNSFOttIzMqoCKw4fWsxFRph8 Qv5g== Received: by 10.50.186.132 with SMTP id fk4mr11198868igc.41.1348667073293; Wed, 26 Sep 2012 06:44:33 -0700 (PDT) Received: from beef.ohporter.com (cpe-24-166-64-7.neo.res.rr.com. [24.166.64.7]) by mx.google.com with ESMTPS id 7sm4514748igh.0.2012.09.26.06.44.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 06:44:32 -0700 (PDT) From: Matt Porter To: Greg Kroah-Hartman , "Hans J. Koch" , Benoit Cousson , Paul Walmsley Cc: Tony Lindgren , Linux OMAP List , Linux Kernel Mailing List Subject: [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Date: Wed, 26 Sep 2012 09:44:29 -0400 Message-Id: <1348667071-12631-2-git-send-email-mporter@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348667071-12631-1-git-send-email-mporter@ti.com> References: <1348667071-12631-1-git-send-email-mporter@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Add ifdefery hacks to only use SRAM on Davinci. This needs to be cleaned up with a sane generic SRAM allocator (like the DT based driver available that can't be used on Davinci which is just starting DT conversion) before it can go upstream. Adds DT, pinctrl, and runtime PM support for use on AM33xx. Signed-off-by: Matt Porter --- Documentation/devicetree/bindings/uio/pruss.txt | 17 ++++++ .../devicetree/bindings/uio/uio_pruss.txt | 17 ++++++ drivers/uio/Kconfig | 4 +- drivers/uio/uio_pruss.c | 63 +++++++++++++++++++- 4 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/uio/pruss.txt create mode 100644 Documentation/devicetree/bindings/uio/uio_pruss.txt diff --git a/Documentation/devicetree/bindings/uio/pruss.txt b/Documentation/devicetree/bindings/uio/pruss.txt new file mode 100644 index 0000000..2ac45c5 --- /dev/null +++ b/Documentation/devicetree/bindings/uio/pruss.txt @@ -0,0 +1,17 @@ +TI PRUSS device + +Required properties: +- compatible : + - "ti,pruss-v1" for AM18xx/OMAP-L138/DA850 + - "ti,pruss-v2" for AM33xx. +- ti,pintc-offset : Offset of the PINTC from the PRUSS address base +- ti,hwmods: Name of the hwmod associated to the PRUSS + +Example: + +pruss: pruss@4a300000 { + compatible = "ti,pruss-v2"; + ti,hwmods = "pruss"; + reg = <0x4a300000 0x080000>; + ti,pintc-offset = <0x20000>; +}; diff --git a/Documentation/devicetree/bindings/uio/uio_pruss.txt b/Documentation/devicetree/bindings/uio/uio_pruss.txt new file mode 100644 index 0000000..2ac45c5 --- /dev/null +++ b/Documentation/devicetree/bindings/uio/uio_pruss.txt @@ -0,0 +1,17 @@ +TI PRUSS device + +Required properties: +- compatible : + - "ti,pruss-v1" for AM18xx/OMAP-L138/DA850 + - "ti,pruss-v2" for AM33xx. +- ti,pintc-offset : Offset of the PINTC from the PRUSS address base +- ti,hwmods: Name of the hwmod associated to the PRUSS + +Example: + +pruss: pruss@4a300000 { + compatible = "ti,pruss-v2"; + ti,hwmods = "pruss"; + reg = <0x4a300000 0x080000>; + ti,pintc-offset = <0x20000>; +}; diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 6f3ea9b..8da7d9b 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -96,9 +96,9 @@ config UIO_NETX config UIO_PRUSS tristate "Texas Instruments PRUSS driver" - depends on ARCH_DAVINCI_DA850 + depends on ARCH_DAVINCI_DA850 || SOC_AM33XX help - PRUSS driver for OMAPL138/DA850/AM18XX devices + PRUSS driver for OMAPL138/DA850/AM18XX and AM33XX devices PRUSS driver requires user space components, examples and user space driver is available from below SVN repo - you may use anonymous login diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index 33a7a27..326ce40 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -25,7 +25,15 @@ #include #include #include +#include +#include +#include +#include +#include + +#ifdef CONFIG_ARCH_DAVINCI_DA850 #include +#endif #define DRV_NAME "pruss_uio" #define DRV_VERSION "1.0" @@ -105,8 +113,10 @@ static void pruss_cleanup(struct platform_device *dev, dma_free_coherent(&dev->dev, extram_pool_sz, gdev->ddr_vaddr, gdev->ddr_paddr); } +#ifdef CONFIG_ARCH_DAVINCI_DA850 if (gdev->sram_vaddr) sram_free(gdev->sram_vaddr, sram_pool_sz); +#endif kfree(gdev->info); clk_put(gdev->pruss_clk); kfree(gdev); @@ -117,8 +127,10 @@ static int __devinit pruss_probe(struct platform_device *dev) struct uio_info *p; struct uio_pruss_dev *gdev; struct resource *regs_prussio; + struct resource res; int ret = -ENODEV, cnt = 0, len; struct uio_pruss_pdata *pdata = dev->dev.platform_data; + struct pinctrl *pinctrl; gdev = kzalloc(sizeof(struct uio_pruss_dev), GFP_KERNEL); if (!gdev) @@ -129,6 +141,7 @@ static int __devinit pruss_probe(struct platform_device *dev) kfree(gdev); return -ENOMEM; } +#ifdef CONFIG_ARCH_DAVINCI_DA850 /* Power on PRU in case its not done as part of boot-loader */ gdev->pruss_clk = clk_get(&dev->dev, "pruss"); if (IS_ERR(gdev->pruss_clk)) { @@ -140,6 +153,28 @@ static int __devinit pruss_probe(struct platform_device *dev) } else { clk_enable(gdev->pruss_clk); } +#endif + + if (dev->dev.of_node) { + pm_runtime_enable(&dev->dev); + ret = pm_runtime_get_sync(&dev->dev); + if (IS_ERR_VALUE(ret)) { + dev_err(&dev->dev, "pm_runtime_get_sync() failed\n"); + return ret; + } + + ret = of_address_to_resource(dev->dev.of_node, 0, &res); + if (IS_ERR_VALUE(ret)) { + dev_err(&dev->dev, "failed to parse DT reg\n"); + return ret; + } + regs_prussio = &res; + } + + pinctrl = devm_pinctrl_get_select_default(&dev->dev); + if (IS_ERR(pinctrl)) + dev_warn(&dev->dev, + "pins are not configured from the driver\n"); regs_prussio = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!regs_prussio) { @@ -152,11 +187,13 @@ static int __devinit pruss_probe(struct platform_device *dev) goto out_free; } +#ifdef CONFIG_ARCH_DAVINCI_DA850 gdev->sram_vaddr = sram_alloc(sram_pool_sz, &(gdev->sram_paddr)); if (!gdev->sram_vaddr) { dev_err(&dev->dev, "Could not allocate SRAM pool\n"); goto out_free; } +#endif gdev->ddr_vaddr = dma_alloc_coherent(&dev->dev, extram_pool_sz, &(gdev->ddr_paddr), GFP_KERNEL | GFP_DMA); @@ -172,7 +209,17 @@ static int __devinit pruss_probe(struct platform_device *dev) goto out_free; } - gdev->pintc_base = pdata->pintc_base; + if (dev->dev.of_node) { + ret = of_property_read_u32(dev->dev.of_node, + "ti,pintc-offset", + &gdev->pintc_base); + if (ret < 0) { + dev_err(&dev->dev, + "Can't parse ti,pintc-offset property\n"); + goto out_free; + } + } else + gdev->pintc_base = pdata->pintc_base; gdev->hostirq_start = platform_get_irq(dev, 0); for (cnt = 0, p = gdev->info; cnt < MAX_PRUSS_EVT; cnt++, p++) { @@ -180,6 +227,7 @@ static int __devinit pruss_probe(struct platform_device *dev) p->mem[0].size = resource_size(regs_prussio); p->mem[0].memtype = UIO_MEM_PHYS; +#ifdef CONFIG_ARCH_DAVINCI_DA850 p->mem[1].addr = gdev->sram_paddr; p->mem[1].size = sram_pool_sz; p->mem[1].memtype = UIO_MEM_PHYS; @@ -187,6 +235,11 @@ static int __devinit pruss_probe(struct platform_device *dev) p->mem[2].addr = gdev->ddr_paddr; p->mem[2].size = extram_pool_sz; p->mem[2].memtype = UIO_MEM_PHYS; +#else + p->mem[1].addr = gdev->ddr_paddr; + p->mem[1].size = extram_pool_sz; + p->mem[1].memtype = UIO_MEM_PHYS; +#endif p->name = kasprintf(GFP_KERNEL, "pruss_evt%d", cnt); p->version = DRV_VERSION; @@ -218,12 +271,20 @@ static int __devexit pruss_remove(struct platform_device *dev) return 0; } +static const struct of_device_id pruss_dt_ids[] = { + { .compatible = "ti,pruss-v1", .data = NULL, }, + { .compatible = "ti,pruss-v2", .data = NULL, }, + {}, +}; +MODULE_DEVICE_TABLE(of, pruss_dt_ids); + static struct platform_driver pruss_driver = { .probe = pruss_probe, .remove = __devexit_p(pruss_remove), .driver = { .name = DRV_NAME, .owner = THIS_MODULE, + .of_match_table = pruss_dt_ids, }, };