forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/sh/rcar/ssi.c
....@@ -42,7 +42,13 @@
4242 #define DWL_24 (5 << 19) /* Data Word Length */
4343 #define DWL_32 (6 << 19) /* Data Word Length */
4444
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 */
4550 #define SWL_32 (3 << 16) /* R/W System Word Length */
51
+
4652 #define SCKD (1 << 15) /* Serial Bit Clock Direction */
4753 #define SWSD (1 << 14) /* Serial WS Direction */
4854 #define SCKP (1 << 13) /* Serial Bit Clock Polarity */
....@@ -93,9 +99,7 @@
9399 /* flags */
94100 #define RSND_SSI_CLK_PIN_SHARE (1 << 0)
95101 #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)
99103
100104 #define for_each_rsnd_ssi(pos, priv, i) \
101105 for (i = 0; \
....@@ -107,25 +111,13 @@
107111 #define rsnd_ssi_nr(priv) ((priv)->ssi_nr)
108112 #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod)
109113 #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)))
112116 #define rsnd_ssi_is_run_mods(mod, io) \
113117 (rsnd_ssi_run_mods(io) & (1 << rsnd_mod_id(mod)))
114118 #define rsnd_ssi_can_output_clk(mod) (!__rsnd_ssi_is_pin_sharing(mod))
115119
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);
129121
130122 int rsnd_ssi_use_busif(struct rsnd_dai_stream *io)
131123 {
....@@ -170,11 +162,10 @@
170162 udelay(5);
171163 }
172164
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));
175166 }
176167
177
-static u32 rsnd_ssi_multi_slaves(struct rsnd_dai_stream *io)
168
+static u32 rsnd_ssi_multi_secondaries(struct rsnd_dai_stream *io)
178169 {
179170 struct rsnd_mod *mod;
180171 enum rsnd_mod_type types[] = {
....@@ -202,7 +193,7 @@
202193 struct rsnd_mod *ssi_parent_mod = rsnd_io_to_mod_ssip(io);
203194 u32 mods;
204195
205
- mods = rsnd_ssi_multi_slaves_runtime(io) |
196
+ mods = rsnd_ssi_multi_secondaries_runtime(io) |
206197 1 << rsnd_mod_id(ssi_mod);
207198
208199 if (ssi_parent_mod)
....@@ -211,22 +202,40 @@
211202 return mods;
212203 }
213204
214
-u32 rsnd_ssi_multi_slaves_runtime(struct rsnd_dai_stream *io)
205
+u32 rsnd_ssi_multi_secondaries_runtime(struct rsnd_dai_stream *io)
215206 {
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);
218209
219210 return 0;
220211 }
221212
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,
223230 int param1, int param2, int *idx)
224231 {
232
+ struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
225233 int ssi_clk_mul_table[] = {
226234 1, 2, 4, 8, 16, 6, 12,
227235 };
228236 int j, ret;
229237 unsigned int main_rate;
238
+ int width = rsnd_rdai_width_get(rdai);
230239
231240 for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) {
232241
....@@ -239,12 +248,7 @@
239248 if (j == 0)
240249 continue;
241250
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];
248252
249253 ret = rsnd_adg_clk_query(priv, main_rate);
250254 if (ret < 0)
....@@ -279,8 +283,13 @@
279283 if (!rsnd_ssi_can_output_clk(mod))
280284 return 0;
281285
282
- if (rsnd_ssi_is_multi_slave(mod, io))
286
+ if (rsnd_ssi_is_multi_secondary(mod, io))
283287 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);
284293
285294 if (ssi->usrcnt > 0) {
286295 if (ssi->rate != rate) {
....@@ -288,10 +297,15 @@
288297 return -EINVAL;
289298 }
290299
300
+ if (ssi->chan != chan) {
301
+ dev_err(dev, "SSI parent/child should use same chan\n");
302
+ return -EINVAL;
303
+ }
304
+
291305 return 0;
292306 }
293307
294
- main_rate = rsnd_ssi_clk_query(priv, rate, chan, &idx);
308
+ main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx);
295309 if (!main_rate) {
296310 dev_err(dev, "unsupported clock rate\n");
297311 return -EIO;
....@@ -311,13 +325,14 @@
311325 * SSICR : FORCE, SCKD, SWSD
312326 * SSIWSR : CONT
313327 */
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);
315330 ssi->wsr = CONT;
316331 ssi->rate = rate;
332
+ ssi->chan = chan;
317333
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);
321336
322337 return 0;
323338 }
....@@ -339,6 +354,7 @@
339354
340355 ssi->cr_clk = 0;
341356 ssi->rate = 0;
357
+ ssi->chan = 0;
342358
343359 rsnd_adg_ssi_clk_stop(mod);
344360 }
....@@ -347,29 +363,48 @@
347363 struct rsnd_dai_stream *io)
348364 {
349365 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);
350368 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
351369 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
352370 u32 cr_own = ssi->cr_own;
353371 u32 cr_mode = ssi->cr_mode;
354372 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;
356378
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);
358381
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);
364388
365389 if (rdai->bit_clk_inv)
366390 cr_own |= SCKP;
367
- if (rdai->frm_clk_inv ^ is_tdm)
391
+ if (rdai->frm_clk_inv && !is_tdm)
368392 cr_own |= SWSP;
369393 if (rdai->data_alignment)
370394 cr_own |= SDTA;
371395 if (rdai->sys_delay)
372396 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
+ }
373408
374409 /*
375410 * We shouldn't exchange SWSP after running.
....@@ -382,12 +417,29 @@
382417 cr_own |= TRMD;
383418
384419 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;
386435 case 16:
387436 cr_own |= DWL_16;
388437 break;
389438 case 24:
390439 cr_own |= DWL_24;
440
+ break;
441
+ case 32:
442
+ cr_own |= DWL_32;
391443 break;
392444 }
393445
....@@ -398,16 +450,38 @@
398450 cr_mode = DIEN; /* PIO : enable Data interrupt */
399451 }
400452
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
+ }
410483 }
484
+
411485 init_end:
412486 ssi->cr_own = cr_own;
413487 ssi->cr_mode = cr_mode;
....@@ -433,13 +507,20 @@
433507 struct rsnd_priv *priv)
434508 {
435509 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
510
+ int ret;
436511
437512 if (!rsnd_ssi_is_run_mods(mod, io))
438513 return 0;
439514
515
+ ret = rsnd_ssi_master_clk_start(mod, io);
516
+ if (ret < 0)
517
+ return ret;
518
+
440519 ssi->usrcnt++;
441520
442
- rsnd_mod_power_on(mod);
521
+ ret = rsnd_mod_power_on(mod);
522
+ if (ret < 0)
523
+ return ret;
443524
444525 rsnd_ssi_config_init(mod, io);
445526
....@@ -457,13 +538,19 @@
457538 {
458539 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
459540 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);
460548
461549 if (!rsnd_ssi_is_run_mods(mod, io))
462550 return 0;
463551
464552 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));
467554 return -EIO;
468555 }
469556
....@@ -479,6 +566,38 @@
479566 ssi->wsr = 0;
480567 }
481568
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
+
482601 return 0;
483602 }
484603
....@@ -487,26 +606,16 @@
487606 struct snd_pcm_substream *substream,
488607 struct snd_pcm_hw_params *params)
489608 {
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));
492611
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;
507618 }
508
-
509
- ssi->chan = chan;
510619
511620 return 0;
512621 }
....@@ -524,7 +633,7 @@
524633 * EN will be set via SSIU :: SSI_CONTROL
525634 * if Multi channel mode
526635 */
527
- if (rsnd_ssi_multi_slaves_runtime(io))
636
+ if (rsnd_ssi_multi_secondaries_runtime(io))
528637 return 0;
529638
530639 /*
....@@ -573,7 +682,7 @@
573682 /* In multi-SSI mode, stop is performed by setting ssi0129 in
574683 * SSI_CONTROL to 0 (in rsnd_ssio_stop_gen2). Do nothing here.
575684 */
576
- if (rsnd_ssi_multi_slaves_runtime(io))
685
+ if (rsnd_ssi_multi_secondaries_runtime(io))
577686 return 0;
578687
579688 /*
....@@ -594,6 +703,11 @@
594703 int enable)
595704 {
596705 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);
597711
598712 if (rsnd_is_gen1(priv))
599713 return 0;
....@@ -606,6 +720,19 @@
606720
607721 if (enable)
608722 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
+ }
609736
610737 rsnd_mod_write(mod, SSI_INT_ENABLE, val);
611738
....@@ -623,6 +750,12 @@
623750 u32 status;
624751 bool elapsed = false;
625752 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);
626759
627760 spin_lock(&priv->lock);
628761
....@@ -638,10 +771,55 @@
638771
639772 /* DMA only */
640773 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);
643776
644777 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
+ }
645823 }
646824
647825 rsnd_ssi_status_clear(mod);
....@@ -665,6 +843,41 @@
665843 return IRQ_HANDLED;
666844 }
667845
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
+
668881 /*
669882 * SSI PIO
670883 */
....@@ -680,12 +893,13 @@
680893 if (!rsnd_rdai_is_clk_master(rdai))
681894 return;
682895
683
- if (rsnd_ssi_is_multi_slave(mod, io))
896
+ if (rsnd_ssi_is_multi_secondary(mod, io))
684897 return;
685898
686899 switch (rsnd_mod_id(mod)) {
687900 case 1:
688901 case 2:
902
+ case 9:
689903 rsnd_dai_connect(rsnd_ssi_mod_get(priv, 0), io, RSND_MOD_SSIP);
690904 break;
691905 case 4:
....@@ -717,23 +931,19 @@
717931 {
718932 struct device *dev = rsnd_priv_to_dev(priv);
719933 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
720
- int ret;
934
+ int ret = 0;
721935
722936 /*
723937 * SSIP/SSIU/IRQ are not needed on
724
- * SSI Multi slaves
938
+ * SSI Multi secondaries
725939 */
726
- if (rsnd_ssi_is_multi_slave(mod, io))
940
+ if (rsnd_ssi_is_multi_secondary(mod, io))
727941 return 0;
728942
729943 /*
730944 * It can't judge ssi parent at this point
731945 * see rsnd_ssi_pcm_new()
732946 */
733
-
734
- ret = rsnd_ssiu_attach(io, mod);
735
- if (ret < 0)
736
- return ret;
737947
738948 /*
739949 * SSI might be called again as PIO fallback
....@@ -855,26 +1065,19 @@
8551065 return 0;
8561066 }
8571067
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
-
8651068 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,
8781081 };
8791082
8801083 static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
....@@ -885,9 +1088,9 @@
8851088
8861089 /*
8871090 * SSIP/SSIU/IRQ/DMA are not needed on
888
- * SSI Multi slaves
1091
+ * SSI Multi secondaries
8891092 */
890
- if (rsnd_ssi_is_multi_slave(mod, io))
1093
+ if (rsnd_ssi_is_multi_secondary(mod, io))
8911094 return 0;
8921095
8931096 ret = rsnd_ssi_common_probe(mod, io, priv);
....@@ -915,8 +1118,7 @@
9151118 */
9161119 mod->ops = &rsnd_ssi_pio_ops;
9171120
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));
9201122
9211123 return 0;
9221124 }
....@@ -928,6 +1130,17 @@
9281130 int is_play = rsnd_io_is_play(io);
9291131 char *name;
9301132
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
+
9311144 if (rsnd_ssi_use_busif(io))
9321145 name = is_play ? "rxu" : "txu";
9331146 else
....@@ -938,26 +1151,25 @@
9381151 }
9391152
9401153 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,
9541167 };
9551168
956
-int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod)
1169
+static int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod)
9571170 {
9581171 return mod->ops == &rsnd_ssi_dma_ops;
9591172 }
960
-
9611173
9621174 /*
9631175 * ssi mod function
....@@ -1014,54 +1226,6 @@
10141226 of_node_put(node);
10151227 }
10161228
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
-
10651229 struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id)
10661230 {
10671231 if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv)))
....@@ -1076,41 +1240,6 @@
10761240 return 0;
10771241
10781242 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);
11141243 }
11151244
11161245 int rsnd_ssi_probe(struct rsnd_priv *priv)
....@@ -1179,7 +1308,7 @@
11791308 ops = &rsnd_ssi_dma_ops;
11801309
11811310 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);
11831312 if (ret) {
11841313 of_node_put(np);
11851314 goto rsnd_ssi_probe_done;