2018-11-23 10:47:19

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 0/8] Add support for audiocodec in Allwinner A64

Hi everyone,

This is v9 of the A64 audio codec series, originally started by Vasily.
These are the last changes to make the A64 audio codec work correctly,
and be accurately represented in the device tree and in software.

Notably, the new driver changes cover regulator supplies for the simple
audio amplifier, which is used in the Pinebook for the internal
speakers, and the audio codec's internal headphone amp. There's also an
extra patch that enables SDM fractional clock support for the audio PLL
on the A64, which gives us accurate audio playback.

Patch 1 & 2 add the cpvdd regulator supply to the sun50i-codec-analog
dt bindings & driver.

Patch 3 & 4 add a regulator supply to the simple-audio-amplifier dt
bindings & driver.

Patch 5 adds SDM fractional clock support for the audio PLL on the A64.

Patch 6 ~ 8 add the device tree bits and enables audio on several
boards.

I have one extra patch for the Bananapi M64 that's not included here,
as I'm waiting for an accessory to test the microphone bias. I'll send
that one out once it's tested.

As always, we'll take the clock and dts patches after Mark has merged
the ASoC ones.

And a big thanks to Vasily for having worked on this for so long.

Regards
ChenYu

v9: - Dropped simple amplifier headphone amp device tree changes
- Dropped "make enable-gpio optional for simple amplifier"
- Lowered oversampling rate from 512 to 128
- Add regulator supply for audio codec CPVDD (headphone amp charge pump)
- Hook up CPVDD regulator in board device trees
- Add patch to enable SDM fractional clock support for audio PLL on A64
v8: - drop merged patches
- add regulator property for simple amplifier, make enable-gpio
optional
- add regulator to speaker amp, introduce headphone amp
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
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.
v5: - collect all the tags
v4: - dts: don't use 'Mic' and 'Headset Mic' widgets from sun8i-codec,
define our board-level widgets instead.
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
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

Chen-Yu Tsai (3):
ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator
supply
ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator
supply
clk: sunxi-ng: sun50i: a64: Use sigma-delta modulation for audio PLL

Vasily Khoruzhick (5):
ASoC: dt-bindings: add regulator property to simple amplifier
ASoC: simple-amplifier: add VCC regulator widget
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 ++
.../bindings/sound/sun50i-codec-analog.txt | 2 +
.../boot/dts/allwinner/sun50i-a64-pine64.dts | 27 ++++++++++
.../dts/allwinner/sun50i-a64-pinebook.dts | 49 +++++++++++++++++
.../allwinner/sun50i-a64-sopine-baseboard.dts | 26 +++++++++
.../boot/dts/allwinner/sun50i-a64-sopine.dtsi | 4 ++
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 54 +++++++++++++++++++
drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 37 ++++++++-----
sound/soc/codecs/simple-amplifier.c | 4 ++
sound/soc/sunxi/sun50i-codec-analog.c | 2 +
10 files changed, 197 insertions(+), 13 deletions(-)

--
2.19.1



2018-11-23 09:29:46

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 8/8] arm64: dts: allwinner: a64: enable sound on Pinebook

From: Vasily Khoruzhick <[email protected]>

The Pinebook has a headphone jack tied to the HP headphone output of
the SoC, and internal speakers connected to the LINEOUT of the SoC,
through a standalone amplifier.

This commit enables I2S, digital and analog parts of audio codec on
Pinebook, along with a device node for the external amplifier.

Signed-off-by: Vasily Khoruzhick <[email protected]>
[[email protected]: dropped headphone_amp; added headphone amp regulator supply;
fixed speaker_amp node name and sound-name-prefix name]
Signed-off-by: Chen-Yu Tsai <[email protected]>
---
.../dts/allwinner/sun50i-a64-pinebook.dts | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
index ec537c529726..b6d0b926a2ff 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
@@ -74,6 +74,32 @@
compatible = "mmc-pwrseq-simple";
reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
};
+
+ speaker_amp: audio-amplifier {
+ compatible = "simple-audio-amplifier";
+ /*
+ * TODO This is actually a fixed regulator controlled by
+ * the GPIO line on the PMIC. This should be corrected
+ * once GPIO support is added for this PMIC.
+ */
+ VCC-supply = <&reg_ldo_io0>;
+ enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */
+ sound-name-prefix = "Speaker Amp";
+ };
+
+};
+
+&codec {
+ hpvcc-supply = <&reg_eldo1>;
+ status = "okay";
+};
+
+&codec_analog {
+ status = "okay";
+};
+
+&dai {
+ status = "okay";
};

