Skip to content

Commit 6dc41d8

Browse files
committed
ASoC: tegra: Add support for WM8962 and CPCAP
Merge series from Svyatoslav Ryhel <clamor95@gmail.com>: Add support for WM8962 and CPCAP codecs found in various Tegra devices.
2 parents 727d1a1 + 06dba25 commit 6dc41d8

7 files changed

Lines changed: 421 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-cpcap.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NVIDIA Tegra audio complex with CPCAP CODEC
8+
9+
maintainers:
10+
- Svyatoslav Ryhel <clamor95@gmail.com>
11+
12+
allOf:
13+
- $ref: nvidia,tegra-audio-common.yaml#
14+
15+
properties:
16+
compatible:
17+
items:
18+
- pattern: '^motorola,tegra-audio-cpcap(-[a-z0-9]+)+$'
19+
- const: nvidia,tegra-audio-cpcap
20+
21+
nvidia,audio-routing:
22+
$ref: /schemas/types.yaml#/definitions/non-unique-string-array
23+
description:
24+
A list of the connections between audio components. Each entry is a
25+
pair of strings, the first being the connection's sink, the second
26+
being the connection's source. Valid names for sources and sinks are
27+
the pins (documented in the binding document), and the jacks on the
28+
board.
29+
minItems: 2
30+
items:
31+
enum:
32+
# Board Connectors
33+
- Speakers
34+
- Int Spk
35+
- Earpiece
36+
- Int Mic
37+
- Headset Mic
38+
- Internal Mic 1
39+
- Internal Mic 2
40+
- Headphone
41+
- Headphones
42+
- Headphone Jack
43+
- Mic Jack
44+
45+
# CODEC Pins
46+
- MICR
47+
- HSMIC
48+
- EMUMIC
49+
- MICL
50+
- EXTR
51+
- EXTL
52+
- EP
53+
- SPKR
54+
- SPKL
55+
- LINER
56+
- LINEL
57+
- HSR
58+
- HSL
59+
- EMUR
60+
- EMUL
61+
62+
unevaluatedProperties: false
63+
64+
examples:
65+
- |
66+
#include <dt-bindings/clock/tegra20-car.h>
67+
#include <dt-bindings/soc/tegra-pmc.h>
68+
sound {
69+
compatible = "motorola,tegra-audio-cpcap-olympus",
70+
"nvidia,tegra-audio-cpcap";
71+
nvidia,model = "Motorola Atrix 4G (MB860) CPCAP";
72+
73+
nvidia,audio-routing =
74+
"Headphones", "HSR",
75+
"Headphones", "HSL",
76+
"Int Spk", "SPKR",
77+
"Int Spk", "SPKL",
78+
"Earpiece", "EP",
79+
"HSMIC", "Mic Jack",
80+
"MICR", "Internal Mic 1",
81+
"MICL", "Internal Mic 2";
82+
83+
nvidia,i2s-controller = <&tegra_i2s1>;
84+
nvidia,audio-codec = <&cpcap_audio>;
85+
86+
clocks = <&tegra_car TEGRA20_CLK_PLL_A>,
87+
<&tegra_car TEGRA20_CLK_PLL_A_OUT0>,
88+
<&tegra_car TEGRA20_CLK_CDEV1>;
89+
clock-names = "pll_a", "pll_a_out0", "mclk";
90+
};

Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max9808x.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ properties:
3535
items:
3636
enum:
3737
# Board Connectors
38+
- Speakers
3839
- Int Spk
40+
- Headphone
41+
- Headphones
3942
- Headphone Jack
4043
- Earpiece
4144
- Headset Mic
45+
- Mic Jack
46+
- Int Mic
4247
- Internal Mic 1
4348
- Internal Mic 2
4449

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-wm8962.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NVIDIA Tegra audio complex with WM8962 CODEC
8+
9+
maintainers:
10+
- Svyatoslav Ryhel <clamor95@gmail.com>
11+
12+
allOf:
13+
- $ref: nvidia,tegra-audio-common.yaml#
14+
15+
properties:
16+
compatible:
17+
items:
18+
- pattern: '^[a-z0-9]+,tegra-audio-wm8962(-[a-z0-9]+)+$'
19+
- const: nvidia,tegra-audio-wm8962
20+
21+
nvidia,audio-routing:
22+
$ref: /schemas/types.yaml#/definitions/non-unique-string-array
23+
description:
24+
A list of the connections between audio components. Each entry is a
25+
pair of strings, the first being the connection's sink, the second
26+
being the connection's source. Valid names for sources and sinks are
27+
the pins (documented in the binding document), and the jacks on the
28+
board.
29+
minItems: 2
30+
items:
31+
enum:
32+
# Board Connectors
33+
- Speakers
34+
- Int Spk
35+
- Earpiece
36+
- Int Mic
37+
- Headset Mic
38+
- Internal Mic 1
39+
- Internal Mic 2
40+
- Headphone
41+
- Headphones
42+
- Headphone Jack
43+
- Mic Jack
44+
45+
# CODEC Pins
46+
- IN1L
47+
- IN1R
48+
- IN2L
49+
- IN2R
50+
- IN3L
51+
- IN3R
52+
- IN4L
53+
- IN4R
54+
- DMICDAT
55+
- HPOUTL
56+
- HPOUTR
57+
- SPKOUT
58+
- SPKOUTL
59+
- SPKOUTR
60+
61+
required:
62+
- nvidia,i2s-controller
63+
64+
unevaluatedProperties: false
65+
66+
examples:
67+
- |
68+
#include <dt-bindings/clock/tegra30-car.h>
69+
#include <dt-bindings/soc/tegra-pmc.h>
70+
sound {
71+
compatible = "microsoft,tegra-audio-wm8962-surface-rt",
72+
"nvidia,tegra-audio-wm8962";
73+
nvidia,model = "Microsoft Surface RT WM8962";
74+
75+
nvidia,audio-routing =
76+
"Headphone Jack", "HPOUTR",
77+
"Headphone Jack", "HPOUTL",
78+
"Int Spk", "SPKOUTR",
79+
"Int Spk", "SPKOUTL";
80+
81+
nvidia,i2s-controller = <&tegra_i2s1>;
82+
nvidia,audio-codec = <&wm8962>;
83+
84+
clocks = <&tegra_car TEGRA30_CLK_PLL_A>,
85+
<&tegra_car TEGRA30_CLK_PLL_A_OUT0>,
86+
<&tegra_pmc TEGRA_PMC_CLK_OUT_1>;
87+
clock-names = "pll_a", "pll_a_out0", "mclk";
88+
};

