Skip to contentSkip to conversation

ASoC: rt5514: Add devicetree binding support for rt5514-spi

PATCH In review Jeffy Chen 2 participants 4 messages Sep 19, 2017

Subsystems (4)
lore
Share & tools
lore

Jeffy Chen

author
#0 lore raw

PATCH v12 1/2 ASoC: rt5514: Add devicetree binding support for rt5514-spi

Add devicetree binding support for rt5514 spi dsp codec.

---

Changes in v12: None
Changes in v11:
Use same compatible for rt5514-i2c & rt5514-spi.

Changes in v10:
Put rt5514-i2c doc & rt5514-spi doc together.

Changes in v9:
Address comments from Brian.

 Documentation/devicetree/bindings/sound/rt5514.txt | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/sound/rt5514.txt +9 -4
index 929ca6756b02..4f33b0d96afe 100644
@@ -1,22 +1,27 @@
 RT5514 audio CODEC
 
-This device supports I2C only.
+This device supports both I2C and SPI.
 
 Required properties:
 
 - compatible : "realtek,rt5514".
 
-- reg : The I2C address of the device.
+- reg : the I2C address of the device for I2C, the chip select
+        number for SPI.
 
 Optional properties:
 
 - clocks: The phandle of the master clock to the CODEC
 - clock-names: Should be "mclk"
 
+- interrupt-parent: The phandle for the interrupt controller.
+- interrupts: The interrupt number to the cpu. The interrupt specifier format
+	      depends on the interrupt controller.
+
 - realtek,dmic-init-delay-ms
-  Set the DMIC initial delay (ms) to wait it ready.
+  Set the DMIC initial delay (ms) to wait it ready for I2C.
 
-Pins on the device (for linking into audio routes) for RT5514:
+Pins on the device (for linking into audio routes) for I2C:
 
   * DMIC1L
   * DMIC1R
Signature · 1 line
2.11.0
author
#1 lore raw

PATCH v12 2/2 ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec

Currently rt5514 dsp and rt5514 codec are sharing the same compatible. Use bus_type to distinguish rt5514 dsp from rt5514 codec.

---

Changes in v12:
Fix device leak.

Changes in v11: None
Changes in v10: None
Changes in v9: None

 sound/soc/rockchip/rk3399_gru_sound.c | 61 ++++++++++++++++++++++++++++-------
 1 file changed, 49 insertions(+), 12 deletions(-)
sound/soc/rockchip/rk3399_gru_sound.c +49 -12
index 0513fe480353..b7759f3d2aac 100644
@@ -23,6 +23,7 @@
 #include <linux/of_gpio.h>
 #include <linux/delay.h>
 #include <linux/spi/spi.h>
+#include <linux/i2c.h>
 #include <linux/input.h>
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -329,15 +330,6 @@ enum {
 	DAILINK_RT5514_DSP,
 };
 
-static const char * const dailink_compat[] = {
-	[DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp",
-	[DAILINK_DA7219] = "dlg,da7219",
-	[DAILINK_DMIC] = "dmic-codec",
-	[DAILINK_MAX98357A] = "maxim,max98357a",
-	[DAILINK_RT5514] = "realtek,rt5514-i2c",
-	[DAILINK_RT5514_DSP] = "realtek,rt5514-spi",
-};
-
 static const struct snd_soc_dai_link rockchip_dais[] = {
 	[DAILINK_CDNDP] = {
 		.name = "DP",
@@ -391,13 +383,58 @@ static const struct snd_soc_dai_link rockchip_dais[] = {
 	},
 };
 
+struct dailink_match_data {
+	const char *compatible;
+	struct bus_type *bus_type;
+};
+
+static const struct dailink_match_data dailink_match[] = {
+	[DAILINK_CDNDP] = {
+		.compatible = "rockchip,rk3399-cdn-dp",
+	},
+	[DAILINK_DA7219] = {
+		.compatible = "dlg,da7219",
+	},
+	[DAILINK_DMIC] = {
+		.compatible = "dmic-codec",
+	},
+	[DAILINK_MAX98357A] = {
+		.compatible = "maxim,max98357a",
+	},
+	[DAILINK_RT5514] = {
+		.compatible = "realtek,rt5514",
+		.bus_type = &i2c_bus_type,
+	},
+	[DAILINK_RT5514_DSP] = {
+		.compatible = "realtek,rt5514",
+		.bus_type = &spi_bus_type,
+	},
+};
+
+static int of_dev_node_match(struct device *dev, void *data)
+{
+	return dev->of_node == data;
+}
+
 static int rockchip_sound_codec_node_match(struct device_node *np_codec)
 {
+	struct device *dev;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(dailink_compat); i++) {
-		if (of_device_is_compatible(np_codec, dailink_compat[i]))
-			return i;
+	for (i = 0; i < ARRAY_SIZE(dailink_match); i++) {
+		if (!of_device_is_compatible(np_codec,
+					     dailink_match[i].compatible))
+			continue;
+
+		if (dailink_match[i].bus_type) {
+			dev = bus_find_device(dailink_match[i].bus_type, NULL,
+					      np_codec, of_dev_node_match);
+			if (!dev)
+				continue;
+			put_device(dev);
+		}
+
+		return i;
 	}
 	return -1;
 }
Signature · 1 line
2.11.0
maintainer
#2 lore raw

Re: [PATCH v12 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec

Quoted 2 lines · Jeffy Chen

Currently rt5514 dsp and rt5514 codec are sharing the same compatible. Use bus_type to distinguish rt5514 dsp from rt5514 codec.

This doens't apply against current code, please check and resend.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170919/d78ab1f9/attachment.sig>

author
#3 lore raw

Re: [PATCH v12 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec

Hi Mark,

Quoted 6 lines · Mark Brown
Quoted 2 lines · Jeffy Chen

Currently rt5514 dsp and rt5514 codec are sharing the same compatible. Use bus_type to distinguish rt5514 dsp from rt5514 codec.

This doens't apply against current code, please check and resend.

i sent a new series which contains all my patches and base on 840cc455c5f5 Add linux-next specific files for 20170919

please help to check, thanks :)

https://py3.patchwork.dja.id.au/patch/66384/
...
https://py3.patchwork.dja.id.au/patch/66389/