Message ID | 1404058907-21112-10-git-send-email-a.heider@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sun, Jun 29, 2014 at 05:21:43PM +0100, Andre Heider wrote: > Add support to probe via devicetree. > > Signed-off-by: Andre Heider <a.heider@gmail.com> > --- > drivers/uio/uio_pruss.c | 46 +++++++++++++++++++++++++++++++++++++++------- > 1 file changed, 39 insertions(+), 7 deletions(-) > > diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c > index afaf726..2df54ab 100644 > --- a/drivers/uio/uio_pruss.c > +++ b/drivers/uio/uio_pruss.c > @@ -26,6 +26,7 @@ > #include <linux/dma-mapping.h> > #include <linux/slab.h> > #include <linux/genalloc.h> > +#include <linux/of_device.h> > > #define DRV_NAME "pruss_uio" > #define DRV_VERSION "1.0" > @@ -70,6 +71,27 @@ struct uio_pruss_dev { > struct gen_pool *sram_pool; > }; > > +#ifdef CONFIG_OF > +struct uio_pruss_params { > + u32 pintc_offset; > +}; > + > +static const struct uio_pruss_params uio_pruss_v1_params = { > + .pintc_offset = 0x4000, > +}; > + > +static const struct uio_pruss_params uio_pruss_v2_params = { > + .pintc_offset = 0x20000, > +}; > + > +static const struct of_device_id pruss_of_match_table[] = { > + { .compatible = "ti,pruss-v1", .data = &uio_pruss_v1_params, }, > + { .compatible = "ti,pruss-v2", .data = &uio_pruss_v2_params, }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, pruss_of_match_table); > +#endif > + > static irqreturn_t pruss_handler(int irq, struct uio_info *info) > { > struct uio_pruss_dev *gdev = info->priv; > @@ -111,6 +133,8 @@ static int pruss_probe(struct platform_device *pdev) > struct uio_pruss_dev *gdev; > struct resource *regs_prussio; > struct device *dev = &pdev->dev; > + const struct of_device_id *match; > + const struct uio_pruss_params *params; > int ret = -ENODEV, cnt = 0, i; > struct uio_pruss_pdata *pdata = dev_get_platdata(dev); > dma_addr_t ddr_paddr; > @@ -123,13 +147,21 @@ static int pruss_probe(struct platform_device *pdev) > if (!gdev->info) > return -ENOMEM; > > - /* Power on PRU in case its not done as part of boot-loader */ > - gdev->pruss_clk = clk_get(dev, "pruss"); > - if (IS_ERR(gdev->pruss_clk)) { > - dev_err(dev, "Failed to get clock\n"); > - return PTR_ERR(gdev->pruss_clk); > + if (dev->of_node) { > + match = of_match_device(pruss_of_match_table, dev); > + params = match->data; > + gdev->pintc_base = params->pintc_offset; > } else { > + /* Power on PRU in case its not done as part of boot-loader */ > + gdev->pruss_clk = clk_get(dev, "pruss"); > + if (IS_ERR(gdev->pruss_clk)) { > + dev_err(dev, "Failed to get clock\n"); > + return PTR_ERR(gdev->pruss_clk); > + } The "pruss" clock was not documented in the binding. Is the clock really called "pruss", or is it given a specific name in the manual? Cheers, Mark.
On Mon, Jun 30, 2014 at 10:36:06AM +0100, Mark Rutland wrote: > On Sun, Jun 29, 2014 at 05:21:43PM +0100, Andre Heider wrote: > > - /* Power on PRU in case its not done as part of boot-loader */ > > - gdev->pruss_clk = clk_get(dev, "pruss"); > > - if (IS_ERR(gdev->pruss_clk)) { > > - dev_err(dev, "Failed to get clock\n"); > > - return PTR_ERR(gdev->pruss_clk); > > + if (dev->of_node) { > > + match = of_match_device(pruss_of_match_table, dev); > > + params = match->data; > > + gdev->pintc_base = params->pintc_offset; > > } else { > > + /* Power on PRU in case its not done as part of boot-loader */ > > + gdev->pruss_clk = clk_get(dev, "pruss"); > > + if (IS_ERR(gdev->pruss_clk)) { > > + dev_err(dev, "Failed to get clock\n"); > > + return PTR_ERR(gdev->pruss_clk); > > + } > > The "pruss" clock was not documented in the binding. > > Is the clock really called "pruss", or is it given a specific name in > the manual? That hunk was moved, see above. It's not the devicetree path, it's for non-DT TI DaVinci: arch/arm/mach-davinci/da850.c:static struct clk pruss_clk = { arch/arm/mach-davinci/da850.c: .name = "pruss", The DT path already has a clocks associated at the hwmod level. From arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c: struct omap_hwmod am33xx_pruss_hwmod = { .name = "pruss", .class = &am33xx_pruss_hwmod_class, .clkdm_name = "pruss_ocp_clkdm", .flags = HWMOD_INIT_DEASSERT_HARD_RESET, .main_clk = "pruss_ocp_gclk", and doesn't require any additional clock entries as far as the binding is concerned. Thanks, Andre
diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index afaf726..2df54ab 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -26,6 +26,7 @@ #include <linux/dma-mapping.h> #include <linux/slab.h> #include <linux/genalloc.h> +#include <linux/of_device.h> #define DRV_NAME "pruss_uio" #define DRV_VERSION "1.0" @@ -70,6 +71,27 @@ struct uio_pruss_dev { struct gen_pool *sram_pool; }; +#ifdef CONFIG_OF +struct uio_pruss_params { + u32 pintc_offset; +}; + +static const struct uio_pruss_params uio_pruss_v1_params = { + .pintc_offset = 0x4000, +}; + +static const struct uio_pruss_params uio_pruss_v2_params = { + .pintc_offset = 0x20000, +}; + +static const struct of_device_id pruss_of_match_table[] = { + { .compatible = "ti,pruss-v1", .data = &uio_pruss_v1_params, }, + { .compatible = "ti,pruss-v2", .data = &uio_pruss_v2_params, }, + {}, +}; +MODULE_DEVICE_TABLE(of, pruss_of_match_table); +#endif + static irqreturn_t pruss_handler(int irq, struct uio_info *info) { struct uio_pruss_dev *gdev = info->priv; @@ -111,6 +133,8 @@ static int pruss_probe(struct platform_device *pdev) struct uio_pruss_dev *gdev; struct resource *regs_prussio; struct device *dev = &pdev->dev; + const struct of_device_id *match; + const struct uio_pruss_params *params; int ret = -ENODEV, cnt = 0, i; struct uio_pruss_pdata *pdata = dev_get_platdata(dev); dma_addr_t ddr_paddr; @@ -123,13 +147,21 @@ static int pruss_probe(struct platform_device *pdev) if (!gdev->info) return -ENOMEM; - /* Power on PRU in case its not done as part of boot-loader */ - gdev->pruss_clk = clk_get(dev, "pruss"); - if (IS_ERR(gdev->pruss_clk)) { - dev_err(dev, "Failed to get clock\n"); - return PTR_ERR(gdev->pruss_clk); + if (dev->of_node) { + match = of_match_device(pruss_of_match_table, dev); + params = match->data; + gdev->pintc_base = params->pintc_offset; } else { + /* Power on PRU in case its not done as part of boot-loader */ + gdev->pruss_clk = clk_get(dev, "pruss"); + if (IS_ERR(gdev->pruss_clk)) { + dev_err(dev, "Failed to get clock\n"); + return PTR_ERR(gdev->pruss_clk); + } + clk_enable(gdev->pruss_clk); + + gdev->pintc_base = pdata->pintc_base; } regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -139,7 +171,7 @@ static int pruss_probe(struct platform_device *pdev) goto out_free; } - if (pdata->sram_pool) { + if (pdata && pdata->sram_pool) { gdev->sram_pool = pdata->sram_pool; gdev->sram_vaddr = (unsigned long)gen_pool_dma_alloc(gdev->sram_pool, @@ -156,7 +188,6 @@ static int pruss_probe(struct platform_device *pdev) goto out_free; } - gdev->pintc_base = pdata->pintc_base; gdev->hostirq_start = platform_get_irq(pdev, 0); for (cnt = 0, p = gdev->info; cnt < MAX_PRUSS_EVT; cnt++, p++) { @@ -214,6 +245,7 @@ static struct platform_driver pruss_driver = { .driver = { .name = DRV_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(pruss_of_match_table), }, };
Add support to probe via devicetree. Signed-off-by: Andre Heider <a.heider@gmail.com> --- drivers/uio/uio_pruss.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-)