aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/sound/armada-370db-audio.txt9
-rw-r--r--sound/soc/intel/mfld_machine.c51
-rw-r--r--sound/soc/kirkwood/Kconfig1
-rw-r--r--sound/soc/kirkwood/armada-370-db.c28
-rw-r--r--sound/soc/soc-io.c35
5 files changed, 60 insertions, 64 deletions
diff --git a/Documentation/devicetree/bindings/sound/armada-370db-audio.txt b/Documentation/devicetree/bindings/sound/armada-370db-audio.txt
index 3893b4d15a20..bf984d238620 100644
--- a/Documentation/devicetree/bindings/sound/armada-370db-audio.txt
+++ b/Documentation/devicetree/bindings/sound/armada-370db-audio.txt
@@ -11,14 +11,17 @@ Mandatory properties:
11 * marvell,audio-controller: a phandle that points to the audio 11 * marvell,audio-controller: a phandle that points to the audio
12 controller of the Armada 370 SoC. 12 controller of the Armada 370 SoC.
13 13
14 * marvell,audio-codec: a phandle that points to the analog audio 14 * marvell,audio-codec: a set of three phandles that points to:
15 codec connected to the Armada 370 SoC. 15
16 1/ the analog audio codec connected to the Armada 370 SoC
17 2/ the S/PDIF transceiver
18 3/ the S/PDIF receiver
16 19
17Example: 20Example:
18 21
19 sound { 22 sound {
20 compatible = "marvell,a370db-audio"; 23 compatible = "marvell,a370db-audio";
21 marvell,audio-controller = <&audio_controller>; 24 marvell,audio-controller = <&audio_controller>;
22 marvell,audio-codec = <&audio_codec>; 25 marvell,audio-codec = <&audio_codec &spdif_out &spdif_in>;
23 status = "okay"; 26 status = "okay";
24 }; 27 };
diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c
index 0cef32e9d402..031d78783fc8 100644
--- a/sound/soc/intel/mfld_machine.c
+++ b/sound/soc/intel/mfld_machine.c
@@ -53,6 +53,7 @@ enum soc_mic_bias_zones {
53 53
54static unsigned int hs_switch; 54static unsigned int hs_switch;
55static unsigned int lo_dac; 55static unsigned int lo_dac;
56static struct snd_soc_codec *mfld_codec;
56 57
57struct mfld_mc_private { 58struct mfld_mc_private {
58 void __iomem *int_base; 59 void __iomem *int_base;
@@ -100,8 +101,8 @@ static int headset_get_switch(struct snd_kcontrol *kcontrol,
100static int headset_set_switch(struct snd_kcontrol *kcontrol, 101static int headset_set_switch(struct snd_kcontrol *kcontrol,
101 struct snd_ctl_elem_value *ucontrol) 102 struct snd_ctl_elem_value *ucontrol)
102{ 103{
103 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 104 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
104 struct snd_soc_dapm_context *dapm = &codec->dapm; 105 struct snd_soc_dapm_context *dapm = &card->dapm;
105 106
106 if (ucontrol->value.integer.value[0] == hs_switch) 107 if (ucontrol->value.integer.value[0] == hs_switch)
107 return 0; 108 return 0;
@@ -127,10 +128,8 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
127 return 0; 128 return 0;
128} 129}
129 130
130static void lo_enable_out_pins(struct snd_soc_codec *codec) 131static void lo_enable_out_pins(struct snd_soc_dapm_context *dapm)
131{ 132{
132 struct snd_soc_dapm_context *dapm = &codec->dapm;
133
134 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL"); 133 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL");
135 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR"); 134 snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR");
136 snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL"); 135 snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL");
@@ -156,8 +155,8 @@ static int lo_get_switch(struct snd_kcontrol *kcontrol,
156static int lo_set_switch(struct snd_kcontrol *kcontrol, 155static int lo_set_switch(struct snd_kcontrol *kcontrol,
157 struct snd_ctl_elem_value *ucontrol) 156 struct snd_ctl_elem_value *ucontrol)
158{ 157{
159 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 158 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
160 struct snd_soc_dapm_context *dapm = &codec->dapm; 159 struct snd_soc_dapm_context *dapm = &card->dapm;
161 160
162 if (ucontrol->value.integer.value[0] == lo_dac) 161 if (ucontrol->value.integer.value[0] == lo_dac)
163 return 0; 162 return 0;
@@ -167,35 +166,35 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
167 /* we dont want to work with last state of lineout so just enable all 166 /* we dont want to work with last state of lineout so just enable all
168 * pins and then disable pins not required 167 * pins and then disable pins not required
169 */ 168 */
170 lo_enable_out_pins(codec); 169 lo_enable_out_pins(dapm);
171 170
172 switch (ucontrol->value.integer.value[0]) { 171 switch (ucontrol->value.integer.value[0]) {
173 case 0: 172 case 0:
174 pr_debug("set vibra path\n"); 173 pr_debug("set vibra path\n");
175 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT"); 174 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT");
176 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT"); 175 snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT");
177 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0); 176 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0);
178 break; 177 break;
179 178
180 case 1: 179 case 1:
181 pr_debug("set hs path\n"); 180 pr_debug("set hs path\n");
182 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones"); 181 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
183 snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT"); 182 snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
184 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22); 183 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22);
185 break; 184 break;
186 185
187 case 2: 186 case 2:
188 pr_debug("set spkr path\n"); 187 pr_debug("set spkr path\n");
189 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL"); 188 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL");
190 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR"); 189 snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR");
191 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44); 190 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44);
192 break; 191 break;
193 192
194 case 3: 193 case 3:
195 pr_debug("set null path\n"); 194 pr_debug("set null path\n");
196 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL"); 195 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL");
197 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR"); 196 snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR");
198 snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66); 197 snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66);
199 break; 198 break;
200 } 199 }
201 200
@@ -238,26 +237,11 @@ static void mfld_jack_check(unsigned int intr_status)
238 237
239static int mfld_init(struct snd_soc_pcm_runtime *runtime) 238static int mfld_init(struct snd_soc_pcm_runtime *runtime)
240{ 239{
241 struct snd_soc_codec *codec = runtime->codec; 240 struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
242 struct snd_soc_dapm_context *dapm = &codec->dapm;
243 int ret_val; 241 int ret_val;
244 242
245 /* Add jack sense widgets */ 243 mfld_codec = runtime->codec;
246 snd_soc_dapm_new_controls(dapm, mfld_widgets, ARRAY_SIZE(mfld_widgets));
247
248 /* Set up the map */
249 snd_soc_dapm_add_routes(dapm, mfld_map, ARRAY_SIZE(mfld_map));
250 244
251 /* always connected */
252 snd_soc_dapm_enable_pin(dapm, "Headphones");
253 snd_soc_dapm_enable_pin(dapm, "Mic");
254
255 ret_val = snd_soc_add_codec_controls(codec, mfld_snd_controls,
256 ARRAY_SIZE(mfld_snd_controls));
257 if (ret_val) {
258 pr_err("soc_add_controls failed %d", ret_val);
259 return ret_val;
260 }
261 /* default is earpiece pin, userspace sets it explcitly */ 245 /* default is earpiece pin, userspace sets it explcitly */
262 snd_soc_dapm_disable_pin(dapm, "Headphones"); 246 snd_soc_dapm_disable_pin(dapm, "Headphones");
263 /* default is lineout NC, userspace sets it explcitly */ 247 /* default is lineout NC, userspace sets it explcitly */
@@ -270,7 +254,7 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
270 snd_soc_dapm_disable_pin(dapm, "LINEINR"); 254 snd_soc_dapm_disable_pin(dapm, "LINEINR");
271 255
272 /* Headset and button jack detection */ 256 /* Headset and button jack detection */
273 ret_val = snd_soc_jack_new(codec, "Intel(R) MID Audio Jack", 257 ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack",
274 SND_JACK_HEADSET | SND_JACK_BTN_0 | 258 SND_JACK_HEADSET | SND_JACK_BTN_0 |
275 SND_JACK_BTN_1, &mfld_jack); 259 SND_JACK_BTN_1, &mfld_jack);
276 if (ret_val) { 260 if (ret_val) {
@@ -352,6 +336,13 @@ static struct snd_soc_card snd_soc_card_mfld = {
352 .owner = THIS_MODULE, 336 .owner = THIS_MODULE,
353 .dai_link = mfld_msic_dailink, 337 .dai_link = mfld_msic_dailink,
354 .num_links = ARRAY_SIZE(mfld_msic_dailink), 338 .num_links = ARRAY_SIZE(mfld_msic_dailink),
339
340 .controls = mfld_snd_controls,
341 .num_controls = ARRAY_SIZE(mfld_snd_controls),
342 .dapm_widgets = mfld_widgets,
343 .num_dapm_widgets = ARRAY_SIZE(mfld_widgets),
344 .dapm_routes = mfld_map,
345 .num_dapm_routes = ARRAY_SIZE(mfld_map),
355}; 346};
356 347
357static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev) 348static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev)
diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig
index 2dc3ecf34801..49f8437665de 100644
--- a/sound/soc/kirkwood/Kconfig
+++ b/sound/soc/kirkwood/Kconfig
@@ -10,6 +10,7 @@ config SND_KIRKWOOD_SOC_ARMADA370_DB
10 tristate "SoC Audio support for Armada 370 DB" 10 tristate "SoC Audio support for Armada 370 DB"
11 depends on SND_KIRKWOOD_SOC && (ARCH_MVEBU || COMPILE_TEST) && I2C 11 depends on SND_KIRKWOOD_SOC && (ARCH_MVEBU || COMPILE_TEST) && I2C
12 select SND_SOC_CS42L51 12 select SND_SOC_CS42L51
13 select SND_SOC_SPDIF
13 help 14 help
14 Say Y if you want to add support for SoC audio on 15 Say Y if you want to add support for SoC audio on
15 the Armada 370 Development Board. 16 the Armada 370 Development Board.
diff --git a/sound/soc/kirkwood/armada-370-db.c b/sound/soc/kirkwood/armada-370-db.c
index 977639b3ffde..c44333849259 100644
--- a/sound/soc/kirkwood/armada-370-db.c
+++ b/sound/soc/kirkwood/armada-370-db.c
@@ -67,6 +67,20 @@ static struct snd_soc_dai_link a370db_dai[] = {
67 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, 67 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
68 .ops = &a370db_ops, 68 .ops = &a370db_ops,
69}, 69},
70{
71 .name = "S/PDIF out",
72 .stream_name = "spdif-out",
73 .cpu_dai_name = "spdif",
74 .codec_dai_name = "dit-hifi",
75 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
76},
77{
78 .name = "S/PDIF in",
79 .stream_name = "spdif-in",
80 .cpu_dai_name = "spdif",
81 .codec_dai_name = "dir-hifi",
82 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
83},
70}; 84};
71 85
72static struct snd_soc_card a370db = { 86static struct snd_soc_card a370db = {
@@ -95,6 +109,20 @@ static int a370db_probe(struct platform_device *pdev)
95 of_parse_phandle(pdev->dev.of_node, 109 of_parse_phandle(pdev->dev.of_node,
96 "marvell,audio-codec", 0); 110 "marvell,audio-codec", 0);
97 111
112 a370db_dai[1].cpu_of_node = a370db_dai[0].cpu_of_node;
113 a370db_dai[1].platform_of_node = a370db_dai[0].cpu_of_node;
114
115 a370db_dai[1].codec_of_node =
116 of_parse_phandle(pdev->dev.of_node,
117 "marvell,audio-codec", 1);
118
119 a370db_dai[2].cpu_of_node = a370db_dai[0].cpu_of_node;
120 a370db_dai[2].platform_of_node = a370db_dai[0].cpu_of_node;
121
122 a370db_dai[2].codec_of_node =
123 of_parse_phandle(pdev->dev.of_node,
124 "marvell,audio-codec", 2);
125
98 return devm_snd_soc_register_card(card->dev, card); 126 return devm_snd_soc_register_card(card->dev, card);
99} 127}
100 128
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index 8aa086996866..260efc8466fc 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -23,21 +23,6 @@
23static int hw_write(struct snd_soc_codec *codec, unsigned int reg, 23static int hw_write(struct snd_soc_codec *codec, unsigned int reg,
24 unsigned int value) 24 unsigned int value)
25{ 25{
26 int ret;
27
28 if (!snd_soc_codec_volatile_register(codec, reg) &&
29 reg < codec->driver->reg_cache_size &&
30 !codec->cache_bypass) {
31 ret = snd_soc_cache_write(codec, reg, value);
32 if (ret < 0)
33 return -1;
34 }
35
36 if (codec->cache_only) {
37 codec->cache_sync = 1;
38 return 0;
39 }
40
41 return regmap_write(codec->control_data, reg, value); 26 return regmap_write(codec->control_data, reg, value);
42} 27}
43 28
@@ -46,23 +31,11 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
46 int ret; 31 int ret;
47 unsigned int val; 32 unsigned int val;
48 33
49 if (reg >= codec->driver->reg_cache_size || 34 ret = regmap_read(codec->control_data, reg, &val);
50 snd_soc_codec_volatile_register(codec, reg) || 35 if (ret == 0)
51 codec->cache_bypass) { 36 return val;
52 if (codec->cache_only) 37 else
53 return -1;
54
55 ret = regmap_read(codec->control_data, reg, &val);
56 if (ret == 0)
57 return val;
58 else
59 return -1;
60 }
61
62 ret = snd_soc_cache_read(codec, reg, &val);
63 if (ret < 0)
64 return -1; 38 return -1;
65 return val;
66} 39}
67 40
68/** 41/**