* [PATCH 2/3] ASoC: DaVinci: Added selection of clk input pin for McBSP
[not found] <1277905678-4695-1-git-send-email-lamiaposta71@gmail.com>
@ 2010-06-30 13:47 ` Raffaele Recalcati
2010-07-01 14:36 ` Mark Brown
2010-06-30 13:47 ` [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S) Raffaele Recalcati
1 sibling, 1 reply; 5+ messages in thread
From: Raffaele Recalcati @ 2010-06-30 13:47 UTC (permalink / raw)
To: linux-arm-kernel
From: Raffaele Recalcati <raffaele.recalcati@bticino.it>
When McBSP peripheral gets the clock from an external pin,
there are three possible chooses, MCBSP_CLKX, MCBSP_CLKR
and MCBSP_CLKS.
evm-dm365 uses MCBSP_CLKR, instead in bmx board I have a different
hardware connection and I use MCBSP_CLKS, so I have added
this possibility.
This patch has been developed against the:
http://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git
git tree and has been tested on bmx board (similar to dm365 evm)
Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it>
Signed-off-by: Davide Bonfanti <davide.bonfanti@bticino.it>
---
arch/arm/mach-davinci/include/mach/asp.h | 8 ++++++++
sound/soc/davinci/davinci-i2s.c | 28 +++++++++++++++++++++++-----
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h
index 834725f..314570d 100644
--- a/arch/arm/mach-davinci/include/mach/asp.h
+++ b/arch/arm/mach-davinci/include/mach/asp.h
@@ -63,6 +63,9 @@ struct snd_platform_data {
unsigned sram_size_playback;
unsigned sram_size_capture;
+ /* To be used when cpu gets clock from external pin */
+ int clk_input_pin;
+
/* McASP specific fields */
int tdm_slots;
u8 op_mode;
@@ -78,6 +81,11 @@ enum {
MCASP_VERSION_2, /* DA8xx/OMAPL1x */
};
+enum {
+ MCBSP_CLKR = 0, /* DM365 */
+ MCBSP_CLKS,
+};
+
#define INACTIVE_MODE 0
#define TX_MODE 1
#define RX_MODE 2
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 319e8ca..e478be9 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -152,6 +152,7 @@ struct davinci_mcbsp_dev {
unsigned int fmt;
int clk_div;
+ int clk_input_pin;
};
static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev,
@@ -278,11 +279,26 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
DAVINCI_MCBSP_PCR_CLKRM;
break;
case SND_SOC_DAIFMT_CBM_CFS:
- /* McBSP CLKR pin is the input for the Sample Rate Generator.
- * McBSP FSR and FSX are driven by the Sample Rate Generator. */
- pcr = DAVINCI_MCBSP_PCR_SCLKME |
- DAVINCI_MCBSP_PCR_FSXM |
- DAVINCI_MCBSP_PCR_FSRM;
+ pcr = DAVINCI_MCBSP_PCR_FSRM | DAVINCI_MCBSP_PCR_FSXM;
+ /*
+ * Selection of the clock input pin that is the
+ * input for the Sample Rate Generator.
+ * McBSP FSR and FSX are driven by the Sample Rate
+ * Generator.
+ */
+ switch (dev->clk_input_pin) {
+ case MCBSP_CLKS:
+ pcr |= DAVINCI_MCBSP_PCR_CLKXM |
+ DAVINCI_MCBSP_PCR_CLKRM;
+ break;
+ case MCBSP_CLKR:
+ pcr |= DAVINCI_MCBSP_PCR_SCLKME;
+ break;
+ default:
+ printk(KERN_ERR "%s:bad clk_input_pin\n", __func__);
+ return -EINVAL;
+ }
+
break;
case SND_SOC_DAIFMT_CBM_CFM:
/* codec is master */
@@ -436,6 +452,7 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
srgr |= clk_div;
break;
case SND_SOC_DAIFMT_CBM_CFS:
+ /* Clock given on CLKS */
srgr = DAVINCI_MCBSP_SRGR_FSGM;
clk_div = dev->clk_div - 1;
srgr |= DAVINCI_MCBSP_SRGR_FWID(mcbsp_word_length * 8 - 1);
@@ -626,6 +643,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
pdata->sram_size_playback;
dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size =
pdata->sram_size_capture;
+ dev->clk_input_pin = pdata->clk_input_pin;
}
dev->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(dev->clk)) {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S)
[not found] <1277905678-4695-1-git-send-email-lamiaposta71@gmail.com>
2010-06-30 13:47 ` [PATCH 2/3] ASoC: DaVinci: Added selection of clk input pin for McBSP Raffaele Recalcati
@ 2010-06-30 13:47 ` Raffaele Recalcati
2010-07-01 15:01 ` Mark Brown
2010-07-01 15:03 ` Mark Brown
1 sibling, 2 replies; 5+ messages in thread
From: Raffaele Recalcati @ 2010-06-30 13:47 UTC (permalink / raw)
To: linux-arm-kernel
From: Raffaele Recalcati <raffaele.recalcati@bticino.it>
i2s_fast_clock switch can be used to have a better approximate
frequency.
The waveform will be not symmetric.
This patch has been developed against the
http://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git
git tree and has been tested on bmx board (similar to dm365 evm, but using
uda1345 as external audio codec).
Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it>
Signed-off-by: Davide Bonfanti <davide.bonfanti@bticino.it>
---
arch/arm/mach-davinci/include/mach/asp.h | 7 +++++++
sound/soc/davinci/davinci-i2s.c | 24 +++++++++++++++++++-----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h
index 314570d..2d8f8af 100644
--- a/arch/arm/mach-davinci/include/mach/asp.h
+++ b/arch/arm/mach-davinci/include/mach/asp.h
@@ -63,6 +63,13 @@ struct snd_platform_data {
unsigned sram_size_playback;
unsigned sram_size_capture;
+ /*
+ * This define works when both clock and FS are output for the cpu
+ * and makes clock very fast (FS is not symmetrical, but sampling
+ * frequency is better approximated
+ */
+ bool i2s_fast_clock;
+
/* To be used when cpu gets clock from external pin */
int clk_input_pin;
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index e478be9..0af5bae 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -150,6 +150,7 @@ struct davinci_mcbsp_dev {
*/
unsigned enable_channel_combine:1;
+ bool i2s_fast_clock;
unsigned int fmt;
int clk_div;
int clk_input_pin;
@@ -443,11 +444,23 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
DAVINCI_MCBSP_SRGR_CLKSM;
srgr |= DAVINCI_MCBSP_SRGR_FWID(mcbsp_word_length *
8 - 1);
- /* symmetric waveforms */
- clk_div = freq / (mcbsp_word_length * 16) /
- params->rate_num * params->rate_den;
- srgr |= DAVINCI_MCBSP_SRGR_FPER(mcbsp_word_length *
- 16 - 1);
+ if (dev->i2s_fast_clock) {
+ clk_div = 256;
+ do {
+ framesize = (freq / (--clk_div)) /
+ params->rate_num *
+ params->rate_den;
+ } while (((framesize < 33) || (framesize > 4095)) &&
+ (clk_div));
+ clk_div--;
+ srgr |= DAVINCI_MCBSP_SRGR_FPER(framesize - 1);
+ } else {
+ /* symmetric waveforms */
+ clk_div = freq / (mcbsp_word_length * 16) /
+ params->rate_num * params->rate_den;
+ srgr |= DAVINCI_MCBSP_SRGR_FPER(mcbsp_word_length *
+ 16 - 1);
+ }
clk_div &= 0xFF;
srgr |= clk_div;
break;
@@ -643,6 +656,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
pdata->sram_size_playback;
dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size =
pdata->sram_size_capture;
+ dev->i2s_fast_clock = pdata->i2s_fast_clock;
dev->clk_input_pin = pdata->clk_input_pin;
}
dev->clk = clk_get(&pdev->dev, NULL);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] ASoC: DaVinci: Added selection of clk input pin for McBSP
2010-06-30 13:47 ` [PATCH 2/3] ASoC: DaVinci: Added selection of clk input pin for McBSP Raffaele Recalcati
@ 2010-07-01 14:36 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-07-01 14:36 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jun 30, 2010 at 03:47:57PM +0200, Raffaele Recalcati wrote:
> + /* To be used when cpu gets clock from external pin */
> + int clk_input_pin;
> +
As previously indicated please say how to use this.
> + default:
> + printk(KERN_ERR "%s:bad clk_input_pin\n", __func__);
Use dev_err().
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S)
2010-06-30 13:47 ` [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S) Raffaele Recalcati
@ 2010-07-01 15:01 ` Mark Brown
2010-07-01 15:03 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-07-01 15:01 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jun 30, 2010 at 03:47:58PM +0200, Raffaele Recalcati wrote:
> + /*
> + * This define works when both clock and FS are output for the cpu
> + * and makes clock very fast (FS is not symmetrical, but sampling
> + * frequency is better approximated
> + */
> + bool i2s_fast_clock;
I'm having a hard time following the description here - which clock is
being made very fast? The output clocks, which are the ones people can
observe, will presumably not suddenly start running very fast.
It's probably better to rename this option to reflect the actual
function (trading off between frequency accuracy and mark/space ratio)
rather than the way it's implemented internally.
> - srgr |= DAVINCI_MCBSP_SRGR_FPER(mcbsp_word_length *
> - 16 - 1);
> + if (dev->i2s_fast_clock) {
> + clk_div = 256;
> + do {
> + framesize = (freq / (--clk_div)) /
> + params->rate_num *
> + params->rate_den;
> + } while (((framesize < 33) || (framesize > 4095)) &&
> + (clk_div));
> + clk_div--;
> + srgr |= DAVINCI_MCBSP_SRGR_FPER(framesize - 1);
> + } else {
> + /* symmetric waveforms */
> + clk_div = freq / (mcbsp_word_length * 16) /
> + params->rate_num * params->rate_den;
> + srgr |= DAVINCI_MCBSP_SRGR_FPER(mcbsp_word_length *
> + 16 - 1);
> + }
Hrm. This doesn't really correspond to your commit message at all.
Your commit message makes it sound like you've changed something about
the clocking setup of the device, such as adding another clock source,
but what you've actually done here is change the method used to
calculate the divider.
I'm *guessing* that the actual effect of your change is that you will
normally end up selecting a very much higher bit clock than would
otherwise be the case. It strikes me that there must be a better
algorithm for the calculation - for example, working up from the minimum
clock rate - which will give the same results as we currently have where
the driver is already generating accurate rates.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S)
2010-06-30 13:47 ` [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S) Raffaele Recalcati
2010-07-01 15:01 ` Mark Brown
@ 2010-07-01 15:03 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-07-01 15:03 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jun 30, 2010 at 03:47:58PM +0200, Raffaele Recalcati wrote:
> From: Raffaele Recalcati <raffaele.recalcati@bticino.it>
>
> i2s_fast_clock switch can be used to have a better approximate
Oh, and please look at the CC list for these posts. You're CCing *very*
widely and at least one address (chaithrika at ti.com) actually bounces.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-01 15:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1277905678-4695-1-git-send-email-lamiaposta71@gmail.com>
2010-06-30 13:47 ` [PATCH 2/3] ASoC: DaVinci: Added selection of clk input pin for McBSP Raffaele Recalcati
2010-07-01 14:36 ` Mark Brown
2010-06-30 13:47 ` [PATCH 3/3] ASoC: DaVinci: Added fast clock timing for McBSP (I2S) Raffaele Recalcati
2010-07-01 15:01 ` Mark Brown
2010-07-01 15:03 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).