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