ASoC: sunxi: Add support for audio codec in A23/H3 SoCs
Subsystems (5)
v2 cover ASoC: sunxi: Add support for audio codec in A23/H3 SoCs
Hi everyone,
This is v2 of my Allwinner A23 and H3 audio codec support series.
Changes since v1:
- Use DEFINE_RES_MEM for the analog path controls block resources.
- Added Rob's ack.
This series adds support for the audio codec found in Allwinner A23 and H3 SoCs. The design and data paths are similar to the audio codec found in earlier SoCs such as the A31. The analog audio paths are symmetrical with left/right channels and down-mix selectors for mono differential output.
What deviates from previous SoCs is that the analog path controls have been moved to a separate control bus, accessed through a message box like register interface in the PRCM block. This necessitates writing a separate component driver for it, which is then tied into the sound card as an ASoC auxiliary device.
Patch 1 adds the analog path controls block to the sun6i-prcm driver as a sub-device, for the A23. The H3 currently does not use the PRCM driver.
Patch 2 adds PCM and card support for the A23 codec to the sun4i-codec driver.
Patch 3 adds a device node for the analog path controls block to the A23 dtsi.
Patch 4 adds a device node for the audio codec, and the phandle for the analog path controls block to the A23 dtsi.
Patch 5 enables the audio codec for the A23 Q8 tablets. On these tablets the headphone output is driven in DC coupled, or "direct drive", mode.
Patch 6 adds PCM and card support for the H3 codec to the sun4i-codec driver.
Patch 7 adds device nodes for the audio codec and analog path controls block to the H3 dtsi.
Patch 8 enables the audio codec on the Orange Pi PC. The audio output jack on the board is tied to the line out pins on the SoC.
Please take a look and let me know what you think.
In addition, the sun4i-codec driver is getting pretty large. Maybe we want to split the different parts into different files?
Regards
ChenYu
Chen-Yu Tsai (8):
mfd: sun6i-prcm: Add codec analog controls sub-device for Allwinner
A23
ASoC: sun4i-codec: Add support for A23 codec
ARM: dts: sun8i: Add codec analog path controls node in PRCM for
A23/A33 ARM: dts: sun8i-a23: Add device node for internal audio codec
ARM: dts: sun8i-a23: q8-tablet: Enable internal audio codec
ASoC: sun4i-codec: Add support for H3 codec
ARM: dts: sun8i-h3: Add device nodes for audio codec and its analog
controls
ARM: dts: sun8i-h3: orange-pi-pc: Enable audio codec
.../devicetree/bindings/sound/sun4i-codec.txt | 14 +- arch/arm/boot/dts/sun8i-a23-a33.dtsi | 4 + arch/arm/boot/dts/sun8i-a23-q8-tablet.dts | 23 +++ arch/arm/boot/dts/sun8i-a23.dtsi | 16 ++ arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 8 + arch/arm/boot/dts/sun8i-h3.dtsi | 19 +++ drivers/mfd/sun6i-prcm.c | 13 ++ sound/soc/sunxi/sun4i-codec.c | 179 +++++++++++++++++++++ 8 files changed, 274 insertions(+), 2 deletions(-)
Signature · 1 line
2.10.2
PATCH v2 1/8 mfd: sun6i-prcm: Add codec analog controls sub-device for Allwinner A23
The PRCM block on the A23 contains a message box like interface to the registers for the analog path controls of the internal codec.
Add a sub-device for it.
--- drivers/mfd/sun6i-prcm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/mfd/sun6i-prcm.c +13 -0
@@ -12,6 +12,9 @@#include <linux/init.h> #include <linux/of.h> +#define SUN8I_CODEC_ANALOG_BASE 0x1c0 +#define SUN8I_CODEC_ANALOG_SIZE 0x4 +struct prcm_data {int nsubdevs;const struct mfd_cell *subdevs;
@@ -57,6 +60,10 @@ static const struct resource sun6i_a31_apb0_rstc_res[] = { }, }; +static const struct resource sun8i_codec_analog_res[] = { +DEFINE_RES_MEM (SUN8I_CODEC_ANALOG_BASE ,SUN8I_CODEC_ANALOG_SIZE ), +}; +static const struct mfd_cell sun6i_a31_prcm_subdevs[] = { { .name ="sun6i-a31-ar100-clk" ,
@@ -109,6 +116,12 @@ static const struct mfd_cell sun8i_a23_prcm_subdevs[] = { .num_resources = ARRAY_SIZE(sun6i_a31_apb0_rstc_res), .resources = sun6i_a31_apb0_rstc_res, }, + { + .name = "sun8i-codec-analog", + .of_compatible = "allwinner,sun8i-a23-codec-analog", + .num_resources = ARRAY_SIZE(sun8i_codec_analog_res), + .resources = sun8i_codec_analog_res, + }, };static const struct prcm_data sun6i_a31_prcm_data = {
Signature · 1 line
2.10.2
PATCH v2 2/8 ASoC: sun4i-codec: Add support for A23 codec
In reply to Chen-Yu TsaiThe codec in the A23 is similar to the one found on the A31. One key difference is the analog path controls are routed through the PRCM block. This is supported by the sun8i-codec-analog driver, and tied into this codec driver with the audio card's aux_dev.
In addition, the A23 does not have LINEOUT, and it does not support headset jack detection or buttons.
--- .../devicetree/bindings/sound/sun4i-codec.txt | 11 ++- sound/soc/sunxi/sun4i-codec.c | 108 +++++++++++++++++++++ 2 files changed, 117 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/sound/sun4i-codec.txt +9 -2
@@ -5,6 +5,7 @@ Required properties: - "allwinner,sun4i-a10-codec" - "allwinner,sun6i-a31-codec" - "allwinner,sun7i-a20-codec" + - "allwinner,sun8i-a23-codec" - reg: must contain the registers location and length - interrupts: must contain the codec interrupt - dmas: DMA channels for tx and rx dma. See the DMA client binding,
@@ -21,6 +22,7 @@ Optional properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-codec" + - "allwinner,sun8i-a23-codec" - resets: phandle to the reset control for this device - allwinner,audio-routing: A list of the connections between audio components. Each entry is a pair of strings, the first being the
@@ -31,10 +33,10 @@ Required properties for the following compatibles: "HP" "HPCOM" "LINEIN" - "LINEOUT" + "LINEOUT" (not on sun8i-a23) "MIC1" "MIC2" - "MIC3" + "MIC3" (sun6i-a31 only) Microphone biases from the SoC: "HBIAS"
@@ -48,6 +50,11 @@ Required properties for the following compatibles: "Mic" "Speaker" +Required properties for the following compatibles: + - "allwinner,sun8i-a23-codec" +- allwinner,codec-analog-controls: A phandle to the codec analog controls + block in the PRCM. + Example: codec: codec@01c22c00 { #sound-dai-cells = <0>;
sound/soc/sunxi/sun4i-codec.c +108 -0
144 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v2 3/8 ARM: dts: sun8i: Add codec analog path controls node in PRCM for A23/A33
In reply to Chen-Yu TsaiOn the A23/A33, the internal codec's analog path controls are located in the PRCM node.
Add a sub-device node to the PRCM for it.
--- arch/arm/boot/dts/sun8i-a23-a33.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/sun8i-a23-a33.dtsi +4 -0
@@ -538,6 +538,10 @@ compatible = "allwinner,sun6i-a31-clock-reset"; #reset-cells = <1>; }; + + codec_analog: codec-analog { + compatible = "allwinner,sun8i-a23-codec-analog"; + }; }; cpucfg@01f01c00 {
Signature · 1 line
2.10.2
PATCH v2 4/8 ARM: dts: sun8i-a23: Add device node for internal audio codec
In reply to Chen-Yu TsaiNow that we have a device tree binding and driver for the A23's internal audio codec, add a device node for it.
--- arch/arm/boot/dts/sun8i-a23.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/sun8i-a23.dtsi +16 -0
@@ -48,6 +48,22 @@ memory { reg = <0x40000000 0x40000000>; }; + + soc@01c00000 { + codec: codec@01c22c00 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun8i-a23-codec"; + reg = <0x01c22c00 0x400>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>; + clock-names = "apb", "codec"; + resets = <&ccu RST_BUS_CODEC>; + dmas = <&dma 15>, <&dma 15>; + dma-names = "rx", "tx"; + allwinner,codec-analog-controls = <&codec_analog>; + status = "disabled"; + }; + }; }; &ccu {
Signature · 1 line
2.10.2
PATCH v2 5/8 ARM: dts: sun8i-a23: q8-tablet: Enable internal audio codec
In reply to Chen-Yu TsaiThe A23 Q8 tablets have an internal mono speaker w/ external amp which has a shutdown control tied to a GPIO pin. Both the speaker amp and the headphone jack are tied to the HP output pins. While the speaker is mono, the headset jack is stereo. Unfortunately the driver does not support automatic switching of this.
In addition, the headset is DC coupled, or "direct drive" enabled. The headset's microphone is tied to MIC2 with HBIAS providing power. A separate internal microphone is tied to MIC1 with MBIAS providing power.
--- arch/arm/boot/dts/sun8i-a23-q8-tablet.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm/boot/dts/sun8i-a23-q8-tablet.dts +23 -0
@@ -48,3 +48,26 @@ model = "Q8 A23 Tablet"; compatible = "allwinner,q8-a23", "allwinner,sun8i-a23"; }; + +&codec { + pinctrl-0 = <&codec_pa_pin>; + allwinner,pa-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */ + allwinner,audio-routing = + "Headphone", "HP", + "Headphone", "HPCOM", + "Speaker", "HP", + "MIC1", "Mic", + "MIC2", "Headset Mic", + "Mic", "MBIAS", + "Headset Mic", "HBIAS"; + status = "okay"; +}; + +&pio { + codec_pa_pin: codec_pa_pin@0 { + allwinner,pins = "PH9"; + allwinner,function = "gpio_out"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; +};
Signature · 1 line
2.10.2
PATCH v2 6/8 ASoC: sun4i-codec: Add support for H3 codec
In reply to Chen-Yu TsaiThe codec on the H3 is similar to the one found on the A31. One key difference is the analog path controls are routed through the PRCM block. This is supported by the sun8i-codec-analog driver, and tied into this codec driver with the audio card's aux_dev.
In addition, the H3 has no HP (headphone) and HBIAS support, and no MIC3 input. The FIFO related registers are slightly rearranged.
--- .../devicetree/bindings/sound/sun4i-codec.txt | 3 + sound/soc/sunxi/sun4i-codec.c | 71 ++++++++++++++++++++++ 2 files changed, 74 insertions(+)
Documentation/devicetree/bindings/sound/sun4i-codec.txt +3 -0
@@ -6,6 +6,7 @@ Required properties: - "allwinner,sun6i-a31-codec" - "allwinner,sun7i-a20-codec" - "allwinner,sun8i-a23-codec" + - "allwinner,sun8i-h3-codec" - reg: must contain the registers location and length - interrupts: must contain the codec interrupt - dmas: DMA channels for tx and rx dma. See the DMA client binding,
@@ -23,6 +24,7 @@ Optional properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-codec" - "allwinner,sun8i-a23-codec" + - "allwinner,sun8i-h3-codec" - resets: phandle to the reset control for this device - allwinner,audio-routing: A list of the connections between audio components. Each entry is a pair of strings, the first being the
@@ -52,6 +54,7 @@ Required properties for the following compatibles: Required properties for the following compatibles: - "allwinner,sun8i-a23-codec" + - "allwinner,sun8i-h3-codec" - allwinner,codec-analog-controls: A phandle to the codec analog controls block in the PRCM.
sound/soc/sunxi/sun4i-codec.c +71 -0
101 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v2 7/8 ARM: dts: sun8i-h3: Add device nodes for audio codec and its analog controls
In reply to Chen-Yu TsaiNow that we support the audio codec found on the Allwinner H3 SoC, add device nodes for it.
--- arch/arm/boot/dts/sun8i-h3.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/boot/dts/sun8i-h3.dtsi +19 -0
@@ -465,6 +465,20 @@ status = "disabled"; }; + codec: codec@01c22c00 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun8i-h3-codec"; + reg = <0x01c22c00 0x400>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>; + clock-names = "apb", "codec"; + resets = <&ccu RST_BUS_CODEC>; + dmas = <&dma 15>, <&dma 15>; + dma-names = "rx", "tx"; + allwinner,codec-analog-controls = <&codec_analog>; + status = "disabled"; + }; + uart0: serial@01c28000 { compatible = "snps,dw-apb-uart"; reg = <0x01c28000 0x400>;
@@ -580,6 +594,11 @@ #reset-cells = <1>; }; + codec_analog: codec-analog@01f015c0 { + compatible = "allwinner,sun8i-h3-codec-analog"; + reg = <0x01f015c0 0x4>; + }; + ir: ir@01f02000 { compatible = "allwinner,sun5i-a13-ir"; clocks = <&apb0_gates 1>, <&ir_clk>;
Signature · 1 line
2.10.2
PATCH v2 8/8 ARM: dts: sun8i-h3: orange-pi-pc: Enable audio codec
In reply to Chen-Yu TsaiThe Orange Pi PC routes the LINEOUT pins to the audio out jack on the board. The onboard microphone is routed to MIC1, with MBIAS providing power.
--- arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts +8 -0
@@ -90,6 +90,14 @@ }; }; +&codec { + allwinner,audio-routing = + "Line Out", "LINEOUT", + "MIC1", "Mic", + "Mic", "MBIAS"; + status = "okay"; +}; + &ehci1 { status = "okay"; };
Signature · 1 line
2.10.2
Re: [PATCH v2 1/8] mfd: sun6i-prcm: Add codec analog controls sub-device for Allwinner A23
In reply to Chen-Yu TsaiQuoted 6 lines · Chen-Yu Tsai
The PRCM block on the A23 contains a message box like interface to the registers for the analog path controls of the internal codec.
Add a sub-device for it.
Signed-off-by Chen-Yu Tsai <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH v2 2/8] ASoC: sun4i-codec: Add support for A23 codec
In reply to Chen-Yu TsaiQuoted 10 lines · Chen-Yu Tsai
The codec in the A23 is similar to the one found on the A31. One key difference is the analog path controls are routed through the PRCM block. This is supported by the sun8i-codec-analog driver, and tied into this codec driver with the audio card's
aux_dev.In addition, the A23 does not have LINEOUT, and it does not support headset jack detection or buttons.
Signed-off-by Chen-Yu Tsai <[email protected]>Acked-by Rob Herring <[email protected]>
Thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH v2 6/8] ASoC: sun4i-codec: Add support for H3 codec
In reply to Chen-Yu TsaiQuoted 10 lines · Chen-Yu Tsai
The codec on the H3 is similar to the one found on the A31. One key difference is the analog path controls are routed through the PRCM block. This is supported by the sun8i-codec-analog driver, and tied into this codec driver with the audio card's
aux_dev.In addition, the H3 has no HP (headphone) and HBIAS support, and no MIC3 input. The FIFO related registers are slightly rearranged.
Signed-off-by Chen-Yu Tsai <[email protected]>Acked-by Rob Herring <[email protected]>
Thanks,
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 1/8] mfd: sun6i-prcm: Add codec analog controls sub-device for Allwinner A23
In reply to Chen-Yu TsaiQuoted 9 lines · Chen-Yu Tsai
The PRCM block on the A23 contains a message box like interface to the registers for the analog path controls of the internal codec.
Add a sub-device for it.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/mfd/sun6i-prcm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Applied for v4.11, thanks.
Quoted 38 lines
drivers/mfd/sun6i-prcm.c +13
-0@@ -12,6 +12,9 @@#include <linux/init.h> #include <linux/of.h> +#define SUN8I_CODEC_ANALOG_BASE 0x1c0 +#define SUN8I_CODEC_ANALOG_SIZE 0x4 +struct prcm_data {int nsubdevs;const struct mfd_cell *subdevs;@@ -57,6 +60,10 @@ static const struct resource sun6i_a31_apb0_rstc_res[] = { }, }; +static const struct resource sun8i_codec_analog_res[] = { +DEFINE_RES_MEM (SUN8I_CODEC_ANALOG_BASE ,SUN8I_CODEC_ANALOG_SIZE ), +}; +static const struct mfd_cell sun6i_a31_prcm_subdevs[] = { { .name ="sun6i-a31-ar100-clk" ,@@ -109,6 +116,12 @@ static const struct mfd_cell sun8i_a23_prcm_subdevs[] = { .num_resources = ARRAY_SIZE(sun6i_a31_apb0_rstc_res), .resources = sun6i_a31_apb0_rstc_res, }, + { + .name = "sun8i-codec-analog", + .of_compatible = "allwinner,sun8i-a23-codec-analog", + .num_resources = ARRAY_SIZE(sun8i_codec_analog_res), + .resources = sun8i_codec_analog_res, + }, };static const struct prcm_data sun6i_a31_prcm_data = {
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Hi Maxime,
Quoted 36 lines · Chen-Yu Tsai
Hi everyone,
This is v2 of my Allwinner A23 and H3 audio codec support series.
Changes since v1:
- Use
DEFINE_RES_MEMfor the analog path controls block resources.
- Added Rob's ack.This series adds support for the audio codec found in Allwinner A23 and H3 SoCs. The design and data paths are similar to the audio codec found in earlier SoCs such as the A31. The analog audio paths are symmetrical with left/right channels and down-mix selectors for mono differential output.
What deviates from previous SoCs is that the analog path controls have been moved to a separate control bus, accessed through a message box like register interface in the PRCM block. This necessitates writing a separate component driver for it, which is then tied into the sound card as an ASoC auxiliary device.
Patch 1 adds the analog path controls block to the sun6i-prcm driver as a sub-device, for the A23. The H3 currently does not use the PRCM driver.
Patch 2 adds PCM and card support for the A23 codec to the sun4i-codec driver.
Patch 3 adds a device node for the analog path controls block to the A23 dtsi.
Patch 4 adds a device node for the audio codec, and the phandle for the analog path controls block to the A23 dtsi.
Patch 5 enables the audio codec for the A23 Q8 tablets. On these tablets the headphone output is driven in DC coupled, or "direct drive", mode.
Quoted 8 lines
Patch 6 adds PCM and card support for the H3 codec to the sun4i-codec driver.
Patch 7 adds device nodes for the audio codec and analog path controls block to the H3 dtsi.
Patch 8 enables the audio codec on the Orange Pi PC. The audio output jack on the board is tied to the line out pins on the SoC.
All the driver bits are in. Can you pick up the dts patches?
Thanks
ChenYu
Quoted 38 lines
Please take a look and let me know what you think.
In addition, the sun4i-codec driver is getting pretty large. Maybe we want to split the different parts into different files?
Regards
ChenYuChen-Yu Tsai (8):
mfd: sun6i-prcm: Add codec analog controls sub-device for AllwinnerA23 ASoC: sun4i-codec: Add support for A23 codec ARM: dts: sun8i: Add codec analog path controls node in PRCM for A23/A33ARM: dts: sun8i-a23: Add device node for internal audio codec
ARM: dts: sun8i-a23: q8-tablet: Enable internal audio codec
ASoC: sun4i-codec: Add support for H3 codec
ARM: dts: sun8i-h3: Add device nodes for audio codec and its analog
controls
ARM: dts: sun8i-h3: orange-pi-pc: Enable audio codec.../devicetree/bindings/sound/sun4i-codec.txt | 14 +- arch/arm/boot/dts/sun8i-a23-a33.dtsi | 4 + arch/arm/boot/dts/sun8i-a23-q8-tablet.dts | 23 +++ arch/arm/boot/dts/sun8i-a23.dtsi | 16 ++ arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 8 + arch/arm/boot/dts/sun8i-h3.dtsi | 19 +++ drivers/mfd/sun6i-prcm.c | 13 ++ sound/soc/sunxi/sun4i-codec.c | 179 +++++++++++++++++++++ 8 files changed, 274 insertions(+), 2 deletions(-)--
2.10.2
Quoted 42 lines · Chen-Yu Tsai
Hi Maxime,
Quoted 39 lines · Chen-Yu Tsai
Hi everyone,
This is v2 of my Allwinner A23 and H3 audio codec support series.
Changes since v1:
- Use
DEFINE_RES_MEMfor the analog path controls block resources.
- Added Rob's ack.This series adds support for the audio codec found in Allwinner A23 and H3 SoCs. The design and data paths are similar to the audio codec found in earlier SoCs such as the A31. The analog audio paths are symmetrical with left/right channels and down-mix selectors for mono differential output.
What deviates from previous SoCs is that the analog path controls have been moved to a separate control bus, accessed through a message box like register interface in the PRCM block. This necessitates writing a separate component driver for it, which is then tied into the sound card as an ASoC auxiliary device.
Patch 1 adds the analog path controls block to the sun6i-prcm driver as a sub-device, for the A23. The H3 currently does not use the PRCM driver.
Patch 2 adds PCM and card support for the A23 codec to the sun4i-codec driver.
Patch 3 adds a device node for the analog path controls block to the A23 dtsi.
Patch 4 adds a device node for the audio codec, and the phandle for the analog path controls block to the A23 dtsi.
Patch 5 enables the audio codec for the A23 Q8 tablets. On these tablets the headphone output is driven in DC coupled, or "direct drive", mode.
Patch 6 adds PCM and card support for the H3 codec to the sun4i-codec driver.
Quoted 7 lines
Quoted 5 lines
Patch 7 adds device nodes for the audio codec and analog path controls block to the H3 dtsi.
Patch 8 enables the audio codec on the Orange Pi PC. The audio output jack on the board is tied to the line out pins on the SoC.
All the driver bits are in. Can you pick up the dts patches?
I just did.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170108/da80dea7/attachment.sig>