LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table
@ 2015-01-27 3:36 Bo Shen
2015-01-27 3:36 ` [PATCH v3 2/2] binding: wm8904: add new compatible string Bo Shen
2015-01-28 19:31 ` [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Bo Shen @ 2015-01-27 3:36 UTC (permalink / raw)
To: Mark Brown, nicolas.ferre
Cc: linux-arm-kernel, linux-kernel, devicetree, alsa-devel,
linux-sound, Alexander Morozov, Bo Shen
From: Alexander Morozov <linux@meltdown.ru>
The WM8904 and WM8918 has the same data type, while the WM8912
has different data type. So, use the data in dt ids table to
distinguish them.
Signed-off-by: Alexander Morozov <linux@meltdown.ru>
[voice.shen@atmel.com: add code to distinguish device type]
Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
Changes in v3:
- Get the device type from match data in probe function.
Changes in v2:
- Add driver data for distinguish the device capability.
sound/soc/codecs/wm8904.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 4d2d2b1..a80bc52 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -2098,6 +2098,24 @@ static const struct regmap_config wm8904_regmap = {
.num_reg_defaults = ARRAY_SIZE(wm8904_reg_defaults),
};
+#ifdef CONFIG_OF
+static enum wm8904_type wm8904_data = WM8904;
+static enum wm8904_type wm8912_data = WM8912;
+
+static const struct of_device_id wm8904_of_match[] = {
+ {
+ .compatible = "wlf,wm8904",
+ .data = &wm8904_data,
+ }, {
+ .compatible = "wlf,wm8912",
+ .data = &wm8912_data,
+ }, {
+ /* sentinel */
+ }
+};
+MODULE_DEVICE_TABLE(of, wm8904_of_match);
+#endif
+
static int wm8904_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
@@ -2125,7 +2143,17 @@ static int wm8904_i2c_probe(struct i2c_client *i2c,
return ret;
}
- wm8904->devtype = id->driver_data;
+ if (i2c->dev.of_node) {
+ const struct of_device_id *match;
+
+ match = of_match_node(wm8904_of_match, i2c->dev.of_node);
+ if (match == NULL)
+ return -EINVAL;
+ wm8904->devtype = *((enum wm8904_type *)match->data);
+ } else {
+ wm8904->devtype = id->driver_data;
+ }
+
i2c_set_clientdata(i2c, wm8904);
wm8904->pdata = i2c->dev.platform_data;
@@ -2259,6 +2287,7 @@ static struct i2c_driver wm8904_i2c_driver = {
.driver = {
.name = "wm8904",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(wm8904_of_match),
},
.probe = wm8904_i2c_probe,
.remove = wm8904_i2c_remove,
--
2.3.0.rc0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 2/2] binding: wm8904: add new compatible string
2015-01-27 3:36 [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table Bo Shen
@ 2015-01-27 3:36 ` Bo Shen
2015-01-28 19:31 ` [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Bo Shen @ 2015-01-27 3:36 UTC (permalink / raw)
To: Mark Brown, nicolas.ferre
Cc: linux-arm-kernel, linux-kernel, devicetree, alsa-devel,
linux-sound, Bo Shen
The "wlf,wm8912" compatible string is used for wm8912, which
share driver with wm8904, however, the data type is different.
Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
Changes in v3: None
Changes in v2: None
Documentation/devicetree/bindings/sound/wm8904.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/wm8904.txt b/Documentation/devicetree/bindings/sound/wm8904.txt
index e99f409..66bf261 100644
--- a/Documentation/devicetree/bindings/sound/wm8904.txt
+++ b/Documentation/devicetree/bindings/sound/wm8904.txt
@@ -3,7 +3,7 @@ WM8904 audio CODEC
This device supports I2C only.
Required properties:
- - compatible: "wlf,wm8904"
+ - compatible: "wlf,wm8904" or "wlf,wm8912"
- reg: the I2C address of the device.
- clock-names: "mclk"
- clocks: reference to
--
2.3.0.rc0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table
2015-01-27 3:36 [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table Bo Shen
2015-01-27 3:36 ` [PATCH v3 2/2] binding: wm8904: add new compatible string Bo Shen
@ 2015-01-28 19:31 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2015-01-28 19:31 UTC (permalink / raw)
To: Bo Shen
Cc: nicolas.ferre, linux-arm-kernel, linux-kernel, devicetree,
alsa-devel, linux-sound, Alexander Morozov
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
On Tue, Jan 27, 2015 at 11:36:39AM +0800, Bo Shen wrote:
> From: Alexander Morozov <linux@meltdown.ru>
>
> The WM8904 and WM8918 has the same data type, while the WM8912
> has different data type. So, use the data in dt ids table to
> distinguish them.
Applied both, thanks - please use subjct lines matching the style for
the subsystem and CC maintainers (including driver maintainers).
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-29 1:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 3:36 [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table Bo Shen
2015-01-27 3:36 ` [PATCH v3 2/2] binding: wm8904: add new compatible string Bo Shen
2015-01-28 19:31 ` [PATCH v3 1/2] ASoC: codecs: wm8904: add dt ids table 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).