* [PATCH v2 0/3] ASoC: meson: t9015: add support for A1 SoC family
@ 2025-03-09 18:16 Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 1/3] ASoC: meson: t9015: prepare to adding new platforms Jan Dakinevich
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:16 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
This series adds support for internal audio codec found on A1 SoC family
extending existing t9015 driver.
Changes v1 [1] -> v2
- detached from v1's series (patches 10, 11, 12)
- configuration of linein/lineout/micbias is moved to device tree
Links:
[1] https://lore.kernel.org/lkml/20240314232201.2102178-1-jan.dakinevich@salutedevices.com/
Jan Dakinevich (3):
ASoC: meson: t9015: prepare to adding new platforms
ASoC: dt-bindings: meson: t9015: add support for A1 SoC family
ASoC: meson: t9015: add support for A1 SoC family
.../bindings/sound/amlogic,t9015.yaml | 69 +++-
sound/soc/meson/t9015.c | 379 +++++++++++++++++-
2 files changed, 423 insertions(+), 25 deletions(-)
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] ASoC: meson: t9015: prepare to adding new platforms
2025-03-09 18:16 [PATCH v2 0/3] ASoC: meson: t9015: add support for A1 SoC family Jan Dakinevich
@ 2025-03-09 18:16 ` Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 3/3] ASoC: " Jan Dakinevich
2 siblings, 0 replies; 6+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:16 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
Move platform specific code to make the reading of upcoming commit
easier.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
sound/soc/meson/t9015.c | 71 ++++++++++++++++++++++++++++-------------
1 file changed, 48 insertions(+), 23 deletions(-)
diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
index a80e9c9d6288..919a2413038d 100644
--- a/sound/soc/meson/t9015.c
+++ b/sound/soc/meson/t9015.c
@@ -51,6 +51,12 @@ struct t9015 {
struct regulator *avdd;
};
+struct t9015_match_data {
+ const struct snd_soc_component_driver *component_drv;
+ struct snd_soc_dai_driver *dai_drv;
+ unsigned int max_register;
+};
+
static int t9015_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_component *component = dai->component;
@@ -112,6 +118,11 @@ static SOC_ENUM_SINGLE_DECL(dacl_in_enum, BLOCK_EN, DACL_SRC, dacl_in_txt);
static const char * const mono_txt[] = { "Stereo", "Mono"};
static SOC_ENUM_SINGLE_DECL(mono_enum, VOL_CTRL1, DAC_MONO, mono_txt);
+static const struct snd_kcontrol_new t9015_right_dac_mux =
+ SOC_DAPM_ENUM("Right DAC Source", dacr_in_enum);
+static const struct snd_kcontrol_new t9015_left_dac_mux =
+ SOC_DAPM_ENUM("Left DAC Source", dacl_in_enum);
+
static const struct snd_kcontrol_new t9015_snd_controls[] = {
/* Volume Controls */
SOC_ENUM("Playback Channel Mode", mono_enum),
@@ -126,11 +137,6 @@ static const struct snd_kcontrol_new t9015_snd_controls[] = {
SOC_SINGLE("Unmute Ramp Switch", VOL_CTRL1, UNMUTE_MODE, 1, 0),
};
-static const struct snd_kcontrol_new t9015_right_dac_mux =
- SOC_DAPM_ENUM("Right DAC Source", dacr_in_enum);
-static const struct snd_kcontrol_new t9015_left_dac_mux =
- SOC_DAPM_ENUM("Left DAC Source", dacl_in_enum);
-
static const struct snd_soc_dapm_widget t9015_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN("Right IN", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("Left IN", NULL, 0, SND_SOC_NOPM, 0, 0),
@@ -223,7 +229,20 @@ static int t9015_set_bias_level(struct snd_soc_component *component,
return 0;
}
+static int t9015_component_probe(struct snd_soc_component *component)
+{
+ /*
+ * Initialize output polarity:
+ * ATM the output polarity is fixed but in the future it might useful
+ * to add DT property to set this depending on the platform needs
+ */
+ snd_soc_component_write(component, LINEOUT_CFG, 0x1111);
+
+ return 0;
+}
+
static const struct snd_soc_component_driver t9015_codec_driver = {
+ .probe = t9015_component_probe,
.set_bias_level = t9015_set_bias_level,
.controls = t9015_snd_controls,
.num_controls = ARRAY_SIZE(t9015_snd_controls),
@@ -235,22 +254,25 @@ static const struct snd_soc_component_driver t9015_codec_driver = {
.endianness = 1,
};
-static const struct regmap_config t9015_regmap_config = {
- .reg_bits = 32,
- .reg_stride = 4,
- .val_bits = 32,
- .max_register = POWER_CFG,
-};
-
static int t9015_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ const struct t9015_match_data *data;
struct t9015 *priv;
void __iomem *regs;
+ struct regmap_config config = {
+ .reg_bits = 32,
+ .reg_stride = 4,
+ .val_bits = 32,
+ };
struct regmap *regmap;
struct clk *pclk;
int ret;
+ data = device_get_match_data(dev);
+ if (!data)
+ dev_err_probe(dev, -ENODEV, "failed to match device\n");
+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -276,25 +298,28 @@ static int t9015_probe(struct platform_device *pdev)
return PTR_ERR(regs);
}
- regmap = devm_regmap_init_mmio(dev, regs, &t9015_regmap_config);
+ config.max_register = data->max_register;
+ regmap = devm_regmap_init_mmio(dev, regs, &config);
if (IS_ERR(regmap)) {
dev_err(dev, "regmap init failed\n");
return PTR_ERR(regmap);
}
- /*
- * Initialize output polarity:
- * ATM the output polarity is fixed but in the future it might useful
- * to add DT property to set this depending on the platform needs
- */
- regmap_write(regmap, LINEOUT_CFG, 0x1111);
-
- return devm_snd_soc_register_component(dev, &t9015_codec_driver,
- &t9015_dai, 1);
+ return devm_snd_soc_register_component(dev, data->component_drv,
+ data->dai_drv, 1);
}
+static const struct t9015_match_data t9015_match_data = {
+ .component_drv = &t9015_codec_driver,
+ .dai_drv = &t9015_dai,
+ .max_register = POWER_CFG,
+};
+
static const struct of_device_id t9015_ids[] __maybe_unused = {
- { .compatible = "amlogic,t9015", },
+ {
+ .compatible = "amlogic,t9015",
+ .data = &t9015_match_data,
+ },
{ }
};
MODULE_DEVICE_TABLE(of, t9015_ids);
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family
2025-03-09 18:16 [PATCH v2 0/3] ASoC: meson: t9015: add support for A1 SoC family Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 1/3] ASoC: meson: t9015: prepare to adding new platforms Jan Dakinevich
@ 2025-03-09 18:16 ` Jan Dakinevich
2025-03-09 19:20 ` Rob Herring (Arm)
2025-03-10 8:09 ` Krzysztof Kozlowski
2025-03-09 18:16 ` [PATCH v2 3/3] ASoC: " Jan Dakinevich
2 siblings, 2 replies; 6+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:16 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
Add support for internal audio codec found A1 SoC family. On this SoC
the component supports capturing from ADC and has specific configuration
of input/output lines.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
.../bindings/sound/amlogic,t9015.yaml | 69 +++++++++++++++++--
1 file changed, 65 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml b/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml
index 5f5cccdbeb34..962795470601 100644
--- a/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml
+++ b/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml
@@ -9,9 +9,6 @@ title: Amlogic T9015 Internal Audio DAC
maintainers:
- Jerome Brunet <jbrunet@baylibre.com>
-allOf:
- - $ref: dai-common.yaml#
-
properties:
$nodename:
pattern: "^audio-controller@.*"
@@ -21,7 +18,9 @@ properties:
compatible:
items:
- - const: amlogic,t9015
+ - enum:
+ - amlogic,t9015
+ - amlogic,t9015-a1
clocks:
items:
@@ -43,6 +42,17 @@ properties:
sound-name-prefix: true
+ lineout-left:
+ $ref: /schemas/types.yaml#/definitions/string
+ lineout-right:
+ $ref: /schemas/types.yaml#/definitions/string
+ linein-left:
+ $ref: /schemas/types.yaml#/definitions/string
+ linein-right:
+ $ref: /schemas/types.yaml#/definitions/string
+ micbias:
+ $ref: /schemas/types.yaml#/definitions/string
+
required:
- "#sound-dai-cells"
- compatible
@@ -52,6 +62,57 @@ required:
- resets
- AVDD-supply
+
+allOf:
+ - $ref: dai-common.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: amlogic,t9015-a1
+ then:
+ properties:
+ lineout-left:
+ items:
+ - enum:
+ - none
+ - right
+ - left-inverted
+ lineout-right:
+ items:
+ - enum:
+ - none
+ - left
+ - right-inverted
+ linein-left:
+ items:
+ - enum:
+ - none
+ - differential
+ - positive
+ - negative
+ linein-right:
+ items:
+ - enum:
+ - none
+ - differential
+ - positive
+ - negative
+ micbias:
+ items:
+ - enum:
+ - 2.0V
+ - 2.1V
+ - 2.3V
+ - 2.5V
+ - 2.8V
+ else:
+ lineout-left: false
+ lineout-right: false
+ linein-left: false
+ linein-right: false
+ micbias: false
+
additionalProperties: false
examples:
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] ASoC: meson: t9015: add support for A1 SoC family
2025-03-09 18:16 [PATCH v2 0/3] ASoC: meson: t9015: add support for A1 SoC family Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 1/3] ASoC: meson: t9015: prepare to adding new platforms Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family Jan Dakinevich
@ 2025-03-09 18:16 ` Jan Dakinevich
2 siblings, 0 replies; 6+ messages in thread
From: Jan Dakinevich @ 2025-03-09 18:16 UTC (permalink / raw)
To: Jan Dakinevich, Conor Dooley, devicetree, Jaroslav Kysela,
Jerome Brunet, Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, linux-kernel, linux-sound,
Mark Brown, Martin Blumenstingl, Neil Armstrong, Rob Herring,
Takashi Iwai
A1's internal codec is very close to t9015. The main difference, that it
has ADC. This commit introduces support for capturing from it.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
sound/soc/meson/t9015.c | 312 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 312 insertions(+)
diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
index 919a2413038d..fe3e62d94fa3 100644
--- a/sound/soc/meson/t9015.c
+++ b/sound/soc/meson/t9015.c
@@ -19,16 +19,33 @@
#define LOLP_EN 3
#define DACR_EN 4
#define DACL_EN 5
+#define ADCR_EN 6
+#define ADCL_EN 7
+#define PGAR_ZCD_EN 8
+#define PGAL_ZCD_EN 9
+#define PGAR_EN 10
+#define PGAL_EN 11
+#define ADCR_INV 16
+#define ADCL_INV 17
+#define ADCR_SRC 18
+#define ADCL_SRC 19
#define DACR_INV 20
#define DACL_INV 21
#define DACR_SRC 22
#define DACL_SRC 23
+#define ADC_DEM_EN 26
+#define ADC_FILTER_MODE 28
+#define ADC_FILTER_EN 29
#define REFP_BUF_EN BIT(12)
#define BIAS_CURRENT_EN BIT(13)
#define VMID_GEN_FAST BIT(14)
#define VMID_GEN_EN BIT(15)
#define I2S_MODE BIT(30)
#define VOL_CTRL0 0x04
+#define PGAR_VC 0
+#define PGAL_VC 8
+#define ADCR_VC 16
+#define ADCL_VC 24
#define GAIN_H 31
#define GAIN_L 23
#define VOL_CTRL1 0x08
@@ -46,6 +63,28 @@
#define LOLN_POL 8
#define LOLP_POL 12
#define POWER_CFG 0x10
+#define LINEIN_CFG 0x14
+#define MICBIAS_LEVEL 0
+#define MICBIAS_EN 3
+#define PGAR_CTVMN 8
+#define PGAR_CTVMP 9
+#define PGAL_CTVMN 10
+#define PGAL_CTVMP 11
+#define PGAR_CTVIN 12
+#define PGAR_CTVIP 13
+#define PGAL_CTVIN 14
+#define PGAL_CTVIP 15
+
+#define PGAR_MASK (BIT(PGAR_CTVMP) | BIT(PGAR_CTVMN) | \
+ BIT(PGAR_CTVIP) | BIT(PGAR_CTVIN))
+#define PGAR_DIFF (BIT(PGAR_CTVIP) | BIT(PGAR_CTVIN))
+#define PGAR_POSITIVE (BIT(PGAR_CTVIP) | BIT(PGAR_CTVMN))
+#define PGAR_NEGATIVE (BIT(PGAR_CTVIN) | BIT(PGAR_CTVMP))
+#define PGAL_MASK (BIT(PGAL_CTVMP) | BIT(PGAL_CTVMN) | \
+ BIT(PGAL_CTVIP) | BIT(PGAL_CTVIN))
+#define PGAL_DIFF (BIT(PGAL_CTVIP) | BIT(PGAL_CTVIN))
+#define PGAL_POSITIVE (BIT(PGAL_CTVIP) | BIT(PGAL_CTVMN))
+#define PGAL_NEGATIVE (BIT(PGAL_CTVIN) | BIT(PGAL_CTVMP))
struct t9015 {
struct regulator *avdd;
@@ -103,6 +142,31 @@ static struct snd_soc_dai_driver t9015_dai = {
.ops = &t9015_dai_ops,
};
+static struct snd_soc_dai_driver a1_t9015_dai = {
+ .name = "t9015-hifi",
+ .playback = {
+ .stream_name = "Playback",
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = SNDRV_PCM_RATE_8000_96000,
+ .formats = (SNDRV_PCM_FMTBIT_S8 |
+ SNDRV_PCM_FMTBIT_S16_LE |
+ SNDRV_PCM_FMTBIT_S20_LE |
+ SNDRV_PCM_FMTBIT_S24_LE),
+ },
+ .capture = {
+ .stream_name = "Capture",
+ .channels_min = 1,
+ .channels_max = 2,
+ .rates = SNDRV_PCM_RATE_8000_96000,
+ .formats = (SNDRV_PCM_FMTBIT_S8 |
+ SNDRV_PCM_FMTBIT_S16_LE |
+ SNDRV_PCM_FMTBIT_S20_LE |
+ SNDRV_PCM_FMTBIT_S24_LE),
+ },
+ .ops = &t9015_dai_ops,
+};
+
static const DECLARE_TLV_DB_MINMAX_MUTE(dac_vol_tlv, -9525, 0);
static const char * const ramp_rate_txt[] = { "Fast", "Slow" };
@@ -179,6 +243,103 @@ static const struct snd_soc_dapm_route t9015_dapm_routes[] = {
{ "LOLP", NULL, "Left+ Driver", },
};
+static const DECLARE_TLV_DB_MINMAX_MUTE(a1_adc_vol_tlv, -29625, 0);
+static const DECLARE_TLV_DB_MINMAX_MUTE(a1_adc_pga_vol_tlv, -1200, 0);
+
+static const char * const a1_adc_right_txt[] = { "Right", "Left" };
+static SOC_ENUM_SINGLE_DECL(a1_adc_right, BLOCK_EN, ADCR_SRC, a1_adc_right_txt);
+
+static const char * const a1_adc_left_txt[] = { "Left", "Right" };
+static SOC_ENUM_SINGLE_DECL(a1_adc_left, BLOCK_EN, ADCL_SRC, a1_adc_left_txt);
+
+static const struct snd_kcontrol_new a1_adc_right_mux =
+ SOC_DAPM_ENUM("ADC Right Source", a1_adc_right);
+static const struct snd_kcontrol_new a1_adc_left_mux =
+ SOC_DAPM_ENUM("ADC Left Source", a1_adc_left);
+
+static const char * const a1_adc_filter_mode_txt[] = { "Voice", "HiFi"};
+static SOC_ENUM_SINGLE_DECL(a1_adc_filter_mode, BLOCK_EN, ADC_FILTER_MODE,
+ a1_adc_filter_mode_txt);
+
+static const struct snd_kcontrol_new a1_t9015_snd_controls[] = {
+ /* Volume Controls */
+ SOC_ENUM("Playback Channel Mode", mono_enum),
+ SOC_SINGLE("Playback Switch", VOL_CTRL1, DAC_SOFT_MUTE, 1, 1),
+ SOC_DOUBLE_TLV("Playback Volume", VOL_CTRL1, DACL_VC, DACR_VC,
+ 0xff, 0, dac_vol_tlv),
+
+ /* Ramp Controls */
+ SOC_ENUM("Ramp Rate", ramp_rate_enum),
+ SOC_SINGLE("Volume Ramp Switch", VOL_CTRL1, VC_RAMP_MODE, 1, 0),
+ SOC_SINGLE("Mute Ramp Switch", VOL_CTRL1, MUTE_MODE, 1, 0),
+ SOC_SINGLE("Unmute Ramp Switch", VOL_CTRL1, UNMUTE_MODE, 1, 0),
+
+ /* ADC Controls */
+ SOC_DOUBLE_TLV("ADC Volume", VOL_CTRL0, ADCL_VC, ADCR_VC,
+ 0x7f, 0, a1_adc_vol_tlv),
+ SOC_SINGLE("ADC Filter Switch", BLOCK_EN, ADC_FILTER_EN, 1, 0),
+ SOC_ENUM("ADC Filter Mode", a1_adc_filter_mode),
+ SOC_SINGLE("ADC DEM Switch", BLOCK_EN, ADC_DEM_EN, 1, 0),
+ SOC_DOUBLE_TLV("ADC PGA Volume", VOL_CTRL0, PGAR_VC, PGAL_VC,
+ 0x1f, 0, a1_adc_pga_vol_tlv),
+ SOC_DOUBLE("ADC PGA Zero Cross-detection Switch", BLOCK_EN,
+ PGAL_ZCD_EN, PGAR_ZCD_EN, 1, 0),
+};
+
+static const struct snd_soc_dapm_widget a1_t9015_dapm_widgets[] = {
+ SND_SOC_DAPM_AIF_IN("Right IN", NULL, 0, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_AIF_IN("Left IN", NULL, 0, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_MUX("Right DAC Sel", SND_SOC_NOPM, 0, 0,
+ &t9015_right_dac_mux),
+ SND_SOC_DAPM_MUX("Left DAC Sel", SND_SOC_NOPM, 0, 0,
+ &t9015_left_dac_mux),
+ SND_SOC_DAPM_DAC("Right DAC", NULL, BLOCK_EN, DACR_EN, 0),
+ SND_SOC_DAPM_DAC("Left DAC", NULL, BLOCK_EN, DACL_EN, 0),
+ SND_SOC_DAPM_OUT_DRV("Right+ Driver", BLOCK_EN, LORP_EN, 0, NULL, 0),
+ SND_SOC_DAPM_OUT_DRV("Left+ Driver", BLOCK_EN, LOLP_EN, 0, NULL, 0),
+ SND_SOC_DAPM_OUTPUT("LORP"),
+ SND_SOC_DAPM_OUTPUT("LOLP"),
+
+ SND_SOC_DAPM_INPUT("ADC IN Right"),
+ SND_SOC_DAPM_INPUT("ADC IN Left"),
+ SND_SOC_DAPM_PGA("ADC PGA Right", BLOCK_EN, PGAR_EN, 0, NULL, 0),
+ SND_SOC_DAPM_PGA("ADC PGA Left", BLOCK_EN, PGAL_EN, 0, NULL, 0),
+ SND_SOC_DAPM_ADC("ADC Right", NULL, BLOCK_EN, ADCR_EN, 0),
+ SND_SOC_DAPM_ADC("ADC Left", NULL, BLOCK_EN, ADCL_EN, 0),
+ SND_SOC_DAPM_MUX("ADC Right Sel", SND_SOC_NOPM, 0, 0, &a1_adc_right_mux),
+ SND_SOC_DAPM_MUX("ADC Left Sel", SND_SOC_NOPM, 0, 0, &a1_adc_left_mux),
+ SND_SOC_DAPM_AIF_OUT("ADC OUT Right", NULL, 0, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_AIF_OUT("ADC OUT Left", NULL, 0, SND_SOC_NOPM, 0, 0),
+};
+
+static const struct snd_soc_dapm_route a1_t9015_dapm_routes[] = {
+ { "Right IN", NULL, "Playback" },
+ { "Left IN", NULL, "Playback" },
+ { "Right DAC Sel", "Right", "Right IN" },
+ { "Right DAC Sel", "Left", "Left IN" },
+ { "Left DAC Sel", "Right", "Right IN" },
+ { "Left DAC Sel", "Left", "Left IN" },
+ { "Right DAC", NULL, "Right DAC Sel" },
+ { "Left DAC", NULL, "Left DAC Sel" },
+ { "Right+ Driver", NULL, "Right DAC" },
+ { "Left+ Driver", NULL, "Left DAC" },
+ { "LORP", NULL, "Right+ Driver", },
+ { "LOLP", NULL, "Left+ Driver", },
+
+ { "ADC PGA Right", NULL, "ADC IN Right" },
+ { "ADC PGA Left", NULL, "ADC IN Left" },
+ { "ADC Right", NULL, "ADC PGA Right" },
+ { "ADC Left", NULL, "ADC PGA Left" },
+ { "ADC Right Sel", "Right", "ADC Right" },
+ { "ADC Right Sel", "Left", "ADC Left" },
+ { "ADC Left Sel", "Right", "ADC Right" },
+ { "ADC Left Sel", "Left", "ADC Left" },
+ { "ADC OUT Right", NULL, "ADC Right Sel" },
+ { "ADC OUT Left", NULL, "ADC Left Sel" },
+ { "Capture", NULL, "ADC OUT Right" },
+ { "Capture", NULL, "ADC OUT Left" },
+};
+
static int t9015_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{
@@ -241,6 +402,134 @@ static int t9015_component_probe(struct snd_soc_component *component)
return 0;
}
+static int a1_t9015_line_cfg(struct snd_soc_component *component,
+ const char *propname, unsigned int reg,
+ unsigned int mask, const char **names,
+ const unsigned int *values, unsigned int count)
+{
+ const char *propval;
+ unsigned int i;
+ int ret;
+
+ ret = device_property_read_string(component->dev, propname, &propval);
+ if (ret)
+ propval = names[0];
+
+ for (i = 0; i < count; i++) {
+ if (strcmp(propval, names[i]))
+ continue;
+
+ snd_soc_component_update_bits(component, reg, mask, values[i]);
+ return 0;
+ }
+
+ dev_err(component->dev, "wrong '%s' property value: '%s'",
+ propname, propval);
+ return -EINVAL;
+}
+
+static int a1_t9015_lineout_cfg(struct snd_soc_component *component)
+{
+ const char *right_names[] = { "none", "right", "left-inverted" };
+ unsigned int right_values[] = { 0, 0x2000, 0x4000, };
+ const char *left_names[] = { "none", "left", "right-inverted" };
+ unsigned int left_values[] = { 0, 0x20, 0x40, };
+ int ret;
+
+ ret = a1_t9015_line_cfg(component, "lineout-right", LINEOUT_CFG, 0x7000,
+ right_names, right_values, ARRAY_SIZE(right_names));
+ if (ret)
+ return ret;
+
+ ret = a1_t9015_line_cfg(component, "lineout-left", LINEOUT_CFG, 0x70,
+ left_names, left_values, ARRAY_SIZE(left_names));
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int a1_t9015_linein_cfg(struct snd_soc_component *component)
+{
+ const char *names[] = { "none", "differential", "positive",
+ "negative" };
+ unsigned int right_values[] = { 0, PGAR_DIFF, PGAR_POSITIVE,
+ PGAR_NEGATIVE };
+ unsigned int left_values[] = { 0, PGAL_DIFF, PGAL_POSITIVE,
+ PGAL_NEGATIVE };
+ int ret;
+
+ ret = a1_t9015_line_cfg(component, "linein-right", LINEIN_CFG, PGAR_MASK,
+ names, right_values, ARRAY_SIZE(names));
+ if (ret)
+ return ret;
+
+ ret = a1_t9015_line_cfg(component, "linein-left", LINEIN_CFG, PGAL_MASK,
+ names, left_values, ARRAY_SIZE(names));
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int a1_t9015_micbias_cfg(struct snd_soc_component *component)
+{
+ const char *names[] = { "2.0V", "2.1V", "2.3V", "2.5V", "2.8V" };
+ const unsigned int values[] = { 0, 1, 2, 3, 7 };
+ const char *propname = "micbias";
+ const char *propval;
+ unsigned int i;
+ int ret;
+
+ ret = device_property_read_string(component->dev, propname, &propval);
+ if (ret) {
+ snd_soc_component_update_bits(component, LINEIN_CFG,
+ BIT(MICBIAS_EN), 0);
+ return 0;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(names); i++) {
+ if (strcmp(propval, names[i]))
+ continue;
+
+ snd_soc_component_update_bits(component, LINEIN_CFG, 0x7,
+ values[i]);
+ snd_soc_component_update_bits(component, LINEIN_CFG,
+ BIT(MICBIAS_EN), BIT(MICBIAS_EN));
+ return 0;
+ }
+
+ dev_err(component->dev, "wrong '%s' property value: '%s'",
+ propname, propval);
+ return -EINVAL;
+}
+
+static int a1_t9015_component_probe(struct snd_soc_component *component)
+{
+ int ret;
+
+ ret = a1_t9015_lineout_cfg(component);
+ if (ret)
+ return ret;
+
+ ret = a1_t9015_linein_cfg(component);
+ if (ret)
+ return ret;
+
+ ret = a1_t9015_micbias_cfg(component);
+ if (ret)
+ return ret;
+
+ /*
+ * This configuration was stealed from original Amlogic's driver to
+ * reproduce the behavior of the driver more accurately. However, it is
+ * not known for certain what it actually affects.
+ */
+ snd_soc_component_write(component, POWER_CFG, 0x00010000);
+
+ return 0;
+}
+
static const struct snd_soc_component_driver t9015_codec_driver = {
.probe = t9015_component_probe,
.set_bias_level = t9015_set_bias_level,
@@ -254,6 +543,19 @@ static const struct snd_soc_component_driver t9015_codec_driver = {
.endianness = 1,
};
+static const struct snd_soc_component_driver a1_t9015_codec_driver = {
+ .probe = a1_t9015_component_probe,
+ .set_bias_level = t9015_set_bias_level,
+ .controls = a1_t9015_snd_controls,
+ .num_controls = ARRAY_SIZE(a1_t9015_snd_controls),
+ .dapm_widgets = a1_t9015_dapm_widgets,
+ .num_dapm_widgets = ARRAY_SIZE(a1_t9015_dapm_widgets),
+ .dapm_routes = a1_t9015_dapm_routes,
+ .num_dapm_routes = ARRAY_SIZE(a1_t9015_dapm_routes),
+ .suspend_bias_off = 1,
+ .endianness = 1,
+};
+
static int t9015_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -315,11 +617,21 @@ static const struct t9015_match_data t9015_match_data = {
.max_register = POWER_CFG,
};
+static const struct t9015_match_data a1_t9015_match_data = {
+ .component_drv = &a1_t9015_codec_driver,
+ .dai_drv = &a1_t9015_dai,
+ .max_register = LINEIN_CFG,
+};
+
static const struct of_device_id t9015_ids[] __maybe_unused = {
{
.compatible = "amlogic,t9015",
.data = &t9015_match_data,
},
+ {
+ .compatible = "amlogic,t9015-a1",
+ .data = &a1_t9015_match_data,
+ },
{ }
};
MODULE_DEVICE_TABLE(of, t9015_ids);
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family
2025-03-09 18:16 ` [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family Jan Dakinevich
@ 2025-03-09 19:20 ` Rob Herring (Arm)
2025-03-10 8:09 ` Krzysztof Kozlowski
1 sibling, 0 replies; 6+ messages in thread
From: Rob Herring (Arm) @ 2025-03-09 19:20 UTC (permalink / raw)
To: Jan Dakinevich
Cc: Kevin Hilman, Takashi Iwai, Jerome Brunet, Jaroslav Kysela,
Conor Dooley, devicetree, linux-sound, Mark Brown,
Neil Armstrong, Krzysztof Kozlowski, Liam Girdwood,
linux-amlogic, linux-arm-kernel, Martin Blumenstingl,
linux-kernel
On Sun, 09 Mar 2025 21:16:29 +0300, Jan Dakinevich wrote:
> Add support for internal audio codec found A1 SoC family. On this SoC
> the component supports capturing from ADC and has specific configuration
> of input/output lines.
>
> Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
> ---
> .../bindings/sound/amlogic,t9015.yaml | 69 +++++++++++++++++--
> 1 file changed, 65 insertions(+), 4 deletions(-)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml: allOf:1:else: 'anyOf' conditional failed, one must be fixed:
'lineout-left' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems']
'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml: allOf:1:else: 'anyOf' conditional failed, one must be fixed:
'lineout-right' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems']
'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml: allOf:1:else: 'anyOf' conditional failed, one must be fixed:
'linein-left' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems']
'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml: allOf:1:else: 'anyOf' conditional failed, one must be fixed:
'linein-right' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems']
'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml: allOf:1:else: 'anyOf' conditional failed, one must be fixed:
'micbias' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems']
'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250309181630.1322745-3-jan.dakinevich@salutedevices.com
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family
2025-03-09 18:16 ` [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family Jan Dakinevich
2025-03-09 19:20 ` Rob Herring (Arm)
@ 2025-03-10 8:09 ` Krzysztof Kozlowski
1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-10 8:09 UTC (permalink / raw)
To: Jan Dakinevich
Cc: Conor Dooley, devicetree, Jaroslav Kysela, Jerome Brunet,
Kevin Hilman, Krzysztof Kozlowski, Liam Girdwood, linux-amlogic,
linux-arm-kernel, linux-kernel, linux-sound, Mark Brown,
Martin Blumenstingl, Neil Armstrong, Rob Herring, Takashi Iwai
On Sun, Mar 09, 2025 at 09:16:29PM +0300, Jan Dakinevich wrote:
> Add support for internal audio codec found A1 SoC family. On this SoC
> the component supports capturing from ADC and has specific configuration
> of input/output lines.
>
> Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
> ---
> .../bindings/sound/amlogic,t9015.yaml | 69 +++++++++++++++++--
> 1 file changed, 65 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml b/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml
> index 5f5cccdbeb34..962795470601 100644
> --- a/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml
> +++ b/Documentation/devicetree/bindings/sound/amlogic,t9015.yaml
> @@ -9,9 +9,6 @@ title: Amlogic T9015 Internal Audio DAC
> maintainers:
> - Jerome Brunet <jbrunet@baylibre.com>
>
> -allOf:
> - - $ref: dai-common.yaml#
> -
> properties:
> $nodename:
> pattern: "^audio-controller@.*"
> @@ -21,7 +18,9 @@ properties:
>
> compatible:
> items:
> - - const: amlogic,t9015
> + - enum:
> + - amlogic,t9015
> + - amlogic,t9015-a1
>
> clocks:
> items:
> @@ -43,6 +42,17 @@ properties:
>
> sound-name-prefix: true
>
> + lineout-left:
Missing vendor prefix.
> + $ref: /schemas/types.yaml#/definitions/string
enum with values
> + lineout-right:
> + $ref: /schemas/types.yaml#/definitions/string
> + linein-left:
> + $ref: /schemas/types.yaml#/definitions/string
> + linein-right:
> + $ref: /schemas/types.yaml#/definitions/string
> + micbias:
use proper unit suffix name, e.g. microvolt
> + $ref: /schemas/types.yaml#/definitions/string
> +
> required:
> - "#sound-dai-cells"
> - compatible
> @@ -52,6 +62,57 @@ required:
> - resets
> - AVDD-supply
>
> +
Only one blank line
> +allOf:
> + - $ref: dai-common.yaml#
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: amlogic,t9015-a1
> + then:
> + properties:
> + lineout-left:
> + items:
You do not have multiple items here, drop.
> + - enum:
> + - none
> + - right
> + - left-inverted
> + lineout-right:
> + items:
> + - enum:
> + - none
> + - left
> + - right-inverted
> + linein-left:
> + items:
> + - enum:
> + - none
> + - differential
> + - positive
> + - negative
> + linein-right:
> + items:
> + - enum:
> + - none
> + - differential
> + - positive
> + - negative
All these go to the top level.
> + micbias:
> + items:
> + - enum:
> + - 2.0V
> + - 2.1V
> + - 2.3V
> + - 2.5V
> + - 2.8V
> + else:
> + lineout-left: false
> + lineout-right: false
> + linein-left: false
> + linein-right: false
> + micbias: false
This is correct.
Best regards,
Krzysztof
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-10 8:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-09 18:16 [PATCH v2 0/3] ASoC: meson: t9015: add support for A1 SoC family Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 1/3] ASoC: meson: t9015: prepare to adding new platforms Jan Dakinevich
2025-03-09 18:16 ` [PATCH v2 2/3] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family Jan Dakinevich
2025-03-09 19:20 ` Rob Herring (Arm)
2025-03-10 8:09 ` Krzysztof Kozlowski
2025-03-09 18:16 ` [PATCH v2 3/3] ASoC: " Jan Dakinevich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®