&ehci0 {
@@ -277,6 +303,29 @@
vcc-hdmi-supply = <&reg_dldo1>;
};

+&sound {
+ status = "okay";
+ simple-audio-card,aux-devs = <&codec_analog>, <&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 Amp INL", "LINEOUT",
+ "Speaker Amp INR", "LINEOUT",
+ "Internal Speaker", "Speaker Amp OUTL",
+ "Internal Speaker", "Speaker Amp OUTR",
+ "Headphone Jack", "HP",
+ "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


2018-11-23 10:42:23

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 2/8] ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator supply

On the Allwinner A64 SoCs, the audio codec has a built-in headphone
amplifier. This amplifier has a power supply separate from the rest of
the analog audio circuitry, labeled cpvdd.

This patch adds a DAPM widget for this supply, and ties it to the
headphone amp widget.

Signed-off-by: Chen-Yu Tsai <[email protected]>
---
sound/soc/sunxi/sun50i-codec-analog.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c
index 8f5f999df631..df1fed0aa001 100644
--- a/sound/soc/sunxi/sun50i-codec-analog.c
+++ b/sound/soc/sunxi/sun50i-codec-analog.c
@@ -274,6 +274,7 @@ static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = {
* stream widgets at the card level.
*/

+ SND_SOC_DAPM_REGULATOR_SUPPLY("hpvcc", 0, 0),
SND_SOC_DAPM_MUX("Headphone Source Playback Route",
SND_SOC_NOPM, 0, 0, sun50i_codec_hp_src),
SND_SOC_DAPM_OUT_DRV("Headphone Amp", SUN50I_ADDA_HP_CTRL,
@@ -361,6 +362,7 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = {
{ "Headphone Source Playback Route", "Mixer", "Left Mixer" },
{ "Headphone Source Playback Route", "Mixer", "Right Mixer" },
{ "Headphone Amp", NULL, "Headphone Source Playback Route" },
+ { "Headphone Amp", NULL, "hpvcc" },
{ "HP", NULL, "Headphone Amp" },

/* Microphone Routes */
--
2.19.1


2018-11-23 10:42:28

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 1/8] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

On the Allwinner A64 SoC, the audio codec has a built-in headphone
amplifier. This amplifier has a power supply separate from the rest of
the analog audio circuitry.

Add a regulator supply property to handle this.

Signed-off-by: Chen-Yu Tsai <[email protected]>
---
Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
index 4f8ad0e04d20..056a098495cc 100644
--- a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
+++ b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
@@ -4,9 +4,11 @@ Required properties:
- compatible: must be one of the following compatibles:
- "allwinner,sun50i-a64-codec-analog"
- reg: must contain the registers location and length
+- cpvdd-supply: Regulator supply for the headphone amplifier

Example:
codec_analog: codec-analog@1f015c0 {
compatible = "allwinner,sun50i-a64-codec-analog";
reg = <0x01f015c0 0x4>;
+ cpvdd-supply = <&reg_eldo1>;
};
--
2.19.1


2018-11-23 10:42:59

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 5/8] clk: sunxi-ng: sun50i: a64: Use sigma-delta modulation for audio PLL

The audio blocks require specific clock rates. Until now we were using
the closest clock rate possible with integer N-M factors. This resulted
in audio playback being slightly slower than it should be.

The vendor kernel gets around this (for some SoCs) by using sigma-delta
modulation to generate a fractional-N factor. As the PLL hardware is
identical in most chips, we can port the settings for H3 onto the A64.

Signed-off-by: Chen-Yu Tsai <[email protected]>
---
drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 37 +++++++++++++++++----------
1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
index 1f45b20ad752..181b599dc163 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
@@ -51,18 +51,29 @@ static struct ccu_nkmp pll_cpux_clk = {
* the base (2x, 4x and 8x), and one variable divider (the one true
* pll audio).
*
- * We don't have any need for the variable divider for now, so we just
- * hardcode it to match with the clock names
+ * With sigma-delta modulation for fractional-N on the audio PLL,
+ * we have to use specific dividers. This means the variable divider
+ * can no longer be used, as the audio codec requests the exact clock
+ * rates we support through this mechanism. So we now hard code the
+ * variable divider to 1. This means the clock rates will no longer
+ * match the clock names.
*/
#define SUN50I_A64_PLL_AUDIO_REG 0x008

-static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
- "osc24M", 0x008,
- 8, 7, /* N */
- 0, 5, /* M */
- BIT(31), /* gate */
- BIT(28), /* lock */
- CLK_SET_RATE_UNGATE);
+static struct ccu_sdm_setting pll_audio_sdm_table[] = {
+ { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
+ { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
+};
+
+static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
+ "osc24M", 0x008,
+ 8, 7, /* N */
+ 0, 5, /* M */
+ pll_audio_sdm_table, BIT(24),
+ 0x284, BIT(31),
+ BIT(31), /* gate */
+ BIT(28), /* lock */
+ CLK_SET_RATE_UNGATE);

static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
"osc24M", 0x010,
@@ -594,9 +605,9 @@ static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
/* Fixed Factor clocks */
static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 2, 1, 0);

-/* We hardcode the divider to 4 for now */
+/* We hardcode the divider to 1 for now */
static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio",
- "pll-audio-base", 4, 1, CLK_SET_RATE_PARENT);
+ "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT);
static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x",
"pll-audio-base", 2, 1, CLK_SET_RATE_PARENT);
static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x",
@@ -916,10 +927,10 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev)
if (IS_ERR(reg))
return PTR_ERR(reg);

- /* Force the PLL-Audio-1x divider to 4 */
+ /* Force the PLL-Audio-1x divider to 1 */
val = readl(reg + SUN50I_A64_PLL_AUDIO_REG);
val &= ~GENMASK(19, 16);
- writel(val | (3 << 16), reg + SUN50I_A64_PLL_AUDIO_REG);
+ writel(val | (0 << 16), reg + SUN50I_A64_PLL_AUDIO_REG);

writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG);

--
2.19.1


2018-11-23 10:47:06

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 6/8] arm64: dts: allwinner: a64: add nodes necessary for analog sound support

From: Vasily Khoruzhick <[email protected]>

Add nodes for i2s, digital and analog parts of audiocodec on A64.

The routing paths listed are entries connecting the digital and analog
side of the audio codec together. Due to how device tree works, these
must be copied over to each board device tree, in addition to any board
level routes.

The oversampling rate is set to 128, so that when playing back 192 kHz
audio samples, the MCLK runs at the same rate as the module clock, at
24.576 MHz.

The user manual suggests using different oversampling rates for different
sample rates, but that's not possible without a platform-specific machine
driver.

Signed-off-by: Vasily Khoruzhick <[email protected]>
[[email protected]: Lowered oversampling rate to 128; expanded commit message]
Signed-off-by: Chen-Yu Tsai <[email protected]>
---
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 42abfbf56b88..384c417cb7a2 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 = <128>;
+ 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>;
@@ -924,6 +972,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";
--
2.19.1


2018-11-23 10:47:08

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 7/8] arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine

From: Vasily Khoruzhick <[email protected]>

This commit enables I2S, digital and analog parts of audiocodec on
Pine64 and SoPine boards.

Signed-off-by: Vasily Khoruzhick <[email protected]>
[[email protected]: Dropped headphone_amp; added headphone amp regulator supply]
Signed-off-by: Chen-Yu Tsai <[email protected]>
---
.../boot/dts/allwinner/sun50i-a64-pine64.dts | 27 +++++++++++++++++++
.../allwinner/sun50i-a64-sopine-baseboard.dts | 26 ++++++++++++++++++
.../boot/dts/allwinner/sun50i-a64-sopine.dtsi | 4 +++
3 files changed, 57 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..216f2f5db5ef 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
@@ -75,6 +75,19 @@
};
};

+&codec {
+ status = "okay";
+};
+
+&codec_analog {
+ hpvcc-supply = <&reg_eldo1>;
+ status = "okay";
+};
+
+&dai {
+ status = "okay";
+};
+
&de {
status = "okay";
};
@@ -259,6 +272,20 @@
vcc-hdmi-supply = <&reg_dldo1>;
};

+&sound {
+ simple-audio-card,aux-devs = <&codec_analog>;
+ 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",
+ "Headphone Jack", "HP",
+ "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..2052319b9030 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
@@ -80,6 +80,18 @@
};
};

+&codec {
+ status = "okay";
+};
+
+&codec_analog {
+ status = "okay";
+};
+
+&dai {
+ status = "okay";
+};
+
&de {
status = "okay";
};
@@ -164,6 +176,20 @@
vcc-hdmi-supply = <&reg_dldo1>;
};

