All of lore.kernel.org
 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 1/5] ASoC: alc5623: Add device tree binding
Date: Thu, 17 Apr 2014 17:53:10 +0200	[thread overview]
Message-ID: <1397749994-24983-2-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1397749994-24983-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.

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.
---
 .../devicetree/bindings/sound/alc5623.txt          | 23 ++++++++++++++++++++++
 sound/soc/codecs/alc5623.c                         | 13 ++++++++++++
 2 files changed, 36 insertions(+)
 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..f7f71346e338
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/alc5623.txt
@@ -0,0 +1,23 @@
+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, the default is 0.
+
+  - jack-det-ctrl:	Default register value for Reg-5Ah, Jack Detect
+			Control Register. If absent, the default is 0.
+
+Example:
+
+			alc5621: alc5621@1a {
+				compatible = "alc5621";
+				reg = <0x1a>;
+				add-ctrl = <0x3700>;
+				jack-det-ctrl = <0x4810>;
+			};
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index 2acf82f4a08a..1f9273d20b39 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 >= 0)
+				alc5623->add_ctrl = val32;
+			ret = of_property_read_u32(np, "jack-det-ctrl", &val32);
+			if (ret >= 0)
+				alc5623->jack_det_ctrl = val32;
+		}
 	}
 
 	alc5623->id = vid2;
-- 
1.9.2

--
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

WARNING: multiple messages have this Message-ID (diff)
From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] ASoC: alc5623: Add device tree binding
Date: Thu, 17 Apr 2014 17:53:10 +0200	[thread overview]
Message-ID: <1397749994-24983-2-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1397749994-24983-1-git-send-email-andrew@lunn.ch>

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

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
I followed the example of the WM8903 binding which allows register
values to be placed into DT.
---
 .../devicetree/bindings/sound/alc5623.txt          | 23 ++++++++++++++++++++++
 sound/soc/codecs/alc5623.c                         | 13 ++++++++++++
 2 files changed, 36 insertions(+)
 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..f7f71346e338
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/alc5623.txt
@@ -0,0 +1,23 @@
+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, the default is 0.
+
+  - jack-det-ctrl:	Default register value for Reg-5Ah, Jack Detect
+			Control Register. If absent, the default is 0.
+
+Example:
+
+			alc5621: alc5621 at 1a {
+				compatible = "alc5621";
+				reg = <0x1a>;
+				add-ctrl = <0x3700>;
+				jack-det-ctrl = <0x4810>;
+			};
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index 2acf82f4a08a..1f9273d20b39 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 >= 0)
+				alc5623->add_ctrl = val32;
+			ret = of_property_read_u32(np, "jack-det-ctrl", &val32);
+			if (ret >= 0)
+				alc5623->jack_det_ctrl = val32;
+		}
 	}
 
 	alc5623->id = vid2;
-- 
1.9.2

  parent reply	other threads:[~2014-04-17 15:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17 15:53 [PATCH 0/5] Simple-audio-card support for HP t5325 Andrew Lunn
2014-04-17 15:53 ` Andrew Lunn
     [not found] ` <1397749994-24983-1-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-04-17 15:53   ` Andrew Lunn [this message]
2014-04-17 15:53     ` [PATCH 1/5] ASoC: alc5623: Add device tree binding Andrew Lunn
2014-04-18 16:33     ` Mark Brown
2014-04-18 16:33       ` Mark Brown
     [not found]       ` <20140418163351.GI12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-04-18 18:17         ` Andrew Lunn
2014-04-18 18:17           ` Andrew Lunn
     [not found]           ` <20140418181735.GB32580-g2DYL2Zd6BY@public.gmane.org>
2014-04-18 18:44             ` Mark Brown
2014-04-18 18:44               ` Mark Brown
2014-04-28  7:01     ` Anil Kumar
2014-04-17 15:53   ` [PATCH 2/5] ARM: Kirkwood: Use DT to instansiate codec Andrew Lunn
2014-04-17 15:53     ` Andrew Lunn
     [not found]     ` <1397749994-24983-3-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-04-17 21:37       ` Jason Cooper
2014-04-17 21:37         ` Jason Cooper
2014-04-17 15:53   ` [PATCH 3/5] ARM: Kirkwood: DT: Add missing #sound-dai-cells property Andrew Lunn
2014-04-17 15:53     ` Andrew Lunn
2014-04-17 15:53   ` [PATCH 4/5] ASoC: simple-card: Support setting mclk via a fixed factor Andrew Lunn
2014-04-17 15:53     ` Andrew Lunn
     [not found]     ` <1397749994-24983-5-git-send-email-andrew-g2DYL2Zd6BY@public.gmane.org>
2014-04-18 16:38       ` Mark Brown
2014-04-18 16:38         ` Mark Brown
2014-04-17 15:53   ` [PATCH 5/5] ARM: Kirkwood: t5325: Use simple-card to instantiate audio Andrew Lunn
2014-04-17 15:53     ` Andrew Lunn
2014-04-18  0:15   ` [PATCH 0/5] Simple-audio-card support for HP t5325 Jason Cooper
2014-04-18  0:15     ` Jason Cooper

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=1397749994-24983-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.