* [RFC PATCH 0/3] uio_pruss support for AM33xx @ 2012-09-26 13:44 Matt Porter 2012-09-26 13:44 ` [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Matt Porter ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Matt Porter @ 2012-09-26 13:44 UTC (permalink / raw) To: Greg Kroah-Hartman, Hans J. Koch, Benoit Cousson, Paul Walmsley Cc: Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List This series enables uio_pruss on AM33xx and it mostly intended to look for the proper solution to handling this particular OMAP hwmod which contains hardware reset lines. The comment in arch/arm/mach-omap2/omap_hwmod.c: /* * If an IP block contains HW reset lines and any of them are * asserted, we let integration code associated with that * block handle the enable. We've received very little * information on what those driver authors need, and until * detailed information is provided and the driver code is * posted to the public lists, this is probably the best we * can do. */ is waiting for some information which is at least partially available with this uio_pruss driver example. The series has some ifdefery to get uio_pruss to build without the DaVinci specific sram API, and then some needed DT, pinctrl, and runtime PM support so I could actually use the driver on AM33xx. The approach to deal with the hardware reset (for at least the pruss hwmod) was to add a generic omap property to properly define this hardware. The implementation simply deasserts any rst lines that are called out in the property when the omap_device is instantiated. This is not the right implementation as the sequence is a bit wrong for pruss since the busy check during the hard reset will fail, even though it fails in a benign manner. Ideally, we would want the implementation to observe the ti,deassert-hard-reset property and use that in omap_hwmod.c:_enable() *after* the module is unidled and the clocks active. However, this is actually functional for purposes of getting the uio_pruss driver up and running. Matt Porter (3): uio: uio_pruss: port to AM33xx ARM: omap: add DT support for deasserting hardware reset lines ARM: dts: AM33xx PRUSS support .../devicetree/bindings/arm/omap/omap.txt | 2 + Documentation/devicetree/bindings/uio/pruss.txt | 17 ++++++ .../devicetree/bindings/uio/uio_pruss.txt | 17 ++++++ arch/arm/boot/dts/am335x-bone.dts | 4 ++ arch/arm/boot/dts/am33xx.dtsi | 11 ++++ arch/arm/plat-omap/omap_device.c | 25 +++++++- drivers/uio/Kconfig | 4 +- drivers/uio/uio_pruss.c | 63 +++++++++++++++++++- 8 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/uio/pruss.txt create mode 100644 Documentation/devicetree/bindings/uio/uio_pruss.txt -- 1.7.9.5 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx 2012-09-26 13:44 [RFC PATCH 0/3] uio_pruss support for AM33xx Matt Porter @ 2012-09-26 13:44 ` Matt Porter 2012-09-26 21:10 ` Greg Kroah-Hartman 2012-09-26 23:51 ` Hans J. Koch 2012-09-26 13:44 ` [RFC PATCH 2/3] ARM: omap: add DT support for deasserting hardware reset lines Matt Porter 2012-09-26 13:44 ` [RFC PATCH 3/3] ARM: dts: AM33xx PRUSS support Matt Porter 2 siblings, 2 replies; 8+ messages in thread From: Matt Porter @ 2012-09-26 13:44 UTC (permalink / raw) To: Greg Kroah-Hartman, Hans J. Koch, Benoit Cousson, Paul Walmsley Cc: Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List 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 <mporter@ti.com> --- 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 <linux/clk.h> #include <linux/dma-mapping.h> #include <linux/slab.h> +#include <linux/of_address.h> +#include <linux/of_device.h> +#include <linux/pinctrl/consumer.h> +#include <linux/err.h> +#include <linux/pm_runtime.h> + +#ifdef CONFIG_ARCH_DAVINCI_DA850 #include <mach/sram.h> +#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, }, }; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx 2012-09-26 13:44 ` [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Matt Porter @ 2012-09-26 21:10 ` Greg Kroah-Hartman 2012-09-28 19:20 ` Matt Porter 2012-09-26 23:51 ` Hans J. Koch 1 sibling, 1 reply; 8+ messages in thread From: Greg Kroah-Hartman @ 2012-09-26 21:10 UTC (permalink / raw) To: Matt Porter Cc: Hans J. Koch, Benoit Cousson, Paul Walmsley, Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List On Wed, Sep 26, 2012 at 09:44:29AM -0400, Matt Porter wrote: > 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. Ick, that's really messy, no other way to do this in a "cleaner" fashion? greg k-h ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx 2012-09-26 21:10 ` Greg Kroah-Hartman @ 2012-09-28 19:20 ` Matt Porter 0 siblings, 0 replies; 8+ messages in thread From: Matt Porter @ 2012-09-28 19:20 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Hans J. Koch, Benoit Cousson, Paul Walmsley, Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List On Wed, Sep 26, 2012 at 02:10:19PM -0700, Greg Kroah-Hartman wrote: > On Wed, Sep 26, 2012 at 09:44:29AM -0400, Matt Porter wrote: > > 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. > > Ick, that's really messy, no other way to do this in a "cleaner" > fashion? There is, I had to untangle some ugly history on the SRAM situation first. First, and what I found humorous is that this driver is completely dead code in the tree...a driver to nowhere. It's not hooked up at all for DA850, no platform devices, no clock support, and to top it off the private SRAM API it's calling uses the ARM local SRAM that the PRU can't even access it [1]. So it's completely broken and one possible course of action is to just say tough luck to Davinci and remove all that SRAM code. I happen to care a bit about DA850 as I have the AM180x variant here... I noticed that previous attempts at consolidating SRAM allocation failed to achieve consensus [2] or in the case of when Jean added the phys support to genalloc the associated mach-davinci/ support was never picked up [3]. The patch in to enable L3 RAM support [1] depended on the genalloc conversion and all appears to have been forgotten and bitrotted since then. I decided to go ahead and add a genalloc pool for the L3 RAM (shared sram) on DA850 that PRU can use and strip out the private API. I'll post v2 with that supports that supports both platforms cleanly. -Matt [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2011-June/051609.html [2] https://patchwork.kernel.org/patch/710741/ [3] http://lists.infradead.org/pipermail/linux-arm-kernel/2011-July/057293.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx 2012-09-26 13:44 ` [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Matt Porter 2012-09-26 21:10 ` Greg Kroah-Hartman @ 2012-09-26 23:51 ` Hans J. Koch 2012-09-28 18:53 ` Matt Porter 1 sibling, 1 reply; 8+ messages in thread From: Hans J. Koch @ 2012-09-26 23:51 UTC (permalink / raw) To: Matt Porter Cc: Greg Kroah-Hartman, Hans J. Koch, Benoit Cousson, Paul Walmsley, Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List On Wed, Sep 26, 2012 at 09:44:29AM -0400, Matt Porter wrote: > 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. I agree with that ;-) Needing lots of ifdefs in *.c files is usually a bad sign... Thanks anyway for posting, it's good to have things like that in the archives. And please make driver code and documentation updates separate patches in the future. Hans > > Adds DT, pinctrl, and runtime PM support for use on > AM33xx. > > Signed-off-by: Matt Porter <mporter@ti.com> > --- > 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 <linux/clk.h> > #include <linux/dma-mapping.h> > #include <linux/slab.h> > +#include <linux/of_address.h> > +#include <linux/of_device.h> > +#include <linux/pinctrl/consumer.h> > +#include <linux/err.h> > +#include <linux/pm_runtime.h> > + > +#ifdef CONFIG_ARCH_DAVINCI_DA850 > #include <mach/sram.h> > +#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, > }, > }; > > -- > 1.7.9.5 > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx 2012-09-26 23:51 ` Hans J. Koch @ 2012-09-28 18:53 ` Matt Porter 0 siblings, 0 replies; 8+ messages in thread From: Matt Porter @ 2012-09-28 18:53 UTC (permalink / raw) To: Hans J. Koch Cc: Greg Kroah-Hartman, Benoit Cousson, Paul Walmsley, Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List On Thu, Sep 27, 2012 at 01:51:18AM +0200, Hans J. Koch wrote: > On Wed, Sep 26, 2012 at 09:44:29AM -0400, Matt Porter wrote: > > 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. > > I agree with that ;-) > Needing lots of ifdefs in *.c files is usually a bad sign... > > Thanks anyway for posting, it's good to have things like that in the archives. > > And please make driver code and documentation updates separate patches in the > future. Will separate out on v2. -Matt > > > > Adds DT, pinctrl, and runtime PM support for use on > > AM33xx. > > > > Signed-off-by: Matt Porter <mporter@ti.com> > > --- > > 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 <linux/clk.h> > > #include <linux/dma-mapping.h> > > #include <linux/slab.h> > > +#include <linux/of_address.h> > > +#include <linux/of_device.h> > > +#include <linux/pinctrl/consumer.h> > > +#include <linux/err.h> > > +#include <linux/pm_runtime.h> > > + > > +#ifdef CONFIG_ARCH_DAVINCI_DA850 > > #include <mach/sram.h> > > +#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, > > }, > > }; > > > > -- > > 1.7.9.5 > > > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 2/3] ARM: omap: add DT support for deasserting hardware reset lines 2012-09-26 13:44 [RFC PATCH 0/3] uio_pruss support for AM33xx Matt Porter 2012-09-26 13:44 ` [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Matt Porter @ 2012-09-26 13:44 ` Matt Porter 2012-09-26 13:44 ` [RFC PATCH 3/3] ARM: dts: AM33xx PRUSS support Matt Porter 2 siblings, 0 replies; 8+ messages in thread From: Matt Porter @ 2012-09-26 13:44 UTC (permalink / raw) To: Greg Kroah-Hartman, Hans J. Koch, Benoit Cousson, Paul Walmsley Cc: Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List This optional binding extension allows specification of a hwmod and associate hardware reset line which should be deasserted for the device to be functional. The implementation works for reference as to the problem that exists for utilizing uio_pruss on AM33xx but is suboptimal. The problem is that this deassertion occurs before clocks are enabled and we are warned that the hard reset failed. Ideally the list of rst lines requested to be deasserted would be cached and used within the hwmod enable sequencing (instead of it just returning if any hardware reset line is asserted). Signed-off-by: Matt Porter <mporter@ti.com> --- .../devicetree/bindings/arm/omap/omap.txt | 2 ++ arch/arm/plat-omap/omap_device.c | 25 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt b/Documentation/devicetree/bindings/arm/omap/omap.txt index d0051a7..3133a4b 100644 --- a/Documentation/devicetree/bindings/arm/omap/omap.txt +++ b/Documentation/devicetree/bindings/arm/omap/omap.txt @@ -21,6 +21,8 @@ Required properties: Optional properties: - ti,no_idle_on_suspend: When present, it prevents the PM to idle the module during suspend. +- ti,deassert-hard-reset: list of hwmod and hardware reset line name pairs + (ascii strings) to be deasserted upon device instantiation. Example: diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index d5f617c..d1ae68c 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -330,8 +330,8 @@ static int omap_device_build_from_dt(struct platform_device *pdev) struct omap_device *od; struct omap_hwmod *oh; struct device_node *node = pdev->dev.of_node; - const char *oh_name; - int oh_cnt, i, ret = 0; + const char *oh_name, *rst_name; + int oh_cnt, dstr_cnt, i, ret = 0; oh_cnt = of_property_count_strings(node, "ti,hwmods"); if (!oh_cnt || IS_ERR_VALUE(oh_cnt)) { @@ -376,6 +376,27 @@ static int omap_device_build_from_dt(struct platform_device *pdev) if (of_get_property(node, "ti,no_idle_on_suspend", NULL)) omap_device_disable_idle_on_suspend(pdev); + dstr_cnt = + of_property_count_strings(node, "ti,deassert-hard-reset"); + if (dstr_cnt > 0) { + for (i = 0; i < dstr_cnt; i += 2) { + of_property_read_string_index( + node, "ti,deassert-hard-reset", i, + &oh_name); + of_property_read_string_index( + node, "ti,deassert-hard-reset", i+1, + &rst_name); + oh = omap_hwmod_lookup(oh_name); + if (!oh) { + dev_warn(&pdev->dev, + "Cannot parse deassert property for '%s'\n", + oh_name); + break; + } + omap_hwmod_deassert_hardreset(oh, rst_name); + } + } + pdev->dev.pm_domain = &omap_device_pm_domain; odbfd_exit1: -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH 3/3] ARM: dts: AM33xx PRUSS support 2012-09-26 13:44 [RFC PATCH 0/3] uio_pruss support for AM33xx Matt Porter 2012-09-26 13:44 ` [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Matt Porter 2012-09-26 13:44 ` [RFC PATCH 2/3] ARM: omap: add DT support for deasserting hardware reset lines Matt Porter @ 2012-09-26 13:44 ` Matt Porter 2 siblings, 0 replies; 8+ messages in thread From: Matt Porter @ 2012-09-26 13:44 UTC (permalink / raw) To: Greg Kroah-Hartman, Hans J. Koch, Benoit Cousson, Paul Walmsley Cc: Tony Lindgren, Linux OMAP List, Linux Kernel Mailing List Adds a pruss node and an example of use on Beaglebone. Signed-off-by: Matt Porter <mporter@ti.com> --- arch/arm/boot/dts/am335x-bone.dts | 4 ++++ arch/arm/boot/dts/am33xx.dtsi | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts index c634f87..9e070c2 100644 --- a/arch/arm/boot/dts/am335x-bone.dts +++ b/arch/arm/boot/dts/am335x-bone.dts @@ -78,3 +78,7 @@ }; }; }; + +&pruss { + status = "okay"; +}; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index bb31bff..399feb3 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -210,5 +210,16 @@ interrupt-parent = <&intc>; interrupts = <91>; }; + + pruss: pruss@4a300000 { + compatible = "ti,pruss-v2"; + ti,hwmods = "pruss"; + ti,deassert-hard-reset = "pruss", "pruss"; + reg = <0x4a300000 0x080000>; + ti,pintc-offset = <0x20000>; + interrupt-parent = <&intc>; + interrupts = <20 21 22 23 24 25 26 27>; + status = "disabled"; + }; }; }; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-09-28 19:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-09-26 13:44 [RFC PATCH 0/3] uio_pruss support for AM33xx Matt Porter 2012-09-26 13:44 ` [RFC PATCH 1/3] uio: uio_pruss: port to AM33xx Matt Porter 2012-09-26 21:10 ` Greg Kroah-Hartman 2012-09-28 19:20 ` Matt Porter 2012-09-26 23:51 ` Hans J. Koch 2012-09-28 18:53 ` Matt Porter 2012-09-26 13:44 ` [RFC PATCH 2/3] ARM: omap: add DT support for deasserting hardware reset lines Matt Porter 2012-09-26 13:44 ` [RFC PATCH 3/3] ARM: dts: AM33xx PRUSS support Matt Porter
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.