[alsa-devel] [PATCH] ASoC: twl6040: Support for DT

Peter Ujfalusi peter.ujfalusi at ti.com
Tue May 8 13:52:25 CEST 2012


Enable Device Tree based loading of the codec driver.

Example of dts section to load the twl6040-codec driver:
twl6040: twl6040 at 4b {
	...
	twl6040_codec: twl6040 at 0 {
		compatible = "ti,twl6040-codec";
		interrupts = <1>;
	};
};

Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>
---
 .../devicetree/bindings/sound/twl6040.txt          |   26 ++++++++++++++++++++
 sound/soc/codecs/twl6040.c                         |    8 ++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/twl6040.txt

diff --git a/Documentation/devicetree/bindings/sound/twl6040.txt b/Documentation/devicetree/bindings/sound/twl6040.txt
new file mode 100644
index 0000000..1f3dd70
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/twl6040.txt
@@ -0,0 +1,26 @@
+ASoC codec driver for the twl6040 family
+
+The ASoC codec driver is a child of the twl6040 MFD dirver.
+Documentation/devicetree/bindings/mfd/twl6040.txt
+
+Required properties:
+- compatible : Must be "ti,twl6040-codec";
+- interrupts: 1, Jack plug detection IRQ
+
+Example:
+/*
+ * 8-channel high quality low-power audio codec
+ * http://www.ti.com/lit/ds/symlink/twl6040.pdf
+ */
+twl6040: twl6040 at 4b {
+	...
+	twl6040_codec: twl6040 at 0 {
+		compatible = "ti,twl6040-codec";
+		interrupts = <1>;
+	};
+};
+
+sound { /* ASoC machine dirver */
+	...
+	dai-link,codec = <&twl6040_codec>;
+};
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 0747260..85c6e0c 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/mfd/twl6040.h>
 
@@ -1229,10 +1230,17 @@ static int __devexit twl6040_codec_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id twl6040_codec_of_match[] = {
+	{.compatible = "ti,twl6040-codec", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, twl6040_codec_of_match);
+
 static struct platform_driver twl6040_codec_driver = {
 	.driver = {
 		.name = "twl6040-codec",
 		.owner = THIS_MODULE,
+		.of_match_table = twl6040_codec_of_match,
 	},
 	.probe = twl6040_codec_probe,
 	.remove = __devexit_p(twl6040_codec_remove),
-- 
1.7.8.6



More information about the Alsa-devel mailing list