All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support
@ 2016-02-02 14:31 Andreas Irestål
  2016-02-02 14:31 ` [PATCH 1/4] ASoC: adau17x1: Fix incorrect BCLK ratio definitions Andreas Irestål
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Andreas Irestål @ 2016-02-02 14:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: Andreas Irestål

This set of patches fixes some minor typos and adds DT support for the
adau17x1 codec drivers. I've only been able to test the 1761 part on
real hardware since I don't have any adau1781 hardware at the moment.

Currently, quite a lot of options are provided through the platform_data
struct, so it made sense parsing the DT and create a platform_data struct
from these parameters not to break anything. I've peeked at a few other
drivers and the TI tlv320aic31xx driver works this way as well.

Andreas Irestål (4):
  ASoC: adau17x1: Fix incorrect BCLK ratio definitions
  ASoc: adau17x1: Correct typos in file headers
  ASoC: adau17x1: Add basic DT support for adau17x1
  ASoC: adau17x1: Add option to provide platform data via DT

 .../devicetree/bindings/sound/adi,adau17x1.txt     |  54 +++++++++
 include/dt-bindings/sound/adau17x1.h               |  14 +++
 include/linux/platform_data/adau17x1.h             |   2 +-
 sound/soc/codecs/adau1761-i2c.c                    |  14 ++-
 sound/soc/codecs/adau1761-spi.c                    |  14 ++-
 sound/soc/codecs/adau1761.c                        | 133 ++++++++++++++++++++-
 sound/soc/codecs/adau1781-i2c.c                    |  10 ++
 sound/soc/codecs/adau1781-spi.c                    |  10 ++
 sound/soc/codecs/adau1781.c                        |  59 ++++++++-
 sound/soc/codecs/adau17x1.h                        |   6 +-
 10 files changed, 308 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/adi,adau17x1.txt
 create mode 100644 include/dt-bindings/sound/adau17x1.h

-- 
2.1.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] ASoC: adau17x1: Fix incorrect BCLK ratio definitions
  2016-02-02 14:31 [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Andreas Irestål
@ 2016-02-02 14:31 ` Andreas Irestål
  2016-02-24  4:15   ` Applied "ASoC: adau17x1: Fix incorrect BCLK ratio definitions" to the asoc tree Mark Brown
  2016-02-02 14:31 ` [PATCH 2/4] ASoc: adau17x1: Correct typos in file headers Andreas Irestål
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Andreas Irestål @ 2016-02-02 14:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: Andreas Irestål

Signed-off-by: Andreas Irestål <andire@axis.com>
---
 sound/soc/codecs/adau17x1.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/adau17x1.h b/sound/soc/codecs/adau17x1.h
index e13583e..5ae87a0 100644
--- a/sound/soc/codecs/adau17x1.h
+++ b/sound/soc/codecs/adau17x1.h
@@ -103,9 +103,9 @@ bool adau17x1_has_dsp(struct adau *adau);
 #define ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL	BIT(3)
 #define ADAU17X1_CLOCK_CONTROL_SYSCLK_EN	BIT(0)
 
