* [PATCH V3] ASoC: WM8962: Add device tree binding
@ 2013-06-07 3:23 Nicolin Chen
[not found] ` <1370575407-17712-1-git-send-email-b42378-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Nicolin Chen @ 2013-06-07 3:23 UTC (permalink / raw)
To: patches, alsa-devel, devicetree-discuss
Cc: grant.likely, broonie, lgirdwood, rob.herring
Document the device tree binding for the WM8962 codec, and modify the
driver to extract platform data from the device tree, if present.
Based on work of WM8903 by Stephen Warren <swarren@nvidia.com>
Signed-off-by: Nicolin Chen <b42378@freescale.com>
---
ChangeLog:
v1->v2:
* Dropped out-of-band value error msg by regarding it as default value.
v2->v3:
* Revised binding doc to warn users if property absent then use default value.
Documentation/devicetree/bindings/sound/wm8962.txt | 23 +++++++++++++
sound/soc/codecs/wm8962.c | 35 +++++++++++++++++++-
2 files changed, 57 insertions(+), 1 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/wm8962.txt b/Documentation/devicetree/bindings/sound/wm8962.txt
index dceb3b1..7f82b59 100644
--- a/Documentation/devicetree/bindings/sound/wm8962.txt
+++ b/Documentation/devicetree/bindings/sound/wm8962.txt
@@ -8,9 +8,32 @@ Required properties:
- reg : the I2C address of the device.
+Optional properties:
+ - spk-mono: This is a boolean property. If present, the SPK_MONO bit
+ of R51 (Class D Control 2) gets set, indicating that the speaker is
+ in mono mode.
+
+ - mic-cfg : Default register value for R48 (Additional Control 4).
+ If absent, the default should be the register default.
+
+ - gpio-cfg : A list of GPIO configuration register values. The list must
+ be 6 entries long. If absent, no configuration of these registers is
+ performed. And note that only the value within [0x0, 0xffff] is valid.
+ Any other value is regarded as setting the GPIO register by its reset
+ value 0x0.
+
Example:
codec: wm8962@1a {
compatible = "wlf,wm8962";
reg = <0x1a>;
+
+ gpio-cfg = <
+ 0x0000 /* 0:Default */
+ 0x0000 /* 1:Default */
+ 0x0013 /* 2:FN_DMICCLK */
+ 0x0000 /* 3:Default */
+ 0x8014 /* 4:FN_DMICCDAT */
+ 0x0000 /* 5:Default */
+ >;
};
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index d56dd86..26219ea 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3584,6 +3584,34 @@ static const struct regmap_config wm8962_regmap = {
.cache_type = REGCACHE_RBTREE,
};
+static int wm8962_set_pdata_from_of(struct i2c_client *i2c,
+ struct wm8962_pdata *pdata)
+{
+ const struct device_node *np = i2c->dev.of_node;
+ u32 val32;
+ int i;
+
+ if (of_property_read_bool(np, "spk-mono"))
+ pdata->spk_mono = true;
+
+ if (of_property_read_u32(np, "mic-cfg", &val32) >= 0)
+ pdata->mic_cfg = val32;
+
+ if (of_property_read_u32_array(np, "gpio-cfg", pdata->gpio_init,
+ ARRAY_SIZE(pdata->gpio_init)) >= 0)
+ for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++) {
+ /*
+ * The range of GPIO register value is [0x0, 0xffff]
+ * While the default value of each register is 0x0
+ * Any other value will be regarded as default value
+ */
+ if (pdata->gpio_init[i] > 0xffff)
+ pdata->gpio_init[i] = 0x0;
+ }
+
+ return 0;
+}
+
static int wm8962_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
@@ -3604,8 +3632,13 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
wm8962->irq = i2c->irq;
/* If platform data was supplied, update the default data in priv */
- if (pdata)
+ if (pdata) {
memcpy(&wm8962->pdata, pdata, sizeof(struct wm8962_pdata));
+ } else if (i2c->dev.of_node) {
+ ret = wm8962_set_pdata_from_of(i2c, &wm8962->pdata);
+ if (ret != 0)
+ return ret;
+ }
for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
wm8962->supplies[i].supply = wm8962_supply_names[i];
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V3] ASoC: WM8962: Add device tree binding
[not found] ` <1370575407-17712-1-git-send-email-b42378-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2013-06-07 9:35 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-06-07 9:35 UTC (permalink / raw)
To: Nicolin Chen
Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A
[-- Attachment #1.1: Type: text/plain, Size: 220 bytes --]
On Fri, Jun 07, 2013 at 11:23:27AM +0800, Nicolin Chen wrote:
> Document the device tree binding for the WM8962 codec, and modify the
> driver to extract platform data from the device tree, if present.
Applied, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-07 9:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-07 3:23 [PATCH V3] ASoC: WM8962: Add device tree binding Nicolin Chen
[not found] ` <1370575407-17712-1-git-send-email-b42378-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-06-07 9:35 ` Mark Brown
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).