staging: ozwpan: Add module parameter description
[linux/fpc-iii.git] / sound / soc / samsung / odroidx2_max98090.c
blob278edf9e2a87e24067ced858a6d92d672f40abde
1 /*
2 * Copyright (C) 2014 Samsung Electronics Co., Ltd.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
10 #include <linux/of.h>
11 #include <linux/module.h>
12 #include <sound/soc.h>
13 #include <sound/pcm_params.h>
14 #include "i2s.h"
16 struct odroidx2_drv_data {
17 const struct snd_soc_dapm_widget *dapm_widgets;
18 unsigned int num_dapm_widgets;
21 /* The I2S CDCLK output clock frequency for the MAX98090 codec */
22 #define MAX98090_MCLK 19200000
24 static int odroidx2_late_probe(struct snd_soc_card *card)
26 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
27 struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai;
28 int ret;
30 ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK,
31 SND_SOC_CLOCK_IN);
32 if (ret < 0)
33 return ret;
35 /* Set the cpu DAI configuration in order to use CDCLK */
36 return snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK,
37 0, SND_SOC_CLOCK_OUT);
40 static const struct snd_soc_dapm_widget odroidx2_dapm_widgets[] = {
41 SND_SOC_DAPM_HP("Headphone Jack", NULL),
42 SND_SOC_DAPM_MIC("Mic Jack", NULL),
43 SND_SOC_DAPM_MIC("DMIC", NULL),
46 static const struct snd_soc_dapm_widget odroidu3_dapm_widgets[] = {
47 SND_SOC_DAPM_HP("Headphone Jack", NULL),
48 SND_SOC_DAPM_SPK("Speakers", NULL),
51 static struct snd_soc_dai_link odroidx2_dai[] = {
53 .name = "MAX98090",
54 .stream_name = "MAX98090 PCM",
55 .codec_dai_name = "HiFi",
56 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
57 SND_SOC_DAIFMT_CBM_CFM,
61 static struct snd_soc_card odroidx2 = {
62 .owner = THIS_MODULE,
63 .dai_link = odroidx2_dai,
64 .num_links = ARRAY_SIZE(odroidx2_dai),
65 .fully_routed = true,
66 .late_probe = odroidx2_late_probe,
69 struct odroidx2_drv_data odroidx2_drvdata = {
70 .dapm_widgets = odroidx2_dapm_widgets,
71 .num_dapm_widgets = ARRAY_SIZE(odroidx2_dapm_widgets),
74 struct odroidx2_drv_data odroidu3_drvdata = {
75 .dapm_widgets = odroidu3_dapm_widgets,
76 .num_dapm_widgets = ARRAY_SIZE(odroidu3_dapm_widgets),
79 static const struct of_device_id odroidx2_audio_of_match[] = {
81 .compatible = "samsung,odroidx2-audio",
82 .data = &odroidx2_drvdata,
83 }, {
84 .compatible = "samsung,odroidu3-audio",
85 .data = &odroidu3_drvdata,
87 { },
89 MODULE_DEVICE_TABLE(of, odroidx2_audio_of_match);
91 static int odroidx2_audio_probe(struct platform_device *pdev)
93 struct device_node *snd_node = pdev->dev.of_node;
94 struct snd_soc_card *card = &odroidx2;
95 struct device_node *i2s_node, *codec_node;
96 struct odroidx2_drv_data *dd;
97 const struct of_device_id *of_id;
98 int ret;
100 of_id = of_match_node(odroidx2_audio_of_match, snd_node);
101 dd = (struct odroidx2_drv_data *)of_id->data;
103 card->num_dapm_widgets = dd->num_dapm_widgets;
104 card->dapm_widgets = dd->dapm_widgets;
106 card->dev = &pdev->dev;
108 ret = snd_soc_of_parse_card_name(card, "samsung,model");
109 if (ret < 0)
110 return ret;
112 ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
113 if (ret < 0)
114 return ret;
116 codec_node = of_parse_phandle(snd_node, "samsung,audio-codec", 0);
117 if (!codec_node) {
118 dev_err(&pdev->dev,
119 "Failed parsing samsung,i2s-codec property\n");
120 return -EINVAL;
123 i2s_node = of_parse_phandle(snd_node, "samsung,i2s-controller", 0);
124 if (!i2s_node) {
125 dev_err(&pdev->dev,
126 "Failed parsing samsung,i2s-controller property\n");
127 ret = -EINVAL;
128 goto err_put_codec_n;
131 odroidx2_dai[0].codec_of_node = codec_node;
132 odroidx2_dai[0].cpu_of_node = i2s_node;
133 odroidx2_dai[0].platform_of_node = i2s_node;
135 ret = snd_soc_register_card(card);
136 if (ret) {
137 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
138 ret);
139 goto err_put_i2s_n;
141 return 0;
143 err_put_i2s_n:
144 of_node_put(i2s_node);
145 err_put_codec_n:
146 of_node_put(codec_node);
147 return ret;
150 static int odroidx2_audio_remove(struct platform_device *pdev)
152 struct snd_soc_card *card = platform_get_drvdata(pdev);
154 snd_soc_unregister_card(card);
156 of_node_put((struct device_node *)odroidx2_dai[0].cpu_of_node);
157 of_node_put((struct device_node *)odroidx2_dai[0].codec_of_node);
159 return 0;
162 static struct platform_driver odroidx2_audio_driver = {
163 .driver = {
164 .name = "odroidx2-audio",
165 .owner = THIS_MODULE,
166 .of_match_table = odroidx2_audio_of_match,
167 .pm = &snd_soc_pm_ops,
169 .probe = odroidx2_audio_probe,
170 .remove = odroidx2_audio_remove,
172 module_platform_driver(odroidx2_audio_driver);
174 MODULE_AUTHOR("Chen Zhen <zhen1.chen@samsung.com>");
175 MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
176 MODULE_DESCRIPTION("ALSA SoC Odroid X2/U3 Audio Support");
177 MODULE_LICENSE("GPL v2");