Skip to contentSkip to conversation

Add support for audiocodec in Allwinner A64

PATCH Superseded Vasily Khoruzhick 2 participants 19 messages Oct 13, 2018 – Oct 19, 2018

Subsystems (4)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for audiocodec in Allwinner A64

This series adds Allwinner A64 audiocodec support into sun4i-i2s, sun8i-codec drivers, introduces new sun50i-codec-analog driver and enables sound on Pine64, SoPine boards and Pinebook.

I2S for audiocodec in A64 is different from other 3 I2S modules but similar to one in A10, digital part of codec is compatible with A33 and analog controls part is completely different from other SoCs - it shares only few bits in few registers, so adding support for it into existing sun8i-codec-analog would mean duplicating all the widgets, controls and some routes and making it hard to read. Therefore it makes sense to introduce new driver.

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

Marcus Cooper (1):
ASoC: sun4i-i2s: Add compatibility with A64 codec I2S

Vasily Khoruzhick (8):
ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio
ASoC: sun8i-codec-analog: split regmap code into separate driver
ASoC: dt-binding: Add bindings for Allwinner A64 codec's analog path
controls
ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path
controls
ASoC: sunxi: allow the sun8i-codec driver to be built on ARM64
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

 .../devicetree/bindings/sound/sun4i-i2s.txt   |   2 +
 .../bindings/sound/sun50i-codec-analog.txt    |  12 +
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  |  30 ++
 .../dts/allwinner/sun50i-a64-pinebook.dts     |  42 ++
 .../allwinner/sun50i-a64-sopine-baseboard.dts |  30 ++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi |  58 +++
 sound/soc/sunxi/Kconfig                       |  17 +-
 sound/soc/sunxi/Makefile                      |   2 +
 sound/soc/sunxi/sun4i-i2s.c                   |  21 +
 sound/soc/sunxi/sun50i-codec-analog.c         | 444 ++++++++++++++++++
 sound/soc/sunxi/sun8i-codec-analog.c          |  79 +---
 sound/soc/sunxi/sun8i-codec.c                 |  35 +-
 sound/soc/sunxi/sunxi-adda-pr-regmap.c        | 102 ++++
 sound/soc/sunxi/sunxi-adda-pr-regmap.h        |   7 +
 14 files changed, 798 insertions(+), 83 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
 create mode 100644 sound/soc/sunxi/sun50i-codec-analog.c
 create mode 100644 sound/soc/sunxi/sunxi-adda-pr-regmap.c
 create mode 100644 sound/soc/sunxi/sunxi-adda-pr-regmap.h
Signature · 1 line
2.19.0
#1 lore raw

PATCH v2 1/9 ASoC: sun4i-i2s: Add compatibility with A64 codec I2S

From: Marcus Cooper <[email protected]>

The I2S block used for the audio codec in the A64 differs from other 3 I2S modules in A64 and isn't compatible with H3. But it is very similar to what is found in A10(sun4i). However, its TX FIFO is located at a different address.

---
 .../devicetree/bindings/sound/sun4i-i2s.txt   |  2 ++
 sound/soc/sunxi/sun4i-i2s.c                   | 21 +++++++++++++++++++
 2 files changed, 23 insertions(+)
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +2 -0
index b9d50d6cdef3..61e71c1729e0 100644
@@ -10,6 +10,7 @@ Required properties:
    - "allwinner,sun6i-a31-i2s"
    - "allwinner,sun8i-a83t-i2s"
    - "allwinner,sun8i-h3-i2s"
+   - "allwinner,sun50i-a64-codec-i2s"
 - reg: physical base address of the controller and length of memory mapped
   region.
 - interrupts: should contain the I2S interrupt.
@@ -26,6 +27,7 @@ Required properties for the following compatibles:
 	- "allwinner,sun6i-a31-i2s"
 	- "allwinner,sun8i-a83t-i2s"
 	- "allwinner,sun8i-h3-i2s"
+	- "allwinner,sun50i-a64-codec-i2s"
 - resets: phandle to the reset line for this codec
 
 Example:
sound/soc/sunxi/sun4i-i2s.c +21 -0
index ed30d30ac720..83374617962c 100644
@@ -967,6 +967,23 @@ static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = {
 	.field_rxchansel	= REG_FIELD(SUN8I_I2S_RX_CHAN_SEL_REG, 0, 2),
 };
 
+static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = {
+	.has_reset		= true,
+	.reg_offset_txdata	= SUN8I_I2S_FIFO_TX_REG,
+	.sun4i_i2s_regmap	= &sun4i_i2s_regmap_config,
+	.has_slave_select_bit	= true,
+	.field_clkdiv_mclk_en	= REG_FIELD(SUN4I_I2S_CLK_DIV_REG, 7, 7),
+	.field_fmt_wss		= REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3),
+	.field_fmt_sr		= REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
+	.field_fmt_bclk		= REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6),
+	.field_fmt_lrclk	= REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7),
+	.field_fmt_mode		= REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1),
+	.field_txchanmap	= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
+	.field_rxchanmap	= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
+	.field_txchansel	= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
+	.field_rxchansel	= REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2),
+};
+
 static int sun4i_i2s_init_regmap_fields(struct device *dev,
 					struct sun4i_i2s *i2s)
 {
@@ -1175,6 +1192,10 @@ static const struct of_device_id sun4i_i2s_match[] = {
 		.compatible = "allwinner,sun8i-h3-i2s",
 		.data = &sun8i_h3_i2s_quirks,
 	},
+	{
+		.compatible = "allwinner,sun50i-a64-codec-i2s",
+		.data = &sun50i_a64_codec_i2s_quirks,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, sun4i_i2s_match);
Signature · 1 line
2.19.0
Acked-by on v2 1/9
#2 lore raw

Re: [PATCH v2 1/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S

Quoted 9 lines · Vasily Khoruzhick

From: Marcus Cooper <[email protected]>

The I2S block used for the audio codec in the A64 differs from other 3 I2S modules in A64 and isn't compatible with H3. But it is very similar to what is found in A10(sun4i). However, its TX FIFO is located at a different address.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181015/6cdbe2ca/attachment.sig>
#3 lore raw

Re: [PATCH v2 1/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S

Quoted 8 lines · PDT Maxime Ripard
Quoted 7 lines · Vasily Khoruzhick

From: Marcus Cooper <[email protected]>

The I2S block used for the audio codec in the A64 differs from other 3 I2S modules in A64 and isn't compatible with H3. But it is very similar to what is found in A10(sun4i). However, its TX FIFO is located at a different address.

Quoted 4 lines
Quoted 2 lines

Mark, can you pick this patch up please?

Thanks!

Regards,
Vasily

Quoted 2 lines

Maxime

#4 lore raw

Re: [PATCH v2 1/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S

Quoted 10 lines · Vasily Khoruzhick
Quoted 8 lines · PDT Maxime Ripard
Quoted 7 lines · Vasily Khoruzhick

From: Marcus Cooper <[email protected]>

The I2S block used for the audio codec in the A64 differs from other 3 I2S modules in A64 and isn't compatible with H3. But it is very similar to what is found in A10(sun4i). However, its TX FIFO is located at a different address.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Mark, can you pick this patch up please?

Ooops, wrong patch, please ignore this message.

Quoted 12 lines

Thanks!

Regards,
Vasily

Quoted 2 lines

Maxime

#5 lore raw

PATCH v2 2/9 ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio

In reply to Vasily Khoruzhick

BCLK / LRCK ratio should be sample size * channels, but it was hardcoded to 32 (0x1 is 32 as per A33 and A64 datasheets).

Calculate it basing on sample size and number of channels.

---
 sound/soc/sunxi/sun8i-codec.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
sound/soc/sunxi/sun8i-codec.c +30 -5
index fb37dd927e33..e681e194ad4c 100644
@@ -52,7 +52,6 @@
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV		13
 #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV		9
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV		6
-#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16		(1 << 6)
 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ		4
 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16		(1 << 4)
 #define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT		2
@@ -257,8 +256,8 @@ static int sun8i_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 }
 
 struct sun8i_codec_clk_div {
-	u8	div;
-	u8	val;
+	unsigned int	div;
+	u8		val;
 };
 
 static const struct sun8i_codec_clk_div sun8i_codec_bclk_div[] = {
@@ -300,12 +299,33 @@ static u8 sun8i_codec_get_bclk_div(struct sun8i_codec *scodec,
 	return best_val;
 }
 
+static const struct sun8i_codec_clk_div sun8i_codec_lrck_div[] = {
+	{ .div = 16,	.val = 0 },
+	{ .div = 32,	.val = 1 },
+	{ .div = 64,	.val = 2 },
+	{ .div = 128,	.val = 3 },
+	{ .div = 256,	.val = 4 },
+};
+
+static int sun8i_codec_get_lrck_div(unsigned int channels,
+				    unsigned int word_size)
+{
+	unsigned int div = word_size * channels;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(sun8i_codec_lrck_div); i++)
+		if (sun8i_codec_lrck_div[i].div == div)
+			return sun8i_codec_lrck_div[i].val;
+
+	return -EINVAL;
+}
+
 static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,
 				 struct snd_pcm_hw_params *params,
 				 struct snd_soc_dai *dai)
 {
 	struct sun8i_codec *scodec = snd_soc_component_get_drvdata(dai->component);
-	int sample_rate;
+	int sample_rate, lrck_div;
 	u8 bclk_div;
 
 	/*
@@ -321,9 +341,14 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,
 			   SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK,
 			   bclk_div << SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV);
 
+	lrck_div = sun8i_codec_get_lrck_div(params_channels(params),
+					    params_physical_width(params));
+	if (lrck_div < 0)
+		return lrck_div;
+
 	regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
 			   SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK,
-			   SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16);
+			   lrck_div << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV);
 
 	sample_rate = sun8i_codec_get_hw_rate(params);
 	if (sample_rate < 0)
Signature · 1 line
2.19.0
#6 lore raw

Re: [PATCH v2 2/9] ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio

Quoted 34 lines · Vasily Khoruzhick

BCLK / LRCK ratio should be sample size * channels, but it was hardcoded to 32 (0x1 is 32 as per A33 and A64 datasheets).

Calculate it basing on sample size and number of channels.

---
 sound/soc/sunxi/sun8i-codec.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
sound/soc/sunxi/sun8i-codec.c +2 -3
index fb37dd927e33..e681e194ad4c 100644
@@ -52,7 +52,6 @@
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV		13
 #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV		9
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV		6
-#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16		(1 << 6)
 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ		4
 #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16		(1 << 4)
 #define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT		2
@@ -257,8 +256,8 @@ static int sun8i_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 }
 
 struct sun8i_codec_clk_div {
-	u8	div;
-	u8	val;
+	unsigned int	div;
+	u8		val;
 };
 
 static const struct sun8i_codec_clk_div sun8i_codec_bclk_div[] = {

sound/soc/sunxi/sun8i-codec.c static u8 sun8i_codec_get_bclk_div(struct sun8i_codec *scodec, · line 308

Quoted 10 lines
sound/soc/sunxi/sun8i-codec.c +7 -0
@@ -300,12 +299,33 @@ static u8 sun8i_codec_get_bclk_div(struct sun8i_codec *scodec,
 	return best_val;
 }
 
+static const struct sun8i_codec_clk_div sun8i_codec_lrck_div[] = {
+	{ .div = 16,	.val = 0 },
+	{ .div = 32,	.val = 1 },
+	{ .div = 64,	.val = 2 },
+	{ .div = 128,	.val = 3 },
+	{ .div = 256,	.val = 4 },
+};

That's log2(div) - 4, right? There's no need to store the table if so.

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

Re: [PATCH v2 2/9] ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio

Quoted 49 lines · PDT Maxime Ripard
Quoted 48 lines · Vasily Khoruzhick

BCLK / LRCK ratio should be sample size * channels, but it was hardcoded to 32 (0x1 is 32 as per A33 and A64 datasheets).

Calculate it basing on sample size and number of channels.

---

 sound/soc/sunxi/sun8i-codec.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
sound/soc/sunxi/sun8i-codec.c +0 -1
index fb37dd927e33..e681e194ad4c 100644
@@ -52,7 +52,6 @@
 
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV		13
 #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV		9
 #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV		6
 
-#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16		(1 << 6)
 

#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4
#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16 (1 << 4)
#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2

sound/soc/sunxi/sun8i-codec.c +0 -0
@@ -257,8 +256,8 @@ static int sun8i_set_fmt(struct snd_soc_dai *dai,

unsigned int fmt)>
}

struct sun8i_codec_clk_div {

sound/soc/sunxi/sun8i-codec.c +2 -2
-	u8	div;
-	u8	val;
+	unsigned int	div;
+	u8		val;
 
 };
 
 static const struct sun8i_codec_clk_div sun8i_codec_bclk_div[] = {
@@ -300,12 +299,33 @@ static u8 sun8i_codec_get_bclk_div(struct

sun8i_codec *scodec,>
return best_val;

}

Quoted 9 lines

sound/soc/sunxi/sun8i-codec.c static u8 sun8i_codec_get_bclk_div(struct sun8i_codec *scodec, · line 308

Quoted 7 lines
sound/soc/sunxi/sun8i-codec.c +7 -0
+static const struct sun8i_codec_clk_div sun8i_codec_lrck_div[] = {
+	{ .div = 16,	.val = 0 },
+	{ .div = 32,	.val = 1 },
+	{ .div = 64,	.val = 2 },
+	{ .div = 128,	.val = 3 },
+	{ .div = 256,	.val = 4 },
+};

That's log2(div) - 4, right? There's no need to store the table if so.

OK, will fix in v3

Quoted 1 line

Maxime

#8 lore raw

PATCH v2 3/9 ASoC: sun8i-codec-analog: split regmap code into separate driver

In reply to Vasily Khoruzhick

It will be reused by sun50i-codec-analog later.

---
 sound/soc/sunxi/Kconfig                |   7 +-
 sound/soc/sunxi/Makefile               |   1 +
 sound/soc/sunxi/sun8i-codec-analog.c   |  79 +------------------
 sound/soc/sunxi/sunxi-adda-pr-regmap.c | 102 +++++++++++++++++++++++++
 sound/soc/sunxi/sunxi-adda-pr-regmap.h |   7 ++
 5 files changed, 119 insertions(+), 77 deletions(-)
 create mode 100644 sound/soc/sunxi/sunxi-adda-pr-regmap.c
 create mode 100644 sound/soc/sunxi/sunxi-adda-pr-regmap.h
sound/soc/sunxi/Kconfig +6 -1
index 22408bc2d6ec..3932f0238add 100644
@@ -23,7 +23,7 @@ config SND_SUN8I_CODEC
 config SND_SUN8I_CODEC_ANALOG
 	tristate "Allwinner sun8i Codec Analog Controls Support"
 	depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST
-	select REGMAP
+	select SND_SUNXI_ADDA_PR_REGMAP
 	help
 	  Say Y or M if you want to add support for the analog controls for
 	  the codec embedded in newer Allwinner SoCs.
@@ -45,4 +45,9 @@ config SND_SUN4I_SPDIF
 	help
 	  Say Y or M to add support for the S/PDIF audio block in the Allwinner
 	  A10 and affiliated SoCs.
+
+config SND_SUNXI_ADDA_PR_REGMAP
+	tristate
+	select REGMAP
+
 endmenu
sound/soc/sunxi/Makefile +1 -0
index 4a9ef67386ca..6406455e03a4 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
 obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
 obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
 obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
+obj-$(CONFIG_SND_SUNXI_ADDA_PR_REGMAP) += sunxi-adda-pr-regmap.o
sound/soc/sunxi/sun8i-codec-analog.c +3 -76

97 lines not on this page · raw message

sound/soc/sunxi/sunxi-adda-pr-regmap.c new file +102 -0

102 lines not on this page · raw message

sound/soc/sunxi/sunxi-adda-pr-regmap.h new file +7 -0
new file mode 100644
index 000000000000..6074c0c4864d
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Vasily Khoruzhick <[email protected]>
+ */
+
+struct regmap *sunxi_adda_pr_regmap_init(struct device *dev,
+					 void __iomem *base);
Signature · 1 line
2.19.0
Acked-by on v2 3/9
#9 lore raw

Re: [PATCH v2 3/9] ASoC: sun8i-codec-analog: split regmap code into separate driver

Hi,

Quoted 27 lines · Vasily Khoruzhick

It will be reused by sun50i-codec-analog later.

---
 sound/soc/sunxi/Kconfig                |   7 +-
 sound/soc/sunxi/Makefile               |   1 +
 sound/soc/sunxi/sun8i-codec-analog.c   |  79 +------------------
 sound/soc/sunxi/sunxi-adda-pr-regmap.c | 102 +++++++++++++++++++++++++
 sound/soc/sunxi/sunxi-adda-pr-regmap.h |   7 ++
 5 files changed, 119 insertions(+), 77 deletions(-)
 create mode 100644 sound/soc/sunxi/sunxi-adda-pr-regmap.c
 create mode 100644 sound/soc/sunxi/sunxi-adda-pr-regmap.h
sound/soc/sunxi/Kconfig +1 -1
index 22408bc2d6ec..3932f0238add 100644
@@ -23,7 +23,7 @@ config SND_SUN8I_CODEC
 config SND_SUN8I_CODEC_ANALOG
 	tristate "Allwinner sun8i Codec Analog Controls Support"
 	depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST
-	select REGMAP
+	select SND_SUNXI_ADDA_PR_REGMAP
 	help
 	  Say Y or M if you want to add support for the analog controls for
 	  the codec embedded in newer Allwinner SoCs.

sound/soc/sunxi/Kconfig config SND_SUN4I_SPDIF · line 52

Quoted 8 lines
sound/soc/sunxi/Kconfig +5 -0
@@ -45,4 +45,9 @@ config SND_SUN4I_SPDIF
 	help
 	  Say Y or M to add support for the S/PDIF audio block in the Allwinner
 	  A10 and affiliated SoCs.
+
+config SND_SUNXI_ADDA_PR_REGMAP
+	tristate
+	select REGMAP
+

This is just a minor nitpick, but I'd rename it to SND_SUN8I_CODEC_ADDA, to be consistent with the rest of the drivers/Kconfig symbols.

With that fixed,

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181015/f6a665cd/attachment.sig>
#10 lore raw

PATCH v2 4/9 ASoC: dt-binding: Add bindings for Allwinner A64 codec's analog path controls

In reply to Vasily Khoruzhick

The internal codec on Allwinner A64 is split into 2 parts. The analog path controls are routed through an embedded custom register bus accessed through the PRCM block just as on A23/A33/H3.

Add a binding for this hardware.

---
 .../bindings/sound/sun50i-codec-analog.txt           | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt
Documentation/devicetree/bindings/sound/sun50i-codec-analog.txt new file +12 -0
new file mode 100644
index 000000000000..4f8ad0e04d20
@@ -0,0 +1,12 @@
+* Allwinner A64 Codec Analog Controls
+
+Required properties:
+- compatible: must be one of the following compatibles:
+		- "allwinner,sun50i-a64-codec-analog"
+- reg: must contain the registers location and length
+
+Example:
+	codec_analog: codec-analog at 1f015c0 {
+		compatible = "allwinner,sun50i-a64-codec-analog";
+		reg = <0x01f015c0 0x4>;
+	};
Signature · 1 line
2.19.0
Acked-by on v2 4/9
#11 lore raw

Re: [PATCH v2 4/9] ASoC: dt-binding: Add bindings for Allwinner A64 codec's analog path controls

Quoted 7 lines · Vasily Khoruzhick

The internal codec on Allwinner A64 is split into 2 parts. The analog path controls are routed through an embedded custom register bus accessed through the PRCM block just as on A23/A33/H3.

Add a binding for this hardware.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181015/75e5605a/attachment.sig>
#12 lore raw

PATCH v2 5/9 ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path controls

In reply to Vasily Khoruzhick

The internal codec on A64 is split into 2 parts. The analog path controls are routed through an embedded custom register bus accessed through the PRCM block.

Add an ASoC component driver for it. This should be tied to the codec audio card as an auxiliary device.

---
 sound/soc/sunxi/Kconfig               |   8 +
 sound/soc/sunxi/Makefile              |   1 +
 sound/soc/sunxi/sun50i-codec-analog.c | 444 ++++++++++++++++++++++++++
 3 files changed, 453 insertions(+)
 create mode 100644 sound/soc/sunxi/sun50i-codec-analog.c
sound/soc/sunxi/Kconfig +8 -0
index 3932f0238add..da1aac68ab03 100644
@@ -28,6 +28,14 @@ config SND_SUN8I_CODEC_ANALOG
 	  Say Y or M if you want to add support for the analog controls for
 	  the codec embedded in newer Allwinner SoCs.
 
+config SND_SUN50I_CODEC_ANALOG
+	tristate "Allwinner sun50i Codec Analog Controls Support"
+	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST
+	select SND_SUNXI_ADDA_PR_REGMAP
+	help
+	  Say Y or M if you want to add support for the analog controls for
+	  the codec embedded in Allwinner A64 SoC.
+
 config SND_SUN4I_I2S
 	tristate "Allwinner A10 I2S Support"
 	select SND_SOC_GENERIC_DMAENGINE_PCM
sound/soc/sunxi/Makefile +1 -0
index 6406455e03a4..ee5bdad63dd6 100644
@@ -3,5 +3,6 @@ obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
 obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
 obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
 obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
+obj-$(CONFIG_SND_SUN50I_CODEC_ANALOG) += sun50i-codec-analog.o
 obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
 obj-$(CONFIG_SND_SUNXI_ADDA_PR_REGMAP) += sunxi-adda-pr-regmap.o
sound/soc/sunxi/sun50i-codec-analog.c new file +444 -0

444 lines not on this page · raw message

Signature · 1 line
2.19.0
Acked-by on v2 5/9
#13 lore raw

Re: [PATCH v2 5/9] ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path controls

Quoted 8 lines · Vasily Khoruzhick

The internal codec on A64 is split into 2 parts. The analog path controls are routed through an embedded custom register bus accessed through the PRCM block.

Add an ASoC component driver for it. This should be tied to the codec audio card as an auxiliary device.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181015/25091c2c/attachment.sig>
#14 lore raw

PATCH v2 6/9 ASoC: sunxi: allow the sun8i-codec driver to be built on ARM64

In reply to Vasily Khoruzhick

Allwinner A64 uses the same digital codec part as in A33, so we need to build this driver on ARM64 as well.

---
 sound/soc/sunxi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sunxi/Kconfig +1 -1
index da1aac68ab03..0f992bdf1a10 100644
@@ -12,7 +12,7 @@ config SND_SUN4I_CODEC
 config SND_SUN8I_CODEC
 	tristate "Allwinner SUN8I audio codec"
 	depends on OF
-	depends on MACH_SUN8I || COMPILE_TEST
+	depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST
 	select REGMAP_MMIO
 	help
 	  This option enables the digital part of the internal audio codec for
Signature · 1 line
2.19.0
Acked-by on v2 6/9
#15 lore raw

Re: [PATCH v2 6/9] ASoC: sunxi: allow the sun8i-codec driver to be built on ARM64

Quoted 4 lines · Vasily Khoruzhick

Allwinner A64 uses the same digital codec part as in A33, so we need to build this driver on ARM64 as well.

Thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#16 lore raw

PATCH v2 7/9 arm64: dts: allwinner: a64: add nodes necessary for analog sound support

In reply to Vasily Khoruzhick

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

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +58 -0
index d3daf90a8715..d066ed59f27a 100644
@@ -157,6 +157,34 @@
 		compatible = "linux,spdif-dit";
 	};
 
+	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",
+				"Left ADC", "ADC",
+				"Right ADC", "ADC",
+				"MIC1", "Mic",
+				"MIC2", "Headset Mic";
+		status = "disabled";
+
+		cpudai: simple-audio-card,cpu {
+			sound-dai = <&dai>;
+		};
+
+		link_codec: simple-audio-card,codec {
+			sound-dai = <&codec>;
+		};
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13
@@ -522,6 +550,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>;
@@ -715,6 +767,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";
Signature · 1 line
2.19.0
#17 lore raw

PATCH v2 8/9 arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine

In reply to Vasily Khoruzhick

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

---
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  | 30 +++++++++++++++++++
 .../allwinner/sun50i-a64-sopine-baseboard.dts | 30 +++++++++++++++++++
 2 files changed, 60 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +30 -0
index 1b9b92e541d2..902f988d0a9e 100644
@@ -64,6 +64,18 @@
 	};
 };
 
