Lines Matching +full:multi +full:- +full:word
1 // SPDX-License-Identifier: GPL-2.0
3 // Renesas R-Car SSIU/SSI support
36 #define DWL_MASK (7 << 19) /* Data Word Length mask */
37 #define DWL_8 (0 << 19) /* Data Word Length */
38 #define DWL_16 (1 << 19) /* Data Word Length */
39 #define DWL_18 (2 << 19) /* Data Word Length */
40 #define DWL_20 (3 << 19) /* Data Word Length */
41 #define DWL_22 (4 << 19) /* Data Word Length */
42 #define DWL_24 (5 << 19) /* Data Word Length */
43 #define DWL_32 (6 << 19) /* Data Word Length */
46 * System word length
48 #define SWL_16 (1 << 16) /* R/W System Word Length */
49 #define SWL_24 (2 << 16) /* R/W System Word Length */
50 #define SWL_32 (3 << 16) /* R/W System Word Length */
107 ((pos) = ((struct rsnd_ssi *)(priv)->ssi + i)); \
110 #define rsnd_ssi_get(priv, id) ((struct rsnd_ssi *)(priv->ssi) + id)
111 #define rsnd_ssi_nr(priv) ((priv)->ssi_nr)
294 if (ssi->usrcnt > 0) { in rsnd_ssi_master_clk_start()
295 if (ssi->rate != rate) { in rsnd_ssi_master_clk_start()
297 return -EINVAL; in rsnd_ssi_master_clk_start()
300 if (ssi->chan != chan) { in rsnd_ssi_master_clk_start()
302 return -EINVAL; in rsnd_ssi_master_clk_start()
311 return -EIO; in rsnd_ssi_master_clk_start()
328 ssi->cr_clk = FORCE | rsnd_rdai_width_to_swl(rdai) | in rsnd_ssi_master_clk_start()
330 ssi->wsr = CONT; in rsnd_ssi_master_clk_start()
331 ssi->rate = rate; in rsnd_ssi_master_clk_start()
332 ssi->chan = chan; in rsnd_ssi_master_clk_start()
352 if (ssi->usrcnt > 1) in rsnd_ssi_master_clk_stop()
355 ssi->cr_clk = 0; in rsnd_ssi_master_clk_stop()
356 ssi->rate = 0; in rsnd_ssi_master_clk_stop()
357 ssi->chan = 0; in rsnd_ssi_master_clk_stop()
370 u32 cr_own = ssi->cr_own; in rsnd_ssi_config_init()
371 u32 cr_mode = ssi->cr_mode; in rsnd_ssi_config_init()
372 u32 wsr = ssi->wsr; in rsnd_ssi_config_init()
389 if (rdai->bit_clk_inv) in rsnd_ssi_config_init()
391 if (rdai->frm_clk_inv && !is_tdm) in rsnd_ssi_config_init()
393 if (rdai->data_alignment) in rsnd_ssi_config_init()
395 if (rdai->sys_delay) in rsnd_ssi_config_init()
403 wsr = ssi->wsr; in rsnd_ssi_config_init()
420 width = snd_pcm_format_width(runtime->format); in rsnd_ssi_config_init()
423 * The SWL and DWL bits in SSICR should be fixed at 32-bit in rsnd_ssi_config_init()
486 ssi->cr_own = cr_own; in rsnd_ssi_config_init()
487 ssi->cr_mode = cr_mode; in rsnd_ssi_config_init()
488 ssi->wsr = wsr; in rsnd_ssi_config_init()
495 rsnd_mod_write(mod, SSIWSR, ssi->wsr); in rsnd_ssi_register_setup()
496 rsnd_mod_write(mod, SSICR, ssi->cr_own | in rsnd_ssi_register_setup()
497 ssi->cr_clk | in rsnd_ssi_register_setup()
498 ssi->cr_mode | in rsnd_ssi_register_setup()
499 ssi->cr_en); in rsnd_ssi_register_setup()
514 ssi->usrcnt++; in rsnd_ssi_init()
545 if (!ssi->usrcnt) { in rsnd_ssi_quit()
547 return -EIO; in rsnd_ssi_quit()
554 ssi->usrcnt--; in rsnd_ssi_quit()
556 if (!ssi->usrcnt) { in rsnd_ssi_quit()
557 ssi->cr_own = 0; in rsnd_ssi_quit()
558 ssi->cr_mode = 0; in rsnd_ssi_quit()
559 ssi->wsr = 0; in rsnd_ssi_quit()
605 if (fmt_width > rdai->chan_width) { in rsnd_ssi_hw_params()
609 dev_err(dev, "invalid combination of slot-width and format-data-width\n"); in rsnd_ssi_hw_params()
610 return -EINVAL; in rsnd_ssi_hw_params()
627 * if Multi channel mode in rsnd_ssi_start()
639 ssi->cr_en = EN; in rsnd_ssi_start()
641 rsnd_mod_write(mod, SSICR, ssi->cr_own | in rsnd_ssi_start()
642 ssi->cr_clk | in rsnd_ssi_start()
643 ssi->cr_mode | in rsnd_ssi_start()
644 ssi->cr_en); in rsnd_ssi_start()
662 cr = ssi->cr_own | in rsnd_ssi_stop()
663 ssi->cr_clk; in rsnd_ssi_stop()
671 rsnd_mod_write(mod, SSICR, cr | ssi->cr_en); in rsnd_ssi_stop()
675 /* In multi-SSI mode, stop is performed by setting ssi0129 in in rsnd_ssi_stop()
688 ssi->cr_en = 0; in rsnd_ssi_stop()
753 spin_lock(&priv->lock); in __rsnd_ssi_interrupt()
822 spin_unlock(&priv->lock); in __rsnd_ssi_interrupt()
828 snd_pcm_stop_xrun(io->substream); in __rsnd_ssi_interrupt()
855 * 1) start Capture -> SSI0/SSI1 are started. in rsnd_ssi_get_status()
856 * 2) start Playback -> SSI0 doesn't work, because it is already in rsnd_ssi_get_status()
862 * IO-0: SRC0 -> CTU1 -+-> MUX -> DVC -> SSIU -> SSI0 in rsnd_ssi_get_status()
864 * IO-1: SRC1 -> CTU2 -+ in rsnd_ssi_get_status()
866 * 1) start IO-0 -> start SSI0 in rsnd_ssi_get_status()
867 * 2) start IO-1 -> SSI0 doesn't need to start, because it is in rsnd_ssi_get_status()
871 return &io->parent_ssi_status; in rsnd_ssi_get_status()
933 * SSI Multi secondaries in rsnd_ssi_common_probe()
950 * mod->status. in rsnd_ssi_common_probe()
955 ret = request_irq(ssi->irq, in rsnd_ssi_common_probe()
973 /* Do nothing if non SSI (= SSI parent, multi SSI) mod */ in rsnd_ssi_common_remove()
979 free_irq(ssi->irq, mod); in rsnd_ssi_common_remove()
995 u32 *buf = (u32 *)(runtime->dma_area + ssi->byte_pos); in rsnd_ssi_pio_interrupt()
1000 if (snd_pcm_format_width(runtime->format) == 24) in rsnd_ssi_pio_interrupt()
1013 byte_pos = ssi->byte_pos + sizeof(*buf); in rsnd_ssi_pio_interrupt()
1015 if (byte_pos >= ssi->next_period_byte) { in rsnd_ssi_pio_interrupt()
1016 int period_pos = byte_pos / ssi->byte_per_period; in rsnd_ssi_pio_interrupt()
1018 if (period_pos >= runtime->periods) { in rsnd_ssi_pio_interrupt()
1023 ssi->next_period_byte = (period_pos + 1) * ssi->byte_per_period; in rsnd_ssi_pio_interrupt()
1028 WRITE_ONCE(ssi->byte_pos, byte_pos); in rsnd_ssi_pio_interrupt()
1041 ssi->byte_pos = 0; in rsnd_ssi_pio_init()
1042 ssi->byte_per_period = runtime->period_size * in rsnd_ssi_pio_init()
1043 runtime->channels * in rsnd_ssi_pio_init()
1045 ssi->next_period_byte = ssi->byte_per_period; in rsnd_ssi_pio_init()
1058 *pointer = bytes_to_frames(runtime, READ_ONCE(ssi->byte_pos)); in rsnd_ssi_pio_pointer()
1094 * SSI Multi secondaries in rsnd_ssi_dma_probe()
1103 /* SSI probe might be called many times in MUX multi path */ in rsnd_ssi_dma_probe()
1104 ret = rsnd_dma_attach(io, mod, &io->dma); in rsnd_ssi_dma_probe()
1122 mod->ops = &rsnd_ssi_pio_ops; in rsnd_ssi_fallback()
1175 return mod->ops == &rsnd_ssi_dma_ops; in rsnd_ssi_is_dma_mode()
1194 /* try SSI -> SSIM1 -> SSIM2 -> SSIM3 */ in rsnd_ssi_connect()
1224 rsnd_ssi_connect(mod, &rdai->playback); in rsnd_parse_connect_ssi()
1226 rsnd_ssi_connect(mod, &rdai->capture); in rsnd_parse_connect_ssi()
1262 return -EINVAL; in rsnd_ssi_probe()
1266 ret = -EINVAL; in rsnd_ssi_probe()
1272 ret = -ENOMEM; in rsnd_ssi_probe()
1276 priv->ssi = ssi; in rsnd_ssi_probe()
1277 priv->ssi_nr = nr; in rsnd_ssi_probe()
1296 if (of_get_property(np, "shared-pin", NULL)) in rsnd_ssi_probe()
1299 if (of_get_property(np, "no-busif", NULL)) in rsnd_ssi_probe()
1302 ssi->irq = irq_of_parse_and_map(np, 0); in rsnd_ssi_probe()
1303 if (!ssi->irq) { in rsnd_ssi_probe()
1304 ret = -EINVAL; in rsnd_ssi_probe()
1309 if (of_property_read_bool(np, "pio-transfer")) in rsnd_ssi_probe()