Add support for audiocodec in Allwinner A64
Subsystems (5)
v8 cover Add support for audiocodec in Allwinner A64
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(-)
Signature · 1 line
2.19.1
PATCH v8 1/7 ASoC: dt-bindings: add regulator property to simple amplifier
Amplifier may have associated regulator, so add a property for it.
--- Documentation/devicetree/bindings/sound/simple-amplifier.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/sound/simple-amplifier.txt +5 -0
@@ -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>; };
Signature · 1 line
2.19.1
Mark Brown
maintainerRe: [PATCH v8 1/7] ASoC: dt-bindings: add regulator property to simple amplifier
Documentation/devicetree/bindings/sound/simple-amplifier.txt Required properties: · line 10
Quoted 4 lines · Vasily Khoruzhick
Documentation/devicetree/bindings/sound/simple-amplifier.txt +4
-0+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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181126/17bc6e82/attachment.sig>
PATCH v8 2/7 ASoC: simple-amplifier: add VCC regulator widget
In reply to Vasily KhoruzhickAmplifier may have assosicated regulator, so add a widget for it and appropriate route.
--- sound/soc/codecs/simple-amplifier.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/simple-amplifier.c +4 -0
@@ -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" }, };
Signature · 1 line
2.19.1
PATCH v8 3/7 ASoC: dt-bindings: make enable-gpio optional for simple amplifier
In reply to Vasily KhoruzhickAmplifier may have no enable GPIO, so make this property optional
--- Documentation/devicetree/bindings/sound/simple-amplifier.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/simple-amplifier.txt +1 -1
@@ -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
Signature · 1 line
2.19.1
Re: [PATCH v8 3/7] ASoC: dt-bindings: make enable-gpio optional for simple amplifier
Quoted 7 lines · Vasily Khoruzhick
Amplifier may have no enable GPIO, so make this property optional
Signed-off-by Vasily Khoruzhick <[email protected]>--- Documentation/devicetree/bindings/sound/simple-amplifier.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v8 4/7 ASoC: simple-amplifier: make enable-gpio optional
In reply to Vasily KhoruzhickAmplifier may have no enable GPIO, so make this property optional.
--- sound/soc/codecs/simple-amplifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/simple-amplifier.c +2 -1
@@ -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 )
Signature · 1 line
2.19.1
PATCH v8 5/7 arm64: dts: allwinner: a64: add nodes necessary for analog sound support
In reply to Vasily KhoruzhickAdd nodes for i2s, digital and analog parts of audiocodec on A64
--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +54 -0
@@ -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 at 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 at 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 at 1c28000 { compatible = "snps,dw-apb-uart"; reg = <0x01c28000 0x400>;
@@ -902,6 +950,12 @@ #reset-cells = <1>; }; + codec_analog: codec-analog at 1f015c0 { + compatible = "allwinner,sun50i-a64-codec-analog"; + reg = <0x01f015c0 0x4>; + status = "disabled"; + }; + r_i2c: i2c at 1f02400 { compatible = "allwinner,sun50i-a64-i2c", "allwinner,sun6i-a31-i2c";
Signature · 1 line
2.19.1
PATCH v8 6/7 arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine
In reply to Vasily KhoruzhickThis commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.
--- .../boot/dts/allwinner/sun50i-a64-pine64.dts | 35 +++++++++++++++++++ .../allwinner/sun50i-a64-sopine-baseboard.dts | 35 +++++++++++++++++++ 2 files changed, 70 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +35 -0
@@ -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";
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +35 -0
@@ -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>;
Signature · 1 line
2.19.1
PATCH v8 7/7 arm64: dts: allwinner: a64: enable sound on Pinebook
In reply to Vasily KhoruzhickThis commit enables I2S, digital and analog parts of audiocodec on Pinebook
--- .../dts/allwinner/sun50i-a64-pinebook.dts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +53 -0
@@ -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>;
Signature · 1 line
2.19.1
Re: [PATCH v8 7/7] arm64: dts: allwinner: a64: enable sound on Pinebook
Quoted 14 lines · Vasily Khoruzhick
This commit enables I2S, digital and analog parts of audiocodec on Pinebook
Signed-off-by Vasily Khoruzhick <[email protected]>--- .../dts/allwinner/sun50i-a64-pinebook.dts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +0
-0
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 61
Quoted 9 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +6
-0@@ -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/ca6360b9788b8495daff658280845683ff401441
Driver patch:
https://github.com/wens/linux/commit/17a91e45d62d370bb2350753be6db86eaf824a5e
DT fixup:
https://github.com/wens/linux/commit/df7c2b26d1a66790237ca25e8cc135c237cd8236
As mentioned on IRC, I will pick up this series incorporating some extra changes.
Thanks
ChenYu
Quoted 67 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +47
-1reg_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