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: 1522461 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by patchwork1.kernel.org (Postfix) with ESMTP id 8FD9F3FE80 for ; Fri, 28 Sep 2012 19:39:18 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id q8SJbtEM022092; Fri, 28 Sep 2012 14:37:55 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q8SJbtGQ018084; Fri, 28 Sep 2012 14:37:55 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Fri, 28 Sep 2012 14:37:55 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id q8SJbtvN023953; Fri, 28 Sep 2012 14:37:55 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id F165280630; Fri, 28 Sep 2012 14:37:54 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 2358680628 for ; Fri, 28 Sep 2012 14:37:49 -0500 (CDT) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id q8SJbm4g003623 for ; Fri, 28 Sep 2012 14:37:48 -0500 (CDT) Received: from psmtp.com (na3sys009amx186.postini.com [74.125.149.167]) by neches.ext.ti.com (8.13.7/8.13.7) with SMTP id q8SJblAL028176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 28 Sep 2012 14:37:47 -0500 Received: from mail-ie0-f173.google.com ([209.85.223.173]) (using TLSv1) by na3sys009amx186.postini.com ([74.125.148.10]) with SMTP; Fri, 28 Sep 2012 15:37:47 EDT Received: by mail-ie0-f173.google.com with SMTP id 17so7532626iea.4 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-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-dkim: 1 skipped:not-enabled X-pstn-settings: 2 (0.5000:0.0050) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [82/3] CC: Linux DaVinci Kernel List , Russell King , Tony Lindgren , Linux Kernel Mailing List , Linux OMAP List , Linux ARM Kernel List 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@linux.davincidsp.com 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, }, };