Lines Matching +full:tegra30 +full:- +full:i2s

1 // SPDX-License-Identifier: GPL-2.0-only
3 * tegra30_ahub.c - Tegra30 AHUB driver
21 #define DRV_NAME "tegra30-ahub"
27 regmap_write(ahub->regmap_apbif, reg, val); in tegra30_apbif_write()
34 regmap_read(ahub->regmap_apbif, reg, &val); in tegra30_apbif_read()
40 regmap_write(ahub->regmap_ahub, reg, val); in tegra30_audio_write()
45 regcache_cache_only(ahub->regmap_apbif, true); in tegra30_ahub_runtime_suspend()
46 regcache_cache_only(ahub->regmap_ahub, true); in tegra30_ahub_runtime_suspend()
48 clk_bulk_disable_unprepare(ahub->nclocks, ahub->clocks); in tegra30_ahub_runtime_suspend()
54 * clk_apbif isn't required for an I2S<->I2S configuration where no PCM data
59 * These functions should not be a plain ref-count. Instead, each active stream
68 ret = reset_control_bulk_assert(ahub->nresets, ahub->resets); in tegra30_ahub_runtime_resume()
72 ret = clk_bulk_prepare_enable(ahub->nclocks, ahub->clocks); in tegra30_ahub_runtime_resume()
78 ret = reset_control_bulk_deassert(ahub->nresets, ahub->resets); in tegra30_ahub_runtime_resume()
82 regcache_cache_only(ahub->regmap_apbif, false); in tegra30_ahub_runtime_resume()
83 regcache_cache_only(ahub->regmap_ahub, false); in tegra30_ahub_runtime_resume()
84 regcache_mark_dirty(ahub->regmap_apbif); in tegra30_ahub_runtime_resume()
85 regcache_mark_dirty(ahub->regmap_ahub); in tegra30_ahub_runtime_resume()
87 ret = regcache_sync(ahub->regmap_apbif); in tegra30_ahub_runtime_resume()
91 ret = regcache_sync(ahub->regmap_ahub); in tegra30_ahub_runtime_resume()
98 clk_bulk_disable_unprepare(ahub->nclocks, ahub->clocks); in tegra30_ahub_runtime_resume()
111 channel = find_first_zero_bit(ahub->rx_usage, in tegra30_ahub_allocate_rx_fifo()
114 return -EBUSY; in tegra30_ahub_allocate_rx_fifo()
116 __set_bit(channel, ahub->rx_usage); in tegra30_ahub_allocate_rx_fifo()
120 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_RXFIFO + in tegra30_ahub_allocate_rx_fifo()
123 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_allocate_rx_fifo()
149 ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); in tegra30_ahub_allocate_rx_fifo()
151 pm_runtime_put(ahub->dev); in tegra30_ahub_allocate_rx_fifo()
159 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; in tegra30_ahub_enable_rx_fifo()
162 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_enable_rx_fifo()
170 pm_runtime_put(ahub->dev); in tegra30_ahub_enable_rx_fifo()
178 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; in tegra30_ahub_disable_rx_fifo()
181 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_disable_rx_fifo()
189 pm_runtime_put(ahub->dev); in tegra30_ahub_disable_rx_fifo()
197 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; in tegra30_ahub_free_rx_fifo()
199 __clear_bit(channel, ahub->rx_usage); in tegra30_ahub_free_rx_fifo()
213 channel = find_first_zero_bit(ahub->tx_usage, in tegra30_ahub_allocate_tx_fifo()
216 return -EBUSY; in tegra30_ahub_allocate_tx_fifo()
218 __set_bit(channel, ahub->tx_usage); in tegra30_ahub_allocate_tx_fifo()
222 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_TXFIFO + in tegra30_ahub_allocate_tx_fifo()
225 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_allocate_tx_fifo()
251 ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); in tegra30_ahub_allocate_tx_fifo()
253 pm_runtime_put(ahub->dev); in tegra30_ahub_allocate_tx_fifo()
261 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0; in tegra30_ahub_enable_tx_fifo()
264 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_enable_tx_fifo()
272 pm_runtime_put(ahub->dev); in tegra30_ahub_enable_tx_fifo()
280 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0; in tegra30_ahub_disable_tx_fifo()
283 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_disable_tx_fifo()
291 pm_runtime_put(ahub->dev); in tegra30_ahub_disable_tx_fifo()
299 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0; in tegra30_ahub_free_tx_fifo()
301 __clear_bit(channel, ahub->tx_usage); in tegra30_ahub_free_tx_fifo()
310 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; in tegra30_ahub_set_rx_cif_source()
313 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_set_rx_cif_source()
319 pm_runtime_put(ahub->dev); in tegra30_ahub_set_rx_cif_source()
327 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; in tegra30_ahub_unset_rx_cif_source()
330 pm_runtime_get_sync(ahub->dev); in tegra30_ahub_unset_rx_cif_source()
336 pm_runtime_put(ahub->dev); in tegra30_ahub_unset_rx_cif_source()
368 (TEGRA30_AHUB_##name##_STRIDE * TEGRA30_AHUB_##name##_COUNT) - 4)
373 (!((reg - TEGRA30_AHUB_##name) % TEGRA30_AHUB_##name##_STRIDE))))
507 { .compatible = "nvidia,tegra124-ahub", .data = &soc_data_tegra124 },
508 { .compatible = "nvidia,tegra114-ahub", .data = &soc_data_tegra114 },
509 { .compatible = "nvidia,tegra30-ahub", .data = &soc_data_tegra30 },
520 soc_data = of_device_get_match_data(&pdev->dev); in tegra30_ahub_probe()
522 return -EINVAL; in tegra30_ahub_probe()
524 ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub), in tegra30_ahub_probe()
527 return -ENOMEM; in tegra30_ahub_probe()
528 dev_set_drvdata(&pdev->dev, ahub); in tegra30_ahub_probe()
530 BUILD_BUG_ON(sizeof(ahub->resets) != sizeof(tegra30_ahub_resets_data)); in tegra30_ahub_probe()
531 memcpy(ahub->resets, tegra30_ahub_resets_data, sizeof(ahub->resets)); in tegra30_ahub_probe()
533 ahub->nresets = soc_data->num_resets; in tegra30_ahub_probe()
534 ahub->soc_data = soc_data; in tegra30_ahub_probe()
535 ahub->dev = &pdev->dev; in tegra30_ahub_probe()
537 ahub->clocks[ahub->nclocks++].id = "apbif"; in tegra30_ahub_probe()
538 ahub->clocks[ahub->nclocks++].id = "d_audio"; in tegra30_ahub_probe()
540 ret = devm_clk_bulk_get(&pdev->dev, ahub->nclocks, ahub->clocks); in tegra30_ahub_probe()
544 ret = devm_reset_control_bulk_get_exclusive(&pdev->dev, ahub->nresets, in tegra30_ahub_probe()
545 ahub->resets); in tegra30_ahub_probe()
547 dev_err(&pdev->dev, "Can't get resets: %d\n", ret); in tegra30_ahub_probe()
557 ahub->apbif_addr = res0->start; in tegra30_ahub_probe()
559 ahub->regmap_apbif = devm_regmap_init_mmio(&pdev->dev, regs_apbif, in tegra30_ahub_probe()
561 if (IS_ERR(ahub->regmap_apbif)) { in tegra30_ahub_probe()
562 dev_err(&pdev->dev, "apbif regmap init failed\n"); in tegra30_ahub_probe()
563 ret = PTR_ERR(ahub->regmap_apbif); in tegra30_ahub_probe()
566 regcache_cache_only(ahub->regmap_apbif, true); in tegra30_ahub_probe()
574 ahub->regmap_ahub = devm_regmap_init_mmio(&pdev->dev, regs_ahub, in tegra30_ahub_probe()
576 if (IS_ERR(ahub->regmap_ahub)) { in tegra30_ahub_probe()
577 dev_err(&pdev->dev, "ahub regmap init failed\n"); in tegra30_ahub_probe()
578 ret = PTR_ERR(ahub->regmap_ahub); in tegra30_ahub_probe()
581 regcache_cache_only(ahub->regmap_ahub, true); in tegra30_ahub_probe()
583 pm_runtime_enable(&pdev->dev); in tegra30_ahub_probe()
585 of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); in tegra30_ahub_probe()
597 pm_runtime_disable(&pdev->dev); in tegra30_ahub_remove()
625 value = (conf->threshold << in tegra30_ahub_set_cif()
627 ((conf->audio_channels - 1) << in tegra30_ahub_set_cif()
629 ((conf->client_channels - 1) << in tegra30_ahub_set_cif()
631 (conf->audio_bits << in tegra30_ahub_set_cif()
633 (conf->client_bits << in tegra30_ahub_set_cif()
635 (conf->expand << in tegra30_ahub_set_cif()
637 (conf->stereo_conv << in tegra30_ahub_set_cif()
639 (conf->replicate << in tegra30_ahub_set_cif()
641 (conf->direction << in tegra30_ahub_set_cif()
643 (conf->truncate << in tegra30_ahub_set_cif()
645 (conf->mono_conv << in tegra30_ahub_set_cif()
657 value = (conf->threshold << in tegra124_ahub_set_cif()
659 ((conf->audio_channels - 1) << in tegra124_ahub_set_cif()
661 ((conf->client_channels - 1) << in tegra124_ahub_set_cif()
663 (conf->audio_bits << in tegra124_ahub_set_cif()
665 (conf->client_bits << in tegra124_ahub_set_cif()
667 (conf->expand << in tegra124_ahub_set_cif()
669 (conf->stereo_conv << in tegra124_ahub_set_cif()
671 (conf->replicate << in tegra124_ahub_set_cif()
673 (conf->direction << in tegra124_ahub_set_cif()
675 (conf->truncate << in tegra124_ahub_set_cif()
677 (conf->mono_conv << in tegra124_ahub_set_cif()
685 MODULE_DESCRIPTION("Tegra30 AHUB driver");