alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v11 1/2] ASoC: rt5514: Add devicetree binding support for rt5514-spi
@ 2017-09-18 11:14 Jeffy Chen
  2017-09-18 11:14 ` [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec Jeffy Chen
  2017-09-19 13:46 ` Applied "ASoC: rt5514: Add devicetree binding support for rt5514-spi" to the asoc tree Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Jeffy Chen @ 2017-09-18 11:14 UTC (permalink / raw)
  To: linux-kernel, dgreid, heiko
  Cc: briannorris, broonie, mka, dianders, Jeffy Chen, devicetree,
	alsa-devel, Liam Girdwood, Rob Herring, Mark Rutland

Add devicetree binding support for rt5514 spi dsp codec.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

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(-)

diff --git a/Documentation/devicetree/bindings/sound/rt5514.txt b/Documentation/devicetree/bindings/sound/rt5514.txt
index 929ca6756b02..4f33b0d96afe 100644
--- a/Documentation/devicetree/bindings/sound/rt5514.txt
+++ b/Documentation/devicetree/bindings/sound/rt5514.txt
@@ -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
-- 
2.11.0

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

* [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec
  2017-09-18 11:14 [PATCH v11 1/2] ASoC: rt5514: Add devicetree binding support for rt5514-spi Jeffy Chen
@ 2017-09-18 11:14 ` Jeffy Chen
  2017-09-18 19:15   ` Matthias Kaehlcke
  2017-09-19 13:46 ` Applied "ASoC: rt5514: Add devicetree binding support for rt5514-spi" to the asoc tree Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Jeffy Chen @ 2017-09-18 11:14 UTC (permalink / raw)
  To: linux-kernel, dgreid, heiko
  Cc: alsa-devel, briannorris, Liam Girdwood, Jeffy Chen, dianders,
	linux-rockchip, broonie, Takashi Iwai, mka, linux-arm-kernel

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

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

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

 sound/soc/rockchip/rk3399_gru_sound.c | 57 +++++++++++++++++++++++++++--------
 1 file changed, 45 insertions(+), 12 deletions(-)

diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c
index 0513fe480353..f8028f1f3266 100644
--- a/sound/soc/rockchip/rk3399_gru_sound.c
+++ b/sound/soc/rockchip/rk3399_gru_sound.c
@@ -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,54 @@ 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)
 {
 	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
+		    && !bus_find_device(dailink_match[i].bus_type,
+					NULL, np_codec, of_dev_node_match))
+			continue;
+
+		return i;
 	}
 	return -1;
 }
-- 
2.11.0

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

* Re: [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec
  2017-09-18 11:14 ` [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec Jeffy Chen
@ 2017-09-18 19:15   ` Matthias Kaehlcke
  2017-09-19  3:16     ` jeffy
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias Kaehlcke @ 2017-09-18 19:15 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel, dgreid, heiko, briannorris, broonie, dianders,
	Jaroslav Kysela, alsa-devel, linux-rockchip, Takashi Iwai,
	Liam Girdwood, linux-arm-kernel

El Mon, Sep 18, 2017 at 07:14:35PM +0800 Jeffy Chen ha dit:

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

This is a better solution than the compatible hack, thanks!

> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
> Changes in v11: None
> Changes in v10: None
> Changes in v9: None
> 
>  sound/soc/rockchip/rk3399_gru_sound.c | 57 +++++++++++++++++++++++++++--------
>  1 file changed, 45 insertions(+), 12 deletions(-)
> 
> diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c
> index 0513fe480353..f8028f1f3266 100644
> --- a/sound/soc/rockchip/rk3399_gru_sound.c
> +++ b/sound/soc/rockchip/rk3399_gru_sound.c
> @@ -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,54 @@ 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;
> +}

The same is done in different places, even with the same function name
(drivers/i2c/i2c-core-of.c, drivers/mux/mux-core.c, ...), which
suggests that we might want to have this function in <linux/of.h>

>  static int rockchip_sound_codec_node_match(struct device_node *np_codec)
>  {
>  	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
> +		    && !bus_find_device(dailink_match[i].bus_type,
> +					NULL, np_codec, of_dev_node_match))
> +			continue;
> +
> +		return i;
>  	}
>  	return -1;
>  }

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>

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

