Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * omap3pandora.c -- SoC audio for Pandora Handheld Console |
| 3 | * |
| 4 | * Author: GraÅžvydas Ignotas <notasas@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 18 | * 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <linux/clk.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/gpio.h> |
| 25 | #include <linux/delay.h> |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 26 | #include <linux/regulator/consumer.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 27 | #include <linux/module.h> |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 28 | |
| 29 | #include <sound/core.h> |
| 30 | #include <sound/pcm.h> |
| 31 | #include <sound/soc.h> |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 32 | |
| 33 | #include <asm/mach-types.h> |
Arnd Bergmann | 2203747 | 2012-08-24 15:21:06 +0200 | [diff] [blame] | 34 | #include <linux/platform_data/asoc-ti-mcbsp.h> |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 35 | |
| 36 | #include "omap-mcbsp.h" |
| 37 | #include "omap-pcm.h" |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 38 | |
| 39 | #define OMAP3_PANDORA_DAC_POWER_GPIO 118 |
| 40 | #define OMAP3_PANDORA_AMP_POWER_GPIO 14 |
| 41 | |
| 42 | #define PREFIX "ASoC omap3pandora: " |
| 43 | |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 44 | static struct regulator *omap3pandora_dac_reg; |
| 45 | |
Grazvydas Ignotas | 4b94dba | 2010-06-17 16:45:28 +0300 | [diff] [blame] | 46 | static int omap3pandora_hw_params(struct snd_pcm_substream *substream, |
| 47 | struct snd_pcm_hw_params *params) |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 48 | { |
Jarkko Nikula | 9e5d86f | 2009-11-09 08:44:32 +0200 | [diff] [blame] | 49 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 50 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 51 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 52 | int ret; |
| 53 | |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 54 | /* Set the codec system clock for DAC and ADC */ |
| 55 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000, |
| 56 | SND_SOC_CLOCK_IN); |
| 57 | if (ret < 0) { |
| 58 | pr_err(PREFIX "can't set codec system clock\n"); |
| 59 | return ret; |
| 60 | } |
| 61 | |
| 62 | /* Set McBSP clock to external */ |
Jarkko Nikula | 9e5d86f | 2009-11-09 08:44:32 +0200 | [diff] [blame] | 63 | ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_EXT, |
| 64 | 256 * params_rate(params), |
| 65 | SND_SOC_CLOCK_IN); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 66 | if (ret < 0) { |
| 67 | pr_err(PREFIX "can't set cpu system clock\n"); |
| 68 | return ret; |
| 69 | } |
| 70 | |
| 71 | ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_MCBSP_CLKGDV, 8); |
| 72 | if (ret < 0) { |
| 73 | pr_err(PREFIX "can't set SRG clock divider\n"); |
| 74 | return ret; |
| 75 | } |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 80 | static int omap3pandora_dac_event(struct snd_soc_dapm_widget *w, |
| 81 | struct snd_kcontrol *k, int event) |
| 82 | { |
| 83 | /* |
| 84 | * The PCM1773 DAC datasheet requires 1ms delay between switching |
| 85 | * VCC power on/off and /PD pin high/low |
| 86 | */ |
| 87 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 88 | regulator_enable(omap3pandora_dac_reg); |
| 89 | mdelay(1); |
| 90 | gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 1); |
| 91 | } else { |
| 92 | gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 0); |
| 93 | mdelay(1); |
| 94 | regulator_disable(omap3pandora_dac_reg); |
| 95 | } |
| 96 | |
| 97 | return 0; |
| 98 | } |
| 99 | |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 100 | static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w, |
| 101 | struct snd_kcontrol *k, int event) |
| 102 | { |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 103 | if (SND_SOC_DAPM_EVENT_ON(event)) |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 104 | gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 1); |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 105 | else |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 106 | gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 0); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | * Audio paths on Pandora board: |
| 113 | * |
| 114 | * |O| ---> PCM DAC +-> AMP -> Headphone Jack |
| 115 | * |M| A +--------> Line Out |
| 116 | * |A| <~~clk~~+ |
| 117 | * |P| <--- TWL4030 <--------- Line In and MICs |
| 118 | */ |
| 119 | static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 120 | SND_SOC_DAPM_DAC_E("PCM DAC", "HiFi Playback", SND_SOC_NOPM, |
| 121 | 0, 0, omap3pandora_dac_event, |
| 122 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 123 | SND_SOC_DAPM_PGA_E("Headphone Amplifier", SND_SOC_NOPM, |
| 124 | 0, 0, NULL, 0, omap3pandora_hp_event, |
| 125 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
| 126 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 127 | SND_SOC_DAPM_LINE("Line Out", NULL), |
| 128 | }; |
| 129 | |
| 130 | static const struct snd_soc_dapm_widget omap3pandora_in_dapm_widgets[] = { |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 131 | SND_SOC_DAPM_MIC("Mic (internal)", NULL), |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 132 | SND_SOC_DAPM_MIC("Mic (external)", NULL), |
| 133 | SND_SOC_DAPM_LINE("Line In", NULL), |
| 134 | }; |
| 135 | |
| 136 | static const struct snd_soc_dapm_route omap3pandora_out_map[] = { |
Grazvydas Ignotas | 3b9447f | 2010-02-05 00:55:33 +0200 | [diff] [blame] | 137 | {"PCM DAC", NULL, "APLL Enable"}, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 138 | {"Headphone Amplifier", NULL, "PCM DAC"}, |
| 139 | {"Line Out", NULL, "PCM DAC"}, |
| 140 | {"Headphone Jack", NULL, "Headphone Amplifier"}, |
| 141 | }; |
| 142 | |
| 143 | static const struct snd_soc_dapm_route omap3pandora_in_map[] = { |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 144 | {"AUXL", NULL, "Line In"}, |
| 145 | {"AUXR", NULL, "Line In"}, |
| 146 | |
Peter Ujfalusi | e04d6e5 | 2012-12-31 11:51:45 +0100 | [diff] [blame] | 147 | {"MAINMIC", NULL, "Mic (internal)"}, |
| 148 | {"Mic (internal)", NULL, "Mic Bias 1"}, |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 149 | |
Peter Ujfalusi | e04d6e5 | 2012-12-31 11:51:45 +0100 | [diff] [blame] | 150 | {"SUBMIC", NULL, "Mic (external)"}, |
| 151 | {"Mic (external)", NULL, "Mic Bias 2"}, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 152 | }; |
| 153 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 154 | static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd) |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 155 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 156 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 157 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 158 | int ret; |
| 159 | |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 160 | /* All TWL4030 output pins are floating */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 161 | snd_soc_dapm_nc_pin(dapm, "EARPIECE"); |
| 162 | snd_soc_dapm_nc_pin(dapm, "PREDRIVEL"); |
| 163 | snd_soc_dapm_nc_pin(dapm, "PREDRIVER"); |
| 164 | snd_soc_dapm_nc_pin(dapm, "HSOL"); |
| 165 | snd_soc_dapm_nc_pin(dapm, "HSOR"); |
| 166 | snd_soc_dapm_nc_pin(dapm, "CARKITL"); |
| 167 | snd_soc_dapm_nc_pin(dapm, "CARKITR"); |
| 168 | snd_soc_dapm_nc_pin(dapm, "HFL"); |
| 169 | snd_soc_dapm_nc_pin(dapm, "HFR"); |
| 170 | snd_soc_dapm_nc_pin(dapm, "VIBRA"); |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 171 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 172 | ret = snd_soc_dapm_new_controls(dapm, omap3pandora_out_dapm_widgets, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 173 | ARRAY_SIZE(omap3pandora_out_dapm_widgets)); |
| 174 | if (ret < 0) |
| 175 | return ret; |
| 176 | |
Peter Ujfalusi | cb42487 | 2011-10-10 15:34:08 +0300 | [diff] [blame] | 177 | return snd_soc_dapm_add_routes(dapm, omap3pandora_out_map, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 178 | ARRAY_SIZE(omap3pandora_out_map)); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 179 | } |
| 180 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 181 | static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd) |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 182 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 183 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 184 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 185 | int ret; |
| 186 | |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 187 | /* Not comnnected */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 188 | snd_soc_dapm_nc_pin(dapm, "HSMIC"); |
| 189 | snd_soc_dapm_nc_pin(dapm, "CARKITMIC"); |
| 190 | snd_soc_dapm_nc_pin(dapm, "DIGIMIC0"); |
| 191 | snd_soc_dapm_nc_pin(dapm, "DIGIMIC1"); |
Grazvydas Ignotas | 7f18534 | 2008-12-23 12:04:48 +0200 | [diff] [blame] | 192 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 193 | ret = snd_soc_dapm_new_controls(dapm, omap3pandora_in_dapm_widgets, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 194 | ARRAY_SIZE(omap3pandora_in_dapm_widgets)); |
| 195 | if (ret < 0) |
| 196 | return ret; |
| 197 | |
Peter Ujfalusi | cb42487 | 2011-10-10 15:34:08 +0300 | [diff] [blame] | 198 | return snd_soc_dapm_add_routes(dapm, omap3pandora_in_map, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 199 | ARRAY_SIZE(omap3pandora_in_map)); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 200 | } |
| 201 | |
Grazvydas Ignotas | 4b94dba | 2010-06-17 16:45:28 +0300 | [diff] [blame] | 202 | static struct snd_soc_ops omap3pandora_ops = { |
| 203 | .hw_params = omap3pandora_hw_params, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | /* Digital audio interface glue - connects codec <--> CPU */ |
| 207 | static struct snd_soc_dai_link omap3pandora_dai[] = { |
| 208 | { |
| 209 | .name = "PCM1773", |
| 210 | .stream_name = "HiFi Out", |
Peter Ujfalusi | 45656b4 | 2012-02-14 18:20:58 +0200 | [diff] [blame] | 211 | .cpu_dai_name = "omap-mcbsp.2", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 212 | .codec_dai_name = "twl4030-hifi", |
| 213 | .platform_name = "omap-pcm-audio", |
| 214 | .codec_name = "twl4030-codec", |
Jarkko Nikula | cf9feff | 2011-09-30 16:07:45 +0300 | [diff] [blame] | 215 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 216 | SND_SOC_DAIFMT_CBS_CFS, |
Grazvydas Ignotas | 4b94dba | 2010-06-17 16:45:28 +0300 | [diff] [blame] | 217 | .ops = &omap3pandora_ops, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 218 | .init = omap3pandora_out_init, |
| 219 | }, { |
| 220 | .name = "TWL4030", |
| 221 | .stream_name = "Line/Mic In", |
Peter Ujfalusi | 45656b4 | 2012-02-14 18:20:58 +0200 | [diff] [blame] | 222 | .cpu_dai_name = "omap-mcbsp.4", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 223 | .codec_dai_name = "twl4030-hifi", |
| 224 | .platform_name = "omap-pcm-audio", |
| 225 | .codec_name = "twl4030-codec", |
Jarkko Nikula | cf9feff | 2011-09-30 16:07:45 +0300 | [diff] [blame] | 226 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 227 | SND_SOC_DAIFMT_CBS_CFS, |
Grazvydas Ignotas | 4b94dba | 2010-06-17 16:45:28 +0300 | [diff] [blame] | 228 | .ops = &omap3pandora_ops, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 229 | .init = omap3pandora_in_init, |
| 230 | } |
| 231 | }; |
| 232 | |
| 233 | /* SoC card */ |
| 234 | static struct snd_soc_card snd_soc_card_omap3pandora = { |
| 235 | .name = "omap3pandora", |
Axel Lin | b425b88 | 2011-12-22 11:08:59 +0800 | [diff] [blame] | 236 | .owner = THIS_MODULE, |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 237 | .dai_link = omap3pandora_dai, |
| 238 | .num_links = ARRAY_SIZE(omap3pandora_dai), |
| 239 | }; |
| 240 | |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 241 | static struct platform_device *omap3pandora_snd_device; |
| 242 | |
| 243 | static int __init omap3pandora_soc_init(void) |
| 244 | { |
| 245 | int ret; |
| 246 | |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 247 | if (!machine_is_omap3_pandora()) |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 248 | return -ENODEV; |
Grazvydas Ignotas | 8f00806 | 2009-01-31 16:29:24 +0200 | [diff] [blame] | 249 | |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 250 | pr_info("OMAP3 Pandora SoC init\n"); |
| 251 | |
| 252 | ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power"); |
| 253 | if (ret) { |
| 254 | pr_err(PREFIX "Failed to get DAC power GPIO\n"); |
| 255 | return ret; |
| 256 | } |
| 257 | |
| 258 | ret = gpio_direction_output(OMAP3_PANDORA_DAC_POWER_GPIO, 0); |
| 259 | if (ret) { |
| 260 | pr_err(PREFIX "Failed to set DAC power GPIO direction\n"); |
| 261 | goto fail0; |
| 262 | } |
| 263 | |
| 264 | ret = gpio_request(OMAP3_PANDORA_AMP_POWER_GPIO, "amp_power"); |
| 265 | if (ret) { |
| 266 | pr_err(PREFIX "Failed to get amp power GPIO\n"); |
| 267 | goto fail0; |
| 268 | } |
| 269 | |
| 270 | ret = gpio_direction_output(OMAP3_PANDORA_AMP_POWER_GPIO, 0); |
| 271 | if (ret) { |
| 272 | pr_err(PREFIX "Failed to set amp power GPIO direction\n"); |
| 273 | goto fail1; |
| 274 | } |
| 275 | |
| 276 | omap3pandora_snd_device = platform_device_alloc("soc-audio", -1); |
| 277 | if (omap3pandora_snd_device == NULL) { |
| 278 | pr_err(PREFIX "Platform device allocation failed\n"); |
| 279 | ret = -ENOMEM; |
| 280 | goto fail1; |
| 281 | } |
| 282 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 283 | platform_set_drvdata(omap3pandora_snd_device, &snd_soc_card_omap3pandora); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 284 | |
| 285 | ret = platform_device_add(omap3pandora_snd_device); |
| 286 | if (ret) { |
| 287 | pr_err(PREFIX "Unable to add platform device\n"); |
| 288 | goto fail2; |
| 289 | } |
| 290 | |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 291 | omap3pandora_dac_reg = regulator_get(&omap3pandora_snd_device->dev, "vcc"); |
| 292 | if (IS_ERR(omap3pandora_dac_reg)) { |
| 293 | pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n", |
| 294 | dev_name(&omap3pandora_snd_device->dev), |
| 295 | PTR_ERR(omap3pandora_dac_reg)); |
Axel Lin | 5c12d20 | 2010-11-24 15:20:48 +0800 | [diff] [blame] | 296 | ret = PTR_ERR(omap3pandora_dac_reg); |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 297 | goto fail3; |
| 298 | } |
| 299 | |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 300 | return 0; |
| 301 | |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 302 | fail3: |
| 303 | platform_device_del(omap3pandora_snd_device); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 304 | fail2: |
| 305 | platform_device_put(omap3pandora_snd_device); |
| 306 | fail1: |
| 307 | gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); |
| 308 | fail0: |
| 309 | gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); |
| 310 | return ret; |
| 311 | } |
| 312 | module_init(omap3pandora_soc_init); |
| 313 | |
| 314 | static void __exit omap3pandora_soc_exit(void) |
| 315 | { |
Grazvydas Ignotas | c50749d | 2010-02-05 16:29:53 +0200 | [diff] [blame] | 316 | regulator_put(omap3pandora_dac_reg); |
Grazvydas Ignotas | 68fb740 | 2008-12-04 22:39:54 +0200 | [diff] [blame] | 317 | platform_device_unregister(omap3pandora_snd_device); |
| 318 | gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); |
| 319 | gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); |
| 320 | } |
| 321 | module_exit(omap3pandora_soc_exit); |
| 322 | |
| 323 | MODULE_AUTHOR("Grazvydas Ignotas <notasas@gmail.com>"); |
| 324 | MODULE_DESCRIPTION("ALSA SoC OMAP3 Pandora"); |
| 325 | MODULE_LICENSE("GPL"); |