sound/soc/tegra/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ config SND_SOC_TEGRA_WM8903
229229
boards using the WM8093 codec. Currently, the supported boards are
230230
Harmony, Ventana, Seaboard, Kaen, and Aebl.
231231

232+
config SND_SOC_TEGRA_WM8962
233+
tristate "SoC Audio support for Tegra boards using a WM8962 codec"
234+
depends on I2C && INPUT && GPIOLIB
235+
select SND_SOC_TEGRA_MACHINE_DRV
236+
select SND_SOC_WM8962
237+
help
238+
Say Y or M here if you want to add support for SoC audio on Tegra
239+
boards using the WM8962 codec. Currently, the supported boards are
240+
Microsoft Surface RT.
241+
232242
config SND_SOC_TEGRA_WM9712
233243
tristate "SoC Audio support for Tegra boards using a WM9712 codec"
234244
depends on GPIOLIB
@@ -294,6 +304,15 @@ config SND_SOC_TEGRA_SGTL5000
294304
boards using the SGTL5000 codec, such as Apalis T30, Apalis TK1 or
295305
Colibri T30.
296306

307+
config SND_SOC_TEGRA_CPCAP
308+
tristate "SoC Audio support for Tegra boards using a CPCAP codec"
309+
depends on I2C && GPIOLIB && MFD_CPCAP
310+
select SND_SOC_TEGRA_MACHINE_DRV
311+
select SND_SOC_CPCAP
312+
help
313+
Say Y or M here if you want to add support for SoC audio on Tegra
314+
boards using the CPCAP codec, such as Motorola Atrix 4G or Droid X2.
315+
297316
endif
298317

299318
endmenu

