Lines Matching +full:axi +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012-2013, Analog Devices Inc.
4 * Author: Lars-Peter Clausen <lars@metafoo.de>
63 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in axi_i2s_trigger()
80 return -EINVAL; in axi_i2s_trigger()
83 regmap_update_bits(i2s->regmap, AXI_I2S_REG_CTRL, mask, val); in axi_i2s_trigger()
97 word_size = AXI_I2S_BITS_PER_FRAME / 2 - 1; in axi_i2s_hw_params()
98 bclk_div = DIV_ROUND_UP(clk_get_rate(i2s->clk_ref), bclk_rate) / 2 - 1; in axi_i2s_hw_params()
100 regmap_write(i2s->regmap, AXI_I2S_REG_CLK_CTRL, (word_size << 16) | in axi_i2s_hw_params()
113 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in axi_i2s_startup()
118 regmap_write(i2s->regmap, AXI_I2S_REG_RESET, mask); in axi_i2s_startup()
120 ret = snd_pcm_hw_constraint_ratnums(substream->runtime, 0, in axi_i2s_startup()
122 &i2s->rate_constraints); in axi_i2s_startup()
126 return clk_prepare_enable(i2s->clk_ref); in axi_i2s_startup()
134 clk_disable_unprepare(i2s->clk_ref); in axi_i2s_shutdown()
143 i2s->has_playback ? &i2s->playback_dma_data : NULL, in axi_i2s_dai_probe()
144 i2s->has_capture ? &i2s->capture_dma_data : NULL); in axi_i2s_dai_probe()
163 .name = "axi-i2s",
179 of_property_for_each_string(np, "dma-names", dma_names, dma_name) { in axi_i2s_parse_of()
181 i2s->has_capture = true; in axi_i2s_parse_of()
183 i2s->has_playback = true; in axi_i2s_parse_of()
191 void __iomem *base; in axi_i2s_probe() local
194 i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); in axi_i2s_probe()
196 return -ENOMEM; in axi_i2s_probe()
200 axi_i2s_parse_of(i2s, pdev->dev.of_node); in axi_i2s_probe()
202 base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in axi_i2s_probe()
203 if (IS_ERR(base)) in axi_i2s_probe()
204 return PTR_ERR(base); in axi_i2s_probe()
206 i2s->regmap = devm_regmap_init_mmio(&pdev->dev, base, in axi_i2s_probe()
208 if (IS_ERR(i2s->regmap)) in axi_i2s_probe()
209 return PTR_ERR(i2s->regmap); in axi_i2s_probe()
211 i2s->clk = devm_clk_get(&pdev->dev, "axi"); in axi_i2s_probe()
212 if (IS_ERR(i2s->clk)) in axi_i2s_probe()
213 return PTR_ERR(i2s->clk); in axi_i2s_probe()
215 i2s->clk_ref = devm_clk_get(&pdev->dev, "ref"); in axi_i2s_probe()
216 if (IS_ERR(i2s->clk_ref)) in axi_i2s_probe()
217 return PTR_ERR(i2s->clk_ref); in axi_i2s_probe()
219 ret = clk_prepare_enable(i2s->clk); in axi_i2s_probe()
223 if (i2s->has_playback) { in axi_i2s_probe()
230 i2s->playback_dma_data.addr = res->start + AXI_I2S_REG_TX_FIFO; in axi_i2s_probe()
231 i2s->playback_dma_data.addr_width = 4; in axi_i2s_probe()
232 i2s->playback_dma_data.maxburst = 1; in axi_i2s_probe()
235 if (i2s->has_capture) { in axi_i2s_probe()
242 i2s->capture_dma_data.addr = res->start + AXI_I2S_REG_RX_FIFO; in axi_i2s_probe()
243 i2s->capture_dma_data.addr_width = 4; in axi_i2s_probe()
244 i2s->capture_dma_data.maxburst = 1; in axi_i2s_probe()
247 i2s->ratnum.num = clk_get_rate(i2s->clk_ref) / 2 / AXI_I2S_BITS_PER_FRAME; in axi_i2s_probe()
248 i2s->ratnum.den_step = 1; in axi_i2s_probe()
249 i2s->ratnum.den_min = 1; in axi_i2s_probe()
250 i2s->ratnum.den_max = 64; in axi_i2s_probe()
252 i2s->rate_constraints.rats = &i2s->ratnum; in axi_i2s_probe()
253 i2s->rate_constraints.nrats = 1; in axi_i2s_probe()
255 regmap_write(i2s->regmap, AXI_I2S_REG_RESET, AXI_I2S_RESET_GLOBAL); in axi_i2s_probe()
257 ret = devm_snd_soc_register_component(&pdev->dev, &axi_i2s_component, in axi_i2s_probe()
262 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); in axi_i2s_probe()
266 dev_info(&pdev->dev, "probed, capture %s, playback %s\n", in axi_i2s_probe()
267 str_enabled_disabled(i2s->has_capture), in axi_i2s_probe()
268 str_enabled_disabled(i2s->has_playback)); in axi_i2s_probe()
273 clk_disable_unprepare(i2s->clk); in axi_i2s_probe()
281 clk_disable_unprepare(i2s->clk); in axi_i2s_dev_remove()
285 { .compatible = "adi,axi-i2s-1.00.a", },
292 .name = "axi-i2s",
300 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
301 MODULE_DESCRIPTION("AXI I2S driver");