+&sound {
+ simple-audio-card,aux-devs = <&codec_analog>;
+ 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",
+ "Headphone Jack", "HP",
+ "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>;
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi
index 6723b8695e0b..d2651f284aa0 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi
@@ -47,6 +47,10 @@

#include <dt-bindings/gpio/gpio.h>

+&codec_analog {
+ hpvcc-supply = <&reg_eldo1>;
+};
+
&mmc0 {
pinctrl-names = "default";
pinctrl-0 = <&mmc0_pins>;
--
2.19.1


2018-11-23 10:47:34

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 3/8] ASoC: dt-bindings: add regulator property to simple amplifier

From: Vasily Khoruzhick <[email protected]>

Amplifier may have associated regulator, so add a property for it.

Signed-off-by: Vasily Khoruzhick <[email protected]>
Signed-off-by: Chen-Yu Tsai <[email protected]>
---
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 = <&regulator>;
enable-gpios = <&gpio GPIOH_3 0>;
};
--
2.19.1


2018-11-23 10:55:22

by Chen-Yu Tsai

[permalink] [raw]
Subject: [PATCH v9 4/8] ASoC: simple-amplifier: add VCC regulator widget

From: Vasily Khoruzhick <[email protected]>

Amplifier may have assosicated regulator, so add a widget for it
and appropriate route.

Signed-off-by: Vasily Khoruzhick <[email protected]>
Signed-off-by: Chen-Yu Tsai <[email protected]>
---
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" },
};
--
2.19.1


2018-11-23 23:22:40

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v9 1/8] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

On Thu, Nov 22, 2018 at 06:23:18PM +0800, Chen-Yu Tsai wrote:
> On the Allwinner A64 SoC, the audio codec has a built-in headphone
> amplifier. This amplifier has a power supply separate from the rest of
> the analog audio circuitry.
>
> Add a regulator supply property to handle this.
>
> Signed-off-by: Chen-Yu Tsai <[email protected]>
> ---
> Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> index 4f8ad0e04d20..056a098495cc 100644
> --- a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> +++ b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> @@ -4,9 +4,11 @@ Required properties:
> - compatible: must be one of the following compatibles:
> - "allwinner,sun50i-a64-codec-analog"
> - reg: must contain the registers location and length
> +- cpvdd-supply: Regulator supply for the headphone amplifier

I guess we should make this optional, since even if it's missing, it's
going to create a dummy regulator. and that allows to have backward
compatibility.

For the rest of the series,
Acked-by: Maxime Ripard <[email protected]>

Thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Attachments:
(No filename) (1.39 kB)
signature.asc (235.00 B)
Download all attachments

2018-11-24 00:25:31

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 1/8] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

On Thu, Nov 22, 2018 at 11:33 PM Maxime Ripard
<[email protected]> wrote:
>
> On Thu, Nov 22, 2018 at 06:23:18PM +0800, Chen-Yu Tsai wrote:
> > On the Allwinner A64 SoC, the audio codec has a built-in headphone
> > amplifier. This amplifier has a power supply separate from the rest of
> > the analog audio circuitry.
> >
> > Add a regulator supply property to handle this.
> >
> > Signed-off-by: Chen-Yu Tsai <[email protected]>
> > ---
> > Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > index 4f8ad0e04d20..056a098495cc 100644
> > --- a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > +++ b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > @@ -4,9 +4,11 @@ Required properties:
> > - compatible: must be one of the following compatibles:
> > - "allwinner,sun50i-a64-codec-analog"
> > - reg: must contain the registers location and length
> > +- cpvdd-supply: Regulator supply for the headphone amplifier
>
> I guess we should make this optional, since even if it's missing, it's
> going to create a dummy regulator. and that allows to have backward
> compatibility.
>
> For the rest of the series,
> Acked-by: Maxime Ripard <[email protected]>

This one (not sun8i-codec-analog) is new for the next release, so there's
no backward compatibility to consider. Plus none of the device tree changes
for A64 have been merged.

ChenYu

2018-11-24 00:29:09

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH v9 1/8] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

On Thu, Nov 22, 2018 at 11:41:57PM +0800, Chen-Yu Tsai wrote:
> On Thu, Nov 22, 2018 at 11:33 PM Maxime Ripard
> <[email protected]> wrote:
> >
> > On Thu, Nov 22, 2018 at 06:23:18PM +0800, Chen-Yu Tsai wrote:
> > > On the Allwinner A64 SoC, the audio codec has a built-in headphone
> > > amplifier. This amplifier has a power supply separate from the rest of
> > > the analog audio circuitry.
> > >
> > > Add a regulator supply property to handle this.
> > >
> > > Signed-off-by: Chen-Yu Tsai <[email protected]>
> > > ---
> > > Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > > index 4f8ad0e04d20..056a098495cc 100644
> > > --- a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > > +++ b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > > @@ -4,9 +4,11 @@ Required properties:
> > > - compatible: must be one of the following compatibles:
> > > - "allwinner,sun50i-a64-codec-analog"
> > > - reg: must contain the registers location and length
> > > +- cpvdd-supply: Regulator supply for the headphone amplifier
> >
> > I guess we should make this optional, since even if it's missing, it's
> > going to create a dummy regulator. and that allows to have backward
> > compatibility.
> >
> > For the rest of the series,
> > Acked-by: Maxime Ripard <[email protected]>
>
> This one (not sun8i-codec-analog) is new for the next release, so there's
> no backward compatibility to consider. Plus none of the device tree changes
> for A64 have been merged.

