static int tegra30_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai); int ret; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif, &i2s->playback_dma_data.addr, &i2s->playback_dma_data.req_sel); i2s->playback_dma_data.wrap = 4; i2s->playback_dma_data.width = 32; tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif, i2s->playback_fifo_cif); } else { ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif, &i2s->capture_dma_data.addr, &i2s->capture_dma_data.req_sel); i2s->capture_dma_data.wrap = 4; i2s->capture_dma_data.width = 32; tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif, i2s->capture_i2s_cif); } return ret; }
static int tegra30_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai); int ret; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif, &i2s->playback_dma_data.addr, &i2s->playback_dma_data.slave_id); i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; i2s->playback_dma_data.maxburst = 4; tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif, i2s->playback_fifo_cif); } else { ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif, &i2s->capture_dma_data.addr, &i2s->capture_dma_data.slave_id); i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; i2s->capture_dma_data.maxburst = 4; tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif, i2s->capture_i2s_cif); } return ret; }
static int tegra_dmic_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct tegra_dmic *dmic = snd_soc_dai_get_drvdata(dai); u32 dmic_cif_id; int ret = 0; mutex_lock(&dmic->mutex); tegra30_ahub_enable_clocks(); ret = clk_enable(dmic->clk); if (ret < 0) dev_err(dmic->dev, "Can't enable DMIC clock\n"); /* Obtain Rx FIFOs and setup connections. */ ret = tegra30_ahub_allocate_rx_fifo(&dmic->rx_cif, &dmic->capture_dma_data.addr, &dmic->capture_dma_data.req_sel); dmic->capture_dma_data.wrap = 4; dmic->capture_dma_data.width = 32; if (dai->id == TEGRA_DMIC_FRONT) dmic_cif_id = TEGRA30_AHUB_TXCIF_DMIC0_TX0; else if (dai->id == TEGRA_DMIC_BACK) dmic_cif_id = TEGRA30_AHUB_TXCIF_DMIC1_TX0; else return -EINVAL; tegra30_ahub_set_rx_cif_source(dmic->rx_cif, dmic_cif_id); mutex_unlock(&dmic->mutex); return ret; }
static int tegra30_i2s_platform_probe(struct platform_device *pdev) { struct tegra30_i2s *i2s; const struct of_device_id *match; u32 cif_ids[2]; struct resource *mem, *memregion; void __iomem *regs; int ret; i2s = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_i2s), GFP_KERNEL); if (!i2s) { dev_err(&pdev->dev, "Can't allocate tegra30_i2s\n"); ret = -ENOMEM; goto err; } dev_set_drvdata(&pdev->dev, i2s); match = of_match_device(tegra30_i2s_of_match, &pdev->dev); if (!match) { dev_err(&pdev->dev, "Error: No device match found\n"); ret = -ENODEV; goto err; } i2s->soc_data = (struct tegra30_i2s_soc_data *)match->data; i2s->dai = tegra30_i2s_dai_template; i2s->dai.name = dev_name(&pdev->dev); ret = of_property_read_u32_array(pdev->dev.of_node, "nvidia,ahub-cif-ids", cif_ids, ARRAY_SIZE(cif_ids)); if (ret < 0) goto err; i2s->playback_i2s_cif = cif_ids[0]; i2s->capture_i2s_cif = cif_ids[1]; i2s->clk_i2s = clk_get(&pdev->dev, NULL); if (IS_ERR(i2s->clk_i2s)) { dev_err(&pdev->dev, "Can't retrieve i2s clock\n"); ret = PTR_ERR(i2s->clk_i2s); goto err; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "No memory resource\n"); ret = -ENODEV; goto err_clk_put; } memregion = devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem), DRV_NAME); if (!memregion) { dev_err(&pdev->dev, "Memory region already claimed\n"); ret = -EBUSY; goto err_clk_put; } regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); if (!regs) { dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto err_clk_put; } i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, &tegra30_i2s_regmap_config); if (IS_ERR(i2s->regmap)) { dev_err(&pdev->dev, "regmap init failed\n"); ret = PTR_ERR(i2s->regmap); goto err_clk_put; } regcache_cache_only(i2s->regmap, true); pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = tegra30_i2s_runtime_resume(&pdev->dev); if (ret) goto err_pm_disable; } i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; i2s->playback_dma_data.maxburst = 4; ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif, i2s->playback_dma_chan, sizeof(i2s->playback_dma_chan), &i2s->playback_dma_data.addr); if (ret) { dev_err(&pdev->dev, "Could not alloc TX FIFO: %d\n", ret); goto err_suspend; } ret = tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif, i2s->playback_fifo_cif); if (ret) { dev_err(&pdev->dev, "Could not route TX FIFO: %d\n", ret); goto err_free_tx_fifo; } i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; i2s->capture_dma_data.maxburst = 4; ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif, i2s->capture_dma_chan, sizeof(i2s->capture_dma_chan), &i2s->capture_dma_data.addr); if (ret) { dev_err(&pdev->dev, "Could not alloc RX FIFO: %d\n", ret); goto err_unroute_tx_fifo; } ret = tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif, i2s->capture_i2s_cif); if (ret) { dev_err(&pdev->dev, "Could not route TX FIFO: %d\n", ret); goto err_free_rx_fifo; } ret = snd_soc_register_component(&pdev->dev, &tegra30_i2s_component, &i2s->dai, 1); if (ret) { dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); ret = -ENOMEM; goto err_unroute_rx_fifo; } ret = tegra_pcm_platform_register_with_chan_names(&pdev->dev, &i2s->dma_config, i2s->playback_dma_chan, i2s->capture_dma_chan); if (ret) { dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); goto err_unregister_component; } return 0; err_unregister_component: snd_soc_unregister_component(&pdev->dev); err_unroute_rx_fifo: tegra30_ahub_unset_rx_cif_source(i2s->capture_fifo_cif); err_free_rx_fifo: tegra30_ahub_free_rx_fifo(i2s->capture_fifo_cif); err_unroute_tx_fifo: tegra30_ahub_unset_rx_cif_source(i2s->playback_i2s_cif); err_free_tx_fifo: tegra30_ahub_free_tx_fifo(i2s->playback_fifo_cif); err_suspend: if (!pm_runtime_status_suspended(&pdev->dev)) tegra30_i2s_runtime_suspend(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); err_clk_put: clk_put(i2s->clk_i2s); err: return ret; }