Add audiocodec support for A64 SoC
Subsystems (4)
cover Add audiocodec support for A64 SoC
This series adds A64 audiocodec support into sun4i-i2s, sun8i-codec and sun8i-codec-analog drivers and enables sound on Pine64 and SoPine boards.
Marcus Cooper (3):
ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
ASoC: sun8i-codec-analog: Use callbacks to add headphones and lineout
outputs
ASoC: sun8i-codec-analog: Add support for A64 SoC
Vasily Khoruzhick (6):
ASoC: sun4i-i2s: Add quirk to handle fixed WSS
ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value
ASoC: sun8i-codec: Add support for A64 SoC
ASoC: sun8i-codec-analog: Add component driver field to quirks
structure
arm64: dts: allwinner: a64: Add nodes necessary for analog sound
support
arm64: dts: allwinner: a64: Enable sound on Pine64 and SoPine
.../devicetree/bindings/sound/sun4i-i2s.txt | 2 +
.../bindings/sound/sun8i-codec-analog.txt | 1 +
.../sound/{sun8i-a33-codec.txt => sun8i-codec.txt} | 6 +-
.../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 16 ++
.../dts/allwinner/sun50i-a64-sopine-baseboard.dts | 16 ++
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 52 ++++
sound/soc/sunxi/Kconfig | 2 +-
sound/soc/sunxi/sun4i-i2s.c | 53 +++-
sound/soc/sunxi/sun8i-codec-analog.c | 307 ++++++++++++++++++---
sound/soc/sunxi/sun8i-codec.c | 47 +++-
10 files changed, 458 insertions(+), 44 deletions(-)
rename Documentation/devicetree/bindings/sound/{sun8i-a33-codec.txt => sun8i-codec.txt} (91%)Signature · 1 line
2.15.0
PATCH 1/9 ASoC: sun4i-i2s: Add quirk to handle fixed WSS
I2S for audio codec on sun50i-A64 always uses fixed word select size value, no matter what is sample width. Add quirk to support that.
--- sound/soc/sunxi/sun4i-i2s.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
sound/soc/sunxi/sun4i-i2s.c +26 -4
@@ -132,6 +132,8 @@* @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. * @fmt_offset: Value by which wss and sr needs to be adjusted. +* @fixed_wss: Hardcoded 'word select size' value needs to be used +* @wss_value: Value to be used as WSS if fixed_wss is set * @field_clkdiv_mclk_en: regmap field to enable mclk output. * @field_fmt_wss: regmap field to set word select size. * @field_fmt_sr: regmap field to set sample resolution.
@@ -150,11 +152,13 @@ struct sun4i_i2s_quirks {bool has_chcfg;bool has_chsel_tx_chen;bool has_chsel_offset; +bool fixed_wss;unsigned int reg_offset_txdata;/* TX FIFO */ const struct regmap_config *sun4i_i2s_regmap;unsigned int mclk_offset;unsigned int bclk_offset;unsigned int fmt_offset; +unsigned int wss_value;/* Register fields for i2s */ struct reg_field field_clkdiv_mclk_en;
@@ -345,7 +349,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct sun4i_i2s *i2s =snd_soc_dai_get_drvdata (dai); -int sr, wss, channels; +int sr, wss, channels, pwidth;u32 width; channels =params_channels (params);
@@ -386,7 +390,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, } i2s->playback_dma_data.addr_width = width; -switch (params_width (params)) { + pwidth =params_width (params); +switch (pwidth) {case 16 : sr =0 ; wss =0 ;
@@ -396,13 +401,30 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,return -EINVAL ; } +if (i2s->variant->fixed_wss) { + wss = i2s->variant->wss_value; +switch (wss) { +case 0 : + pwidth =16 ; +break ; +case 1 : + pwidth =20 ; +break ; +case 2 : + pwidth =24 ; +break ; +case 3 : + pwidth =32 ; +break ; + } + } +regmap_field_write (i2s->field_fmt_wss, wss + i2s->variant->fmt_offset);regmap_field_write (i2s->field_fmt_sr, sr + i2s->variant->fmt_offset); -return sun4i_i2s_set_clk_rate (i2s,params_rate (params), -params_width (params)); +return sun4i_i2s_set_clk_rate (i2s,params_rate (params), pwidth); }static int sun4i_i2s_set_fmt (struct snd_soc_dai *dai,unsigned int fmt)
Signature · 1 line
2.15.0
PATCH 2/9 ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Vasily KhoruzhickFrom: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added fixed_wss and wss_value to A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]
--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +2 -0
@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.
@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - resets: phandle to the reset line for this codec Example:
sound/soc/sunxi/sun4i-i2s.c +23 -0
@@ -942,6 +942,25 @@ 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_acodec_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, + .fixed_wss = true, + .wss_value =3 , + .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) {
@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match);
Signature · 1 line
2.15.0
PATCH 3/9 ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value
In reply to Vasily KhoruzhickLRCK divider for A64 differs from A33, so add a quirk to support that.
--- sound/soc/sunxi/sun8i-codec.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)
sound/soc/sunxi/sun8i-codec.c +32 -6
@@ -24,6 +24,7 @@#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/of_device.h> #include <sound/pcm_params.h> #include <sound/soc.h>
@@ -75,11 +76,22 @@#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6)#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9) +/* +* struct sun8i_codec_quirks - Differences between SoC variants. +* +* @aif1_lrck_div: LRCK divider +*/ +struct sun8i_codec_quirks { +unsigned int aif1_lrck_div; +}; + +struct sun8i_codec { -struct device *dev; -struct regmap *regmap; -struct clk *clk_module; -struct clk *clk_bus; +struct device *dev; +struct regmap *regmap; +struct clk *clk_module; +struct clk *clk_bus; +const struct sun8i_codec_quirks *variant; };static int sun8i_codec_runtime_resume (struct device *dev)
@@ -305,7 +317,7 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,regmap_update_bits (scodec->regmap,SUN8I_AIF1CLK_CTRL ,SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK , -SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 ); + scodec->variant->aif1_lrck_div); sample_rate =sun8i_codec_get_hw_rate (params);if (sample_rate <0 )
@@ -440,6 +452,10 @@ static const struct regmap_config sun8i_codec_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct sun8i_codec_quirks sun8i_a33_codec_quirks = { + .aif1_lrck_div =SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 , +}; +static int sun8i_codec_probe (struct platform_device *pdev) {struct resource *res_base;
@@ -453,6 +469,13 @@ static int sun8i_codec_probe(struct platform_device *pdev) scodec->dev = &pdev->dev; + scodec->variant =of_device_get_match_data (&pdev->dev); +if (!scodec->variant) { +dev_err (&pdev->dev,"Failed to determine the quirks to use\n" ); +return -ENODEV ; + } + + scodec->clk_module =devm_clk_get (&pdev->dev,"mod" );if (IS_ERR (scodec->clk_module)) {dev_err (&pdev->dev,"Failed to get the module clock\n" );
@@ -524,7 +547,10 @@ static int sun8i_codec_remove(struct platform_device *pdev) }static const struct of_device_id sun8i_codec_of_match[] = { - { .compatible ="allwinner,sun8i-a33-codec" }, + { + .compatible ="allwinner,sun8i-a33-codec" , + .data = &sun8i_a33_codec_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun8i_codec_of_match);
Signature · 1 line
2.15.0
PATCH 4/9 ASoC: sun8i-codec: Add support for A64 SoC
In reply to Vasily KhoruzhickDigital part of audio codec block in the A64 is very similar to what is used by the A33(sun8i) devices. However, it uses different LRCK divider.
---
.../bindings/sound/{sun8i-a33-codec.txt => sun8i-codec.txt} | 6 ++++--
sound/soc/sunxi/sun8i-codec.c | 9 +++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
rename Documentation/devicetree/bindings/sound/{sun8i-a33-codec.txt => sun8i-codec.txt} (91%)Documentation/devicetree/bindings/sound/sun8i-codec.txt renamed from Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt +4 -2
@@ -1,7 +1,7 @@ Allwinner SUN8I audio codec ------------------------------------ -On Sun8i-A33 SoCs, the audio is separated in different parts: +On Sun8i-A33 and Sun50i-A64 SoCs, the audio is separated in different parts: - A DAI driver. It uses the "sun4i-i2s" driver which is documented here: Documentation/devicetree/bindings/sound/sun4i-i2s.txt
@@ -16,7 +16,9 @@ On Sun8i-A33 SoCs, the audio is separated in different parts: This bindings documentation exposes Sun8i codec (digital part). Required properties: -- compatible: must be "allwinner,sun8i-a33-codec" +- compatible: should be one of the following: + - "allwinner,sun8i-a33-codec" + - "allwinner,sun50i-a64-codec" - reg: must contain the registers location and length - interrupts: must contain the codec interrupt - clocks: a list of phandle + clock-specifer pairs, one for each entry
sound/soc/sunxi/sun8i-codec.c +9 -0
@@ -52,6 +52,7 @@#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_LRCK_DIV_64 (2 << 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
@@ -456,6 +457,10 @@ static const struct sun8i_codec_quirks sun8i_a33_codec_quirks = { .aif1_lrck_div = SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16, }; +static const struct sun8i_codec_quirks sun50i_a64_codec_quirks = { + .aif1_lrck_div =SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_64 , +}; +static int sun8i_codec_probe (struct platform_device *pdev) {struct resource *res_base;
@@ -551,6 +556,10 @@ static const struct of_device_id sun8i_codec_of_match[] = { .compatible = "allwinner,sun8i-a33-codec", .data = &sun8i_a33_codec_quirks, }, + { + .compatible = "allwinner,sun50i-a64-codec", + .data = &sun50i_a64_codec_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun8i_codec_of_match);
Signature · 1 line
2.15.0
PATCH 5/9 ASoC: sun8i-codec-analog: Use callbacks to add headphones and lineout outputs
In reply to Vasily KhoruzhickFrom: Marcus Cooper <[email protected]>
Widgets for headphones and lineout outputs on A64 are different enough and use different regs, so move addition of these outputs into callback to simplify upcoming A64 support.
--- sound/soc/sunxi/sun8i-codec-analog.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
sound/soc/sunxi/sun8i-codec-analog.c +19 -10
@@ -397,7 +397,7 @@ static const struct snd_soc_dapm_route sun8i_codec_mixer_routes[] = {/* headphone specific controls, widgets, and routes */ static const DECLARE_TLV_DB_SCALE(sun8i_codec_hp_vol_scale, -6300, 100, 1); -static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] = { +static const struct snd_kcontrol_new sun8i_a23_codec_hp_ctrls[] = { SOC_SINGLE_TLV("Headphone Playback Volume", SUN8I_ADDA_HP_VOLC, SUN8I_ADDA_HP_VOLC_HP_VOL, 0x3f, 0,
@@ -447,7 +447,7 @@ static int sun8i_headphone_amp_event(struct snd_soc_dapm_widget *w,return 0 ; } -static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = { +static const struct snd_soc_dapm_widget sun8i_a23_codec_hp_widgets[] = {SND_SOC_DAPM_MUX ("Headphone Source Playback Route" ,SND_SOC_NOPM ,0 ,0 , sun8i_codec_hp_src), SND_SOC_DAPM_OUT_DRV_E("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL,
@@ -471,22 +471,24 @@ static const struct snd_soc_dapm_route sun8i_codec_headphone_routes[] = { { "HP", NULL, "Headphone Amp" }, }; -static int sun8i_codec_add_headphone (struct snd_soc_component *cmpnt) +static int sun8i_a23_codec_add_headphone (struct snd_soc_component *cmpnt) {struct snd_soc_dapm_context *dapm =snd_soc_component_get_dapm (cmpnt);struct device *dev = cmpnt->dev;int ret; ret =snd_soc_add_component_controls (cmpnt, - sun8i_codec_headphone_controls, -ARRAY_SIZE (sun8i_codec_headphone_controls)); + sun8i_a23_codec_hp_ctrls, +ARRAY_SIZE ( + sun8i_a23_codec_hp_ctrls));if (ret) {dev_err (dev,"Failed to add Headphone controls: %d\n" , ret);return ret; } - ret =snd_soc_dapm_new_controls (dapm, sun8i_codec_headphone_widgets, -ARRAY_SIZE (sun8i_codec_headphone_widgets)); + ret =snd_soc_dapm_new_controls (dapm, + sun8i_a23_codec_hp_widgets, +ARRAY_SIZE (sun8i_a23_codec_hp_widgets));if (ret) {dev_err (dev,"Failed to add Headphone DAPM widgets: %d\n" , ret);return ret;
@@ -604,6 +606,7 @@ static const DECLARE_TLV_DB_RANGE(sun8i_codec_lineout_vol_scale, 0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0), ); +static const struct snd_kcontrol_new sun8i_codec_lineout_controls[] = { SOC_SINGLE_TLV("Line Out Playback Volume", SUN8I_ADDA_PHONE_GAIN_CTRL,
@@ -648,7 +651,7 @@ static const struct snd_soc_dapm_route sun8i_codec_lineout_routes[] = { { "LINEOUT", NULL, "Line Out Enable", }, }; -static int sun8i_codec_add_lineout (struct snd_soc_component *cmpnt) +static int sun8i_h3_codec_add_lineout (struct snd_soc_component *cmpnt) {struct snd_soc_dapm_context *dapm =snd_soc_component_get_dapm (cmpnt);struct device *dev = cmpnt->dev;
@@ -751,6 +754,9 @@ struct sun8i_codec_analog_quirks {bool has_lineout;bool has_mbias;bool has_mic2; +const struct snd_soc_component_driver *cmpnt_drv; +int (*add_headphone)(struct snd_soc_component *cmpnt); +int (*add_lineout)(struct snd_soc_component *cmpnt); };static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
@@ -759,6 +765,7 @@ static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { .has_linein = true, .has_mbias = true, .has_mic2 = true, + .add_headphone = sun8i_a23_codec_add_headphone, };static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
@@ -766,8 +773,10 @@ static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { .has_lineout = true, .has_mbias = true, .has_mic2 = true, + .add_lineout = sun8i_h3_codec_add_lineout, }; +static int sun8i_codec_analog_add_mixer (struct snd_soc_component *cmpnt,const struct sun8i_codec_analog_quirks *quirks) {
@@ -834,7 +843,7 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)return ret;if (quirks->has_headphone) { - ret =sun8i_codec_add_headphone (cmpnt); + ret = quirks->add_headphone (cmpnt);if (ret)return ret; }
@@ -852,7 +861,7 @@ static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt) }if (quirks->has_lineout) { - ret =sun8i_codec_add_lineout (cmpnt); + ret = quirks->add_lineout (cmpnt);if (ret)return ret; }
Signature · 1 line
2.15.0
PATCH 6/9 ASoC: sun8i-codec-analog: Add component driver field to quirks structure
In reply to Vasily KhoruzhickThis is necessary for upcoming addition of A64 support. A64 uses the same DAPM routes, but slightly different widgets. Use approach from sun4i-codec driver and pass appropriate component driver through quirks.
--- sound/soc/sunxi/sun8i-codec-analog.c | 57 +++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 24 deletions(-)
sound/soc/sunxi/sun8i-codec-analog.c +33 -24
@@ -759,24 +759,6 @@ struct sun8i_codec_analog_quirks {int (*add_lineout)(struct snd_soc_component *cmpnt); }; -static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { - .has_headphone = true, - .has_hmic = true, - .has_linein = true, - .has_mbias = true, - .has_mic2 = true, - .add_headphone = sun8i_a23_codec_add_headphone, -}; - -static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { - .has_linein = true, - .has_lineout = true, - .has_mbias = true, - .has_mic2 = true, - .add_lineout = sun8i_h3_codec_add_lineout, -}; - -static int sun8i_codec_analog_add_mixer (struct snd_soc_component *cmpnt,const struct sun8i_codec_analog_quirks *quirks) {
@@ -819,11 +801,6 @@ static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt,return 0 ; } -static const struct sun8i_codec_analog_quirks sun8i_v3s_quirks = { - .has_headphone = true, - .has_hmic = true, -}; -static int sun8i_codec_analog_cmpnt_probe (struct snd_soc_component *cmpnt) {struct device *dev = cmpnt->dev;
@@ -891,6 +868,31 @@ static const struct snd_soc_component_driver sun8i_codec_analog_cmpnt_drv = { .probe = sun8i_codec_analog_cmpnt_probe, }; +static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = { + .has_headphone = true, + .has_hmic = true, + .has_linein = true, + .has_mbias = true, + .has_mic2 = true, + .add_headphone = sun8i_a23_codec_add_headphone, + .cmpnt_drv = &sun8i_codec_analog_cmpnt_drv, +}; + +static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = { + .has_linein = true, + .has_lineout = true, + .has_mbias = true, + .has_mic2 = true, + .add_lineout = sun8i_h3_codec_add_lineout, + .cmpnt_drv = &sun8i_codec_analog_cmpnt_drv, +}; + +static const struct sun8i_codec_analog_quirks sun8i_v3s_quirks = { + .has_headphone = true, + .has_hmic = true, + .cmpnt_drv = &sun8i_codec_analog_cmpnt_drv, +}; +static const struct of_device_id sun8i_codec_analog_of_match[] = { { .compatible ="allwinner,sun8i-a23-codec-analog" ,
@@ -913,6 +915,13 @@ static int sun8i_codec_analog_probe(struct platform_device *pdev)struct resource *res;struct regmap *regmap;void __iomem *base; +const struct sun8i_codec_analog_quirks *quirks; + + quirks =of_device_get_match_data (&pdev->dev); +if (quirks ==NULL ) { +dev_err (&pdev->dev,"Failed to determine the quirks to use\n" ); +return -ENODEV ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); base =devm_ioremap_resource (&pdev->dev, res);
@@ -928,7 +937,7 @@ static int sun8i_codec_analog_probe(struct platform_device *pdev) }return devm_snd_soc_register_component (&pdev->dev, - &sun8i_codec_analog_cmpnt_drv, + quirks->cmpnt_drv,NULL ,0 ); }
Signature · 1 line
2.15.0
PATCH 7/9 ASoC: sun8i-codec-analog: Add support for A64 SoC
In reply to Vasily KhoruzhickFrom: Marcus Cooper <[email protected]>
Analog part of audiocodec is very similar to other codecs supports by this driver, but has different registers
--- .../bindings/sound/sun8i-codec-analog.txt | 1 + sound/soc/sunxi/Kconfig | 2 +- sound/soc/sunxi/sun8i-codec-analog.c | 227 +++++++++++++++++++++ 3 files changed, 229 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt +1 -0
@@ -5,6 +5,7 @@ Required properties: - "allwinner,sun8i-a23-codec-analog" - "allwinner,sun8i-h3-codec-analog" - "allwinner,sun8i-v3s-codec-analog" + - "allwinner,sun50i-a64-codec-analog" Required properties if not a sub-node of the PRCM node: - reg: must contain the registers location and length
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
sound/soc/sunxi/sun8i-codec-analog.c +227 -0
331 lines not on this page · raw message
Signature · 1 line
2.15.0
PATCH 8/9 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 | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +52 -0
@@ -112,6 +112,28 @@ method = "smc"; }; + sound: sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "SUN50i Audio Card"; + 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"; + 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
@@ -382,6 +404,30 @@ }; }; + dai: dai@1c22c00 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun50i-a64-acodec-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,sun50i-a64-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>;
@@ -563,6 +609,12 @@ #reset-cells = <1>; }; + codec_analog: codec-analog at 1f015c0 { + compatible = "allwinner,sun50i-a64-codec-analog"; + reg = <0x01f015c0 0x4>; + status = "disabled"; + }; + r_pio: pinctrl at 1f02c00 { compatible = "allwinner,sun50i-a64-r-pinctrl"; reg = <0x01f02c00 0x400>;
Signature · 1 line
2.15.0
PATCH 9/9 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.
--- arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 16 ++++++++++++++++ .../boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +16 -0
@@ -64,6 +64,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };
@@ -229,6 +241,10 @@ regulator-name = "vcc-rtc"; }; +&sound { + status = "okay"; +}; + /* On Exp and Euler connectors */ &uart0 { pinctrl-names = "default";
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +16 -0
@@ -69,6 +69,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };
@@ -133,6 +145,10 @@ regulator-name = "vcc-wifi"; }; +&sound { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pins_a>;
Signature · 1 line
2.15.0
Re: [PATCH 1/9] ASoC: sun4i-i2s: Add quirk to handle fixed WSS
In reply to Vasily KhoruzhickHi,
Quoted 2 lines · Vasily Khoruzhick
I2S for audio codec on sun50i-A64 always uses fixed word select size value, no matter what is sample width. Add quirk to support that.
Please clarify on this. Does this mean the WSS bitfield is useless and it always sends out the same sample sizes regardless of the setting? Or it's the codec that can only use a fixed sample width?
As far as I can tell, the code you added in this patch points to the latter. In that case. this is the wrong way to go about it. The limitation is a property of the codec, not the I2S controller. If the codec assumes 32 bits per sample, then that is what you should setup in the code driver. See sun8i_codec_dai in sound/soc/sunxi/sun8i-codec.c where you can set the format. You'll likely need to make a copy of the data structure for A64, and tie it to the compatible.
ChenYu
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Vasily KhoruzhickQuoted 31 lines · Vasily Khoruzhick
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]Signed-off-by Marcus Cooper <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.
Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s"
I would keep the compatible format the same. ie. allwinner,sun50i-a64-i2s. The A33 for example uses the sun6i-a31-i2s for it's dai.
sound/soc/sunxi/sun4i-i2s.c static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { · line 945
Quoted 12 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +0
-0- resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +1
-0@@ -942,6 +942,25 @@ 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_acodec_i2s_quirks = {
ditto
Quoted 22 lines
sound/soc/sunxi/sun4i-i2s.c +18
-0+ .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, + .fixed_wss = true, + .wss_value = 3, + .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) {
sound/soc/sunxi/sun4i-i2s.c static const struct of_device_id sun4i_i2s_match[] = { · line 1170
Quoted 6 lines
sound/soc/sunxi/sun4i-i2s.c +3
-0@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks,
ditto
BR,
CK
Quoted 7 lines
sound/soc/sunxi/sun4i-i2s.c +1
-1+ }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.15.0
Re: [PATCH 3/9] ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value
In reply to Vasily KhoruzhickQuoted 23 lines · Vasily Khoruzhick
LRCK divider for A64 differs from A33, so add a quirk to support that.
Signed-off-by Vasily Khoruzhick <[email protected]>--- sound/soc/sunxi/sun8i-codec.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)sound/soc/sunxi/sun8i-codec.c +1
-0@@ -24,6 +24,7 @@#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/of_device.h> #include <sound/pcm_params.h> #include <sound/soc.h> @@ -75,11 +76,22 @@#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6)#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9)
sound/soc/sunxi/sun8i-codec.c line 88
Quoted 10 lines
sound/soc/sunxi/sun8i-codec.c +10
-0+/* +* struct sun8i_codec_quirks - Differences between SoC variants. +* +* @aif1_lrck_div: LRCK divider +*/ +struct sun8i_codec_quirks { +unsigned int aif1_lrck_div; +}; + +
Extra line
Quoted 34 lines
sound/soc/sunxi/sun8i-codec.c +10
-5struct sun8i_codec { -struct device *dev; -struct regmap *regmap; -struct clk *clk_module; -struct clk *clk_bus; +struct device *dev; +struct regmap *regmap; +struct clk *clk_module; +struct clk *clk_bus; +const struct sun8i_codec_quirks *variant; };static int sun8i_codec_runtime_resume (struct device *dev)@@ -305,7 +317,7 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,regmap_update_bits (scodec->regmap,SUN8I_AIF1CLK_CTRL ,SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK , -SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 ); + scodec->variant->aif1_lrck_div); sample_rate =sun8i_codec_get_hw_rate (params);if (sample_rate <0 )@@ -440,6 +452,10 @@ static const struct regmap_config sun8i_codec_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct sun8i_codec_quirks sun8i_a33_codec_quirks = { + .aif1_lrck_div =SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 , +}; +static int sun8i_codec_probe (struct platform_device *pdev) {struct resource *res_base;
sound/soc/sunxi/sun8i-codec.c static int sun8i_codec_probe(struct platform_device *pdev) · line 478
Quoted 10 lines
sound/soc/sunxi/sun8i-codec.c +7
-0@@ -453,6 +469,13 @@ static int sun8i_codec_probe(struct platform_device *pdev) scodec->dev = &pdev->dev; + scodec->variant =of_device_get_match_data (&pdev->dev); +if (!scodec->variant) { +dev_err (&pdev->dev,"Failed to determine the quirks to use\n" ); +return -ENODEV ; + } + +
ditto
Quoted 18 lines
sound/soc/sunxi/sun8i-codec.c +4
-2scodec->clk_module =devm_clk_get (&pdev->dev,"mod" );if (IS_ERR (scodec->clk_module)) {dev_err (&pdev->dev,"Failed to get the module clock\n" );@@ -524,7 +547,10 @@ static int sun8i_codec_remove(struct platform_device *pdev) }static const struct of_device_id sun8i_codec_of_match[] = { - { .compatible ="allwinner,sun8i-a33-codec" }, + { + .compatible ="allwinner,sun8i-a33-codec" , + .data = &sun8i_a33_codec_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun8i_codec_of_match); --2.15.0
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Code KipperI'd keep it sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.
Quoted 91 lines · Code Kipper
Quoted 31 lines · Vasily Khoruzhick
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]Signed-off-by Marcus Cooper <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s"I would keep the compatible format the same. ie. allwinner,sun50i-a64-i2s. The A33 for example uses the sun6i-a31-i2s for it's dai.
sound/soc/sunxi/sun4i-i2s.c static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { · line 945
Quoted 12 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +0
-0- resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +1
-0@@ -942,6 +942,25 @@ 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_acodec_i2s_quirks = {ditto
Quoted 22 lines
sound/soc/sunxi/sun4i-i2s.c +18
-0+ .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, + .fixed_wss = true, + .wss_value = 3, + .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) {sound/soc/sunxi/sun4i-i2s.c static const struct of_device_id sun4i_i2s_match[] = { · line 1170
Quoted 6 lines
sound/soc/sunxi/sun4i-i2s.c +3
-0@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks,ditto
BR,
CKQuoted 7 lines
sound/soc/sunxi/sun4i-i2s.c +1
-1+ }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.15.0
Re: [PATCH 3/9] ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value
In reply to Vasily KhoruzhickQuoted 12 lines · Vasily Khoruzhick
LRCK divider for A64 differs from A33, so add a quirk to support that.
Signed-off-by Vasily Khoruzhick <[email protected]>--- sound/soc/sunxi/sun8i-codec.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)sound/soc/sunxi/sun8i-codec.c +0
-0
sound/soc/sunxi/sun8i-codec.c line 27
Quoted 4 lines
sound/soc/sunxi/sun8i-codec.c +1
-0@@ -24,6 +24,7 @@#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/of_device.h>
Please keep them sorted in alphabetical order.
Quoted 31 lines
sound/soc/sunxi/sun8i-codec.c +15
-4#include <sound/pcm_params.h> #include <sound/soc.h> @@ -75,11 +76,22 @@#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6)#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9) +/* +* struct sun8i_codec_quirks - Differences between SoC variants. +* +* @aif1_lrck_div: LRCK divider +*/ +struct sun8i_codec_quirks { +unsigned int aif1_lrck_div; +}; + +struct sun8i_codec { -struct device *dev; -struct regmap *regmap; -struct clk *clk_module; -struct clk *clk_bus; +struct device *dev; +struct regmap *regmap; +struct clk *clk_module; +struct clk *clk_bus; +const struct sun8i_codec_quirks *variant; };static int sun8i_codec_runtime_resume (struct device *dev)
sound/soc/sunxi/sun8i-codec.c static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, · line 320
Quoted 5 lines
sound/soc/sunxi/sun8i-codec.c +1
-1@@ -305,7 +317,7 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,regmap_update_bits (scodec->regmap,SUN8I_AIF1CLK_CTRL ,SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK , -SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 ); + scodec->variant->aif1_lrck_div);
Hard coding a fixed divider is generally a bad idea. You adding another fixed value for this is evidence of this.
The BCK:LRCK divider is equal to sample width * 2. You should have that instead.
Also I see no evidence that either the I2S controller (see my comment on patch 1) or the codec is limited to a certain sample width in hardware, other than your claims, which are vague at best.
The user manual for both the A33 and A64 list many possible widths and dividers. If the user manual is wrong, please provide solid evidence proving it wrong.
Either way this series will not be accepted in its current form.
ChenYu
Quoted 43 lines
sound/soc/sunxi/sun8i-codec.c +15
-2sample_rate =sun8i_codec_get_hw_rate (params);if (sample_rate <0 )@@ -440,6 +452,10 @@ static const struct regmap_config sun8i_codec_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct sun8i_codec_quirks sun8i_a33_codec_quirks = { + .aif1_lrck_div =SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 , +}; +static int sun8i_codec_probe (struct platform_device *pdev) {struct resource *res_base;@@ -453,6 +469,13 @@ static int sun8i_codec_probe(struct platform_device *pdev) scodec->dev = &pdev->dev; + scodec->variant =of_device_get_match_data (&pdev->dev); +if (!scodec->variant) { +dev_err (&pdev->dev,"Failed to determine the quirks to use\n" ); +return -ENODEV ; + } + + scodec->clk_module =devm_clk_get (&pdev->dev,"mod" );if (IS_ERR (scodec->clk_module)) {dev_err (&pdev->dev,"Failed to get the module clock\n" );@@ -524,7 +547,10 @@ static int sun8i_codec_remove(struct platform_device *pdev) }static const struct of_device_id sun8i_codec_of_match[] = { - { .compatible ="allwinner,sun8i-a33-codec" }, + { + .compatible ="allwinner,sun8i-a33-codec" , + .data = &sun8i_a33_codec_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun8i_codec_of_match); --2.15.0
Re: [PATCH 3/9] ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value
Quoted 68 lines · Chen-Yu Tsai
Quoted 12 lines · Vasily Khoruzhick
LRCK divider for A64 differs from A33, so add a quirk to support that.
Signed-off-by Vasily Khoruzhick <[email protected]>--- sound/soc/sunxi/sun8i-codec.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)sound/soc/sunxi/sun8i-codec.c +0
-0sound/soc/sunxi/sun8i-codec.c line 27
Quoted 4 lines
sound/soc/sunxi/sun8i-codec.c +1
-0@@ -24,6 +24,7 @@#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/of_device.h> Please keep them sorted in alphabetical order.
Quoted 31 lines
sound/soc/sunxi/sun8i-codec.c +15
-4#include <sound/pcm_params.h> #include <sound/soc.h> @@ -75,11 +76,22 @@#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6)#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9) +/* +* struct sun8i_codec_quirks - Differences between SoC variants. +* +* @aif1_lrck_div: LRCK divider +*/ +struct sun8i_codec_quirks { +unsigned int aif1_lrck_div; +}; + +struct sun8i_codec { -struct device *dev; -struct regmap *regmap; -struct clk *clk_module; -struct clk *clk_bus; +struct device *dev; +struct regmap *regmap; +struct clk *clk_module; +struct clk *clk_bus; +const struct sun8i_codec_quirks *variant; };static int sun8i_codec_runtime_resume (struct device *dev)sound/soc/sunxi/sun8i-codec.c static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, · line 320
Quoted 5 lines
sound/soc/sunxi/sun8i-codec.c +1
-1@@ -305,7 +317,7 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,regmap_update_bits (scodec->regmap,SUN8I_AIF1CLK_CTRL ,SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK , -SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 ); + scodec->variant->aif1_lrck_div);Hard coding a fixed divider is generally a bad idea. You adding another fixed value for this is evidence of this.
The BCK:LRCK divider is equal to sample width * 2. You should have that instead.
Also I see no evidence that either the I2S controller (see my comment on patch 1) or the codec is limited to a certain sample width in hardware, other than your claims, which are vague at best.
Quoted 5 lines
The user manual for both the A33 and A64 list many possible widths and dividers. If the user manual is wrong, please provide solid evidence proving it wrong.
Either way this series will not be accepted in its current form.
So following up on the discussion on IRC, please add the relevant information to the commit messages:
- Why is this hard-coded value needed? i.e. does it not work with standard values generated by the framework from the format value?
This is the most important part. This might also include:
* What you have done to test the non-working values
Other things worth mentioning:
- Where the hard-coded values came from?
- Why a special quirk is needed, instead of say, limiting the supported format to SNDRV_PCM_FMTBIT_S32_LE, which produces the correct wss and lrck_div values
- Anything else you think is relevant to the patch or hardware
You should also leave a comment explaining why the quirk is needed just before the code where you handle the quirks. Otherwise it makes little sense to people that don't have the context about this.
Regards
ChenYu
Quoted 46 lines
ChenYu
Quoted 43 lines
sound/soc/sunxi/sun8i-codec.c +15
-2sample_rate =sun8i_codec_get_hw_rate (params);if (sample_rate <0 )@@ -440,6 +452,10 @@ static const struct regmap_config sun8i_codec_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct sun8i_codec_quirks sun8i_a33_codec_quirks = { + .aif1_lrck_div =SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 , +}; +static int sun8i_codec_probe (struct platform_device *pdev) {struct resource *res_base;@@ -453,6 +469,13 @@ static int sun8i_codec_probe(struct platform_device *pdev) scodec->dev = &pdev->dev; + scodec->variant =of_device_get_match_data (&pdev->dev); +if (!scodec->variant) { +dev_err (&pdev->dev,"Failed to determine the quirks to use\n" ); +return -ENODEV ; + } + + scodec->clk_module =devm_clk_get (&pdev->dev,"mod" );if (IS_ERR (scodec->clk_module)) {dev_err (&pdev->dev,"Failed to get the module clock\n" );@@ -524,7 +547,10 @@ static int sun8i_codec_remove(struct platform_device *pdev) }static const struct of_device_id sun8i_codec_of_match[] = { - { .compatible ="allwinner,sun8i-a33-codec" }, + { + .compatible ="allwinner,sun8i-a33-codec" , + .data = &sun8i_a33_codec_quirks, + }, {} };MODULE_DEVICE_TABLE (of, sun8i_codec_of_match); --2.15.0
Re: [PATCH 9/9] arm64: dts: allwinner: a64: Enable sound on Pine64 and SoPine
In reply to Vasily KhoruzhickQuoted 33 lines · Vasily Khoruzhick
This commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.
Signed-off-by Vasily Khoruzhick <[email protected]>--- arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 16 ++++++++++++++++ .../boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +12
-0@@ -64,6 +64,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts line 245
Quoted 5 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +2
-0@@ -229,6 +241,10 @@ regulator-name = "vcc-rtc"; }; +&sound { + status = "okay";
This is missing all the board level widgets and routing. Yes I know that it works right now, but that's because simple-card isn't a strict card, i.e. it doesn't force the need for actual inputs and outputs at both ends of the DAPM graph.
Later on you'll find that missing the routing leaves the microphone unusable, because the microphone bias is not turned on.
ChenYu
Quoted 42 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +2
-0+}; + /* On Exp and Euler connectors */ &uart0 { pinctrl-names = "default";arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +16
-1@@ -69,6 +69,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };@@ -133,6 +145,10 @@ regulator-name = "vcc-wifi"; }; +&sound { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pins_a>; --2.15.0
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Vasily KhoruzhickHi,
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.
Please don't top-post.
What are those differences?
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
In reply to Vasily KhoruzhickQuoted 5 lines · Vasily Khoruzhick
Digital part of audio codec block in the A64 is very similar to what is used by the A33(sun8i) devices. However, it uses different LRCK divider.
Signed-off-by Vasily Khoruzhick <[email protected]>
What makes it impossible to derive from the sample rate and number of channels?
Have you tried other sampling rates?
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Maxime RipardQuoted 9 lines · Maxime Ripard
Hi,
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.Please don't top-post.
What are those differences?
Different registers and their locations. Compare quirks for sun50i_a64_acodec_i2s and sun8i_h3_i2s fro details.
Quoted 6 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Re: [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
In reply to Maxime RipardQuoted 9 lines · Maxime Ripard
Quoted 5 lines · Vasily Khoruzhick
Digital part of audio codec block in the A64 is very similar to what is used by the A33(sun8i) devices. However, it uses different LRCK divider.
Signed-off-by Vasily Khoruzhick <[email protected]>What makes it impossible to derive from the sample rate and number of channels?
It's BCLK / LRCK ratio as per A64 user manual, so it doesn't depend on sample rate. BSP driver always uses a fixed value of 64 here.
Quoted 1 line
Have you tried other sampling rates?
I tried speaker-test with a number of sampling rates and had no issues. I couldn't try it in mono, since sun4i-i2s supports minimum of 2 channels.
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Vasily KhoruzhickQuoted 8 lines · Vasily Khoruzhick
Quoted 6 lines · Maxime Ripard
Hi,
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.
Quoted 6 lines
Quoted 3 lines
Please don't top-post.
What are those differences?
Different registers and their locations. Compare quirks for
sun50i_a64_acodec_i2sandsun8i_h3_i2sfro details.
Whatever differences should also be mentionned in your commit log.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171206/77ec3a6e/attachment.sig>
Re: [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
In reply to Vasily KhoruzhickQuoted 7 lines · Vasily Khoruzhick
Quoted 5 lines · Maxime Ripard
Quoted 4 lines · Vasily Khoruzhick
Digital part of audio codec block in the A64 is very similar to what is used by the A33(sun8i) devices. However, it uses different LRCK divider.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Vasily Khoruzhick <[email protected]>What makes it impossible to derive from the sample rate and number of channels?
It's BCLK / LRCK ratio as per A64 user manual, so it doesn't depend on sample rate. BSP driver always uses a fixed value of 64 here.
Well, it kind of does.
BCLK is sample rate * sample size * channels, and LRCK is running at the sample rate. So the ratio is the sample size * channels.
Anything deviating from those standard i2s concepts should at least be documented, with arguments to back them off.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171206/20e46530/attachment.sig>
Mark Brown
maintainerRe: [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
Quoted 5 lines · Maxime Ripard
BCLK is sample rate * sample size * channels, and LRCK is running at the sample rate. So the ratio is the sample size * channels.
Anything deviating from those standard i2s concepts should at least be documented, with arguments to back them off.
BCLK can be higher than the minimum there in most formats, though some hardware is more restrictive so we tend to go for the minimum clock rate.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
Quoted 10 lines · Mark Brown
Quoted 5 lines · Maxime Ripard
BCLK is sample rate * sample size * channels, and LRCK is running at the sample rate. So the ratio is the sample size * channels.
Anything deviating from those standard i2s concepts should at least be documented, with arguments to back them off.
BCLK can be higher than the minimum there in most formats, though some hardware is more restrictive so we tend to go for the minimum clock rate.
How does that work in such a case? Is LRCK faster as well, and we're keeping the same ratio, or will the codec buffer the current sample until the next word?
Is it usually a property of the codec or the DAI?
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171206/74219ba6/attachment-0001.sig>
Mark Brown
maintainerRe: [PATCH 4/9] ASoC: sun8i-codec: Add support for A64 SoC
Quoted 8 lines · Maxime Ripard
Quoted 2 lines · Mark Brown
BCLK can be higher than the minimum there in most formats, though some hardware is more restrictive so we tend to go for the minimum clock rate.
How does that work in such a case? Is LRCK faster as well, and we're keeping the same ratio, or will the codec buffer the current sample until the next word?
No, the extra clock cycles just get ignored - most of the formats define the location of the data in terms of LRCLK edges, any extra BCLK edges shouldn't do anything.
Quoted 1 line
Is it usually a property of the codec or the DAI?
Things that require extra cycles for some reason tend to be CODECs, but
this can also be done just because whatever the clock master is doesn't
have very flexible dividers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171206/62f7abdd/attachment.sig>
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Vasily KhoruzhickQuoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.
Well I wouldn't and the description of it is usage is clearly stated in the devicetree
for the dai.
Quoted 13 lines · Code Kipper
Quoted 11 lines · Vasily Khoruzhick
Quoted 10 lines
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]
This needs to be investigated more...I'm suspicious of the SUN8I_I2S_FMT0_LRCK_PERIOD value which is hardcoded to 0x1f. I've made this following change
https://github.com/codekipper/linux-sunxi/commit/4c5fe5f5576cfbb2e1e94a99cd19dfdc9403ea50
which seems to work for me but I would like to look at it with a logic analyser and test other sample depths.
CK
Quoted 80 lines
Quoted 80 lines
Quoted 21 lines
Signed-off-by Marcus Cooper <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s"I would keep the compatible format the same. ie. allwinner,sun50i-a64-i2s. The A33 for example uses the sun6i-a31-i2s for it's dai.
sound/soc/sunxi/sun4i-i2s.c static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { · line 945
Quoted 12 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +0
-0- resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +1
-0@@ -942,6 +942,25 @@ 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_acodec_i2s_quirks = {ditto
Quoted 22 lines
sound/soc/sunxi/sun4i-i2s.c +18
-0+ .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, + .fixed_wss = true, + .wss_value = 3, + .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) {sound/soc/sunxi/sun4i-i2s.c static const struct of_device_id sun4i_i2s_match[] = { · line 1170
Quoted 6 lines
sound/soc/sunxi/sun4i-i2s.c +3
-0@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks,ditto
BR,
CKQuoted 7 lines
sound/soc/sunxi/sun4i-i2s.c +1
-1+ }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.15.0
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
Quoted 20 lines · Code Kipper
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.Well I wouldn't and the description of it is usage is clearly stated in the devicetree
for the dai.Quoted 13 lines · Code Kipper
Quoted 11 lines · Vasily Khoruzhick
Quoted 10 lines
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]
Quoted 7 lines
This needs to be investigated more...I'm suspicious of the
SUN8I_I2S_FMT0_LRCK_PERIODvalue which is hardcoded to0x1f. I've made this following change
https://github.com/codekipper/linux-sunxi/commit/4c5fe5f5576cfbb2e1e94a99cd19dfdc9403ea50
which seems to work for me but I would like to look at it with a logic analyser and test other sample depths.
CK
Another good reason not to have hard-coded values for things that are rightly configurable. :)
ChenYu
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
In reply to Code KipperQuoted 7 lines · Code Kipper
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.Well I wouldn't and the description of it is usage is clearly stated in the devicetree
for the dai.
OK, how would you name 3 other I2S modules that are present in A64?
Quoted 12 lines
Quoted 12 lines · Code Kipper
Quoted 11 lines · Vasily Khoruzhick
Quoted 10 lines
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]
Quoted 7 lines
This needs to be investigated more...I'm suspicious of the
SUN8I_I2S_FMT0_LRCK_PERIODvalue which is hardcoded to0x1f. I've made this following change
https://github.com/codekipper/linux-sunxi/commit/4c5fe5f5576cfbb2e1e94a99cd19dfdc9403ea50
which seems to work for me but I would like to look at it with a logic analyser and test other sample depths.
CK
I'm afraid it's not possible to get inside of SoC, since internal I2S pins do not go out. And other 3 I2S modules are different from one for internal codec.
Quoted 80 lines
Quoted 80 lines
Quoted 80 lines
Quoted 21 lines
Signed-off-by Marcus Cooper <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s"I would keep the compatible format the same. ie. allwinner,sun50i-a64-i2s. The A33 for example uses the sun6i-a31-i2s for it's dai.
sound/soc/sunxi/sun4i-i2s.c static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { · line 945
Quoted 12 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +0
-0- resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +1
-0@@ -942,6 +942,25 @@ 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_acodec_i2s_quirks = {ditto
Quoted 22 lines
sound/soc/sunxi/sun4i-i2s.c +18
-0+ .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, + .fixed_wss = true, + .wss_value = 3, + .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) {sound/soc/sunxi/sun4i-i2s.c static const struct of_device_id sun4i_i2s_match[] = { · line 1170
Quoted 6 lines
sound/soc/sunxi/sun4i-i2s.c +3
-0@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks,ditto
BR,
CKQuoted 7 lines
sound/soc/sunxi/sun4i-i2s.c +1
-1+ }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.15.0
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
Quoted 10 lines · Vasily Khoruzhick
Quoted 7 lines · Code Kipper
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.Well I wouldn't and the description of it is usage is clearly stated in the devicetree
for the dai.OK, how would you name 3 other I2S modules that are present in A64?
https://github.com/codekipper/linux-sunxi/commit/34f37778fbc08247e3bd1556f7ed02303053f5ab
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines · Code Kipper
Quoted 11 lines · Vasily Khoruzhick
Quoted 10 lines
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]Quoted 7 lines
This needs to be investigated more...I'm suspicious of the
SUN8I_I2S_FMT0_LRCK_PERIODvalue which is hardcoded to0x1f. I've made this following change
https://github.com/codekipper/linux-sunxi/commit/4c5fe5f5576cfbb2e1e94a99cd19dfdc9403ea50
which seems to work for me but I would like to look at it with a logic analyser and test other sample depths.
CK
Quoted 3 lines
I'm afraid it's not possible to get inside of SoC, since internal I2S pins do not go out. And other 3 I2S modules are different from one for internal codec.
I just think this needs more of an investigation, I've git a similar patch
https://github.com/codekipper/linux-sunxi/commit/282d986b6f9ed441ecdc996c6dceed63cbe32652
which I've not delivered for that very reason.
CK
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 22 lines
Signed-off-by Marcus Cooper <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s"I would keep the compatible format the same. ie. allwinner,sun50i-a64-i2s. The A33 for example uses the sun6i-a31-i2s for it's dai.
sound/soc/sunxi/sun4i-i2s.c static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { · line 945
Quoted 12 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +0
-0- resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +1
-0@@ -942,6 +942,25 @@ 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_acodec_i2s_quirks = {ditto
Quoted 22 lines
sound/soc/sunxi/sun4i-i2s.c +18
-0+ .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, + .fixed_wss = true, + .wss_value = 3, + .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) {sound/soc/sunxi/sun4i-i2s.c static const struct of_device_id sun4i_i2s_match[] = { · line 1170
Quoted 6 lines
sound/soc/sunxi/sun4i-i2s.c +3
-0@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks,ditto
BR,
CKQuoted 7 lines
sound/soc/sunxi/sun4i-i2s.c +1
-1+ }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.15.0
Re: [PATCH 2/9] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S
Quoted 6 lines · Code Kipper
Quoted 5 lines · Vasily Khoruzhick
Quoted 4 lines · Code Kipper
Quoted 2 lines · Vasily Khoruzhick
I'd keep it
sun50i_a64_acodec_i2s, since other 3 I2S modules aren't compatible with this one, but similar to H3.
Quoted 24 lines
Quoted 5 lines
Quoted 3 lines
Well I wouldn't and the description of it is usage is clearly stated in the devicetree
for the dai.OK, how would you name 3 other I2S modules that are present in A64?
https://github.com/codekipper/linux-sunxi/commit/34f37778fbc08247e3bd1556f7ed02303053f5ab
Quoted 18 lines
Quoted 18 lines
Quoted 13 lines · Code Kipper
Quoted 11 lines · Vasily Khoruzhick
Quoted 10 lines
From: Marcus Cooper <[email protected]>
The I2S block used for the audio codec in the A64 is very similar to what is used by the A10(sun4i) devices. However, its TX FIFO is located at a different address.
[vasilykh: - added
fixed_wssandwss_valueto A64 quirks,
- changed compatible to 'allwinner,sun50i-a64-acodec-i2s, since A64 has 3 more I2S blocks that are not compatible with audio codec I2S]This needs to be investigated more...I'm suspicious of the
SUN8I_I2S_FMT0_LRCK_PERIODvalue which is hardcoded to0x1f. I've made this following change
https://github.com/codekipper/linux-sunxi/commit/4c5fe5f5576cfbb2e1e94a99cd19dfdc9403ea50
which seems to work for me but I would like to look at it with a logic
I tried this change and now it works fine for me as well without hardcoded WSS value. So problem was in hardcoded
LRCK period. Are you OK with me submitting this patch as a part of my A64 audio series?
Quoted 91 lines
Quoted 6 lines
Quoted 2 lines
analyser and test other sample depths.
CKI'm afraid it's not possible to get inside of SoC, since internal I2S pins do not go out. And other 3 I2S modules are different from one for internal codec.
I just think this needs more of an investigation, I've git a similar patch
https://github.com/codekipper/linux-sunxi/commit/282d986b6f9ed441ecdc996c6dceed63cbe32652
which I've not delivered for that very reason.
CKQuoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 22 lines
Signed-off-by Marcus Cooper <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 ++ sound/soc/sunxi/sun4i-i2s.c | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+)Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -9,6 +9,7 @@ Required properties: - "allwinner,sun4i-a10-i2s" - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s" - reg: physical base address of the controller and length of memory mapped region. - interrupts: should contain the I2S interrupt.Documentation/devicetree/bindings/sound/sun4i-i2s.txt Required properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +1
-0@@ -24,6 +25,7 @@ Required properties: Required properties for the following compatibles: - "allwinner,sun6i-a31-i2s" - "allwinner,sun8i-h3-i2s" + - "allwinner,sun50i-a64-acodec-i2s"I would keep the compatible format the same. ie. allwinner,sun50i-a64-i2s. The A33 for example uses the sun6i-a31-i2s for it's dai.
sound/soc/sunxi/sun4i-i2s.c static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { · line 945
Quoted 12 lines
Documentation/devicetree/bindings/sound/sun4i-i2s.txt +0
-0- resets: phandle to the reset line for this codec Example:sound/soc/sunxi/sun4i-i2s.c +1
-0@@ -942,6 +942,25 @@ 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_acodec_i2s_quirks = {ditto
Quoted 22 lines
sound/soc/sunxi/sun4i-i2s.c +18
-0+ .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, + .fixed_wss = true, + .wss_value = 3, + .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) {sound/soc/sunxi/sun4i-i2s.c static const struct of_device_id sun4i_i2s_match[] = { · line 1170
Quoted 6 lines
sound/soc/sunxi/sun4i-i2s.c +3
-0@@ -1146,6 +1165,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun8i-h3-i2s", .data = &sun8i_h3_i2s_quirks, }, + { + .compatible = "allwinner,sun50i-a64-acodec-i2s", + .data = &sun50i_a64_acodec_i2s_quirks,ditto
BR,
CKQuoted 7 lines
sound/soc/sunxi/sun4i-i2s.c +1
-1+ }, {} };MODULE_DEVICE_TABLE (of, sun4i_i2s_match); --2.15.0
Re: [PATCH 9/9] arm64: dts: allwinner: a64: Enable sound on Pine64 and SoPine
In reply to Chen-Yu TsaiQuoted 45 lines · Chen-Yu Tsai
Quoted 33 lines · Vasily Khoruzhick
This commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.
Signed-off-by Vasily Khoruzhick <[email protected]>--- arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 16 ++++++++++++++++ .../boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts | 16 ++++++++++++++++ 2 files changed, 32 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +12
-0@@ -64,6 +64,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts line 245
Quoted 5 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +2
-0@@ -229,6 +241,10 @@ regulator-name = "vcc-rtc"; }; +&sound { + status = "okay";This is missing all the board level widgets and routing. Yes I know that it works right now, but that's because simple-card isn't a strict card, i.e. it doesn't force the need for actual inputs and outputs at both ends of the DAPM graph.
Quoted 2 lines
Later on you'll find that missing the routing leaves the microphone unusable, because the microphone bias is not turned on.
sun8i-codec driver doesn't support capture at the moment. What else it could be missing?
Quoted 45 lines
ChenYu
Quoted 42 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +2
-0+}; + /* On Exp and Euler connectors */ &uart0 { pinctrl-names = "default";arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +16
-1@@ -69,6 +69,18 @@ }; }; +&codec { + status = "okay"; +}; + +&codec_analog { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; };@@ -133,6 +145,10 @@ regulator-name = "vcc-wifi"; }; +&sound { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pins_a>; --2.15.0