sound/soc/tegra/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ obj-$(CONFIG_SND_SOC_TEGRA210_OPE) += snd-soc-tegra210-ope.o
4343

4444
# Tegra machine Support
4545
snd-soc-tegra-wm8903-y := tegra_wm8903.o
46+
snd-soc-tegra-wm8962-y := tegra_wm8962.o
4647
snd-soc-tegra-machine-y := tegra_asoc_machine.o
4748
snd-soc-tegra-audio-graph-card-y := tegra_audio_graph_card.o
4849

4950
obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o
51+
obj-$(CONFIG_SND_SOC_TEGRA_WM8962) += snd-soc-tegra-wm8962.o
5052
obj-$(CONFIG_SND_SOC_TEGRA_MACHINE_DRV) += snd-soc-tegra-machine.o
5153
obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += snd-soc-tegra-audio-graph-card.o

sound/soc/tegra/tegra_asoc_machine.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ static unsigned int tegra_machine_mclk_rate_6mhz(unsigned int srate)
287287
return mclk;
288288
}
289289

290+
static unsigned int tegra_machine_mclk_rate_cpcap(unsigned int srate)
291+
{
292+
unsigned int mclk;
293+
294+
switch (srate) {
295+
case 11025:
296+
case 22050:
297+
case 44100:
298+
case 88200:
299+
mclk = 26000000;
300+
break;
301+
default:
302+
mclk = 256 * srate;
303+
break;
304+
}
305+
306+
return mclk;
307+
}
308+
290309
static int tegra_machine_hw_params(struct snd_pcm_substream *substream,
291310
struct snd_pcm_hw_params *params)
292311
{
@@ -985,6 +1004,38 @@ static const struct tegra_asoc_data tegra_rt5631_data = {
9851004
.add_hp_jack = true,
9861005
};
9871006

1007+
/* CPCAP machine */
1008+
1009+
SND_SOC_DAILINK_DEFS(cpcap_hifi,
1010+
DAILINK_COMP_ARRAY(COMP_EMPTY()),
1011+
DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cpcap-hifi")),
1012+
DAILINK_COMP_ARRAY(COMP_EMPTY()));
1013+
1014+
static struct snd_soc_dai_link tegra_cpcap_dai = {
1015+
.name = "CPCAP",
1016+
.stream_name = "CPCAP PCM",
1017+
.init = tegra_asoc_machine_init,
1018+
.dai_fmt = SND_SOC_DAIFMT_I2S |
1019+
SND_SOC_DAIFMT_NB_NF |
1020+
SND_SOC_DAIFMT_CBP_CFP,
1021+
SND_SOC_DAILINK_REG(cpcap_hifi),
1022+
};
1023+
1024+
static struct snd_soc_card snd_soc_tegra_cpcap = {
1025+
.components = "codec:cpcap",
1026+
.dai_link = &tegra_cpcap_dai,
1027+
.num_links = 1,
1028+
.fully_routed = true,
1029+
};
1030+
1031+
static const struct tegra_asoc_data tegra_cpcap_data = {
1032+
.mclk_rate = tegra_machine_mclk_rate_cpcap,
1033+
.card = &snd_soc_tegra_cpcap,
1034+
.add_common_dapm_widgets = true,
1035+
.add_common_controls = true,
1036+
.add_common_snd_ops = true,
1037+
};
1038+
9881039
static const struct of_device_id tegra_machine_of_match[] = {
9891040
{ .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data },
9901041
{ .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data },
@@ -997,6 +1048,7 @@ static const struct of_device_id tegra_machine_of_match[] = {
9971048
{ .compatible = "nvidia,tegra-audio-rt5640", .data = &tegra_rt5640_data },
9981049
{ .compatible = "nvidia,tegra-audio-alc5632", .data = &tegra_rt5632_data },
9991050
{ .compatible = "nvidia,tegra-audio-rt5631", .data = &tegra_rt5631_data },
1051+
{ .compatible = "nvidia,tegra-audio-cpcap", .data = &tegra_cpcap_data },
10001052
{},
10011053
};
10021054
MODULE_DEVICE_TABLE(of, tegra_machine_of_match);

0 commit comments

Comments
 (0)