* Re: [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec
  2017-09-18 19:15   ` Matthias Kaehlcke
@ 2017-09-19  3:16     ` jeffy
  0 siblings, 0 replies; 5+ messages in thread
From: jeffy @ 2017-09-19  3:16 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: linux-kernel, dgreid, heiko, briannorris, broonie, dianders,
	Jaroslav Kysela, alsa-devel, linux-rockchip, Takashi Iwai,
	Liam Girdwood, linux-arm-kernel

Hi Matthias,

On 09/19/2017 03:15 AM, Matthias Kaehlcke wrote:
>> >+static int of_dev_node_match(struct device *dev, void *data)
>> >+{
>> >+	return dev->of_node == data;
>> >+}
> The same is done in different places, even with the same function name
> (drivers/i2c/i2c-core-of.c, drivers/mux/mux-core.c, ...), which
> suggests that we might want to have this function in <linux/of.h>
>

right, we are dupping this for bus_find_device in:
./arch/powerpc/platforms/pseries/ibmebus.c
./drivers/gpu/drm/drm_mipi_dsi.c
./drivers/hwtracing/coresight/of_coresight.c
./drivers/of/of_mdio.c
./drivers/of/platform.c
./drivers/i2c/i2c-core-of.c
./drivers/nvmem/core.c

and for class_find_device in:
./drivers/spi/spi.c
./drivers/fpga/fpga-mgr.c
./drivers/fpga/fpga-region.c
./drivers/fpga/fpga-bridge.c
./drivers/regulator/core.c
./drivers/mux/core.c
./drivers/net/phy/mdio_bus.c

and for component_match_add in:
./drivers/iommu/mtk_iommu.c
  (and a lot of drm drivers)

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

* Applied "ASoC: rt5514: Add devicetree binding support for rt5514-spi" to the asoc tree
  2017-09-18 11:14 [PATCH v11 1/2] ASoC: rt5514: Add devicetree binding support for rt5514-spi Jeffy Chen
  2017-09-18 11:14 ` [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec Jeffy Chen
@ 2017-09-19 13:46 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2017-09-19 13:46 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: Mark Brown, linux-kernel, dgreid, heiko, Mark Rutland, devicetree,
	alsa-devel, briannorris, dianders, Rob Herring, Liam Girdwood

The patch

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

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 d6604145dfccc3dd9e882dd3d6bd2545c9ff64e9 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Mon, 18 Sep 2017 19:14:34 +0800
Subject: [PATCH] ASoC: rt5514: Add devicetree binding support for rt5514-spi

Add devicetree binding support for rt5514 spi dsp codec.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 Documentation/devicetree/bindings/sound/rt5514.txt | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/rt5514.txt b/Documentation/devicetree/bindings/sound/rt5514.txt
index 929ca6756b02..4f33b0d96afe 100644
--- a/Documentation/devicetree/bindings/sound/rt5514.txt
+++ b/Documentation/devicetree/bindings/sound/rt5514.txt
@@ -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
-- 
2.14.1

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

end of thread, other threads:[~2017-09-19 13:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-18 11:14 [PATCH v11 1/2] ASoC: rt5514: Add devicetree binding support for rt5514-spi Jeffy Chen
2017-09-18 11:14 ` [PATCH v11 2/2] ASoC: rockchip: Use bus_type to distinguish rt5514 dsp from rt5514 codec Jeffy Chen
2017-09-18 19:15   ` Matthias Kaehlcke
2017-09-19  3:16     ` jeffy
2017-09-19 13:46 ` Applied "ASoC: rt5514: Add devicetree binding support for rt5514-spi" to the asoc tree 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).