Ok, that works for me then.

Thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Attachments:
(No filename) (1.87 kB)
signature.asc (235.00 B)
Download all attachments

2018-11-24 07:52:46

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 1/8] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

On Thu, Nov 22, 2018 at 11:48 PM Maxime Ripard
<[email protected]> wrote:
>
> On Thu, Nov 22, 2018 at 11:41:57PM +0800, Chen-Yu Tsai wrote:
> > On Thu, Nov 22, 2018 at 11:33 PM Maxime Ripard
> > <[email protected]> wrote:
> > >
> > > On Thu, Nov 22, 2018 at 06:23:18PM +0800, Chen-Yu Tsai wrote:
> > > > On the Allwinner A64 SoC, the audio codec has a built-in headphone
> > > > amplifier. This amplifier has a power supply separate from the rest of
> > > > the analog audio circuitry.
> > > >
> > > > Add a regulator supply property to handle this.
> > > >
> > > > Signed-off-by: Chen-Yu Tsai <[email protected]>
> > > > ---
> > > > Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt | 2 ++
> > > > 1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > > > index 4f8ad0e04d20..056a098495cc 100644
> > > > --- a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > > > +++ b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
> > > > @@ -4,9 +4,11 @@ Required properties:
> > > > - compatible: must be one of the following compatibles:
> > > > - "allwinner,sun50i-a64-codec-analog"
> > > > - reg: must contain the registers location and length
> > > > +- cpvdd-supply: Regulator supply for the headphone amplifier
> > >
> > > I guess we should make this optional, since even if it's missing, it's
> > > going to create a dummy regulator. and that allows to have backward
> > > compatibility.
> > >
> > > For the rest of the series,
> > > Acked-by: Maxime Ripard <[email protected]>
> >
> > This one (not sun8i-codec-analog) is new for the next release, so there's
> > no backward compatibility to consider. Plus none of the device tree changes
> > for A64 have been merged.
>
> Ok, that works for me then.

Well, I misspoke. The driver was introduced in 4.20-rc1, and these changes will
end up in 4.21. But again, since we don't have any device tree changes already
merged, we should be fine.

Implementation wise, there really isn't a "required" variant of the regulator
API. The API will use the dummy regulator if it's missing.

ChenYu

2018-11-24 07:58:06

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 0/8] Add support for audiocodec in Allwinner A64

On Fri, Nov 23, 2018 at 12:26 PM Vasily Khoruzhick <[email protected]> wrote:
>
> On Thursday, November 22, 2018 2:23:17 AM PST Chen-Yu Tsai wrote:
> > Hi everyone,
> >
> > This is v9 of the A64 audio codec series, originally started by Vasily.
> > These are the last changes to make the A64 audio codec work correctly,
> > and be accurately represented in the device tree and in software.
> >
> > Notably, the new driver changes cover regulator supplies for the simple
> > audio amplifier, which is used in the Pinebook for the internal
> > speakers, and the audio codec's internal headphone amp. There's also an
> > extra patch that enables SDM fractional clock support for the audio PLL
> > on the A64, which gives us accurate audio playback.
> >
> > Patch 1 & 2 add the cpvdd regulator supply to the sun50i-codec-analog
> > dt bindings & driver.
> >
> > Patch 3 & 4 add a regulator supply to the simple-audio-amplifier dt
> > bindings & driver.
> >
> > Patch 5 adds SDM fractional clock support for the audio PLL on the A64.
> >
> > Patch 6 ~ 8 add the device tree bits and enables audio on several
> > boards.
> >
> > I have one extra patch for the Bananapi M64 that's not included here,
> > as I'm waiting for an accessory to test the microphone bias. I'll send
> > that one out once it's tested.
> >
> > As always, we'll take the clock and dts patches after Mark has merged
> > the ASoC ones.
> >
> > And a big thanks to Vasily for having worked on this for so long.
>
> Thank you for picking it up!
>
> Just a minor note: hpvcc-supply should be a property of codec_analog in
> sun50i-a64-pinebook.dts

Thanks. I'll fix that up when applying.

> Otherwise looks fine, tested on Pinebook and Pine64-LTS.
>
> Tested-by: Vasily Khoruzhick <[email protected]>

Great!

ChenYu

2018-11-24 07:58:08

by Vasily Khoruzhick

[permalink] [raw]
Subject: Re: [PATCH v9 0/8] Add support for audiocodec in Allwinner A64

On Thursday, November 22, 2018 2:23:17 AM PST Chen-Yu Tsai wrote:
> Hi everyone,
>
> This is v9 of the A64 audio codec series, originally started by Vasily.
> These are the last changes to make the A64 audio codec work correctly,
> and be accurately represented in the device tree and in software.
>
> Notably, the new driver changes cover regulator supplies for the simple
> audio amplifier, which is used in the Pinebook for the internal
> speakers, and the audio codec's internal headphone amp. There's also an
> extra patch that enables SDM fractional clock support for the audio PLL
> on the A64, which gives us accurate audio playback.
>
> Patch 1 & 2 add the cpvdd regulator supply to the sun50i-codec-analog
> dt bindings & driver.
>
> Patch 3 & 4 add a regulator supply to the simple-audio-amplifier dt
> bindings & driver.
>
> Patch 5 adds SDM fractional clock support for the audio PLL on the A64.
>
> Patch 6 ~ 8 add the device tree bits and enables audio on several
> boards.
>
> I have one extra patch for the Bananapi M64 that's not included here,
> as I'm waiting for an accessory to test the microphone bias. I'll send
> that one out once it's tested.
>
> As always, we'll take the clock and dts patches after Mark has merged
> the ASoC ones.
>
> And a big thanks to Vasily for having worked on this for so long.

Thank you for picking it up!

Just a minor note: hpvcc-supply should be a property of codec_analog in
sun50i-a64-pinebook.dts

Otherwise looks fine, tested on Pinebook and Pine64-LTS.

Tested-by: Vasily Khoruzhick <[email protected]>

> Regards
> ChenYu
>
> v9: - Dropped simple amplifier headphone amp device tree changes
> - Dropped "make enable-gpio optional for simple amplifier"
> - Lowered oversampling rate from 512 to 128
> - Add regulator supply for audio codec CPVDD (headphone amp charge pump)
> - Hook up CPVDD regulator in board device trees
> - Add patch to enable SDM fractional clock support for audio PLL on A64
> v8: - drop merged patches
> - add regulator property for simple amplifier, make enable-gpio
> optional
> - add regulator to speaker amp, introduce headphone amp
> 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
> 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.
> v5: - collect all the tags
> v4: - dts: don't use 'Mic' and 'Headset Mic' widgets from sun8i-codec,
> define our board-level widgets instead.
> 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
> 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
>
> Chen-Yu Tsai (3):
> ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator
> supply
> ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator
> supply
> clk: sunxi-ng: sun50i: a64: Use sigma-delta modulation for audio PLL
>
> Vasily Khoruzhick (5):
> ASoC: dt-bindings: add regulator property to simple amplifier
> ASoC: simple-amplifier: add VCC regulator widget
> 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 ++
> .../bindings/sound/sun50i-codec-analog.txt | 2 +
> .../boot/dts/allwinner/sun50i-a64-pine64.dts | 27 ++++++++++
> .../dts/allwinner/sun50i-a64-pinebook.dts | 49 +++++++++++++++++
> .../allwinner/sun50i-a64-sopine-baseboard.dts | 26 +++++++++
> .../boot/dts/allwinner/sun50i-a64-sopine.dtsi | 4 ++
> arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 54 +++++++++++++++++++
> drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 37 ++++++++-----
> sound/soc/codecs/simple-amplifier.c | 4 ++
> sound/soc/sunxi/sun50i-codec-analog.c | 2 +
> 10 files changed, 197 insertions(+), 13 deletions(-)





2018-11-24 07:58:47

by Vasily Khoruzhick

[permalink] [raw]
Subject: Re: [PATCH v9 8/8] arm64: dts: allwinner: a64: enable sound on Pinebook