+&codec {
+	status = "okay";
+};
+
+&codec_analog {
+	status = "okay";
+};
+
+&dai {
+	status = "okay";
+};
+
 &ehci0 {
 	status = "okay";
 };
@@ -238,6 +250,24 @@
 	status = "disabled";
 };
 
+&sound {
+	status = "okay";
+	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",
+			"Speaker", "LINEOUT",
+			"Headphone Jack", "HP",
+			"AIF1 Slot 0 Left ADC", "Left ADC",
+			"AIF1 Slot 0 Right ADC", "Right ADC",
+			"Left ADC", "ADC",
+			"Right ADC", "ADC",
+			"Headset Mic", "Microphone Jack",
+			"Microphone Jack", "HBIAS",
+			"MIC2", "Headset Mic";
+};
+
 /* On Exp and Euler connectors */
 &uart0 {
 	pinctrl-names = "default";
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +30 -0
index c21f2331add6..b131b7aec24e 100644
@@ -69,6 +69,18 @@
 	};
 };
 
+&codec {
+	status = "okay";
+};
+
+&codec_analog {
+	status = "okay";
+};
+
+&dai {
+	status = "okay";
+};
+
 &ehci0 {
 	status = "okay";
 };
@@ -138,6 +150,24 @@
 	vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+	status = "okay";
