Re: [PATCH 3/5] MFD: twl4030-codec: APLL_INFREQ handling in the MFD driver

2009-11-03 Thread Peter Ujfalusi
On Monday 02 November 2009 19:30:35 ext Mark Brown wrote:
 On Mon, Nov 02, 2009 at 02:34:53PM +0200, Peter Ujfalusi wrote:
  Move the APLL_CTL register configuration to the twl4030-codec
  MFD driver.
  Provide also a function for childs to query the audio_mclk
  frequency.
 
 This all looks good to me, some nitpicks below.
 
  +unsigned int twl4030_codec_get_mclk(void)
  +{
  +   struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev);
  +
  +   return codec-audio_mclk;
  +}
  +EXPORT_SYMBOL_GPL(twl4030_codec_get_mclk);
 
 As I said in my followup to patch 5 this feels like it should have a
 parameter to specify the twl4030 though in practical systems it won't
 matter.

I agree that this does not look quite nice, but as you already mentioned, it is 
highly unlikely that one system would have more than one twl series of PM chip 
on board. Another reason is that we have other part of the twl, which needs 
resources from the codec part, but it is not loaded through the codec MFD, so 
providing the needed information is kind of tricky with that setup.

 
  +   if (!(pdata-audio_mclk == 1920 ||
  + pdata-audio_mclk == 2600 ||
  + pdata-audio_mclk == 3840)) {
  +   dev_err(pdev-dev, Invalid audio_mclk\n);
  +   return -EINVAL;
  +   }
 
 Might flow more naturally with a switch statement?

Yes, true. This looks weird, I'll change it.

 

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] MFD: twl4030-codec: APLL_INFREQ handling in the MFD driver

2009-11-03 Thread Mark Brown
 on board. Another reason is that we have other part of the twl, which needs 
 resources from the codec part, but it is not loaded through the codec MFD, so 
 providing the needed information is kind of tricky with that setup.

I had thought that the sub-device was supposed to handle the arbitration
and could be used here.  But like we said, it's not going to make any
difference in the grand scheme of things.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] MFD: twl4030-codec: APLL_INFREQ handling in the MFD driver

2009-11-03 Thread Peter Ujfalusi
On Tuesday 03 November 2009 15:44:38 ext Mark Brown wrote:
  on board. Another reason is that we have other part of the twl, which
  needs resources from the codec part, but it is not loaded through the
  codec MFD, so providing the needed information is kind of tricky with
  that setup.
 
 I had thought that the sub-device was supposed to handle the arbitration
 and could be used here.

That would have been ideal. As such the audio and the Vibra interface is the 
only one directly inside of the codec part of twl, but there is a need for 
other 
modules to actually control resources within the codec part in order to 
operate, 
but they are not actually sub-devices of the codec MFD.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] MFD: twl4030-codec: APLL_INFREQ handling in the MFD driver

2009-11-02 Thread Peter Ujfalusi
Move the APLL_CTL register configuration to the twl4030-codec
MFD driver.
Provide also a function for childs to query the audio_mclk
frequency.

Signed-off-by: Peter Ujfalusi peter.ujfal...@nokia.com
---
 drivers/mfd/twl4030-codec.c   |   40 +
 include/linux/mfd/twl4030-codec.h |1 +
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl4030-codec.c b/drivers/mfd/twl4030-codec.c
index 9710307..6e77f57 100644
--- a/drivers/mfd/twl4030-codec.c
+++ b/drivers/mfd/twl4030-codec.c
@@ -41,6 +41,7 @@ struct twl4030_codec_resource {
 };
 
 struct twl4030_codec {
+   unsigned int audio_mclk;
struct mutex mutex;
struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX];
struct mfd_cell cells[TWL4030_CODEC_CELLS];
@@ -145,12 +146,32 @@ int twl4030_codec_disable_resource(unsigned id)
 }
 EXPORT_SYMBOL_GPL(twl4030_codec_disable_resource);
 
+unsigned int twl4030_codec_get_mclk(void)
+{
+   struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev);
+
+   return codec-audio_mclk;
+}
+EXPORT_SYMBOL_GPL(twl4030_codec_get_mclk);
+
 static int __devinit twl4030_codec_probe(struct platform_device *pdev)
 {
struct twl4030_codec *codec;
struct twl4030_codec_data *pdata = pdev-dev.platform_data;
struct mfd_cell *cell = NULL;
int ret, childs = 0;
+   u8 val;
+
+   if (!pdata) {
+   dev_err(pdev-dev, Platform data is missing\n);
+   return -EINVAL;
+   }
+   if (!(pdata-audio_mclk == 1920 ||
+ pdata-audio_mclk == 2600 ||
+ pdata-audio_mclk == 3840)) {
+   dev_err(pdev-dev, Invalid audio_mclk\n);
+   return -EINVAL;
+   }
 
codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL);
if (!codec)
@@ -160,6 +181,25 @@ static int __devinit twl4030_codec_probe(struct 
platform_device *pdev)
 
twl4030_codec_dev = pdev;
mutex_init(codec-mutex);
+   codec-audio_mclk = pdata-audio_mclk;
+
+   /* Configure APLL_INFREQ */
+   twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, val,
+   TWL4030_REG_APLL_CTL);
+   val = ~TWL4030_APLL_INFREQ;
+   switch (codec-audio_mclk) {
+   case 1920:
+   val |= TWL4030_APLL_INFREQ_19200KHZ;
+   break;
+   case 2600:
+   val |= TWL4030_APLL_INFREQ_26000KHZ;
+   break;
+   case 3840:
+   val |= TWL4030_APLL_INFREQ_38400KHZ;
+   break;
+   }
+   twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
+   val, TWL4030_REG_APLL_CTL);
 
/* Codec power */
codec-resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE;
diff --git a/include/linux/mfd/twl4030-codec.h 
b/include/linux/mfd/twl4030-codec.h
index ef0a304..2ec317c 100644
--- a/include/linux/mfd/twl4030-codec.h
+++ b/include/linux/mfd/twl4030-codec.h
@@ -267,5 +267,6 @@ enum twl4030_codec_res {
 
 int twl4030_codec_disable_resource(enum twl4030_codec_res id);
 int twl4030_codec_enable_resource(enum twl4030_codec_res id);
+unsigned int twl4030_codec_get_mclk(void);
 
 #endif /* End of __TWL4030_CODEC_H__ */
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html