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