S3C64XX I2S: Codec Clock Gating Option
Subsystems (5)
PATCH 3/10 S3C64XX I2S: Codec Clock Gating Option
In SoC-Master mode, CODCLK maybe gated out as MCLK of the CODEC. In SoC-Slave mode, CODCLK needs to be cut-off from PAD inorder to avoid collision with MCLK from CODEC.
Option to gate/block CODCLK is implemented in this patch.
--- arch/arm/plat-s3c/include/plat/regs-s3c2412-iis.h | 2 ++ sound/soc/s3c24xx/s3c64xx-i2s.c | 8 ++++++++ sound/soc/s3c24xx/s3c64xx-i2s.h | 2 ++ 3 files changed, 12 insertions(+), 0 deletions(-)
arch/arm/plat-s3c/include/plat/regs-s3c2412-iis.h +2 -0
@@ -38,6 +38,8 @@#define S3C64XX_IISMOD_BLC_24BIT (2 << 13)#define S3C64XX_IISMOD_BLC_MASK (3 << 13) +#define S3C64XX_IISMOD_CDCLK_EXT (1 << 12) +#define S3C64XX_IISMOD_IMS_PCLK (0 << 10)#define S3C64XX_IISMOD_IMS_SYSMUX (1 << 10)
sound/soc/s3c24xx/s3c64xx-i2s.c +8 -0
@@ -99,6 +99,14 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, iismod |=S3C64XX_IISMOD_IMS_SYSMUX ;break ; +case S3C64XX_CODCLKSRC_INT : + iismod &= ~S3C64XX_IISMOD_CDCLK_EXT ; +break ; + +case S3C64XX_CODCLKSRC_EXT : + iismod |=S3C64XX_IISMOD_CDCLK_EXT ; +break ; +default :return -EINVAL ; }
sound/soc/s3c24xx/s3c64xx-i2s.h +2 -0
@@ -25,6 +25,8 @@ struct clk;#define S3C64XX_CLKSRC_PCLK (0)#define S3C64XX_CLKSRC_MUX (1) +#define S3C64XX_CODCLKSRC_INT (2) +#define S3C64XX_CODCLKSRC_EXT (3)extern struct snd_soc_dai s3c64xx_i2s_dai[];
Signature · 1 line
1.6.2.5
PATCH 3/10 S3C64XX I2S: Codec Clock Gating Option
Quoted 4 lines · Jassi
In SoC-Master mode, CODCLK maybe gated out as MCLK of the CODEC. In SoC-Slave mode, CODCLK needs to be cut-off from PAD inorder to avoid collision with MCLK from CODEC.
Option to gate/block CODCLK is implemented in this patch.
Just to confuse matters the datasheet appears to use both CODCLK and CDCLK to refer to the same signal (as far as I can tell, anyway - there's only a couple of references to CODCLK). The drivers are currently using CDCLK as the name, it'd be better to stick with just one.
In terms of functionality it might be clearer to describe what's going on here as switching the function of CDCLK from being an input to being an output. The actual implementation appears to be done by gating the output of the internal clock signal to the CDCLK pin but in terms of what the user can see externally the clock isn't gated, it's still active but it changed direction.
arch/arm/plat-s3c/include/plat/regs-s3c2412-iis.h line 42
Quoted 2 lines
arch/arm/plat-s3c/include/plat/regs-s3c2412-iis.h +2
-0+#define S3C64XX_IISMOD_CDCLK_EXT (1 << 12) +
The datasheet calls this bit CDLKCON - it'd be better to preserve that naming unless there is a good reason to diverge?
sound/soc/s3c24xx/s3c64xx-i2s.c static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, · line 109
Quoted 12 lines
sound/soc/s3c24xx/s3c64xx-i2s.c +8
-0@@ -99,6 +99,14 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, iismod |=S3C64XX_IISMOD_IMS_SYSMUX ;break ; +case S3C64XX_CODCLKSRC_INT : + iismod &= ~S3C64XX_IISMOD_CDCLK_EXT ; +break ; + +case S3C64XX_CODCLKSRC_EXT : + iismod |=S3C64XX_IISMOD_CDCLK_EXT ; +break ; +
This should really be done using the direction parameter - clk_id should specify that CDCLK should be used and the direction parameter be used to say if it's an input or output.
Ideally this would also be more joined up with the rest of the configuration so the machine driver could just specify the master clock for the IIS block and have all the clock switching (the system controller mux and IMS) updated appropriately. That should make it easier for users to set up the clocking since they don't need to worry about the implementation details of the IIS block.
PATCH 3/10 S3C64XX I2S: Codec Clock Gating Option
Quoted 6 lines · Mark Brown
Quoted 4 lines · Jassi
In SoC-Master mode, CODCLK maybe gated out as MCLK of the CODEC. In SoC-Slave mode, CODCLK needs to be cut-off from PAD inorder to avoid collision with MCLK from CODEC.
Option to gate/block CODCLK is implemented in this patch.
Quoted 6 lines
In terms of functionality it might be clearer to describe what's going on here as switching the function of CDCLK from being an input to being an output. ?The actual implementation appears to be done by gating the output of the internal clock signal to the CDCLK pin but in terms of what the user can see externally the clock isn't gated, it's still active but it changed direction.
The bit IISMOD[12], if cleared, gates the RCLK towards the Xi2sCDCLK. If this bit is set, it simply disconnects the RCLK and Xi2sCDCLK.
If the I2S controller wants to use clock from Xi2sCDCLK via "audio-bus" through the MUX, then we want RCLK to be disconnected and we set this bit 1.
If we provide the MCLK of the CODEC from RCLK of I2S controller, we connect RCLK to Xi2sCDCLK which is usually connected to the MCLK of the CODEC, In this case we gate RCLK by clearing this bit (note that it is a not-gate)
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+#define S3C64XX_IISMOD_CDCLK_EXT ? ? (1 << 12) +The datasheet calls this bit CDLKCON - it'd be better to preserve that naming unless there is a good reason to diverge?
CON is better used for register defines.
This is but one bit: CodecClock is Internal or External. So, yes, minor but some reason for that.
Btw, I have already notified this issue to our technical writers.
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0
-0@@ -99,6 +99,14 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, ? ? ? ? ? ? ? iismod |= S3C64XX_IISMOD_IMS_SYSMUX; ? ? ? ? ? ? ? break;
Quoted 12 lines
Review static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, · line 109
Quoted 8 lines
(quoted diff) +8
-0+ ? ? case S3C64XX_CODCLKSRC_INT: + ? ? ? ? ? ? iismod &= ~S3C64XX_IISMOD_CDCLK_EXT; + ? ? ? ? ? ? break; + + ? ? case S3C64XX_CODCLKSRC_EXT: + ? ? ? ? ? ? iismod |= S3C64XX_IISMOD_CDCLK_EXT; + ? ? ? ? ? ? break; +This should really be done using the direction parameter -
clk_idshould specify that CDCLK should be used and the direction parameter be used to say if it's an input or output.
Again, the patch aims to simply fit in the place. For the current state and design of our driver this change is least intrusive and most simple.
PATCH 3/10 S3C64XX I2S: Codec Clock Gating Option
Quoted 11 lines · jassi brar
On Tue, Sep 15, 2009 at 7:44 PM, Mark Brown
Quoted 6 lines
In terms of functionality it might be clearer to describe what's going on here as switching the function of CDCLK from being an input to being an output. ?The actual implementation appears to be done by gating the output of the internal clock signal to the CDCLK pin but in terms of what the user can see externally the clock isn't gated, it's still active but it changed direction.
The bit IISMOD[12], if cleared, gates the RCLK towards the Xi2sCDCLK. If this bit is set, it simply disconnects the RCLK and Xi2sCDCLK.
This is an implementation detail; it does this gating internally in order to allow the pin to be used as an input. The potential confusion here is that the user visible CDCLK can still have a live signal on it, the thing that's been disconnected is an internal signal which can be used to drive it. If you say it's gated that suggests that the signal is stopped completely.
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
+ ? ? case
S3C64XX_CODCLKSRC_INT:
+ ? ? ? ? ? ? iismod &= ~S3C64XX_IISMOD_CDCLK_EXT;
+ ? ? ? ? ? ? break;+ ? ? case
S3C64XX_CODCLKSRC_EXT:
+ ? ? ? ? ? ? iismod |=S3C64XX_IISMOD_CDCLK_EXT;
+ ? ? ? ? ? ? break;
Quoted 7 lines
Quoted 3 lines
This should really be done using the direction parameter -
clk_idshould specify that CDCLK should be used and the direction parameter be used to say if it's an input or output.Again, the patch aims to simply fit in the place. For the current state and design of our driver this change is least intrusive and most simple.
There's no meaningful extra effort required to do this properly and given that all this patch does is implement an external interface it's better to just get it right rather than spend the effort on fixups (and merge issues).
In general, the wider the impact of your changes the more important it is to get them right.
PATCH 3/10 S3C64XX I2S: Codec Clock Gating Option
Quoted 4 lines · Mark Brown
There's no meaningful extra effort required to do this properly and given that all this patch does is implement an external interface it's better to just get it right rather than spend the effort on fixups (and merge issues).
I added the following patch to implement this, not tested yet.
PATCH 3/10 S3C64XX I2S: Codec Clock Gating Option
Quoted 59 lines · Mark Brown
Quoted 4 lines · Mark Brown
There's no meaningful extra effort required to do this properly and given that all this patch does is implement an external interface it's better to just get it right rather than spend the effort on fixups (and merge issues).
I added the following patch to implement this, not tested yet.
From
8bb014895547eeeb9aa61a654f24e41e15919304Mon Sep 17 00:00:00 2001
From: Mark Brown <[email protected]>
Date: Wed, 16 Sep 2009 19:38:53 +0100
Subject: [PATCH] ASoC: Add S3C64xx IIS CDCLK source selectionCDCLK can either be an output generated by the CPU, intended for use as the CODEC master clock, or an input (probably from the CODEC) providing a master clock for the IIS block.
Signed-off-by Mark Brown <[email protected]>---
?arch/arm/plat-s3c/include/plat/regs-s3c2412-iis.h | ? ?2 ++ ?sound/soc/s3c24xx/s3c64xx-i2s.c ? ? ? ? ? ? ? ? ? | ? 13 +++++++++++++ ?sound/soc/s3c24xx/s3c64xx-i2s.h ? ? ? ? ? ? ? ? ? | ? ?1 +?3 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/plat-s3c/include/plat/regs-s3c2412-iis.h +2
-0@@ -67,6 +67,8 @@ ?#define S3C2412_IISMOD_BCLK_MASK ? ? ? (3 << 1) ?#define S3C2412_IISMOD_8BIT ? ? ? ? ? ?(1 << 0) +#define S3C64XX_IISMOD_CDCLKCON ? ? ? ? ? ? ? ?(1 << 12) + ?#define S3C2412_IISPSR_PSREN ? ? ? ? ? (1 << 15) ?#define S3C2412_IISFIC_TXFLUSH ? ? ? ? (1 << 15)sound/soc/s3c24xx/s3c64xx-i2s.c +13
-0@@ -99,6 +99,19 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, ? ? ? ? ? ? ? ?iismod |= S3C64XX_IISMOD_IMS_SYSMUX; ? ? ? ? ? ? ? ?break; + ? ? ? case S3C64XX_CLKSRC_CDCLK: + ? ? ? ? ? ? ? switch (dir) { + ? ? ? ? ? ? ? case SND_SOC_CLOCK_IN: + ? ? ? ? ? ? ? ? ? ? ? iismod |= S3C64XX_IISMOD_CDCLKCON; + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? case SND_SOC_CLOCK_OUT: + ? ? ? ? ? ? ? ? ? ? ? iismod &= ~S3C64XX_IISMOD_CDCLKCON; + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? default: + ? ? ? ? ? ? ? ? ? ? ? return -EINVAL; + ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? break; +
Quoted 3 lines
? ? ? ?default:
? ? ? ? ? ? ? ?return-EINVAL;
? ? ? ?}
oops, all along i had misunderstood ur suggestion. This seems fine.