[alsa-devel] [PATCH 1/2] ASoC: wm8985: add device tree binding for WM8985
Add device tree binding for the WM8985 codec driver.
Signed-off-by: Petr Kulhavy petr@barix.com --- Documentation/devicetree/bindings/sound/wm8985.txt | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/wm8985.txt
diff --git a/Documentation/devicetree/bindings/sound/wm8985.txt b/Documentation/devicetree/bindings/sound/wm8985.txt new file mode 100644 index 000000000000..788d64766257 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/wm8985.txt @@ -0,0 +1,36 @@ +Wolfson Microelectronics WM8985 and WM8758 audio codecs + +These devices support both I2C and SPI (configured with pin strapping +on the board). + +Required properties: + + - compatible : "wlf,wm8985" or "wlf,wm8758" + + - reg : the I2C address of the device for I2C, the chip select + number for SPI. + +Pins on the device for linking into audio routes: + + * LIN : left microphone pre-amp negative input + * LIP : left microphone pre-amp positive input + * RIN : right microphone pre-amp negative input + * RIP : right microphone pre-amp positive input + * L2 : left line input / secondary pre-amp positive input + * R2 : right line input / secondary pre-amp positive input + * AUXL : left auxiliary input (WM8985 only) + * AUXR : right auxiliary input (WM8985 only) + + * HPL : left headphone / line output (the LOUT1 pin) + * HPR : right headphone / line output (the ROUT1 pin) + * SPKL : left headphone / line output (the LOUT2 pin) + * SPKR : right headphone / line output (the ROUT2 pin) + * Mic Bias : microphone bias + + +Example: + +wm8758: audio-codec@1a { + compatible = "wlf,wm8758"; + reg = <0x1a>; +};
Add device-tree support to the WM8985 driver.
Signed-off-by: Petr Kulhavy petr@barix.com --- sound/soc/codecs/wm8985.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index bbf25a1ad51d..fa5b391c24bd 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c @@ -32,6 +32,7 @@ #include <sound/soc.h> #include <sound/initval.h> #include <sound/tlv.h> +#include <linux/of_device.h>
#include "wm8985.h"
@@ -1323,11 +1324,19 @@ static const struct wm8xxx_chip wm8758_chip = { .codec_dev = &soc_codec_dev_wm8758, };
+static const struct of_device_id wm8985_of_match[] = { + { .compatible = "wlf,wm8985", .data = &wm8985_chip}, + { .compatible = "wlf,wm8758", .data = &wm8758_chip}, + { } +}; +MODULE_DEVICE_TABLE(of, wm8985_of_match);
#if defined(CONFIG_SPI_MASTER) static int wm8985_spi_probe(struct spi_device *spi) { struct wm8985_priv *wm8985; + const struct wm8xxx_chip *chip; + const struct of_device_id *of_id; int ret;
wm8985 = devm_kzalloc(&spi->dev, sizeof *wm8985, GFP_KERNEL); @@ -1336,6 +1345,12 @@ static int wm8985_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8985);
+ of_id = of_match_device(wm8985_of_match, &spi->dev); + if (of_id) + chip = of_id->data; + else + chip = &wm8985_chip; + wm8985->regmap = devm_regmap_init_spi(spi, &wm8985_regmap); if (IS_ERR(wm8985->regmap)) { ret = PTR_ERR(wm8985->regmap); @@ -1345,7 +1360,7 @@ static int wm8985_spi_probe(struct spi_device *spi) }
ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8985, &wm8985_dai, 1); + chip->codec_dev, chip->dai, 1); return ret; }
@@ -1358,6 +1373,7 @@ static int wm8985_spi_remove(struct spi_device *spi) static struct spi_driver wm8985_spi_driver = { .driver = { .name = "wm8985", + .of_match_table = wm8985_of_match, }, .probe = wm8985_spi_probe, .remove = wm8985_spi_remove @@ -1369,7 +1385,8 @@ static int wm8985_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8985_priv *wm8985; - struct wm8xxx_chip *chip = (void *) id->driver_data; + const struct wm8xxx_chip *chip; + const struct of_device_id *of_id; int ret;
wm8985 = devm_kzalloc(&i2c->dev, sizeof *wm8985, GFP_KERNEL); @@ -1378,6 +1395,12 @@ static int wm8985_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8985);
+ of_id = of_match_device(wm8985_of_match, &i2c->dev); + if (of_id) + chip = of_id->data; + else + chip = (void *) id->driver_data; + wm8985->regmap = devm_regmap_init_i2c(i2c, &wm8985_regmap); if (IS_ERR(wm8985->regmap)) { ret = PTR_ERR(wm8985->regmap); @@ -1407,6 +1430,7 @@ MODULE_DEVICE_TABLE(i2c, wm8985_i2c_id); static struct i2c_driver wm8985_i2c_driver = { .driver = { .name = "wm8985", + .of_match_table = wm8985_of_match, }, .probe = wm8985_i2c_probe, .remove = wm8985_i2c_remove,
On Thu, May 12, 2016 at 05:58:49PM +0200, Petr Kulhavy wrote:
Add device tree binding for the WM8985 codec driver.
Signed-off-by: Petr Kulhavy petr@barix.com
Documentation/devicetree/bindings/sound/wm8985.txt | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/wm8985.txt
Acked-by: Rob Herring robh@kernel.org
participants (3)
-
Mark Brown
-
Petr Kulhavy
-
Rob Herring