diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2009-11-04 02:58:19 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-11-10 07:07:23 -0500 |
commit | f9b4639e045c750e2bad37462476403995508350 (patch) | |
tree | ad64a6e75caf3733e65e436281abc3824fca62b2 /drivers/mfd/twl4030-codec.c | |
parent | 953e2f3d272db9db6671ad4f4244820557a71cf7 (diff) |
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: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/mfd/twl4030-codec.c')
-rw-r--r-- | drivers/mfd/twl4030-codec.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/mfd/twl4030-codec.c b/drivers/mfd/twl4030-codec.c index 97103078dc2a..77b914907d7c 100644 --- a/drivers/mfd/twl4030-codec.c +++ b/drivers/mfd/twl4030-codec.c | |||
@@ -41,6 +41,7 @@ struct twl4030_codec_resource { | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | struct twl4030_codec { | 43 | struct twl4030_codec { |
44 | unsigned int audio_mclk; | ||
44 | struct mutex mutex; | 45 | struct mutex mutex; |
45 | struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX]; | 46 | struct twl4030_codec_resource resource[TWL4030_CODEC_RES_MAX]; |
46 | struct mfd_cell cells[TWL4030_CODEC_CELLS]; | 47 | struct mfd_cell cells[TWL4030_CODEC_CELLS]; |
@@ -145,12 +146,45 @@ int twl4030_codec_disable_resource(unsigned id) | |||
145 | } | 146 | } |
146 | EXPORT_SYMBOL_GPL(twl4030_codec_disable_resource); | 147 | EXPORT_SYMBOL_GPL(twl4030_codec_disable_resource); |
147 | 148 | ||
149 | unsigned int twl4030_codec_get_mclk(void) | ||
150 | { | ||
151 | struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev); | ||
152 | |||
153 | return codec->audio_mclk; | ||
154 | } | ||
155 | EXPORT_SYMBOL_GPL(twl4030_codec_get_mclk); | ||
156 | |||
148 | static int __devinit twl4030_codec_probe(struct platform_device *pdev) | 157 | static int __devinit twl4030_codec_probe(struct platform_device *pdev) |
149 | { | 158 | { |
150 | struct twl4030_codec *codec; | 159 | struct twl4030_codec *codec; |
151 | struct twl4030_codec_data *pdata = pdev->dev.platform_data; | 160 | struct twl4030_codec_data *pdata = pdev->dev.platform_data; |
152 | struct mfd_cell *cell = NULL; | 161 | struct mfd_cell *cell = NULL; |
153 | int ret, childs = 0; | 162 | int ret, childs = 0; |
163 | u8 val; | ||
164 | |||
165 | if (!pdata) { | ||
166 | dev_err(&pdev->dev, "Platform data is missing\n"); | ||
167 | return -EINVAL; | ||
168 | } | ||
169 | |||
170 | /* Configure APLL_INFREQ and disable APLL if enabled */ | ||
171 | val = 0; | ||
172 | switch (pdata->audio_mclk) { | ||
173 | case 19200000: | ||
174 | val |= TWL4030_APLL_INFREQ_19200KHZ; | ||
175 | break; | ||
176 | case 26000000: | ||
177 | val |= TWL4030_APLL_INFREQ_26000KHZ; | ||
178 | break; | ||
179 | case 38400000: | ||
180 | val |= TWL4030_APLL_INFREQ_38400KHZ; | ||
181 | break; | ||
182 | default: | ||
183 | dev_err(&pdev->dev, "Invalid audio_mclk\n"); | ||
184 | return -EINVAL; | ||
185 | } | ||
186 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | ||
187 | val, TWL4030_REG_APLL_CTL); | ||
154 | 188 | ||
155 | codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL); | 189 | codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL); |
156 | if (!codec) | 190 | if (!codec) |
@@ -160,6 +194,7 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev) | |||
160 | 194 | ||
161 | twl4030_codec_dev = pdev; | 195 | twl4030_codec_dev = pdev; |
162 | mutex_init(&codec->mutex); | 196 | mutex_init(&codec->mutex); |
197 | codec->audio_mclk = pdata->audio_mclk; | ||
163 | 198 | ||
164 | /* Codec power */ | 199 | /* Codec power */ |
165 | codec->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE; | 200 | codec->resource[TWL4030_CODEC_RES_POWER].reg = TWL4030_REG_CODEC_MODE; |