.. | .. |
---|
42 | 42 | #define DWL_24 (5 << 19) /* Data Word Length */ |
---|
43 | 43 | #define DWL_32 (6 << 19) /* Data Word Length */ |
---|
44 | 44 | |
---|
| 45 | +/* |
---|
| 46 | + * System word length |
---|
| 47 | + */ |
---|
| 48 | +#define SWL_16 (1 << 16) /* R/W System Word Length */ |
---|
| 49 | +#define SWL_24 (2 << 16) /* R/W System Word Length */ |
---|
45 | 50 | #define SWL_32 (3 << 16) /* R/W System Word Length */ |
---|
| 51 | + |
---|
46 | 52 | #define SCKD (1 << 15) /* Serial Bit Clock Direction */ |
---|
47 | 53 | #define SWSD (1 << 14) /* Serial WS Direction */ |
---|
48 | 54 | #define SCKP (1 << 13) /* Serial Bit Clock Polarity */ |
---|
.. | .. |
---|
93 | 99 | /* flags */ |
---|
94 | 100 | #define RSND_SSI_CLK_PIN_SHARE (1 << 0) |
---|
95 | 101 | #define RSND_SSI_NO_BUSIF (1 << 1) /* SSI+DMA without BUSIF */ |
---|
96 | | -#define RSND_SSI_HDMI0 (1 << 2) /* for HDMI0 */ |
---|
97 | | -#define RSND_SSI_HDMI1 (1 << 3) /* for HDMI1 */ |
---|
98 | | -#define RSND_SSI_PROBED (1 << 4) |
---|
| 102 | +#define RSND_SSI_PROBED (1 << 2) |
---|
99 | 103 | |
---|
100 | 104 | #define for_each_rsnd_ssi(pos, priv, i) \ |
---|
101 | 105 | for (i = 0; \ |
---|
.. | .. |
---|
107 | 111 | #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) |
---|
108 | 112 | #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) |
---|
109 | 113 | #define rsnd_ssi_is_parent(ssi, io) ((ssi) == rsnd_io_to_mod_ssip(io)) |
---|
110 | | -#define rsnd_ssi_is_multi_slave(mod, io) \ |
---|
111 | | - (rsnd_ssi_multi_slaves(io) & (1 << rsnd_mod_id(mod))) |
---|
| 114 | +#define rsnd_ssi_is_multi_secondary(mod, io) \ |
---|
| 115 | + (rsnd_ssi_multi_secondaries(io) & (1 << rsnd_mod_id(mod))) |
---|
112 | 116 | #define rsnd_ssi_is_run_mods(mod, io) \ |
---|
113 | 117 | (rsnd_ssi_run_mods(io) & (1 << rsnd_mod_id(mod))) |
---|
114 | 118 | #define rsnd_ssi_can_output_clk(mod) (!__rsnd_ssi_is_pin_sharing(mod)) |
---|
115 | 119 | |
---|
116 | | -int rsnd_ssi_hdmi_port(struct rsnd_dai_stream *io) |
---|
117 | | -{ |
---|
118 | | - struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io); |
---|
119 | | - struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
---|
120 | | - |
---|
121 | | - if (rsnd_flags_has(ssi, RSND_SSI_HDMI0)) |
---|
122 | | - return RSND_SSI_HDMI_PORT0; |
---|
123 | | - |
---|
124 | | - if (rsnd_flags_has(ssi, RSND_SSI_HDMI1)) |
---|
125 | | - return RSND_SSI_HDMI_PORT1; |
---|
126 | | - |
---|
127 | | - return 0; |
---|
128 | | -} |
---|
| 120 | +static int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); |
---|
129 | 121 | |
---|
130 | 122 | int rsnd_ssi_use_busif(struct rsnd_dai_stream *io) |
---|
131 | 123 | { |
---|
.. | .. |
---|
170 | 162 | udelay(5); |
---|
171 | 163 | } |
---|
172 | 164 | |
---|
173 | | - dev_warn(dev, "%s[%d] status check failed\n", |
---|
174 | | - rsnd_mod_name(mod), rsnd_mod_id(mod)); |
---|
| 165 | + dev_warn(dev, "%s status check failed\n", rsnd_mod_name(mod)); |
---|
175 | 166 | } |
---|
176 | 167 | |
---|
177 | | -static u32 rsnd_ssi_multi_slaves(struct rsnd_dai_stream *io) |
---|
| 168 | +static u32 rsnd_ssi_multi_secondaries(struct rsnd_dai_stream *io) |
---|
178 | 169 | { |
---|
179 | 170 | struct rsnd_mod *mod; |
---|
180 | 171 | enum rsnd_mod_type types[] = { |
---|
.. | .. |
---|
202 | 193 | struct rsnd_mod *ssi_parent_mod = rsnd_io_to_mod_ssip(io); |
---|
203 | 194 | u32 mods; |
---|
204 | 195 | |
---|
205 | | - mods = rsnd_ssi_multi_slaves_runtime(io) | |
---|
| 196 | + mods = rsnd_ssi_multi_secondaries_runtime(io) | |
---|
206 | 197 | 1 << rsnd_mod_id(ssi_mod); |
---|
207 | 198 | |
---|
208 | 199 | if (ssi_parent_mod) |
---|
.. | .. |
---|
211 | 202 | return mods; |
---|
212 | 203 | } |
---|
213 | 204 | |
---|
214 | | -u32 rsnd_ssi_multi_slaves_runtime(struct rsnd_dai_stream *io) |
---|
| 205 | +u32 rsnd_ssi_multi_secondaries_runtime(struct rsnd_dai_stream *io) |
---|
215 | 206 | { |
---|
216 | | - if (rsnd_runtime_is_ssi_multi(io)) |
---|
217 | | - return rsnd_ssi_multi_slaves(io); |
---|
| 207 | + if (rsnd_runtime_is_multi_ssi(io)) |
---|
| 208 | + return rsnd_ssi_multi_secondaries(io); |
---|
218 | 209 | |
---|
219 | 210 | return 0; |
---|
220 | 211 | } |
---|
221 | 212 | |
---|
222 | | -unsigned int rsnd_ssi_clk_query(struct rsnd_priv *priv, |
---|
| 213 | +static u32 rsnd_rdai_width_to_swl(struct rsnd_dai *rdai) |
---|
| 214 | +{ |
---|
| 215 | + struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); |
---|
| 216 | + struct device *dev = rsnd_priv_to_dev(priv); |
---|
| 217 | + int width = rsnd_rdai_width_get(rdai); |
---|
| 218 | + |
---|
| 219 | + switch (width) { |
---|
| 220 | + case 32: return SWL_32; |
---|
| 221 | + case 24: return SWL_24; |
---|
| 222 | + case 16: return SWL_16; |
---|
| 223 | + } |
---|
| 224 | + |
---|
| 225 | + dev_err(dev, "unsupported slot width value: %d\n", width); |
---|
| 226 | + return 0; |
---|
| 227 | +} |
---|
| 228 | + |
---|
| 229 | +unsigned int rsnd_ssi_clk_query(struct rsnd_dai *rdai, |
---|
223 | 230 | int param1, int param2, int *idx) |
---|
224 | 231 | { |
---|
| 232 | + struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); |
---|
225 | 233 | int ssi_clk_mul_table[] = { |
---|
226 | 234 | 1, 2, 4, 8, 16, 6, 12, |
---|
227 | 235 | }; |
---|
228 | 236 | int j, ret; |
---|
229 | 237 | unsigned int main_rate; |
---|
| 238 | + int width = rsnd_rdai_width_get(rdai); |
---|
230 | 239 | |
---|
231 | 240 | for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) { |
---|
232 | 241 | |
---|
.. | .. |
---|
239 | 248 | if (j == 0) |
---|
240 | 249 | continue; |
---|
241 | 250 | |
---|
242 | | - /* |
---|
243 | | - * this driver is assuming that |
---|
244 | | - * system word is 32bit x chan |
---|
245 | | - * see rsnd_ssi_init() |
---|
246 | | - */ |
---|
247 | | - main_rate = 32 * param1 * param2 * ssi_clk_mul_table[j]; |
---|
| 251 | + main_rate = width * param1 * param2 * ssi_clk_mul_table[j]; |
---|
248 | 252 | |
---|
249 | 253 | ret = rsnd_adg_clk_query(priv, main_rate); |
---|
250 | 254 | if (ret < 0) |
---|
.. | .. |
---|
279 | 283 | if (!rsnd_ssi_can_output_clk(mod)) |
---|
280 | 284 | return 0; |
---|
281 | 285 | |
---|
282 | | - if (rsnd_ssi_is_multi_slave(mod, io)) |
---|
| 286 | + if (rsnd_ssi_is_multi_secondary(mod, io)) |
---|
283 | 287 | return 0; |
---|
| 288 | + |
---|
| 289 | + if (rsnd_runtime_is_tdm_split(io)) |
---|
| 290 | + chan = rsnd_io_converted_chan(io); |
---|
| 291 | + |
---|
| 292 | + chan = rsnd_channel_normalization(chan); |
---|
284 | 293 | |
---|
285 | 294 | if (ssi->usrcnt > 0) { |
---|
286 | 295 | if (ssi->rate != rate) { |
---|
.. | .. |
---|
288 | 297 | return -EINVAL; |
---|
289 | 298 | } |
---|
290 | 299 | |
---|
| 300 | + if (ssi->chan != chan) { |
---|
| 301 | + dev_err(dev, "SSI parent/child should use same chan\n"); |
---|
| 302 | + return -EINVAL; |
---|
| 303 | + } |
---|
| 304 | + |
---|
291 | 305 | return 0; |
---|
292 | 306 | } |
---|
293 | 307 | |
---|
294 | | - main_rate = rsnd_ssi_clk_query(priv, rate, chan, &idx); |
---|
| 308 | + main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx); |
---|
295 | 309 | if (!main_rate) { |
---|
296 | 310 | dev_err(dev, "unsupported clock rate\n"); |
---|
297 | 311 | return -EIO; |
---|
.. | .. |
---|
311 | 325 | * SSICR : FORCE, SCKD, SWSD |
---|
312 | 326 | * SSIWSR : CONT |
---|
313 | 327 | */ |
---|
314 | | - ssi->cr_clk = FORCE | SWL_32 | SCKD | SWSD | CKDV(idx); |
---|
| 328 | + ssi->cr_clk = FORCE | rsnd_rdai_width_to_swl(rdai) | |
---|
| 329 | + SCKD | SWSD | CKDV(idx); |
---|
315 | 330 | ssi->wsr = CONT; |
---|
316 | 331 | ssi->rate = rate; |
---|
| 332 | + ssi->chan = chan; |
---|
317 | 333 | |
---|
318 | | - dev_dbg(dev, "%s[%d] outputs %u Hz\n", |
---|
319 | | - rsnd_mod_name(mod), |
---|
320 | | - rsnd_mod_id(mod), rate); |
---|
| 334 | + dev_dbg(dev, "%s outputs %d chan %u Hz\n", |
---|
| 335 | + rsnd_mod_name(mod), chan, rate); |
---|
321 | 336 | |
---|
322 | 337 | return 0; |
---|
323 | 338 | } |
---|
.. | .. |
---|
339 | 354 | |
---|
340 | 355 | ssi->cr_clk = 0; |
---|
341 | 356 | ssi->rate = 0; |
---|
| 357 | + ssi->chan = 0; |
---|
342 | 358 | |
---|
343 | 359 | rsnd_adg_ssi_clk_stop(mod); |
---|
344 | 360 | } |
---|
.. | .. |
---|
347 | 363 | struct rsnd_dai_stream *io) |
---|
348 | 364 | { |
---|
349 | 365 | struct rsnd_dai *rdai = rsnd_io_to_rdai(io); |
---|
| 366 | + struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); |
---|
| 367 | + struct device *dev = rsnd_priv_to_dev(priv); |
---|
350 | 368 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); |
---|
351 | 369 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
---|
352 | 370 | u32 cr_own = ssi->cr_own; |
---|
353 | 371 | u32 cr_mode = ssi->cr_mode; |
---|
354 | 372 | u32 wsr = ssi->wsr; |
---|
355 | | - int is_tdm; |
---|
| 373 | + int width; |
---|
| 374 | + int is_tdm, is_tdm_split; |
---|
| 375 | + int id = rsnd_mod_id(mod); |
---|
| 376 | + int i; |
---|
| 377 | + u32 sys_int_enable = 0; |
---|
356 | 378 | |
---|
357 | | - is_tdm = rsnd_runtime_is_ssi_tdm(io); |
---|
| 379 | + is_tdm = rsnd_runtime_is_tdm(io); |
---|
| 380 | + is_tdm_split = rsnd_runtime_is_tdm_split(io); |
---|
358 | 381 | |
---|
359 | | - /* |
---|
360 | | - * always use 32bit system word. |
---|
361 | | - * see also rsnd_ssi_master_clk_enable() |
---|
362 | | - */ |
---|
363 | | - cr_own |= FORCE | SWL_32; |
---|
| 382 | + if (is_tdm) |
---|
| 383 | + dev_dbg(dev, "TDM mode\n"); |
---|
| 384 | + if (is_tdm_split) |
---|
| 385 | + dev_dbg(dev, "TDM Split mode\n"); |
---|
| 386 | + |
---|
| 387 | + cr_own |= FORCE | rsnd_rdai_width_to_swl(rdai); |
---|
364 | 388 | |
---|
365 | 389 | if (rdai->bit_clk_inv) |
---|
366 | 390 | cr_own |= SCKP; |
---|
367 | | - if (rdai->frm_clk_inv ^ is_tdm) |
---|
| 391 | + if (rdai->frm_clk_inv && !is_tdm) |
---|
368 | 392 | cr_own |= SWSP; |
---|
369 | 393 | if (rdai->data_alignment) |
---|
370 | 394 | cr_own |= SDTA; |
---|
371 | 395 | if (rdai->sys_delay) |
---|
372 | 396 | cr_own |= DEL; |
---|
| 397 | + |
---|
| 398 | + /* |
---|
| 399 | + * TDM Mode |
---|
| 400 | + * see |
---|
| 401 | + * rsnd_ssiu_init_gen2() |
---|
| 402 | + */ |
---|
| 403 | + wsr = ssi->wsr; |
---|
| 404 | + if (is_tdm || is_tdm_split) { |
---|
| 405 | + wsr |= WS_MODE; |
---|
| 406 | + cr_own |= CHNL_8; |
---|
| 407 | + } |
---|
373 | 408 | |
---|
374 | 409 | /* |
---|
375 | 410 | * We shouldn't exchange SWSP after running. |
---|
.. | .. |
---|
382 | 417 | cr_own |= TRMD; |
---|
383 | 418 | |
---|
384 | 419 | cr_own &= ~DWL_MASK; |
---|
385 | | - switch (snd_pcm_format_width(runtime->format)) { |
---|
| 420 | + width = snd_pcm_format_width(runtime->format); |
---|
| 421 | + if (is_tdm_split) { |
---|
| 422 | + /* |
---|
| 423 | + * The SWL and DWL bits in SSICR should be fixed at 32-bit |
---|
| 424 | + * setting when TDM split mode. |
---|
| 425 | + * see datasheet |
---|
| 426 | + * Operation :: TDM Format Split Function (TDM Split Mode) |
---|
| 427 | + */ |
---|
| 428 | + width = 32; |
---|
| 429 | + } |
---|
| 430 | + |
---|
| 431 | + switch (width) { |
---|
| 432 | + case 8: |
---|
| 433 | + cr_own |= DWL_8; |
---|
| 434 | + break; |
---|
386 | 435 | case 16: |
---|
387 | 436 | cr_own |= DWL_16; |
---|
388 | 437 | break; |
---|
389 | 438 | case 24: |
---|
390 | 439 | cr_own |= DWL_24; |
---|
| 440 | + break; |
---|
| 441 | + case 32: |
---|
| 442 | + cr_own |= DWL_32; |
---|
391 | 443 | break; |
---|
392 | 444 | } |
---|
393 | 445 | |
---|
.. | .. |
---|
398 | 450 | cr_mode = DIEN; /* PIO : enable Data interrupt */ |
---|
399 | 451 | } |
---|
400 | 452 | |
---|
401 | | - /* |
---|
402 | | - * TDM Extend Mode |
---|
403 | | - * see |
---|
404 | | - * rsnd_ssiu_init_gen2() |
---|
405 | | - */ |
---|
406 | | - wsr = ssi->wsr; |
---|
407 | | - if (is_tdm) { |
---|
408 | | - wsr |= WS_MODE; |
---|
409 | | - cr_own |= CHNL_8; |
---|
| 453 | + /* enable busif buffer over/under run interrupt. */ |
---|
| 454 | + if (is_tdm || is_tdm_split) { |
---|
| 455 | + switch (id) { |
---|
| 456 | + case 0: |
---|
| 457 | + case 1: |
---|
| 458 | + case 2: |
---|
| 459 | + case 3: |
---|
| 460 | + case 4: |
---|
| 461 | + for (i = 0; i < 4; i++) { |
---|
| 462 | + sys_int_enable = rsnd_mod_read(mod, |
---|
| 463 | + SSI_SYS_INT_ENABLE(i * 2)); |
---|
| 464 | + sys_int_enable |= 0xf << (id * 4); |
---|
| 465 | + rsnd_mod_write(mod, |
---|
| 466 | + SSI_SYS_INT_ENABLE(i * 2), |
---|
| 467 | + sys_int_enable); |
---|
| 468 | + } |
---|
| 469 | + |
---|
| 470 | + break; |
---|
| 471 | + case 9: |
---|
| 472 | + for (i = 0; i < 4; i++) { |
---|
| 473 | + sys_int_enable = rsnd_mod_read(mod, |
---|
| 474 | + SSI_SYS_INT_ENABLE((i * 2) + 1)); |
---|
| 475 | + sys_int_enable |= 0xf << 4; |
---|
| 476 | + rsnd_mod_write(mod, |
---|
| 477 | + SSI_SYS_INT_ENABLE((i * 2) + 1), |
---|
| 478 | + sys_int_enable); |
---|
| 479 | + } |
---|
| 480 | + |
---|
| 481 | + break; |
---|
| 482 | + } |
---|
410 | 483 | } |
---|
| 484 | + |
---|
411 | 485 | init_end: |
---|
412 | 486 | ssi->cr_own = cr_own; |
---|
413 | 487 | ssi->cr_mode = cr_mode; |
---|
.. | .. |
---|
433 | 507 | struct rsnd_priv *priv) |
---|
434 | 508 | { |
---|
435 | 509 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
---|
| 510 | + int ret; |
---|
436 | 511 | |
---|
437 | 512 | if (!rsnd_ssi_is_run_mods(mod, io)) |
---|
438 | 513 | return 0; |
---|
439 | 514 | |
---|
| 515 | + ret = rsnd_ssi_master_clk_start(mod, io); |
---|
| 516 | + if (ret < 0) |
---|
| 517 | + return ret; |
---|
| 518 | + |
---|
440 | 519 | ssi->usrcnt++; |
---|
441 | 520 | |
---|
442 | | - rsnd_mod_power_on(mod); |
---|
| 521 | + ret = rsnd_mod_power_on(mod); |
---|
| 522 | + if (ret < 0) |
---|
| 523 | + return ret; |
---|
443 | 524 | |
---|
444 | 525 | rsnd_ssi_config_init(mod, io); |
---|
445 | 526 | |
---|
.. | .. |
---|
457 | 538 | { |
---|
458 | 539 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
---|
459 | 540 | struct device *dev = rsnd_priv_to_dev(priv); |
---|
| 541 | + int is_tdm, is_tdm_split; |
---|
| 542 | + int id = rsnd_mod_id(mod); |
---|
| 543 | + int i; |
---|
| 544 | + u32 sys_int_enable = 0; |
---|
| 545 | + |
---|
| 546 | + is_tdm = rsnd_runtime_is_tdm(io); |
---|
| 547 | + is_tdm_split = rsnd_runtime_is_tdm_split(io); |
---|
460 | 548 | |
---|
461 | 549 | if (!rsnd_ssi_is_run_mods(mod, io)) |
---|
462 | 550 | return 0; |
---|
463 | 551 | |
---|
464 | 552 | if (!ssi->usrcnt) { |
---|
465 | | - dev_err(dev, "%s[%d] usrcnt error\n", |
---|
466 | | - rsnd_mod_name(mod), rsnd_mod_id(mod)); |
---|
| 553 | + dev_err(dev, "%s usrcnt error\n", rsnd_mod_name(mod)); |
---|
467 | 554 | return -EIO; |
---|
468 | 555 | } |
---|
469 | 556 | |
---|
.. | .. |
---|
479 | 566 | ssi->wsr = 0; |
---|
480 | 567 | } |
---|
481 | 568 | |
---|
| 569 | + /* disable busif buffer over/under run interrupt. */ |
---|
| 570 | + if (is_tdm || is_tdm_split) { |
---|
| 571 | + switch (id) { |
---|
| 572 | + case 0: |
---|
| 573 | + case 1: |
---|
| 574 | + case 2: |
---|
| 575 | + case 3: |
---|
| 576 | + case 4: |
---|
| 577 | + for (i = 0; i < 4; i++) { |
---|
| 578 | + sys_int_enable = rsnd_mod_read(mod, |
---|
| 579 | + SSI_SYS_INT_ENABLE(i * 2)); |
---|
| 580 | + sys_int_enable &= ~(0xf << (id * 4)); |
---|
| 581 | + rsnd_mod_write(mod, |
---|
| 582 | + SSI_SYS_INT_ENABLE(i * 2), |
---|
| 583 | + sys_int_enable); |
---|
| 584 | + } |
---|
| 585 | + |
---|
| 586 | + break; |
---|
| 587 | + case 9: |
---|
| 588 | + for (i = 0; i < 4; i++) { |
---|
| 589 | + sys_int_enable = rsnd_mod_read(mod, |
---|
| 590 | + SSI_SYS_INT_ENABLE((i * 2) + 1)); |
---|
| 591 | + sys_int_enable &= ~(0xf << 4); |
---|
| 592 | + rsnd_mod_write(mod, |
---|
| 593 | + SSI_SYS_INT_ENABLE((i * 2) + 1), |
---|
| 594 | + sys_int_enable); |
---|
| 595 | + } |
---|
| 596 | + |
---|
| 597 | + break; |
---|
| 598 | + } |
---|
| 599 | + } |
---|
| 600 | + |
---|
482 | 601 | return 0; |
---|
483 | 602 | } |
---|
484 | 603 | |
---|
.. | .. |
---|
487 | 606 | struct snd_pcm_substream *substream, |
---|
488 | 607 | struct snd_pcm_hw_params *params) |
---|
489 | 608 | { |
---|
490 | | - struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
---|
491 | | - int chan = params_channels(params); |
---|
| 609 | + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); |
---|
| 610 | + unsigned int fmt_width = snd_pcm_format_width(params_format(params)); |
---|
492 | 611 | |
---|
493 | | - /* |
---|
494 | | - * snd_pcm_ops::hw_params will be called *before* |
---|
495 | | - * snd_soc_dai_ops::trigger. Thus, ssi->usrcnt is 0 |
---|
496 | | - * in 1st call. |
---|
497 | | - */ |
---|
498 | | - if (ssi->usrcnt) { |
---|
499 | | - /* |
---|
500 | | - * Already working. |
---|
501 | | - * It will happen if SSI has parent/child connection. |
---|
502 | | - * it is error if child <-> parent SSI uses |
---|
503 | | - * different channels. |
---|
504 | | - */ |
---|
505 | | - if (ssi->chan != chan) |
---|
506 | | - return -EIO; |
---|
| 612 | + if (fmt_width > rdai->chan_width) { |
---|
| 613 | + struct rsnd_priv *priv = rsnd_io_to_priv(io); |
---|
| 614 | + struct device *dev = rsnd_priv_to_dev(priv); |
---|
| 615 | + |
---|
| 616 | + dev_err(dev, "invalid combination of slot-width and format-data-width\n"); |
---|
| 617 | + return -EINVAL; |
---|
507 | 618 | } |
---|
508 | | - |
---|
509 | | - ssi->chan = chan; |
---|
510 | 619 | |
---|
511 | 620 | return 0; |
---|
512 | 621 | } |
---|
.. | .. |
---|
524 | 633 | * EN will be set via SSIU :: SSI_CONTROL |
---|
525 | 634 | * if Multi channel mode |
---|
526 | 635 | */ |
---|
527 | | - if (rsnd_ssi_multi_slaves_runtime(io)) |
---|
| 636 | + if (rsnd_ssi_multi_secondaries_runtime(io)) |
---|
528 | 637 | return 0; |
---|
529 | 638 | |
---|
530 | 639 | /* |
---|
.. | .. |
---|
573 | 682 | /* In multi-SSI mode, stop is performed by setting ssi0129 in |
---|
574 | 683 | * SSI_CONTROL to 0 (in rsnd_ssio_stop_gen2). Do nothing here. |
---|
575 | 684 | */ |
---|
576 | | - if (rsnd_ssi_multi_slaves_runtime(io)) |
---|
| 685 | + if (rsnd_ssi_multi_secondaries_runtime(io)) |
---|
577 | 686 | return 0; |
---|
578 | 687 | |
---|
579 | 688 | /* |
---|
.. | .. |
---|
594 | 703 | int enable) |
---|
595 | 704 | { |
---|
596 | 705 | u32 val = 0; |
---|
| 706 | + int is_tdm, is_tdm_split; |
---|
| 707 | + int id = rsnd_mod_id(mod); |
---|
| 708 | + |
---|
| 709 | + is_tdm = rsnd_runtime_is_tdm(io); |
---|
| 710 | + is_tdm_split = rsnd_runtime_is_tdm_split(io); |
---|
597 | 711 | |
---|
598 | 712 | if (rsnd_is_gen1(priv)) |
---|
599 | 713 | return 0; |
---|
.. | .. |
---|
606 | 720 | |
---|
607 | 721 | if (enable) |
---|
608 | 722 | val = rsnd_ssi_is_dma_mode(mod) ? 0x0e000000 : 0x0f000000; |
---|
| 723 | + |
---|
| 724 | + if (is_tdm || is_tdm_split) { |
---|
| 725 | + switch (id) { |
---|
| 726 | + case 0: |
---|
| 727 | + case 1: |
---|
| 728 | + case 2: |
---|
| 729 | + case 3: |
---|
| 730 | + case 4: |
---|
| 731 | + case 9: |
---|
| 732 | + val |= 0x0000ff00; |
---|
| 733 | + break; |
---|
| 734 | + } |
---|
| 735 | + } |
---|
609 | 736 | |
---|
610 | 737 | rsnd_mod_write(mod, SSI_INT_ENABLE, val); |
---|
611 | 738 | |
---|
.. | .. |
---|
623 | 750 | u32 status; |
---|
624 | 751 | bool elapsed = false; |
---|
625 | 752 | bool stop = false; |
---|
| 753 | + int id = rsnd_mod_id(mod); |
---|
| 754 | + int i; |
---|
| 755 | + int is_tdm, is_tdm_split; |
---|
| 756 | + |
---|
| 757 | + is_tdm = rsnd_runtime_is_tdm(io); |
---|
| 758 | + is_tdm_split = rsnd_runtime_is_tdm_split(io); |
---|
626 | 759 | |
---|
627 | 760 | spin_lock(&priv->lock); |
---|
628 | 761 | |
---|
.. | .. |
---|
638 | 771 | |
---|
639 | 772 | /* DMA only */ |
---|
640 | 773 | if (is_dma && (status & (UIRQ | OIRQ))) { |
---|
641 | | - rsnd_dbg_irq_status(dev, "%s[%d] err status : 0x%08x\n", |
---|
642 | | - rsnd_mod_name(mod), rsnd_mod_id(mod), status); |
---|
| 774 | + rsnd_dbg_irq_status(dev, "%s err status : 0x%08x\n", |
---|
| 775 | + rsnd_mod_name(mod), status); |
---|
643 | 776 | |
---|
644 | 777 | stop = true; |
---|
| 778 | + } |
---|
| 779 | + |
---|
| 780 | + status = 0; |
---|
| 781 | + |
---|
| 782 | + if (is_tdm || is_tdm_split) { |
---|
| 783 | + switch (id) { |
---|
| 784 | + case 0: |
---|
| 785 | + case 1: |
---|
| 786 | + case 2: |
---|
| 787 | + case 3: |
---|
| 788 | + case 4: |
---|
| 789 | + for (i = 0; i < 4; i++) { |
---|
| 790 | + status = rsnd_mod_read(mod, |
---|
| 791 | + SSI_SYS_STATUS(i * 2)); |
---|
| 792 | + status &= 0xf << (id * 4); |
---|
| 793 | + |
---|
| 794 | + if (status) { |
---|
| 795 | + rsnd_dbg_irq_status(dev, |
---|
| 796 | + "%s err status : 0x%08x\n", |
---|
| 797 | + rsnd_mod_name(mod), status); |
---|
| 798 | + rsnd_mod_write(mod, |
---|
| 799 | + SSI_SYS_STATUS(i * 2), |
---|
| 800 | + 0xf << (id * 4)); |
---|
| 801 | + stop = true; |
---|
| 802 | + } |
---|
| 803 | + } |
---|
| 804 | + break; |
---|
| 805 | + case 9: |
---|
| 806 | + for (i = 0; i < 4; i++) { |
---|
| 807 | + status = rsnd_mod_read(mod, |
---|
| 808 | + SSI_SYS_STATUS((i * 2) + 1)); |
---|
| 809 | + status &= 0xf << 4; |
---|
| 810 | + |
---|
| 811 | + if (status) { |
---|
| 812 | + rsnd_dbg_irq_status(dev, |
---|
| 813 | + "%s err status : 0x%08x\n", |
---|
| 814 | + rsnd_mod_name(mod), status); |
---|
| 815 | + rsnd_mod_write(mod, |
---|
| 816 | + SSI_SYS_STATUS((i * 2) + 1), |
---|
| 817 | + 0xf << 4); |
---|
| 818 | + stop = true; |
---|
| 819 | + } |
---|
| 820 | + } |
---|
| 821 | + break; |
---|
| 822 | + } |
---|
645 | 823 | } |
---|
646 | 824 | |
---|
647 | 825 | rsnd_ssi_status_clear(mod); |
---|
.. | .. |
---|
665 | 843 | return IRQ_HANDLED; |
---|
666 | 844 | } |
---|
667 | 845 | |
---|
| 846 | +static u32 *rsnd_ssi_get_status(struct rsnd_mod *mod, |
---|
| 847 | + struct rsnd_dai_stream *io, |
---|
| 848 | + enum rsnd_mod_type type) |
---|
| 849 | +{ |
---|
| 850 | + /* |
---|
| 851 | + * SSIP (= SSI parent) needs to be special, otherwise, |
---|
| 852 | + * 2nd SSI might doesn't start. see also rsnd_mod_call() |
---|
| 853 | + * |
---|
| 854 | + * We can't include parent SSI status on SSI, because we don't know |
---|
| 855 | + * how many SSI requests parent SSI. Thus, it is localed on "io" now. |
---|
| 856 | + * ex) trouble case |
---|
| 857 | + * Playback: SSI0 |
---|
| 858 | + * Capture : SSI1 (needs SSI0) |
---|
| 859 | + * |
---|
| 860 | + * 1) start Capture -> SSI0/SSI1 are started. |
---|
| 861 | + * 2) start Playback -> SSI0 doesn't work, because it is already |
---|
| 862 | + * marked as "started" on 1) |
---|
| 863 | + * |
---|
| 864 | + * OTOH, using each mod's status is good for MUX case. |
---|
| 865 | + * It doesn't need to start in 2nd start |
---|
| 866 | + * ex) |
---|
| 867 | + * IO-0: SRC0 -> CTU1 -+-> MUX -> DVC -> SSIU -> SSI0 |
---|
| 868 | + * | |
---|
| 869 | + * IO-1: SRC1 -> CTU2 -+ |
---|
| 870 | + * |
---|
| 871 | + * 1) start IO-0 -> start SSI0 |
---|
| 872 | + * 2) start IO-1 -> SSI0 doesn't need to start, because it is |
---|
| 873 | + * already started on 1) |
---|
| 874 | + */ |
---|
| 875 | + if (type == RSND_MOD_SSIP) |
---|
| 876 | + return &io->parent_ssi_status; |
---|
| 877 | + |
---|
| 878 | + return rsnd_mod_get_status(mod, io, type); |
---|
| 879 | +} |
---|
| 880 | + |
---|
668 | 881 | /* |
---|
669 | 882 | * SSI PIO |
---|
670 | 883 | */ |
---|
.. | .. |
---|
680 | 893 | if (!rsnd_rdai_is_clk_master(rdai)) |
---|
681 | 894 | return; |
---|
682 | 895 | |
---|
683 | | - if (rsnd_ssi_is_multi_slave(mod, io)) |
---|
| 896 | + if (rsnd_ssi_is_multi_secondary(mod, io)) |
---|
684 | 897 | return; |
---|
685 | 898 | |
---|
686 | 899 | switch (rsnd_mod_id(mod)) { |
---|
687 | 900 | case 1: |
---|
688 | 901 | case 2: |
---|
| 902 | + case 9: |
---|
689 | 903 | rsnd_dai_connect(rsnd_ssi_mod_get(priv, 0), io, RSND_MOD_SSIP); |
---|
690 | 904 | break; |
---|
691 | 905 | case 4: |
---|
.. | .. |
---|
717 | 931 | { |
---|
718 | 932 | struct device *dev = rsnd_priv_to_dev(priv); |
---|
719 | 933 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
---|
720 | | - int ret; |
---|
| 934 | + int ret = 0; |
---|
721 | 935 | |
---|
722 | 936 | /* |
---|
723 | 937 | * SSIP/SSIU/IRQ are not needed on |
---|
724 | | - * SSI Multi slaves |
---|
| 938 | + * SSI Multi secondaries |
---|
725 | 939 | */ |
---|
726 | | - if (rsnd_ssi_is_multi_slave(mod, io)) |
---|
| 940 | + if (rsnd_ssi_is_multi_secondary(mod, io)) |
---|
727 | 941 | return 0; |
---|
728 | 942 | |
---|
729 | 943 | /* |
---|
730 | 944 | * It can't judge ssi parent at this point |
---|
731 | 945 | * see rsnd_ssi_pcm_new() |
---|
732 | 946 | */ |
---|
733 | | - |
---|
734 | | - ret = rsnd_ssiu_attach(io, mod); |
---|
735 | | - if (ret < 0) |
---|
736 | | - return ret; |
---|
737 | 947 | |
---|
738 | 948 | /* |
---|
739 | 949 | * SSI might be called again as PIO fallback |
---|
.. | .. |
---|
855 | 1065 | return 0; |
---|
856 | 1066 | } |
---|
857 | 1067 | |
---|
858 | | -static int rsnd_ssi_prepare(struct rsnd_mod *mod, |
---|
859 | | - struct rsnd_dai_stream *io, |
---|
860 | | - struct rsnd_priv *priv) |
---|
861 | | -{ |
---|
862 | | - return rsnd_ssi_master_clk_start(mod, io); |
---|
863 | | -} |
---|
864 | | - |
---|
865 | 1068 | static struct rsnd_mod_ops rsnd_ssi_pio_ops = { |
---|
866 | | - .name = SSI_NAME, |
---|
867 | | - .probe = rsnd_ssi_common_probe, |
---|
868 | | - .remove = rsnd_ssi_common_remove, |
---|
869 | | - .init = rsnd_ssi_pio_init, |
---|
870 | | - .quit = rsnd_ssi_quit, |
---|
871 | | - .start = rsnd_ssi_start, |
---|
872 | | - .stop = rsnd_ssi_stop, |
---|
873 | | - .irq = rsnd_ssi_irq, |
---|
874 | | - .pointer = rsnd_ssi_pio_pointer, |
---|
875 | | - .pcm_new = rsnd_ssi_pcm_new, |
---|
876 | | - .hw_params = rsnd_ssi_hw_params, |
---|
877 | | - .prepare = rsnd_ssi_prepare, |
---|
| 1069 | + .name = SSI_NAME, |
---|
| 1070 | + .probe = rsnd_ssi_common_probe, |
---|
| 1071 | + .remove = rsnd_ssi_common_remove, |
---|
| 1072 | + .init = rsnd_ssi_pio_init, |
---|
| 1073 | + .quit = rsnd_ssi_quit, |
---|
| 1074 | + .start = rsnd_ssi_start, |
---|
| 1075 | + .stop = rsnd_ssi_stop, |
---|
| 1076 | + .irq = rsnd_ssi_irq, |
---|
| 1077 | + .pointer = rsnd_ssi_pio_pointer, |
---|
| 1078 | + .pcm_new = rsnd_ssi_pcm_new, |
---|
| 1079 | + .hw_params = rsnd_ssi_hw_params, |
---|
| 1080 | + .get_status = rsnd_ssi_get_status, |
---|
878 | 1081 | }; |
---|
879 | 1082 | |
---|
880 | 1083 | static int rsnd_ssi_dma_probe(struct rsnd_mod *mod, |
---|
.. | .. |
---|
885 | 1088 | |
---|
886 | 1089 | /* |
---|
887 | 1090 | * SSIP/SSIU/IRQ/DMA are not needed on |
---|
888 | | - * SSI Multi slaves |
---|
| 1091 | + * SSI Multi secondaries |
---|
889 | 1092 | */ |
---|
890 | | - if (rsnd_ssi_is_multi_slave(mod, io)) |
---|
| 1093 | + if (rsnd_ssi_is_multi_secondary(mod, io)) |
---|
891 | 1094 | return 0; |
---|
892 | 1095 | |
---|
893 | 1096 | ret = rsnd_ssi_common_probe(mod, io, priv); |
---|
.. | .. |
---|
915 | 1118 | */ |
---|
916 | 1119 | mod->ops = &rsnd_ssi_pio_ops; |
---|
917 | 1120 | |
---|
918 | | - dev_info(dev, "%s[%d] fallback to PIO mode\n", |
---|
919 | | - rsnd_mod_name(mod), rsnd_mod_id(mod)); |
---|
| 1121 | + dev_info(dev, "%s fallback to PIO mode\n", rsnd_mod_name(mod)); |
---|
920 | 1122 | |
---|
921 | 1123 | return 0; |
---|
922 | 1124 | } |
---|
.. | .. |
---|
928 | 1130 | int is_play = rsnd_io_is_play(io); |
---|
929 | 1131 | char *name; |
---|
930 | 1132 | |
---|
| 1133 | + /* |
---|
| 1134 | + * It should use "rcar_sound,ssiu" on DT. |
---|
| 1135 | + * But, we need to keep compatibility for old version. |
---|
| 1136 | + * |
---|
| 1137 | + * If it has "rcar_sound.ssiu", it will be used. |
---|
| 1138 | + * If not, "rcar_sound.ssi" will be used. |
---|
| 1139 | + * see |
---|
| 1140 | + * rsnd_ssiu_dma_req() |
---|
| 1141 | + * rsnd_dma_of_path() |
---|
| 1142 | + */ |
---|
| 1143 | + |
---|
931 | 1144 | if (rsnd_ssi_use_busif(io)) |
---|
932 | 1145 | name = is_play ? "rxu" : "txu"; |
---|
933 | 1146 | else |
---|
.. | .. |
---|
938 | 1151 | } |
---|
939 | 1152 | |
---|
940 | 1153 | static struct rsnd_mod_ops rsnd_ssi_dma_ops = { |
---|
941 | | - .name = SSI_NAME, |
---|
942 | | - .dma_req = rsnd_ssi_dma_req, |
---|
943 | | - .probe = rsnd_ssi_dma_probe, |
---|
944 | | - .remove = rsnd_ssi_common_remove, |
---|
945 | | - .init = rsnd_ssi_init, |
---|
946 | | - .quit = rsnd_ssi_quit, |
---|
947 | | - .start = rsnd_ssi_start, |
---|
948 | | - .stop = rsnd_ssi_stop, |
---|
949 | | - .irq = rsnd_ssi_irq, |
---|
950 | | - .pcm_new = rsnd_ssi_pcm_new, |
---|
951 | | - .fallback = rsnd_ssi_fallback, |
---|
952 | | - .hw_params = rsnd_ssi_hw_params, |
---|
953 | | - .prepare = rsnd_ssi_prepare, |
---|
| 1154 | + .name = SSI_NAME, |
---|
| 1155 | + .dma_req = rsnd_ssi_dma_req, |
---|
| 1156 | + .probe = rsnd_ssi_dma_probe, |
---|
| 1157 | + .remove = rsnd_ssi_common_remove, |
---|
| 1158 | + .init = rsnd_ssi_init, |
---|
| 1159 | + .quit = rsnd_ssi_quit, |
---|
| 1160 | + .start = rsnd_ssi_start, |
---|
| 1161 | + .stop = rsnd_ssi_stop, |
---|
| 1162 | + .irq = rsnd_ssi_irq, |
---|
| 1163 | + .pcm_new = rsnd_ssi_pcm_new, |
---|
| 1164 | + .fallback = rsnd_ssi_fallback, |
---|
| 1165 | + .hw_params = rsnd_ssi_hw_params, |
---|
| 1166 | + .get_status = rsnd_ssi_get_status, |
---|
954 | 1167 | }; |
---|
955 | 1168 | |
---|
956 | | -int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod) |
---|
| 1169 | +static int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod) |
---|
957 | 1170 | { |
---|
958 | 1171 | return mod->ops == &rsnd_ssi_dma_ops; |
---|
959 | 1172 | } |
---|
960 | | - |
---|
961 | 1173 | |
---|
962 | 1174 | /* |
---|
963 | 1175 | * ssi mod function |
---|
.. | .. |
---|
1014 | 1226 | of_node_put(node); |
---|
1015 | 1227 | } |
---|
1016 | 1228 | |
---|
1017 | | -static void __rsnd_ssi_parse_hdmi_connection(struct rsnd_priv *priv, |
---|
1018 | | - struct rsnd_dai_stream *io, |
---|
1019 | | - struct device_node *remote_ep) |
---|
1020 | | -{ |
---|
1021 | | - struct device *dev = rsnd_priv_to_dev(priv); |
---|
1022 | | - struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io); |
---|
1023 | | - struct rsnd_ssi *ssi; |
---|
1024 | | - struct device_node *remote_node = of_graph_get_port_parent(remote_ep); |
---|
1025 | | - |
---|
1026 | | - /* support Gen3 only */ |
---|
1027 | | - if (!rsnd_is_gen3(priv)) |
---|
1028 | | - return; |
---|
1029 | | - |
---|
1030 | | - if (!mod) |
---|
1031 | | - return; |
---|
1032 | | - |
---|
1033 | | - ssi = rsnd_mod_to_ssi(mod); |
---|
1034 | | - |
---|
1035 | | - /* HDMI0 */ |
---|
1036 | | - if (strstr(remote_node->full_name, "hdmi@fead0000")) { |
---|
1037 | | - rsnd_flags_set(ssi, RSND_SSI_HDMI0); |
---|
1038 | | - dev_dbg(dev, "%s[%d] connected to HDMI0\n", |
---|
1039 | | - rsnd_mod_name(mod), rsnd_mod_id(mod)); |
---|
1040 | | - } |
---|
1041 | | - |
---|
1042 | | - /* HDMI1 */ |
---|
1043 | | - if (strstr(remote_node->full_name, "hdmi@feae0000")) { |
---|
1044 | | - rsnd_flags_set(ssi, RSND_SSI_HDMI1); |
---|
1045 | | - dev_dbg(dev, "%s[%d] connected to HDMI1\n", |
---|
1046 | | - rsnd_mod_name(mod), rsnd_mod_id(mod)); |
---|
1047 | | - } |
---|
1048 | | -} |
---|
1049 | | - |
---|
1050 | | -void rsnd_ssi_parse_hdmi_connection(struct rsnd_priv *priv, |
---|
1051 | | - struct device_node *endpoint, |
---|
1052 | | - int dai_i) |
---|
1053 | | -{ |
---|
1054 | | - struct rsnd_dai *rdai = rsnd_rdai_get(priv, dai_i); |
---|
1055 | | - struct device_node *remote_ep; |
---|
1056 | | - |
---|
1057 | | - remote_ep = of_graph_get_remote_endpoint(endpoint); |
---|
1058 | | - if (!remote_ep) |
---|
1059 | | - return; |
---|
1060 | | - |
---|
1061 | | - __rsnd_ssi_parse_hdmi_connection(priv, &rdai->playback, remote_ep); |
---|
1062 | | - __rsnd_ssi_parse_hdmi_connection(priv, &rdai->capture, remote_ep); |
---|
1063 | | -} |
---|
1064 | | - |
---|
1065 | 1229 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id) |
---|
1066 | 1230 | { |
---|
1067 | 1231 | if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv))) |
---|
.. | .. |
---|
1076 | 1240 | return 0; |
---|
1077 | 1241 | |
---|
1078 | 1242 | return !!(rsnd_flags_has(rsnd_mod_to_ssi(mod), RSND_SSI_CLK_PIN_SHARE)); |
---|
1079 | | -} |
---|
1080 | | - |
---|
1081 | | -static u32 *rsnd_ssi_get_status(struct rsnd_dai_stream *io, |
---|
1082 | | - struct rsnd_mod *mod, |
---|
1083 | | - enum rsnd_mod_type type) |
---|
1084 | | -{ |
---|
1085 | | - /* |
---|
1086 | | - * SSIP (= SSI parent) needs to be special, otherwise, |
---|
1087 | | - * 2nd SSI might doesn't start. see also rsnd_mod_call() |
---|
1088 | | - * |
---|
1089 | | - * We can't include parent SSI status on SSI, because we don't know |
---|
1090 | | - * how many SSI requests parent SSI. Thus, it is localed on "io" now. |
---|
1091 | | - * ex) trouble case |
---|
1092 | | - * Playback: SSI0 |
---|
1093 | | - * Capture : SSI1 (needs SSI0) |
---|
1094 | | - * |
---|
1095 | | - * 1) start Capture -> SSI0/SSI1 are started. |
---|
1096 | | - * 2) start Playback -> SSI0 doesn't work, because it is already |
---|
1097 | | - * marked as "started" on 1) |
---|
1098 | | - * |
---|
1099 | | - * OTOH, using each mod's status is good for MUX case. |
---|
1100 | | - * It doesn't need to start in 2nd start |
---|
1101 | | - * ex) |
---|
1102 | | - * IO-0: SRC0 -> CTU1 -+-> MUX -> DVC -> SSIU -> SSI0 |
---|
1103 | | - * | |
---|
1104 | | - * IO-1: SRC1 -> CTU2 -+ |
---|
1105 | | - * |
---|
1106 | | - * 1) start IO-0 -> start SSI0 |
---|
1107 | | - * 2) start IO-1 -> SSI0 doesn't need to start, because it is |
---|
1108 | | - * already started on 1) |
---|
1109 | | - */ |
---|
1110 | | - if (type == RSND_MOD_SSIP) |
---|
1111 | | - return &io->parent_ssi_status; |
---|
1112 | | - |
---|
1113 | | - return rsnd_mod_get_status(io, mod, type); |
---|
1114 | 1243 | } |
---|
1115 | 1244 | |
---|
1116 | 1245 | int rsnd_ssi_probe(struct rsnd_priv *priv) |
---|
.. | .. |
---|
1179 | 1308 | ops = &rsnd_ssi_dma_ops; |
---|
1180 | 1309 | |
---|
1181 | 1310 | ret = rsnd_mod_init(priv, rsnd_mod_get(ssi), ops, clk, |
---|
1182 | | - rsnd_ssi_get_status, RSND_MOD_SSI, i); |
---|
| 1311 | + RSND_MOD_SSI, i); |
---|
1183 | 1312 | if (ret) { |
---|
1184 | 1313 | of_node_put(np); |
---|
1185 | 1314 | goto rsnd_ssi_probe_done; |
---|