Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCHv2 6/6] ARM: dts: Enable SGTL5000 codec based audio driver node for VF610 TOWER.

64 views
Skip to first unread message

Xiubo Li

unread,
Jan 13, 2014, 2:00:02 AM1/13/14
to
This patch adds and enables SGTL5000 codec support, and also specified
the corresponding SAI node.

Signed-off-by: Xiubo Li <Li.X...@freescale.com>
---
arch/arm/boot/dts/vf610-twr.dts | 47 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/vf610-twr.dts b/arch/arm/boot/dts/vf610-twr.dts
index e60c20c..acc860a 100644
--- a/arch/arm/boot/dts/vf610-twr.dts
+++ b/arch/arm/boot/dts/vf610-twr.dts
@@ -34,6 +34,43 @@
};
};

+ regulators {
+ compatible = "simple-bus";
+
+ reg_3p3v: 3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "3P3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+ };
+
+ sound {
+ compatible = "simple-audio-card";
+ sound-widgets = "vf610-sgtl5000";
+ simple-audio-card,format = "i2s";
+ simple-audio-card,routing =
+ "MIC_IN", "Mic Jack",
+ "Mic Jack", "Mic Bias",
+ "LINE_IN", "Line In Jack",
+ "Headphone Jack", "HP_OUT",
+ "Ext Spk", "LINE_OUT";
+
+ simple-audio-card,cpu {
+ sound-dai = <&sai2>;
+ master-clkdir-out;
+ frame-master;
+ bitclock-master;
+ };
+
+ simple-audio-card,codec {
+ sound-dai = <&codec>;
+ frame-master;
+ bitclock-master;
+ };
+ };
+
};

&dspi0 {
@@ -72,9 +109,19 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c0_1>;
status = "okay";
+
+ codec: sgtl5000@0a {
+ #sound-dai-cells = <0>;
+ compatible = "fsl,sgtl5000";
+ reg = <0x0a>;
+ VDDA-supply = <&reg_3p3v>;
+ VDDIO-supply = <&reg_3p3v>;
+ clocks = <&clks VF610_CLK_SAI2>;
+ };
};