On Thursday, November 22, 2018 2:23:25 AM PST Chen-Yu Tsai wrote:
> From: Vasily Khoruzhick <[email protected]>
>
> The Pinebook has a headphone jack tied to the HP headphone output of
> the SoC, and internal speakers connected to the LINEOUT of the SoC,
> through a standalone amplifier.
>
> This commit enables I2S, digital and analog parts of audio codec on
> Pinebook, along with a device node for the external amplifier.
>
> Signed-off-by: Vasily Khoruzhick <[email protected]>
> [[email protected]: dropped headphone_amp; added headphone amp regulator supply;
> fixed speaker_amp node name and sound-name-prefix name]
> Signed-off-by: Chen-Yu Tsai <[email protected]>
> ---
> .../dts/allwinner/sun50i-a64-pinebook.dts | 49 +++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
> b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts index
> ec537c529726..b6d0b926a2ff 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
> @@ -74,6 +74,32 @@
> compatible = "mmc-pwrseq-simple";
> reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
> };
> +
> + speaker_amp: audio-amplifier {
> + compatible = "simple-audio-amplifier";
> + /*
> + * TODO This is actually a fixed regulator controlled by
> + * the GPIO line on the PMIC. This should be corrected
> + * once GPIO support is added for this PMIC.
> + */
> + VCC-supply = <&reg_ldo_io0>;
> + enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */
> + sound-name-prefix = "Speaker Amp";
> + };
> +
> +};
> +
> +&codec {
> + hpvcc-supply = <&reg_eldo1>;

It should be a property of codec_analog, not codec

> + status = "okay";
> +};
> +
> +&codec_analog {
> + status = "okay";
> +};
> +
> +&dai {
> + status = "okay";
> };
>
> &ehci0 {
> @@ -277,6 +303,29 @@
> vcc-hdmi-supply = <&reg_dldo1>;
> };
>
> +&sound {
> + status = "okay";
> + simple-audio-card,aux-devs = <&codec_analog>, <&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 Amp INL", "LINEOUT",
> + "Speaker Amp INR", "LINEOUT",
> + "Internal Speaker", "Speaker Amp OUTL",
> + "Internal Speaker", "Speaker Amp OUTR",
> + "Headphone Jack", "HP",
> + "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>;





2018-11-24 08:36:20

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v9 1/8] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

On Thu, Nov 22, 2018 at 04:32:41PM +0100, Maxime Ripard wrote:
> On Thu, Nov 22, 2018 at 06:23:18PM +0800, Chen-Yu Tsai wrote:

> > +- cpvdd-supply: Regulator supply for the headphone amplifier

> I guess we should make this optional, since even if it's missing, it's
> going to create a dummy regulator. and that allows to have backward
> compatibility.

Regulators should never be marked as optional unless they can be
physically absent. It is true that Linux has code to handle partially
defined device trees but we shouldn't rely on other OSs having similar
code and it's better practice to have board device trees be fully
specified, it means that if we need the regulator information for some
future thing it's more likely to be there and it's less likely that bugs
which do things like cause the regulator to be powered off incorrectly
will be introduced in future.


Attachments:
(No filename) (891.00 B)
signature.asc (499.00 B)
Download all attachments

2018-11-24 08:37:38

by Mark Brown

[permalink] [raw]
Subject: Applied "ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator supply" to the asoc tree

The patch

ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator supply

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From ca0412a05756cd0b94751ca4d54fe6522f00b1f4 Mon Sep 17 00:00:00 2001
From: Chen-Yu Tsai <[email protected]>
Date: Thu, 22 Nov 2018 18:23:19 +0800
Subject: [PATCH] ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd
regulator supply

On the Allwinner A64 SoCs, the audio codec has a built-in headphone
amplifier. This amplifier has a power supply separate from the rest of
the analog audio circuitry, labeled cpvdd.

This patch adds a DAPM widget for this supply, and ties it to the
headphone amp widget.

