dmaengine: mmp_tdma: add dt support
Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
This commit is contained in:
parent
c8acd6aa6b
commit
f1a7757008
1 changed files with 36 additions and 25 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <mach/regs-icu.h>
|
#include <mach/regs-icu.h>
|
||||||
#include <mach/sram.h>
|
#include <mach/sram.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
|
|
||||||
#include "dmaengine.h"
|
#include "dmaengine.h"
|
||||||
|
|
||||||
|
@ -127,7 +128,6 @@ struct mmp_tdma_device {
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
struct dma_device device;
|
struct dma_device device;
|
||||||
struct mmp_tdma_chan *tdmac[TDMA_CHANNEL_NUM];
|
struct mmp_tdma_chan *tdmac[TDMA_CHANNEL_NUM];
|
||||||
int irq;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define to_mmp_tdma_chan(dchan) container_of(dchan, struct mmp_tdma_chan, chan)
|
#define to_mmp_tdma_chan(dchan) container_of(dchan, struct mmp_tdma_chan, chan)
|
||||||
|
@ -492,7 +492,7 @@ static int __devinit mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
if (irq)
|
if (irq)
|
||||||
tdmac->irq = irq + idx;
|
tdmac->irq = irq;
|
||||||
tdmac->dev = tdev->dev;
|
tdmac->dev = tdev->dev;
|
||||||
tdmac->chan.device = &tdev->device;
|
tdmac->chan.device = &tdev->device;
|
||||||
tdmac->idx = idx;
|
tdmac->idx = idx;
|
||||||
|
@ -505,34 +505,43 @@ static int __devinit mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
|
||||||
/* add the channel to tdma_chan list */
|
/* add the channel to tdma_chan list */
|
||||||
list_add_tail(&tdmac->chan.device_node,
|
list_add_tail(&tdmac->chan.device_node,
|
||||||
&tdev->device.channels);
|
&tdev->device.channels);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct of_device_id mmp_tdma_dt_ids[] = {
|
||||||
|
{ .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA},
|
||||||
|
{ .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU},
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, mmp_tdma_dt_ids);
|
||||||
|
|
||||||
static int __devinit mmp_tdma_probe(struct platform_device *pdev)
|
static int __devinit mmp_tdma_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct platform_device_id *id = platform_get_device_id(pdev);
|
enum mmp_tdma_type type;
|
||||||
enum mmp_tdma_type type = id->driver_data;
|
const struct of_device_id *of_id;
|
||||||
struct mmp_tdma_device *tdev;
|
struct mmp_tdma_device *tdev;
|
||||||
struct resource *iores;
|
struct resource *iores;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
int irq = 0;
|
int irq = 0, irq_num = 0;
|
||||||
int chan_num = TDMA_CHANNEL_NUM;
|
int chan_num = TDMA_CHANNEL_NUM;
|
||||||
|
|
||||||
|
of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev);
|
||||||
|
if (of_id)
|
||||||
|
type = (enum mmp_tdma_type) of_id->data;
|
||||||
|
else
|
||||||
|
type = platform_get_device_id(pdev)->driver_data;
|
||||||
|
|
||||||
/* always have couple channels */
|
/* always have couple channels */
|
||||||
tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL);
|
tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL);
|
||||||
if (!tdev)
|
if (!tdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
tdev->dev = &pdev->dev;
|
tdev->dev = &pdev->dev;
|
||||||
iores = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
|
||||||
if (!iores)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (resource_size(iores) != chan_num)
|
for (i = 0; i < chan_num; i++) {
|
||||||
tdev->irq = iores->start;
|
if (platform_get_irq(pdev, i) > 0)
|
||||||
else
|
irq_num++;
|
||||||
irq = iores->start;
|
}
|
||||||
|
|
||||||
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!iores)
|
if (!iores)
|
||||||
|
@ -542,25 +551,26 @@ static int __devinit mmp_tdma_probe(struct platform_device *pdev)
|
||||||
if (!tdev->base)
|
if (!tdev->base)
|
||||||
return -EADDRNOTAVAIL;
|
return -EADDRNOTAVAIL;
|
||||||
|
|
||||||
if (tdev->irq) {
|
INIT_LIST_HEAD(&tdev->device.channels);
|
||||||
ret = devm_request_irq(&pdev->dev, tdev->irq,
|
|
||||||
|
if (irq_num != chan_num) {
|
||||||
|
irq = platform_get_irq(pdev, 0);
|
||||||
|
ret = devm_request_irq(&pdev->dev, irq,
|
||||||
mmp_tdma_int_handler, IRQF_DISABLED, "tdma", tdev);
|
mmp_tdma_int_handler, IRQF_DISABLED, "tdma", tdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* initialize channel parameters */
|
||||||
|
for (i = 0; i < chan_num; i++) {
|
||||||
|
irq = (irq_num != chan_num) ? 0 : platform_get_irq(pdev, i);
|
||||||
|
ret = mmp_tdma_chan_init(tdev, i, irq, type);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
dma_cap_set(DMA_SLAVE, tdev->device.cap_mask);
|
dma_cap_set(DMA_SLAVE, tdev->device.cap_mask);
|
||||||
dma_cap_set(DMA_CYCLIC, tdev->device.cap_mask);
|
dma_cap_set(DMA_CYCLIC, tdev->device.cap_mask);
|
||||||
|
|
||||||
INIT_LIST_HEAD(&tdev->device.channels);
|
|
||||||
|
|
||||||
/* initialize channel parameters */
|
|
||||||
for (i = 0; i < chan_num; i++) {
|
|
||||||
ret = mmp_tdma_chan_init(tdev, i, irq, type);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
tdev->device.dev = &pdev->dev;
|
tdev->device.dev = &pdev->dev;
|
||||||
tdev->device.device_alloc_chan_resources =
|
tdev->device.device_alloc_chan_resources =
|
||||||
mmp_tdma_alloc_chan_resources;
|
mmp_tdma_alloc_chan_resources;
|
||||||
|
@ -595,6 +605,7 @@ static struct platform_driver mmp_tdma_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "mmp-tdma",
|
.name = "mmp-tdma",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
.of_match_table = mmp_tdma_dt_ids,
|
||||||
},
|
},
|
||||||
.id_table = mmp_tdma_id_table,
|
.id_table = mmp_tdma_id_table,
|
||||||
.probe = mmp_tdma_probe,
|
.probe = mmp_tdma_probe,
|
||||||
|
|
Loading…
Add table
Reference in a new issue