Lines Matching +full:- +full:chn +full:- +full:disabled
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * pxa-ssp.c -- ALSA Soc Audio Layer
30 #include <sound/pxa2xx-lib.h>
33 #include "pxa-ssp.h"
55 dev_dbg(ssp->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", in dump_registers()
59 dev_dbg(ssp->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", in dump_registers()
67 dma->addr_width = width4 ? DMA_SLAVE_BUSWIDTH_4_BYTES : in pxa_ssp_set_dma_params()
69 dma->maxburst = 16; in pxa_ssp_set_dma_params()
70 dma->addr = ssp->phys_base + SSDR; in pxa_ssp_set_dma_params()
77 struct ssp_device *ssp = priv->ssp; in pxa_ssp_startup()
82 clk_prepare_enable(ssp->clk); in pxa_ssp_startup()
86 clk_prepare_enable(priv->extclk); in pxa_ssp_startup()
90 return -ENOMEM; in pxa_ssp_startup()
91 dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? in pxa_ssp_startup()
103 struct ssp_device *ssp = priv->ssp; in pxa_ssp_shutdown()
107 clk_disable_unprepare(ssp->clk); in pxa_ssp_shutdown()
110 clk_disable_unprepare(priv->extclk); in pxa_ssp_shutdown()
121 struct ssp_device *ssp = priv->ssp; in pxa_ssp_suspend()
124 clk_prepare_enable(ssp->clk); in pxa_ssp_suspend()
126 priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0); in pxa_ssp_suspend()
127 priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1); in pxa_ssp_suspend()
128 priv->to = __raw_readl(ssp->mmio_base + SSTO); in pxa_ssp_suspend()
129 priv->psp = __raw_readl(ssp->mmio_base + SSPSP); in pxa_ssp_suspend()
132 clk_disable_unprepare(ssp->clk); in pxa_ssp_suspend()
139 struct ssp_device *ssp = priv->ssp; in pxa_ssp_resume()
142 clk_prepare_enable(ssp->clk); in pxa_ssp_resume()
144 __raw_writel(sssr, ssp->mmio_base + SSSR); in pxa_ssp_resume()
145 __raw_writel(priv->cr0 & ~SSCR0_SSE, ssp->mmio_base + SSCR0); in pxa_ssp_resume()
146 __raw_writel(priv->cr1, ssp->mmio_base + SSCR1); in pxa_ssp_resume()
147 __raw_writel(priv->to, ssp->mmio_base + SSTO); in pxa_ssp_resume()
148 __raw_writel(priv->psp, ssp->mmio_base + SSPSP); in pxa_ssp_resume()
153 clk_disable_unprepare(ssp->clk); in pxa_ssp_resume()
164 * ssp_set_clkdiv - set SSP clock divider
171 if (ssp->type == PXA25x_SSP) { in pxa_ssp_set_scr()
173 sscr0 |= ((div - 2)/2) << 8; /* 2..512 */ in pxa_ssp_set_scr()
176 sscr0 |= (div - 1) << 8; /* 1..4096 */ in pxa_ssp_set_scr()
188 struct ssp_device *ssp = priv->ssp; in pxa_ssp_set_dai_sysclk()
193 if (priv->extclk) { in pxa_ssp_set_dai_sysclk()
201 ret = clk_set_rate(priv->extclk, freq); in pxa_ssp_set_dai_sysclk()
208 dev_dbg(ssp->dev, in pxa_ssp_set_dai_sysclk()
210 cpu_dai->id, clk_id, freq); in pxa_ssp_set_dai_sysclk()
218 if (ssp->type == PXA25x_SSP) in pxa_ssp_set_dai_sysclk()
219 priv->sysclk = 1843200; in pxa_ssp_set_dai_sysclk()
221 priv->sysclk = 13000000; in pxa_ssp_set_dai_sysclk()
224 priv->sysclk = freq; in pxa_ssp_set_dai_sysclk()
228 priv->sysclk = freq; in pxa_ssp_set_dai_sysclk()
232 priv->sysclk = 0; in pxa_ssp_set_dai_sysclk()
237 return -ENODEV; in pxa_ssp_set_dai_sysclk()
240 /* The SSP clock must be disabled when changing SSP clock mode in pxa_ssp_set_dai_sysclk()
242 if (ssp->type != PXA3xx_SSP) in pxa_ssp_set_dai_sysclk()
243 clk_disable_unprepare(ssp->clk); in pxa_ssp_set_dai_sysclk()
245 if (ssp->type != PXA3xx_SSP) in pxa_ssp_set_dai_sysclk()
246 clk_prepare_enable(ssp->clk); in pxa_ssp_set_dai_sysclk()
252 * Configure the PLL frequency pxa27x and (afaik - pxa320 only)
256 struct ssp_device *ssp = priv->ssp; in pxa_ssp_set_pll()
259 if (ssp->type == PXA3xx_SSP) in pxa_ssp_set_pll()
286 * a wider range of frequencies - calculate a value for it. in pxa_ssp_set_pll()
288 if (ssp->type == PXA3xx_SSP) { in pxa_ssp_set_pll()
301 dev_dbg(ssp->dev, in pxa_ssp_set_pll()
307 return -EINVAL; in pxa_ssp_set_pll()
322 struct ssp_device *ssp = priv->ssp; in pxa_ssp_set_dai_tdm_slot()
330 sscr0 |= SSCR0_EDSS | SSCR0_DataSize(slot_width - 16); in pxa_ssp_set_dai_tdm_slot()
357 struct ssp_device *ssp = priv->ssp; in pxa_ssp_set_dai_tristate()
381 return -EINVAL; in pxa_ssp_set_dai_fmt()
391 return -EINVAL; in pxa_ssp_set_dai_fmt()
401 return -EINVAL; in pxa_ssp_set_dai_fmt()
405 priv->dai_fmt = fmt; in pxa_ssp_set_dai_fmt()
417 struct ssp_device *ssp = priv->ssp; in pxa_ssp_configure_dai_fmt()
421 if (priv->configured_dai_fmt == priv->dai_fmt) in pxa_ssp_configure_dai_fmt()
435 switch (priv->dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in pxa_ssp_configure_dai_fmt()
445 return -EINVAL; in pxa_ssp_configure_dai_fmt()
448 switch (priv->dai_fmt & SND_SOC_DAIFMT_INV_MASK) { in pxa_ssp_configure_dai_fmt()
461 return -EINVAL; in pxa_ssp_configure_dai_fmt()
464 switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in pxa_ssp_configure_dai_fmt()
480 return -EINVAL; in pxa_ssp_configure_dai_fmt()
487 switch (priv->dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in pxa_ssp_configure_dai_fmt()
504 priv->configured_dai_fmt = priv->dai_fmt; in pxa_ssp_configure_dai_fmt()
536 struct ssp_device *ssp = priv->ssp; in pxa_ssp_hw_params()
537 int chn = params_channels(params); in pxa_ssp_hw_params() local
543 int bclk = rate * chn * (width / 8); in pxa_ssp_hw_params()
549 * to force 16-bit frame width on the wire (for S16_LE), even in pxa_ssp_hw_params()
550 * with two channels. Use 16-bit DMA transfers for this case. in pxa_ssp_hw_params()
553 ((chn == 2) && (ttsa != 1)) || (width == 32), in pxa_ssp_hw_params()
554 substream->stream == SNDRV_PCM_STREAM_PLAYBACK, dma_data); in pxa_ssp_hw_params()
570 if (ssp->type == PXA3xx_SSP) in pxa_ssp_hw_params()
596 for (m = pxa_ssp_clock_modes; m->rate; m++) { in pxa_ssp_hw_params()
597 if (m->rate == rate) in pxa_ssp_hw_params()
601 if (!m->rate) in pxa_ssp_hw_params()
602 return -EINVAL; in pxa_ssp_hw_params()
610 ssacd |= SSACD_ACDS(m->acds); in pxa_ssp_hw_params()
611 ssacd |= m->scdb; in pxa_ssp_hw_params()
623 switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in pxa_ssp_hw_params()
627 if (((priv->sysclk / bclk) == 64) && (width == 16)) { in pxa_ssp_hw_params()
636 if (ssp->type != PXA3xx_SSP) in pxa_ssp_hw_params()
637 return -EINVAL; in pxa_ssp_hw_params()
663 * - complain loudly and fail if they've not been set up yet. in pxa_ssp_hw_params()
666 dev_err(ssp->dev, "No TDM timeslot configured\n"); in pxa_ssp_hw_params()
667 return -EINVAL; in pxa_ssp_hw_params()
686 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in pxa_ssp_set_running_bit()
712 struct ssp_device *ssp = priv->ssp; in pxa_ssp_trigger()
738 ret = -EINVAL; in pxa_ssp_trigger()
748 struct device *dev = dai->dev; in pxa_ssp_probe()
754 return -ENOMEM; in pxa_ssp_probe()
756 if (dev->of_node) { in pxa_ssp_probe()
759 ssp_handle = of_parse_phandle(dev->of_node, "port", 0); in pxa_ssp_probe()
762 ret = -ENODEV; in pxa_ssp_probe()
766 priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio"); in pxa_ssp_probe()
767 if (priv->ssp == NULL) { in pxa_ssp_probe()
768 ret = -ENODEV; in pxa_ssp_probe()
772 priv->extclk = devm_clk_get(dev, "extclk"); in pxa_ssp_probe()
773 if (IS_ERR(priv->extclk)) { in pxa_ssp_probe()
774 ret = PTR_ERR(priv->extclk); in pxa_ssp_probe()
775 if (ret == -EPROBE_DEFER) in pxa_ssp_probe()
778 priv->extclk = NULL; in pxa_ssp_probe()
781 priv->ssp = pxa_ssp_request(dai->id + 1, "SoC audio"); in pxa_ssp_probe()
782 if (priv->ssp == NULL) { in pxa_ssp_probe()
783 ret = -ENODEV; in pxa_ssp_probe()
788 priv->dai_fmt = (unsigned int) -1; in pxa_ssp_probe()
802 pxa_ssp_free(priv->ssp); in pxa_ssp_remove()
845 .name = "pxa-ssp",
860 { .compatible = "mrvl,pxa-ssp-dai" },
868 return devm_snd_soc_register_component(&pdev->dev, &pxa_ssp_component, in asoc_ssp_probe()
874 .name = "pxa-ssp-dai",
887 MODULE_ALIAS("platform:pxa-ssp-dai");