From: Jan Dakinevich <jan.dakinevich@salutedevices.com>
To: Jan Dakinevich <jan.dakinevich@salutedevices.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Jerome Brunet <jbrunet@baylibre.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
<linux-amlogic@lists.infradead.org>, <linux-clk@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<alsa-devel@alsa-project.org>, <linux-sound@vger.kernel.org>,
<linux-gpio@vger.kernel.org>
Cc: <kernel@salutedevices.com>
Subject: [PATCH 10/25] ASoC: meson: t9015: prepare to adding new platforms
Date: Fri, 15 Mar 2024 02:21:46 +0300 [thread overview]
Message-ID: <20240314232201.2102178-11-jan.dakinevich@salutedevices.com> (raw)
In-Reply-To: <20240314232201.2102178-1-jan.dakinevich@salutedevices.com>
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 571f65788c59..48f6767bd858 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
next prev parent reply other threads:[~2024-03-14 23:24 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 23:21 [PATCH 00/25] Introduce support of audio for Amlogic A1 SoC family Jan Dakinevich
2024-03-14 23:21 ` [PATCH 01/25] clk: meson: a1: restrict an amount of 'hifi_pll' params Jan Dakinevich
2024-03-15 8:58 ` Jerome Brunet
2024-03-17 14:17 ` Jan Dakinevich
2024-03-18 10:17 ` Jerome Brunet
2024-03-18 22:35 ` Jan Dakinevich
2024-03-19 8:21 ` Jerome Brunet
2024-03-19 13:53 ` Dmitry Rokosov
2024-03-14 23:21 ` [PATCH 02/25] clk: meson: axg: move reset controller's code to separate module Jan Dakinevich
2024-03-14 23:21 ` [PATCH 03/25] dt-bindings: clock: meson: add A1 audio clock and reset controller bindings Jan Dakinevich
2024-03-15 9:56 ` Krzysztof Kozlowski
2024-03-14 23:21 ` [PATCH 04/25] clk: meson: a1: add the audio clock controller driver Jan Dakinevich
2024-03-15 9:20 ` Jerome Brunet
2024-03-19 1:47 ` Jan Dakinevich
2024-03-19 8:30 ` Jerome Brunet
2024-03-23 18:02 ` Jan Dakinevich
2024-03-26 15:26 ` Jerome Brunet
2024-03-26 18:44 ` Jan Dakinevich
2024-03-27 12:57 ` Jerome Brunet
2024-03-14 23:21 ` [PATCH 05/25] ASoC: meson: codec-glue: add support for capture stream Jan Dakinevich
2024-03-14 23:21 ` [PATCH 06/25] ASoC: meson: g12a-toacodec: fix "Lane Select" width Jan Dakinevich
2024-03-15 10:00 ` Jerome Brunet
2024-03-15 13:17 ` Dan Carpenter
2024-03-24 17:51 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 07/25] ASoC: meson: g12a-toacodec: rework the definition of bits Jan Dakinevich
2024-03-14 23:21 ` [PATCH 08/25] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family Jan Dakinevich
2024-03-15 9:58 ` Krzysztof Kozlowski
2024-03-17 14:29 ` Jan Dakinevich
2024-03-17 14:46 ` Krzysztof Kozlowski
2024-03-17 15:11 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 09/25] ASoC: " Jan Dakinevich
2024-03-15 13:33 ` Mark Brown
2024-03-17 15:19 ` Jan Dakinevich
2024-03-18 10:42 ` Jerome Brunet
2024-03-18 13:30 ` Mark Brown
2024-03-14 23:21 ` Jan Dakinevich [this message]
2024-03-14 23:21 ` [PATCH 11/25] ASoC: dt-bindings: meson: t9015: " Jan Dakinevich
2024-03-17 19:03 ` Rob Herring
2024-03-17 23:39 ` Jan Dakinevich
2024-03-18 7:46 ` Krzysztof Kozlowski
2024-03-14 23:21 ` [PATCH 12/25] ASoC: " Jan Dakinevich
2024-03-15 13:36 ` Mark Brown
2024-03-17 16:27 ` Jan Dakinevich
2024-03-18 13:48 ` Mark Brown
2024-03-18 22:43 ` Jan Dakinevich
2024-03-18 10:46 ` Jerome Brunet
2024-03-19 0:17 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 13/25] ASoC: dt-bindings: meson: axg-pdm: document 'sysrate' property Jan Dakinevich
2024-03-15 10:00 ` Krzysztof Kozlowski
2024-03-15 10:22 ` Jerome Brunet
2024-03-17 15:52 ` Jan Dakinevich
2024-03-18 10:55 ` Jerome Brunet
2024-03-18 12:19 ` Jerome Brunet
2024-03-19 0:30 ` Jan Dakinevich
2024-03-19 0:35 ` Jan Dakinevich
2024-03-19 5:17 ` Krzysztof Kozlowski
2024-03-17 15:55 ` Jan Dakinevich
2024-03-17 16:27 ` Krzysztof Kozlowski
2024-03-17 16:35 ` Jan Dakinevich
2024-03-19 5:17 ` Krzysztof Kozlowski
2024-03-14 23:21 ` [PATCH 14/25] ASoC: meson: axg-pdm: introduce " Jan Dakinevich
2024-03-14 23:21 ` [PATCH 15/25] pinctrl/meson: fix typo in PDM's pin name Jan Dakinevich
2024-03-14 23:21 ` [PATCH 16/25] ASoC: dt-bindings: meson: meson-axg-audio-arb: claim support of A1 SoC family Jan Dakinevich
2024-03-17 19:10 ` Rob Herring
2024-03-14 23:21 ` [PATCH 17/25] ASoC: dt-bindings: meson: axg-fifo: " Jan Dakinevich
2024-03-17 19:13 ` Rob Herring
2024-03-14 23:21 ` [PATCH 18/25] ASoC: dt-bindings: meson: axg-pdm: " Jan Dakinevich
2024-03-17 19:14 ` Rob Herring
2024-03-14 23:21 ` [PATCH 19/25] ASoC: dt-bindings: meson: axg-sound-card: " Jan Dakinevich
2024-03-15 10:06 ` Jerome Brunet
2024-03-17 16:39 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 20/25] ASoC: dt-bindings: meson: axg-tdm-formatters: " Jan Dakinevich
2024-03-17 19:16 ` Rob Herring
2024-03-14 23:21 ` [PATCH 21/25] ASoC: dt-bindings: meson: axg-tdm-iface: " Jan Dakinevich
2024-03-15 10:13 ` Jerome Brunet
2024-03-14 23:21 ` [PATCH 22/25] ASoC: dt-bindings: meson: introduce link-name optional property Jan Dakinevich
2024-03-17 19:45 ` Rob Herring
2024-03-18 7:27 ` Dmitry Rokosov
2024-03-14 23:21 ` [PATCH 23/25] ASoC: meson: implement link-name optional property in meson card utils Jan Dakinevich
2024-03-14 23:22 ` [PATCH 24/25] arm64: dts: meson: a1: add audio devices Jan Dakinevich
2024-03-14 23:22 ` [PATCH 25/25] arm64: dts: ad402: enable audio Jan Dakinevich
2024-03-15 10:01 ` [PATCH 00/25] Introduce support of audio for Amlogic A1 SoC family Jerome Brunet
2024-03-15 15:50 ` Rob Herring
2024-03-15 16:53 ` Neil Armstrong
2024-03-18 7:30 ` Dmitry Rokosov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240314232201.2102178-11-jan.dakinevich@salutedevices.com \
--to=jan.dakinevich@salutedevices.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jbrunet@baylibre.com \
--cc=kernel@salutedevices.com \
--cc=khilman@baylibre.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox