devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
To: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux ARM
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
Subject: [PATCH v2 1/9] ASoC: alc5623: Add device tree binding
Date: Sat,  3 May 2014 20:30:11 +0200	[thread overview]
Message-ID: <1399141819-23924-2-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1399141819-23924-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>

Let the ALC5623 codec be instantiated from DT. Add a simple binding
for the additional control register and the jack detect register.

Also, add a prompt to the Kconfig entry for this CODEC, so that it can
be selected. Since kirkwood-t5325.c will no longer be used, we need to
be able to enable the CODEC in the mvebu_v5_defconfig etc.

Signed-off-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
---
I followed the example of the WM8903 binding which allows register
values to be placed into DT.

v1->v2:

Add redundant OF ID table.
Fix binding documentation.
Fix check of return code from of_property_read_u32().
Add Kconfig prompt
---
 .../devicetree/bindings/sound/alc5623.txt          | 25 ++++++++++++++++++++++
 sound/soc/codecs/Kconfig                           |  2 +-
 sound/soc/codecs/alc5623.c                         | 20 +++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/sound/alc5623.txt

diff --git a/Documentation/devicetree/bindings/sound/alc5623.txt b/Documentation/devicetree/bindings/sound/alc5623.txt
new file mode 100644
index 000000000000..26c86c98d671
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/alc5623.txt
@@ -0,0 +1,25 @@
+ALC5621/ALC5622/ALC5623 audio Codec
+
+Required properties:
+
+ - compatible:	"realtek,alc5623"
+ - reg:		the I2C address of the device.
+
+Optional properties:
+
+ - add-ctrl:	  Default register value for Reg-40h, Additional Control
+		  Register. If absent or has the value of 0, the
+		  register is untouched.
+
+ - jack-det-ctrl: Default register value for Reg-5Ah, Jack Detect
+		  Control Register. If absent or has value 0, the
+		  register is untouched.
+
+Example:
+
+	alc5621: alc5621@1a {
+		compatible = "alc5621";
+		reg = <0x1a>;
+		add-ctrl = <0x3700>;
+		jack-det-ctrl = <0x4810>;
+	};
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index f0e840137887..5fefaa8c50ef 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -269,7 +269,7 @@ config SND_SOC_AK5386
 	tristate "AKM AK5638 CODEC"
 
 config SND_SOC_ALC5623
