Lines Matching +full:i2s +full:- +full:out
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
84 #define I2S_CKR_MDIV(n) (((n) - 1) << 16)
86 #define I2S_CKR_RSD(n) (((n) - 1) << 8)
88 #define I2S_CKR_TSD(n) (((n) - 1) << 0)
94 #define I2S_DMACR_RDL(n) (((n) - 1) << 16)
98 #define I2S_INTCR_RFT(n) (((n) - 1) << 20)
137 { "rockchip,rk3066-i2s", 1 },
138 { "rockchip,rk3399-i2s", 1 },
145 { -1, 0 }
161 #define RK_I2S_LOCK(sc) mtx_lock(&(sc)->mtx)
162 #define RK_I2S_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
163 #define RK_I2S_READ_4(sc, reg) bus_read_4((sc)->res[0], (reg))
164 #define RK_I2S_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val))
183 clk_set_freq(sc->clk, RK_I2S_SAMPLING_RATE * 256, in rk_i2s_init()
185 error = clk_enable(sc->clk); in rk_i2s_init()
187 device_printf(sc->dev, "cannot enable i2s_clk clock\n"); in rk_i2s_init()
195 if (sc->grf && ofw_bus_is_compatible(sc->dev, "rockchip,rk3399-i2s")) { in rk_i2s_init()
198 SYSCON_WRITE_4(sc->grf, GRF_SOC_CON8, val); in rk_i2s_init()
204 SYSCON_WRITE_4(sc->grf, 0xe640, val); in rk_i2s_init()
219 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in rk_i2s_probe()
222 device_set_desc(dev, "Rockchip I2S"); in rk_i2s_probe()
234 sc->dev = dev; in rk_i2s_attach()
236 mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); in rk_i2s_attach()
238 if (bus_alloc_resources(dev, rk_i2s_spec, sc->res) != 0) { in rk_i2s_attach()
244 error = clk_get_by_ofw_name(dev, 0, "i2s_hclk", &sc->hclk); in rk_i2s_attach()
250 error = clk_get_by_ofw_name(dev, 0, "i2s_clk", &sc->clk); in rk_i2s_attach()
257 error = clk_enable(sc->hclk); in rk_i2s_attach()
266 "rockchip,grf", &sc->grf) != 0) { in rk_i2s_attach()
285 struct rk_i2s_softc *i2s; in rk_i2s_detach() local
287 i2s = device_get_softc(dev); in rk_i2s_detach()
289 if (i2s->hclk != NULL) in rk_i2s_detach()
290 clk_release(i2s->hclk); in rk_i2s_detach()
291 if (i2s->clk) in rk_i2s_detach()
292 clk_release(i2s->clk); in rk_i2s_detach()
294 if (i2s->intrhand != NULL) in rk_i2s_detach()
295 bus_teardown_intr(i2s->dev, i2s->res[1], i2s->intrhand); in rk_i2s_detach()
297 bus_release_resources(dev, rk_i2s_spec, i2s->res); in rk_i2s_detach()
298 mtx_destroy(&i2s->mtx); in rk_i2s_detach()
404 if (count > FIFO_SIZE - 1) in rk_i2s_dai_intr()
405 count = FIFO_SIZE - 1; in rk_i2s_dai_intr()
406 size = play_buf->bufsize; in rk_i2s_dai_intr()
409 samples = play_buf->buf; in rk_i2s_dai_intr()
419 sc->play_ptr += written; in rk_i2s_dai_intr()
420 sc->play_ptr %= size; in rk_i2s_dai_intr()
429 size = rec_buf->bufsize; in rk_i2s_dai_intr()
431 samples = rec_buf->buf; in rk_i2s_dai_intr()
436 for (; level > 0; level--) { in rk_i2s_dai_intr()
444 sc->rec_ptr += recorded; in rk_i2s_dai_intr()
445 sc->rec_ptr %= size; in rk_i2s_dai_intr()
515 sc->play_ptr = 0; in rk_i2s_dai_trigger()
517 sc->rec_ptr = 0; in rk_i2s_dai_trigger()
535 ptr = sc->play_ptr; in rk_i2s_dai_get_ptr()
537 ptr = sc->rec_ptr; in rk_i2s_dai_get_ptr()
548 if (bus_setup_intr(dev, sc->res[1], in rk_i2s_dai_setup_intr()
550 &sc->intrhand)) { in rk_i2s_dai_setup_intr()
572 error = clk_disable(sc->clk); in rk_i2s_dai_set_sysclk()
574 device_printf(sc->dev, "could not disable i2s_clk clock\n"); in rk_i2s_dai_set_sysclk()
578 error = clk_set_freq(sc->clk, rate, CLK_SET_ROUND_DOWN); in rk_i2s_dai_set_sysclk()
580 device_printf(sc->dev, "could not set i2s_clk freq\n"); in rk_i2s_dai_set_sysclk()
582 error = clk_enable(sc->clk); in rk_i2s_dai_set_sysclk()
584 device_printf(sc->dev, "could not enable i2s_clk clock\n"); in rk_i2s_dai_set_sysclk()
607 error = clk_get_freq(sc->clk, &clk_freq); in rk_i2s_dai_set_chanspeed()
609 device_printf(sc->dev, "failed to get clk frequency: err=%d\n", error); in rk_i2s_dai_set_chanspeed()
647 "i2s",