Commit | Line | Data |
---|---|---|
49100c98 JN |
1 | /* |
2 | * rx51.c -- SoC audio for Nokia RX-51 | |
3 | * | |
4 | * Copyright (C) 2008 - 2009 Nokia Corporation | |
5 | * | |
0ac3a014 | 6 | * Contact: Peter Ujfalusi <peter.ujfalusi@ti.com> |
49100c98 | 7 | * Eduardo Valentin <eduardo.valentin@nokia.com> |
7ec41ee5 | 8 | * Jarkko Nikula <jarkko.nikula@bitmer.com> |
49100c98 JN |
9 | * |
10 | * This program is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU General Public License | |
12 | * version 2 as published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
22 | * 02110-1301 USA | |
23 | * | |
24 | */ | |
25 | ||
26 | #include <linux/delay.h> | |
27 | #include <linux/gpio.h> | |
28 | #include <linux/platform_device.h> | |
386e81ab | 29 | #include <linux/gpio/consumer.h> |
da155d5b | 30 | #include <linux/module.h> |
49100c98 | 31 | #include <sound/core.h> |
8c523115 | 32 | #include <sound/jack.h> |
49100c98 JN |
33 | #include <sound/pcm.h> |
34 | #include <sound/soc.h> | |
2203747c | 35 | #include <linux/platform_data/asoc-ti-mcbsp.h> |
48529b3b | 36 | #include "../codecs/tpa6130a2.h" |
49100c98 JN |
37 | |
38 | #include <asm/mach-types.h> | |
39 | ||
40 | #include "omap-mcbsp.h" | |
49100c98 | 41 | |
4eb54703 JN |
42 | enum { |
43 | RX51_JACK_DISABLED, | |
48529b3b JN |
44 | RX51_JACK_TVOUT, /* tv-out with stereo output */ |
45 | RX51_JACK_HP, /* headphone: stereo output, no mic */ | |
31164c7c | 46 | RX51_JACK_HS, /* headset: stereo output with mic */ |
4eb54703 JN |
47 | }; |
48 | ||
386e81ab SR |
49 | struct rx51_audio_pdata { |
50 | struct gpio_desc *tvout_selection_gpio; | |
51 | struct gpio_desc *jack_detection_gpio; | |
52 | struct gpio_desc *eci_sw_gpio; | |
53 | struct gpio_desc *speaker_amp_gpio; | |
54 | }; | |
55 | ||
49100c98 JN |
56 | static int rx51_spk_func; |
57 | static int rx51_dmic_func; | |
4eb54703 | 58 | static int rx51_jack_func; |
49100c98 | 59 | |
022658be | 60 | static void rx51_ext_control(struct snd_soc_dapm_context *dapm) |
49100c98 | 61 | { |
386e81ab SR |
62 | struct snd_soc_card *card = dapm->card; |
63 | struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); | |
31164c7c | 64 | int hp = 0, hs = 0, tvout = 0; |
48529b3b JN |
65 | |
66 | switch (rx51_jack_func) { | |
67 | case RX51_JACK_TVOUT: | |
68 | tvout = 1; | |
31164c7c JN |
69 | hp = 1; |
70 | break; | |
71 | case RX51_JACK_HS: | |
72 | hs = 1; | |
48529b3b JN |
73 | case RX51_JACK_HP: |
74 | hp = 1; | |
75 | break; | |
76 | } | |
ce6120cc | 77 | |
9dd2bb3f CK |
78 | snd_soc_dapm_mutex_lock(dapm); |
79 | ||
49100c98 | 80 | if (rx51_spk_func) |
9dd2bb3f | 81 | snd_soc_dapm_enable_pin_unlocked(dapm, "Ext Spk"); |
49100c98 | 82 | else |
9dd2bb3f | 83 | snd_soc_dapm_disable_pin_unlocked(dapm, "Ext Spk"); |
49100c98 | 84 | if (rx51_dmic_func) |
9dd2bb3f | 85 | snd_soc_dapm_enable_pin_unlocked(dapm, "DMic"); |
49100c98 | 86 | else |
9dd2bb3f | 87 | snd_soc_dapm_disable_pin_unlocked(dapm, "DMic"); |
48529b3b | 88 | if (hp) |
9dd2bb3f | 89 | snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack"); |
48529b3b | 90 | else |
9dd2bb3f | 91 | snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); |
31164c7c | 92 | if (hs) |
9dd2bb3f | 93 | snd_soc_dapm_enable_pin_unlocked(dapm, "HS Mic"); |
31164c7c | 94 | else |
9dd2bb3f | 95 | snd_soc_dapm_disable_pin_unlocked(dapm, "HS Mic"); |
49100c98 | 96 | |
386e81ab | 97 | gpiod_set_value(pdata->tvout_selection_gpio, tvout); |
4eb54703 | 98 | |
9dd2bb3f CK |
99 | snd_soc_dapm_sync_unlocked(dapm); |
100 | ||
101 | snd_soc_dapm_mutex_unlock(dapm); | |
49100c98 JN |
102 | } |
103 | ||
104 | static int rx51_startup(struct snd_pcm_substream *substream) | |
105 | { | |
106 | struct snd_pcm_runtime *runtime = substream->runtime; | |
107 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
022658be | 108 | struct snd_soc_card *card = rtd->card; |
49100c98 | 109 | |
be448b4f | 110 | snd_pcm_hw_constraint_single(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2); |
022658be | 111 | rx51_ext_control(&card->dapm); |
49100c98 JN |
112 | |
113 | return 0; | |
114 | } | |
115 | ||
116 | static int rx51_hw_params(struct snd_pcm_substream *substream, | |
117 | struct snd_pcm_hw_params *params) | |
118 | { | |
119 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
f0fba2ad | 120 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
49100c98 JN |
121 | |
122 | /* Set the codec system clock for DAC and ADC */ | |
123 | return snd_soc_dai_set_sysclk(codec_dai, 0, 19200000, | |
124 | SND_SOC_CLOCK_IN); | |
125 | } | |
126 | ||
127 | static struct snd_soc_ops rx51_ops = { | |
128 | .startup = rx51_startup, | |
129 | .hw_params = rx51_hw_params, | |
130 | }; | |
131 | ||
132 | static int rx51_get_spk(struct snd_kcontrol *kcontrol, | |
133 | struct snd_ctl_elem_value *ucontrol) | |
134 | { | |
f4d438ee | 135 | ucontrol->value.enumerated.item[0] = rx51_spk_func; |
49100c98 JN |
136 | |
137 | return 0; | |
138 | } | |
139 | ||
140 | static int rx51_set_spk(struct snd_kcontrol *kcontrol, | |
141 | struct snd_ctl_elem_value *ucontrol) | |
142 | { | |
022658be | 143 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
49100c98 | 144 | |
f4d438ee | 145 | if (rx51_spk_func == ucontrol->value.enumerated.item[0]) |
49100c98 JN |
146 | return 0; |
147 | ||
f4d438ee | 148 | rx51_spk_func = ucontrol->value.enumerated.item[0]; |
022658be | 149 | rx51_ext_control(&card->dapm); |
49100c98 JN |
150 | |
151 | return 1; | |
152 | } | |
153 | ||
154 | static int rx51_spk_event(struct snd_soc_dapm_widget *w, | |
155 | struct snd_kcontrol *k, int event) | |
156 | { | |
386e81ab SR |
157 | struct snd_soc_dapm_context *dapm = w->dapm; |
158 | struct snd_soc_card *card = dapm->card; | |
159 | struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); | |
160 | ||
161 | gpiod_set_raw_value_cansleep(pdata->speaker_amp_gpio, | |
162 | !!SND_SOC_DAPM_EVENT_ON(event)); | |
49100c98 JN |
163 | |
164 | return 0; | |
165 | } | |
166 | ||
48529b3b JN |
167 | static int rx51_hp_event(struct snd_soc_dapm_widget *w, |
168 | struct snd_kcontrol *k, int event) | |
169 | { | |
a761f87f | 170 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
48529b3b JN |
171 | |
172 | if (SND_SOC_DAPM_EVENT_ON(event)) | |
173 | tpa6130a2_stereo_enable(codec, 1); | |
174 | else | |
175 | tpa6130a2_stereo_enable(codec, 0); | |
176 | ||
177 | return 0; | |
178 | } | |
179 | ||
49100c98 JN |
180 | static int rx51_get_input(struct snd_kcontrol *kcontrol, |
181 | struct snd_ctl_elem_value *ucontrol) | |
182 | { | |
f4d438ee | 183 | ucontrol->value.enumerated.item[0] = rx51_dmic_func; |
49100c98 JN |
184 | |
185 | return 0; | |
186 | } | |
187 | ||
188 | static int rx51_set_input(struct snd_kcontrol *kcontrol, | |
189 | struct snd_ctl_elem_value *ucontrol) | |
190 | { | |
022658be | 191 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
49100c98 | 192 | |
f4d438ee | 193 | if (rx51_dmic_func == ucontrol->value.enumerated.item[0]) |
49100c98 JN |
194 | return 0; |
195 | ||
f4d438ee | 196 | rx51_dmic_func = ucontrol->value.enumerated.item[0]; |
022658be | 197 | rx51_ext_control(&card->dapm); |
49100c98 JN |
198 | |
199 | return 1; | |
200 | } | |
201 | ||
4eb54703 JN |
202 | static int rx51_get_jack(struct snd_kcontrol *kcontrol, |
203 | struct snd_ctl_elem_value *ucontrol) | |
204 | { | |
f4d438ee | 205 | ucontrol->value.enumerated.item[0] = rx51_jack_func; |
4eb54703 JN |
206 | |
207 | return 0; | |
208 | } | |
209 | ||
210 | static int rx51_set_jack(struct snd_kcontrol *kcontrol, | |
211 | struct snd_ctl_elem_value *ucontrol) | |
212 | { | |
022658be | 213 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
4eb54703 | 214 | |
f4d438ee | 215 | if (rx51_jack_func == ucontrol->value.enumerated.item[0]) |
4eb54703 JN |
216 | return 0; |
217 | ||
f4d438ee | 218 | rx51_jack_func = ucontrol->value.enumerated.item[0]; |
022658be | 219 | rx51_ext_control(&card->dapm); |
4eb54703 JN |
220 | |
221 | return 1; | |
222 | } | |
223 | ||
8c523115 JN |
224 | static struct snd_soc_jack rx51_av_jack; |
225 | ||
226 | static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = { | |
227 | { | |
8c523115 | 228 | .name = "avdet-gpio", |
17840619 | 229 | .report = SND_JACK_HEADSET, |
8c523115 JN |
230 | .invert = 1, |
231 | .debounce_time = 200, | |
232 | }, | |
233 | }; | |
234 | ||
49100c98 JN |
235 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { |
236 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), | |
237 | SND_SOC_DAPM_MIC("DMic", NULL), | |
48529b3b | 238 | SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event), |
31164c7c | 239 | SND_SOC_DAPM_MIC("HS Mic", NULL), |
9d7e584b | 240 | SND_SOC_DAPM_LINE("FM Transmitter", NULL), |
8cda9751 JN |
241 | SND_SOC_DAPM_SPK("Earphone", NULL), |
242 | }; | |
243 | ||
49100c98 JN |
244 | static const struct snd_soc_dapm_route audio_map[] = { |
245 | {"Ext Spk", NULL, "HPLOUT"}, | |
246 | {"Ext Spk", NULL, "HPROUT"}, | |
6876c7c8 LPC |
247 | {"Ext Spk", NULL, "HPLCOM"}, |
248 | {"Ext Spk", NULL, "HPRCOM"}, | |
48529b3b JN |
249 | {"Headphone Jack", NULL, "LLOUT"}, |
250 | {"Headphone Jack", NULL, "RLOUT"}, | |
9d7e584b JN |
251 | {"FM Transmitter", NULL, "LLOUT"}, |
252 | {"FM Transmitter", NULL, "RLOUT"}, | |
49100c98 | 253 | |
2ca087bc PU |
254 | {"DMic Rate 64", NULL, "DMic"}, |
255 | {"DMic", NULL, "Mic Bias"}, | |
49100c98 | 256 | |
8cda9751 JN |
257 | {"b LINE2R", NULL, "MONO_LOUT"}, |
258 | {"Earphone", NULL, "b HPLOUT"}, | |
31164c7c | 259 | |
2ca087bc PU |
260 | {"LINE1L", NULL, "HS Mic"}, |
261 | {"HS Mic", NULL, "b Mic Bias"}, | |
8cda9751 JN |
262 | }; |
263 | ||
441dc45a SR |
264 | static const char * const spk_function[] = {"Off", "On"}; |
265 | static const char * const input_function[] = {"ADC", "Digital Mic"}; | |
266 | static const char * const jack_function[] = { | |
267 | "Off", "TV-OUT", "Headphone", "Headset" | |
268 | }; | |
49100c98 JN |
269 | |
270 | static const struct soc_enum rx51_enum[] = { | |
271 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), | |
272 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(input_function), input_function), | |
4eb54703 | 273 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(jack_function), jack_function), |
49100c98 JN |
274 | }; |
275 | ||
276 | static const struct snd_kcontrol_new aic34_rx51_controls[] = { | |
277 | SOC_ENUM_EXT("Speaker Function", rx51_enum[0], | |
278 | rx51_get_spk, rx51_set_spk), | |
279 | SOC_ENUM_EXT("Input Select", rx51_enum[1], | |
280 | rx51_get_input, rx51_set_input), | |
4eb54703 JN |
281 | SOC_ENUM_EXT("Jack Function", rx51_enum[2], |
282 | rx51_get_jack, rx51_set_jack), | |
9d7e584b | 283 | SOC_DAPM_PIN_SWITCH("FM Transmitter"), |
8cda9751 JN |
284 | SOC_DAPM_PIN_SWITCH("Earphone"), |
285 | }; | |
286 | ||
f0fba2ad | 287 | static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) |
49100c98 | 288 | { |
f0fba2ad | 289 | struct snd_soc_codec *codec = rtd->codec; |
0596f700 | 290 | struct snd_soc_card *card = rtd->card; |
386e81ab | 291 | struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); |
49100c98 JN |
292 | int err; |
293 | ||
48529b3b | 294 | err = tpa6130a2_add_controls(codec); |
0265e1ae SR |
295 | if (err < 0) { |
296 | dev_err(card->dev, "Failed to add TPA6130A2 controls\n"); | |
48529b3b | 297 | return err; |
0265e1ae | 298 | } |
26d9ca34 | 299 | snd_soc_limit_volume(card, "TPA6130A2 Headphone Playback Volume", 42); |
48529b3b | 300 | |
0a17a370 | 301 | err = omap_mcbsp_st_add_controls(rtd, 2); |
0265e1ae SR |
302 | if (err < 0) { |
303 | dev_err(card->dev, "Failed to add MCBSP controls\n"); | |
fa4d1f59 | 304 | return err; |
0265e1ae | 305 | } |
fa4d1f59 | 306 | |
8c523115 | 307 | /* AV jack detection */ |
753d45e6 LPC |
308 | err = snd_soc_card_jack_new(rtd->card, "AV Jack", |
309 | SND_JACK_HEADSET | SND_JACK_VIDEOOUT, | |
310 | &rx51_av_jack, NULL, 0); | |
0265e1ae SR |
311 | if (err) { |
312 | dev_err(card->dev, "Failed to add AV Jack\n"); | |
8c523115 | 313 | return err; |
0265e1ae | 314 | } |
386e81ab SR |
315 | |
316 | /* prepare gpio for snd_soc_jack_add_gpios */ | |
317 | rx51_av_jack_gpios[0].gpio = desc_to_gpio(pdata->jack_detection_gpio); | |
318 | devm_gpiod_put(card->dev, pdata->jack_detection_gpio); | |
319 | ||
8c523115 JN |
320 | err = snd_soc_jack_add_gpios(&rx51_av_jack, |
321 | ARRAY_SIZE(rx51_av_jack_gpios), | |
322 | rx51_av_jack_gpios); | |
0265e1ae SR |
323 | if (err) { |
324 | dev_err(card->dev, "Failed to add GPIOs\n"); | |
325 | return err; | |
326 | } | |
8c523115 JN |
327 | |
328 | return err; | |
49100c98 JN |
329 | } |
330 | ||
16088cb6 | 331 | static int rx51_card_remove(struct snd_soc_card *card) |
e1d4d3c8 SW |
332 | { |
333 | snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), | |
334 | rx51_av_jack_gpios); | |
335 | ||
336 | return 0; | |
337 | } | |
338 | ||
49100c98 JN |
339 | /* Digital audio interface glue - connects codec <--> CPU */ |
340 | static struct snd_soc_dai_link rx51_dai[] = { | |
341 | { | |
342 | .name = "TLV320AIC34", | |
343 | .stream_name = "AIC34", | |
45656b44 | 344 | .cpu_dai_name = "omap-mcbsp.2", |
f0fba2ad | 345 | .codec_dai_name = "tlv320aic3x-hifi", |
aac25145 | 346 | .platform_name = "omap-mcbsp.2", |
f0fba2ad | 347 | .codec_name = "tlv320aic3x-codec.2-0018", |
cf9feff2 JN |
348 | .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | |
349 | SND_SOC_DAIFMT_CBM_CFM, | |
49100c98 JN |
350 | .init = rx51_aic34_init, |
351 | .ops = &rx51_ops, | |
352 | }, | |
353 | }; | |
354 | ||
a0e17b4e | 355 | static struct snd_soc_aux_dev rx51_aux_dev[] = { |
8cda9751 JN |
356 | { |
357 | .name = "TLV320AIC34b", | |
358 | .codec_name = "tlv320aic3x-codec.2-0019", | |
8cda9751 JN |
359 | }, |
360 | }; | |
361 | ||
362 | static struct snd_soc_codec_conf rx51_codec_conf[] = { | |
363 | { | |
364 | .dev_name = "tlv320aic3x-codec.2-0019", | |
365 | .name_prefix = "b", | |
366 | }, | |
367 | }; | |
368 | ||
49100c98 JN |
369 | /* Audio card */ |
370 | static struct snd_soc_card rx51_sound_card = { | |
371 | .name = "RX-51", | |
b425b884 | 372 | .owner = THIS_MODULE, |
e1d4d3c8 | 373 | .remove = rx51_card_remove, |
49100c98 JN |
374 | .dai_link = rx51_dai, |
375 | .num_links = ARRAY_SIZE(rx51_dai), | |
8cda9751 JN |
376 | .aux_dev = rx51_aux_dev, |
377 | .num_aux_devs = ARRAY_SIZE(rx51_aux_dev), | |
378 | .codec_conf = rx51_codec_conf, | |
379 | .num_configs = ARRAY_SIZE(rx51_codec_conf), | |
6876c7c8 | 380 | .fully_routed = true, |
81fc5dd4 LPC |
381 | |
382 | .controls = aic34_rx51_controls, | |
383 | .num_controls = ARRAY_SIZE(aic34_rx51_controls), | |
384 | .dapm_widgets = aic34_dapm_widgets, | |
385 | .num_dapm_widgets = ARRAY_SIZE(aic34_dapm_widgets), | |
386 | .dapm_routes = audio_map, | |
387 | .num_dapm_routes = ARRAY_SIZE(audio_map), | |
49100c98 JN |
388 | }; |
389 | ||
a7d52028 | 390 | static int rx51_soc_probe(struct platform_device *pdev) |
49100c98 | 391 | { |
386e81ab | 392 | struct rx51_audio_pdata *pdata; |
d052a3d6 | 393 | struct device_node *np = pdev->dev.of_node; |
a7d52028 | 394 | struct snd_soc_card *card = &rx51_sound_card; |
49100c98 JN |
395 | int err; |
396 | ||
ea2409ba | 397 | if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900")) |
49100c98 JN |
398 | return -ENODEV; |
399 | ||
a7d52028 | 400 | card->dev = &pdev->dev; |
49100c98 | 401 | |
d052a3d6 SR |
402 | if (np) { |
403 | struct device_node *dai_node; | |
404 | ||
405 | dai_node = of_parse_phandle(np, "nokia,cpu-dai", 0); | |
406 | if (!dai_node) { | |
407 | dev_err(&pdev->dev, "McBSP node is not provided\n"); | |
408 | return -EINVAL; | |
409 | } | |
410 | rx51_dai[0].cpu_dai_name = NULL; | |
411 | rx51_dai[0].platform_name = NULL; | |
412 | rx51_dai[0].cpu_of_node = dai_node; | |
413 | rx51_dai[0].platform_of_node = dai_node; | |
414 | ||
415 | dai_node = of_parse_phandle(np, "nokia,audio-codec", 0); | |
416 | if (!dai_node) { | |
417 | dev_err(&pdev->dev, "Codec node is not provided\n"); | |
418 | return -EINVAL; | |
419 | } | |
420 | rx51_dai[0].codec_name = NULL; | |
421 | rx51_dai[0].codec_of_node = dai_node; | |
422 | ||
423 | dai_node = of_parse_phandle(np, "nokia,audio-codec", 1); | |
424 | if (!dai_node) { | |
425 | dev_err(&pdev->dev, "Auxiliary Codec node is not provided\n"); | |
426 | return -EINVAL; | |
427 | } | |
428 | rx51_aux_dev[0].codec_name = NULL; | |
429 | rx51_aux_dev[0].codec_of_node = dai_node; | |
430 | rx51_codec_conf[0].dev_name = NULL; | |
431 | rx51_codec_conf[0].of_node = dai_node; | |
432 | ||
433 | dai_node = of_parse_phandle(np, "nokia,headphone-amplifier", 0); | |
434 | if (!dai_node) { | |
435 | dev_err(&pdev->dev, "Headphone amplifier node is not provided\n"); | |
436 | return -EINVAL; | |
437 | } | |
438 | ||
439 | /* TODO: tpa6130a2a driver supports only a single instance, so | |
440 | * this driver ignores the headphone-amplifier node for now. | |
441 | * It's already mandatory in the DT binding to be future proof. | |
442 | */ | |
443 | } | |
444 | ||
386e81ab SR |
445 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
446 | if (pdata == NULL) { | |
447 | dev_err(card->dev, "failed to create private data\n"); | |
448 | return -ENOMEM; | |
449 | } | |
450 | snd_soc_card_set_drvdata(card, pdata); | |
451 | ||
452 | pdata->tvout_selection_gpio = devm_gpiod_get(card->dev, | |
0a8ba6ee UKK |
453 | "tvout-selection", |
454 | GPIOD_OUT_LOW); | |
386e81ab SR |
455 | if (IS_ERR(pdata->tvout_selection_gpio)) { |
456 | dev_err(card->dev, "could not get tvout selection gpio\n"); | |
457 | return PTR_ERR(pdata->tvout_selection_gpio); | |
458 | } | |
459 | ||
386e81ab | 460 | pdata->jack_detection_gpio = devm_gpiod_get(card->dev, |
0a8ba6ee UKK |
461 | "jack-detection", |
462 | GPIOD_ASIS); | |
386e81ab SR |
463 | if (IS_ERR(pdata->jack_detection_gpio)) { |
464 | dev_err(card->dev, "could not get jack detection gpio\n"); | |
465 | return PTR_ERR(pdata->jack_detection_gpio); | |
466 | } | |
467 | ||
0a8ba6ee UKK |
468 | pdata->eci_sw_gpio = devm_gpiod_get(card->dev, "eci-switch", |
469 | GPIOD_OUT_HIGH); | |
386e81ab SR |
470 | if (IS_ERR(pdata->eci_sw_gpio)) { |
471 | dev_err(card->dev, "could not get eci switch gpio\n"); | |
472 | return PTR_ERR(pdata->eci_sw_gpio); | |
473 | } | |
474 | ||
386e81ab | 475 | pdata->speaker_amp_gpio = devm_gpiod_get(card->dev, |
0a8ba6ee UKK |
476 | "speaker-amplifier", |
477 | GPIOD_OUT_LOW); | |
386e81ab SR |
478 | if (IS_ERR(pdata->speaker_amp_gpio)) { |
479 | dev_err(card->dev, "could not get speaker enable gpio\n"); | |
480 | return PTR_ERR(pdata->speaker_amp_gpio); | |
481 | } | |
482 | ||
a7d52028 SR |
483 | err = devm_snd_soc_register_card(card->dev, card); |
484 | if (err) { | |
485 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", err); | |
386e81ab | 486 | return err; |
a7d52028 | 487 | } |
49100c98 JN |
488 | |
489 | return 0; | |
49100c98 JN |
490 | } |
491 | ||
d052a3d6 SR |
492 | #if defined(CONFIG_OF) |
493 | static const struct of_device_id rx51_audio_of_match[] = { | |
494 | { .compatible = "nokia,n900-audio", }, | |
495 | {}, | |
496 | }; | |
497 | MODULE_DEVICE_TABLE(of, rx51_audio_of_match); | |
498 | #endif | |
499 | ||
a7d52028 SR |
500 | static struct platform_driver rx51_soc_driver = { |
501 | .driver = { | |
502 | .name = "rx51-audio", | |
d052a3d6 | 503 | .of_match_table = of_match_ptr(rx51_audio_of_match), |
a7d52028 SR |
504 | }, |
505 | .probe = rx51_soc_probe, | |
a7d52028 SR |
506 | }; |
507 | ||
508 | module_platform_driver(rx51_soc_driver); | |
49100c98 JN |
509 | |
510 | MODULE_AUTHOR("Nokia Corporation"); | |
511 | MODULE_DESCRIPTION("ALSA SoC Nokia RX-51"); | |
512 | MODULE_LICENSE("GPL"); | |
beab3da1 | 513 | MODULE_ALIAS("platform:rx51-audio"); |