Commit f9b4639e authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

MFD: twl4030-codec: APLL_INFREQ handling in the MFD driver

Configure the APLL_INFREQ field in the APLL_CTL register
based on the platform data.
Provide also a function for childs to query the audio_mclk
frequency.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 953e2f3d
...@@ -41,6 +41,7 @@ struct twl4030_codec_resource { ...@@ -41,6 +41,7 @@ struct twl4030_codec_resource {
}; };
struct twl4030_codec { struct twl4030_codec {
unsigned int audio_mclk;
struct mutex mutex; struct mutex mutex;
struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX]; struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX];
struct mfd_cell cells[TWL4030_CODEC_CELLS]; struct mfd_cell cells[TWL4030_CODEC_CELLS];
...@@ -145,12 +146,45 @@ int twl4030_codec_disable_resource(unsigned id) ...@@ -145,12 +146,45 @@ int twl4030_codec_disable_resource(unsigned id)
} }
EXPORT_SYMBOL_GPL(twl4030_codec_disable_resource); 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) static int __devinit twl4030_codec_probe(struct platform_device *pdev)
{ {
struct twl4030_codec *codec; struct twl4030_codec *codec;
struct twl4030_codec_data *pdata = pdev->dev.platform_data; struct twl4030_codec_data *pdata = pdev->dev.platform_data;
struct mfd_cell *cell = NULL; struct mfd_cell *cell = NULL;
int ret, childs = 0; int ret, childs = 0;
u8 val;
if (!pdata) {
dev_err(&pdev->dev, "Platform data is missing\n");
return -EINVAL;
}
/* Configure APLL_INFREQ and disable APLL if enabled */
val = 0;
switch (pdata->audio_mclk) {
case 19200000:
val |= TWL4030_APLL_INFREQ_19200KHZ;
break;
case 26000000:
val |= TWL4030_APLL_INFREQ_26000KHZ;
break;
case 38400000:
val |= TWL4030_APLL_INFREQ_38400KHZ;
break;
default:
dev_err(&pdev->dev, "Invalid audio_mclk\n");
return -EINVAL;
}
twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
val, TWL4030_REG_APLL_CTL);
codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL); codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL);
if (!codec) if (!codec)
...@@ -160,6 +194,7 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev) ...@@ -160,6 +194,7 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev)
twl4030_codec_dev = pdev; twl4030_codec_dev = pdev;
mutex_init(&codec->mutex); mutex_init(&codec->mutex);
codec->audio_mclk = pdata->audio_mclk;
/* Codec power */ /* Codec power */
codec->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE; codec->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE;
......
...@@ -267,5 +267,6 @@ enum twl4030_codec_res { ...@@ -267,5 +267,6 @@ enum twl4030_codec_res {
int twl4030_codec_disable_resource(enum twl4030_codec_res id); int twl4030_codec_disable_resource(enum twl4030_codec_res id);
int twl4030_codec_enable_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__ */ #endif /* End of __TWL4030_CODEC_H__ */
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