-#define ADAU17X1_SERIAL_PORT1_BCLK32		(0x0 << 5)
-#define ADAU17X1_SERIAL_PORT1_BCLK48		(0x1 << 5)
-#define ADAU17X1_SERIAL_PORT1_BCLK64		(0x2 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK64		(0x0 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK32		(0x1 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK48		(0x2 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK128		(0x3 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK256		(0x4 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK_MASK		(0x7 << 5)
-- 
2.1.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] ASoc: adau17x1: Correct typos in file headers
  2016-02-02 14:31 [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Andreas Irestål
  2016-02-02 14:31 ` [PATCH 1/4] ASoC: adau17x1: Fix incorrect BCLK ratio definitions Andreas Irestål
@ 2016-02-02 14:31 ` Andreas Irestål
  2016-02-24  4:15   ` Applied "ASoC: adau17x1: Correct typos in file headers" to the asoc tree Mark Brown
  2016-02-02 14:31 ` [PATCH 3/4] ASoC: adau17x1: Add basic DT support for adau17x1 Andreas Irestål
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Andreas Irestål @ 2016-02-02 14:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: Andreas Irestål

Signed-off-by: Andreas Irestål <andire@axis.com>
---
 include/linux/platform_data/adau17x1.h | 2 +-
 sound/soc/codecs/adau1761-i2c.c        | 2 +-
 sound/soc/codecs/adau1761-spi.c        | 2 +-
 sound/soc/codecs/adau1761.c            | 2 +-
 sound/soc/codecs/adau1781.c            | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/platform_data/adau17x1.h b/include/linux/platform_data/adau17x1.h
index a81766c..9db1b90 100644
--- a/include/linux/platform_data/adau17x1.h
+++ b/include/linux/platform_data/adau17x1.h
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961/ADAU1781/ADAU1781 codecs
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961/ADAU1381/ADAU1781 codecs
  *
  * Copyright 2011-2014 Analog Devices Inc.
  * Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1761-i2c.c b/sound/soc/codecs/adau1761-i2c.c
index 348ccb1..a1b1267 100644
--- a/sound/soc/codecs/adau1761-i2c.c
+++ b/sound/soc/codecs/adau1761-i2c.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
  *
  * Copyright 2014 Analog Devices Inc.
  *  Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1761-spi.c b/sound/soc/codecs/adau1761-spi.c
index 8bc1fbd..1883349 100644
--- a/sound/soc/codecs/adau1761-spi.c
+++ b/sound/soc/codecs/adau1761-spi.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
  *
  * Copyright 2014 Analog Devices Inc.
  *  Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c
index 2f12477..16fed36 100644
--- a/sound/soc/codecs/adau1761.c
+++ b/sound/soc/codecs/adau1761.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
  *
  * Copyright 2011-2013 Analog Devices Inc.
  * Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1781.c b/sound/soc/codecs/adau1781.c
index fde9068..bc1bb56 100644
--- a/sound/soc/codecs/adau1781.c
+++ b/sound/soc/codecs/adau1781.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1781/ADAU1781 codec
+ * Driver for ADAU1381/ADAU1781 codec
  *
  * Copyright 2011-2013 Analog Devices Inc.
  * Author: Lars-Peter Clausen <lars@metafoo.de>
-- 
2.1.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] ASoC: adau17x1: Add basic DT support for adau17x1
  2016-02-02 14:31 [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Andreas Irestål
  2016-02-02 14:31 ` [PATCH 1/4] ASoC: adau17x1: Fix incorrect BCLK ratio definitions Andreas Irestål
  2016-02-02 14:31 ` [PATCH 2/4] ASoc: adau17x1: Correct typos in file headers Andreas Irestål
@ 2016-02-02 14:31 ` Andreas Irestål
  2016-02-02 14:31 ` [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT Andreas Irestål
  2016-02-04 20:54 ` [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Lars-Peter Clausen
  4 siblings, 0 replies; 9+ messages in thread
From: Andreas Irestål @ 2016-02-02 14:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: Andreas Irestål

Signed-off-by: Andreas Irestål <andire@axis.com>
---
 .../devicetree/bindings/sound/adi,adau17x1.txt      | 21 +++++++++++++++++++++
 sound/soc/codecs/adau1761-i2c.c                     | 12 ++++++++++++
 sound/soc/codecs/adau1761-spi.c                     | 12 ++++++++++++
 sound/soc/codecs/adau1781-i2c.c                     | 10 ++++++++++
 sound/soc/codecs/adau1781-spi.c                     | 10 ++++++++++
 5 files changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/adi,adau17x1.txt

diff --git a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
new file mode 100644
index 0000000..90f3ac3
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
@@ -0,0 +1,21 @@
+Analog Devices ADAU1361/ADAU1461/ADAU1761/ADAU1961/ADAU1381/ADAU1781
+
+Required properties:
+
+ - compatible:		Should contain one of the following:
+			"adi,adau1361"
+			"adi,adau1461"
+			"adi,adau1761"
+			"adi,adau1961"
+			"adi,adau1381"
+			"adi,adau1781"
+ - reg:			The i2c address. Value depends on the state of ADDR0
+			and ADDR1, as wired in hardware.
+
+Example:
+	i2c_bus {
+		adau1361@38 {
+			compatible = "adi,adau1361";
+			reg = <0x38>;
+		};
+	};
diff --git a/sound/soc/codecs/adau1761-i2c.c b/sound/soc/codecs/adau1761-i2c.c
index a1b1267..8de010f 100644
--- a/sound/soc/codecs/adau1761-i2c.c
+++ b/sound/soc/codecs/adau1761-i2c.c
@@ -44,9 +44,21 @@ static const struct i2c_device_id adau1761_i2c_ids[] = {
 };
 MODULE_DEVICE_TABLE(i2c, adau1761_i2c_ids);
 
+#if defined(CONFIG_OF)
+static const struct of_device_id adau1761_i2c_dt_ids[] = {
+	{ .compatible = "adi,adau1361", },
+	{ .compatible = "adi,adau1461", },
+	{ .compatible = "adi,adau1761", },
+	{ .compatible = "adi,adau1961", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adau1761_i2c_dt_ids);
+#endif
+
 static struct i2c_driver adau1761_i2c_driver = {
 	.driver = {
 		.name = "adau1761",
+		.of_match_table = of_match_ptr(adau1761_i2c_dt_ids),
 	},
 	.probe = adau1761_i2c_probe,
 	.remove = adau1761_i2c_remove,
diff --git a/sound/soc/codecs/adau1761-spi.c b/sound/soc/codecs/adau1761-spi.c
index 1883349..d917124 100644
--- a/sound/soc/codecs/adau1761-spi.c
+++ b/sound/soc/codecs/adau1761-spi.c
@@ -61,9 +61,21 @@ static const struct spi_device_id adau1761_spi_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, adau1761_spi_id);
 
+#if defined(CONFIG_OF)
+static const struct of_device_id adau1761_spi_dt_ids[] = {
+	{ .compatible = "adi,adau1361", },
+	{ .compatible = "adi,adau1461", },
+	{ .compatible = "adi,adau1761", },
+	{ .compatible = "adi,adau1961", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adau1761_spi_dt_ids);
+#endif
+
 static struct spi_driver adau1761_spi_driver = {
 	.driver = {
 		.name = "adau1761",
+		.of_match_table = of_match_ptr(adau1761_spi_dt_ids),
 	},
 	.probe = adau1761_spi_probe,
 	.remove = adau1761_spi_remove,
diff --git a/sound/soc/codecs/adau1781-i2c.c b/sound/soc/codecs/adau1781-i2c.c
index 0e32bba..06cbca8 100644
--- a/sound/soc/codecs/adau1781-i2c.c
+++ b/sound/soc/codecs/adau1781-i2c.c
@@ -42,9 +42,19 @@ static const struct i2c_device_id adau1781_i2c_ids[] = {
 };
 MODULE_DEVICE_TABLE(i2c, adau1781_i2c_ids);
 
+#if defined(CONFIG_OF)
+static const struct of_device_id adau1781_i2c_dt_ids[] = {
+	{ .compatible = "adi,adau1381", },
+	{ .compatible = "adi,adau1781", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adau1781_i2c_dt_ids);
+#endif
+
 static struct i2c_driver adau1781_i2c_driver = {
 	.driver = {
 		.name = "adau1781",
+		.of_match_table = of_match_ptr(adau1781_i2c_dt_ids),
 	},
 	.probe = adau1781_i2c_probe,
 	.remove = adau1781_i2c_remove,
diff --git a/sound/soc/codecs/adau1781-spi.c b/sound/soc/codecs/adau1781-spi.c
index 33a73ff..3d965a0 100644
--- a/sound/soc/codecs/adau1781-spi.c
+++ b/sound/soc/codecs/adau1781-spi.c
@@ -59,9 +59,19 @@ static const struct spi_device_id adau1781_spi_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, adau1781_spi_id);
 
+#if defined(CONFIG_OF)
+static const struct of_device_id adau1781_spi_dt_ids[] = {
+	{ .compatible = "adi,adau1381", },
+	{ .compatible = "adi,adau1781", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adau1781_spi_dt_ids);
+#endif
+
 static struct spi_driver adau1781_spi_driver = {
 	.driver = {
 		.name = "adau1781",
+		.of_match_table = of_match_ptr(adau1781_spi_dt_ids),
 	},
 	.probe = adau1781_spi_probe,
 	.remove = adau1781_spi_remove,
-- 
2.1.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT
  2016-02-02 14:31 [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Andreas Irestål
                   ` (2 preceding siblings ...)
  2016-02-02 14:31 ` [PATCH 3/4] ASoC: adau17x1: Add basic DT support for adau17x1 Andreas Irestål
@ 2016-02-02 14:31 ` Andreas Irestål
  2016-02-04 21:01   ` Lars-Peter Clausen
  2016-02-04 20:54 ` [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Lars-Peter Clausen
  4 siblings, 1 reply; 9+ messages in thread
From: Andreas Irestål @ 2016-02-02 14:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: Andreas Irestål

Signed-off-by: Andreas Irestål <andire@axis.com>
---
 .../devicetree/bindings/sound/adi,adau17x1.txt     |  33 ++++++
 include/dt-bindings/sound/adau17x1.h               |  14 +++
 sound/soc/codecs/adau1761.c                        | 131 +++++++++++++++++++++
 sound/soc/codecs/adau1781.c                        |  57 +++++++++
 4 files changed, 235 insertions(+)
 create mode 100644 include/dt-bindings/sound/adau17x1.h

diff --git a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
index 90f3ac3..296b417 100644
--- a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
+++ b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
@@ -12,10 +12,43 @@ Required properties:
  - reg:			The i2c address. Value depends on the state of ADDR0
 			and ADDR1, as wired in hardware.
 
+Optional properties:
+
+ - input-differential	bool to set if the input is differential
+ - digital-microphone	bool to set if there is a digital microphone connected
+			to the digmic/jackdet pin.
+ - micbias-vg		Microphone bias voltage
+	MICBIAS_0_90_AVDD - 0.9 * AVDD
+	MICBIAS_0_65_AVDD - 0.65 * AVDD
+
+Optional properties (ADAU1361/ADAU1461/ADAU1761/ADAU1961 only)
+
+ - jack-detection	If present, configures codec to use the digmic/jackdet
+			pin for jack detection. must provide one of
+			JACKDETECT_ACTIVE_LO or JACKDETECT_ACTIVE_HI followed
+			by debounce time in ms, which must be 5, 10, 20, or 40.
+
+ - lineout-mode		Set output mode of the lineout pins.
+ - headphone-mode	Set output mode of the headphone pins.
+
+The output mode must be one of:
+	OUTPUT_MODE_HEADPHONE           - Headphone output
+	OUTPUT_MODE_HEADPHONE_CAPLESS   - Capless headphone output
+	OUTPUT_MODE_LINE                - Line output
+
+
+
 Example:
+#include <dt-bindings/sound/adau17x1.h>
+
 	i2c_bus {
 		adau1361@38 {
 			compatible = "adi,adau1361";
 			reg = <0x38>;
+			input-differential;
+			jack-detection = <JACKDETECT_ACTIVE_LO 40>;
+			lineout-mode = <OUTPUT_MODE_LINE>;
+			headphone-mode = <OUTPUT_MODE_HEADPHONE>;
+			micbias-vg = <MICBIAS_0_90_AVDD>;
 		};
 	};
diff --git a/include/dt-bindings/sound/adau17x1.h b/include/dt-bindings/sound/adau17x1.h
new file mode 100644
index 0000000..3152019
--- /dev/null
+++ b/include/dt-bindings/sound/adau17x1.h
@@ -0,0 +1,14 @@
+#ifndef __DT_ADAU17X1_H
+#define __DT_ADAU17X1_H
+
+#define MICBIAS_0_90_AVDD		0
+#define MICBIAS_0_65_AVDD		1
+
+#define OUTPUT_MODE_HEADPHONE		0
+#define OUTPUT_MODE_HEADPHONE_CAPLESS	1
+#define OUTPUT_MODE_LINE		2
+
+#define JACKDETECT_ACTIVE_HI		0
+#define JACKDETECT_ACTIVE_LO		1
+
+#endif
diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c
index 16fed36..22106b2 100644
--- a/sound/soc/codecs/adau1761.c
+++ b/sound/soc/codecs/adau1761.c
@@ -18,6 +18,7 @@
 #include <sound/soc.h>
 #include <sound/tlv.h>
 #include <linux/platform_data/adau17x1.h>
+#include <dt-bindings/sound/adau17x1.h>
 
 #include "adau17x1.h"
 #include "adau1761.h"
@@ -636,13 +637,143 @@ static bool adau1761_readable_register(struct device *dev, unsigned int reg)
 	return adau17x1_readable_register(dev, reg);
 }
 
+#ifdef CONFIG_OF
+static inline void adau1761_parse_of_outmode(struct snd_soc_codec *codec,
+					    uint32_t of_val,
+					    enum adau1761_output_mode *mode)
+{
+	switch (of_val) {
+	case OUTPUT_MODE_HEADPHONE:
+		*mode = ADAU1761_OUTPUT_MODE_HEADPHONE;
+		break;
+	case OUTPUT_MODE_HEADPHONE_CAPLESS:
+		*mode = ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS;
+		break;
+	case OUTPUT_MODE_LINE:
+		*mode = ADAU1761_OUTPUT_MODE_LINE;
+		break;
+	default:
+		dev_warn(codec->dev, "Invalid output mode %d\n", of_val);
+		*mode = ADAU1761_OUTPUT_MODE_LINE;
+		break;
+	}
+}
+
+static void adau1761_pdata_from_of(struct snd_soc_codec *codec,
+				   struct adau1761_platform_data *pdata)
+{
+	struct device_node *np = codec->dev->of_node;
+	uint32_t val;
+	uint32_t debounce_pars[2];
+
+	if (of_get_property(np, "input-differential", NULL))
+		pdata->input_differential = 1;
+	else
+		pdata->input_differential = 0;
+
+	if (of_get_property(np, "jack-detection", NULL)) {
+		pdata->digmic_jackdetect_pin_mode =
+			ADAU1761_DIGMIC_JACKDET_PIN_MODE_JACKDETECT;
+		if (!of_property_read_u32_array(np, "jack-detection",
+						debounce_pars, 2)) {
+			pdata->jackdetect_active_low =
+				debounce_pars[0] == JACKDETECT_ACTIVE_LO;
+			switch (debounce_pars[1]) {
+			case 5:
+				pdata->jackdetect_debounce_time =
+					ADAU1761_JACKDETECT_DEBOUNCE_5MS;
+				break;
+			case 10:
+				pdata->jackdetect_debounce_time =
+					ADAU1761_JACKDETECT_DEBOUNCE_10MS;
+				break;
+			case 20:
+				pdata->jackdetect_debounce_time =
+					ADAU1761_JACKDETECT_DEBOUNCE_20MS;
+				break;
+			case 40:
+				pdata->jackdetect_debounce_time =
+					ADAU1761_JACKDETECT_DEBOUNCE_40MS;
+				break;
+			default:
+				dev_warn(codec->dev, "Invalid debounce_time %d\n",
+					debounce_pars[1]);
+				pdata->jackdetect_debounce_time =
+					ADAU1761_JACKDETECT_DEBOUNCE_40MS;
+				break;
+			}
+		} else if (!of_property_read_u32_array(np, "jack-detection",
+						debounce_pars, 1)) {
+			dev_warn(codec->dev, "Debounce time not provided\n");
+			pdata->jackdetect_active_low =
+				debounce_pars[0] == JACKDETECT_ACTIVE_LO;
+		} else {
+			dev_warn(codec->dev, "No jack detection settings found\n");
+			pdata->jackdetect_active_low = 0;
+			pdata->jackdetect_debounce_time =
+				ADAU1761_JACKDETECT_DEBOUNCE_40MS;
+		}
+	} else if (of_get_property(np, "digital-microphone", NULL)) {
+		pdata->digmic_jackdetect_pin_mode =
+			ADAU1761_DIGMIC_JACKDET_PIN_MODE_DIGMIC;
+	} else {
+		pdata->digmic_jackdetect_pin_mode =
+			ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE;
+	}
+
+	if (!of_property_read_u32(np, "headphone-mode", &val))
+		adau1761_parse_of_outmode(codec, val, &pdata->headphone_mode);
+	else
+		pdata->headphone_mode = ADAU1761_OUTPUT_MODE_LINE;
+
+	if (!of_property_read_u32(np, "lineout-mode", &val))
+		adau1761_parse_of_outmode(codec, val, &pdata->lineout_mode);
+	else
+		pdata->lineout_mode = ADAU1761_OUTPUT_MODE_LINE;
+
+	if (!of_property_read_u32(np, "micbias-vg", &val)) {
+		switch (val) {
+		case MICBIAS_0_65_AVDD:
+			pdata->micbias_voltage = ADAU17X1_MICBIAS_0_65_AVDD;
+			break;
+		case MICBIAS_0_90_AVDD:
+			pdata->micbias_voltage = ADAU17X1_MICBIAS_0_90_AVDD;
+			break;
+		default:
+			dev_warn(codec->dev, "Invalid micbias voltage setting\n");
+			pdata->micbias_voltage = ADAU17X1_MICBIAS_0_90_AVDD;
+			break;
+		}
+	} else {
+		pdata->micbias_voltage = ADAU17X1_MICBIAS_0_90_AVDD;
+	}
+}
+#else
+static void adau1761_pdata_from_of(struct snd_soc_codec *codec,
+				   struct adau1761_platform_data *pdata)
+{
+}
+#endif
+
 static int adau1761_codec_probe(struct snd_soc_codec *codec)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
 	struct adau1761_platform_data *pdata = codec->dev->platform_data;
 	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+	struct device_node *np = codec->dev->of_node;
+	struct adau1761_platform_data *of_pdata;
 	int ret;
 
+	if (!pdata && np && of_device_is_available(np)) {
+		of_pdata = devm_kzalloc(codec->dev, sizeof(*of_pdata), 
+			GFP_KERNEL);
+		if (!of_pdata)
+			return -ENOMEM;
+		adau1761_pdata_from_of(codec, of_pdata);
+		pdata = of_pdata;
+		codec->dev->platform_data = pdata;
+	}
+
 	ret = adau17x1_add_widgets(codec);
 	if (ret < 0)
 		return ret;
diff --git a/sound/soc/codecs/adau1781.c b/sound/soc/codecs/adau1781.c
index bc1bb56..b207911 100644
--- a/sound/soc/codecs/adau1781.c
+++ b/sound/soc/codecs/adau1781.c
@@ -18,6 +18,7 @@
 #include <sound/soc.h>
 #include <sound/tlv.h>
 #include <linux/platform_data/adau17x1.h>
+#include <dt-bindings/sound/adau17x1.h>
 
 #include "adau17x1.h"
 #include "adau1781.h"
@@ -380,13 +381,69 @@ static int adau1781_set_input_mode(struct adau *adau, unsigned int reg,
 		ADAU1781_INPUT_DIFFERNTIAL, val);
 }
 
+#ifdef CONFIG_OF
+static void adau1781_pdata_from_of(struct snd_soc_codec *codec,
+				   struct adau1781_platform_data *pdata)
+{
+	struct device_node *np = codec->dev->of_node;
+	uint32_t val;
+
+	if (of_get_property(np, "input-differential", NULL)) {
+		pdata->left_input_differential = 1;
+		pdata->right_input_differential = 1;
+	} else {
+		pdata->left_input_differential = 0;
+		pdata->right_input_differential = 0;
+	}
+
+	if (of_get_property(np, "digital-microphone", NULL))
+		pdata->use_dmic = 1;
+	else
+		pdata->use_dmic = 0;
+
+	if (!of_property_read_u32(np, "micbias-vg", &val)) {
+		switch (val) {
+		case MICBIAS_0_65_AVDD:
+			pdata->micbias_voltage = ADAU17X1_MICBIAS_0_65_AVDD;
+			break;
+		case MICBIAS_0_90_AVDD:
+			pdata->micbias_voltage = ADAU17X1_MICBIAS_0_90_AVDD;
+			break;
+		default:
+			dev_warn(codec->dev, "Invalid micbias voltage setting\n");
+			pdata->micbias_voltage = ADAU17X1_MICBIAS_0_90_AVDD;
+			break;
+		}
+	} else {
+		pdata->micbias_voltage = ADAU17X1_MICBIAS_0_90_AVDD;
+	}
+}
+#else
+static void adau1781_pdata_from_of(struct snd_soc_codec *codec,
+				   struct adau1781_platform_data *pdata)
+{
+}
+#endif
+
 static int adau1781_codec_probe(struct snd_soc_codec *codec)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
 	struct adau1781_platform_data *pdata = dev_get_platdata(codec->dev);
 	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+	struct device_node *np = codec->dev->of_node;
+	struct adau1781_platform_data *of_pdata;
 	int ret;
 
+	if (!pdata && np && of_device_is_available(np)) {
+		of_pdata = devm_kzalloc(codec->dev, sizeof(*of_pdata),
+			GFP_KERNEL);
+		if (!of_pdata)
+			return -ENOMEM;
+		adau1781_pdata_from_of(codec, of_pdata);
+		pdata = of_pdata;
+		codec->dev->platform_data = pdata;
+	}
+
 	ret = adau17x1_add_widgets(codec);
 	if (ret)
 		return ret;
-- 
2.1.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support
  2016-02-02 14:31 [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Andreas Irestål
                   ` (3 preceding siblings ...)
  2016-02-02 14:31 ` [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT Andreas Irestål
@ 2016-02-04 20:54 ` Lars-Peter Clausen
  4 siblings, 0 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2016-02-04 20:54 UTC (permalink / raw)
  To: Andreas Irestål, alsa-devel; +Cc: Andreas Irestål

On 02/02/2016 03:31 PM, Andreas Irestål wrote:
> This set of patches fixes some minor typos and adds DT support for the
> adau17x1 codec drivers. I've only been able to test the 1761 part on
> real hardware since I don't have any adau1781 hardware at the moment.
> 
> Currently, quite a lot of options are provided through the platform_data
> struct, so it made sense parsing the DT and create a platform_data struct
> from these parameters not to break anything. I've peeked at a few other
> drivers and the TI tlv320aic31xx driver works this way as well.

Hi,

Thanks for the patches. The first 3 patches look good. You can add a

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

when you resend with the maintainers on Cc.

- Lars

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT
  2016-02-02 14:31 ` [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT Andreas Irestål
@ 2016-02-04 21:01   ` Lars-Peter Clausen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2016-02-04 21:01 UTC (permalink / raw)
  To: Andreas Irestål, alsa-devel; +Cc: Andreas Irestål

At least a bit of commit message would be nice.

On 02/02/2016 03:31 PM, Andreas Irestål wrote:
> Signed-off-by: Andreas Irestål <andire@axis.com>
> ---
>  .../devicetree/bindings/sound/adi,adau17x1.txt     |  33 ++++++
>  include/dt-bindings/sound/adau17x1.h               |  14 +++
>  sound/soc/codecs/adau1761.c                        | 131 +++++++++++++++++++++
>  sound/soc/codecs/adau1781.c                        |  57 +++++++++
>  4 files changed, 235 insertions(+)
>  create mode 100644 include/dt-bindings/sound/adau17x1.h
> 
> diff --git a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
> index 90f3ac3..296b417 100644
> --- a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
> +++ b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
> @@ -12,10 +12,43 @@ Required properties:
>   - reg:			The i2c address. Value depends on the state of ADDR0
>  			and ADDR1, as wired in hardware.
>  
> +Optional properties:
> +
> + - input-differential	bool to set if the input is differential
> + - digital-microphone	bool to set if there is a digital microphone connected
> +			to the digmic/jackdet pin.
> + - micbias-vg		Microphone bias voltage
> +	MICBIAS_0_90_AVDD - 0.9 * AVDD
> +	MICBIAS_0_65_AVDD - 0.65 * AVDD
> +
> +Optional properties (ADAU1361/ADAU1461/ADAU1761/ADAU1961 only)
> +
> + - jack-detection	If present, configures codec to use the digmic/jackdet
> +			pin for jack detection. must provide one of
> +			JACKDETECT_ACTIVE_LO or JACKDETECT_ACTIVE_HI followed
> +			by debounce time in ms, which must be 5, 10, 20, or 40.
> +
> + - lineout-mode		Set output mode of the lineout pins.
> + - headphone-mode	Set output mode of the headphone pins.

These properties all need a vendor prefix ("adi,").

[...]
> +
> +static void adau1761_pdata_from_of(struct snd_soc_codec *codec,
> +				   struct adau1761_platform_data *pdata)
> +{
> +	struct device_node *np = codec->dev->of_node;
> +	uint32_t val;
> +	uint32_t debounce_pars[2];
> +
> +	if (of_get_property(np, "input-differential", NULL))

There is a helper function for this of_property_read_bool().

> +		pdata->input_differential = 1;
> +	else
> +		pdata->input_differential = 0;
> +
[...]
> +
>  static int adau1761_codec_probe(struct snd_soc_codec *codec)
>  {
>  	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
>  	struct adau1761_platform_data *pdata = codec->dev->platform_data;
>  	struct adau *adau = snd_soc_codec_get_drvdata(codec);
> +	struct device_node *np = codec->dev->of_node;
> +	struct adau1761_platform_data *of_pdata;
>  	int ret;
>  
> +	if (!pdata && np && of_device_is_available(np)) {
> +		of_pdata = devm_kzalloc(codec->dev, sizeof(*of_pdata), 
> +			GFP_KERNEL);
> +		if (!of_pdata)
> +			return -ENOMEM;
> +		adau1761_pdata_from_of(codec, of_pdata);
> +		pdata = of_pdata;
> +		codec->dev->platform_data = pdata;

The parsing should be done in the main probe function. This will make sure
that we propagate errors up the stack the right way.

> +	}


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Applied "ASoC: adau17x1: Correct typos in file headers" to the asoc tree
  2016-02-02 14:31 ` [PATCH 2/4] ASoc: adau17x1: Correct typos in file headers Andreas Irestål
@ 2016-02-24  4:15   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-02-24  4:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 3784 bytes --]

The patch

   ASoC: adau17x1: Correct typos in file headers

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From d6dde63e90cf0d34ae61e885a5eb254c59eb3358 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Irest=C3=A5l?= <andreas.irestal@axis.com>
Date: Tue, 16 Feb 2016 13:56:42 +0100
Subject: [PATCH] ASoC: adau17x1: Correct typos in file headers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Andreas Irestål <andire@axis.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/linux/platform_data/adau17x1.h | 2 +-
 sound/soc/codecs/adau1761-i2c.c        | 2 +-
 sound/soc/codecs/adau1761-spi.c        | 2 +-
 sound/soc/codecs/adau1761.c            | 2 +-
 sound/soc/codecs/adau1781.c            | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/platform_data/adau17x1.h b/include/linux/platform_data/adau17x1.h
index a81766cae230..9db1b905df24 100644
--- a/include/linux/platform_data/adau17x1.h
+++ b/include/linux/platform_data/adau17x1.h
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961/ADAU1781/ADAU1781 codecs
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961/ADAU1381/ADAU1781 codecs
  *
  * Copyright 2011-2014 Analog Devices Inc.
  * Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1761-i2c.c b/sound/soc/codecs/adau1761-i2c.c
index 348ccb17d3cc..a1b12671c307 100644
--- a/sound/soc/codecs/adau1761-i2c.c
+++ b/sound/soc/codecs/adau1761-i2c.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
  *
  * Copyright 2014 Analog Devices Inc.
  *  Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1761-spi.c b/sound/soc/codecs/adau1761-spi.c
index 8bc1fbd25fcc..188334928c23 100644
--- a/sound/soc/codecs/adau1761-spi.c
+++ b/sound/soc/codecs/adau1761-spi.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
  *
  * Copyright 2014 Analog Devices Inc.
  *  Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c
index e7136b1956a3..b95d29dbd13d 100644
--- a/sound/soc/codecs/adau1761.c
+++ b/sound/soc/codecs/adau1761.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec
+ * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
  *
  * Copyright 2011-2013 Analog Devices Inc.
  * Author: Lars-Peter Clausen <lars@metafoo.de>
diff --git a/sound/soc/codecs/adau1781.c b/sound/soc/codecs/adau1781.c
index fde9068550a6..bc1bb56dae63 100644
--- a/sound/soc/codecs/adau1781.c
+++ b/sound/soc/codecs/adau1781.c
@@ -1,5 +1,5 @@
 /*
- * Driver for ADAU1781/ADAU1781 codec
+ * Driver for ADAU1381/ADAU1781 codec
  *
  * Copyright 2011-2013 Analog Devices Inc.
  * Author: Lars-Peter Clausen <lars@metafoo.de>
-- 
2.7.0


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Applied "ASoC: adau17x1: Fix incorrect BCLK ratio definitions" to the asoc tree
  2016-02-02 14:31 ` [PATCH 1/4] ASoC: adau17x1: Fix incorrect BCLK ratio definitions Andreas Irestål
@ 2016-02-24  4:15   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-02-24  4:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 2284 bytes --]

The patch

   ASoC: adau17x1: Fix incorrect BCLK ratio definitions

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 7c139db2e579669c3313f92d2dd2256b255fcc07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Irest=C3=A5l?= <andreas.irestal@axis.com>
Date: Tue, 16 Feb 2016 13:56:41 +0100
Subject: [PATCH] ASoC: adau17x1: Fix incorrect BCLK ratio definitions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Andreas Irestål <andire@axis.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/adau17x1.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/adau17x1.h b/sound/soc/codecs/adau17x1.h
index e13583e6ff56..5ae87a084d97 100644
--- a/sound/soc/codecs/adau17x1.h
+++ b/sound/soc/codecs/adau17x1.h
@@ -103,9 +103,9 @@ bool adau17x1_has_dsp(struct adau *adau);
 #define ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL	BIT(3)
 #define ADAU17X1_CLOCK_CONTROL_SYSCLK_EN	BIT(0)
 
-#define ADAU17X1_SERIAL_PORT1_BCLK32		(0x0 << 5)
-#define ADAU17X1_SERIAL_PORT1_BCLK48		(0x1 << 5)
-#define ADAU17X1_SERIAL_PORT1_BCLK64		(0x2 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK64		(0x0 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK32		(0x1 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK48		(0x2 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK128		(0x3 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK256		(0x4 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK_MASK		(0x7 << 5)
-- 
2.7.0


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-02-24  4:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 14:31 [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Andreas Irestål
2016-02-02 14:31 ` [PATCH 1/4] ASoC: adau17x1: Fix incorrect BCLK ratio definitions Andreas Irestål
2016-02-24  4:15   ` Applied "ASoC: adau17x1: Fix incorrect BCLK ratio definitions" to the asoc tree Mark Brown
2016-02-02 14:31 ` [PATCH 2/4] ASoc: adau17x1: Correct typos in file headers Andreas Irestål
2016-02-24  4:15   ` Applied "ASoC: adau17x1: Correct typos in file headers" to the asoc tree Mark Brown
2016-02-02 14:31 ` [PATCH 3/4] ASoC: adau17x1: Add basic DT support for adau17x1 Andreas Irestål
2016-02-02 14:31 ` [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT Andreas Irestål
2016-02-04 21:01   ` Lars-Peter Clausen
2016-02-04 20:54 ` [PATCH 0/4] ASoC: adau17x1: Minor fixes and DT support Lars-Peter Clausen

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.