[alsa-devel] [PATCH v8 0/7] Add support for audiocodec in Allwinner A64
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
v2: - Use simple-amplifier for speaker amp on Pinebook - Rename sun50i-a64-i2s to sun50i-a64-codec-i2s to preserve compatible string for other 3 I2S modules in A64 in case if there's any incompatibility with H3 v3: - renamed sunxi-adda-pr-regmap to sun8i-adda-pr-regmap - use ilog2() to calculate reg value for LRCK div instead of using a table v4: - dts: don't use 'Mic' and 'Headset Mic' widgets from sun8i-codec, define our board-level widgets instead. v5: - collect all the tags v6: - driver patches has been merged through ASoC tree - rebase onto 4.20-rc1 - Drop 'Speaker' from routes on sopine and pine64, they don't have speaker. v7: - drop 'Mic' and 'Headset Mic' from dtsi - move AIF1 Slot 0 ADC to ADC route to sun8i-codec - drop BIAS routes for Pine64 and SoPine v8 - drop merged patches - add regulator property for simple amplifier, make enable-gpio optional - add regulator to speaker amp, introduce headphone amp
Vasily Khoruzhick (7): ASoC: dt-bindings: add regulator property to simple amplifier ASoC: simple-amplifier: add VCC regulator widget ASoC: dt-bindings: make enable-gpio optional for simple amplifier ASoC: simple-amplifier: make enable-gpio optional arm64: dts: allwinner: a64: add nodes necessary for analog sound support arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine arm64: dts: allwinner: a64: enable sound on Pinebook
.../bindings/sound/simple-amplifier.txt | 5 ++ .../boot/dts/allwinner/sun50i-a64-pine64.dts | 35 ++++++++++++ .../dts/allwinner/sun50i-a64-pinebook.dts | 53 ++++++++++++++++++ .../allwinner/sun50i-a64-sopine-baseboard.dts | 35 ++++++++++++ arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 54 +++++++++++++++++++ sound/soc/codecs/simple-amplifier.c | 7 ++- 6 files changed, 188 insertions(+), 1 deletion(-)
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
Amplifier may have associated regulator, so add a property for it.
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- Documentation/devicetree/bindings/sound/simple-amplifier.txt | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/simple-amplifier.txt b/Documentation/devicetree/bindings/sound/simple-amplifier.txt index 8647edae7af0..7182ac4f1e65 100644 --- a/Documentation/devicetree/bindings/sound/simple-amplifier.txt +++ b/Documentation/devicetree/bindings/sound/simple-amplifier.txt @@ -4,9 +4,14 @@ Required properties: - compatible : "dioo,dio2125" or "simple-audio-amplifier" - enable-gpios : the gpio connected to the enable pin of the simple amplifier
+Optional properties: +- VCC-supply : power supply for the device, as covered + in Documentation/devicetree/bindings/regulator/regulator.txt + Example:
amp: analog-amplifier { compatible = "simple-audio-amplifier"; + VCC-supply = <®ulator>; enable-gpios = <&gpio GPIOH_3 0>; };
![](https://secure.gravatar.com/avatar/d930951cb00393ecf9c3db3a56d78fa9.jpg?s=120&d=mm&r=g)
On Tue, Nov 20, 2018 at 09:17:46PM -0800, Vasily Khoruzhick wrote:
+Optional properties: +- VCC-supply : power supply for the device, as covered
in Documentation/devicetree/bindings/regulator/regulator.txt
As ever supplies shouldn't be marked as optional unless they can be missing even though they can safely be omitted on Linux. This one's a bit odd in that the name is going to depend on which amp is connected but still it's probably best that we do that for consistency.
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
Amplifier may have assosicated regulator, so add a widget for it and appropriate route.
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- sound/soc/codecs/simple-amplifier.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c index 85524acf3e9c..c07e8a80b4b7 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -19,6 +19,7 @@
#include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/regulator/consumer.h> #include <sound/soc.h>
#define DRV_NAME "simple-amplifier" @@ -58,11 +59,14 @@ static const struct snd_soc_dapm_widget simple_amp_dapm_widgets[] = { (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)), SND_SOC_DAPM_OUTPUT("OUTL"), SND_SOC_DAPM_OUTPUT("OUTR"), + SND_SOC_DAPM_REGULATOR_SUPPLY("VCC", 20, 0), };
static const struct snd_soc_dapm_route simple_amp_dapm_routes[] = { { "DRV", NULL, "INL" }, { "DRV", NULL, "INR" }, + { "OUTL", NULL, "VCC" }, + { "OUTR", NULL, "VCC" }, { "OUTL", NULL, "DRV" }, { "OUTR", NULL, "DRV" }, };
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
Amplifier may have no enable GPIO, so make this property optional
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- Documentation/devicetree/bindings/sound/simple-amplifier.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/simple-amplifier.txt b/Documentation/devicetree/bindings/sound/simple-amplifier.txt index 7182ac4f1e65..b1b097cc9b68 100644 --- a/Documentation/devicetree/bindings/sound/simple-amplifier.txt +++ b/Documentation/devicetree/bindings/sound/simple-amplifier.txt @@ -2,9 +2,9 @@ Simple Amplifier Audio Driver
Required properties: - compatible : "dioo,dio2125" or "simple-audio-amplifier" -- enable-gpios : the gpio connected to the enable pin of the simple amplifier
Optional properties: +- enable-gpios : the gpio connected to the enable pin of the simple amplifier - VCC-supply : power supply for the device, as covered in Documentation/devicetree/bindings/regulator/regulator.txt
![](https://secure.gravatar.com/avatar/ee1e7f40e65828eb76184367a6353704.jpg?s=120&d=mm&r=g)
On Tue, 20 Nov 2018 21:17:48 -0800, Vasily Khoruzhick wrote:
Amplifier may have no enable GPIO, so make this property optional
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com
Documentation/devicetree/bindings/sound/simple-amplifier.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Rob Herring robh@kernel.org
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
Amplifier may have no enable GPIO, so make this property optional.
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- sound/soc/codecs/simple-amplifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c index c07e8a80b4b7..351aa55c384e 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -89,7 +89,8 @@ static int simple_amp_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, priv);
- priv->gpiod_enable = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); + priv->gpiod_enable = devm_gpiod_get_optional(dev, "enable", + GPIOD_OUT_LOW); if (IS_ERR(priv->gpiod_enable)) { err = PTR_ERR(priv->gpiod_enable); if (err != -EPROBE_DEFER)
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
Add nodes for i2s, digital and analog parts of audiocodec on A64
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index f3a66f888205..44fce4b0ac49 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi @@ -155,6 +155,30 @@ method = "smc"; };
+ sound: sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "sun50i-a64-audio"; + simple-audio-card,format = "i2s"; + simple-audio-card,frame-master = <&cpudai>; + simple-audio-card,bitclock-master = <&cpudai>; + simple-audio-card,mclk-fs = <512>; + simple-audio-card,aux-devs = <&codec_analog>; + simple-audio-card,routing = + "Left DAC", "AIF1 Slot 0 Left", + "Right DAC", "AIF1 Slot 0 Right", + "AIF1 Slot 0 Left ADC", "Left ADC", + "AIF1 Slot 0 Right ADC", "Right ADC"; + status = "disabled"; + + cpudai: simple-audio-card,cpu { + sound-dai = <&dai>; + }; + + link_codec: simple-audio-card,codec { + sound-dai = <&codec>; + }; + }; + sound_spdif { compatible = "simple-audio-card"; simple-audio-card,name = "On-board SPDIF"; @@ -665,6 +689,30 @@ status = "disabled"; };
+ dai: dai@1c22c00 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun50i-a64-codec-i2s"; + reg = <0x01c22c00 0x200>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>; + clock-names = "apb", "mod"; + resets = <&ccu RST_BUS_CODEC>; + reset-names = "rst"; + dmas = <&dma 15>, <&dma 15>; + dma-names = "rx", "tx"; + status = "disabled"; + }; + + codec: codec@1c22e00 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun8i-a33-codec"; + reg = <0x01c22e00 0x600>; + interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>; + clock-names = "bus", "mod"; + status = "disabled"; + }; + uart0: serial@1c28000 { compatible = "snps,dw-apb-uart"; reg = <0x01c28000 0x400>; @@ -902,6 +950,12 @@ #reset-cells = <1>; };
+ codec_analog: codec-analog@1f015c0 { + compatible = "allwinner,sun50i-a64-codec-analog"; + reg = <0x01f015c0 0x4>; + status = "disabled"; + }; + r_i2c: i2c@1f02400 { compatible = "allwinner,sun50i-a64-i2c", "allwinner,sun6i-a31-i2c";
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
This commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- .../boot/dts/allwinner/sun50i-a64-pine64.dts | 35 +++++++++++++++++++ .../allwinner/sun50i-a64-sopine-baseboard.dts | 35 +++++++++++++++++++ 2 files changed, 70 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts index c077b6c1f458..30d0743d0d79 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts @@ -73,6 +73,24 @@ }; }; }; + + headphone_amp: headphone_amp { + compatible = "simple-audio-amplifier"; + VCC-supply = <®_eldo1>; + sound-name-prefix = "HP"; + }; +}; + +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; };
&de { @@ -259,6 +277,23 @@ vcc-hdmi-supply = <®_dldo1>; };
+&sound { + simple-audio-card,aux-devs = <&codec_analog>, <&headphone_amp>; + simple-audio-card,widgets = "Microphone", "Microphone Jack", + "Headphone", "Headphone Jack"; + simple-audio-card,routing = + "Left DAC", "AIF1 Slot 0 Left", + "Right DAC", "AIF1 Slot 0 Right", + "HP INL", "HP", + "HP INR", "HP", + "Headphone Jack", "HP OUTL", + "Headphone Jack", "HP OUTR", + "AIF1 Slot 0 Left ADC", "Left ADC", + "AIF1 Slot 0 Right ADC", "Right ADC", + "MIC2", "Microphone Jack"; + status = "okay"; +}; + /* On Euler connector */ &spdif { status = "disabled"; diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts index 53fcc9098df3..81d85ad127a2 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts @@ -72,6 +72,12 @@ }; };
+ headphone_amp: headphone_amp { + compatible = "simple-audio-amplifier"; + VCC-supply = <®_eldo1>; + sound-name-prefix = "HP"; + }; + reg_vcc1v8: vcc1v8 { compatible = "regulator-fixed"; regulator-name = "vcc1v8"; @@ -80,6 +86,18 @@ }; };
+&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &de { status = "okay"; }; @@ -164,6 +182,23 @@ vcc-hdmi-supply = <®_dldo1>; };
+&sound { + simple-audio-card,aux-devs = <&codec_analog>, <&headphone_amp>; + simple-audio-card,widgets = "Microphone", "Microphone Jack", + "Headphone", "Headphone Jack"; + simple-audio-card,routing = + "Left DAC", "AIF1 Slot 0 Left", + "Right DAC", "AIF1 Slot 0 Right", + "HP INL", "HP", + "HP INR", "HP", + "Headphone Jack", "HP OUTL", + "Headphone Jack", "HP OUTR", + "AIF1 Slot 0 Left ADC", "Left ADC", + "AIF1 Slot 0 Right ADC", "Right ADC", + "MIC2", "Microphone Jack"; + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>;
![](https://secure.gravatar.com/avatar/39a3056f444af794ebea9d401c4084d1.jpg?s=120&d=mm&r=g)
This commit enables I2S, digital and analog parts of audiocodec on Pinebook
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com --- .../dts/allwinner/sun50i-a64-pinebook.dts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts index 77fac84797e9..cecfa7ea90b2 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts @@ -53,6 +53,12 @@ }; };
+ headphone_amp: headphone_amp { + compatible = "simple-audio-amplifier"; + VCC-supply = <®_eldo1>; + sound-name-prefix = "HP"; + }; + reg_vcc3v3: vcc3v3 { compatible = "regulator-fixed"; regulator-name = "vcc3v3"; @@ -64,6 +70,26 @@ compatible = "mmc-pwrseq-simple"; reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */ }; + + speaker_amp: speaker_amp { + compatible = "simple-audio-amplifier"; + VCC-supply = <®_ldo_io0>; + enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */ + sound-name-prefix = "SPEAKER"; + }; + +}; + +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; };
&ehci0 { @@ -267,6 +293,33 @@ vcc-hdmi-supply = <®_dldo1>; };
+&sound { + status = "okay"; + simple-audio-card,aux-devs = <&codec_analog>, <&headphone_amp>, + <&speaker_amp>; + simple-audio-card,widgets = "Microphone", "Internal Microphone Left", + "Microphone", "Internal Microphone Right", + "Headphone", "Headphone Jack", + "Speaker", "Internal Speaker"; + simple-audio-card,routing = + "Left DAC", "AIF1 Slot 0 Left", + "Right DAC", "AIF1 Slot 0 Right", + "SPEAKER INL", "LINEOUT", + "SPEAKER INR", "LINEOUT", + "Internal Speaker", "SPEAKER OUTL", + "Internal Speaker", "SPEAKER OUTR", + "HP INL", "HP", + "HP INR", "HP", + "Headphone Jack", "HP OUTL", + "Headphone Jack", "HP OUTR", + "AIF1 Slot 0 Left ADC", "Left ADC", + "AIF1 Slot 0 Right ADC", "Right ADC", + "Internal Microphone Left", "MBIAS", + "MIC1", "Internal Microphone Left", + "Internal Microphone Right", "HBIAS", + "MIC2", "Internal Microphone Right"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>;
![](https://secure.gravatar.com/avatar/53e17915a0ebda94220596c4137b83fa.jpg?s=120&d=mm&r=g)
On Wed, Nov 21, 2018 at 1:19 PM Vasily Khoruzhick anarsoul@gmail.com wrote:
This commit enables I2S, digital and analog parts of audiocodec on Pinebook
Signed-off-by: Vasily Khoruzhick anarsoul@gmail.com
.../dts/allwinner/sun50i-a64-pinebook.dts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts index 77fac84797e9..cecfa7ea90b2 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts @@ -53,6 +53,12 @@ }; };
headphone_amp: headphone_amp {
compatible = "simple-audio-amplifier";
VCC-supply = <®_eldo1>;
sound-name-prefix = "HP";
};
This is part of the analog side of the codec. Representing it as a standalone amp is inaccurate. Here's what I have to add it to the codec:
DT binding patch: https://github.com/wens/linux/commit/ca6360b9788b8495daff658280845683ff40144...
Driver patch: https://github.com/wens/linux/commit/17a91e45d62d370bb2350753be6db86eaf824a5...
DT fixup: https://github.com/wens/linux/commit/df7c2b26d1a66790237ca25e8cc135c237cd823...
As mentioned on IRC, I will pick up this series incorporating some extra changes.
Thanks ChenYu
reg_vcc3v3: vcc3v3 { compatible = "regulator-fixed"; regulator-name = "vcc3v3";
@@ -64,6 +70,26 @@ compatible = "mmc-pwrseq-simple"; reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */ };
speaker_amp: speaker_amp {
compatible = "simple-audio-amplifier";
VCC-supply = <®_ldo_io0>;
enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */
sound-name-prefix = "SPEAKER";
};
+};
+&codec {
status = "okay";
+};
+&codec_analog {
status = "okay";
+};
+&dai {
status = "okay";
};
&ehci0 { @@ -267,6 +293,33 @@ vcc-hdmi-supply = <®_dldo1>; };
+&sound {
status = "okay";
simple-audio-card,aux-devs = <&codec_analog>, <&headphone_amp>,
<&speaker_amp>;
simple-audio-card,widgets = "Microphone", "Internal Microphone Left",
"Microphone", "Internal Microphone Right",
"Headphone", "Headphone Jack",
"Speaker", "Internal Speaker";
simple-audio-card,routing =
"Left DAC", "AIF1 Slot 0 Left",
"Right DAC", "AIF1 Slot 0 Right",
"SPEAKER INL", "LINEOUT",
"SPEAKER INR", "LINEOUT",
"Internal Speaker", "SPEAKER OUTL",
"Internal Speaker", "SPEAKER OUTR",
"HP INL", "HP",
"HP INR", "HP",
"Headphone Jack", "HP OUTL",
"Headphone Jack", "HP OUTR",
"AIF1 Slot 0 Left ADC", "Left ADC",
"AIF1 Slot 0 Right ADC", "Right ADC",
"Internal Microphone Left", "MBIAS",
"MIC1", "Internal Microphone Left",
"Internal Microphone Right", "HBIAS",
"MIC2", "Internal Microphone Right";
+};
&uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>; -- 2.19.1
participants (4)
-
Chen-Yu Tsai
-
Mark Brown
-
Rob Herring
-
Vasily Khoruzhick