[PATCH 1/3] dma: rcar-audmapp: enable .set_slave

From: Kuninori Morimoto
Date: Wed Jun 18 2014 - 04:59:37 EST


From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>

Current .set_slave callback did nothing,
since it assumed src/dst address come from platform settings.
But, it isn't good match to DT probing.
This patch enables .set_slave callback to this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
drivers/dma/sh/rcar-audmapp.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
index 2de7728..858483b 100644
--- a/drivers/dma/sh/rcar-audmapp.c
+++ b/drivers/dma/sh/rcar-audmapp.c
@@ -47,6 +47,7 @@ struct audmapp_chan {
struct shdma_chan shdma_chan;
struct audmapp_slave_config *config;
void __iomem *base;
+ dma_addr_t slave_addr;
};

struct audmapp_device {
@@ -56,7 +57,14 @@ struct audmapp_device {
void __iomem *chan_reg;
};

+struct audmapp_desc {
+ struct shdma_desc shdma_desc;
+ dma_addr_t src;
+ dma_addr_t dst;
+};
+
#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
+#define to_desc(sdesc) container_of(sdesc, struct audmapp_desc, shdma_desc)
#define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device, \
struct audmapp_device, shdma_dev.dma_dev)

@@ -90,19 +98,20 @@ static void audmapp_halt(struct shdma_chan *schan)
}

static void audmapp_start_xfer(struct shdma_chan *schan,
- struct shdma_desc *sdecs)
+ struct shdma_desc *sdesc)
{
struct audmapp_chan *auchan = to_chan(schan);
struct audmapp_device *audev = to_dev(auchan);
+ struct audmapp_desc *desc = to_desc(sdesc);
struct audmapp_slave_config *cfg = auchan->config;
struct device *dev = audev->dev;
u32 chcr = cfg->chcr | PDMACHCR_DE;

- dev_dbg(dev, "src/dst/chcr = %pad/%pad/%x\n",
- &cfg->src, &cfg->dst, cfg->chcr);
+ dev_dbg(dev, "src/dst/chcr = %pad/%pad/%08x\n",
+ &desc->src, &desc->dst, chcr);

- audmapp_write(auchan, cfg->src, PDMASAR);
- audmapp_write(auchan, cfg->dst, PDMADAR);
+ audmapp_write(auchan, desc->src, PDMASAR);
+ audmapp_write(auchan, desc->dst, PDMADAR);
audmapp_write(auchan, chcr, PDMACHCR);
}

@@ -137,14 +146,16 @@ static int audmapp_set_slave(struct shdma_chan *schan, int slave_id,
return 0;

auchan->config = cfg;
+ auchan->slave_addr = slave_addr ? : cfg->dst;

return 0;
}

static int audmapp_desc_setup(struct shdma_chan *schan,
- struct shdma_desc *sdecs,
+ struct shdma_desc *sdesc,
dma_addr_t src, dma_addr_t dst, size_t *len)
{
+ struct audmapp_desc *desc = to_desc(sdesc);
struct audmapp_chan *auchan = to_chan(schan);
struct audmapp_slave_config *cfg = auchan->config;

@@ -154,6 +165,9 @@ static int audmapp_desc_setup(struct shdma_chan *schan,
if (*len > (size_t)AUDMAPP_LEN_MAX)
*len = (size_t)AUDMAPP_LEN_MAX;

+ desc->src = src;
+ desc->dst = dst;
+
return 0;
}

@@ -164,7 +178,9 @@ static void audmapp_setup_xfer(struct shdma_chan *schan,

static dma_addr_t audmapp_slave_addr(struct shdma_chan *schan)
{
- return 0; /* always fixed address */
+ struct audmapp_chan *auchan = to_chan(schan);
+
+ return auchan->slave_addr;
}

static bool audmapp_channel_busy(struct shdma_chan *schan)
@@ -183,7 +199,7 @@ static bool audmapp_desc_completed(struct shdma_chan *schan,

static struct shdma_desc *audmapp_embedded_desc(void *buf, int i)
{
- return &((struct shdma_desc *)buf)[i];
+ return &((struct audmapp_desc *)buf)[i].shdma_desc;
}

static const struct shdma_ops audmapp_shdma_ops = {
@@ -260,7 +276,7 @@ static int audmapp_probe(struct platform_device *pdev)

sdev = &audev->shdma_dev;
sdev->ops = &audmapp_shdma_ops;
- sdev->desc_size = sizeof(struct shdma_desc);
+ sdev->desc_size = sizeof(struct audmapp_desc);

dma_dev = &sdev->dma_dev;
dma_dev->copy_align = LOG2_DEFAULT_XFER_SIZE;
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/