&sai2 {
+ #sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai2_1>;
status = "okay";
--
1.8.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Xiubo Li

unread,
Jan 13, 2014, 2:00:02 AM1/13/14
to
This patch series is one use case of simple card driver based on dts.
For some audio cards they need to add some off-CODEC widgets. For the
audio card, if it needs off-CODEC widgets, some explict code for a
simple audio is needed, if not, just ignore of this.

This can make the audio card driver simpler and easier to debug by using
the simple card driver and some explict code if needed.

Xiubo Li

unread,
Jan 13, 2014, 2:00:02 AM1/13/14
to
Signed-off-by: Xiubo Li <Li.X...@freescale.com>
---
Documentation/devicetree/bindings/sound/simple-card.txt | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index e9e20ec..01eb2d0 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -15,6 +15,10 @@ Optional properties:
Each entry is a pair of strings, the first being the
connection's sink, the second being the connection's
source.
+- sound-widgets : The name of the audio card's off-CODEC widgets. If the
+ audio card need the off-CODEC widgets, the card driver
+ should register its widgets with one specified name:
+ "XXXX", and in dt node the sound-widgets = "XXXX".

Required subnodes:

@@ -42,6 +46,7 @@ Example:

sound {
compatible = "simple-audio-card";
+ sound-widgets = "widgets"
simple-audio-card,format = "left_j";
simple-audio-routing =
"MIC_IN", "Mic Jack",
--
1.8.4

Xiubo Li

unread,
Jan 13, 2014, 2:00:02 AM1/13/14
to
Signed-off-by: Xiubo Li <Li.X...@freescale.com>
---
sound/soc/generic/simple-card.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index b7dc63e..dbd93cc 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -125,6 +125,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
struct device_node **of_codec,
struct device_node **of_platform)
{
+ struct snd_soc_widgets *wdg;
struct device_node *np;
char *name;
int ret;
@@ -133,6 +134,14 @@ static int asoc_simple_card_parse_of(struct device_node *node,
info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
(SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);

+ wdg = snd_soc_get_widgets(node);
+ if (!IS_ERR_OR_NULL(wdg)) {
+ info->snd_card.dapm_widgets = wdg->widgets;
+ info->snd_card.num_dapm_widgets = wdg->cnt;
+ } else if (IS_ERR(wdg)) {
+ return PTR_ERR(wdg);
+ }
+
/* DAPM routes */
if (of_property_read_bool(node, "simple-audio-card,routing")) {
ret = snd_soc_of_parse_audio_routing(&info->snd_card,
--
1.8.4

Xiubo Li

unread,
Jan 13, 2014, 2:00:03 AM1/13/14
to
This will be need for some audio card, which maybe using the simple
card and the off-CODEC widgets is needed.

Signed-off-by: Xiubo Li <Li.X...@freescale.com>
---
include/sound/soc.h | 10 ++++++++++
sound/soc/soc-core.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 03ce45b..23f9572 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -326,6 +326,7 @@ struct snd_soc_platform_driver;
struct snd_soc_codec;
struct snd_soc_codec_driver;
struct snd_soc_component;
+struct snd_soc_widgets;
struct snd_soc_component_driver;
struct soc_enum;
struct snd_soc_jack;
@@ -385,6 +386,8 @@ int devm_snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *cmpnt_drv,
struct snd_soc_dai_driver *dai_drv, int num_dai);
void snd_soc_unregister_component(struct device *dev);
+int snd_soc_register_widgets(struct snd_soc_widgets *wdg);
+void snd_soc_unregister_widgets(struct snd_soc_widgets *wdg);
int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
unsigned int reg);
int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
@@ -664,6 +667,13 @@ struct snd_soc_component {
const struct snd_soc_component_driver *driver;
};

+struct snd_soc_widgets {
+ const char *name;
+ struct list_head list;
+ const struct snd_soc_dapm_widget *widgets;
+ unsigned int cnt;
+};
+
/* SoC Audio Codec device */
struct snd_soc_codec {
const char *name;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3a128f0..9adcada 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3821,6 +3821,45 @@ int snd_soc_unregister_card(struct snd_soc_card *card)
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_card);

+static DEFINE_MUTEX(widgets_mutex);
+static LIST_HEAD(widgets_list);
+/**
+ * snd_soc_register_widgets - Register off codec widgets with
+ * the ASoC core
+ *
+ * @wdg: widgets to register
+ *
+ */
+int snd_soc_register_widgets(struct snd_soc_widgets *wdg)
+{
+ int ret;
+
+ if (!wdg)
+ return -EINVAL;
+
+ mutex_lock(&widgets_mutex);
+ list_add(&wdg->list, &widgets_list);
+ mutex_unlock(&widgets_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_register_widgets);
+
+/**
+ * snd_soc_unregister_widgets - Unregister off codec widgets with
+ * the ASoC core
+ *
+ * @wdg: widgets to unregister
+ *
+ */
+void snd_soc_unregister_widgets(struct snd_soc_widgets *wdg)
+{
+ mutex_lock(&widgets_mutex);
+ list_del(&wdg->list);
+ mutex_unlock(&widgets_mutex);
+}
+EXPORT_SYMBOL_GPL(snd_soc_unregister_widgets);
+
/*
* Simplify DAI link configuration by removing ".-1" from device names
* and sanitizing names.
--
1.8.4

Xiubo Li

unread,
Jan 13, 2014, 2:00:03 AM1/13/14
to
This is the SGTL5000 codec based off-CODEC widgets supports.

Signed-off-by: Xiubo Li <Li.X...@freescale.com>
---
sound/soc/fsl/Kconfig | 25 ++++++++++++++++++
sound/soc/fsl/Makefile | 3 +++
sound/soc/fsl/snd-soc-simple-card-vf610.c | 43 +++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+)
create mode 100644 sound/soc/fsl/snd-soc-simple-card-vf610.c

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 324988d..1a09028 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -219,3 +219,28 @@ config SND_SOC_IMX_MC13783
select SND_SOC_IMX_PCM_DMA

endif # SND_IMX_SOC
+
+menuconfig SND_VF610_SOC
+ tristate "SoC Audio for Freescale VF610 CPUs"
+ select DMA_ENGINE
+ help
+ Say Y or M if you want to add support for codecs attached to
+ the VF610 CPUs.
+
+ This will enable Freeacale SAI and SGTL5000 codec, and an extra
+ TWR-AUDIO-SGTL sub-board is needed for SGTL5000.
+
+if SND_VF610_SOC
+
+config SND_SOC_VF610_SGTL5000
+ tristate "SoC Audio support for VF610 boards with SGTL5000"
+ depends on OF && I2C
+ select SND_SOC_FSL_SAI
+ select SND_SOC_SGTL5000
+ select SND_SIMPLE_CARD
+ help
+ Say Y if you want to add support for SoC audio on an VF610 board with
+ a SGTL5000 codec and a SAI.
+
+
+endif #SND_VF610_SOC
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index b12ad4b..668cead 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -60,3 +60,6 @@ obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o
obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
+
+# Simple audio card widgets Support
+obj-$(CONFIG_SND_SOC_VF610_SGTL5000) += snd-soc-simple-card-vf610.o
diff --git a/sound/soc/fsl/snd-soc-simple-card-vf610.c b/sound/soc/fsl/snd-soc-simple-card-vf610.c
new file mode 100644
index 0000000..ee28748
--- /dev/null
+++ b/sound/soc/fsl/snd-soc-simple-card-vf610.c
@@ -0,0 +1,43 @@
+/*
+ * ASoC VF610 SGTL5000 off-CODEC widgets support
+ *
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+static const struct snd_soc_dapm_widget vf610_sgtl5000_dapm_widgets[] = {
+ SND_SOC_DAPM_MIC("Mic Jack", NULL),
+ SND_SOC_DAPM_LINE("Line In Jack", NULL),
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_SPK("Line Out Jack", NULL),
+ SND_SOC_DAPM_SPK("Ext Spk", NULL),
+};
+
+struct snd_soc_widgets vf610_sgtl5000_widgets = {
+ .name = "vf610-sgtl5000",
+ .widgets = vf610_sgtl5000_dapm_widgets,
+ .cnt = ARRAY_SIZE(vf610_sgtl5000_dapm_widgets),
+};
+
+static int __init __vf610_sgtl5000_widgets_init(void)
+{
+ return snd_soc_register_widgets(&vf610_sgtl5000_widgets);
+}
+module_init(__vf610_sgtl5000_widgets_init);
+
+static void __exit __vf610_sgtl5000_widgets_exit(void)
+{
+ snd_soc_unregister_widgets(&vf610_sgtl5000_widgets);
+}
+module_exit(__vf610_sgtl5000_widgets_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:vf610-simple-card-widgets");
+MODULE_DESCRIPTION("ASoC Simple Sound Card Widgets");
+MODULE_AUTHOR("Xiubo Li <Li.X...@freescale.com>");
--
1.8.4

Xiubo Li

unread,
Jan 13, 2014, 2:00:03 AM1/13/14
to
Add widgets list getting.

Signed-off-by: Xiubo Li <Li.X...@freescale.com>
---
include/sound/soc.h | 1 +
sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 23f9572..f352333 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -388,6 +388,7 @@ int devm_snd_soc_register_component(struct device *dev,
void snd_soc_unregister_component(struct device *dev);
int snd_soc_register_widgets(struct snd_soc_widgets *wdg);
void snd_soc_unregister_widgets(struct snd_soc_widgets *wdg);
+struct snd_soc_widgets *snd_soc_get_widgets(struct device_node *np);
int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
unsigned int reg);
int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9adcada..e1d26e6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3860,6 +3860,37 @@ void snd_soc_unregister_widgets(struct snd_soc_widgets *wdg)
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_widgets);

+struct snd_soc_widgets *snd_soc_get_widgets(struct device_node *np)
+{
+ struct snd_soc_widgets *wdg;
+ const char *string;
+ int ret;
+
+ if (!np)
+ return ERR_PTR(-EINVAL);
+
+ if (!of_property_read_bool(np, "sound-widgets"))
+ return NULL;
+
+ ret = of_property_read_string(np, "sound-widgets",
+ &string);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ mutex_lock(&widgets_mutex);
+ list_for_each_entry(wdg, &widgets_list, list) {
+ if (!strcmp(string, wdg->name)) {
+ mutex_unlock(&widgets_mutex);
+ return wdg;
+ }
+
+ }
+ mutex_unlock(&widgets_mutex);
+
+ return ERR_PTR(-EPROBE_DEFER);
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_widgets);
+
/*
* Simplify DAI link configuration by removing ".-1" from device names
* and sanitizing names.
--
1.8.4


Mark Brown

unread,
Jan 13, 2014, 12:20:02 PM1/13/14
to
On Mon, Jan 13, 2014 at 01:53:57PM +0800, Xiubo Li wrote:
> This is the SGTL5000 codec based off-CODEC widgets supports.
>
> Signed-off-by: Xiubo Li <Li.X...@freescale.com>
> ---
> sound/soc/fsl/Kconfig | 25 ++++++++++++++++++
> sound/soc/fsl/Makefile | 3 +++
> sound/soc/fsl/snd-soc-simple-card-vf610.c | 43 +++++++++++++++++++++++++++++++

My previous comment on this still stands - if we're adding an explicit
machine driver for a simple card that defeats the point of having simple
card in the first place, the system may as well just have a normal
machine driver.
signature.asc

Li.X...@freescale.com

unread,
Jan 14, 2014, 5:00:02 AM1/14/14
to
Hi Mark,

I have sent another patch, if that patch is ok, please ignore this patch
series.

The new patch :" ASoC: add snd_soc_of_parse_audio_simple_widgets for
DeviceTree"

Thanks,

--
Best Regards,
Xiubo
0 new messages