diff options
author | Daniel Mack <zonque@gmail.com> | 2012-10-04 09:08:39 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-10-14 22:24:47 -0400 |
commit | 4ed8c9b737b61030d7b6ac71294d698de85b5b7e (patch) | |
tree | 6c2d6eef82ed9c4130a4a4560237d254aef3ad3a /sound/soc/davinci | |
parent | 393a53cbcfab404d516544cd30650c7b104cd3d4 (diff) |
ASoC: McASP: add support for clock dividers
Add support for the internal clock dividers of the McASP driver.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 714e51e5be5b..9b1920e25564 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -199,6 +199,7 @@ | |||
199 | #define ACLKXE BIT(5) | 199 | #define ACLKXE BIT(5) |
200 | #define TX_ASYNC BIT(6) | 200 | #define TX_ASYNC BIT(6) |
201 | #define ACLKXPOL BIT(7) | 201 | #define ACLKXPOL BIT(7) |
202 | #define ACLKXDIV_MASK 0x1f | ||
202 | 203 | ||
203 | /* | 204 | /* |
204 | * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits | 205 | * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits |
@@ -207,6 +208,7 @@ | |||
207 | #define ACLKRE BIT(5) | 208 | #define ACLKRE BIT(5) |
208 | #define RX_ASYNC BIT(6) | 209 | #define RX_ASYNC BIT(6) |
209 | #define ACLKRPOL BIT(7) | 210 | #define ACLKRPOL BIT(7) |
211 | #define ACLKRDIV_MASK 0x1f | ||
210 | 212 | ||
211 | /* | 213 | /* |
212 | * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control | 214 | * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control |
@@ -215,6 +217,7 @@ | |||
215 | #define AHCLKXDIV(val) (val) | 217 | #define AHCLKXDIV(val) (val) |
216 | #define AHCLKXPOL BIT(14) | 218 | #define AHCLKXPOL BIT(14) |
217 | #define AHCLKXE BIT(15) | 219 | #define AHCLKXE BIT(15) |
220 | #define AHCLKXDIV_MASK 0xfff | ||
218 | 221 | ||
219 | /* | 222 | /* |
220 | * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control | 223 | * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control |
@@ -223,6 +226,7 @@ | |||
223 | #define AHCLKRDIV(val) (val) | 226 | #define AHCLKRDIV(val) (val) |
224 | #define AHCLKRPOL BIT(14) | 227 | #define AHCLKRPOL BIT(14) |
225 | #define AHCLKRE BIT(15) | 228 | #define AHCLKRE BIT(15) |
229 | #define AHCLKRDIV_MASK 0xfff | ||
226 | 230 | ||
227 | /* | 231 | /* |
228 | * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits | 232 | * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits |
@@ -554,6 +558,32 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
554 | return 0; | 558 | return 0; |
555 | } | 559 | } |
556 | 560 | ||
561 | static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) | ||
562 | { | ||
563 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
564 | |||
565 | switch (div_id) { | ||
566 | case 0: /* MCLK divider */ | ||
567 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, | ||
568 | AHCLKXDIV(div - 1), AHCLKXDIV_MASK); | ||
569 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, | ||
570 | AHCLKRDIV(div - 1), AHCLKRDIV_MASK); | ||
571 | break; | ||
572 | |||
573 | case 1: /* BCLK divider */ | ||
574 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, | ||
575 | ACLKXDIV(div - 1), ACLKXDIV_MASK); | ||
576 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKRCTL_REG, | ||
577 | ACLKRDIV(div - 1), ACLKRDIV_MASK); | ||
578 | break; | ||
579 | |||
580 | default: | ||
581 | return -EINVAL; | ||
582 | } | ||
583 | |||
584 | return 0; | ||
585 | } | ||
586 | |||
557 | static int davinci_config_channel_size(struct davinci_audio_dev *dev, | 587 | static int davinci_config_channel_size(struct davinci_audio_dev *dev, |
558 | int channel_size) | 588 | int channel_size) |
559 | { | 589 | { |
@@ -880,7 +910,7 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = { | |||
880 | .trigger = davinci_mcasp_trigger, | 910 | .trigger = davinci_mcasp_trigger, |
881 | .hw_params = davinci_mcasp_hw_params, | 911 | .hw_params = davinci_mcasp_hw_params, |
882 | .set_fmt = davinci_mcasp_set_dai_fmt, | 912 | .set_fmt = davinci_mcasp_set_dai_fmt, |
883 | 913 | .set_clkdiv = davinci_mcasp_set_clkdiv, | |
884 | }; | 914 | }; |
885 | 915 | ||
886 | #define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ | 916 | #define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ |