23 #include <linux/module.h>
27 #include <linux/slab.h>
60 static void mmp_sspa_tx_enable(
struct ssp_device *sspa)
64 sspa_sp = mmp_sspa_read_reg(sspa,
SSPA_TXSP);
67 mmp_sspa_write_reg(sspa,
SSPA_TXSP, sspa_sp);
70 static void mmp_sspa_tx_disable(
struct ssp_device *sspa)
74 sspa_sp = mmp_sspa_read_reg(sspa,
SSPA_TXSP);
77 mmp_sspa_write_reg(sspa,
SSPA_TXSP, sspa_sp);
80 static void mmp_sspa_rx_enable(
struct ssp_device *sspa)
84 sspa_sp = mmp_sspa_read_reg(sspa,
SSPA_RXSP);
87 mmp_sspa_write_reg(sspa,
SSPA_RXSP, sspa_sp);
90 static void mmp_sspa_rx_disable(
struct ssp_device *sspa)
94 sspa_sp = mmp_sspa_read_reg(sspa,
SSPA_RXSP);
97 mmp_sspa_write_reg(sspa,
SSPA_RXSP, sspa_sp);
125 static int mmp_sspa_set_dai_sysclk(
struct snd_soc_dai *cpu_dai,
126 int clk_id,
unsigned int freq,
int dir)
148 static int mmp_sspa_set_dai_pll(
struct snd_soc_dai *cpu_dai,
int pll_id,
149 int source,
unsigned int freq_in,
150 unsigned int freq_out)
152 struct sspa_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
178 static int mmp_sspa_set_dai_fmt(
struct snd_soc_dai *cpu_dai,
183 u32 sspa_sp, sspa_ctrl;
191 (mmp_sspa_read_reg(sspa,
SSPA_RXSP) & SSPA_SP_S_EN)) {
193 "can't change hardware dai format: stream is in use\n");
229 mmp_sspa_write_reg(sspa,
SSPA_TXSP, sspa_sp);
230 mmp_sspa_write_reg(sspa,
SSPA_RXSP, sspa_sp);
233 mmp_sspa_write_reg(sspa,
SSPA_TXSP, sspa_sp);
234 mmp_sspa_write_reg(sspa,
SSPA_RXSP, sspa_sp);
244 mmp_sspa_write_reg(sspa,
SSPA_TXSP, sspa_sp);
246 mmp_sspa_write_reg(sspa,
SSPA_TXCTL, sspa_ctrl);
247 mmp_sspa_write_reg(sspa,
SSPA_RXCTL, sspa_ctrl);
267 struct sspa_priv *sspa_priv = snd_soc_dai_get_drvdata(dai);
273 sspa_ctrl = mmp_sspa_read_reg(sspa,
SSPA_TXCTL);
275 sspa_ctrl = mmp_sspa_read_reg(sspa,
SSPA_RXCTL);
304 mmp_sspa_write_reg(sspa,
SSPA_TXCTL, sspa_ctrl);
307 mmp_sspa_write_reg(sspa,
SSPA_RXCTL, sspa_ctrl);
315 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_params);
322 struct sspa_priv *sspa_priv = snd_soc_dai_get_drvdata(dai);
337 mmp_sspa_rx_enable(sspa);
340 mmp_sspa_tx_enable(sspa);
351 mmp_sspa_tx_disable(sspa);
355 mmp_sspa_rx_disable(sspa);
369 snd_soc_dai_set_drvdata(dai, priv);
374 #define MMP_SSPA_RATES SNDRV_PCM_RATE_8000_192000
375 #define MMP_SSPA_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
376 SNDRV_PCM_FMTBIT_S16_LE | \
377 SNDRV_PCM_FMTBIT_S24_LE | \
378 SNDRV_PCM_FMTBIT_S24_LE | \
379 SNDRV_PCM_FMTBIT_S32_LE)
382 .startup = mmp_sspa_startup,
383 .shutdown = mmp_sspa_shutdown,
384 .trigger = mmp_sspa_trigger,
385 .hw_params = mmp_sspa_hw_params,
386 .set_sysclk = mmp_sspa_set_dai_sysclk,
387 .set_pll = mmp_sspa_set_dai_pll,
388 .set_fmt = mmp_sspa_set_dai_fmt,
392 .probe = mmp_sspa_probe,
405 .ops = &mmp_sspa_dai_ops,
410 struct sspa_priv *
priv;
437 if (IS_ERR(priv->
sspa->clk))
438 return PTR_ERR(priv->
sspa->clk);
445 if (IS_ERR(priv->
sysclk)) {
447 return PTR_ERR(priv->
sysclk);
451 platform_set_drvdata(pdev, priv);
458 struct sspa_priv *priv = platform_get_drvdata(pdev);
469 .name =
"mmp-sspa-dai",
472 .probe = asoc_mmp_sspa_probe,