Lines Matching +full:i2s +full:- +full:out

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
164 .name = "I2S/PCM controller",
212 { "allwinner,sun50i-a64-codec-i2s", (uintptr_t)&sun50i_a64_codec_config },
213 { "allwinner,sun8i-h3-i2s", (uintptr_t)&sun8i_h3_config },
220 { -1, 0 }
235 #define I2S_LOCK(sc) mtx_lock(&(sc)->mtx)
236 #define I2S_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
237 #define I2S_READ(sc, reg) bus_read_4((sc)->res[0], (reg))
238 #define I2S_WRITE(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val))
239 #define I2S_TYPE(sc) ((sc)->cfg->type)
254 return -1; in sunxi_i2s_div_to_regval()
270 error = clk_enable(sc->clk); in aw_i2s_init()
272 device_printf(sc->dev, "cannot enable mod clock\n"); in aw_i2s_init()
298 I2S_WRITE(sc, sc->cfg->txchmap, 0x76543210); in aw_i2s_init()
299 val = I2S_READ(sc, sc->cfg->txchsel); in aw_i2s_init()
304 I2S_WRITE(sc, sc->cfg->txchsel, val); in aw_i2s_init()
305 I2S_WRITE(sc, sc->cfg->rxchmap, 0x76543210); in aw_i2s_init()
306 val = I2S_READ(sc, sc->cfg->rxchsel); in aw_i2s_init()
311 I2S_WRITE(sc, sc->cfg->rxchsel, val); in aw_i2s_init()
331 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in aw_i2s_probe()
334 device_set_desc(dev, "Allwinner I2S"); in aw_i2s_probe()
348 sc->dev = dev; in aw_i2s_attach()
350 sc->cfg = (void*)ofw_bus_search_compatible(dev, compat_data)->ocd_data; in aw_i2s_attach()
352 mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); in aw_i2s_attach()
354 if (bus_alloc_resources(dev, aw_i2s_spec, sc->res) != 0) { in aw_i2s_attach()
360 error = clk_get_by_ofw_name(dev, 0, "mod", &sc->clk); in aw_i2s_attach()
381 device_printf(dev, "cannot de-assert reset\n"); in aw_i2s_attach()
401 struct aw_i2s_softc *i2s; in aw_i2s_detach() local
403 i2s = device_get_softc(dev); in aw_i2s_detach()
405 if (i2s->clk) in aw_i2s_detach()
406 clk_release(i2s->clk); in aw_i2s_detach()
408 if (i2s->intrhand != NULL) in aw_i2s_detach()
409 bus_teardown_intr(i2s->dev, i2s->res[1], i2s->intrhand); in aw_i2s_detach()
411 bus_release_resources(dev, aw_i2s_spec, i2s->res); in aw_i2s_detach()
412 mtx_destroy(&i2s->mtx); in aw_i2s_detach()
476 chsel = I2S_READ(sc, sc->cfg->txchsel); in aw_i2s_dai_init()
479 I2S_WRITE(sc, sc->cfg->txchsel, chsel); in aw_i2s_dai_init()
481 chsel = I2S_READ(sc, sc->cfg->rxchsel); in aw_i2s_dai_init()
484 I2S_WRITE(sc, sc->cfg->rxchsel, chsel); in aw_i2s_dai_init()
500 fat0 |= DA_FAT0_LRCK_PERIOD(32 - 1); in aw_i2s_dai_init()
523 // device_printf(sc->dev, "status: %08x\n", status); in aw_i2s_dai_intr()
533 size = play_buf->bufsize; in aw_i2s_dai_intr()
536 samples = play_buf->buf; in aw_i2s_dai_intr()
540 for (; empty > 0; empty--) { in aw_i2s_dai_intr()
546 sc->play_ptr += written; in aw_i2s_dai_intr()
547 sc->play_ptr %= size; in aw_i2s_dai_intr()
559 size = rec_buf->bufsize; in aw_i2s_dai_intr()
561 samples = rec_buf->buf; in aw_i2s_dai_intr()
566 for (; available > 0; available--) { in aw_i2s_dai_intr()
572 sc->rec_ptr += recorded; in aw_i2s_dai_intr()
573 sc->rec_ptr %= size; in aw_i2s_dai_intr()
650 sc->play_ptr = 0; in aw_i2s_dai_trigger()
660 sc->rec_ptr = 0; in aw_i2s_dai_trigger()
680 ptr = sc->play_ptr; in aw_i2s_dai_get_ptr()
682 ptr = sc->rec_ptr; in aw_i2s_dai_get_ptr()
693 if (bus_setup_intr(dev, sc->res[1], in aw_i2s_dai_setup_intr()
695 &sc->intrhand)) { in aw_i2s_dai_setup_intr()
720 error = clk_set_freq(sc->clk, AW_I2S_CLK_RATE, CLK_SET_ROUND_DOWN); in aw_i2s_dai_set_sysclk()
722 device_printf(sc->dev, in aw_i2s_dai_set_sysclk()
726 error = clk_enable(sc->clk); in aw_i2s_dai_set_sysclk()
728 device_printf(sc->dev, in aw_i2s_dai_set_sysclk()
749 if (bclk_val == -1 || mclk_val == -1) { in aw_i2s_dai_set_sysclk()
750 device_printf(sc->dev, "couldn't configure bclk/mclk dividers\n"); in aw_i2s_dai_set_sysclk()
799 "i2s",