aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2014-07-04 09:13:45 -0400
committerMark Brown <broonie@linaro.org>2014-07-09 04:34:18 -0400
commita40712a3e604bd59c7d3bdbabc9aec6208102783 (patch)
tree9679d2eb1adfb3c91eccef4d2b3867dba39b9c89
parent83e3fbd6f3949d21c178a76af72cdfb5be0274ee (diff)
ASoC: samsung: Add machine driver for Odroid X2/U3
This patch adds the sound subsystem driver for Odroid-X2 and Odroid-U3 boards. The codec works in I2S master mode; there are two separate audio routing paths defined, as there are differences in the signal routing between the X2 and U3 boards, i.e. U3 uses single jack for headphones and microphone. Signed-off-by: Chen Zhen <zhen1.chen@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/samsung/Kconfig8
-rw-r--r--sound/soc/samsung/Makefile2
-rw-r--r--sound/soc/samsung/odroidx2_max98090.c177
3 files changed, 187 insertions, 0 deletions
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 3be49cd2e984..333d645cea87 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -237,3 +237,11 @@ config SND_SOC_SNOW
237 help 237 help
238 Say Y if you want to add audio support for various Snow 238 Say Y if you want to add audio support for various Snow
239 boards based on Exynos5 series of SoCs. 239 boards based on Exynos5 series of SoCs.
240
241config SND_SOC_ODROIDX2
242 tristate "Audio support for Odroid-X2 and Odroid-U3"
243 depends on SND_SOC_SAMSUNG
244 select SND_SOC_MAX98090
245 select SND_SAMSUNG_I2S
246 help
247 Say Y here to enable audio support for the Odroid-X2/U3.
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index 6469199acea5..e8d9ccdc41fd 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -44,6 +44,7 @@ snd-soc-tobermory-objs := tobermory.o
44snd-soc-lowland-objs := lowland.o 44snd-soc-lowland-objs := lowland.o
45snd-soc-littlemill-objs := littlemill.o 45snd-soc-littlemill-objs := littlemill.o
46snd-soc-bells-objs := bells.o 46snd-soc-bells-objs := bells.o
47snd-soc-odroidx2-max98090-objs := odroidx2_max98090.o
47 48
48obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o 49obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o
49obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o 50obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
@@ -69,3 +70,4 @@ obj-$(CONFIG_SND_SOC_TOBERMORY) += snd-soc-tobermory.o
69obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o 70obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o
70obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o 71obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o
71obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o 72obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o
73obj-$(CONFIG_SND_SOC_ODROIDX2) += snd-soc-odroidx2-max98090.o
diff --git a/sound/soc/samsung/odroidx2_max98090.c b/sound/soc/samsung/odroidx2_max98090.c
new file mode 100644
index 000000000000..278edf9e2a87
--- /dev/null
+++ b/sound/soc/samsung/odroidx2_max98090.c
@@ -0,0 +1,177 @@
1/*
2 * Copyright (C) 2014 Samsung Electronics Co., Ltd.
3 *
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 */
9
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"
15
16struct odroidx2_drv_data {
17 const struct snd_soc_dapm_widget *dapm_widgets;
18 unsigned int num_dapm_widgets;
19};
20
21/* The I2S CDCLK output clock frequency for the MAX98090 codec */
22#define MAX98090_MCLK 19200000
23
24static int odroidx2_late_probe(struct snd_soc_card *card)
25{
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;
29
30 ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK,
31 SND_SOC_CLOCK_IN);
32 if (ret < 0)
33 return ret;
34
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);
38}
39
40static 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),
44};
45
46static const struct snd_soc_dapm_widget odroidu3_dapm_widgets[] = {
47 SND_SOC_DAPM_HP("Headphone Jack", NULL),
48 SND_SOC_DAPM_SPK("Speakers", NULL),
49};
50
51static struct snd_soc_dai_link odroidx2_dai[] = {
52 {
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,
58 }
59};
60
61static 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,
67};
68
69struct odroidx2_drv_data odroidx2_drvdata = {
70 .dapm_widgets = odroidx2_dapm_widgets,
71 .num_dapm_widgets = ARRAY_SIZE(odroidx2_dapm_widgets),
72};
73
74struct odroidx2_drv_data odroidu3_drvdata = {
75 .dapm_widgets = odroidu3_dapm_widgets,
76 .num_dapm_widgets = ARRAY_SIZE(odroidu3_dapm_widgets),
77};
78
79static const struct of_device_id odroidx2_audio_of_match[] = {
80 {
81 .compatible = "samsung,odroidx2-audio",
82 .data = &odroidx2_drvdata,
83 }, {
84 .compatible = "samsung,odroidu3-audio",
85 .data = &odroidu3_drvdata,
86 },
87 { },
88};
89MODULE_DEVICE_TABLE(of, odroidx2_audio_of_match);
90
91static int odroidx2_audio_probe(struct platform_device *pdev)
92{
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;
99
100 of_id = of_match_node(odroidx2_audio_of_match, snd_node);
101 dd = (struct odroidx2_drv_data *)of_id->data;
102
103 card->num_dapm_widgets = dd->num_dapm_widgets;
104 card->dapm_widgets = dd->dapm_widgets;
105
106 card->dev = &pdev->dev;
107
108 ret = snd_soc_of_parse_card_name(card, "samsung,model");
109 if (ret < 0)
110 return ret;
111
112 ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
113 if (ret < 0)
114 return ret;
115
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;
121 }
122
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;
129 }
130
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;
134
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;
140 }
141 return 0;
142
143err_put_i2s_n:
144 of_node_put(i2s_node);
145err_put_codec_n:
146 of_node_put(codec_node);
147 return ret;
148}
149
150static int odroidx2_audio_remove(struct platform_device *pdev)
151{
152 struct snd_soc_card *card = platform_get_drvdata(pdev);
153
154 snd_soc_unregister_card(card);
155
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);
158
159 return 0;
160}
161
162static 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,
168 },
169 .probe = odroidx2_audio_probe,
170 .remove = odroidx2_audio_remove,
171};
172module_platform_driver(odroidx2_audio_driver);
173
174MODULE_AUTHOR("Chen Zhen <zhen1.chen@samsung.com>");
175MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
176MODULE_DESCRIPTION("ALSA SoC Odroid X2/U3 Audio Support");
177MODULE_LICENSE("GPL v2");