Commit 76c80b5b authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: rsnd: use mod base common method on DMA phase2

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

DMA will be implemented as module. Then rsnd_dma_ops will be rebased
to rsnd_mod_ops, but these are similar, but different function.
This patch modify rsnd_dma_ops same style as rsnd_mod_ops.
This is prepare for final merge
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 940e9479
...@@ -52,9 +52,15 @@ struct rsnd_dma_ctrl { ...@@ -52,9 +52,15 @@ struct rsnd_dma_ctrl {
struct rsnd_dma_ops { struct rsnd_dma_ops {
char *name; char *name;
void (*start)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); void (*start)(struct rsnd_mod *mod,
void (*stop)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); struct rsnd_dai_stream *io,
void (*quit)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); struct rsnd_priv *priv);
void (*stop)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void (*quit)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
}; };
#define rsnd_priv_to_dmac(p) ((struct rsnd_dma_ctrl *)(p)->dma) #define rsnd_priv_to_dmac(p) ((struct rsnd_dma_ctrl *)(p)->dma)
...@@ -101,18 +107,23 @@ static void rsnd_dmaen_complete(void *data) ...@@ -101,18 +107,23 @@ static void rsnd_dmaen_complete(void *data)
rsnd_mod_interrupt(mod, __rsnd_dmaen_complete); rsnd_mod_interrupt(mod, __rsnd_dmaen_complete);
} }
static void rsnd_dmaen_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma) static void rsnd_dmaen_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma); struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
dmaengine_terminate_all(dmaen->chan); dmaengine_terminate_all(dmaen->chan);
} }
static void rsnd_dmaen_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma) static void rsnd_dmaen_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma); struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
struct rsnd_mod *user_mod = dma->user_mod; struct rsnd_mod *user_mod = dma->user_mod;
struct rsnd_priv *priv = rsnd_io_to_priv(io);
struct snd_pcm_substream *substream = io->substream; struct snd_pcm_substream *substream = io->substream;
struct device *dev = rsnd_priv_to_dev(priv); struct device *dev = rsnd_priv_to_dev(priv);
struct dma_async_tx_descriptor *desc; struct dma_async_tx_descriptor *desc;
...@@ -229,7 +240,7 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io, ...@@ -229,7 +240,7 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io,
return 0; return 0;
rsnd_dma_attach_err: rsnd_dma_attach_err:
rsnd_dma_quit(io, rsnd_mod_get(dma)); rsnd_dma_quit(rsnd_mod_get(dma), io, priv);
rsnd_dma_channel_err: rsnd_dma_channel_err:
/* /*
...@@ -241,8 +252,11 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io, ...@@ -241,8 +252,11 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io,
return -EAGAIN; return -EAGAIN;
} }
static void rsnd_dmaen_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma) static void rsnd_dmaen_quit(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma); struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
if (dmaen->chan) if (dmaen->chan)
...@@ -352,8 +366,11 @@ static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg) ...@@ -352,8 +366,11 @@ static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg)
return ioread32(rsnd_dmapp_addr(dmac, dma, reg)); return ioread32(rsnd_dmapp_addr(dmac, dma, reg));
} }
static void rsnd_dmapp_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma) static void rsnd_dmapp_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
int i; int i;
rsnd_dmapp_write(dma, 0, PDMACHCR); rsnd_dmapp_write(dma, 0, PDMACHCR);
...@@ -365,8 +382,11 @@ static void rsnd_dmapp_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma) ...@@ -365,8 +382,11 @@ static void rsnd_dmapp_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
} }
} }
static void rsnd_dmapp_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma) static void rsnd_dmapp_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma); struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
rsnd_dmapp_write(dma, dma->src_addr, PDMASAR); rsnd_dmapp_write(dma, dma->src_addr, PDMASAR);
...@@ -388,8 +408,6 @@ static int rsnd_dmapp_attach(struct rsnd_dai_stream *io, ...@@ -388,8 +408,6 @@ static int rsnd_dmapp_attach(struct rsnd_dai_stream *io,
dmac->dmapp_num++; dmac->dmapp_num++;
rsnd_dmapp_stop(io, dma);
dev_dbg(dev, "id/src/dst/chcr = %d/%pad/%pad/%08x\n", dev_dbg(dev, "id/src/dst/chcr = %d/%pad/%pad/%08x\n",
dmapp->dmapp_id, &dma->src_addr, &dma->dst_addr, dmapp->chcr); dmapp->dmapp_id, &dma->src_addr, &dma->dst_addr, dmapp->chcr);
...@@ -609,30 +627,36 @@ static void rsnd_dma_of_path(struct rsnd_mod *this, ...@@ -609,30 +627,36 @@ static void rsnd_dma_of_path(struct rsnd_mod *this,
} }
} }
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_mod *mod) void rsnd_dma_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod); struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
dma->ops->stop(io, dma); dma->ops->stop(mod, io, priv);
} }
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_mod *mod) void rsnd_dma_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod); struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
dma->ops->start(io, dma); dma->ops->start(mod, io, priv);
} }
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_mod *mod) void rsnd_dma_quit(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{ {
struct rsnd_dma *dma = rsnd_mod_to_dma(mod); struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
if (!dmac) if (!dmac)
return; return;
dma->ops->quit(io, dma); dma->ops->quit(mod, io, priv);
} }
static struct rsnd_mod_ops rsnd_dma_ops = { static struct rsnd_mod_ops rsnd_dma_ops = {
......
...@@ -193,11 +193,17 @@ void rsnd_path_parse(struct rsnd_priv *priv, ...@@ -193,11 +193,17 @@ void rsnd_path_parse(struct rsnd_priv *priv,
/* /*
* R-Car DMA * R-Car DMA
*/ */
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_mod *mod); void rsnd_dma_start(struct rsnd_mod *mod,
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_mod *mod); struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void rsnd_dma_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void rsnd_dma_quit(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
struct rsnd_mod *rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *rsnd_dma_attach(struct rsnd_dai_stream *io,
struct rsnd_mod *mod, int id); struct rsnd_mod *mod, int id);
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
int rsnd_dma_probe(struct platform_device *pdev, int rsnd_dma_probe(struct platform_device *pdev,
const struct rsnd_of_data *of_data, const struct rsnd_of_data *of_data,
struct rsnd_priv *priv); struct rsnd_priv *priv);
......
...@@ -843,7 +843,7 @@ static int rsnd_src_remove_gen2(struct rsnd_mod *mod, ...@@ -843,7 +843,7 @@ static int rsnd_src_remove_gen2(struct rsnd_mod *mod,
{ {
struct rsnd_src *src = rsnd_mod_to_src(mod); struct rsnd_src *src = rsnd_mod_to_src(mod);
rsnd_dma_quit(io, rsnd_src_to_dma(src)); rsnd_dma_quit(rsnd_src_to_dma(src), io, priv);
return 0; return 0;
} }
...@@ -875,7 +875,7 @@ static int rsnd_src_start_gen2(struct rsnd_mod *mod, ...@@ -875,7 +875,7 @@ static int rsnd_src_start_gen2(struct rsnd_mod *mod,
{ {
struct rsnd_src *src = rsnd_mod_to_src(mod); struct rsnd_src *src = rsnd_mod_to_src(mod);
rsnd_dma_start(io, rsnd_src_to_dma(src)); rsnd_dma_start(rsnd_src_to_dma(src), io, priv);
return _rsnd_src_start_gen2(mod, io); return _rsnd_src_start_gen2(mod, io);
} }
...@@ -889,7 +889,7 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod, ...@@ -889,7 +889,7 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod,
ret = _rsnd_src_stop_gen2(mod); ret = _rsnd_src_stop_gen2(mod);
rsnd_dma_stop(io, rsnd_src_to_dma(src)); rsnd_dma_stop(rsnd_src_to_dma(src), io, priv);
return ret; return ret;
} }
......
...@@ -596,7 +596,7 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, ...@@ -596,7 +596,7 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod,
struct device *dev = rsnd_priv_to_dev(priv); struct device *dev = rsnd_priv_to_dev(priv);
int irq = ssi->info->irq; int irq = ssi->info->irq;
rsnd_dma_quit(io, rsnd_ssi_to_dma(ssi)); rsnd_dma_quit(rsnd_ssi_to_dma(ssi), io, priv);
/* PIO will request IRQ again */ /* PIO will request IRQ again */
devm_free_irq(dev, irq, mod); devm_free_irq(dev, irq, mod);
...@@ -632,7 +632,7 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod, ...@@ -632,7 +632,7 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod,
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
struct rsnd_mod *dma = rsnd_ssi_to_dma(ssi); struct rsnd_mod *dma = rsnd_ssi_to_dma(ssi);
rsnd_dma_start(io, dma); rsnd_dma_start(dma, io, priv);
rsnd_ssi_start(mod, io, priv); rsnd_ssi_start(mod, io, priv);
...@@ -648,7 +648,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, ...@@ -648,7 +648,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod,
rsnd_ssi_stop(mod, io, priv); rsnd_ssi_stop(mod, io, priv);
rsnd_dma_stop(io, dma); rsnd_dma_stop(dma, io, priv);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment