aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sh
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2015-02-20 05:26:29 -0500
committerMark Brown <broonie@kernel.org>2015-03-07 10:04:29 -0500
commit747c71b12ee8357e73a88eb25f569e2a20e80df3 (patch)
tree991ba5ac39dc1844a2ed69289a209a2f334c9365 /sound/soc/sh
parentbfe834be9525a82c8a40380c7df8ca3b149e9c93 (diff)
ASoC: rsnd: move rsnd_gen_dma_addr() from gen.c to dma.c
Now, we have dma.c for Audio DMAC / Audio DMAC peri peri. rsnd_gen_dma_addr() should go there. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sh')
-rw-r--r--sound/soc/sh/rcar/dma.c120
-rw-r--r--sound/soc/sh/rcar/gen.c110
-rw-r--r--sound/soc/sh/rcar/rsnd.h3
3 files changed, 117 insertions, 116 deletions
diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c
index 37acd409e88c..188b4634939c 100644
--- a/sound/soc/sh/rcar/dma.c
+++ b/sound/soc/sh/rcar/dma.c
@@ -32,7 +32,6 @@ static void rsnd_dma_complete(void *data)
32} 32}
33 33
34#define DMA_NAME_SIZE 16 34#define DMA_NAME_SIZE 16
35#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
36static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod) 35static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod)
37{ 36{
38 if (mod) 37 if (mod)
@@ -97,6 +96,10 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma,
97 struct rsnd_mod **mod_from, 96 struct rsnd_mod **mod_from,
98 struct rsnd_mod **mod_to); 97 struct rsnd_mod **mod_to);
99 98
99static dma_addr_t rsnd_dma_addr(struct rsnd_priv *priv,
100 struct rsnd_mod *mod,
101 int is_play, int is_from);
102
100int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id) 103int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id)
101{ 104{
102 struct device *dev = rsnd_priv_to_dev(priv); 105 struct device *dev = rsnd_priv_to_dev(priv);
@@ -122,8 +125,8 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id)
122 rsnd_dma_of_name(mod_from, mod_to, dma_name); 125 rsnd_dma_of_name(mod_from, mod_to, dma_name);
123 126
124 cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; 127 cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
125 cfg.src_addr = rsnd_gen_dma_addr(priv, mod_from, is_play, 1); 128 cfg.src_addr = rsnd_dma_addr(priv, mod_from, is_play, 1);
126 cfg.dst_addr = rsnd_gen_dma_addr(priv, mod_to, is_play, 0); 129 cfg.dst_addr = rsnd_dma_addr(priv, mod_to, is_play, 0);
127 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 130 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
128 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 131 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
129 132
@@ -168,6 +171,117 @@ void rsnd_dma_quit(struct rsnd_dma *dma)
168 dma->chan = NULL; 171 dma->chan = NULL;
169} 172}
170 173
174/*
175 * DMA read/write register offset
176 *
177 * RSND_xxx_I_N for Audio DMAC input
178 * RSND_xxx_O_N for Audio DMAC output
179 * RSND_xxx_I_P for Audio DMAC peri peri input
180 * RSND_xxx_O_P for Audio DMAC peri peri output
181 *
182 * ex) R-Car H2 case
183 * mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out
184 * SSI : 0xec541000 / 0xec241008 / 0xec24100c
185 * SSIU: 0xec541000 / 0xec100000 / 0xec100000 / 0xec400000 / 0xec400000
186 * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000
187 * CMD : 0xec500000 / / 0xec008000 0xec308000
188 */
189#define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8)
190#define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc)
191
192#define RDMA_SSIU_I_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
193#define RDMA_SSIU_O_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
194
195#define RDMA_SSIU_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
196#define RDMA_SSIU_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
197
198#define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i))
199#define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i))
200
201#define RDMA_SRC_I_P(addr, i) (addr ##_reg - 0x00200000 + (0x400 * i))
202#define RDMA_SRC_O_P(addr, i) (addr ##_reg - 0x001fc000 + (0x400 * i))
203
204#define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i))
205#define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i))
206
207static dma_addr_t
208rsnd_gen2_dma_addr(struct rsnd_priv *priv,
209 struct rsnd_mod *mod,
210 int is_play, int is_from)
211{
212 struct device *dev = rsnd_priv_to_dev(priv);
213 struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
214 phys_addr_t ssi_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SSI);
215 phys_addr_t src_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SCU);
216 int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod);
217 int use_src = !!rsnd_io_to_mod_src(io);
218 int use_dvc = !!rsnd_io_to_mod_dvc(io);
219 int id = rsnd_mod_id(mod);
220 struct dma_addr {
221 dma_addr_t out_addr;
222 dma_addr_t in_addr;
223 } dma_addrs[3][2][3] = {
224 /* SRC */
225 {{{ 0, 0 },
226 /* Capture */
227 { RDMA_SRC_O_N(src, id), RDMA_SRC_I_P(src, id) },
228 { RDMA_CMD_O_N(src, id), RDMA_SRC_I_P(src, id) } },
229 /* Playback */
230 {{ 0, 0, },
231 { RDMA_SRC_O_P(src, id), RDMA_SRC_I_N(src, id) },
232 { RDMA_CMD_O_P(src, id), RDMA_SRC_I_N(src, id) } }
233 },
234 /* SSI */
235 /* Capture */
236 {{{ RDMA_SSI_O_N(ssi, id), 0 },
237 { RDMA_SSIU_O_P(ssi, id), 0 },
238 { RDMA_SSIU_O_P(ssi, id), 0 } },
239 /* Playback */
240 {{ 0, RDMA_SSI_I_N(ssi, id) },
241 { 0, RDMA_SSIU_I_P(ssi, id) },
242 { 0, RDMA_SSIU_I_P(ssi, id) } }
243 },
244 /* SSIU */
245 /* Capture */
246 {{{ RDMA_SSIU_O_N(ssi, id), 0 },
247 { RDMA_SSIU_O_P(ssi, id), 0 },
248 { RDMA_SSIU_O_P(ssi, id), 0 } },
249 /* Playback */
250 {{ 0, RDMA_SSIU_I_N(ssi, id) },
251 { 0, RDMA_SSIU_I_P(ssi, id) },
252 { 0, RDMA_SSIU_I_P(ssi, id) } } },
253 };
254
255 /* it shouldn't happen */
256 if (use_dvc && !use_src)
257 dev_err(dev, "DVC is selected without SRC\n");
258
259 /* use SSIU or SSI ? */
260 if (is_ssi && (0 == strcmp(rsnd_mod_dma_name(mod), "ssiu")))
261 is_ssi++;
262
263 return (is_from) ?
264 dma_addrs[is_ssi][is_play][use_src + use_dvc].out_addr :
265 dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr;
266}
267
268static dma_addr_t rsnd_dma_addr(struct rsnd_priv *priv,
269 struct rsnd_mod *mod,
270 int is_play, int is_from)
271{
272 /*
273 * gen1 uses default DMA addr
274 */
275 if (rsnd_is_gen1(priv))
276 return 0;
277
278 if (!mod)
279 return 0;
280
281 return rsnd_gen2_dma_addr(priv, mod, is_play, is_from);
282}
283
284#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
171static void rsnd_dma_of_path(struct rsnd_dma *dma, 285static void rsnd_dma_of_path(struct rsnd_dma *dma,
172 int is_play, 286 int is_play,
173 struct rsnd_mod **mod_from, 287 struct rsnd_mod **mod_from,
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index 0da04ed3aabe..0273724a2668 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -188,116 +188,6 @@ static int _rsnd_gen_regmap_init(struct rsnd_priv *priv,
188} 188}
189 189
190/* 190/*
191 * DMA read/write register offset
192 *
193 * RSND_xxx_I_N for Audio DMAC input
194 * RSND_xxx_O_N for Audio DMAC output
195 * RSND_xxx_I_P for Audio DMAC peri peri input
196 * RSND_xxx_O_P for Audio DMAC peri peri output
197 *
198 * ex) R-Car H2 case
199 * mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out
200 * SSI : 0xec541000 / 0xec241008 / 0xec24100c
201 * SSIU: 0xec541000 / 0xec100000 / 0xec100000 / 0xec400000 / 0xec400000
202 * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000
203 * CMD : 0xec500000 / / 0xec008000 0xec308000
204 */
205#define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8)
206#define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc)
207
208#define RDMA_SSIU_I_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
209#define RDMA_SSIU_O_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
210
211#define RDMA_SSIU_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
212#define RDMA_SSIU_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
213
214#define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i))
215#define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i))
216
217#define RDMA_SRC_I_P(addr, i) (addr ##_reg - 0x00200000 + (0x400 * i))
218#define RDMA_SRC_O_P(addr, i) (addr ##_reg - 0x001fc000 + (0x400 * i))
219
220#define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i))
221#define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i))
222
223static dma_addr_t
224rsnd_gen2_dma_addr(struct rsnd_priv *priv,
225 struct rsnd_mod *mod,
226 int is_play, int is_from)
227{
228 struct device *dev = rsnd_priv_to_dev(priv);
229 struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
230 phys_addr_t ssi_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SSI);
231 phys_addr_t src_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SCU);
232 int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod);
233 int use_src = !!rsnd_io_to_mod_src(io);
234 int use_dvc = !!rsnd_io_to_mod_dvc(io);
235 int id = rsnd_mod_id(mod);
236 struct dma_addr {
237 dma_addr_t out_addr;
238 dma_addr_t in_addr;
239 } dma_addrs[3][2][3] = {
240 /* SRC */
241 {{{ 0, 0 },
242 /* Capture */
243 { RDMA_SRC_O_N(src, id), RDMA_SRC_I_P(src, id) },
244 { RDMA_CMD_O_N(src, id), RDMA_SRC_I_P(src, id) } },
245 /* Playback */
246 {{ 0, 0, },
247 { RDMA_SRC_O_P(src, id), RDMA_SRC_I_N(src, id) },
248 { RDMA_CMD_O_P(src, id), RDMA_SRC_I_N(src, id) } }
249 },
250 /* SSI */
251 /* Capture */
252 {{{ RDMA_SSI_O_N(ssi, id), 0 },
253 { RDMA_SSIU_O_P(ssi, id), 0 },
254 { RDMA_SSIU_O_P(ssi, id), 0 } },
255 /* Playback */
256 {{ 0, RDMA_SSI_I_N(ssi, id) },
257 { 0, RDMA_SSIU_I_P(ssi, id) },
258 { 0, RDMA_SSIU_I_P(ssi, id) } }
259 },
260 /* SSIU */
261 /* Capture */
262 {{{ RDMA_SSIU_O_N(ssi, id), 0 },
263 { RDMA_SSIU_O_P(ssi, id), 0 },
264 { RDMA_SSIU_O_P(ssi, id), 0 } },
265 /* Playback */
266 {{ 0, RDMA_SSIU_I_N(ssi, id) },
267 { 0, RDMA_SSIU_I_P(ssi, id) },
268 { 0, RDMA_SSIU_I_P(ssi, id) } } },
269 };
270
271 /* it shouldn't happen */
272 if (use_dvc && !use_src)
273 dev_err(dev, "DVC is selected without SRC\n");
274
275 /* use SSIU or SSI ? */
276 if (is_ssi && (0 == strcmp(rsnd_mod_dma_name(mod), "ssiu")))
277 is_ssi++;
278
279 return (is_from) ?
280 dma_addrs[is_ssi][is_play][use_src + use_dvc].out_addr :
281 dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr;
282}
283
284dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv,
285 struct rsnd_mod *mod,
286 int is_play, int is_from)
287{
288 /*
289 * gen1 uses default DMA addr
290 */
291 if (rsnd_is_gen1(priv))
292 return 0;
293
294 if (!mod)
295 return 0;
296
297 return rsnd_gen2_dma_addr(priv, mod, is_play, is_from);
298}
299
300/*
301 * Gen2 191 * Gen2
302 */ 192 */
303static int rsnd_gen2_probe(struct platform_device *pdev, 193static int rsnd_gen2_probe(struct platform_device *pdev,
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 8a8a4d5d55ef..a73e94c1d785 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -328,9 +328,6 @@ int rsnd_gen_probe(struct platform_device *pdev,
328void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, 328void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
329 struct rsnd_mod *mod, 329 struct rsnd_mod *mod,
330 enum rsnd_reg reg); 330 enum rsnd_reg reg);
331dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv,
332 struct rsnd_mod *mod,
333 int is_play, int is_from);
334phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id); 331phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id);
335 332
336#define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) 333#define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1)