Signed-off-by: Chen-Yu Tsai <[email protected]>
Acked-by: Maxime Ripard <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
sound/soc/sunxi/sun50i-codec-analog.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c
index 8f5f999df631..df1fed0aa001 100644
--- a/sound/soc/sunxi/sun50i-codec-analog.c
+++ b/sound/soc/sunxi/sun50i-codec-analog.c
@@ -274,6 +274,7 @@ static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = {
* stream widgets at the card level.
*/

+ SND_SOC_DAPM_REGULATOR_SUPPLY("hpvcc", 0, 0),
SND_SOC_DAPM_MUX("Headphone Source Playback Route",
SND_SOC_NOPM, 0, 0, sun50i_codec_hp_src),
SND_SOC_DAPM_OUT_DRV("Headphone Amp", SUN50I_ADDA_HP_CTRL,
@@ -361,6 +362,7 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = {
{ "Headphone Source Playback Route", "Mixer", "Left Mixer" },
{ "Headphone Source Playback Route", "Mixer", "Right Mixer" },
{ "Headphone Amp", NULL, "Headphone Source Playback Route" },
+ { "Headphone Amp", NULL, "hpvcc" },
{ "HP", NULL, "Headphone Amp" },

/* Microphone Routes */
--
2.19.1


2018-11-24 08:37:41

by Mark Brown

[permalink] [raw]
Subject: Applied "ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply" to the asoc tree

The patch

ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp regulator supply

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 21dd30200e3d350fe420d23a2a00b17633a3d1a2 Mon Sep 17 00:00:00 2001
From: Chen-Yu Tsai <[email protected]>
Date: Thu, 22 Nov 2018 18:23:18 +0800
Subject: [PATCH] ASoC: dt-bindings: sun50i-codec-analog: Add headphone amp
regulator supply

On the Allwinner A64 SoC, the audio codec has a built-in headphone
amplifier. This amplifier has a power supply separate from the rest of
the analog audio circuitry.

Add a regulator supply property to handle this.

Signed-off-by: Chen-Yu Tsai <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
index 4f8ad0e04d20..056a098495cc 100644
--- a/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
+++ b/Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
@@ -4,9 +4,11 @@ Required properties:
- compatible: must be one of the following compatibles:
- "allwinner,sun50i-a64-codec-analog"
- reg: must contain the registers location and length
+- cpvdd-supply: Regulator supply for the headphone amplifier

Example:
codec_analog: codec-analog@1f015c0 {
compatible = "allwinner,sun50i-a64-codec-analog";
reg = <0x01f015c0 0x4>;
+ cpvdd-supply = <&reg_eldo1>;
};
--
2.19.1


2018-11-24 08:41:22

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v9 0/8] Add support for audiocodec in Allwinner A64

On Fri, Nov 23, 2018 at 12:37 PM Chen-Yu Tsai <[email protected]> wrote:
>
> On Fri, Nov 23, 2018 at 12:26 PM Vasily Khoruzhick <[email protected]> wrote:
> >
> > On Thursday, November 22, 2018 2:23:17 AM PST Chen-Yu Tsai wrote:
> > > Hi everyone,
> > >
> > > This is v9 of the A64 audio codec series, originally started by Vasily.
> > > These are the last changes to make the A64 audio codec work correctly,
> > > and be accurately represented in the device tree and in software.
> > >
> > > Notably, the new driver changes cover regulator supplies for the simple
> > > audio amplifier, which is used in the Pinebook for the internal
> > > speakers, and the audio codec's internal headphone amp. There's also an
> > > extra patch that enables SDM fractional clock support for the audio PLL
> > > on the A64, which gives us accurate audio playback.
> > >
> > > Patch 1 & 2 add the cpvdd regulator supply to the sun50i-codec-analog
> > > dt bindings & driver.
> > >
> > > Patch 3 & 4 add a regulator supply to the simple-audio-amplifier dt
> > > bindings & driver.
> > >
> > > Patch 5 adds SDM fractional clock support for the audio PLL on the A64.
> > >
> > > Patch 6 ~ 8 add the device tree bits and enables audio on several
> > > boards.
> > >
> > > I have one extra patch for the Bananapi M64 that's not included here,
> > > as I'm waiting for an accessory to test the microphone bias. I'll send
> > > that one out once it's tested.
> > >
> > > As always, we'll take the clock and dts patches after Mark has merged
> > > the ASoC ones.
> > >
> > > And a big thanks to Vasily for having worked on this for so long.
> >
> > Thank you for picking it up!
> >
> > Just a minor note: hpvcc-supply should be a property of codec_analog in
> > sun50i-a64-pinebook.dts
>
> Thanks. I'll fix that up when applying.

Merged the remaining 4 patches with the misplaced regulator supply property
in the last patch fixed.

ChenYu

> > Otherwise looks fine, tested on Pinebook and Pine64-LTS.
> >
> > Tested-by: Vasily Khoruzhick <[email protected]>
>
> Great!
>
> ChenYu

2018-11-26 19:16:25

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v9 3/8] ASoC: dt-bindings: add regulator property to simple amplifier

On Thu, 22 Nov 2018 18:23:20 +0800, Chen-Yu Tsai wrote:
> From: Vasily Khoruzhick <[email protected]>
>
> Amplifier may have associated regulator, so add a property for it.
>
> Signed-off-by: Vasily Khoruzhick <[email protected]>
> Signed-off-by: Chen-Yu Tsai <[email protected]>
> ---
> Documentation/devicetree/bindings/sound/simple-amplifier.txt | 5 +++++
> 1 file changed, 5 insertions(+)
>

Reviewed-by: Rob Herring <[email protected]>