Add support for audiocodec in Allwinner A64
Subsystems (4)
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.
Marcus Cooper (1):
ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
Vasily Khoruzhick (9):
ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio
ASoC: sun8i-codec: add support for speaker amp GPIO
ASoC: sun8i-codec-analog: split regmap code into separate driver
ASoC: sunxi: Add bindings for A64 codec's analog path controls
ASoC: sunxi: Add support 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 | 14 + .../boot/dts/allwinner/sun50i-a64-pine64.dts | 30 ++ .../dts/allwinner/sun50i-a64-pinebook.dts | 33 ++ .../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 | 451 ++++++++++++++++++ sound/soc/sunxi/sun8i-codec-analog.c | 79 +-- sound/soc/sunxi/sun8i-codec.c | 61 ++- sound/soc/sunxi/sunxi-adda-pr-regmap.c | 102 ++++ sound/soc/sunxi/sunxi-adda-pr-regmap.h | 7 + 14 files changed, 824 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
PATCH 1/10 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
@@ -10,6 +10,7 @@ Required properties: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-a83t-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-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-i2s" - resets: phandle to the reset line for this codec Example:
sound/soc/sunxi/sun4i-i2s.c +21 -0
@@ -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_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-i2s", + .data = &sun50i_a64_i2s_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match);
Signature · 1 line
2.19.0
PATCH 2/10 ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio
In reply to Vasily KhoruzhickBCLK / 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
@@ -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
PATCH 3/10 ASoC: sun8i-codec: add support for speaker amp GPIO
In reply to Vasily KhoruzhickSome boards may have external amplifier for speaker that is controlled via GPIO, add support for it in similar way as it's done in sun4i-codec
--- .../bindings/sound/sun8i-a33-codec.txt | 3 +++ sound/soc/sunxi/sun8i-codec.c | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+)
Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt +3 -0
@@ -25,6 +25,9 @@ Required properties: - "bus": the parent APB clock for this controller - "mod": the parent module clock +Optional properties: +- allwinner,pa-gpios: gpio to enable external amplifier + Here is an example to add a sound card and the codec binding on sun8i SoCs that are similar to A33 using simple-card:
sound/soc/sunxi/sun8i-codec.c +27 -0
@@ -24,6 +24,7 @@#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/gpio/consumer.h> #include <sound/pcm_params.h> #include <sound/soc.h>
@@ -97,8 +98,22 @@ struct sun8i_codec {struct regmap *regmap;struct clk *clk_module;struct clk *clk_bus; +struct gpio_desc *gpio_pa; }; +static int sun8i_codec_spk_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_component *component = +snd_soc_dapm_to_component (w->dapm); +struct sun8i_codec *scodec =snd_soc_component_get_drvdata (component); + +gpiod_set_value_cansleep (scodec->gpio_pa, + !!SND_SOC_DAPM_EVENT_ON (event)); + +return 0 ; +} +static int sun8i_codec_runtime_resume (struct device *dev) {struct sun8i_codec *scodec =dev_get_drvdata (dev);
@@ -432,6 +447,9 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {SOC_MIXER_ARRAY ("Right Digital ADC Mixer" ,SND_SOC_NOPM ,0 ,0 , sun8i_input_mixer_controls), +/* Speaker */ +SND_SOC_DAPM_SPK ("Speaker" , sun8i_codec_spk_event), +/* Clocks */ SND_SOC_DAPM_SUPPLY ("MODCLK AFI1" ,SUN8I_MOD_CLK_ENA , SUN8I_MOD_CLK_ENA_AIF1, 0, NULL, 0),
@@ -570,6 +588,15 @@ static int sun8i_codec_probe(struct platform_device *pdev)return PTR_ERR (scodec->clk_bus); } + scodec->gpio_pa =devm_gpiod_get_optional (&pdev->dev,"allwinner,pa" , +GPIOD_OUT_LOW ); +if (IS_ERR (scodec->gpio_pa)) { + ret =PTR_ERR (scodec->gpio_pa); +if (ret != -EPROBE_DEFER ) +dev_err (&pdev->dev,"Failed to get pa gpio: %d\n" , ret); +return ret; + } + res_base =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); base =devm_ioremap_resource (&pdev->dev, res_base);if (IS_ERR (base)) {
Signature · 1 line
2.19.0
PATCH 4/10 ASoC: sun8i-codec-analog: split regmap code into separate driver
In reply to Vasily KhoruzhickIt 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
@@ -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
@@ -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
@@ -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
PATCH 5/10 ASoC: dt-binding: Add bindings for Allwinner A64 codec's analog path controls
In reply to Vasily KhoruzhickThe 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
@@ -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
PATCH 6/10 ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path controls
In reply to Vasily KhoruzhickThe 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
@@ -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
@@ -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
PATCH 7/10 ASoC: sunxi: allow the sun8i-codec driver to be built on ARM64
In reply to Vasily KhoruzhickAllwinner 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
@@ -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
PATCH 8/10 arm64: dts: allwinner: a64: add nodes necessary for analog sound support
In reply to Vasily KhoruzhickAdd nodes for i2s, digital and analog parts of audiocodec on A64
--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +58 -0
@@ -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-i2s"; + reg = <0x01c22c00 0x200>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>; + clock-names = "apb", "mod"; + resets = <&ccu RST_BUS_CODEC>; + reset-names = "rst"; + dmas = <&dma 15>, <&dma 15>; + dma-names = "rx", "tx"; + status = "disabled"; + }; + + codec: codec at 1c22e00 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun8i-a33-codec"; + reg = <0x01c22e00 0x600>; + interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>; + clock-names = "bus", "mod"; + status = "disabled"; + }; + uart0: serial at 1c28000 { compatible = "snps,dw-apb-uart"; reg = <0x01c28000 0x400>;
@@ -715,6 +767,12 @@ #reset-cells = <1>; }; + codec_analog: codec-analog at 1f015c0 { + compatible = "allwinner,sun50i-a64-codec-analog"; + reg = <0x01f015c0 0x4>; + status = "disabled"; + }; + r_i2c: i2c at 1f02400 { compatible = "allwinner,sun50i-a64-i2c", "allwinner,sun6i-a31-i2c";
Signature · 1 line
2.19.0
PATCH 9/10 arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine
In reply to Vasily KhoruzhickThis commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.
--- .../boot/dts/allwinner/sun50i-a64-pine64.dts | 30 +++++++++++++++++++ .../allwinner/sun50i-a64-sopine-baseboard.dts | 30 +++++++++++++++++++ 2 files changed, 60 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +30 -0
@@ -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
@@ -69,6 +69,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };
@@ -138,6 +150,24 @@ vcc-hdmi-supply = <®_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
PATCH 10/10 arm64: dts: allwinner: a64: enable sound on Pinebook
In reply to Vasily KhoruzhickThis commit enables I2S, digital and analog parts of audiocodec on Pinebook
--- .../dts/allwinner/sun50i-a64-pinebook.dts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +33 -0
@@ -76,6 +76,19 @@ }; }; +&codec { + allwinner,pa-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { phys = <&usbphy 0>; phy-names = "usb";
@@ -278,6 +291,26 @@ vcc-hdmi-supply = <®_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", + "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
Re: [PATCH 03/10] ASoC: sun8i-codec: add support for speaker amp GPIO
In reply to Vasily KhoruzhickQuoted 5 lines · Vasily Khoruzhick
Some boards may have external amplifier for speaker that is controlled via GPIO, add support for it in similar way as it's done in sun4i-codec
Signed-off-by Vasily Khoruzhick <[email protected]>
ASoC now has a generic amplifier driver. Please use that instead.
See Documentation/devicetree/bindings/sound/simple-amplifier.txt
ChenYu
Re: [PATCH 03/10] ASoC: sun8i-codec: add support for speaker amp GPIO
Quoted 11 lines · Chen-Yu Tsai
Quoted 5 lines · Vasily Khoruzhick
Some boards may have external amplifier for speaker that is controlled via GPIO, add support for it in similar way as it's done in sun4i-codec
Signed-off-by Vasily Khoruzhick <[email protected]>ASoC now has a generic amplifier driver. Please use that instead.
See
Documentation/devicetree/bindings/sound/simple-amplifier.txt
Is there any example on how to use it? Documentation doesn't specify what DAPM routes I have to add to get it working.
Quoted 2 lines
ChenYu
Re: [PATCH 01/10] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Vasily KhoruzhickQuoted 19 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.
Signed-off-by Marcus Cooper <[email protected]>--- .../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 +0
-0
Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 13
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -10,6 +10,7 @@ Required properties: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-a83t-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-i2s"
This compatible is already used as the SoC-specific compatible (in case we have unforeseen differences between A64 and H3 I2S).
Since this is tied to the codec, I think it deserves a special compatible anyway.
How about "allwinner,sun50i-a64-codec-i2s" ?
The rest looks good, so once the compatible is changed,
Quoted 57 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0- 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-i2s" - resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +21
-1@@ -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_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-i2s", + .data = &sun50i_a64_i2s_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.19.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel at alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH 03/10] ASoC: sun8i-codec: add support for speaker amp GPIO
In reply to Vasily KhoruzhickQuoted 8 lines · Vasily Khoruzhick
Quoted 6 lines · Chen-Yu Tsai
Quoted 4 lines · Vasily Khoruzhick
Some boards may have external amplifier for speaker that is controlled via GPIO, add support for it in similar way as it's done in sun4i-codec
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Vasily Khoruzhick <[email protected]>ASoC now has a generic amplifier driver. Please use that instead.
See
Documentation/devicetree/bindings/sound/simple-amplifier.txtIs there any example on how to use it? Documentation doesn't specify what DAPM routes I have to add to get it working.
(CC-ed author, Jerome)
The driver lists INL, INR, OUTL, OUTR as the in and out endpoints. Not sure why they aren't in the bindings, but this driver is relatively new.
ChenYu
Re: [PATCH 01/10] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Chen-Yu TsaiQuoted 29 lines · Chen-Yu Tsai
Quoted 19 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.
Signed-off-by Marcus Cooper <[email protected]>--- .../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 +0
-0Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 13
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -10,6 +10,7 @@ Required properties: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-a83t-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-i2s"This compatible is already used as the SoC-specific compatible (in case we have unforeseen differences between A64 and H3 I2S).
Quoted 3 lines
Since this is tied to the codec, I think it deserves a special compatible anyway.
How about "allwinner,sun50i-a64-codec-i2s" ?
That's what I proposed a ~year ago and I was asked to change it to allwinner,sun50i-a64-i2c.
Quoted 62 lines
The rest looks good, so once the compatible is changed,
Reviewed-by Chen-Yu Tsai <[email protected]>Quoted 57 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0- 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-i2s" - resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +21
-1@@ -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_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-i2s", + .data = &sun50i_a64_i2s_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.19.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel at alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel