Commit cdf4b670 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Samuel Ortiz

mfd: twl4030-audio: Rearange and clean-up the probe function

To facilitate the device tree support the probe function need to be rearanged.
Small cleanup in the APLL frequency selection part as well.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 39c1421d
...@@ -169,35 +169,30 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev) ...@@ -169,35 +169,30 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio),
GFP_KERNEL);
if (!audio)
return -ENOMEM;
mutex_init(&audio->mutex);
audio->audio_mclk = pdata->audio_mclk;
/* Configure APLL_INFREQ and disable APLL if enabled */ /* Configure APLL_INFREQ and disable APLL if enabled */
val = 0; switch (audio->audio_mclk) {
switch (pdata->audio_mclk) {
case 19200000: case 19200000:
val |= TWL4030_APLL_INFREQ_19200KHZ; val = TWL4030_APLL_INFREQ_19200KHZ;
break; break;
case 26000000: case 26000000:
val |= TWL4030_APLL_INFREQ_26000KHZ; val = TWL4030_APLL_INFREQ_26000KHZ;
break; break;
case 38400000: case 38400000:
val |= TWL4030_APLL_INFREQ_38400KHZ; val = TWL4030_APLL_INFREQ_38400KHZ;
break; break;
default: default:
dev_err(&pdev->dev, "Invalid audio_mclk\n"); dev_err(&pdev->dev, "Invalid audio_mclk\n");
return -EINVAL; return -EINVAL;
} }
twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, val, TWL4030_REG_APLL_CTL);
val, TWL4030_REG_APLL_CTL);
audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio),
GFP_KERNEL);
if (!audio)
return -ENOMEM;
platform_set_drvdata(pdev, audio);
twl4030_audio_dev = pdev;
mutex_init(&audio->mutex);
audio->audio_mclk = pdata->audio_mclk;
/* Codec power */ /* Codec power */
audio->resource[TWL4030_AUDIO_RES_POWER].reg = TWL4030_REG_CODEC_MODE; audio->resource[TWL4030_AUDIO_RES_POWER].reg = TWL4030_REG_CODEC_MODE;
...@@ -222,6 +217,9 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev) ...@@ -222,6 +217,9 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev)
childs++; childs++;
} }
platform_set_drvdata(pdev, audio);
twl4030_audio_dev = pdev;
if (childs) if (childs)
ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells, ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells,
childs, NULL, 0, NULL); childs, NULL, 0, NULL);
......
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