2018-06-12 12:58:38 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//
|
|
|
|
// Renesas R-Car Audio DMAC support
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015 Renesas Electronics Corp.
|
|
|
|
// Copyright (c) 2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
#include <linux/delay.h>
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
#include <linux/of_dma.h>
|
2015-02-20 17:25:55 +07:00
|
|
|
#include "rsnd.h"
|
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
/*
|
|
|
|
* Audio DMAC peri peri register
|
|
|
|
*/
|
|
|
|
#define PDMASAR 0x00
|
|
|
|
#define PDMADAR 0x04
|
|
|
|
#define PDMACHCR 0x0c
|
|
|
|
|
|
|
|
/* PDMACHCR */
|
|
|
|
#define PDMACHCR_DE (1 << 0)
|
|
|
|
|
2015-10-26 15:38:58 +07:00
|
|
|
|
|
|
|
struct rsnd_dmaen {
|
|
|
|
struct dma_chan *chan;
|
2017-06-07 07:20:01 +07:00
|
|
|
dma_cookie_t cookie;
|
2016-11-14 11:20:56 +07:00
|
|
|
unsigned int dma_len;
|
2015-10-26 15:38:58 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rsnd_dmapp {
|
|
|
|
int dmapp_id;
|
|
|
|
u32 chcr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rsnd_dma {
|
2015-10-26 15:42:25 +07:00
|
|
|
struct rsnd_mod mod;
|
2016-11-14 11:20:40 +07:00
|
|
|
struct rsnd_mod *mod_from;
|
|
|
|
struct rsnd_mod *mod_to;
|
2015-10-26 15:38:58 +07:00
|
|
|
dma_addr_t src_addr;
|
|
|
|
dma_addr_t dst_addr;
|
|
|
|
union {
|
|
|
|
struct rsnd_dmaen en;
|
|
|
|
struct rsnd_dmapp pp;
|
|
|
|
} dma;
|
|
|
|
};
|
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
struct rsnd_dma_ctrl {
|
|
|
|
void __iomem *base;
|
2015-10-26 15:42:25 +07:00
|
|
|
int dmaen_num;
|
2015-02-20 17:27:42 +07:00
|
|
|
int dmapp_num;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define rsnd_priv_to_dmac(p) ((struct rsnd_dma_ctrl *)(p)->dma)
|
2015-10-26 15:42:25 +07:00
|
|
|
#define rsnd_mod_to_dma(_mod) container_of((_mod), struct rsnd_dma, mod)
|
2015-10-26 15:38:58 +07:00
|
|
|
#define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en)
|
|
|
|
#define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp)
|
2015-02-20 17:27:42 +07:00
|
|
|
|
ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()
Current rsnd driver has rsnd_mod_id() which returns mod ID,
and it returns -1 if mod was NULL.
In the same time, this driver has rsnd_mod_name() which returns mod
name, and it returns "unknown" if mod or mod->ops was NULL.
Basically these "mod" never be NULL, but the reason why rsnd driver
has such behavior is that DMA path finder is assuming memory as
"mod == NULL".
Thus, current DMA path debug code prints like below.
Here "unknown[-1]" means it was memory.
...
rcar_sound ec500000.sound: unknown[-1] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] unknown[-1] -> src[0]
...
1st issue is that it is confusable for user.
2nd issue is rsnd driver has something like below code.
mask |= 1 << rsnd_mod_id(mod);
Because of this kind of code, some statically code checker will
reports "Shifting by a negative value is undefined behaviour".
But this "mod" never be NULL, thus negative shift never happen.
To avoid these issues, this patch adds new dummy "mem" to
indicate memory, and use it to indicate debug information,
and, remove unneeded "NULL mod" behavior from rsnd_mod_id() and
rsnd_mod_name().
The debug information will be like below by this patch
...
rcar_sound ec500000.sound: mem[0] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] mem[0] -> src[0]
...
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-01 14:17:34 +07:00
|
|
|
/* for DEBUG */
|
|
|
|
static struct rsnd_mod_ops mem_ops = {
|
|
|
|
.name = "mem",
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct rsnd_mod mem = {
|
|
|
|
};
|
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
/*
|
|
|
|
* Audio DMAC
|
|
|
|
*/
|
2015-06-15 13:26:25 +07:00
|
|
|
static void __rsnd_dmaen_complete(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io)
|
2015-02-20 17:25:55 +07:00
|
|
|
{
|
2017-11-16 11:36:51 +07:00
|
|
|
if (rsnd_io_is_working(io))
|
2015-06-15 13:21:15 +07:00
|
|
|
rsnd_dai_period_elapsed(io);
|
2015-02-20 17:25:55 +07:00
|
|
|
}
|
|
|
|
|
2015-06-15 13:26:25 +07:00
|
|
|
static void rsnd_dmaen_complete(void *data)
|
|
|
|
{
|
|
|
|
struct rsnd_mod *mod = data;
|
|
|
|
|
|
|
|
rsnd_mod_interrupt(mod, __rsnd_dmaen_complete);
|
|
|
|
}
|
|
|
|
|
2016-11-14 11:20:40 +07:00
|
|
|
static struct dma_chan *rsnd_dmaen_request_channel(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod_from,
|
|
|
|
struct rsnd_mod *mod_to)
|
|
|
|
{
|
|
|
|
if ((!mod_from && !mod_to) ||
|
|
|
|
(mod_from && mod_to))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (mod_from)
|
|
|
|
return rsnd_mod_dma_req(io, mod_from);
|
|
|
|
else
|
|
|
|
return rsnd_mod_dma_req(io, mod_to);
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:01 +07:00
|
|
|
static int rsnd_dmaen_stop(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
2015-02-20 17:25:55 +07:00
|
|
|
{
|
2015-10-26 15:42:46 +07:00
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
2015-02-20 17:29:13 +07:00
|
|
|
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
|
|
|
|
2017-11-16 11:36:51 +07:00
|
|
|
if (dmaen->chan)
|
2016-11-14 11:20:40 +07:00
|
|
|
dmaengine_terminate_all(dmaen->chan);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-03 14:09:17 +07:00
|
|
|
static int rsnd_dmaen_cleanup(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
2016-11-14 11:20:40 +07:00
|
|
|
{
|
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
|
|
|
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DMAEngine release uses mutex lock.
|
|
|
|
* Thus, it shouldn't be called under spinlock.
|
2018-09-03 14:09:17 +07:00
|
|
|
* Let's call it under prepare
|
2016-11-14 11:20:40 +07:00
|
|
|
*/
|
|
|
|
if (dmaen->chan)
|
|
|
|
dma_release_channel(dmaen->chan);
|
|
|
|
|
|
|
|
dmaen->chan = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-03 14:09:17 +07:00
|
|
|
static int rsnd_dmaen_prepare(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
2016-11-14 11:20:40 +07:00
|
|
|
{
|
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
|
|
|
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
|
2018-09-21 11:59:59 +07:00
|
|
|
/* maybe suspended */
|
|
|
|
if (dmaen->chan)
|
|
|
|
return 0;
|
2016-11-14 11:20:40 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* DMAEngine request uses mutex lock.
|
|
|
|
* Thus, it shouldn't be called under spinlock.
|
2018-09-03 14:09:17 +07:00
|
|
|
* Let's call it under prepare
|
2016-11-14 11:20:40 +07:00
|
|
|
*/
|
|
|
|
dmaen->chan = rsnd_dmaen_request_channel(io,
|
|
|
|
dma->mod_from,
|
|
|
|
dma->mod_to);
|
|
|
|
if (IS_ERR_OR_NULL(dmaen->chan)) {
|
|
|
|
dmaen->chan = NULL;
|
|
|
|
dev_err(dev, "can't get dma channel\n");
|
2017-11-06 08:07:27 +07:00
|
|
|
return -EIO;
|
2016-11-14 11:20:40 +07:00
|
|
|
}
|
2015-10-26 15:43:01 +07:00
|
|
|
|
|
|
|
return 0;
|
2015-02-20 17:25:55 +07:00
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:01 +07:00
|
|
|
static int rsnd_dmaen_start(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
2015-02-20 17:25:55 +07:00
|
|
|
{
|
2015-10-26 15:42:46 +07:00
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
2015-02-20 17:29:13 +07:00
|
|
|
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
2015-02-20 17:25:55 +07:00
|
|
|
struct snd_pcm_substream *substream = io->substream;
|
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
struct dma_async_tx_descriptor *desc;
|
2016-11-14 11:20:40 +07:00
|
|
|
struct dma_slave_config cfg = {};
|
2019-10-23 01:55:18 +07:00
|
|
|
enum dma_slave_buswidth buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
2015-02-20 17:28:32 +07:00
|
|
|
int is_play = rsnd_io_is_play(io);
|
2016-11-14 11:20:40 +07:00
|
|
|
int ret;
|
|
|
|
|
2019-10-23 01:55:18 +07:00
|
|
|
/*
|
|
|
|
* in case of monaural data writing or reading through Audio-DMAC
|
|
|
|
* data is always in Left Justified format, so both src and dst
|
|
|
|
* DMA Bus width need to be set equal to physical data width.
|
|
|
|
*/
|
|
|
|
if (rsnd_runtime_channel_original(io) == 1) {
|
|
|
|
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
|
|
|
int bits = snd_pcm_format_physical_width(runtime->format);
|
|
|
|
|
|
|
|
switch (bits) {
|
|
|
|
case 8:
|
|
|
|
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_err(dev, "invalid format width %d\n", bits);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-14 11:20:40 +07:00
|
|
|
cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
|
|
|
|
cfg.src_addr = dma->src_addr;
|
|
|
|
cfg.dst_addr = dma->dst_addr;
|
2019-10-23 01:55:18 +07:00
|
|
|
cfg.src_addr_width = buswidth;
|
|
|
|
cfg.dst_addr_width = buswidth;
|
2016-11-14 11:20:40 +07:00
|
|
|
|
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.
In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.
To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-30 14:47:50 +07:00
|
|
|
dev_dbg(dev, "%s %pad -> %pad\n",
|
|
|
|
rsnd_mod_name(mod),
|
2016-11-14 11:20:40 +07:00
|
|
|
&cfg.src_addr, &cfg.dst_addr);
|
|
|
|
|
|
|
|
ret = dmaengine_slave_config(dmaen->chan, &cfg);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2015-02-20 17:29:13 +07:00
|
|
|
desc = dmaengine_prep_dma_cyclic(dmaen->chan,
|
2017-11-16 11:36:51 +07:00
|
|
|
substream->runtime->dma_addr,
|
|
|
|
snd_pcm_lib_buffer_bytes(substream),
|
|
|
|
snd_pcm_lib_period_bytes(substream),
|
2015-02-20 17:28:32 +07:00
|
|
|
is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM,
|
2015-02-20 17:25:55 +07:00
|
|
|
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
|
|
|
|
|
|
|
|
if (!desc) {
|
|
|
|
dev_err(dev, "dmaengine_prep_slave_sg() fail\n");
|
2015-10-26 15:43:01 +07:00
|
|
|
return -EIO;
|
2015-02-20 17:25:55 +07:00
|
|
|
}
|
|
|
|
|
2015-02-20 17:27:12 +07:00
|
|
|
desc->callback = rsnd_dmaen_complete;
|
2015-10-26 15:43:01 +07:00
|
|
|
desc->callback_param = rsnd_mod_get(dma);
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2017-11-16 11:36:51 +07:00
|
|
|
dmaen->dma_len = snd_pcm_lib_buffer_bytes(substream);
|
2016-11-14 11:20:56 +07:00
|
|
|
|
2017-06-07 07:20:01 +07:00
|
|
|
dmaen->cookie = dmaengine_submit(desc);
|
|
|
|
if (dmaen->cookie < 0) {
|
2015-02-20 17:25:55 +07:00
|
|
|
dev_err(dev, "dmaengine_submit() fail\n");
|
2015-10-26 15:43:01 +07:00
|
|
|
return -EIO;
|
2015-02-20 17:25:55 +07:00
|
|
|
}
|
|
|
|
|
2015-02-20 17:29:13 +07:00
|
|
|
dma_async_issue_pending(dmaen->chan);
|
2015-10-26 15:43:01 +07:00
|
|
|
|
|
|
|
return 0;
|
2015-02-20 17:25:55 +07:00
|
|
|
}
|
|
|
|
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node,
|
|
|
|
struct rsnd_mod *mod, char *name)
|
|
|
|
{
|
2016-10-25 07:37:18 +07:00
|
|
|
struct dma_chan *chan = NULL;
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
struct device_node *np;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
for_each_child_of_node(of_node, np) {
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
if (i == rsnd_mod_id_raw(mod) && (!chan))
|
2016-10-25 07:37:18 +07:00
|
|
|
chan = of_dma_request_slave_channel(np, name);
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2016-10-25 07:37:18 +07:00
|
|
|
/* It should call of_node_put(), since, it is rsnd_xxx_of_node() */
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
of_node_put(of_node);
|
|
|
|
|
|
|
|
return chan;
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:39:20 +07:00
|
|
|
static int rsnd_dmaen_attach(struct rsnd_dai_stream *io,
|
2016-10-25 07:36:13 +07:00
|
|
|
struct rsnd_dma *dma,
|
2015-02-20 17:27:12 +07:00
|
|
|
struct rsnd_mod *mod_from, struct rsnd_mod *mod_to)
|
2015-02-20 17:25:55 +07:00
|
|
|
{
|
2015-06-15 13:26:25 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
2015-10-26 15:42:25 +07:00
|
|
|
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
2016-11-14 11:20:40 +07:00
|
|
|
struct dma_chan *chan;
|
|
|
|
|
|
|
|
/* try to get DMAEngine channel */
|
|
|
|
chan = rsnd_dmaen_request_channel(io, mod_from, mod_to);
|
|
|
|
if (IS_ERR_OR_NULL(chan)) {
|
2018-09-06 10:21:47 +07:00
|
|
|
/* Let's follow when -EPROBE_DEFER case */
|
|
|
|
if (PTR_ERR(chan) == -EPROBE_DEFER)
|
|
|
|
return PTR_ERR(chan);
|
|
|
|
|
2016-11-14 11:20:40 +07:00
|
|
|
/*
|
|
|
|
* DMA failed. try to PIO mode
|
|
|
|
* see
|
|
|
|
* rsnd_ssi_fallback()
|
|
|
|
* rsnd_rdai_continuance_probe()
|
|
|
|
*/
|
|
|
|
return -EAGAIN;
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
}
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2018-04-16 12:14:01 +07:00
|
|
|
/*
|
|
|
|
* use it for IPMMU if needed
|
|
|
|
* see
|
|
|
|
* rsnd_preallocate_pages()
|
|
|
|
*/
|
|
|
|
io->dmac_dev = chan->device->dev;
|
|
|
|
|
2016-11-14 11:20:40 +07:00
|
|
|
dma_release_channel(chan);
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2015-10-26 15:42:25 +07:00
|
|
|
dmac->dmaen_num++;
|
|
|
|
|
2015-02-20 17:25:55 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-06-07 07:20:01 +07:00
|
|
|
static int rsnd_dmaen_pointer(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
snd_pcm_uframes_t *pointer)
|
|
|
|
{
|
|
|
|
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
|
|
|
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
|
|
|
|
struct dma_tx_state state;
|
|
|
|
enum dma_status status;
|
|
|
|
unsigned int pos = 0;
|
|
|
|
|
|
|
|
status = dmaengine_tx_status(dmaen->chan, dmaen->cookie, &state);
|
|
|
|
if (status == DMA_IN_PROGRESS || status == DMA_PAUSED) {
|
|
|
|
if (state.residue > 0 && state.residue <= dmaen->dma_len)
|
|
|
|
pos = dmaen->dma_len - state.residue;
|
|
|
|
}
|
|
|
|
*pointer = bytes_to_frames(runtime, pos);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:01 +07:00
|
|
|
static struct rsnd_mod_ops rsnd_dmaen_ops = {
|
2018-10-30 14:46:05 +07:00
|
|
|
.name = "audmac",
|
|
|
|
.prepare = rsnd_dmaen_prepare,
|
|
|
|
.cleanup = rsnd_dmaen_cleanup,
|
|
|
|
.start = rsnd_dmaen_start,
|
|
|
|
.stop = rsnd_dmaen_stop,
|
|
|
|
.pointer = rsnd_dmaen_pointer,
|
|
|
|
.get_status = rsnd_mod_get_status,
|
2015-02-20 17:27:12 +07:00
|
|
|
};
|
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
/*
|
|
|
|
* Audio DMAC peri peri
|
|
|
|
*/
|
|
|
|
static const u8 gen2_id_table_ssiu[] = {
|
2018-09-03 14:08:00 +07:00
|
|
|
/* SSI00 ~ SSI07 */
|
|
|
|
0x00, 0x01, 0x02, 0x03, 0x39, 0x3a, 0x3b, 0x3c,
|
|
|
|
/* SSI10 ~ SSI17 */
|
|
|
|
0x04, 0x05, 0x06, 0x07, 0x3d, 0x3e, 0x3f, 0x40,
|
|
|
|
/* SSI20 ~ SSI27 */
|
|
|
|
0x08, 0x09, 0x0a, 0x0b, 0x41, 0x42, 0x43, 0x44,
|
|
|
|
/* SSI30 ~ SSI37 */
|
|
|
|
0x0c, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
|
|
|
|
/* SSI40 ~ SSI47 */
|
|
|
|
0x0d, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52,
|
|
|
|
/* SSI5 */
|
|
|
|
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
/* SSI6 */
|
|
|
|
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
/* SSI7 */
|
|
|
|
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
/* SSI8 */
|
|
|
|
0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
/* SSI90 ~ SSI97 */
|
|
|
|
0x12, 0x13, 0x14, 0x15, 0x53, 0x54, 0x55, 0x56,
|
2015-02-20 17:27:42 +07:00
|
|
|
};
|
|
|
|
static const u8 gen2_id_table_scu[] = {
|
|
|
|
0x2d, /* SCU_SRCI0 */
|
|
|
|
0x2e, /* SCU_SRCI1 */
|
|
|
|
0x2f, /* SCU_SRCI2 */
|
|
|
|
0x30, /* SCU_SRCI3 */
|
|
|
|
0x31, /* SCU_SRCI4 */
|
|
|
|
0x32, /* SCU_SRCI5 */
|
|
|
|
0x33, /* SCU_SRCI6 */
|
|
|
|
0x34, /* SCU_SRCI7 */
|
|
|
|
0x35, /* SCU_SRCI8 */
|
|
|
|
0x36, /* SCU_SRCI9 */
|
|
|
|
};
|
|
|
|
static const u8 gen2_id_table_cmd[] = {
|
|
|
|
0x37, /* SCU_CMD0 */
|
|
|
|
0x38, /* SCU_CMD1 */
|
|
|
|
};
|
|
|
|
|
2015-06-15 13:26:25 +07:00
|
|
|
static u32 rsnd_dmapp_get_id(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod)
|
2015-02-20 17:27:42 +07:00
|
|
|
{
|
|
|
|
struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
|
2015-02-20 17:27:42 +07:00
|
|
|
struct rsnd_mod *src = rsnd_io_to_mod_src(io);
|
|
|
|
struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
|
|
|
|
const u8 *entry = NULL;
|
2018-09-03 14:08:00 +07:00
|
|
|
int id = 255;
|
2015-02-20 17:27:42 +07:00
|
|
|
int size = 0;
|
|
|
|
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
if ((mod == ssi) ||
|
|
|
|
(mod == ssiu)) {
|
|
|
|
int busif = rsnd_mod_id_sub(ssiu);
|
2018-09-03 14:08:00 +07:00
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
entry = gen2_id_table_ssiu;
|
|
|
|
size = ARRAY_SIZE(gen2_id_table_ssiu);
|
2018-09-03 14:08:00 +07:00
|
|
|
id = (rsnd_mod_id(mod) * 8) + busif;
|
2015-02-20 17:27:42 +07:00
|
|
|
} else if (mod == src) {
|
|
|
|
entry = gen2_id_table_scu;
|
|
|
|
size = ARRAY_SIZE(gen2_id_table_scu);
|
2018-09-03 14:08:00 +07:00
|
|
|
id = rsnd_mod_id(mod);
|
2015-02-20 17:27:42 +07:00
|
|
|
} else if (mod == dvc) {
|
|
|
|
entry = gen2_id_table_cmd;
|
|
|
|
size = ARRAY_SIZE(gen2_id_table_cmd);
|
2018-09-03 14:08:00 +07:00
|
|
|
id = rsnd_mod_id(mod);
|
2015-02-20 17:27:42 +07:00
|
|
|
}
|
|
|
|
|
2016-05-10 09:22:37 +07:00
|
|
|
if ((!entry) || (size <= id)) {
|
|
|
|
struct device *dev = rsnd_priv_to_dev(rsnd_io_to_priv(io));
|
2015-02-20 17:27:42 +07:00
|
|
|
|
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.
In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.
To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-30 14:47:50 +07:00
|
|
|
dev_err(dev, "unknown connection (%s)\n", rsnd_mod_name(mod));
|
2016-05-10 09:22:37 +07:00
|
|
|
|
|
|
|
/* use non-prohibited SRS number as error */
|
|
|
|
return 0x00; /* SSI00 */
|
|
|
|
}
|
2015-02-20 17:27:42 +07:00
|
|
|
|
|
|
|
return entry[id];
|
|
|
|
}
|
|
|
|
|
2015-06-15 13:26:25 +07:00
|
|
|
static u32 rsnd_dmapp_get_chcr(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod_from,
|
2015-02-20 17:27:42 +07:00
|
|
|
struct rsnd_mod *mod_to)
|
|
|
|
{
|
2015-06-15 13:26:25 +07:00
|
|
|
return (rsnd_dmapp_get_id(io, mod_from) << 24) +
|
|
|
|
(rsnd_dmapp_get_id(io, mod_to) << 16);
|
2015-02-20 17:27:42 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define rsnd_dmapp_addr(dmac, dma, reg) \
|
2015-02-20 17:29:13 +07:00
|
|
|
(dmac->base + 0x20 + reg + \
|
|
|
|
(0x10 * rsnd_dma_to_dmapp(dma)->dmapp_id))
|
2015-02-20 17:27:42 +07:00
|
|
|
static void rsnd_dmapp_write(struct rsnd_dma *dma, u32 data, u32 reg)
|
|
|
|
{
|
2015-10-26 15:42:25 +07:00
|
|
|
struct rsnd_mod *mod = rsnd_mod_get(dma);
|
2015-02-20 17:27:42 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
|
|
|
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
|
2018-09-06 10:22:01 +07:00
|
|
|
dev_dbg(dev, "w 0x%px : %08x\n", rsnd_dmapp_addr(dmac, dma, reg), data);
|
2015-02-20 17:27:42 +07:00
|
|
|
|
|
|
|
iowrite32(data, rsnd_dmapp_addr(dmac, dma, reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg)
|
|
|
|
{
|
2015-10-26 15:42:25 +07:00
|
|
|
struct rsnd_mod *mod = rsnd_mod_get(dma);
|
2015-02-20 17:27:42 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
|
|
|
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
|
|
|
|
|
|
|
return ioread32(rsnd_dmapp_addr(dmac, dma, reg));
|
|
|
|
}
|
|
|
|
|
2017-03-14 07:34:49 +07:00
|
|
|
static void rsnd_dmapp_bset(struct rsnd_dma *dma, u32 data, u32 mask, u32 reg)
|
|
|
|
{
|
|
|
|
struct rsnd_mod *mod = rsnd_mod_get(dma);
|
|
|
|
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
|
|
|
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
ASoC: rcar: dma: remove unnecessary "volatile"
commit 2a3af642eb20("ASoC: rcar: clear DE bit only in PDMACHCR...")
added rsnd_dmapp_bset(), but it used copy-paste. Thus, it had
unnecessary "volatile", and had below warning on x86.
This patch fix it.
sound/soc/sh/rcar/dma.c: In function 'rsnd_dmapp_bset':
>> sound/soc/sh/rcar/dma.c:463:21: warning: passing argument 1 of \
'ioread32' discards 'volatile' qualifier from pointer target \
type [-Wdiscarded-qualifiers]
u32 val = ioread32(addr);
^~~~
In file included from arch/x86/include/asm/io.h:203:0,
from arch/x86/include/asm/realmode.h:5,
from arch/x86/include/asm/acpi.h:33,
from arch/x86/include/asm/fixmap.h:19,
from arch/x86/include/asm/apic.h:10,
from arch/x86/include/asm/smp.h:12,
from include/linux/smp.h:59,
from include/linux/topology.h:33,
from include/linux/gfp.h:8,
from include/linux/idr.h:16,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:15,
from include/linux/kobject.h:21,
from include/linux/of.h:21,
from include/linux/of_dma.h:16,
from sound/soc/sh/rcar/dma.c:12:
include/asm-generic/iomap.h:31:21: note: expected 'void *' \
but argument is of type 'volatile void *'
extern unsigned int ioread32(void __iomem *);
^~~~~~~~
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-03-16 11:22:09 +07:00
|
|
|
void __iomem *addr = rsnd_dmapp_addr(dmac, dma, reg);
|
2017-03-14 07:34:49 +07:00
|
|
|
u32 val = ioread32(addr);
|
|
|
|
|
|
|
|
val &= ~mask;
|
|
|
|
val |= (data & mask);
|
|
|
|
|
|
|
|
iowrite32(val, addr);
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:01 +07:00
|
|
|
static int rsnd_dmapp_stop(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
2015-02-20 17:27:42 +07:00
|
|
|
{
|
2015-10-26 15:42:46 +07:00
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
2015-02-20 17:27:42 +07:00
|
|
|
int i;
|
|
|
|
|
2017-03-14 07:34:49 +07:00
|
|
|
rsnd_dmapp_bset(dma, 0, PDMACHCR_DE, PDMACHCR);
|
2015-02-20 17:27:42 +07:00
|
|
|
|
|
|
|
for (i = 0; i < 1024; i++) {
|
2017-03-14 07:34:49 +07:00
|
|
|
if (0 == (rsnd_dmapp_read(dma, PDMACHCR) & PDMACHCR_DE))
|
2015-10-28 11:31:03 +07:00
|
|
|
return 0;
|
2015-02-20 17:27:42 +07:00
|
|
|
udelay(1);
|
|
|
|
}
|
2015-10-26 15:43:01 +07:00
|
|
|
|
2015-10-28 11:31:03 +07:00
|
|
|
return -EIO;
|
2015-02-20 17:27:42 +07:00
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:01 +07:00
|
|
|
static int rsnd_dmapp_start(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
2015-02-20 17:27:42 +07:00
|
|
|
{
|
2015-10-26 15:42:46 +07:00
|
|
|
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
|
2015-02-20 17:29:13 +07:00
|
|
|
struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
|
|
|
|
|
2015-02-20 17:27:42 +07:00
|
|
|
rsnd_dmapp_write(dma, dma->src_addr, PDMASAR);
|
|
|
|
rsnd_dmapp_write(dma, dma->dst_addr, PDMADAR);
|
2015-02-20 17:29:13 +07:00
|
|
|
rsnd_dmapp_write(dma, dmapp->chcr, PDMACHCR);
|
2015-10-26 15:43:01 +07:00
|
|
|
|
|
|
|
return 0;
|
2015-02-20 17:27:42 +07:00
|
|
|
}
|
|
|
|
|
2015-10-26 15:39:20 +07:00
|
|
|
static int rsnd_dmapp_attach(struct rsnd_dai_stream *io,
|
2016-10-25 07:36:13 +07:00
|
|
|
struct rsnd_dma *dma,
|
2015-10-26 15:39:20 +07:00
|
|
|
struct rsnd_mod *mod_from, struct rsnd_mod *mod_to)
|
2015-02-20 17:27:42 +07:00
|
|
|
{
|
2015-02-20 17:29:13 +07:00
|
|
|
struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
|
2015-06-15 13:26:25 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
2015-02-20 17:27:42 +07:00
|
|
|
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
|
2015-02-20 17:29:13 +07:00
|
|
|
dmapp->dmapp_id = dmac->dmapp_num;
|
2015-06-15 13:26:25 +07:00
|
|
|
dmapp->chcr = rsnd_dmapp_get_chcr(io, mod_from, mod_to) | PDMACHCR_DE;
|
2015-02-20 17:27:42 +07:00
|
|
|
|
|
|
|
dmac->dmapp_num++;
|
|
|
|
|
2015-03-10 17:48:05 +07:00
|
|
|
dev_dbg(dev, "id/src/dst/chcr = %d/%pad/%pad/%08x\n",
|
|
|
|
dmapp->dmapp_id, &dma->src_addr, &dma->dst_addr, dmapp->chcr);
|
2015-02-20 17:27:42 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:01 +07:00
|
|
|
static struct rsnd_mod_ops rsnd_dmapp_ops = {
|
2018-10-30 14:46:05 +07:00
|
|
|
.name = "audmac-pp",
|
|
|
|
.start = rsnd_dmapp_start,
|
|
|
|
.stop = rsnd_dmapp_stop,
|
|
|
|
.quit = rsnd_dmapp_stop,
|
|
|
|
.get_status = rsnd_mod_get_status,
|
2015-02-20 17:27:42 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Common DMAC Interface
|
|
|
|
*/
|
|
|
|
|
2015-02-20 17:26:29 +07:00
|
|
|
/*
|
|
|
|
* DMA read/write register offset
|
|
|
|
*
|
|
|
|
* RSND_xxx_I_N for Audio DMAC input
|
|
|
|
* RSND_xxx_O_N for Audio DMAC output
|
|
|
|
* RSND_xxx_I_P for Audio DMAC peri peri input
|
|
|
|
* RSND_xxx_O_P for Audio DMAC peri peri output
|
|
|
|
*
|
|
|
|
* ex) R-Car H2 case
|
|
|
|
* mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out
|
|
|
|
* SSI : 0xec541000 / 0xec241008 / 0xec24100c
|
|
|
|
* SSIU: 0xec541000 / 0xec100000 / 0xec100000 / 0xec400000 / 0xec400000
|
|
|
|
* SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000
|
|
|
|
* CMD : 0xec500000 / / 0xec008000 0xec308000
|
|
|
|
*/
|
|
|
|
#define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8)
|
|
|
|
#define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc)
|
|
|
|
|
2019-10-23 01:54:29 +07:00
|
|
|
#define RDMA_SSIU_I_N(addr, i, j) (addr ##_reg - 0x00441000 + (0x1000 * (i)) + (((j) / 4) * 0xA000) + (((j) % 4) * 0x400) - (0x4000 * ((i) / 9) * ((j) / 4)))
|
2018-09-03 14:07:43 +07:00
|
|
|
#define RDMA_SSIU_O_N(addr, i, j) RDMA_SSIU_I_N(addr, i, j)
|
2015-02-20 17:26:29 +07:00
|
|
|
|
2019-10-23 01:54:29 +07:00
|
|
|
#define RDMA_SSIU_I_P(addr, i, j) (addr ##_reg - 0x00141000 + (0x1000 * (i)) + (((j) / 4) * 0xA000) + (((j) % 4) * 0x400) - (0x4000 * ((i) / 9) * ((j) / 4)))
|
2018-09-03 14:07:43 +07:00
|
|
|
#define RDMA_SSIU_O_P(addr, i, j) RDMA_SSIU_I_P(addr, i, j)
|
2015-02-20 17:26:29 +07:00
|
|
|
|
|
|
|
#define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i))
|
|
|
|
#define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i))
|
|
|
|
|
|
|
|
#define RDMA_SRC_I_P(addr, i) (addr ##_reg - 0x00200000 + (0x400 * i))
|
|
|
|
#define RDMA_SRC_O_P(addr, i) (addr ##_reg - 0x001fc000 + (0x400 * i))
|
|
|
|
|
|
|
|
#define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i))
|
|
|
|
#define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i))
|
|
|
|
|
|
|
|
static dma_addr_t
|
2015-06-15 13:26:25 +07:00
|
|
|
rsnd_gen2_dma_addr(struct rsnd_dai_stream *io,
|
2015-02-20 17:26:29 +07:00
|
|
|
struct rsnd_mod *mod,
|
|
|
|
int is_play, int is_from)
|
|
|
|
{
|
2015-06-15 13:26:25 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
2015-02-20 17:26:29 +07:00
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
phys_addr_t ssi_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SSI);
|
|
|
|
phys_addr_t src_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SCU);
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod) ||
|
|
|
|
!!(rsnd_io_to_mod_ssiu(io) == mod);
|
2015-02-20 17:26:29 +07:00
|
|
|
int use_src = !!rsnd_io_to_mod_src(io);
|
2015-07-15 14:17:17 +07:00
|
|
|
int use_cmd = !!rsnd_io_to_mod_dvc(io) ||
|
2015-07-15 14:17:36 +07:00
|
|
|
!!rsnd_io_to_mod_mix(io) ||
|
2015-07-15 14:17:17 +07:00
|
|
|
!!rsnd_io_to_mod_ctu(io);
|
2015-02-20 17:26:29 +07:00
|
|
|
int id = rsnd_mod_id(mod);
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
int busif = rsnd_mod_id_sub(rsnd_io_to_mod_ssiu(io));
|
2015-02-20 17:26:29 +07:00
|
|
|
struct dma_addr {
|
|
|
|
dma_addr_t out_addr;
|
|
|
|
dma_addr_t in_addr;
|
|
|
|
} dma_addrs[3][2][3] = {
|
|
|
|
/* SRC */
|
2017-08-21 14:03:01 +07:00
|
|
|
/* Capture */
|
2015-02-20 17:26:29 +07:00
|
|
|
{{{ 0, 0 },
|
|
|
|
{ RDMA_SRC_O_N(src, id), RDMA_SRC_I_P(src, id) },
|
|
|
|
{ RDMA_CMD_O_N(src, id), RDMA_SRC_I_P(src, id) } },
|
|
|
|
/* Playback */
|
|
|
|
{{ 0, 0, },
|
|
|
|
{ RDMA_SRC_O_P(src, id), RDMA_SRC_I_N(src, id) },
|
|
|
|
{ RDMA_CMD_O_P(src, id), RDMA_SRC_I_N(src, id) } }
|
|
|
|
},
|
|
|
|
/* SSI */
|
|
|
|
/* Capture */
|
2018-09-03 14:07:43 +07:00
|
|
|
{{{ RDMA_SSI_O_N(ssi, id), 0 },
|
|
|
|
{ RDMA_SSIU_O_P(ssi, id, busif), 0 },
|
|
|
|
{ RDMA_SSIU_O_P(ssi, id, busif), 0 } },
|
2015-02-20 17:26:29 +07:00
|
|
|
/* Playback */
|
2018-09-03 14:07:43 +07:00
|
|
|
{{ 0, RDMA_SSI_I_N(ssi, id) },
|
|
|
|
{ 0, RDMA_SSIU_I_P(ssi, id, busif) },
|
|
|
|
{ 0, RDMA_SSIU_I_P(ssi, id, busif) } }
|
2015-02-20 17:26:29 +07:00
|
|
|
},
|
|
|
|
/* SSIU */
|
|
|
|
/* Capture */
|
2018-09-03 14:07:43 +07:00
|
|
|
{{{ RDMA_SSIU_O_N(ssi, id, busif), 0 },
|
|
|
|
{ RDMA_SSIU_O_P(ssi, id, busif), 0 },
|
|
|
|
{ RDMA_SSIU_O_P(ssi, id, busif), 0 } },
|
2015-02-20 17:26:29 +07:00
|
|
|
/* Playback */
|
2018-09-03 14:07:43 +07:00
|
|
|
{{ 0, RDMA_SSIU_I_N(ssi, id, busif) },
|
|
|
|
{ 0, RDMA_SSIU_I_P(ssi, id, busif) },
|
|
|
|
{ 0, RDMA_SSIU_I_P(ssi, id, busif) } } },
|
2015-02-20 17:26:29 +07:00
|
|
|
};
|
|
|
|
|
2018-09-03 14:07:43 +07:00
|
|
|
/*
|
|
|
|
* FIXME
|
|
|
|
*
|
|
|
|
* We can't support SSI9-4/5/6/7, because its address is
|
|
|
|
* out of calculation rule
|
|
|
|
*/
|
|
|
|
if ((id == 9) && (busif >= 4))
|
|
|
|
dev_err(dev, "This driver doesn't support SSI%d-%d, so far",
|
|
|
|
id, busif);
|
|
|
|
|
2015-02-20 17:26:29 +07:00
|
|
|
/* it shouldn't happen */
|
2015-07-15 14:17:17 +07:00
|
|
|
if (use_cmd && !use_src)
|
2015-02-20 17:26:29 +07:00
|
|
|
dev_err(dev, "DVC is selected without SRC\n");
|
|
|
|
|
|
|
|
/* use SSIU or SSI ? */
|
2015-10-22 10:15:46 +07:00
|
|
|
if (is_ssi && rsnd_ssi_use_busif(io))
|
2015-02-20 17:26:29 +07:00
|
|
|
is_ssi++;
|
|
|
|
|
|
|
|
return (is_from) ?
|
2015-07-15 14:17:17 +07:00
|
|
|
dma_addrs[is_ssi][is_play][use_src + use_cmd].out_addr :
|
|
|
|
dma_addrs[is_ssi][is_play][use_src + use_cmd].in_addr;
|
2015-02-20 17:26:29 +07:00
|
|
|
}
|
|
|
|
|
2015-06-15 13:26:25 +07:00
|
|
|
static dma_addr_t rsnd_dma_addr(struct rsnd_dai_stream *io,
|
2015-02-20 17:26:29 +07:00
|
|
|
struct rsnd_mod *mod,
|
|
|
|
int is_play, int is_from)
|
|
|
|
{
|
2015-06-15 13:26:25 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
|
|
|
|
2015-02-20 17:26:29 +07:00
|
|
|
/*
|
|
|
|
* gen1 uses default DMA addr
|
|
|
|
*/
|
|
|
|
if (rsnd_is_gen1(priv))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!mod)
|
|
|
|
return 0;
|
|
|
|
|
2015-06-15 13:26:25 +07:00
|
|
|
return rsnd_gen2_dma_addr(io, mod, is_play, is_from);
|
2015-02-20 17:26:29 +07:00
|
|
|
}
|
|
|
|
|
2015-07-15 14:16:56 +07:00
|
|
|
#define MOD_MAX (RSND_MOD_MAX + 1) /* +Memory */
|
2015-10-26 15:42:25 +07:00
|
|
|
static void rsnd_dma_of_path(struct rsnd_mod *this,
|
2015-06-15 13:26:25 +07:00
|
|
|
struct rsnd_dai_stream *io,
|
2015-02-20 17:25:55 +07:00
|
|
|
int is_play,
|
|
|
|
struct rsnd_mod **mod_from,
|
|
|
|
struct rsnd_mod **mod_to)
|
|
|
|
{
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
struct rsnd_mod *ssi;
|
2015-02-20 17:25:55 +07:00
|
|
|
struct rsnd_mod *src = rsnd_io_to_mod_src(io);
|
2015-07-15 14:17:17 +07:00
|
|
|
struct rsnd_mod *ctu = rsnd_io_to_mod_ctu(io);
|
2015-07-15 14:17:36 +07:00
|
|
|
struct rsnd_mod *mix = rsnd_io_to_mod_mix(io);
|
2015-02-20 17:25:55 +07:00
|
|
|
struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
|
|
|
|
struct rsnd_mod *mod[MOD_MAX];
|
2015-07-15 14:16:56 +07:00
|
|
|
struct rsnd_mod *mod_start, *mod_end;
|
|
|
|
struct rsnd_priv *priv = rsnd_mod_to_priv(this);
|
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
2015-10-26 15:40:19 +07:00
|
|
|
int nr, i, idx;
|
2015-02-20 17:25:55 +07:00
|
|
|
|
ASoC: rsnd: add SSIU BUSIF support
Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.
BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.
1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-06 12:21:08 +07:00
|
|
|
/*
|
|
|
|
* It should use "rcar_sound,ssiu" on DT.
|
|
|
|
* But, we need to keep compatibility for old version.
|
|
|
|
*
|
|
|
|
* If it has "rcar_sound.ssiu", it will be used.
|
|
|
|
* If not, "rcar_sound.ssi" will be used.
|
|
|
|
* see
|
|
|
|
* rsnd_ssiu_dma_req()
|
|
|
|
* rsnd_ssi_dma_req()
|
|
|
|
*/
|
|
|
|
if (rsnd_ssiu_of_node(priv)) {
|
|
|
|
struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
|
|
|
|
|
|
|
|
/* use SSIU */
|
|
|
|
ssi = ssiu;
|
|
|
|
if (this == rsnd_io_to_mod_ssi(io))
|
|
|
|
this = ssiu;
|
|
|
|
} else {
|
|
|
|
/* keep compatible, use SSI */
|
|
|
|
ssi = rsnd_io_to_mod_ssi(io);
|
|
|
|
}
|
|
|
|
|
2015-07-15 14:16:56 +07:00
|
|
|
if (!ssi)
|
|
|
|
return;
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2015-07-15 14:16:56 +07:00
|
|
|
nr = 0;
|
|
|
|
for (i = 0; i < MOD_MAX; i++) {
|
2015-02-20 17:25:55 +07:00
|
|
|
mod[i] = NULL;
|
2015-07-15 14:16:56 +07:00
|
|
|
nr += !!rsnd_io_to_mod(io, i);
|
|
|
|
}
|
2015-02-20 17:25:55 +07:00
|
|
|
|
|
|
|
/*
|
2015-07-15 14:16:56 +07:00
|
|
|
* [S] -*-> [E]
|
|
|
|
* [S] -*-> SRC -o-> [E]
|
|
|
|
* [S] -*-> SRC -> DVC -o-> [E]
|
|
|
|
* [S] -*-> SRC -> CTU -> MIX -> DVC -o-> [E]
|
|
|
|
*
|
|
|
|
* playback [S] = mem
|
|
|
|
* [E] = SSI
|
2015-02-20 17:25:55 +07:00
|
|
|
*
|
2015-07-15 14:16:56 +07:00
|
|
|
* capture [S] = SSI
|
|
|
|
* [E] = mem
|
2015-02-20 17:25:55 +07:00
|
|
|
*
|
2015-07-15 14:16:56 +07:00
|
|
|
* -*-> Audio DMAC
|
|
|
|
* -o-> Audio DMAC peri peri
|
2015-02-20 17:25:55 +07:00
|
|
|
*/
|
2015-07-15 14:16:56 +07:00
|
|
|
mod_start = (is_play) ? NULL : ssi;
|
|
|
|
mod_end = (is_play) ? ssi : NULL;
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2015-10-26 15:40:19 +07:00
|
|
|
idx = 0;
|
|
|
|
mod[idx++] = mod_start;
|
2015-07-15 14:16:56 +07:00
|
|
|
for (i = 1; i < nr; i++) {
|
|
|
|
if (src) {
|
2015-10-26 15:40:19 +07:00
|
|
|
mod[idx++] = src;
|
2015-02-20 17:25:55 +07:00
|
|
|
src = NULL;
|
2015-07-15 14:17:17 +07:00
|
|
|
} else if (ctu) {
|
2015-10-26 15:40:19 +07:00
|
|
|
mod[idx++] = ctu;
|
2015-07-15 14:17:17 +07:00
|
|
|
ctu = NULL;
|
2015-07-15 14:17:36 +07:00
|
|
|
} else if (mix) {
|
2015-10-26 15:40:19 +07:00
|
|
|
mod[idx++] = mix;
|
2015-07-15 14:17:36 +07:00
|
|
|
mix = NULL;
|
2015-07-15 14:16:56 +07:00
|
|
|
} else if (dvc) {
|
2015-10-26 15:40:19 +07:00
|
|
|
mod[idx++] = dvc;
|
2015-02-20 17:25:55 +07:00
|
|
|
dvc = NULL;
|
|
|
|
}
|
|
|
|
}
|
2015-10-26 15:40:19 +07:00
|
|
|
mod[idx] = mod_end;
|
2015-02-20 17:25:55 +07:00
|
|
|
|
2015-07-15 14:16:56 +07:00
|
|
|
/*
|
|
|
|
* | SSI | SRC |
|
|
|
|
* -------------+-----+-----+
|
|
|
|
* is_play | o | * |
|
|
|
|
* !is_play | * | o |
|
|
|
|
*/
|
|
|
|
if ((this == ssi) == (is_play)) {
|
2015-10-26 15:40:19 +07:00
|
|
|
*mod_from = mod[idx - 1];
|
|
|
|
*mod_to = mod[idx];
|
2015-02-20 17:25:55 +07:00
|
|
|
} else {
|
2015-07-15 14:16:56 +07:00
|
|
|
*mod_from = mod[0];
|
|
|
|
*mod_to = mod[1];
|
|
|
|
}
|
|
|
|
|
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.
In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.
To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-30 14:47:50 +07:00
|
|
|
dev_dbg(dev, "module connection (this is %s)\n", rsnd_mod_name(this));
|
2015-10-26 15:40:19 +07:00
|
|
|
for (i = 0; i <= idx; i++) {
|
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.
In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.
To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-30 14:47:50 +07:00
|
|
|
dev_dbg(dev, " %s%s\n",
|
ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()
Current rsnd driver has rsnd_mod_id() which returns mod ID,
and it returns -1 if mod was NULL.
In the same time, this driver has rsnd_mod_name() which returns mod
name, and it returns "unknown" if mod or mod->ops was NULL.
Basically these "mod" never be NULL, but the reason why rsnd driver
has such behavior is that DMA path finder is assuming memory as
"mod == NULL".
Thus, current DMA path debug code prints like below.
Here "unknown[-1]" means it was memory.
...
rcar_sound ec500000.sound: unknown[-1] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] unknown[-1] -> src[0]
...
1st issue is that it is confusable for user.
2nd issue is rsnd driver has something like below code.
mask |= 1 << rsnd_mod_id(mod);
Because of this kind of code, some statically code checker will
reports "Shifting by a negative value is undefined behaviour".
But this "mod" never be NULL, thus negative shift never happen.
To avoid these issues, this patch adds new dummy "mem" to
indicate memory, and use it to indicate debug information,
and, remove unneeded "NULL mod" behavior from rsnd_mod_id() and
rsnd_mod_name().
The debug information will be like below by this patch
...
rcar_sound ec500000.sound: mem[0] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] mem[0] -> src[0]
...
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-01 14:17:34 +07:00
|
|
|
rsnd_mod_name(mod[i] ? mod[i] : &mem),
|
|
|
|
(mod[i] == *mod_from) ? " from" :
|
|
|
|
(mod[i] == *mod_to) ? " to" : "");
|
2015-02-20 17:25:55 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-20 13:28:44 +07:00
|
|
|
static int rsnd_dma_alloc(struct rsnd_dai_stream *io, struct rsnd_mod *mod,
|
|
|
|
struct rsnd_mod **dma_mod)
|
2015-02-20 17:27:12 +07:00
|
|
|
{
|
2015-07-15 14:16:56 +07:00
|
|
|
struct rsnd_mod *mod_from = NULL;
|
|
|
|
struct rsnd_mod *mod_to = NULL;
|
2015-06-15 13:26:25 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
2015-03-10 08:25:01 +07:00
|
|
|
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
|
2015-07-15 14:16:03 +07:00
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
2017-09-20 13:28:44 +07:00
|
|
|
struct rsnd_dma *dma;
|
2015-10-26 15:43:01 +07:00
|
|
|
struct rsnd_mod_ops *ops;
|
|
|
|
enum rsnd_mod_type type;
|
2016-10-25 07:36:13 +07:00
|
|
|
int (*attach)(struct rsnd_dai_stream *io, struct rsnd_dma *dma,
|
2015-10-26 15:39:20 +07:00
|
|
|
struct rsnd_mod *mod_from, struct rsnd_mod *mod_to);
|
2015-02-20 17:27:12 +07:00
|
|
|
int is_play = rsnd_io_is_play(io);
|
2015-10-26 15:42:25 +07:00
|
|
|
int ret, dma_id;
|
2015-02-20 17:27:12 +07:00
|
|
|
|
2015-03-10 08:25:01 +07:00
|
|
|
/*
|
|
|
|
* DMA failed. try to PIO mode
|
|
|
|
* see
|
|
|
|
* rsnd_ssi_fallback()
|
|
|
|
* rsnd_rdai_continuance_probe()
|
|
|
|
*/
|
|
|
|
if (!dmac)
|
2016-01-21 08:58:33 +07:00
|
|
|
return -EAGAIN;
|
2015-10-26 15:38:26 +07:00
|
|
|
|
2015-10-26 15:42:25 +07:00
|
|
|
rsnd_dma_of_path(mod, io, is_play, &mod_from, &mod_to);
|
2015-02-20 17:27:12 +07:00
|
|
|
|
2018-04-11 09:10:29 +07:00
|
|
|
/* for Gen2 or later */
|
2015-10-26 15:39:20 +07:00
|
|
|
if (mod_from && mod_to) {
|
2015-10-26 15:43:01 +07:00
|
|
|
ops = &rsnd_dmapp_ops;
|
2015-10-26 15:39:20 +07:00
|
|
|
attach = rsnd_dmapp_attach;
|
2015-10-26 15:42:25 +07:00
|
|
|
dma_id = dmac->dmapp_num;
|
2015-10-26 15:43:01 +07:00
|
|
|
type = RSND_MOD_AUDMAPP;
|
2015-10-26 15:39:20 +07:00
|
|
|
} else {
|
2015-10-26 15:43:01 +07:00
|
|
|
ops = &rsnd_dmaen_ops;
|
2015-10-26 15:39:20 +07:00
|
|
|
attach = rsnd_dmaen_attach;
|
2015-10-26 15:42:25 +07:00
|
|
|
dma_id = dmac->dmaen_num;
|
2015-10-26 15:43:01 +07:00
|
|
|
type = RSND_MOD_AUDMA;
|
2015-10-26 15:39:20 +07:00
|
|
|
}
|
2015-02-20 17:27:42 +07:00
|
|
|
|
|
|
|
/* for Gen1, overwrite */
|
2015-10-26 15:39:20 +07:00
|
|
|
if (rsnd_is_gen1(priv)) {
|
2015-10-26 15:43:01 +07:00
|
|
|
ops = &rsnd_dmaen_ops;
|
2015-10-26 15:39:20 +07:00
|
|
|
attach = rsnd_dmaen_attach;
|
2015-10-26 15:42:25 +07:00
|
|
|
dma_id = dmac->dmaen_num;
|
2015-10-26 15:43:01 +07:00
|
|
|
type = RSND_MOD_AUDMA;
|
2015-10-26 15:39:20 +07:00
|
|
|
}
|
2015-02-20 17:27:12 +07:00
|
|
|
|
2017-09-20 13:28:44 +07:00
|
|
|
dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
|
|
|
|
if (!dma)
|
|
|
|
return -ENOMEM;
|
2015-10-26 15:42:25 +07:00
|
|
|
|
2017-09-20 13:28:44 +07:00
|
|
|
*dma_mod = rsnd_mod_get(dma);
|
2015-10-26 15:42:25 +07:00
|
|
|
|
2017-09-20 13:28:44 +07:00
|
|
|
ret = rsnd_mod_init(priv, *dma_mod, ops, NULL,
|
2018-10-30 14:46:05 +07:00
|
|
|
type, dma_id);
|
2017-09-20 13:28:44 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2015-12-17 09:56:11 +07:00
|
|
|
|
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.
In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.
To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-30 14:47:50 +07:00
|
|
|
dev_dbg(dev, "%s %s -> %s\n",
|
|
|
|
rsnd_mod_name(*dma_mod),
|
ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()
Current rsnd driver has rsnd_mod_id() which returns mod ID,
and it returns -1 if mod was NULL.
In the same time, this driver has rsnd_mod_name() which returns mod
name, and it returns "unknown" if mod or mod->ops was NULL.
Basically these "mod" never be NULL, but the reason why rsnd driver
has such behavior is that DMA path finder is assuming memory as
"mod == NULL".
Thus, current DMA path debug code prints like below.
Here "unknown[-1]" means it was memory.
...
rcar_sound ec500000.sound: unknown[-1] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] unknown[-1] -> src[0]
...
1st issue is that it is confusable for user.
2nd issue is rsnd driver has something like below code.
mask |= 1 << rsnd_mod_id(mod);
Because of this kind of code, some statically code checker will
reports "Shifting by a negative value is undefined behaviour".
But this "mod" never be NULL, thus negative shift never happen.
To avoid these issues, this patch adds new dummy "mem" to
indicate memory, and use it to indicate debug information,
and, remove unneeded "NULL mod" behavior from rsnd_mod_id() and
rsnd_mod_name().
The debug information will be like below by this patch
...
rcar_sound ec500000.sound: mem[0] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] mem[0] -> src[0]
...
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-01 14:17:34 +07:00
|
|
|
rsnd_mod_name(mod_from ? mod_from : &mem),
|
ASoC: rsnd: rsnd_mod_name() handles both name and ID
Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.
In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.
To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-30 14:47:50 +07:00
|
|
|
rsnd_mod_name(mod_to ? mod_to : &mem));
|
2017-09-20 13:28:44 +07:00
|
|
|
|
|
|
|
ret = attach(io, dma, mod_from, mod_to);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2015-10-26 15:38:26 +07:00
|
|
|
|
2017-09-20 13:28:44 +07:00
|
|
|
dma->src_addr = rsnd_dma_addr(io, mod_from, is_play, 1);
|
|
|
|
dma->dst_addr = rsnd_dma_addr(io, mod_to, is_play, 0);
|
|
|
|
dma->mod_from = mod_from;
|
|
|
|
dma->mod_to = mod_to;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod,
|
|
|
|
struct rsnd_mod **dma_mod)
|
|
|
|
{
|
|
|
|
if (!(*dma_mod)) {
|
|
|
|
int ret = rsnd_dma_alloc(io, mod, dma_mod);
|
2016-01-21 08:58:33 +07:00
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-09-20 13:28:44 +07:00
|
|
|
return rsnd_dai_connect(*dma_mod, io, (*dma_mod)->type);
|
2015-02-20 17:27:12 +07:00
|
|
|
}
|
2015-02-20 17:27:42 +07:00
|
|
|
|
2015-11-10 12:14:12 +07:00
|
|
|
int rsnd_dma_probe(struct rsnd_priv *priv)
|
2015-02-20 17:27:42 +07:00
|
|
|
{
|
2015-11-10 12:14:12 +07:00
|
|
|
struct platform_device *pdev = rsnd_priv_to_pdev(priv);
|
2015-02-20 17:27:42 +07:00
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
struct rsnd_dma_ctrl *dmac;
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* for Gen1
|
|
|
|
*/
|
|
|
|
if (rsnd_is_gen1(priv))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
2018-04-11 09:10:29 +07:00
|
|
|
* for Gen2 or later
|
2015-02-20 17:27:42 +07:00
|
|
|
*/
|
|
|
|
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "audmapp");
|
|
|
|
dmac = devm_kzalloc(dev, sizeof(*dmac), GFP_KERNEL);
|
|
|
|
if (!dmac || !res) {
|
|
|
|
dev_err(dev, "dma allocate failed\n");
|
2015-03-10 08:25:01 +07:00
|
|
|
return 0; /* it will be PIO mode */
|
2015-02-20 17:27:42 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
dmac->dmapp_num = 0;
|
|
|
|
dmac->base = devm_ioremap_resource(dev, res);
|
|
|
|
if (IS_ERR(dmac->base))
|
|
|
|
return PTR_ERR(dmac->base);
|
|
|
|
|
|
|
|
priv->dma = dmac;
|
|
|
|
|
ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()
Current rsnd driver has rsnd_mod_id() which returns mod ID,
and it returns -1 if mod was NULL.
In the same time, this driver has rsnd_mod_name() which returns mod
name, and it returns "unknown" if mod or mod->ops was NULL.
Basically these "mod" never be NULL, but the reason why rsnd driver
has such behavior is that DMA path finder is assuming memory as
"mod == NULL".
Thus, current DMA path debug code prints like below.
Here "unknown[-1]" means it was memory.
...
rcar_sound ec500000.sound: unknown[-1] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] unknown[-1] -> src[0]
...
1st issue is that it is confusable for user.
2nd issue is rsnd driver has something like below code.
mask |= 1 << rsnd_mod_id(mod);
Because of this kind of code, some statically code checker will
reports "Shifting by a negative value is undefined behaviour".
But this "mod" never be NULL, thus negative shift never happen.
To avoid these issues, this patch adds new dummy "mem" to
indicate memory, and use it to indicate debug information,
and, remove unneeded "NULL mod" behavior from rsnd_mod_id() and
rsnd_mod_name().
The debug information will be like below by this patch
...
rcar_sound ec500000.sound: mem[0] from
rcar_sound ec500000.sound: src[0] to
rcar_sound ec500000.sound: ctu[2]
rcar_sound ec500000.sound: mix[0]
rcar_sound ec500000.sound: dvc[0]
rcar_sound ec500000.sound: ssi[0]
rcar_sound ec500000.sound: audmac[0] mem[0] -> src[0]
...
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-01 14:17:34 +07:00
|
|
|
/* dummy mem mod for debug */
|
2018-10-30 14:46:05 +07:00
|
|
|
return rsnd_mod_init(NULL, &mem, &mem_ops, NULL, 0, 0);
|
2015-02-20 17:27:42 +07:00
|
|
|
}
|