diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2009-11-04 02:58:20 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-11-10 07:08:15 -0500 |
commit | 68d019553b8cc4ddac7f861e23efbe48a1367490 (patch) | |
tree | aee381715561969b9058c6a8fa2b965c9731821a /sound/soc | |
parent | 0969afcc449d5d655784c04e938cf4cfc6e89c0e (diff) |
ASoC: TWL4030: Do not modify the APLL_CTL register
APLL_CTL register is configured by the twl4030-codec MFD
driver.
Remove code, which makes changes in the APLL_CTL register,
and replace those with checks against the configured
audio_mclk configuration done in the MFD driver.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 928257b25111..510b8b226f96 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -214,7 +214,8 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
214 | 214 | ||
215 | /* set all audio section registers to reasonable defaults */ | 215 | /* set all audio section registers to reasonable defaults */ |
216 | for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) | 216 | for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) |
217 | twl4030_write(codec, i, cache[i]); | 217 | if (i != TWL4030_REG_APLL_CTL) |
218 | twl4030_write(codec, i, cache[i]); | ||
218 | 219 | ||
219 | } | 220 | } |
220 | 221 | ||
@@ -1753,30 +1754,23 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1753 | { | 1754 | { |
1754 | struct snd_soc_codec *codec = codec_dai->codec; | 1755 | struct snd_soc_codec *codec = codec_dai->codec; |
1755 | struct twl4030_priv *twl4030 = codec->private_data; | 1756 | struct twl4030_priv *twl4030 = codec->private_data; |
1756 | u8 apll_ctrl; | ||
1757 | 1757 | ||
1758 | apll_ctrl = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL); | ||
1759 | apll_ctrl &= ~TWL4030_APLL_INFREQ; | ||
1760 | switch (freq) { | 1758 | switch (freq) { |
1761 | case 19200000: | 1759 | case 19200000: |
1762 | apll_ctrl |= TWL4030_APLL_INFREQ_19200KHZ; | ||
1763 | twl4030->sysclk = 19200; | ||
1764 | break; | ||
1765 | case 26000000: | 1760 | case 26000000: |
1766 | apll_ctrl |= TWL4030_APLL_INFREQ_26000KHZ; | ||
1767 | twl4030->sysclk = 26000; | ||
1768 | break; | ||
1769 | case 38400000: | 1761 | case 38400000: |
1770 | apll_ctrl |= TWL4030_APLL_INFREQ_38400KHZ; | ||
1771 | twl4030->sysclk = 38400; | ||
1772 | break; | 1762 | break; |
1773 | default: | 1763 | default: |
1774 | printk(KERN_ERR "TWL4030 set sysclk: unknown rate %d\n", | 1764 | dev_err(codec->dev, "Unsupported APLL mclk: %u\n", freq); |
1775 | freq); | ||
1776 | return -EINVAL; | 1765 | return -EINVAL; |
1777 | } | 1766 | } |
1778 | 1767 | ||
1779 | twl4030_write(codec, TWL4030_REG_APLL_CTL, apll_ctrl); | 1768 | if ((freq / 1000) != twl4030->sysclk) { |
1769 | dev_err(codec->dev, | ||
1770 | "Mismatch in APLL mclk: %u (configured: %u)\n", | ||
1771 | freq, twl4030->sysclk * 1000); | ||
1772 | return -EINVAL; | ||
1773 | } | ||
1780 | 1774 | ||
1781 | return 0; | 1775 | return 0; |
1782 | } | 1776 | } |
@@ -1874,18 +1868,16 @@ static int twl4030_voice_startup(struct snd_pcm_substream *substream, | |||
1874 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1868 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
1875 | struct snd_soc_device *socdev = rtd->socdev; | 1869 | struct snd_soc_device *socdev = rtd->socdev; |
1876 | struct snd_soc_codec *codec = socdev->card->codec; | 1870 | struct snd_soc_codec *codec = socdev->card->codec; |
1877 | u8 infreq; | 1871 | struct twl4030_priv *twl4030 = codec->private_data; |
1878 | u8 mode; | 1872 | u8 mode; |
1879 | 1873 | ||
1880 | /* If the system master clock is not 26MHz, the voice PCM interface is | 1874 | /* If the system master clock is not 26MHz, the voice PCM interface is |
1881 | * not avilable. | 1875 | * not avilable. |
1882 | */ | 1876 | */ |
1883 | infreq = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL) | 1877 | if (twl4030->sysclk != 26000) { |
1884 | & TWL4030_APLL_INFREQ; | 1878 | dev_err(codec->dev, "The board is configured for %u Hz, while" |
1885 | 1879 | "the Voice interface needs 26MHz APLL mclk\n", | |
1886 | if (infreq != TWL4030_APLL_INFREQ_26000KHZ) { | 1880 | twl4030->sysclk * 1000); |
1887 | printk(KERN_ERR "TWL4030 voice startup: " | ||
1888 | "MCLK is not 26MHz, call set_sysclk() on init\n"); | ||
1889 | return -EINVAL; | 1881 | return -EINVAL; |
1890 | } | 1882 | } |
1891 | 1883 | ||
@@ -1958,22 +1950,19 @@ static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1958 | int clk_id, unsigned int freq, int dir) | 1950 | int clk_id, unsigned int freq, int dir) |
1959 | { | 1951 | { |
1960 | struct snd_soc_codec *codec = codec_dai->codec; | 1952 | struct snd_soc_codec *codec = codec_dai->codec; |
1961 | u8 apll_ctrl; | 1953 | struct twl4030_priv *twl4030 = codec->private_data; |
1962 | 1954 | ||
1963 | apll_ctrl = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL); | 1955 | if (freq != 26000000) { |
1964 | apll_ctrl &= ~TWL4030_APLL_INFREQ; | 1956 | dev_err(codec->dev, "Unsupported APLL mclk: %u, the Voice" |
1965 | switch (freq) { | 1957 | "interface needs 26MHz APLL mclk\n", freq); |
1966 | case 26000000: | 1958 | return -EINVAL; |
1967 | apll_ctrl |= TWL4030_APLL_INFREQ_26000KHZ; | 1959 | } |
1968 | break; | 1960 | if ((freq / 1000) != twl4030->sysclk) { |
1969 | default: | 1961 | dev_err(codec->dev, |
1970 | printk(KERN_ERR "TWL4030 voice set sysclk: unknown rate %d\n", | 1962 | "Mismatch in APLL mclk: %u (configured: %u)\n", |
1971 | freq); | 1963 | freq, twl4030->sysclk * 1000); |
1972 | return -EINVAL; | 1964 | return -EINVAL; |
1973 | } | 1965 | } |
1974 | |||
1975 | twl4030_write(codec, TWL4030_REG_APLL_CTL, apll_ctrl); | ||
1976 | |||
1977 | return 0; | 1966 | return 0; |
1978 | } | 1967 | } |
1979 | 1968 | ||
@@ -2131,17 +2120,15 @@ static int twl4030_soc_probe(struct platform_device *pdev) | |||
2131 | if (setup) { | 2120 | if (setup) { |
2132 | unsigned char hs_pop; | 2121 | unsigned char hs_pop; |
2133 | 2122 | ||
2134 | if (setup->sysclk) | 2123 | if (setup->sysclk != twl4030->sysclk) |
2135 | twl4030->sysclk = setup->sysclk; | 2124 | dev_warn(&pdev->dev, |
2136 | else | 2125 | "Mismatch in APLL mclk: %u (configured: %u)\n", |
2137 | twl4030->sysclk = 26000; | 2126 | setup->sysclk, twl4030->sysclk); |
2138 | 2127 | ||
2139 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); | 2128 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); |
2140 | hs_pop &= ~TWL4030_RAMP_DELAY; | 2129 | hs_pop &= ~TWL4030_RAMP_DELAY; |
2141 | hs_pop |= (setup->ramp_delay_value << 2); | 2130 | hs_pop |= (setup->ramp_delay_value << 2); |
2142 | twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 2131 | twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
2143 | } else { | ||
2144 | twl4030->sysclk = 26000; | ||
2145 | } | 2132 | } |
2146 | 2133 | ||
2147 | /* register pcms */ | 2134 | /* register pcms */ |
@@ -2179,10 +2166,8 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev) | |||
2179 | struct twl4030_priv *twl4030; | 2166 | struct twl4030_priv *twl4030; |
2180 | int ret; | 2167 | int ret; |
2181 | 2168 | ||
2182 | if (!pdata || !(pdata->audio_mclk == 19200000 || | 2169 | if (!pdata) { |
2183 | pdata->audio_mclk == 26000000 || | 2170 | dev_err(&pdev->dev, "platform_data is missing\n"); |
2184 | pdata->audio_mclk == 38400000)) { | ||
2185 | dev_err(&pdev->dev, "Invalid platform_data\n"); | ||
2186 | return -EINVAL; | 2171 | return -EINVAL; |
2187 | } | 2172 | } |
2188 | 2173 | ||
@@ -2221,6 +2206,7 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev) | |||
2221 | twl4030_codec = codec; | 2206 | twl4030_codec = codec; |
2222 | 2207 | ||
2223 | /* Set the defaults, and power up the codec */ | 2208 | /* Set the defaults, and power up the codec */ |
2209 | twl4030->sysclk = twl4030_codec_get_mclk() / 1000; | ||
2224 | twl4030_init_chip(codec); | 2210 | twl4030_init_chip(codec); |
2225 | codec->bias_level = SND_SOC_BIAS_OFF; | 2211 | codec->bias_level = SND_SOC_BIAS_OFF; |
2226 | twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 2212 | twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |