Commit 33392680 authored by Cliff Cai's avatar Cliff Cai Committed by Takashi Iwai

ALSA: ASoC Blackfin: add I2S DAI support for AD73311

Signed-off-by: default avatarCliff Cai <cliff.cai@analog.com>
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 0e77e784
...@@ -70,6 +70,13 @@ static struct sport_param sport_params[2] = { ...@@ -70,6 +70,13 @@ static struct sport_param sport_params[2] = {
} }
}; };
static u16 sport_req[][7] = {
{ P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0},
{ P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0},
};
static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
unsigned int fmt) unsigned int fmt)
{ {
...@@ -78,6 +85,14 @@ static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, ...@@ -78,6 +85,14 @@ static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
/* interface format:support I2S,slave mode */ /* interface format:support I2S,slave mode */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
bf5xx_i2s.tcr1 |= TFSR | TCKFE;
bf5xx_i2s.rcr1 |= RFSR | RCKFE;
bf5xx_i2s.tcr2 |= TSFSE;
bf5xx_i2s.rcr2 |= RSFSE;
break;
case SND_SOC_DAIFMT_DSP_A:
bf5xx_i2s.tcr1 |= TFSR;
bf5xx_i2s.rcr1 |= RFSR;
break; break;
case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_LEFT_J:
ret = -EINVAL; ret = -EINVAL;
...@@ -127,14 +142,17 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -127,14 +142,17 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream,
case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_S16_LE:
bf5xx_i2s.tcr2 |= 15; bf5xx_i2s.tcr2 |= 15;
bf5xx_i2s.rcr2 |= 15; bf5xx_i2s.rcr2 |= 15;
sport_handle->wdsize = 2;
break; break;
case SNDRV_PCM_FORMAT_S24_LE: case SNDRV_PCM_FORMAT_S24_LE:
bf5xx_i2s.tcr2 |= 23; bf5xx_i2s.tcr2 |= 23;
bf5xx_i2s.rcr2 |= 23; bf5xx_i2s.rcr2 |= 23;
sport_handle->wdsize = 3;
break; break;
case SNDRV_PCM_FORMAT_S32_LE: case SNDRV_PCM_FORMAT_S32_LE:
bf5xx_i2s.tcr2 |= 31; bf5xx_i2s.tcr2 |= 31;
bf5xx_i2s.rcr2 |= 31; bf5xx_i2s.rcr2 |= 31;
sport_handle->wdsize = 4;
break; break;
} }
...@@ -145,17 +163,17 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -145,17 +163,17 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream,
* need to configure both of them at the time when the first * need to configure both of them at the time when the first
* stream is opened. * stream is opened.
* *
* CPU DAI format:I2S, slave mode. * CPU DAI:slave mode.
*/ */
ret = sport_config_rx(sport_handle, RFSR | RCKFE, ret = sport_config_rx(sport_handle, bf5xx_i2s.rcr1,
RSFSE|bf5xx_i2s.rcr2, 0, 0); bf5xx_i2s.rcr2, 0, 0);
if (ret) { if (ret) {
pr_err("SPORT is busy!\n"); pr_err("SPORT is busy!\n");
return -EBUSY; return -EBUSY;
} }
ret = sport_config_tx(sport_handle, TFSR | TCKFE, ret = sport_config_tx(sport_handle, bf5xx_i2s.tcr1,
TSFSE|bf5xx_i2s.tcr2, 0, 0); bf5xx_i2s.tcr2, 0, 0);
if (ret) { if (ret) {
pr_err("SPORT is busy!\n"); pr_err("SPORT is busy!\n");
return -EBUSY; return -EBUSY;
...@@ -174,13 +192,6 @@ static void bf5xx_i2s_shutdown(struct snd_pcm_substream *substream) ...@@ -174,13 +192,6 @@ static void bf5xx_i2s_shutdown(struct snd_pcm_substream *substream)
static int bf5xx_i2s_probe(struct platform_device *pdev, static int bf5xx_i2s_probe(struct platform_device *pdev,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
u16 sport_req[][7] = {
{ P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0},
{ P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0},
};
pr_debug("%s enter\n", __func__); pr_debug("%s enter\n", __func__);
if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) {
pr_err("Requesting Peripherals failed\n"); pr_err("Requesting Peripherals failed\n");
...@@ -198,6 +209,13 @@ static int bf5xx_i2s_probe(struct platform_device *pdev, ...@@ -198,6 +209,13 @@ static int bf5xx_i2s_probe(struct platform_device *pdev,
return 0; return 0;
} }
static void bf5xx_i2s_remove(struct platform_device *pdev,
struct snd_soc_dai *dai)
{
pr_debug("%s enter\n", __func__);
peripheral_free_list(&sport_req[sport_num][0]);
}
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int bf5xx_i2s_suspend(struct platform_device *dev, static int bf5xx_i2s_suspend(struct platform_device *dev,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
...@@ -263,15 +281,16 @@ struct snd_soc_dai bf5xx_i2s_dai = { ...@@ -263,15 +281,16 @@ struct snd_soc_dai bf5xx_i2s_dai = {
.id = 0, .id = 0,
.type = SND_SOC_DAI_I2S, .type = SND_SOC_DAI_I2S,
.probe = bf5xx_i2s_probe, .probe = bf5xx_i2s_probe,
.remove = bf5xx_i2s_remove,
.suspend = bf5xx_i2s_suspend, .suspend = bf5xx_i2s_suspend,
.resume = bf5xx_i2s_resume, .resume = bf5xx_i2s_resume,
.playback = { .playback = {
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = BF5XX_I2S_RATES, .rates = BF5XX_I2S_RATES,
.formats = BF5XX_I2S_FORMATS,}, .formats = BF5XX_I2S_FORMATS,},
.capture = { .capture = {
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = BF5XX_I2S_RATES, .rates = BF5XX_I2S_RATES,
.formats = BF5XX_I2S_FORMATS,}, .formats = BF5XX_I2S_FORMATS,},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment