diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2014-05-23 02:25:54 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-05-26 09:34:56 -0400 |
commit | ad32d0c7b0e993433df152ae747652647eb65a27 (patch) | |
tree | 0703f9ccfaa0daeb60a2203e535e11cd9630a22f | |
parent | 199e7688bdf7d188d70c3432c96ec13d8a14b341 (diff) |
ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr
The DMAC src/dst addr needs to be set from driver when DT case.
(It was set from SoC/DMAEngine code when non-DT case)
This patch adds rsnd_gen_dma_addr() to set DMAC src/dst addr.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/sh/rcar/core.c | 5 | ||||
-rw-r--r-- | sound/soc/sh/rcar/gen.c | 95 | ||||
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 5 |
3 files changed, 101 insertions, 4 deletions
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index cddb76d7d965..ebb5d46029a5 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
@@ -358,10 +358,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | |||
358 | return -EIO; | 358 | return -EIO; |
359 | } | 359 | } |
360 | 360 | ||
361 | cfg.slave_id = id; | 361 | rsnd_gen_dma_addr(priv, dma, &cfg, is_play, id); |
362 | cfg.dst_addr = 0; /* use default addr when playback */ | ||
363 | cfg.src_addr = 0; /* use default addr when capture */ | ||
364 | cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
365 | 362 | ||
366 | ret = dmaengine_slave_config(dma->chan, &cfg); | 363 | ret = dmaengine_slave_config(dma->chan, &cfg); |
367 | if (ret < 0) | 364 | if (ret < 0) |
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index a1583b57bf8d..1dd2b7d38c2c 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
@@ -156,6 +156,101 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv, | |||
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * DMA read/write register offset | ||
160 | * | ||
161 | * RSND_xxx_I_N for Audio DMAC input | ||
162 | * RSND_xxx_O_N for Audio DMAC output | ||
163 | * RSND_xxx_I_P for Audio DMAC peri peri input | ||
164 | * RSND_xxx_O_P for Audio DMAC peri peri output | ||
165 | * | ||
166 | * ex) R-Car H2 case | ||
167 | * mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out | ||
168 | * SSI : 0xec541000 / 0xec241008 / 0xec24100c / 0xec400000 / 0xec400000 | ||
169 | * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000 | ||
170 | * CMD : 0xec500000 / 0xec008000 0xec308000 | ||
171 | */ | ||
172 | #define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8) | ||
173 | #define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc) | ||
174 | |||
175 | #define RDMA_SSI_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | ||
176 | #define RDMA_SSI_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | ||
177 | |||
178 | #define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i)) | ||
179 | #define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i)) | ||
180 | |||
181 | #define RDMA_SRC_I_P(addr, i) (addr ##_reg - 0x00200000 + (0x400 * i)) | ||
182 | #define RDMA_SRC_O_P(addr, i) (addr ##_reg - 0x001fc000 + (0x400 * i)) | ||
183 | |||
184 | #define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i)) | ||
185 | #define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i)) | ||
186 | |||
187 | void rsnd_gen_dma_addr(struct rsnd_priv *priv, | ||
188 | struct rsnd_dma *dma, | ||
189 | struct dma_slave_config *cfg, | ||
190 | int is_play, int slave_id) | ||
191 | { | ||
192 | struct platform_device *pdev = rsnd_priv_to_pdev(priv); | ||
193 | struct device *dev = rsnd_priv_to_dev(priv); | ||
194 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); | ||
195 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | ||
196 | dma_addr_t ssi_reg = platform_get_resource(pdev, | ||
197 | IORESOURCE_MEM, RSND_GEN2_SSI)->start; | ||
198 | dma_addr_t src_reg = platform_get_resource(pdev, | ||
199 | IORESOURCE_MEM, RSND_GEN2_SCU)->start; | ||
200 | int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod); | ||
201 | int use_src = !!rsnd_io_to_mod_src(io); | ||
202 | int use_dvc = !!rsnd_io_to_mod_dvc(io); | ||
203 | int id = rsnd_mod_id(mod); | ||
204 | struct dma_addr { | ||
205 | dma_addr_t src_addr; | ||
206 | dma_addr_t dst_addr; | ||
207 | } dma_addrs[2][2][3] = { | ||
208 | { /* SRC */ | ||
209 | /* Capture */ | ||
210 | {{ 0, 0 }, | ||
211 | { RDMA_SRC_O_N(src, id), 0 }, | ||
212 | { RDMA_CMD_O_N(src, id), 0 }}, | ||
213 | /* Playback */ | ||
214 | {{ 0, 0, }, | ||
215 | { 0, RDMA_SRC_I_N(src, id) }, | ||
216 | { 0, RDMA_SRC_I_N(src, id) }} | ||
217 | }, { /* SSI */ | ||
218 | /* Capture */ | ||
219 | {{ RDMA_SSI_O_N(ssi, id), 0 }, | ||
220 | { RDMA_SSI_O_P(ssi, id), RDMA_SRC_I_P(src, id) }, | ||
221 | { RDMA_SSI_O_P(ssi, id), RDMA_SRC_I_P(src, id) }}, | ||
222 | /* Playback */ | ||
223 | {{ 0, RDMA_SSI_I_N(ssi, id) }, | ||
224 | { RDMA_SRC_O_P(src, id), RDMA_SSI_I_P(ssi, id) }, | ||
225 | { RDMA_CMD_O_P(src, id), RDMA_SSI_I_P(ssi, id) }} | ||
226 | } | ||
227 | }; | ||
228 | |||
229 | cfg->slave_id = slave_id; | ||
230 | cfg->src_addr = 0; | ||
231 | cfg->dst_addr = 0; | ||
232 | cfg->direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
233 | |||
234 | /* | ||
235 | * gen1 uses default DMA addr | ||
236 | */ | ||
237 | if (rsnd_is_gen1(priv)) | ||
238 | return; | ||
239 | |||
240 | /* it shouldn't happen */ | ||
241 | if (use_dvc & !use_src) { | ||
242 | dev_err(dev, "DVC is selected without SRC\n"); | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | cfg->src_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].src_addr; | ||
247 | cfg->dst_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].dst_addr; | ||
248 | |||
249 | dev_dbg(dev, "dma%d addr - src : %x / dst : %x\n", | ||
250 | id, cfg->src_addr, cfg->dst_addr); | ||
251 | } | ||
252 | |||
253 | /* | ||
159 | * Gen2 | 254 | * Gen2 |
160 | */ | 255 | */ |
161 | 256 | ||
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 344f9415e669..39d98af5ee05 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -281,6 +281,11 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
281 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | 281 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, |
282 | struct rsnd_mod *mod, | 282 | struct rsnd_mod *mod, |
283 | enum rsnd_reg reg); | 283 | enum rsnd_reg reg); |
284 | void rsnd_gen_dma_addr(struct rsnd_priv *priv, | ||
285 | struct rsnd_dma *dma, | ||
286 | struct dma_slave_config *cfg, | ||
287 | int is_play, int slave_id); | ||
288 | |||
284 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) | 289 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) |
285 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) | 290 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) |
286 | 291 | ||