From patchwork Fri Sep 28 19:37:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 1522571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 8F09D3FE80 for ; Fri, 28 Sep 2012 19:40:41 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1THgOU-0001Za-KP; Fri, 28 Sep 2012 19:38:38 +0000 Received: from mail-ie0-f177.google.com ([209.85.223.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1THgNf-0001Me-Bt for linux-arm-kernel@lists.infradead.org; Fri, 28 Sep 2012 19:37:48 +0000 Received: by mail-ie0-f177.google.com with SMTP id e14so8694078iej.36 for ; Fri, 28 Sep 2012 12:37:47 -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=OJgQqEwn5shXI21HV4pMZM2L3s74rX/Vuau6SOKqf3k=; b=i6FXf8dm16i8N8DixhspXdLsbyfafVZrTq/W2jKKdxkUh1x10cmF3dr5AVpWRo+Y0a 3N1YKhrM8gEaspRdMdIP2S4tusZs+Vmj4UYiCHVeFBpe42RPAdpnDRBthpeZtJpLt6W5 3uHje6jXKvRuSp01CRn3InQOMdSXhOrmhyyOMxMtqrRfysw7yel15rkLQ3WG0RBETnbJ OghK63Ulz8EiFa7J1SnYy/qdxu0Uo6XVQVZyhiWkuRobEixZSxqEigZw1cjEM4+Vx1WM 8IDNbhfhiRNlQj3Co+RItf18XoTAtmx3+rJG3SGuc96km/eK7lzjaB18yJZZvw3v3AhE lbKw== Received: by 10.50.207.9 with SMTP id ls9mr2606951igc.64.1348861067226; Fri, 28 Sep 2012 12:37:47 -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 q1sm449747igj.15.2012.09.28.12.37.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Sep 2012 12:37:46 -0700 (PDT) From: Matt Porter To: Greg Kroah-Hartman , "Hans J. Koch" , Benoit Cousson , Paul Walmsley , Sekhar Nori Subject: [PATCH v2 2/7] uio: uio_pruss: add support for am33xx Date: Fri, 28 Sep 2012 15:37:47 -0400 Message-Id: <1348861072-14507-3-git-send-email-mporter@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348861072-14507-1-git-send-email-mporter@ti.com> References: <1348861072-14507-1-git-send-email-mporter@ti.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.223.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ohiomdp[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Linux DaVinci Kernel List , Russell King , Tony Lindgren , Linux Kernel Mailing List , Linux OMAP List , Linux ARM Kernel List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Adds DT, pinctrl, and runtime PM support to enable AM33xx. Signed-off-by: Matt Porter --- drivers/uio/Kconfig | 4 +-- drivers/uio/uio_pruss.c | 90 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 73 insertions(+), 21 deletions(-) diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index c48b938..5db1f34 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig @@ -96,10 +96,10 @@ config UIO_NETX config UIO_PRUSS tristate "Texas Instruments PRUSS driver" - depends on ARCH_DAVINCI_DA850 + depends on ARCH_DAVINCI_DA850 || SOC_AM33XX select GENERIC_ALLOCATOR 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 1b55db3..8560958 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -26,6 +26,11 @@ #include #include #include +#include +#include +#include +#include +#include #define DRV_NAME "pruss_uio" #define DRV_VERSION "1.0" @@ -120,8 +125,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) @@ -132,18 +139,51 @@ static int __devinit pruss_probe(struct platform_device *dev) kfree(gdev); return -ENOMEM; } - /* 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)) { - dev_err(&dev->dev, "Failed to get clock\n"); - kfree(gdev->info); - kfree(gdev); - ret = PTR_ERR(gdev->pruss_clk); - return ret; + + 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; + + 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 { - clk_enable(gdev->pruss_clk); + /* 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)) { + dev_err(&dev->dev, "Failed to get clock\n"); + kfree(gdev->info); + kfree(gdev); + ret = PTR_ERR(gdev->pruss_clk); + return ret; + } else { + clk_enable(gdev->pruss_clk); + } + gdev->pintc_base = pdata->pintc_base; + gdev->sram_pool = pdata->l3ram_pool; } + 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) { dev_err(&dev->dev, "No PRUSS I/O resource specified\n"); @@ -155,8 +195,7 @@ static int __devinit pruss_probe(struct platform_device *dev) goto out_free; } - if (pdata->l3ram_pool) { - gdev->sram_pool = pdata->l3ram_pool; + if (gdev->sram_pool) { gdev->sram_vaddr = gen_pool_alloc(gdev->sram_pool, sram_pool_sz); if (!gdev->sram_vaddr) { @@ -182,7 +221,6 @@ static int __devinit pruss_probe(struct platform_device *dev) goto out_free; } - 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++) { @@ -190,13 +228,19 @@ static int __devinit pruss_probe(struct platform_device *dev) p->mem[0].size = resource_size(regs_prussio); p->mem[0].memtype = UIO_MEM_PHYS; - p->mem[1].addr = gdev->sram_paddr; - p->mem[1].size = sram_pool_sz; - p->mem[1].memtype = UIO_MEM_PHYS; - - p->mem[2].addr = gdev->ddr_paddr; - p->mem[2].size = extram_pool_sz; - p->mem[2].memtype = UIO_MEM_PHYS; + if (gdev->sram_vaddr) { + p->mem[1].addr = gdev->sram_paddr; + p->mem[1].size = sram_pool_sz; + p->mem[1].memtype = UIO_MEM_PHYS; + + 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; + } p->name = kasprintf(GFP_KERNEL, "pruss_evt%d", cnt); p->version = DRV_VERSION; @@ -228,12 +272,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, }, };