Lines Matching +full:lpc3220 +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0-or-later
13 #include <linux/clk.h>
23 #include "lpc3xxx-i2s.h"
60 if (abs(trate - i2srate) < diff) { in __lpc3xxx_find_clkdiv()
61 diff = abs(trate - i2srate); in __lpc3xxx_find_clkdiv()
72 struct device *dev = i2s_info_p->dev; in lpc3xxx_i2s_startup()
76 guard(mutex)(&i2s_info_p->lock); in lpc3xxx_i2s_startup()
78 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in lpc3xxx_i2s_startup()
83 if (flag & i2s_info_p->streams_in_use) { in lpc3xxx_i2s_startup()
85 ret = -EBUSY; in lpc3xxx_i2s_startup()
89 if (i2s_info_p->streams_in_use == 0) { in lpc3xxx_i2s_startup()
90 ret = clk_prepare_enable(i2s_info_p->clk); in lpc3xxx_i2s_startup()
97 i2s_info_p->streams_in_use |= flag; in lpc3xxx_i2s_startup()
104 struct regmap *regs = i2s_info_p->regs; in lpc3xxx_i2s_shutdown()
108 guard(mutex)(&i2s_info_p->lock); in lpc3xxx_i2s_shutdown()
110 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in lpc3xxx_i2s_shutdown()
119 i2s_info_p->streams_in_use &= ~flag; in lpc3xxx_i2s_shutdown()
121 if (i2s_info_p->streams_in_use == 0) in lpc3xxx_i2s_shutdown()
122 clk_disable_unprepare(i2s_info_p->clk); in lpc3xxx_i2s_shutdown()
131 i2s_info_p->freq = freq; in lpc3xxx_i2s_set_dai_sysclk()
139 struct device *dev = i2s_info_p->dev; in lpc3xxx_i2s_set_dai_fmt()
143 return -EINVAL; in lpc3xxx_i2s_set_dai_fmt()
148 return -EINVAL; in lpc3xxx_i2s_set_dai_fmt()
159 struct device *dev = i2s_info_p->dev; in lpc3xxx_i2s_hw_params()
160 struct regmap *regs = i2s_info_p->regs; in lpc3xxx_i2s_hw_params()
183 return -EINVAL; in lpc3xxx_i2s_hw_params()
189 __lpc3xxx_find_clkdiv(&clkx, &clky, i2s_info_p->freq, xfersize, i2s_info_p->clkrate); in lpc3xxx_i2s_hw_params()
191 dev_dbg(dev, "Stream : %s\n", snd_pcm_direction_name(substream->stream)); in lpc3xxx_i2s_hw_params()
192 dev_dbg(dev, "Desired clock rate : %d\n", i2s_info_p->freq); in lpc3xxx_i2s_hw_params()
193 dev_dbg(dev, "Base clock rate : %d\n", i2s_info_p->clkrate); in lpc3xxx_i2s_hw_params()
200 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in lpc3xxx_i2s_hw_params()
219 struct regmap *regs = i2s_info_p->regs; in lpc3xxx_i2s_trigger()
226 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in lpc3xxx_i2s_trigger()
237 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in lpc3xxx_i2s_trigger()
245 ret = -EINVAL; in lpc3xxx_i2s_trigger()
255 snd_soc_dai_init_dma_data(dai, &i2s_info_p->playback_dma_config, in lpc3xxx_i2s_dai_probe()
256 &i2s_info_p->capture_dma_config); in lpc3xxx_i2s_dai_probe()
290 .name = "lpc32xx-i2s",
303 struct device *dev = &pdev->dev; in lpc32xx_i2s_probe()
311 return -ENOMEM; in lpc32xx_i2s_probe()
314 i2s_info_p->dev = dev; in lpc32xx_i2s_probe()
320 i2s_info_p->regs = devm_regmap_init_mmio(dev, iomem, &lpc32xx_i2s_regconfig); in lpc32xx_i2s_probe()
321 if (IS_ERR(i2s_info_p->regs)) in lpc32xx_i2s_probe()
322 return dev_err_probe(dev, PTR_ERR(i2s_info_p->regs), in lpc32xx_i2s_probe()
323 "failed to init register map: %pe\n", i2s_info_p->regs); in lpc32xx_i2s_probe()
325 i2s_info_p->clk = devm_clk_get(dev, NULL); in lpc32xx_i2s_probe()
326 if (IS_ERR(i2s_info_p->clk)) in lpc32xx_i2s_probe()
327 return dev_err_probe(dev, PTR_ERR(i2s_info_p->clk), "Can't get clock\n"); in lpc32xx_i2s_probe()
329 i2s_info_p->clkrate = clk_get_rate(i2s_info_p->clk); in lpc32xx_i2s_probe()
330 if (i2s_info_p->clkrate == 0) in lpc32xx_i2s_probe()
331 return dev_err_probe(dev, -EINVAL, "Invalid returned clock rate\n"); in lpc32xx_i2s_probe()
333 mutex_init(&i2s_info_p->lock); in lpc32xx_i2s_probe()
340 i2s_info_p->playback_dma_config.addr = (dma_addr_t)(res->start + LPC3XXX_REG_I2S_TX_FIFO); in lpc32xx_i2s_probe()
341 i2s_info_p->playback_dma_config.maxburst = 4; in lpc32xx_i2s_probe()
343 i2s_info_p->capture_dma_config.addr = (dma_addr_t)(res->start + LPC3XXX_REG_I2S_RX_FIFO); in lpc32xx_i2s_probe()
344 i2s_info_p->capture_dma_config.maxburst = 4; in lpc32xx_i2s_probe()
354 { .compatible = "nxp,lpc3220-i2s" },
362 .name = "lpc3xxx-i2s",