-       tristate
+       tristate "Realtek ALC5623 CODEC"
 
 config SND_SOC_ALC5632
 	tristate
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index 2acf82f4a08a..9d0755aa1d16 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -23,6 +23,7 @@
 #include <linux/i2c.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -998,8 +999,10 @@ static int alc5623_i2c_probe(struct i2c_client *client,
 {
 	struct alc5623_platform_data *pdata;
 	struct alc5623_priv *alc5623;
+	struct device_node *np;
 	unsigned int vid1, vid2;
 	int ret;
+	u32 val32;
 
 	alc5623 = devm_kzalloc(&client->dev, sizeof(struct alc5623_priv),
 			       GFP_KERNEL);
@@ -1040,6 +1043,16 @@ static int alc5623_i2c_probe(struct i2c_client *client,
 	if (pdata) {
 		alc5623->add_ctrl = pdata->add_ctrl;
 		alc5623->jack_det_ctrl = pdata->jack_det_ctrl;
+	} else {
+		if (client->dev.of_node) {
+			np = client->dev.of_node;
+			ret = of_property_read_u32(np, "add-ctrl", &val32);
+			if (!ret)
+				alc5623->add_ctrl = val32;
+			ret = of_property_read_u32(np, "jack-det-ctrl", &val32);
+			if (!ret)
+				alc5623->jack_det_ctrl = val32;
+		}
 	}
 
 	alc5623->id = vid2;
@@ -1081,11 +1094,18 @@ static const struct i2c_device_id alc5623_i2c_table[] = {
 };
 MODULE_DEVICE_TABLE(i2c, alc5623_i2c_table);
 
+static const struct of_device_id alc5623_of_match[] = {
+	{ .compatible = "realtek,alc5623", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, alc5623_of_match);
+
 /*  i2c codec control layer */
 static struct i2c_driver alc5623_i2c_driver = {
 	.driver = {
 		.name = "alc562x-codec",
 		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(alc5623_of_match),
 	},
 	.probe = alc5623_i2c_probe,
 	.remove =  alc5623_i2c_remove,
-- 
2.0.0.rc0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-05-03 18:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-03 18:30 [PATCH v2 0/9] DT instantiation of sound on T5325 Andrew Lunn
     [not found] ` <1399141819-23924-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-03 18:30   ` Andrew Lunn [this message]
     [not found]     ` <1399141819-23924-2-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-04 17:49       ` [PATCH v2 1/9] ASoC: alc5623: Add device tree binding Jason Cooper
2014-05-20 22:12       ` Mark Brown
2014-05-03 18:30   ` [PATCH v2 2/9] ARM: Kirkwood: Remove platform driver for codec Andrew Lunn
     [not found]     ` <1399141819-23924-3-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-05  1:12       ` Jason Cooper
2014-05-03 18:30   ` [PATCH v2 3/9] ARM: Kirkwood: Add node for audio codec Andrew Lunn
     [not found]     ` <1399141819-23924-4-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-05  1:21       ` Jason Cooper
2014-05-03 18:30   ` [PATCH v2 4/9] ARM: Kirkwood: DT: Add missing #sound-dai-cells property Andrew Lunn
2014-05-03 18:30   ` [PATCH v2 5/9] ASoC: simple-card: Support setting mclk via a fixed factor Andrew Lunn
     [not found]     ` <1399141819-23924-6-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-04 17:50       ` Jason Cooper
2014-05-20 22:13       ` Mark Brown
     [not found]         ` <20140520221359.GF12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-22 15:31           ` [PATCH v3 " Andrew Lunn
     [not found]             ` <1400772710-23523-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-22 17:39               ` Mark Brown
     [not found]                 ` <20140522173919.GM12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-22 17:52                   ` Andrew Lunn
     [not found]                     ` <20140522175206.GA24500-g2DYL2Zd6BY@public.gmane.org>
2014-05-22 18:30                       ` Mark Brown
     [not found]                         ` <20140522183054.GQ12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-22 19:10                           ` Andrew Lunn
     [not found]                             ` <20140522191013.GC24500-g2DYL2Zd6BY@public.gmane.org>
2014-05-22 19:23                               ` Mark Brown
2014-05-26 13:29               ` Mark Brown
2014-05-03 18:30   ` [PATCH v2 6/9] ARM: Kirkwood: t5325: Remove platform device to instantiate audio Andrew Lunn
2014-05-03 18:30   ` [PATCH v2 7/9] ARM: Kirkwood: t5325: Use simple card " Andrew Lunn
2014-05-03 18:30   ` [PATCH v2 8/9] ARM: mvebu_v5_defconfig: Enable sound modules needed for t5325 Andrew Lunn
     [not found]     ` <1399141819-23924-9-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-05-05  1:23       ` Jason Cooper
2014-05-03 18:30   ` [PATCH v2 9/9] ARM: multi_v5_defconfig: " Andrew Lunn
2014-05-08 17:37   ` [PATCH v2 0/9] DT instantiation of sound on T5325 Andrew Lunn
     [not found]     ` <20140508173748.GK27377-g2DYL2Zd6BY@public.gmane.org>
2014-05-20 21:47       ` Mark Brown
     [not found]         ` <20140520214718.GT12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-20 21:53           ` Andrew Lunn

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=1399141819-23924-2-git-send-email-andrew@lunn.ch \
    --to=andrew-g2dyl2zd6by@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).