Lines Matching +full:ssiu +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0
3 // Renesas R-Car SSIU/SSI support
34 #define CHNL_6 (2u << 22) /* Channels */
39 #define DWL_18 (2u << 19) /* Data Word Length */
49 #define SWL_24 (2 << 16) /* R/W System Word Length */
102 #define RSND_SSI_PROBED (1 << 2)
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)
232 1, 2, 4, 8, 16, 6, 12, in rsnd_ssi_clk_query()
292 if (ssi->usrcnt > 0) { in rsnd_ssi_master_clk_start()
293 if (ssi->rate != rate) { in rsnd_ssi_master_clk_start()
295 return -EINVAL; in rsnd_ssi_master_clk_start()
298 if (ssi->chan != chan) { in rsnd_ssi_master_clk_start()
300 return -EINVAL; in rsnd_ssi_master_clk_start()
306 ret = -EIO; in rsnd_ssi_master_clk_start()
325 ssi->cr_clk = FORCE | rsnd_rdai_width_to_swl(rdai) | in rsnd_ssi_master_clk_start()
327 ssi->wsr = CONT; in rsnd_ssi_master_clk_start()
328 ssi->rate = rate; in rsnd_ssi_master_clk_start()
329 ssi->chan = chan; in rsnd_ssi_master_clk_start()
353 if (ssi->usrcnt > 1) in rsnd_ssi_master_clk_stop()
356 ssi->cr_clk = 0; in rsnd_ssi_master_clk_stop()
357 ssi->rate = 0; in rsnd_ssi_master_clk_stop()
358 ssi->chan = 0; in rsnd_ssi_master_clk_stop()
371 u32 cr_own = ssi->cr_own; in rsnd_ssi_config_init()
372 u32 cr_mode = ssi->cr_mode; in rsnd_ssi_config_init()
373 u32 wsr = ssi->wsr; in rsnd_ssi_config_init()
387 if (rdai->bit_clk_inv) in rsnd_ssi_config_init()
389 if (rdai->frm_clk_inv && !is_tdm) in rsnd_ssi_config_init()
391 if (rdai->data_alignment) in rsnd_ssi_config_init()
393 if (rdai->sys_delay) in rsnd_ssi_config_init()
417 width = snd_pcm_format_width(runtime->format); in rsnd_ssi_config_init()
420 * The SWL and DWL bits in SSICR should be fixed at 32-bit in rsnd_ssi_config_init()
451 ssi->cr_own = cr_own; in rsnd_ssi_config_init()
452 ssi->cr_mode = cr_mode; in rsnd_ssi_config_init()
453 ssi->wsr = wsr; in rsnd_ssi_config_init()
460 rsnd_mod_write(mod, SSIWSR, ssi->wsr); in rsnd_ssi_register_setup()
461 rsnd_mod_write(mod, SSICR, ssi->cr_own | in rsnd_ssi_register_setup()
462 ssi->cr_clk | in rsnd_ssi_register_setup()
463 ssi->cr_mode | in rsnd_ssi_register_setup()
464 ssi->cr_en); in rsnd_ssi_register_setup()
484 ssi->usrcnt++; in rsnd_ssi_init()
510 if (!ssi->usrcnt) { in rsnd_ssi_quit()
512 return -EIO; in rsnd_ssi_quit()
519 ssi->usrcnt--; in rsnd_ssi_quit()
521 if (!ssi->usrcnt) { in rsnd_ssi_quit()
522 ssi->cr_own = 0; in rsnd_ssi_quit()
523 ssi->cr_mode = 0; in rsnd_ssi_quit()
524 ssi->wsr = 0; in rsnd_ssi_quit()
538 if (fmt_width > rdai->chan_width) { in rsnd_ssi_hw_params()
542 dev_err(dev, "invalid combination of slot-width and format-data-width\n"); in rsnd_ssi_hw_params()
543 return -EINVAL; in rsnd_ssi_hw_params()
559 * EN will be set via SSIU :: SSI_CONTROL in rsnd_ssi_start()
572 ssi->cr_en = EN; in rsnd_ssi_start()
574 rsnd_mod_write(mod, SSICR, ssi->cr_own | in rsnd_ssi_start()
575 ssi->cr_clk | in rsnd_ssi_start()
576 ssi->cr_mode | in rsnd_ssi_start()
577 ssi->cr_en); in rsnd_ssi_start()
595 cr = ssi->cr_own | in rsnd_ssi_stop()
596 ssi->cr_clk; in rsnd_ssi_stop()
604 rsnd_mod_write(mod, SSICR, cr | ssi->cr_en); in rsnd_ssi_stop()
608 /* In multi-SSI mode, stop is performed by setting ssi0129 in in rsnd_ssi_stop()
621 ssi->cr_en = 0; in rsnd_ssi_stop()
654 case 2: in rsnd_ssi_irq()
680 spin_lock(&priv->lock); in __rsnd_ssi_interrupt()
704 spin_unlock(&priv->lock); in __rsnd_ssi_interrupt()
710 snd_pcm_stop_xrun(io->substream); in __rsnd_ssi_interrupt()
729 * 2nd SSI might doesn't start. see also rsnd_mod_call() in rsnd_ssi_get_status()
737 * 1) start Capture -> SSI0/SSI1 are started. in rsnd_ssi_get_status()
738 * 2) start Playback -> SSI0 doesn't work, because it is already in rsnd_ssi_get_status()
742 * It doesn't need to start in 2nd start in rsnd_ssi_get_status()
744 * IO-0: SRC0 -> CTU1 -+-> MUX -> DVC -> SSIU -> SSI0 in rsnd_ssi_get_status()
746 * IO-1: SRC1 -> CTU2 -+ in rsnd_ssi_get_status()
748 * 1) start IO-0 -> start SSI0 in rsnd_ssi_get_status()
749 * 2) start IO-1 -> SSI0 doesn't need to start, because it is in rsnd_ssi_get_status()
753 return &io->parent_ssi_status; in rsnd_ssi_get_status()
778 case 2: in rsnd_ssi_parent_attach()
814 * SSIP/SSIU/IRQ are not needed on in rsnd_ssi_common_probe()
832 * mod->status. in rsnd_ssi_common_probe()
837 ret = request_irq(ssi->irq, in rsnd_ssi_common_probe()
861 free_irq(ssi->irq, mod); in rsnd_ssi_common_remove()
877 u32 *buf = (u32 *)(runtime->dma_area + ssi->byte_pos); in rsnd_ssi_pio_interrupt()
882 if (snd_pcm_format_width(runtime->format) == 24) in rsnd_ssi_pio_interrupt()
895 byte_pos = ssi->byte_pos + sizeof(*buf); in rsnd_ssi_pio_interrupt()
897 if (byte_pos >= ssi->next_period_byte) { in rsnd_ssi_pio_interrupt()
898 int period_pos = byte_pos / ssi->byte_per_period; in rsnd_ssi_pio_interrupt()
900 if (period_pos >= runtime->periods) { in rsnd_ssi_pio_interrupt()
905 ssi->next_period_byte = (period_pos + 1) * ssi->byte_per_period; in rsnd_ssi_pio_interrupt()
910 WRITE_ONCE(ssi->byte_pos, byte_pos); in rsnd_ssi_pio_interrupt()
923 ssi->byte_pos = 0; in rsnd_ssi_pio_init()
924 ssi->byte_per_period = runtime->period_size * in rsnd_ssi_pio_init()
925 runtime->channels * in rsnd_ssi_pio_init()
927 ssi->next_period_byte = ssi->byte_per_period; in rsnd_ssi_pio_init()
940 *pointer = bytes_to_frames(runtime, READ_ONCE(ssi->byte_pos)); in rsnd_ssi_pio_pointer()
967 * SSIP/SSIU/IRQ/DMA are not needed on in rsnd_ssi_dma_probe()
978 ret = rsnd_dma_attach(io, mod, &io->dma); in rsnd_ssi_dma_probe()
996 mod->ops = &rsnd_ssi_pio_ops; in rsnd_ssi_fallback()
1011 * It should use "rcar_sound,ssiu" on DT. in rsnd_ssi_dma_req()
1014 * If it has "rcar_sound.ssiu", it will be used. in rsnd_ssi_dma_req()
1040 seq_printf(m, "bit_clk_inv: %d\n", rdai->bit_clk_inv); in rsnd_ssi_debug_info()
1041 seq_printf(m, "frm_clk_inv: %d\n", rdai->frm_clk_inv); in rsnd_ssi_debug_info()
1047 seq_printf(m, "chan: %d\n", ssi->chan); in rsnd_ssi_debug_info()
1048 seq_printf(m, "user: %d\n", ssi->usrcnt); in rsnd_ssi_debug_info()
1077 return mod->ops == &rsnd_ssi_dma_ops; in rsnd_ssi_is_dma_mode()
1096 /* try SSI -> SSIM1 -> SSIM2 -> SSIM3 */ in rsnd_ssi_connect()
1101 rsnd_rdai_channels_set(rdai, (i + 1) * 2); in rsnd_ssi_connect()
1135 rsnd_ssi_connect(mod, &rdai->playback); in rsnd_parse_connect_ssi()
1137 rsnd_ssi_connect(mod, &rdai->capture); in rsnd_parse_connect_ssi()
1173 return -EINVAL; in rsnd_ssi_probe()
1177 ret = -EINVAL; in rsnd_ssi_probe()
1183 ret = -ENOMEM; in rsnd_ssi_probe()
1187 priv->ssi = ssi; in rsnd_ssi_probe()
1188 priv->ssi_nr = nr; in rsnd_ssi_probe()
1197 ret = -EINVAL; in rsnd_ssi_probe()
1214 if (of_property_read_bool(np, "shared-pin")) in rsnd_ssi_probe()
1217 if (of_property_read_bool(np, "no-busif")) in rsnd_ssi_probe()
1220 ssi->irq = irq_of_parse_and_map(np, 0); in rsnd_ssi_probe()
1221 if (!ssi->irq) { in rsnd_ssi_probe()
1222 ret = -EINVAL; in rsnd_ssi_probe()
1227 if (of_property_read_bool(np, "pio-transfer")) in rsnd_ssi_probe()