]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - sound/soc/sh/rcar/rsnd.h
Merge remote-tracking branch 'asoc/fix/rcar' into asoc-linus
[mirror_ubuntu-bionic-kernel.git] / sound / soc / sh / rcar / rsnd.h
1 /*
2 * Renesas R-Car
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11 #ifndef RSND_H
12 #define RSND_H
13
14 #include <linux/clk.h>
15 #include <linux/device.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/io.h>
18 #include <linux/list.h>
19 #include <linux/module.h>
20 #include <linux/of_device.h>
21 #include <linux/of_irq.h>
22 #include <linux/sh_dma.h>
23 #include <linux/workqueue.h>
24 #include <sound/soc.h>
25 #include <sound/pcm_params.h>
26
27 #define RSND_GEN1_SRU 0
28 #define RSND_GEN1_ADG 1
29 #define RSND_GEN1_SSI 2
30
31 #define RSND_GEN2_SCU 0
32 #define RSND_GEN2_ADG 1
33 #define RSND_GEN2_SSIU 2
34 #define RSND_GEN2_SSI 3
35
36 #define RSND_BASE_MAX 4
37
38 /*
39 * pseudo register
40 *
41 * The register address offsets SRU/SCU/SSIU on Gen1/Gen2 are very different.
42 * This driver uses pseudo register in order to hide it.
43 * see gen1/gen2 for detail
44 */
45 enum rsnd_reg {
46 /* SCU (MIX/CTU/DVC) */
47 RSND_REG_SRC_I_BUSIF_MODE,
48 RSND_REG_SRC_O_BUSIF_MODE,
49 RSND_REG_SRC_ROUTE_MODE0,
50 RSND_REG_SRC_SWRSR,
51 RSND_REG_SRC_SRCIR,
52 RSND_REG_SRC_ADINR,
53 RSND_REG_SRC_IFSCR,
54 RSND_REG_SRC_IFSVR,
55 RSND_REG_SRC_SRCCR,
56 RSND_REG_SRC_CTRL,
57 RSND_REG_SRC_BSDSR,
58 RSND_REG_SRC_BSISR,
59 RSND_REG_SRC_INT_ENABLE0,
60 RSND_REG_SRC_BUSIF_DALIGN,
61 RSND_REG_SRCIN_TIMSEL0,
62 RSND_REG_SRCIN_TIMSEL1,
63 RSND_REG_SRCIN_TIMSEL2,
64 RSND_REG_SRCIN_TIMSEL3,
65 RSND_REG_SRCIN_TIMSEL4,
66 RSND_REG_SRCOUT_TIMSEL0,
67 RSND_REG_SRCOUT_TIMSEL1,
68 RSND_REG_SRCOUT_TIMSEL2,
69 RSND_REG_SRCOUT_TIMSEL3,
70 RSND_REG_SRCOUT_TIMSEL4,
71 RSND_REG_SCU_SYS_STATUS0,
72 RSND_REG_SCU_SYS_STATUS1,
73 RSND_REG_SCU_SYS_INT_EN0,
74 RSND_REG_SCU_SYS_INT_EN1,
75 RSND_REG_CMD_CTRL,
76 RSND_REG_CMD_BUSIF_DALIGN,
77 RSND_REG_CMD_ROUTE_SLCT,
78 RSND_REG_CMDOUT_TIMSEL,
79 RSND_REG_CTU_SWRSR,
80 RSND_REG_CTU_CTUIR,
81 RSND_REG_CTU_ADINR,
82 RSND_REG_CTU_CPMDR,
83 RSND_REG_CTU_SCMDR,
84 RSND_REG_CTU_SV00R,
85 RSND_REG_CTU_SV01R,
86 RSND_REG_CTU_SV02R,
87 RSND_REG_CTU_SV03R,
88 RSND_REG_CTU_SV04R,
89 RSND_REG_CTU_SV05R,
90 RSND_REG_CTU_SV06R,
91 RSND_REG_CTU_SV07R,
92 RSND_REG_CTU_SV10R,
93 RSND_REG_CTU_SV11R,
94 RSND_REG_CTU_SV12R,
95 RSND_REG_CTU_SV13R,
96 RSND_REG_CTU_SV14R,
97 RSND_REG_CTU_SV15R,
98 RSND_REG_CTU_SV16R,
99 RSND_REG_CTU_SV17R,
100 RSND_REG_CTU_SV20R,
101 RSND_REG_CTU_SV21R,
102 RSND_REG_CTU_SV22R,
103 RSND_REG_CTU_SV23R,
104 RSND_REG_CTU_SV24R,
105 RSND_REG_CTU_SV25R,
106 RSND_REG_CTU_SV26R,
107 RSND_REG_CTU_SV27R,
108 RSND_REG_CTU_SV30R,
109 RSND_REG_CTU_SV31R,
110 RSND_REG_CTU_SV32R,
111 RSND_REG_CTU_SV33R,
112 RSND_REG_CTU_SV34R,
113 RSND_REG_CTU_SV35R,
114 RSND_REG_CTU_SV36R,
115 RSND_REG_CTU_SV37R,
116 RSND_REG_MIX_SWRSR,
117 RSND_REG_MIX_MIXIR,
118 RSND_REG_MIX_ADINR,
119 RSND_REG_MIX_MIXMR,
120 RSND_REG_MIX_MVPDR,
121 RSND_REG_MIX_MDBAR,
122 RSND_REG_MIX_MDBBR,
123 RSND_REG_MIX_MDBCR,
124 RSND_REG_MIX_MDBDR,
125 RSND_REG_MIX_MDBER,
126 RSND_REG_DVC_SWRSR,
127 RSND_REG_DVC_DVUIR,
128 RSND_REG_DVC_ADINR,
129 RSND_REG_DVC_DVUCR,
130 RSND_REG_DVC_ZCMCR,
131 RSND_REG_DVC_VOL0R,
132 RSND_REG_DVC_VOL1R,
133 RSND_REG_DVC_VOL2R,
134 RSND_REG_DVC_VOL3R,
135 RSND_REG_DVC_VOL4R,
136 RSND_REG_DVC_VOL5R,
137 RSND_REG_DVC_VOL6R,
138 RSND_REG_DVC_VOL7R,
139 RSND_REG_DVC_DVUER,
140 RSND_REG_DVC_VRCTR,
141 RSND_REG_DVC_VRPDR,
142 RSND_REG_DVC_VRDBR,
143
144 /* ADG */
145 RSND_REG_BRRA,
146 RSND_REG_BRRB,
147 RSND_REG_BRGCKR,
148 RSND_REG_DIV_EN,
149 RSND_REG_AUDIO_CLK_SEL0,
150 RSND_REG_AUDIO_CLK_SEL1,
151 RSND_REG_AUDIO_CLK_SEL2,
152
153 /* SSIU */
154 RSND_REG_SSI_MODE,
155 RSND_REG_SSI_MODE0,
156 RSND_REG_SSI_MODE1,
157 RSND_REG_SSI_MODE2,
158 RSND_REG_SSI_CONTROL,
159 RSND_REG_SSI_CTRL,
160 RSND_REG_SSI_BUSIF_MODE,
161 RSND_REG_SSI_BUSIF_ADINR,
162 RSND_REG_SSI_BUSIF_DALIGN,
163 RSND_REG_SSI_INT_ENABLE,
164 RSND_REG_SSI_SYS_STATUS0,
165 RSND_REG_SSI_SYS_STATUS1,
166 RSND_REG_SSI_SYS_STATUS2,
167 RSND_REG_SSI_SYS_STATUS3,
168 RSND_REG_SSI_SYS_STATUS4,
169 RSND_REG_SSI_SYS_STATUS5,
170 RSND_REG_SSI_SYS_STATUS6,
171 RSND_REG_SSI_SYS_STATUS7,
172
173 /* SSI */
174 RSND_REG_SSICR,
175 RSND_REG_SSISR,
176 RSND_REG_SSITDR,
177 RSND_REG_SSIRDR,
178 RSND_REG_SSIWSR,
179
180 RSND_REG_MAX,
181 };
182
183 struct rsnd_priv;
184 struct rsnd_mod;
185 struct rsnd_dai;
186 struct rsnd_dai_stream;
187
188 /*
189 * R-Car basic functions
190 */
191 #define rsnd_mod_read(m, r) \
192 rsnd_read(rsnd_mod_to_priv(m), m, RSND_REG_##r)
193 #define rsnd_mod_write(m, r, d) \
194 rsnd_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
195 #define rsnd_mod_bset(m, r, s, d) \
196 rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d)
197
198 u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg);
199 void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
200 enum rsnd_reg reg, u32 data);
201 void rsnd_force_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
202 enum rsnd_reg reg, u32 data);
203 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
204 u32 mask, u32 data);
205 u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
206 u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
207
208 /*
209 * R-Car DMA
210 */
211 int rsnd_dma_attach(struct rsnd_dai_stream *io,
212 struct rsnd_mod *mod, struct rsnd_mod **dma_mod);
213 int rsnd_dma_probe(struct rsnd_priv *priv);
214 struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node,
215 struct rsnd_mod *mod, char *name);
216
217 /*
218 * R-Car sound mod
219 */
220 enum rsnd_mod_type {
221 RSND_MOD_AUDMAPP,
222 RSND_MOD_AUDMA,
223 RSND_MOD_DVC,
224 RSND_MOD_MIX,
225 RSND_MOD_CTU,
226 RSND_MOD_CMD,
227 RSND_MOD_SRC,
228 RSND_MOD_SSIM3, /* SSI multi 3 */
229 RSND_MOD_SSIM2, /* SSI multi 2 */
230 RSND_MOD_SSIM1, /* SSI multi 1 */
231 RSND_MOD_SSIP, /* SSI parent */
232 RSND_MOD_SSI,
233 RSND_MOD_SSIU,
234 RSND_MOD_MAX,
235 };
236
237 struct rsnd_mod_ops {
238 char *name;
239 struct dma_chan* (*dma_req)(struct rsnd_dai_stream *io,
240 struct rsnd_mod *mod);
241 int (*probe)(struct rsnd_mod *mod,
242 struct rsnd_dai_stream *io,
243 struct rsnd_priv *priv);
244 int (*remove)(struct rsnd_mod *mod,
245 struct rsnd_dai_stream *io,
246 struct rsnd_priv *priv);
247 int (*init)(struct rsnd_mod *mod,
248 struct rsnd_dai_stream *io,
249 struct rsnd_priv *priv);
250 int (*quit)(struct rsnd_mod *mod,
251 struct rsnd_dai_stream *io,
252 struct rsnd_priv *priv);
253 int (*start)(struct rsnd_mod *mod,
254 struct rsnd_dai_stream *io,
255 struct rsnd_priv *priv);
256 int (*stop)(struct rsnd_mod *mod,
257 struct rsnd_dai_stream *io,
258 struct rsnd_priv *priv);
259 int (*irq)(struct rsnd_mod *mod,
260 struct rsnd_dai_stream *io,
261 struct rsnd_priv *priv, int enable);
262 int (*pcm_new)(struct rsnd_mod *mod,
263 struct rsnd_dai_stream *io,
264 struct snd_soc_pcm_runtime *rtd);
265 int (*hw_params)(struct rsnd_mod *mod,
266 struct rsnd_dai_stream *io,
267 struct snd_pcm_substream *substream,
268 struct snd_pcm_hw_params *hw_params);
269 int (*fallback)(struct rsnd_mod *mod,
270 struct rsnd_dai_stream *io,
271 struct rsnd_priv *priv);
272 int (*nolock_start)(struct rsnd_mod *mod,
273 struct rsnd_dai_stream *io,
274 struct rsnd_priv *priv);
275 int (*nolock_stop)(struct rsnd_mod *mod,
276 struct rsnd_dai_stream *io,
277 struct rsnd_priv *priv);
278 };
279
280 struct rsnd_dai_stream;
281 struct rsnd_mod {
282 int id;
283 enum rsnd_mod_type type;
284 struct rsnd_mod_ops *ops;
285 struct rsnd_priv *priv;
286 struct clk *clk;
287 u32 *(*get_status)(struct rsnd_dai_stream *io,
288 struct rsnd_mod *mod,
289 enum rsnd_mod_type type);
290 u32 status;
291 };
292 /*
293 * status
294 *
295 * 0xH0000CBA
296 *
297 * A 0: nolock_start 1: nolock_stop
298 * B 0: init 1: quit
299 * C 0: start 1: stop
300 *
301 * H is always called (see __rsnd_mod_call)
302 * H 0: probe 1: remove
303 * H 0: pcm_new
304 * H 0: fallback
305 * H 0: hw_params
306 */
307 #define __rsnd_mod_shift_nolock_start 0
308 #define __rsnd_mod_shift_nolock_stop 0
309 #define __rsnd_mod_shift_init 4
310 #define __rsnd_mod_shift_quit 4
311 #define __rsnd_mod_shift_start 8
312 #define __rsnd_mod_shift_stop 8
313 #define __rsnd_mod_shift_probe 28 /* always called */
314 #define __rsnd_mod_shift_remove 28 /* always called */
315 #define __rsnd_mod_shift_irq 28 /* always called */
316 #define __rsnd_mod_shift_pcm_new 28 /* always called */
317 #define __rsnd_mod_shift_fallback 28 /* always called */
318 #define __rsnd_mod_shift_hw_params 28 /* always called */
319
320 #define __rsnd_mod_add_probe 0
321 #define __rsnd_mod_add_remove 0
322 #define __rsnd_mod_add_nolock_start 1
323 #define __rsnd_mod_add_nolock_stop -1
324 #define __rsnd_mod_add_init 1
325 #define __rsnd_mod_add_quit -1
326 #define __rsnd_mod_add_start 1
327 #define __rsnd_mod_add_stop -1
328 #define __rsnd_mod_add_irq 0
329 #define __rsnd_mod_add_pcm_new 0
330 #define __rsnd_mod_add_fallback 0
331 #define __rsnd_mod_add_hw_params 0
332
333 #define __rsnd_mod_call_probe 0
334 #define __rsnd_mod_call_remove 0
335 #define __rsnd_mod_call_init 0
336 #define __rsnd_mod_call_quit 1
337 #define __rsnd_mod_call_start 0
338 #define __rsnd_mod_call_stop 1
339 #define __rsnd_mod_call_irq 0
340 #define __rsnd_mod_call_pcm_new 0
341 #define __rsnd_mod_call_fallback 0
342 #define __rsnd_mod_call_hw_params 0
343 #define __rsnd_mod_call_nolock_start 0
344 #define __rsnd_mod_call_nolock_stop 1
345
346 #define rsnd_mod_to_priv(mod) ((mod)->priv)
347 #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1)
348 #define rsnd_mod_power_on(mod) clk_enable((mod)->clk)
349 #define rsnd_mod_power_off(mod) clk_disable((mod)->clk)
350 #define rsnd_mod_get(ip) (&(ip)->mod)
351
352 int rsnd_mod_init(struct rsnd_priv *priv,
353 struct rsnd_mod *mod,
354 struct rsnd_mod_ops *ops,
355 struct clk *clk,
356 u32* (*get_status)(struct rsnd_dai_stream *io,
357 struct rsnd_mod *mod,
358 enum rsnd_mod_type type),
359 enum rsnd_mod_type type,
360 int id);
361 void rsnd_mod_quit(struct rsnd_mod *mod);
362 char *rsnd_mod_name(struct rsnd_mod *mod);
363 struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
364 struct rsnd_mod *mod);
365 void rsnd_mod_interrupt(struct rsnd_mod *mod,
366 void (*callback)(struct rsnd_mod *mod,
367 struct rsnd_dai_stream *io));
368 u32 *rsnd_mod_get_status(struct rsnd_dai_stream *io,
369 struct rsnd_mod *mod,
370 enum rsnd_mod_type type);
371 struct rsnd_mod *rsnd_mod_next(int *iterator,
372 struct rsnd_dai_stream *io,
373 enum rsnd_mod_type *array,
374 int array_size);
375 #define for_each_rsnd_mod(iterator, pos, io) \
376 for (iterator = 0; \
377 (pos = rsnd_mod_next(&iterator, io, NULL, 0)); iterator++)
378 #define for_each_rsnd_mod_arrays(iterator, pos, io, array, size) \
379 for (iterator = 0; \
380 (pos = rsnd_mod_next(&iterator, io, array, size)); iterator++)
381 #define for_each_rsnd_mod_array(iterator, pos, io, array) \
382 for_each_rsnd_mod_arrays(iterator, pos, io, array, ARRAY_SIZE(array))
383
384 void rsnd_parse_connect_common(struct rsnd_dai *rdai,
385 struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id),
386 struct device_node *node,
387 struct device_node *playback,
388 struct device_node *capture);
389
390 void rsnd_set_slot(struct rsnd_dai *rdai,
391 int slots, int slots_total);
392 int rsnd_get_slot(struct rsnd_dai_stream *io);
393 int rsnd_get_slot_num(struct rsnd_dai_stream *io);
394
395 int rsnd_runtime_channel_original(struct rsnd_dai_stream *io);
396 int rsnd_runtime_channel_after_ctu(struct rsnd_dai_stream *io);
397 int rsnd_runtime_channel_for_ssi(struct rsnd_dai_stream *io);
398 int rsnd_runtime_is_ssi_multi(struct rsnd_dai_stream *io);
399 int rsnd_runtime_is_ssi_tdm(struct rsnd_dai_stream *io);
400
401 /*
402 * DT
403 */
404 #define rsnd_parse_of_node(priv, node) \
405 of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, node)
406 #define RSND_NODE_DAI "rcar_sound,dai"
407 #define RSND_NODE_SSI "rcar_sound,ssi"
408 #define RSND_NODE_SRC "rcar_sound,src"
409 #define RSND_NODE_CTU "rcar_sound,ctu"
410 #define RSND_NODE_MIX "rcar_sound,mix"
411 #define RSND_NODE_DVC "rcar_sound,dvc"
412
413 /*
414 * R-Car sound DAI
415 */
416 #define RSND_DAI_NAME_SIZE 16
417 struct rsnd_dai_stream {
418 char name[RSND_DAI_NAME_SIZE];
419 struct snd_pcm_substream *substream;
420 struct rsnd_mod *mod[RSND_MOD_MAX];
421 struct rsnd_dai_path_info *info; /* rcar_snd.h */
422 struct rsnd_dai *rdai;
423 u32 parent_ssi_status;
424 int byte_pos;
425 int period_pos;
426 int byte_per_period;
427 int next_period_byte;
428 };
429 #define rsnd_io_to_mod(io, i) ((i) < RSND_MOD_MAX ? (io)->mod[(i)] : NULL)
430 #define rsnd_io_to_mod_ssi(io) rsnd_io_to_mod((io), RSND_MOD_SSI)
431 #define rsnd_io_to_mod_ssiu(io) rsnd_io_to_mod((io), RSND_MOD_SSIU)
432 #define rsnd_io_to_mod_ssip(io) rsnd_io_to_mod((io), RSND_MOD_SSIP)
433 #define rsnd_io_to_mod_src(io) rsnd_io_to_mod((io), RSND_MOD_SRC)
434 #define rsnd_io_to_mod_ctu(io) rsnd_io_to_mod((io), RSND_MOD_CTU)
435 #define rsnd_io_to_mod_mix(io) rsnd_io_to_mod((io), RSND_MOD_MIX)
436 #define rsnd_io_to_mod_dvc(io) rsnd_io_to_mod((io), RSND_MOD_DVC)
437 #define rsnd_io_to_mod_cmd(io) rsnd_io_to_mod((io), RSND_MOD_CMD)
438 #define rsnd_io_to_rdai(io) ((io)->rdai)
439 #define rsnd_io_to_priv(io) (rsnd_rdai_to_priv(rsnd_io_to_rdai(io)))
440 #define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io)
441 #define rsnd_io_to_runtime(io) ((io)->substream ? \
442 (io)->substream->runtime : NULL)
443 int rsnd_io_is_working(struct rsnd_dai_stream *io);
444
445 struct rsnd_dai {
446 char name[RSND_DAI_NAME_SIZE];
447 struct rsnd_dai_stream playback;
448 struct rsnd_dai_stream capture;
449 struct rsnd_priv *priv;
450
451 int slots;
452 int slots_num;
453
454 unsigned int clk_master:1;
455 unsigned int bit_clk_inv:1;
456 unsigned int frm_clk_inv:1;
457 unsigned int sys_delay:1;
458 unsigned int data_alignment:1;
459 };
460
461 #define rsnd_rdai_nr(priv) ((priv)->rdai_nr)
462 #define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master)
463 #define rsnd_rdai_to_priv(rdai) ((rdai)->priv)
464 #define for_each_rsnd_dai(rdai, priv, i) \
465 for (i = 0; \
466 (i < rsnd_rdai_nr(priv)) && \
467 ((rdai) = rsnd_rdai_get(priv, i)); \
468 i++)
469
470 struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id);
471
472 bool rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
473 void rsnd_dai_period_elapsed(struct rsnd_dai_stream *io);
474 int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional);
475 int rsnd_dai_connect(struct rsnd_mod *mod,
476 struct rsnd_dai_stream *io,
477 enum rsnd_mod_type type);
478 #define rsnd_dai_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_DAI)
479
480 /*
481 * R-Car Gen1/Gen2
482 */
483 int rsnd_gen_probe(struct rsnd_priv *priv);
484 void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
485 struct rsnd_mod *mod,
486 enum rsnd_reg reg);
487 phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id);
488
489 /*
490 * R-Car ADG
491 */
492 int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod);
493 int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate);
494 int rsnd_adg_probe(struct rsnd_priv *priv);
495 void rsnd_adg_remove(struct rsnd_priv *priv);
496 int rsnd_adg_set_src_timesel_gen2(struct rsnd_mod *src_mod,
497 struct rsnd_dai_stream *io,
498 unsigned int in_rate,
499 unsigned int out_rate);
500 int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod,
501 struct rsnd_dai_stream *io);
502 #define rsnd_adg_clk_enable(priv) rsnd_adg_clk_control(priv, 1)
503 #define rsnd_adg_clk_disable(priv) rsnd_adg_clk_control(priv, 0)
504 void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable);
505
506 /*
507 * R-Car sound priv
508 */
509 struct rsnd_priv {
510
511 struct platform_device *pdev;
512 spinlock_t lock;
513 unsigned long flags;
514 #define RSND_GEN_MASK (0xF << 0)
515 #define RSND_GEN1 (1 << 0)
516 #define RSND_GEN2 (2 << 0)
517
518 /*
519 * below value will be filled on rsnd_gen_probe()
520 */
521 void *gen;
522
523 /*
524 * below value will be filled on rsnd_adg_probe()
525 */
526 void *adg;
527
528 /*
529 * below value will be filled on rsnd_dma_probe()
530 */
531 void *dma;
532
533 /*
534 * below value will be filled on rsnd_ssi_probe()
535 */
536 void *ssi;
537 int ssi_nr;
538
539 /*
540 * below value will be filled on rsnd_ssiu_probe()
541 */
542 void *ssiu;
543 int ssiu_nr;
544
545 /*
546 * below value will be filled on rsnd_src_probe()
547 */
548 void *src;
549 int src_nr;
550
551 /*
552 * below value will be filled on rsnd_ctu_probe()
553 */
554 void *ctu;
555 int ctu_nr;
556
557 /*
558 * below value will be filled on rsnd_mix_probe()
559 */
560 void *mix;
561 int mix_nr;
562
563 /*
564 * below value will be filled on rsnd_dvc_probe()
565 */
566 void *dvc;
567 int dvc_nr;
568
569 /*
570 * below value will be filled on rsnd_cmd_probe()
571 */
572 void *cmd;
573 int cmd_nr;
574
575 /*
576 * below value will be filled on rsnd_dai_probe()
577 */
578 struct snd_soc_dai_driver *daidrv;
579 struct rsnd_dai *rdai;
580 int rdai_nr;
581 };
582
583 #define rsnd_priv_to_pdev(priv) ((priv)->pdev)
584 #define rsnd_priv_to_dev(priv) (&(rsnd_priv_to_pdev(priv)->dev))
585
586 #define rsnd_is_gen1(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN1)
587 #define rsnd_is_gen2(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN2)
588
589 /*
590 * rsnd_kctrl
591 */
592 struct rsnd_kctrl_cfg {
593 unsigned int max;
594 unsigned int size;
595 u32 *val;
596 const char * const *texts;
597 void (*update)(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
598 struct rsnd_dai_stream *io;
599 struct snd_card *card;
600 struct snd_kcontrol *kctrl;
601 };
602
603 #define RSND_MAX_CHANNELS 8
604 struct rsnd_kctrl_cfg_m {
605 struct rsnd_kctrl_cfg cfg;
606 u32 val[RSND_MAX_CHANNELS];
607 };
608
609 struct rsnd_kctrl_cfg_s {
610 struct rsnd_kctrl_cfg cfg;
611 u32 val;
612 };
613
614 void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg);
615 #define rsnd_kctrl_remove(_cfg) _rsnd_kctrl_remove(&((_cfg).cfg))
616
617 int rsnd_kctrl_new_m(struct rsnd_mod *mod,
618 struct rsnd_dai_stream *io,
619 struct snd_soc_pcm_runtime *rtd,
620 const unsigned char *name,
621 void (*update)(struct rsnd_dai_stream *io,
622 struct rsnd_mod *mod),
623 struct rsnd_kctrl_cfg_m *_cfg,
624 int ch_size,
625 u32 max);
626 int rsnd_kctrl_new_s(struct rsnd_mod *mod,
627 struct rsnd_dai_stream *io,
628 struct snd_soc_pcm_runtime *rtd,
629 const unsigned char *name,
630 void (*update)(struct rsnd_dai_stream *io,
631 struct rsnd_mod *mod),
632 struct rsnd_kctrl_cfg_s *_cfg,
633 u32 max);
634 int rsnd_kctrl_new_e(struct rsnd_mod *mod,
635 struct rsnd_dai_stream *io,
636 struct snd_soc_pcm_runtime *rtd,
637 const unsigned char *name,
638 struct rsnd_kctrl_cfg_s *_cfg,
639 void (*update)(struct rsnd_dai_stream *io,
640 struct rsnd_mod *mod),
641 const char * const *texts,
642 u32 max);
643
644 /*
645 * R-Car SSI
646 */
647 int rsnd_ssi_probe(struct rsnd_priv *priv);
648 void rsnd_ssi_remove(struct rsnd_priv *priv);
649 struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
650 int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod);
651 int rsnd_ssi_use_busif(struct rsnd_dai_stream *io);
652 u32 rsnd_ssi_multi_slaves_runtime(struct rsnd_dai_stream *io);
653
654 #define rsnd_ssi_is_pin_sharing(io) \
655 __rsnd_ssi_is_pin_sharing(rsnd_io_to_mod_ssi(io))
656 int __rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod);
657
658 #define rsnd_ssi_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_SSI)
659 void rsnd_parse_connect_ssi(struct rsnd_dai *rdai,
660 struct device_node *playback,
661 struct device_node *capture);
662
663 /*
664 * R-Car SSIU
665 */
666 int rsnd_ssiu_attach(struct rsnd_dai_stream *io,
667 struct rsnd_mod *mod);
668 int rsnd_ssiu_probe(struct rsnd_priv *priv);
669 void rsnd_ssiu_remove(struct rsnd_priv *priv);
670
671 /*
672 * R-Car SRC
673 */
674 int rsnd_src_probe(struct rsnd_priv *priv);
675 void rsnd_src_remove(struct rsnd_priv *priv);
676 struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id);
677
678 #define rsnd_src_get_in_rate(priv, io) rsnd_src_get_rate(priv, io, 1)
679 #define rsnd_src_get_out_rate(priv, io) rsnd_src_get_rate(priv, io, 0)
680 unsigned int rsnd_src_get_rate(struct rsnd_priv *priv,
681 struct rsnd_dai_stream *io,
682 int is_in);
683
684 #define rsnd_src_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_SRC)
685 #define rsnd_parse_connect_src(rdai, playback, capture) \
686 rsnd_parse_connect_common(rdai, rsnd_src_mod_get, \
687 rsnd_src_of_node(rsnd_rdai_to_priv(rdai)), \
688 playback, capture)
689
690 /*
691 * R-Car CTU
692 */
693 int rsnd_ctu_probe(struct rsnd_priv *priv);
694 void rsnd_ctu_remove(struct rsnd_priv *priv);
695 int rsnd_ctu_converted_channel(struct rsnd_mod *mod);
696 struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id);
697 #define rsnd_ctu_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_CTU)
698 #define rsnd_parse_connect_ctu(rdai, playback, capture) \
699 rsnd_parse_connect_common(rdai, rsnd_ctu_mod_get, \
700 rsnd_ctu_of_node(rsnd_rdai_to_priv(rdai)), \
701 playback, capture)
702
703 /*
704 * R-Car MIX
705 */
706 int rsnd_mix_probe(struct rsnd_priv *priv);
707 void rsnd_mix_remove(struct rsnd_priv *priv);
708 struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id);
709 #define rsnd_mix_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_MIX)
710 #define rsnd_parse_connect_mix(rdai, playback, capture) \
711 rsnd_parse_connect_common(rdai, rsnd_mix_mod_get, \
712 rsnd_mix_of_node(rsnd_rdai_to_priv(rdai)), \
713 playback, capture)
714
715 /*
716 * R-Car DVC
717 */
718 int rsnd_dvc_probe(struct rsnd_priv *priv);
719 void rsnd_dvc_remove(struct rsnd_priv *priv);
720 struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id);
721 #define rsnd_dvc_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_DVC)
722 #define rsnd_parse_connect_dvc(rdai, playback, capture) \
723 rsnd_parse_connect_common(rdai, rsnd_dvc_mod_get, \
724 rsnd_dvc_of_node(rsnd_rdai_to_priv(rdai)), \
725 playback, capture)
726
727 /*
728 * R-Car CMD
729 */
730 int rsnd_cmd_probe(struct rsnd_priv *priv);
731 void rsnd_cmd_remove(struct rsnd_priv *priv);
732 int rsnd_cmd_attach(struct rsnd_dai_stream *io, int id);
733 struct rsnd_mod *rsnd_cmd_mod_get(struct rsnd_priv *priv, int id);
734
735 #ifdef DEBUG
736 void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type);
737 #define rsnd_mod_confirm_ssi(mssi) rsnd_mod_make_sure(mssi, RSND_MOD_SSI)
738 #define rsnd_mod_confirm_src(msrc) rsnd_mod_make_sure(msrc, RSND_MOD_SRC)
739 #define rsnd_mod_confirm_dvc(mdvc) rsnd_mod_make_sure(mdvc, RSND_MOD_DVC)
740 #else
741 #define rsnd_mod_confirm_ssi(mssi)
742 #define rsnd_mod_confirm_src(msrc)
743 #define rsnd_mod_confirm_dvc(mdvc)
744 #endif
745
746 #endif