+	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",
+			"Speaker", "LINEOUT",
+			"Headphone Jack", "HP",
+			"AIF1 Slot 0 Left ADC", "Left ADC",
+			"AIF1 Slot 0 Right ADC", "Right ADC",
+			"Left ADC", "ADC",
+			"Right ADC", "ADC",
+			"Headset Mic", "Microphone Jack",
+			"Microphone Jack", "HBIAS",
+			"MIC2", "Headset Mic";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pins_a>;
Signature · 1 line
2.19.0
#18 lore raw

PATCH v2 9/9 arm64: dts: allwinner: a64: enable sound on Pinebook

In reply to Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pinebook

---
 .../dts/allwinner/sun50i-a64-pinebook.dts     | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +42 -0
index e2e426334cfe..8a3a24a09d4c 100644
@@ -74,6 +74,23 @@
 		compatible = "mmc-pwrseq-simple";
 		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
 	};
+
+	speaker_amp: speaker_amp {
+		compatible = "simple-audio-amplifier";
+		enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>;
+	};
+};
+
+&codec {
+	status = "okay";
+};
+
+&codec_analog {
+	status = "okay";
+};
+
+&dai {
+	status = "okay";
 };
 
 &ehci0 {
@@ -278,6 +295,31 @@
 	vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+	status = "okay";
+	simple-audio-card,widgets = "Microphone", "Microphone Jack",
+				    "Headphone", "Headphone Jack",
+				    "Speaker", "Internal Speaker";
+	simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
+	simple-audio-card,routing =
+			"Left DAC", "AIF1 Slot 0 Left",
+			"Right DAC", "AIF1 Slot 0 Right",
+			"INL", "LINEOUT",
+			"INR", "LINEOUT",
+			"Internal Speaker", "OUTL",
+			"Internal Speaker", "OUTR",
+			"Headphone Jack", "HP",
+			"AIF1 Slot 0 Left ADC", "Left ADC",
+			"AIF1 Slot 0 Right ADC", "Right ADC",
+			"Left ADC", "ADC",
+			"Right ADC", "ADC",
+			"Mic", "MBIAS",
+			"MIC1", "Mic",
+			"Headset Mic", "Microphone Jack",
+			"Microphone Jack", "HBIAS",
+			"MIC2", "Headset Mic";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pins_a>;
Signature · 1 line
2.19.0