0001
0002 #include <linux/extcon.h>
0003 #include <linux/iio/consumer.h>
0004 #include <linux/iio/iio.h>
0005 #include <linux/input-event-codes.h>
0006 #include <linux/mfd/wm8994/registers.h>
0007 #include <linux/module.h>
0008 #include <linux/of.h>
0009 #include <linux/of_device.h>
0010 #include <linux/of_gpio.h>
0011 #include <linux/regulator/consumer.h>
0012 #include <sound/jack.h>
0013 #include <sound/pcm_params.h>
0014 #include <sound/soc.h>
0015
0016 #include "i2s.h"
0017 #include "../codecs/wm8994.h"
0018
0019 #define ARIES_MCLK1_FREQ 24000000
0020
0021 struct aries_wm8994_variant {
0022 unsigned int modem_dai_fmt;
0023 bool has_fm_radio;
0024 };
0025
0026 struct aries_wm8994_data {
0027 struct extcon_dev *usb_extcon;
0028 struct regulator *reg_main_micbias;
0029 struct regulator *reg_headset_micbias;
0030 struct gpio_desc *gpio_headset_detect;
0031 struct gpio_desc *gpio_headset_key;
0032 struct gpio_desc *gpio_earpath_sel;
0033 struct iio_channel *adc;
0034 const struct aries_wm8994_variant *variant;
0035 };
0036
0037
0038 static struct snd_soc_jack aries_dock;
0039
0040 static struct snd_soc_jack_pin dock_pins[] = {
0041 {
0042 .pin = "LINE",
0043 .mask = SND_JACK_LINEOUT,
0044 },
0045 };
0046
0047 static int aries_extcon_notifier(struct notifier_block *this,
0048 unsigned long connected, void *_cmd)
0049 {
0050 if (connected)
0051 snd_soc_jack_report(&aries_dock, SND_JACK_LINEOUT,
0052 SND_JACK_LINEOUT);
0053 else
0054 snd_soc_jack_report(&aries_dock, 0, SND_JACK_LINEOUT);
0055
0056 return NOTIFY_DONE;
0057 }
0058
0059 static struct notifier_block aries_extcon_notifier_block = {
0060 .notifier_call = aries_extcon_notifier,
0061 };
0062
0063
0064 static struct snd_soc_jack aries_headset;
0065
0066 static struct snd_soc_jack_pin jack_pins[] = {
0067 {
0068 .pin = "HP",
0069 .mask = SND_JACK_HEADPHONE,
0070 }, {
0071 .pin = "Headset Mic",
0072 .mask = SND_JACK_MICROPHONE,
0073 },
0074 };
0075
0076 static struct snd_soc_jack_zone headset_zones[] = {
0077 {
0078 .min_mv = 0,
0079 .max_mv = 241,
0080 .jack_type = SND_JACK_HEADPHONE,
0081 }, {
0082 .min_mv = 242,
0083 .max_mv = 2980,
0084 .jack_type = SND_JACK_HEADSET,
0085 }, {
0086 .min_mv = 2981,
0087 .max_mv = UINT_MAX,
0088 .jack_type = SND_JACK_HEADPHONE,
0089 },
0090 };
0091
0092 static irqreturn_t headset_det_irq_thread(int irq, void *data)
0093 {
0094 struct aries_wm8994_data *priv = (struct aries_wm8994_data *) data;
0095 int ret = 0;
0096 int time_left_ms = 300;
0097 int adc;
0098
0099 while (time_left_ms > 0) {
0100 if (!gpiod_get_value(priv->gpio_headset_detect)) {
0101 snd_soc_jack_report(&aries_headset, 0,
0102 SND_JACK_HEADSET);
0103 gpiod_set_value(priv->gpio_earpath_sel, 0);
0104 return IRQ_HANDLED;
0105 }
0106 msleep(20);
0107 time_left_ms -= 20;
0108 }
0109
0110
0111 ret = regulator_enable(priv->reg_headset_micbias);
0112 if (ret)
0113 pr_err("%s failed to enable micbias: %d", __func__, ret);
0114
0115 gpiod_set_value(priv->gpio_earpath_sel, 1);
0116
0117 ret = iio_read_channel_processed(priv->adc, &adc);
0118 if (ret < 0) {
0119
0120 pr_err("%s failed to read ADC, assuming headphones", __func__);
0121 snd_soc_jack_report(&aries_headset, SND_JACK_HEADPHONE,
0122 SND_JACK_HEADSET);
0123 } else {
0124 snd_soc_jack_report(&aries_headset,
0125 snd_soc_jack_get_type(&aries_headset, adc),
0126 SND_JACK_HEADSET);
0127 }
0128
0129 ret = regulator_disable(priv->reg_headset_micbias);
0130 if (ret)
0131 pr_err("%s failed disable micbias: %d", __func__, ret);
0132
0133
0134 if (!(aries_headset.status & SND_JACK_MICROPHONE))
0135 gpiod_set_value(priv->gpio_earpath_sel, 0);
0136
0137 return IRQ_HANDLED;
0138 }
0139
0140 static int headset_button_check(void *data)
0141 {
0142 struct aries_wm8994_data *priv = (struct aries_wm8994_data *) data;
0143
0144
0145 if (gpiod_get_value_cansleep(priv->gpio_headset_key) &&
0146 aries_headset.status & SND_JACK_MICROPHONE)
0147 return SND_JACK_BTN_0;
0148
0149 return 0;
0150 }
0151
0152 static struct snd_soc_jack_gpio headset_button_gpio[] = {
0153 {
0154 .name = "Media Button",
0155 .report = SND_JACK_BTN_0,
0156 .debounce_time = 30,
0157 .jack_status_check = headset_button_check,
0158 },
0159 };
0160
0161 static int aries_spk_cfg(struct snd_soc_dapm_widget *w,
0162 struct snd_kcontrol *kcontrol, int event)
0163 {
0164 struct snd_soc_card *card = w->dapm->card;
0165 struct snd_soc_pcm_runtime *rtd;
0166 struct snd_soc_component *component;
0167 int ret = 0;
0168
0169 rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
0170 component = asoc_rtd_to_codec(rtd, 0)->component;
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 switch (event) {
0181 case SND_SOC_DAPM_POST_PMU:
0182 ret = snd_soc_component_update_bits(component,
0183 WM8994_AIF1_DAC1_FILTERS_1,
0184 WM8994_AIF1DAC1_MONO, WM8994_AIF1DAC1_MONO);
0185 break;
0186 case SND_SOC_DAPM_PRE_PMD:
0187 ret = snd_soc_component_update_bits(component,
0188 WM8994_AIF1_DAC1_FILTERS_1,
0189 WM8994_AIF1DAC1_MONO, 0);
0190 break;
0191 }
0192
0193 return ret;
0194 }
0195
0196 static int aries_main_bias(struct snd_soc_dapm_widget *w,
0197 struct snd_kcontrol *kcontrol, int event)
0198 {
0199 struct snd_soc_card *card = w->dapm->card;
0200 struct aries_wm8994_data *priv = snd_soc_card_get_drvdata(card);
0201 int ret = 0;
0202
0203 switch (event) {
0204 case SND_SOC_DAPM_PRE_PMU:
0205 ret = regulator_enable(priv->reg_main_micbias);
0206 break;
0207 case SND_SOC_DAPM_POST_PMD:
0208 ret = regulator_disable(priv->reg_main_micbias);
0209 break;
0210 }
0211
0212 return ret;
0213 }
0214
0215 static int aries_headset_bias(struct snd_soc_dapm_widget *w,
0216 struct snd_kcontrol *kcontrol, int event)
0217 {
0218 struct snd_soc_card *card = w->dapm->card;
0219 struct aries_wm8994_data *priv = snd_soc_card_get_drvdata(card);
0220 int ret = 0;
0221
0222 switch (event) {
0223 case SND_SOC_DAPM_PRE_PMU:
0224 ret = regulator_enable(priv->reg_headset_micbias);
0225 break;
0226 case SND_SOC_DAPM_POST_PMD:
0227 ret = regulator_disable(priv->reg_headset_micbias);
0228 break;
0229 }
0230
0231 return ret;
0232 }
0233
0234 static const struct snd_kcontrol_new aries_controls[] = {
0235 SOC_DAPM_PIN_SWITCH("Modem In"),
0236 SOC_DAPM_PIN_SWITCH("Modem Out"),
0237 };
0238
0239 static const struct snd_soc_dapm_widget aries_dapm_widgets[] = {
0240 SND_SOC_DAPM_HP("HP", NULL),
0241
0242 SND_SOC_DAPM_SPK("SPK", aries_spk_cfg),
0243 SND_SOC_DAPM_SPK("RCV", NULL),
0244
0245 SND_SOC_DAPM_LINE("LINE", NULL),
0246
0247 SND_SOC_DAPM_MIC("Main Mic", aries_main_bias),
0248 SND_SOC_DAPM_MIC("Headset Mic", aries_headset_bias),
0249
0250 SND_SOC_DAPM_MIC("Bluetooth Mic", NULL),
0251 SND_SOC_DAPM_SPK("Bluetooth SPK", NULL),
0252
0253 SND_SOC_DAPM_LINE("Modem In", NULL),
0254 SND_SOC_DAPM_LINE("Modem Out", NULL),
0255
0256
0257 SND_SOC_DAPM_LINE("FM In", NULL),
0258 };
0259
0260 static int aries_hw_params(struct snd_pcm_substream *substream,
0261 struct snd_pcm_hw_params *params)
0262 {
0263 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
0264 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
0265 unsigned int pll_out;
0266 int ret;
0267
0268
0269 if (params_width(params) == 24)
0270 pll_out = params_rate(params) * 384;
0271 else if (params_rate(params) == 8000 || params_rate(params) == 11025)
0272 pll_out = params_rate(params) * 512;
0273 else
0274 pll_out = params_rate(params) * 256;
0275
0276 ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, WM8994_FLL_SRC_MCLK1,
0277 ARIES_MCLK1_FREQ, pll_out);
0278 if (ret < 0)
0279 return ret;
0280
0281 ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1,
0282 pll_out, SND_SOC_CLOCK_IN);
0283 if (ret < 0)
0284 return ret;
0285
0286 return 0;
0287 }
0288
0289 static int aries_hw_free(struct snd_pcm_substream *substream)
0290 {
0291 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
0292 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
0293 int ret;
0294
0295
0296 ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1,
0297 ARIES_MCLK1_FREQ, SND_SOC_CLOCK_IN);
0298 if (ret < 0)
0299 return ret;
0300
0301
0302 ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, WM8994_FLL_SRC_MCLK1,
0303 ARIES_MCLK1_FREQ, 0);
0304 if (ret < 0)
0305 return ret;
0306
0307 return 0;
0308 }
0309
0310
0311
0312
0313 static const struct snd_soc_ops aries_ops = {
0314 .hw_params = aries_hw_params,
0315 .hw_free = aries_hw_free,
0316 };
0317
0318 static int aries_baseband_init(struct snd_soc_pcm_runtime *rtd)
0319 {
0320 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
0321 unsigned int pll_out;
0322 int ret;
0323
0324 pll_out = 8000 * 512;
0325
0326
0327 ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL2, WM8994_FLL_SRC_MCLK1,
0328 ARIES_MCLK1_FREQ, pll_out);
0329 if (ret < 0)
0330 return ret;
0331
0332
0333 ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL2,
0334 pll_out, SND_SOC_CLOCK_IN);
0335 if (ret < 0)
0336 return ret;
0337
0338 return 0;
0339 }
0340
0341 static int aries_late_probe(struct snd_soc_card *card)
0342 {
0343 struct aries_wm8994_data *priv = snd_soc_card_get_drvdata(card);
0344 int ret, irq;
0345
0346 ret = snd_soc_card_jack_new_pins(card, "Dock", SND_JACK_LINEOUT,
0347 &aries_dock, dock_pins, ARRAY_SIZE(dock_pins));
0348 if (ret)
0349 return ret;
0350
0351 ret = devm_extcon_register_notifier(card->dev,
0352 priv->usb_extcon, EXTCON_JACK_LINE_OUT,
0353 &aries_extcon_notifier_block);
0354 if (ret)
0355 return ret;
0356
0357 if (extcon_get_state(priv->usb_extcon,
0358 EXTCON_JACK_LINE_OUT) > 0)
0359 snd_soc_jack_report(&aries_dock, SND_JACK_LINEOUT,
0360 SND_JACK_LINEOUT);
0361 else
0362 snd_soc_jack_report(&aries_dock, 0, SND_JACK_LINEOUT);
0363
0364 ret = snd_soc_card_jack_new_pins(card, "Headset",
0365 SND_JACK_HEADSET | SND_JACK_BTN_0,
0366 &aries_headset,
0367 jack_pins, ARRAY_SIZE(jack_pins));
0368 if (ret)
0369 return ret;
0370
0371 ret = snd_soc_jack_add_zones(&aries_headset, ARRAY_SIZE(headset_zones),
0372 headset_zones);
0373 if (ret)
0374 return ret;
0375
0376 irq = gpiod_to_irq(priv->gpio_headset_detect);
0377 if (irq < 0) {
0378 dev_err(card->dev, "Failed to map headset detect gpio to irq");
0379 return -EINVAL;
0380 }
0381
0382 ret = devm_request_threaded_irq(card->dev, irq, NULL,
0383 headset_det_irq_thread,
0384 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
0385 IRQF_ONESHOT, "headset_detect", priv);
0386 if (ret) {
0387 dev_err(card->dev, "Failed to request headset detect irq");
0388 return ret;
0389 }
0390
0391 headset_button_gpio[0].data = priv;
0392 headset_button_gpio[0].desc = priv->gpio_headset_key;
0393
0394 snd_jack_set_key(aries_headset.jack, SND_JACK_BTN_0, KEY_MEDIA);
0395
0396 return snd_soc_jack_add_gpios(&aries_headset,
0397 ARRAY_SIZE(headset_button_gpio), headset_button_gpio);
0398 }
0399
0400 static const struct snd_soc_pcm_stream baseband_params = {
0401 .formats = SNDRV_PCM_FMTBIT_S16_LE,
0402 .rate_min = 8000,
0403 .rate_max = 8000,
0404 .channels_min = 1,
0405 .channels_max = 1,
0406 };
0407
0408 static const struct snd_soc_pcm_stream bluetooth_params = {
0409 .formats = SNDRV_PCM_FMTBIT_S16_LE,
0410 .rate_min = 8000,
0411 .rate_max = 8000,
0412 .channels_min = 1,
0413 .channels_max = 2,
0414 };
0415
0416 static const struct snd_soc_dapm_widget aries_modem_widgets[] = {
0417 SND_SOC_DAPM_INPUT("Modem RX"),
0418 SND_SOC_DAPM_OUTPUT("Modem TX"),
0419 };
0420
0421 static const struct snd_soc_dapm_route aries_modem_routes[] = {
0422 { "Modem Capture", NULL, "Modem RX" },
0423 { "Modem TX", NULL, "Modem Playback" },
0424 };
0425
0426 static const struct snd_soc_component_driver aries_component = {
0427 .name = "aries-audio",
0428 .dapm_widgets = aries_modem_widgets,
0429 .num_dapm_widgets = ARRAY_SIZE(aries_modem_widgets),
0430 .dapm_routes = aries_modem_routes,
0431 .num_dapm_routes = ARRAY_SIZE(aries_modem_routes),
0432 .idle_bias_on = 1,
0433 .use_pmdown_time = 1,
0434 .endianness = 1,
0435 };
0436
0437 static struct snd_soc_dai_driver aries_ext_dai[] = {
0438 {
0439 .name = "Voice call",
0440 .playback = {
0441 .stream_name = "Modem Playback",
0442 .channels_min = 1,
0443 .channels_max = 1,
0444 .rate_min = 8000,
0445 .rate_max = 8000,
0446 .rates = SNDRV_PCM_RATE_8000,
0447 .formats = SNDRV_PCM_FMTBIT_S16_LE,
0448 },
0449 .capture = {
0450 .stream_name = "Modem Capture",
0451 .channels_min = 1,
0452 .channels_max = 1,
0453 .rate_min = 8000,
0454 .rate_max = 8000,
0455 .rates = SNDRV_PCM_RATE_8000,
0456 .formats = SNDRV_PCM_FMTBIT_S16_LE,
0457 },
0458 },
0459 };
0460
0461 SND_SOC_DAILINK_DEFS(aif1,
0462 DAILINK_COMP_ARRAY(COMP_CPU(SAMSUNG_I2S_DAI)),
0463 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8994-aif1")),
0464 DAILINK_COMP_ARRAY(COMP_EMPTY()));
0465
0466 SND_SOC_DAILINK_DEFS(baseband,
0467 DAILINK_COMP_ARRAY(COMP_CPU("Voice call")),
0468 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8994-aif2")));
0469
0470 SND_SOC_DAILINK_DEFS(bluetooth,
0471 DAILINK_COMP_ARRAY(COMP_CPU("bt-sco-pcm")),
0472 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8994-aif3")));
0473
0474 static struct snd_soc_dai_link aries_dai[] = {
0475 {
0476 .name = "WM8994 AIF1",
0477 .stream_name = "HiFi",
0478 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
0479 SND_SOC_DAIFMT_CBM_CFM,
0480 .ops = &aries_ops,
0481 SND_SOC_DAILINK_REG(aif1),
0482 },
0483 {
0484 .name = "WM8994 AIF2",
0485 .stream_name = "Baseband",
0486 .init = &aries_baseband_init,
0487 .params = &baseband_params,
0488 .ignore_suspend = 1,
0489 SND_SOC_DAILINK_REG(baseband),
0490 },
0491 {
0492 .name = "WM8994 AIF3",
0493 .stream_name = "Bluetooth",
0494 .params = &bluetooth_params,
0495 .ignore_suspend = 1,
0496 SND_SOC_DAILINK_REG(bluetooth),
0497 },
0498 };
0499
0500 static struct snd_soc_card aries_card = {
0501 .name = "ARIES",
0502 .owner = THIS_MODULE,
0503 .dai_link = aries_dai,
0504 .num_links = ARRAY_SIZE(aries_dai),
0505 .controls = aries_controls,
0506 .num_controls = ARRAY_SIZE(aries_controls),
0507 .dapm_widgets = aries_dapm_widgets,
0508 .num_dapm_widgets = ARRAY_SIZE(aries_dapm_widgets),
0509 .late_probe = aries_late_probe,
0510 };
0511
0512 static const struct aries_wm8994_variant fascinate4g_variant = {
0513 .modem_dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS
0514 | SND_SOC_DAIFMT_IB_NF,
0515 .has_fm_radio = false,
0516 };
0517
0518 static const struct aries_wm8994_variant aries_variant = {
0519 .modem_dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBM_CFM
0520 | SND_SOC_DAIFMT_IB_NF,
0521 .has_fm_radio = true,
0522 };
0523
0524 static const struct of_device_id samsung_wm8994_of_match[] = {
0525 {
0526 .compatible = "samsung,fascinate4g-wm8994",
0527 .data = &fascinate4g_variant,
0528 },
0529 {
0530 .compatible = "samsung,aries-wm8994",
0531 .data = &aries_variant,
0532 },
0533 { },
0534 };
0535 MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match);
0536
0537 static int aries_audio_probe(struct platform_device *pdev)
0538 {
0539 struct device_node *np = pdev->dev.of_node;
0540 struct device_node *cpu, *codec, *extcon_np;
0541 struct device *dev = &pdev->dev;
0542 struct snd_soc_card *card = &aries_card;
0543 struct aries_wm8994_data *priv;
0544 struct snd_soc_dai_link *dai_link;
0545 const struct of_device_id *match;
0546 int ret, i;
0547
0548 if (!np)
0549 return -EINVAL;
0550
0551 card->dev = dev;
0552
0553 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
0554 if (!priv)
0555 return -ENOMEM;
0556
0557 snd_soc_card_set_drvdata(card, priv);
0558
0559 match = of_match_node(samsung_wm8994_of_match, np);
0560 priv->variant = match->data;
0561
0562
0563 if (!priv->variant->has_fm_radio)
0564 card->num_dapm_widgets--;
0565
0566 priv->reg_main_micbias = devm_regulator_get(dev, "main-micbias");
0567 if (IS_ERR(priv->reg_main_micbias)) {
0568 dev_err(dev, "Failed to get main micbias regulator\n");
0569 return PTR_ERR(priv->reg_main_micbias);
0570 }
0571
0572 priv->reg_headset_micbias = devm_regulator_get(dev, "headset-micbias");
0573 if (IS_ERR(priv->reg_headset_micbias)) {
0574 dev_err(dev, "Failed to get headset micbias regulator\n");
0575 return PTR_ERR(priv->reg_headset_micbias);
0576 }
0577
0578 priv->gpio_earpath_sel = devm_gpiod_get(dev, "earpath-sel",
0579 GPIOD_OUT_LOW);
0580 if (IS_ERR(priv->gpio_earpath_sel)) {
0581 dev_err(dev, "Failed to get earpath selector gpio");
0582 return PTR_ERR(priv->gpio_earpath_sel);
0583 }
0584
0585 extcon_np = of_parse_phandle(np, "extcon", 0);
0586 priv->usb_extcon = extcon_find_edev_by_node(extcon_np);
0587 of_node_put(extcon_np);
0588 if (IS_ERR(priv->usb_extcon))
0589 return dev_err_probe(dev, PTR_ERR(priv->usb_extcon),
0590 "Failed to get extcon device");
0591
0592 priv->adc = devm_iio_channel_get(dev, "headset-detect");
0593 if (IS_ERR(priv->adc))
0594 return dev_err_probe(dev, PTR_ERR(priv->adc),
0595 "Failed to get ADC channel");
0596
0597 if (priv->adc->channel->type != IIO_VOLTAGE)
0598 return -EINVAL;
0599
0600 priv->gpio_headset_key = devm_gpiod_get(dev, "headset-key",
0601 GPIOD_IN);
0602 if (IS_ERR(priv->gpio_headset_key)) {
0603 dev_err(dev, "Failed to get headset key gpio");
0604 return PTR_ERR(priv->gpio_headset_key);
0605 }
0606
0607 priv->gpio_headset_detect = devm_gpiod_get(dev,
0608 "headset-detect", GPIOD_IN);
0609 if (IS_ERR(priv->gpio_headset_detect)) {
0610 dev_err(dev, "Failed to get headset detect gpio");
0611 return PTR_ERR(priv->gpio_headset_detect);
0612 }
0613
0614
0615 snd_soc_of_parse_card_name(card, "model");
0616
0617 ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
0618 if (ret < 0) {
0619 dev_err(dev, "Audio routing invalid/unspecified\n");
0620 return ret;
0621 }
0622
0623 aries_dai[1].dai_fmt = priv->variant->modem_dai_fmt;
0624
0625 cpu = of_get_child_by_name(dev->of_node, "cpu");
0626 if (!cpu)
0627 return -EINVAL;
0628
0629 codec = of_get_child_by_name(dev->of_node, "codec");
0630 if (!codec) {
0631 ret = -EINVAL;
0632 goto out;
0633 }
0634
0635 for_each_card_prelinks(card, i, dai_link) {
0636 dai_link->codecs->of_node = of_parse_phandle(codec,
0637 "sound-dai", 0);
0638 if (!dai_link->codecs->of_node) {
0639 ret = -EINVAL;
0640 goto out;
0641 }
0642 }
0643
0644
0645 aries_dai[0].cpus->of_node = of_parse_phandle(cpu,
0646 "sound-dai", 0);
0647 if (!aries_dai[0].cpus->of_node) {
0648 ret = -EINVAL;
0649 goto out;
0650 }
0651
0652 aries_dai[0].platforms->of_node = aries_dai[0].cpus->of_node;
0653
0654
0655 aries_dai[2].cpus->of_node = of_parse_phandle(cpu,
0656 "sound-dai", 1);
0657 if (!aries_dai[2].cpus->of_node) {
0658 ret = -EINVAL;
0659 goto out;
0660 }
0661
0662 ret = devm_snd_soc_register_component(dev, &aries_component,
0663 aries_ext_dai, ARRAY_SIZE(aries_ext_dai));
0664 if (ret < 0) {
0665 dev_err(dev, "Failed to register component: %d\n", ret);
0666 goto out;
0667 }
0668
0669 ret = devm_snd_soc_register_card(dev, card);
0670 if (ret)
0671 dev_err(dev, "snd_soc_register_card() failed:%d\n", ret);
0672
0673 out:
0674 of_node_put(cpu);
0675 of_node_put(codec);
0676
0677 return ret;
0678 }
0679
0680 static struct platform_driver aries_audio_driver = {
0681 .driver = {
0682 .name = "aries-audio-wm8994",
0683 .of_match_table = of_match_ptr(samsung_wm8994_of_match),
0684 .pm = &snd_soc_pm_ops,
0685 },
0686 .probe = aries_audio_probe,
0687 };
0688
0689 module_platform_driver(aries_audio_driver);
0690
0691 MODULE_DESCRIPTION("ALSA SoC ARIES WM8994");
0692 MODULE_LICENSE("GPL");
0693 MODULE_ALIAS("platform:aries-audio-wm8994");