Linux-Tegra Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio
@ 2020-10-16 14:42 Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 01/15] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
                   ` (14 more replies)
  0 siblings, 15 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Summary of changes:
 * Support multiple instances of a component. For example there can be
   multiple I2S devices which can use the same component driver.

 * Support open platforms with empty Codec endpoint. Customers can plug
   their own HW and can populate codec endpoint.

 * In a component model there can be many components which can be
   connected togethe. In such cases Identify no-pcm DPCM DAI links which
   can be used in BE<->BE connections.

 * Add Tegra audio graph driver which is based on generic audio graph
   driver and specific customizations are done in Tegra driver.

 * This pushes DT support for Tegra210 based platforms which uses
   audio-graph card and above enhancements.

The series is based on following references where DPCM usgae for Tegra
Audio and simple-card driver proposal were discussed.

 * https://lkml.org/lkml/2020/4/30/519 (DPCM for Tegra)
 * https://lkml.org/lkml/2020/6/27/4 (simple-card driver)

Changelog
=========

v3 -> v4
--------
 * Added new patches to convert graph.txt and audio-graph-card.txt
   to corresponding json-schema files. Later these references
   are used in Tegra audio graph schema.

 * AHUB component binding docs are updated to reflect the usage
   of ports/port/endpoint

 * More common stuff is moved into graph_parse_of() and this is
   used by both generic and Tegra audio graph.

 * DT binding for Tegra audio graph is updated to included "ports { }"

 * As per the suggestion 'void *data' member is dropped from
   'asoc_simple_priv' and instead container method is used to
   maintain required custom data internal to Tegra audio graph. 

v2 -> v3
--------
 * Dropped new compatible addition in generic graph driver
   after reviewing it with Morimoto-san. Instead added Tegra
   audio graph driver and new compatibles are added in the same.
 * Added new patches to expose new members for customization
   in audio graph driver.
 * Added new patch for Tegra audio graph driver and related
   documentation.
 * Minor change in below commit where mutex version of helper is used
   "ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM"
 * DT binding is updated to use the newly exposed compatibles
 * No changes in other patches

v1 -> v2
--------
 * Re-organized ports/endpoints description for ADMAIF and XBAR.
   Updated DT patches accordingly.
 * After above change, multiple Codec endpoint support is not
   required and hence dropped for now. This will be considered
   separately if at all required in future.
 * Re-ordered patches in the series.

Sameer Pujar (15):
  ASoC: soc-core: Fix component name_prefix parsing
  ASoC: soc-pcm: Get all BEs along DAPM path
  ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names
  ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM
  ASoC: audio-graph: Support empty Codec endpoint
  ASoC: audio-graph: Expose new members for asoc_simple_priv
  ASoC: audio-graph: Expose helpers from audio graph
  Documentation: of: Convert graph bindings to json-schema
  ASoC: dt-bindings: audio-graph: Convert bindings to json-schema
  ASoC: dt-bindings: tegra: Add graph bindings
  ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  ASoC: tegra: Add audio graph based card driver
  arm64: defconfig: Enable Tegra audio graph card driver
  arm64: tegra: Audio graph header for Tegra210
  arm64: tegra: Audio graph sound card for Jetson Nano and TX1

 Documentation/devicetree/bindings/graph.txt        | 128 -----
 Documentation/devicetree/bindings/graph.yaml       | 170 +++++++
 .../devicetree/bindings/sound/audio-graph-card.txt | 337 -------------
 .../bindings/sound/audio-graph-card.yaml           | 548 +++++++++++++++++++++
 .../sound/nvidia,tegra-audio-graph-card.yaml       | 158 ++++++
 .../bindings/sound/nvidia,tegra186-dspk.yaml       |   7 +
 .../bindings/sound/nvidia,tegra210-admaif.yaml     |   7 +
 .../bindings/sound/nvidia,tegra210-ahub.yaml       |   7 +
 .../bindings/sound/nvidia,tegra210-dmic.yaml       |   7 +
 .../bindings/sound/nvidia,tegra210-i2s.yaml        |   7 +
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi      | 153 ++++++
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 ++++++++++
 arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts | 146 ++++++
 arch/arm64/configs/defconfig                       |   1 +
 include/sound/graph_card.h                         |  16 +
 include/sound/simple_card_utils.h                  |   3 +
 include/sound/soc.h                                |   1 +
 sound/soc/generic/audio-graph-card.c               | 175 ++++---
 sound/soc/soc-core.c                               |   3 +-
 sound/soc/soc-pcm.c                                |   3 +-
 sound/soc/tegra/Kconfig                            |   9 +
 sound/soc/tegra/Makefile                           |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c           | 255 ++++++++++
 23 files changed, 1882 insertions(+), 523 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/graph.txt
 create mode 100644 Documentation/devicetree/bindings/graph.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card.txt
 create mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
 create mode 100644 include/sound/graph_card.h
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

-- 
2.7.4


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

* [PATCH v4 01/15] ASoC: soc-core: Fix component name_prefix parsing
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 02/15] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

The "prefix" can be defined in DAI link node or it can be specified as
part of the component node itself. Currently "sound-name-prefix" defined
in a component is not taking effect. Actually the property is not getting
parsed. It can be fixed by parsing "sound-name-prefix" property whenever
"prefix" is missing in DAI link Codec node.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 sound/soc/soc-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ea3986a..cb7333d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1124,7 +1124,8 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
 	for (i = 0; i < card->num_configs; i++) {
 		struct snd_soc_codec_conf *map = &card->codec_conf[i];
 
-		if (snd_soc_is_matching_component(&map->dlc, component)) {
+		if (snd_soc_is_matching_component(&map->dlc, component) &&
+		    map->name_prefix) {
 			component->name_prefix = map->name_prefix;
 			return;
 		}
-- 
2.7.4


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

* [PATCH v4 02/15] ASoC: soc-pcm: Get all BEs along DAPM path
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 01/15] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 03/15] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

dpcm_end_walk_at_be() stops the graph walk when first BE is found for
the given FE component. In a component model we may want to connect
multiple DAIs from different components. A new flag is introduced in
'snd_soc_card', which when set allows DAI/component chaining. Later
PCM operations can be called for all these listed components for a
valid DAPM path.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 include/sound/soc.h | 1 +
 sound/soc/soc-pcm.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 3b038c5..9b69d70 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1084,6 +1084,7 @@ struct snd_soc_card {
 	unsigned int fully_routed:1;
 	unsigned int disable_route_checks:1;
 	unsigned int probed:1;
+	unsigned int component_chaining:1;
 
 	void *drvdata;
 };
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index dcab952..9bd2d65 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1284,7 +1284,8 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
 
 	/* get number of valid DAI paths and their widgets */
 	paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list,
-			dpcm_end_walk_at_be);
+			fe->card->component_chaining ?
+				NULL : dpcm_end_walk_at_be);
 
 	dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths,
 			stream ? "capture" : "playback");
-- 
2.7.4


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

* [PATCH v4 03/15] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 01/15] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 02/15] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 04/15] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

For multiple instances of components, using DAI name alone for DAI links
is causing conflicts. Components can define multiple DAIs and hence using
just a device name won't help either. Thus DT device node reference and
DAI names are used to uniquely represent DAI link names.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 97b4f54..1e20562 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -253,7 +253,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 			goto out_put_node;
 
 		ret = asoc_simple_set_dailink_name(dev, dai_link,
-						   "fe.%s",
+						   "fe.%pOFP.%s",
+						   cpus->of_node,
 						   cpus->dai_name);
 		if (ret < 0)
 			goto out_put_node;
@@ -287,7 +288,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 			goto out_put_node;
 
 		ret = asoc_simple_set_dailink_name(dev, dai_link,
-						   "be.%s",
+						   "be.%pOFP.%s",
+						   codecs->of_node,
 						   codecs->dai_name);
 		if (ret < 0)
 			goto out_put_node;
-- 
2.7.4


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

* [PATCH v4 04/15] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (2 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 03/15] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 05/15] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

PCM devices are created for FE dai links with 'no-pcm' flag as '0'.
Such DAI links have CPU component which implement either pcm_construct()
or pcm_new() at component or dai level respectively. Based on this,
current patch exposes a helper function to identify such components
and populate 'no_pcm' flag for DPCM DAI link.

This helps to have BE<->BE component links where PCM devices need
not be created for CPU component involved in such links.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 1e20562..9b06841 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -111,6 +111,17 @@ static int graph_get_dai_id(struct device_node *ep)
 	return id;
 }
 
+static bool soc_component_is_pcm(struct snd_soc_dai_link_component *dlc)
+{
+	struct snd_soc_dai *dai = snd_soc_find_dai_with_mutex(dlc);
+
+	if (dai && (dai->component->driver->pcm_construct ||
+		    dai->driver->pcm_new))
+		return true;
+
+	return false;
+}
+
 static int asoc_simple_parse_dai(struct device_node *ep,
 				 struct snd_soc_dai_link_component *dlc,
 				 int *is_single_link)
@@ -205,6 +216,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 				  int dup_codec)
 {
 	struct device *dev = simple_priv_to_dev(priv);
+	struct snd_soc_card *card = simple_priv_to_card(priv);
 	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
 	struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
 	struct device_node *top = dev->of_node;
@@ -259,6 +271,19 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 		if (ret < 0)
 			goto out_put_node;
 
+		/*
+		 * In BE<->BE connections it is not required to create
+		 * PCM devices at CPU end of the dai link and thus 'no_pcm'
+		 * flag needs to be set. It is useful when there are many
+		 * BE components and some of these have to be connected to
+		 * form a valid audio path.
+		 *
+		 * For example: FE <-> BE1 <-> BE2 <-> ... <-> BEn where
+		 * there are 'n' BE components in the path.
+		 */
+		if (card->component_chaining && !soc_component_is_pcm(cpus))
+			dai_link->no_pcm = 1;
+
 		/* card->num_links includes Codec */
 		asoc_simple_canonicalize_cpu(dai_link, is_single_links);
 	} else {
-- 
2.7.4


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

* [PATCH v4 05/15] ASoC: audio-graph: Support empty Codec endpoint
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (3 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 04/15] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 06/15] ASoC: audio-graph: Expose new members for asoc_simple_priv Sameer Pujar
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

For open platforms, which can support pluggable audio cards, Codec
endpoint is not fixed always. It actually depends on the compatible
HW module that is going to be connected. From SoC side the given I/O
interface is always available. Hence such links have fixed CPU endpoint
but no Codec endpoint. This patch helps to support such links where
user can populate Codec endpoint only and its fields in Platform DT
depending on the plugged HW.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 9b06841..0ba50be9 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -229,6 +229,14 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	struct snd_soc_dai_link_component *codecs = dai_link->codecs;
 	int ret;
 
+	/*
+	 * Codec endpoint can be NULL for pluggable audio HW.
+	 * Platform DT can populate the Codec endpoint depending on the
+	 * plugged HW.
+	 */
+	if (!li->cpu && !codec_ep)
+		return 0;
+
 	/* Do it all CPU endpoint, and 1st Codec endpoint */
 	if (!li->cpu && dup_codec)
 		return 0;
@@ -565,7 +573,7 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,
 	li->link++; /* 1xCPU-dummy */
 	li->dais++; /* 1xCPU */
 
-	if (!dup_codec) {
+	if (!dup_codec && codec_ep) {
 		li->link++; /* 1xdummy-Codec */
 		li->conf++; /* 1xdummy-Codec */
 		li->dais++; /* 1xCodec */
-- 
2.7.4


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

* [PATCH v4 06/15] ASoC: audio-graph: Expose new members for asoc_simple_priv
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (4 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 05/15] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 07/15] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Add new members in struct 'asoc_simple_priv'. Idea is to leverage
simple or graph card driver as much as possible and vendor can
maintain a thin driver to control the behavior by populating these
newly exposed members.

Following are the members added in 'asoc_simple_priv':

  - 'ops' struct: In some cases SoC vendor drivers may want to
    implement 'snd_soc_ops' callbacks differently. In such cases
    custom callbacks would be used.

  - 'force_dpcm' flag: Right now simple or graph card drivers
    detect DAI links as DPCM links if:

      * The dpcm_selectable is set AND
      * Codec is connected to multiple CPU endpoints or aconvert
        property is used for rate/channels.

    So there is no way to directly specify usage of DPCM alone. So a
    flag is exposed to mark all links as DPCM. Vendor driver can
    set this if required.

  - 'dpcm_selectable': Currently simple or audio graph drivers
    provide a way to enable this for specific compatibles. However
    vendor driver may want to define some additional info. Thus
    expose this variable where vendor drivers can set this if
    required.

Audio graph driver is updated to consider above flags or callbacks.
Subsequent patches in the series illustrate usage for above.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h    |  3 +++
 sound/soc/generic/audio-graph-card.c | 41 ++++++++++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 86a1e95..ba4a3e1 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -56,6 +56,9 @@ struct asoc_simple_priv {
 	struct asoc_simple_dai *dais;
 	struct snd_soc_codec_conf *codec_conf;
 	struct gpio_desc *pa_gpio;
+	const struct snd_soc_ops *ops;
+	unsigned int dpcm_selectable:1;
+	unsigned int force_dpcm:1;
 };
 #define simple_priv_to_card(priv)	(&(priv)->snd_card)
 #define simple_priv_to_props(priv, i)	((priv)->dai_props + (i))
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 0ba50be9..4db9c0e 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -355,6 +355,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	snd_soc_dai_link_set_capabilities(dai_link);
 
 	dai_link->ops			= &graph_ops;
+
+	/* Use custom snd_soc_ops callbacks if available */
+	if (priv->ops)
+		dai_link->ops = priv->ops;
+
 	dai_link->init			= asoc_simple_dai_init;
 
 out_put_node:
@@ -439,6 +444,28 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
 	return 0;
 }
 
+static inline bool parse_as_dpcm_link(struct asoc_simple_priv *priv,
+				      struct device_node *codec_port,
+				      struct asoc_simple_data *adata)
+{
+	if (priv->force_dpcm)
+		return true;
+
+	if (!priv->dpcm_selectable)
+		return false;
+
+	/*
+	 * It is DPCM
+	 * if Codec port has many endpoints,
+	 * or has convert-xxx property
+	 */
+	if ((of_get_child_count(codec_port) > 1) ||
+	    (adata->convert_rate || adata->convert_channels))
+		return true;
+
+	return false;
+}
+
 static int graph_for_each_link(struct asoc_simple_priv *priv,
 			struct link_info *li,
 			int (*func_noml)(struct asoc_simple_priv *priv,
@@ -459,7 +486,6 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,
 	struct device_node *codec_port;
 	struct device_node *codec_port_old = NULL;
 	struct asoc_simple_data adata;
-	uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
 	int rc, ret;
 
 	/* loop for all listed CPU port */
@@ -482,14 +508,8 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,
 			graph_parse_convert(dev, codec_ep, &adata);
 			graph_parse_convert(dev, cpu_ep,   &adata);
 
-			/*
-			 * It is DPCM
-			 * if Codec port has many endpoints,
-			 * or has convert-xxx property
-			 */
-			if (dpcm_selectable &&
-			    ((of_get_child_count(codec_port) > 1) ||
-			     adata.convert_rate || adata.convert_channels))
+			/* check if link requires DPCM parsing */
+			if (parse_as_dpcm_link(priv, codec_port, &adata))
 				ret = func_dpcm(priv, cpu_ep, codec_ep, li,
 						(codec_port_old == codec_port));
 			/* else normal sound */
@@ -678,6 +698,9 @@ static int graph_probe(struct platform_device *pdev)
 	card->num_dapm_widgets	= ARRAY_SIZE(graph_dapm_widgets);
 	card->probe		= graph_card_probe;
 
+	if (of_device_get_match_data(dev))
+		priv->dpcm_selectable = 1;
+
 	memset(&li, 0, sizeof(li));
 	graph_get_dais_count(priv, &li);
 	if (!li.link || !li.dais)
-- 
2.7.4


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

* [PATCH v4 07/15] ASoC: audio-graph: Expose helpers from audio graph
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (5 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 06/15] ASoC: audio-graph: Expose new members for asoc_simple_priv Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:42 ` [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema Sameer Pujar
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

This commit exposes following functions which can be used by a sound
card driver based on generic audio graph driver. Idea is vendors can
have a thin driver and re-use common stuff from audio graph driver.

 - graph_card_probe()
 - graph_parse_of()

In doing so a new header file is added for above. The graph_probe()
function is simplified by moving more common stuff to graph_parse_of().

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/graph_card.h           | 16 ++++++
 sound/soc/generic/audio-graph-card.c | 95 +++++++++++++++++++-----------------
 2 files changed, 66 insertions(+), 45 deletions(-)
 create mode 100644 include/sound/graph_card.h

diff --git a/include/sound/graph_card.h b/include/sound/graph_card.h
new file mode 100644
index 0000000..bbb5a13
--- /dev/null
+++ b/include/sound/graph_card.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * ASoC audio graph card support
+ *
+ */
+
+#ifndef __GRAPH_CARD_H
+#define __GRAPH_CARD_H
+
+#include <sound/simple_card_utils.h>
+
+int graph_card_probe(struct snd_soc_card *card);
+
+int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
+
+#endif /* __GRAPH_CARD_H */
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 4db9c0e..16a04a6 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -18,7 +18,7 @@
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
-#include <sound/simple_card_utils.h>
+#include <sound/graph_card.h>
 
 #define DPCM_SELECTABLE 1
 
@@ -529,12 +529,34 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,
 	return 0;
 }
 
-static int graph_parse_of(struct asoc_simple_priv *priv)
+static void graph_get_dais_count(struct asoc_simple_priv *priv,
+				 struct link_info *li);
+
+int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
 {
 	struct snd_soc_card *card = simple_priv_to_card(priv);
 	struct link_info li;
 	int ret;
 
+	card->owner = THIS_MODULE;
+	card->dev = dev;
+
+	memset(&li, 0, sizeof(li));
+	graph_get_dais_count(priv, &li);
+	if (!li.link || !li.dais)
+		return -EINVAL;
+
+	ret = asoc_simple_init_priv(priv, &li);
+	if (ret < 0)
+		return ret;
+
+	priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
+	if (IS_ERR(priv->pa_gpio)) {
+		ret = PTR_ERR(priv->pa_gpio);
+		dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
+		return ret;
+	}
+
 	ret = asoc_simple_parse_widgets(card, NULL);
 	if (ret < 0)
 		return ret;
@@ -561,11 +583,32 @@ static int graph_parse_of(struct asoc_simple_priv *priv)
 					  graph_dai_link_of,
 					  graph_dai_link_of_dpcm);
 		if (ret < 0)
-			return ret;
+			goto err;
 	}
 
-	return asoc_simple_parse_card_name(card, NULL);
+	ret = asoc_simple_parse_card_name(card, NULL);
+	if (ret < 0)
+		goto err;
+
+	snd_soc_card_set_drvdata(card, priv);
+
+	asoc_simple_debug_info(priv);
+
+	ret = devm_snd_soc_register_card(dev, card);
+	if (ret < 0)
+		goto err;
+
+	return 0;
+
+err:
+	asoc_simple_clean_reference(card);
+
+	if (ret != -EPROBE_DEFER)
+		dev_err(dev, "parse error %d\n", ret);
+
+	return ret;
 }
+EXPORT_SYMBOL_GPL(graph_parse_of);
 
 static int graph_count_noml(struct asoc_simple_priv *priv,
 			    struct device_node *cpu_ep,
@@ -662,7 +705,7 @@ static void graph_get_dais_count(struct asoc_simple_priv *priv,
 		li->link, li->dais, li->conf);
 }
 
-static int graph_card_probe(struct snd_soc_card *card)
+int graph_card_probe(struct snd_soc_card *card)
 {
 	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
 	int ret;
@@ -677,14 +720,13 @@ static int graph_card_probe(struct snd_soc_card *card)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(graph_card_probe);
 
 static int graph_probe(struct platform_device *pdev)
 {
 	struct asoc_simple_priv *priv;
 	struct device *dev = &pdev->dev;
 	struct snd_soc_card *card;
-	struct link_info li;
-	int ret;
 
 	/* Allocate the private data and the DAI link array */
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -692,8 +734,6 @@ static int graph_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	card = simple_priv_to_card(priv);
-	card->owner		= THIS_MODULE;
-	card->dev		= dev;
 	card->dapm_widgets	= graph_dapm_widgets;
 	card->num_dapm_widgets	= ARRAY_SIZE(graph_dapm_widgets);
 	card->probe		= graph_card_probe;
@@ -701,42 +741,7 @@ static int graph_probe(struct platform_device *pdev)
 	if (of_device_get_match_data(dev))
 		priv->dpcm_selectable = 1;
 
-	memset(&li, 0, sizeof(li));
-	graph_get_dais_count(priv, &li);
-	if (!li.link || !li.dais)
-		return -EINVAL;
-
-	ret = asoc_simple_init_priv(priv, &li);
-	if (ret < 0)
-		return ret;
-
-	priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
-	if (IS_ERR(priv->pa_gpio)) {
-		ret = PTR_ERR(priv->pa_gpio);
-		dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
-		return ret;
-	}
-
-	ret = graph_parse_of(priv);
-	if (ret < 0) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "parse error %d\n", ret);
-		goto err;
-	}
-
-	snd_soc_card_set_drvdata(card, priv);
-
-	asoc_simple_debug_info(priv);
-
-	ret = devm_snd_soc_register_card(dev, card);
-	if (ret < 0)
-		goto err;
-
-	return 0;
-err:
-	asoc_simple_clean_reference(card);
-
-	return ret;
+	return graph_parse_of(priv, dev);
 }
 
 static int graph_remove(struct platform_device *pdev)
-- 
2.7.4


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

* [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (6 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 07/15] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-19 21:56   ` Rob Herring
  2020-10-16 14:42 ` [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert " Sameer Pujar
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Convert device tree bindings of graph to YAML format.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
---
 Documentation/devicetree/bindings/graph.txt  | 128 --------------------
 Documentation/devicetree/bindings/graph.yaml | 170 +++++++++++++++++++++++++++
 2 files changed, 170 insertions(+), 128 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/graph.txt
 create mode 100644 Documentation/devicetree/bindings/graph.yaml

diff --git a/Documentation/devicetree/bindings/graph.txt b/Documentation/devicetree/bindings/graph.txt
deleted file mode 100644
index 0415e2c..0000000
--- a/Documentation/devicetree/bindings/graph.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-Common bindings for device graphs
-
-General concept
----------------
-
-The hierarchical organisation of the device tree is well suited to describe
-control flow to devices, but there can be more complex connections between
-devices that work together to form a logical compound device, following an
-arbitrarily complex graph.
-There already is a simple directed graph between devices tree nodes using
-phandle properties pointing to other nodes to describe connections that
-can not be inferred from device tree parent-child relationships. The device
-tree graph bindings described herein abstract more complex devices that can
-have multiple specifiable ports, each of which can be linked to one or more
-ports of other devices.
-
-These common bindings do not contain any information about the direction or
-type of the connections, they just map their existence. Specific properties
-may be described by specialized bindings depending on the type of connection.
-
-To see how this binding applies to video pipelines, for example, see
-Documentation/devicetree/bindings/media/video-interfaces.txt.
-Here the ports describe data interfaces, and the links between them are
-the connecting data buses. A single port with multiple connections can
-correspond to multiple devices being connected to the same physical bus.
-
-Organisation of ports and endpoints
------------------------------------
-
-Ports are described by child 'port' nodes contained in the device node.
-Each port node contains an 'endpoint' subnode for each remote device port
-connected to this port. If a single port is connected to more than one
-remote device, an 'endpoint' child node must be provided for each link.
-If more than one port is present in a device node or there is more than one
-endpoint at a port, or a port node needs to be associated with a selected
-hardware interface, a common scheme using '#address-cells', '#size-cells'
-and 'reg' properties is used to number the nodes.
-
-device {
-        ...
-        #address-cells = <1>;
-        #size-cells = <0>;
-
-        port@0 {
-	        #address-cells = <1>;
-	        #size-cells = <0>;
-		reg = <0>;
-
-                endpoint@0 {
-			reg = <0>;
-			...
-		};
-                endpoint@1 {
-			reg = <1>;
-			...
-		};
-        };
-
-        port@1 {
-		reg = <1>;
-
-		endpoint { ... };
-	};
-};
-
-All 'port' nodes can be grouped under an optional 'ports' node, which
-allows to specify #address-cells, #size-cells properties for the 'port'
-nodes independently from any other child device nodes a device might
-have.
-
-device {
-        ...
-        ports {
-                #address-cells = <1>;
-                #size-cells = <0>;
-
-                port@0 {
-                        ...
-                        endpoint@0 { ... };
-                        endpoint@1 { ... };
-                };
-
-                port@1 { ... };
-        };
-};
-
-Links between endpoints
------------------------
-
-Each endpoint should contain a 'remote-endpoint' phandle property that points
-to the corresponding endpoint in the port of the remote device. In turn, the
-remote endpoint should contain a 'remote-endpoint' property. If it has one, it
-must not point to anything other than the local endpoint. Two endpoints with
-their 'remote-endpoint' phandles pointing at each other form a link between the
-containing ports.
-
-device-1 {
-        port {
-                device_1_output: endpoint {
-                        remote-endpoint = <&device_2_input>;
-                };
-        };
-};
-
-device-2 {
-        port {
-                device_2_input: endpoint {
-                        remote-endpoint = <&device_1_output>;
-                };
-        };
-};
-
-Required properties
--------------------
-
-If there is more than one 'port' or more than one 'endpoint' node or 'reg'
-property present in the port and/or endpoint nodes then the following
-properties are required in a relevant parent node:
-
- - #address-cells : number of cells required to define port/endpoint
-                    identifier, should be 1.
- - #size-cells    : should be zero.
-
-Optional endpoint properties
-----------------------------
-
-- remote-endpoint: phandle to an 'endpoint' subnode of a remote device node.
-
diff --git a/Documentation/devicetree/bindings/graph.yaml b/Documentation/devicetree/bindings/graph.yaml
new file mode 100644
index 0000000..67804c1
--- /dev/null
+++ b/Documentation/devicetree/bindings/graph.yaml
@@ -0,0 +1,170 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/graph.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Common bindings for device graphs
+
+description: |
+  The hierarchical organisation of the device tree is well suited to describe
+  control flow to devices, but there can be more complex connections between
+  devices that work together to form a logical compound device, following an
+  arbitrarily complex graph.
+  There already is a simple directed graph between devices tree nodes using
+  phandle properties pointing to other nodes to describe connections that
+  can not be inferred from device tree parent-child relationships. The device
+  tree graph bindings described herein abstract more complex devices that can
+  have multiple specifiable ports, each of which can be linked to one or more
+  ports of other devices.
+
+  These common bindings do not contain any information about the direction or
+  type of the connections, they just map their existence. Specific properties
+  may be described by specialized bindings depending on the type of connection.
+
+  To see how this binding applies to video pipelines, for example, see
+  Documentation/devicetree/bindings/media/video-interfaces.txt.
+  Here the ports describe data interfaces, and the links between them are
+  the connecting data buses. A single port with multiple connections can
+  correspond to multiple devices being connected to the same physical bus.
+
+maintainers:
+  - Philipp Zabel <p.zabel@pengutronix.de>
+
+definitions:
+
+  port:
+    type: object
+    description: |
+      If there is more than one 'port' or more than one 'endpoint' node
+      or 'reg' property present in the port and/or endpoint nodes then
+      '#address-cells' and '#size-cells' properties are required in relevant
+      parent node.
+
+    patternProperties:
+      "^endpoint(@[0-9a-f]+)?$":
+        type: object
+        properties:
+          remote-endpoint:
+            description: |
+              phandle to an 'endpoint' subnode of a remote device node.
+            $ref: /schemas/types.yaml#/definitions/phandle
+
+  ports:
+    type: object
+    patternProperties:
+      "^port(@[0-9a-f]+)?$":
+        $ref: "#/definitions/port"
+
+properties:
+  ports:
+    $ref: "#/definitions/ports"
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: "#/definitions/port"
+
+additionalProperties: false
+
+examples:
+  # Organisation of ports and endpoints:
+  #
+  # Ports are described by child 'port' nodes contained in the device node.
+  # Each port node contains an 'endpoint' subnode for each remote device port
+  # connected to this port. If a single port is connected to more than one
+  # remote device, an 'endpoint' child node must be provided for each link.
+  # If more than one port is present in a device node or there is more than
+  # one endpoint at a port, or a port node needs to be associated with a
+  # selected hardware interface, a common scheme using '#address-cells',
+  # '#size-cells' and 'reg' properties is used to number the nodes.
+  - |
+    device {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        port@0 {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            reg = <0>;
+
+            endpoint@0 {
+                reg = <0>;
+                // ...
+            };
+            endpoint@1 {
+                reg = <1>;
+                // ...
+            };
+        };
+
+        port@1 {
+            reg = <1>;
+
+            endpoint {
+                // ...
+            };
+        };
+    };
+
+  # All 'port' nodes can be grouped under an optional 'ports' node, which
+  # allows to specify #address-cells, #size-cells properties for the 'port'
+  # nodes independently from any other child device nodes a device might
+  # have.
+  - |
+    device {
+        // ...
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                reg = <0>;
+                // ...
+
+                endpoint@0 {
+                    reg = <0>;
+                    // ...
+                };
+                endpoint@1 {
+                    reg = <1>;
+                    // ...
+                };
+            };
+
+            port@1 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+                reg = <1>;
+                // ...
+            };
+        };
+    };
+
+  # Links between endpoints:
+  #
+  # Each endpoint should contain a 'remote-endpoint' phandle property that
+  # points to the corresponding endpoint in the port of the remote device.
+  # In turn, the remote endpoint should contain a 'remote-endpoint' property.
+  # If it has one, it must not point to anything other than the local endpoint.
+  # Two endpoints with their 'remote-endpoint' phandles pointing at each other
+  # form a link between the containing ports.
+  - |
+    device-1 {
+        port {
+            device_1_output: endpoint {
+                remote-endpoint = <&device_2_input>;
+            };
+        };
+    };
+
+    device-2 {
+        port {
+            device_2_input: endpoint {
+                remote-endpoint = <&device_1_output>;
+            };
+        };
+    };
+
+...
-- 
2.7.4


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

* [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert bindings to json-schema
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (7 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-19  2:50   ` Kuninori Morimoto
  2020-10-16 14:42 ` [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings Sameer Pujar
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Convert device tree bindings of audio graph card to YAML format. Also
expose some common definitions which can be used by similar graph based
audio sound cards.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../devicetree/bindings/sound/audio-graph-card.txt | 337 -------------
 .../bindings/sound/audio-graph-card.yaml           | 548 +++++++++++++++++++++
 2 files changed, 548 insertions(+), 337 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card.txt
 create mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card.yaml

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card.txt b/Documentation/devicetree/bindings/sound/audio-graph-card.txt
deleted file mode 100644
index d5f6919..0000000
--- a/Documentation/devicetree/bindings/sound/audio-graph-card.txt
+++ /dev/null
@@ -1,337 +0,0 @@
-Audio Graph Card:
-
-Audio Graph Card specifies audio DAI connections of SoC <-> codec.
-It is based on common bindings for device graphs.
-see ${LINUX}/Documentation/devicetree/bindings/graph.txt
-
-Basically, Audio Graph Card property is same as Simple Card.
-see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.yaml
-
-Below are same as Simple-Card.
-
-- label
-- widgets
-- routing
-- dai-format
-- frame-master
-- bitclock-master
-- bitclock-inversion
-- frame-inversion
-- mclk-fs
-- hp-det-gpio
-- mic-det-gpio
-- dai-tdm-slot-num
-- dai-tdm-slot-width
-- clocks / system-clock-frequency
-
-Required properties:
-
-- compatible				: "audio-graph-card";
-- dais					: list of CPU DAI port{s}
-
-Optional properties:
-- pa-gpios: GPIO used to control external amplifier.
-
------------------------
-Example: Single DAI case
------------------------
-
-	sound_card {
-		compatible = "audio-graph-card";
-
-		dais = <&cpu_port>;
-	};
-
-	dai-controller {
-		...
-		cpu_port: port {
-			cpu_endpoint: endpoint {
-				remote-endpoint = <&codec_endpoint>;
-
-				dai-format = "left_j";
-				...
-			};
-		};
-	};
-
-	audio-codec {
-		...
-		port {
-			codec_endpoint: endpoint {
-				remote-endpoint = <&cpu_endpoint>;
-			};
-		};
-	};
-
------------------------
-Example: Multi DAI case
------------------------
-
-	sound-card {
-		compatible = "audio-graph-card";
-
-		label = "sound-card";
-
-		dais = <&cpu_port0
-			&cpu_port1
-			&cpu_port2>;
-	};
-
-	audio-codec@0 {
-		...
-		port {
-			codec0_endpoint: endpoint {
-				remote-endpoint = <&cpu_endpoint0>;
-			};
-		};
-	};
-
-	audio-codec@1 {
-		...
-		port {
-			codec1_endpoint: endpoint {
-				remote-endpoint = <&cpu_endpoint1>;
-			};
-		};
-	};
-
-	audio-codec@2 {
-		...
-		port {
-			codec2_endpoint: endpoint {
-				remote-endpoint = <&cpu_endpoint2>;
-			};
-		};
-	};
-
-	dai-controller {
-		...
-		ports {
-			cpu_port0: port@0 {
-				cpu_endpoint0: endpoint {
-					remote-endpoint = <&codec0_endpoint>;
-
-					dai-format = "left_j";
-					...
-				};
-			};
-			cpu_port1: port@1 {
-				cpu_endpoint1: endpoint {
-					remote-endpoint = <&codec1_endpoint>;
-
-					dai-format = "i2s";
-					...
-				};
-			};
-			cpu_port2: port@2 {
-				cpu_endpoint2: endpoint {
-					remote-endpoint = <&codec2_endpoint>;
-
-					dai-format = "i2s";
-					...
-				};
-			};
-		};
-	};
-
-
------------------------
-Example: Sampling Rate Conversion
------------------------
-
-	sound_card {
-		compatible = "audio-graph-card";
-
-		label = "sound-card";
-		prefix = "codec";
-		routing = "codec Playback", "DAI0 Playback",
-			  "DAI0 Capture",   "codec Capture";
-		convert-rate = <48000>;
-
-		dais = <&cpu_port>;
-	};
-
-	audio-codec {
-		...
-		port {
-			codec_endpoint: endpoint {
-				remote-endpoint = <&cpu_endpoint>;
-			};
-		};
-	};
-
-	dai-controller {
-		...
-		cpu_port: port {
-			cpu_endpoint: endpoint {
-				remote-endpoint = <&codec_endpoint>;
-
-				dai-format = "left_j";
-				...
-			};
-		};
-	};
-
------------------------
-Example: 2 CPU 1 Codec (Mixing)
------------------------
-
-	sound_card {
-		compatible = "audio-graph-card";
-
-		label = "sound-card";
-		routing = "codec Playback", "DAI0 Playback",
-			  "codec Playback", "DAI1 Playback",
-			  "DAI0 Capture",   "codec Capture";
-
-		dais = <&cpu_port>;
-	};
-
-	audio-codec {
-		...
-
-		audio-graph-card,prefix = "codec";
-		audio-graph-card,convert-rate = <48000>;
-		port {
-			reg = <0>;
-			codec_endpoint0: endpoint@0 {
-				remote-endpoint = <&cpu_endpoint0>;
-			};
-			codec_endpoint1: endpoint@1 {
-				remote-endpoint = <&cpu_endpoint1>;
-			};
-		};
-	};
-
-	dai-controller {
-		...
-		cpu_port: port {
-			cpu_endpoint0: endpoint@0 {
-				remote-endpoint = <&codec_endpoint0>;
-
-				dai-format = "left_j";
-				...
-			};
-			cpu_endpoint1: endpoint@1 {
-				remote-endpoint = <&codec_endpoint1>;
-
-				dai-format = "left_j";
-				...
-			};
-		};
-	};
-
------------------------
-Example: Multi DAI with DPCM
------------------------
-
-	CPU0 ------ ak4613
-	CPU1 ------ HDMI
-	CPU2 ------ PCM3168A-p	/* DPCM 1ch/2ch */
-	CPU3 --/		/* DPCM 3ch/4ch */
-	CPU4 --/		/* DPCM 5ch/6ch */
-	CPU5 --/		/* DPCM 7ch/8ch */
-	CPU6 ------ PCM3168A-c
-
-	sound_card: sound {
-		compatible = "audio-graph-card";
-
-		label = "sound-card";
-
-		routing =	"pcm3168a Playback", "DAI2 Playback",
-				"pcm3168a Playback", "DAI3 Playback",
-				"pcm3168a Playback", "DAI4 Playback",
-				"pcm3168a Playback", "DAI5 Playback";
-
-		dais = <&snd_port0	/* ak4613 */
-			&snd_port1	/* HDMI0  */
-			&snd_port2	/* pcm3168a playback */
-			&snd_port3	/* pcm3168a capture  */
-			>;
-	};
-
-	ak4613: codec@10 {
-		...
-		port {
-			ak4613_endpoint: endpoint {
-				remote-endpoint = <&rsnd_endpoint0>;
-			};
-		};
-	};
-
-	pcm3168a: audio-codec@44 {
-		...
-		audio-graph-card,prefix = "pcm3168a";
-		audio-graph-card,convert-channels = <8>; /* TDM Split */
-		ports {
-			port@0 {
-				reg = <0>;
-				pcm3168a_endpoint_p1: endpoint@1 {
-					remote-endpoint = <&rsnd_endpoint2>;
-					...
-				};
-				pcm3168a_endpoint_p2: endpoint@2 {
-					remote-endpoint = <&rsnd_endpoint3>;
-					...
-				};
-				pcm3168a_endpoint_p3: endpoint@3 {
-					remote-endpoint = <&rsnd_endpoint4>;
-					...
-				};
-				pcm3168a_endpoint_p4: endpoint@4 {
-					remote-endpoint = <&rsnd_endpoint5>;
-					...
-				};
-			};
-			port@1 {
-				reg = <1>;
-				pcm3168a_endpoint_c: endpoint {
-					remote-endpoint = <&rsnd_endpoint6>;
-					...
-				};
-			};
-		};
-	};
-
-	&sound {
-		ports {
-			snd_port0: port@0 {
-				rsnd_endpoint0: endpoint {
-					remote-endpoint = <&ak4613_endpoint>;
-					...
-				};
-			};
-			snd_port1: port@1 {
-				rsnd_endpoint1: endpoint {
-					remote-endpoint = <&dw_hdmi0_snd_in>;
-					...
-				};
-			};
-			snd_port2: port@2 {
-				#address-cells = <1>;
-				#size-cells = <0>;
-				rsnd_endpoint2: endpoint@2 {
-					remote-endpoint = <&pcm3168a_endpoint_p1>;
-					...
-				};
-				rsnd_endpoint3: endpoint@3 {
-					remote-endpoint = <&pcm3168a_endpoint_p2>;
-					...
-				};
-				rsnd_endpoint4: endpoint@4 {
-					remote-endpoint = <&pcm3168a_endpoint_p3>;
-					...
-				};
-				rsnd_endpoint5: endpoint@5 {
-					remote-endpoint = <&pcm3168a_endpoint_p4>;
-					...
-				};
-			};
-			snd_port3: port@6 {
-				rsnd_endpoint6: endpoint {
-					remote-endpoint = <&pcm3168a_endpoint_c>;
-					...
-				};
-			};
-		};
-	};
diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card.yaml b/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
new file mode 100644
index 0000000..d4b56bd
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
@@ -0,0 +1,548 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/audio-graph-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic audio graph card
+
+description: |
+  Audio Graph Card specifies audio DAI connections of SoC <-> codec.
+  It is based on common bindings for device graphs.
+  see ${LINUX}/Documentation/devicetree/bindings/graph.yaml
+
+  Basically, Audio Graph Card properties are similar to Simple Card.
+  see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.yaml
+  Common definitions required here are referenced from above.
+
+maintainers:
+  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+
+definitions:
+
+  end-point:
+    type: object
+    properties:
+      mclk-fs:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
+
+      prefix:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
+
+      convert-rate:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
+
+      convert-channels:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
+
+      frame-inversion:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/frame-inversion
+
+      bitclock-inversion:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/bitclock-inversion
+
+      frame-master:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/frame-master
+
+      bitclock-master:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/bitclock-master
+
+      dai-tdm-slot-num:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/dai-tdm-slot-num
+
+      dai-tdm-slot-width:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/dai-tdm-slot-width
+
+      clocks:
+        maxItems: 1
+
+      system-clock-frequency:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/system-clock-frequency
+
+      system-clock-direction-out:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/system-clock-direction-out
+
+      dai-format:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/format
+
+      remote-endpoint:
+        description: phandle to an 'endpoint' subnode of a remote device node.
+        $ref: /schemas/types.yaml#/definitions/phandle
+
+  port:
+    type: object
+    description: |
+      If there is more than one 'port' or more than one 'endpoint' node
+      or 'reg' property present in the port and/or endpoint nodes then
+      '#address-cells' and '#size-cells' properties are required in relevant
+      parent node.
+    properties:
+      convert-rate:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
+
+      convert-channels:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
+
+      prefix:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
+
+      mclk-fs:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
+
+    patternProperties:
+      "^endpoint(@[0-9a-f]+)?$":
+        type: object
+        $ref: "#/definitions/end-point"
+
+  ports:
+    type: object
+    properties:
+      convert-rate:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
+
+      convert-channels:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
+
+      prefix:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
+
+      mclk-fs:
+        $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
+
+    patternProperties:
+      "^port(@[0-9a-f]+)?$":
+        $ref: "#/definitions/port"
+
+properties:
+  compatible:
+    items:
+      - const: audio-graph-card
+
+  dais:
+    description: list of CPU DAI port{s}
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+  label:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/label
+
+  pa-gpios:
+    description: GPIO used to control external amplifier.
+
+  widgets:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/widgets
+
+  routing:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/routing
+
+  convert-rate:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
+
+  convert-channels:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
+
+  mclk-fs:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
+
+  prefix:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
+
+  hp-det-gpio:
+    maxItems: 1
+
+  mic-det-gpio:
+    maxItems: 1
+
+  ports:
+    $ref: "#/definitions/ports"
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: "#/definitions/port"
+
+required:
+  - compatible
+  - dais
+
+additionalProperties: false
+
+examples:
+  # ---------------
+  # Single DAI case
+  # ---------------
+  - |
+    sound_card {
+        compatible = "audio-graph-card";
+
+        dais = <&cpu_port>;
+    };
+
+    dai-controller {
+        // ...
+
+        cpu_port: port {
+            cpu_endpoint: endpoint {
+                remote-endpoint = <&codec_endpoint>;
+
+                dai-format = "left_j";
+
+                // ...
+            };
+        };
+    };
+
+    audio-codec {
+        // ...
+
+        port {
+            codec_endpoint: endpoint {
+                remote-endpoint = <&cpu_endpoint>;
+            };
+        };
+    };
+
+  # --------------
+  # Multi DAI case
+  # --------------
+  - |
+    sound-card {
+        compatible = "audio-graph-card";
+
+        label = "sound-card";
+
+        dais = <&cpu_port0
+                &cpu_port1
+                &cpu_port2>;
+    };
+
+    audio-codec-0 {
+        // ...
+
+        port {
+            codec0_endpoint: endpoint {
+                remote-endpoint = <&cpu_endpoint0>;
+            };
+        };
+    };
+
+    audio-codec-1 {
+        // ...
+
+        port {
+            codec1_endpoint: endpoint {
+                remote-endpoint = <&cpu_endpoint1>;
+            };
+        };
+    };
+
+    audio-codec-2 {
+        // ...
+
+        port {
+            codec2_endpoint: endpoint {
+                remote-endpoint = <&cpu_endpoint2>;
+            };
+        };
+    };
+
+    dai-controller {
+        // ...
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            cpu_port0: port@0 {
+                reg = <0>;
+
+                cpu_endpoint0: endpoint {
+                    remote-endpoint = <&codec0_endpoint>;
+
+                    dai-format = "left_j";
+
+                    // ...
+                };
+            };
+            cpu_port1: port@1 {
+                reg = <1>;
+
+                cpu_endpoint1: endpoint {
+                    remote-endpoint = <&codec1_endpoint>;
+
+                    dai-format = "i2s";
+
+                    // ...
+                };
+            };
+            cpu_port2: port@2 {
+                reg = <2>;
+
+                cpu_endpoint2: endpoint {
+                    remote-endpoint = <&codec2_endpoint>;
+
+                    dai-format = "i2s";
+
+                    // ...
+                };
+            };
+        };
+    };
+
+  # ------------------------
+  # Sampling Rate Conversion
+  # ------------------------
+  - |
+    sound_card {
+        compatible = "audio-graph-card";
+
+        label = "sound-card";
+        prefix = "codec";
+        routing = "codec Playback", "DAI0 Playback",
+                  "DAI0 Capture",   "codec Capture";
+        convert-rate = <48000>;
+
+        dais = <&cpu_port_src>;
+    };
+
+    audio-codec {
+        // ...
+
+        port {
+            codec_endpoint_src: endpoint {
+                remote-endpoint = <&cpu_endpoint_src>;
+            };
+        };
+    };
+
+    dai-controller {
+        // ...
+
+        cpu_port_src: port {
+            cpu_endpoint_src: endpoint {
+                remote-endpoint = <&codec_endpoint_src>;
+
+                dai-format = "left_j";
+
+                // ...
+            };
+        };
+    };
+
+  # ----------------------
+  # 2 CPU 1 Codec (Mixing)
+  # ----------------------
+  - |
+    sound_card {
+        compatible = "audio-graph-card";
+
+        label = "sound-card";
+        routing = "codec Playback", "DAI0 Playback",
+                  "codec Playback", "DAI1 Playback",
+                  "DAI0 Capture",   "codec Capture";
+
+        dais = <&cpu_port_mix>;
+    };
+
+    audio-codec {
+        // ...
+
+        audio-graph-card,prefix = "codec";
+        audio-graph-card,convert-rate = <48000>;
+
+        port {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            codec_endpoint0_mix: endpoint@0 {
+                reg = <0>;
+
+                remote-endpoint = <&cpu_endpoint0_mix>;
+            };
+            codec_endpoint1_mix: endpoint@1 {
+                reg = <1>;
+
+                remote-endpoint = <&cpu_endpoint1_mix>;
+            };
+        };
+    };
+
+    dai-controller {
+        // ...
+
+        cpu_port_mix: port {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            cpu_endpoint0_mix: endpoint@0 {
+                reg = <0>;
+
+                remote-endpoint = <&codec_endpoint0_mix>;
+
+                dai-format = "left_j";
+
+                // ...
+            };
+            cpu_endpoint1_mix: endpoint@1 {
+                reg = <1>;
+
+                remote-endpoint = <&codec_endpoint1_mix>;
+
+                dai-format = "left_j";
+
+                // ...
+            };
+        };
+    };
+
+  # -------------------
+  # Multi DAI with DPCM
+  #
+  #  CPU0 ------ ak4613
+  #  CPU1 ------ HDMI
+  #  CPU2 ------ PCM3168A-p    /* DPCM 1ch/2ch */
+  #  CPU3 --/                  /* DPCM 3ch/4ch */
+  #  CPU4 --/                  /* DPCM 5ch/6ch */
+  #  CPU5 --/                  /* DPCM 7ch/8ch */
+  #  CPU6 ------ PCM3168A-c
+  # -------------------
+  - |
+    sound_card: sound {
+        compatible = "audio-graph-card";
+
+        label = "sound-card";
+
+        routing = "pcm3168a Playback", "DAI2 Playback",
+                  "pcm3168a Playback", "DAI3 Playback",
+                  "pcm3168a Playback", "DAI4 Playback",
+                  "pcm3168a Playback", "DAI5 Playback";
+
+        dais = <&snd_port0    /* ak4613 */
+                &snd_port1    /* HDMI0  */
+                &snd_port2    /* pcm3168a playback */
+                &snd_port3    /* pcm3168a capture  */
+                >;
+    };
+
+    ak4613: codec-10 {
+        // ...
+
+        port {
+            ak4613_endpoint: endpoint {
+                remote-endpoint = <&rsnd_endpoint0>;
+            };
+        };
+    };
+
+    pcm3168a: audio-codec-44 {
+        // ...
+
+        audio-graph-card,prefix = "pcm3168a";
+        audio-graph-card,convert-channels = <8>; /* TDM Split */
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                reg = <0>;
+                pcm3168a_endpoint_p1: endpoint@1 {
+                    reg = <1>;
+                    remote-endpoint = <&rsnd_endpoint2>;
+
+                    // ...
+                };
+                pcm3168a_endpoint_p2: endpoint@2 {
+                    reg = <2>;
+                    remote-endpoint = <&rsnd_endpoint3>;
+
+                    // ...
+                };
+                pcm3168a_endpoint_p3: endpoint@3 {
+                    reg = <3>;
+                    remote-endpoint = <&rsnd_endpoint4>;
+
+                    // ...
+                };
+                pcm3168a_endpoint_p4: endpoint@4 {
+                    reg = <4>;
+                    remote-endpoint = <&rsnd_endpoint5>;
+
+                    // ...
+                };
+            };
+            port@1 {
+                reg = <1>;
+                pcm3168a_endpoint_c: endpoint {
+                    remote-endpoint = <&rsnd_endpoint6>;
+
+                    // ...
+                };
+            };
+        };
+    };
+
+    dai-controller {
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            snd_port0: port@0 {
+                reg = <0>;
+                rsnd_endpoint0: endpoint {
+                    remote-endpoint = <&ak4613_endpoint>;
+
+                    // ...
+                };
+            };
+            snd_port1: port@1 {
+                reg = <1>;
+                rsnd_endpoint1: endpoint {
+                    remote-endpoint = <&dw_hdmi0_snd_in>;
+
+                    // ...
+                };
+            };
+            snd_port2: port@2 {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                reg = <2>;
+                rsnd_endpoint2: endpoint@2 {
+                    reg = <2>;
+                    remote-endpoint = <&pcm3168a_endpoint_p1>;
+
+                    // ...
+                };
+                rsnd_endpoint3: endpoint@3 {
+                    reg = <3>;
+                    remote-endpoint = <&pcm3168a_endpoint_p2>;
+
+                    // ...
+                };
+                rsnd_endpoint4: endpoint@4 {
+                    reg = <4>;
+                    remote-endpoint = <&pcm3168a_endpoint_p3>;
+
+                    // ...
+                };
+                rsnd_endpoint5: endpoint@5 {
+                    reg = <5>;
+                    remote-endpoint = <&pcm3168a_endpoint_p4>;
+
+                    // ...
+                };
+            };
+            snd_port3: port@6 {
+                reg = <6>;
+                rsnd_endpoint6: endpoint {
+                    remote-endpoint = <&pcm3168a_endpoint_c>;
+
+                    // ...
+                };
+            };
+        };
+    };
+
+...
-- 
2.7.4


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

* [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (8 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert " Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-19 22:11   ` Rob Herring
  2020-10-16 14:42 ` [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card Sameer Pujar
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Add device tree binding properties of generic graph to ASoC component
devices. This allows to define audio ports out of these components or
DAIs and audio graph based sound card can be realised with this.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml  | 7 +++++++
 .../devicetree/bindings/sound/nvidia,tegra210-admaif.yaml          | 7 +++++++
 Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml  | 7 +++++++
 Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml  | 7 +++++++
 Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml   | 7 +++++++
 5 files changed, 35 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
index ed2fb32..23875b1 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
@@ -55,6 +55,13 @@ properties:
       The name can be "DSPK1" or "DSPKx", where x depends on the maximum
       available instances on a Tegra SoC.
 
+  ports:
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
+
 required:
   - compatible
   - reg
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
index c028b25..26ba725 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
@@ -37,6 +37,13 @@ properties:
 
   dma-names: true
 
+  ports:
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
+
 if:
   properties:
     compatible:
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
index d772197..d6aa849 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
@@ -56,6 +56,13 @@ properties:
 
   ranges: true
 
+  ports:
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
+
 required:
   - compatible
   - reg
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
index 2a3207b..36232ed 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
@@ -56,6 +56,13 @@ properties:
       The name can be "DMIC1" or "DMIC2" ... "DMICx", where x depends
       on the maximum available instances on a Tegra SoC.
 
+  ports:
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
+
 required:
   - compatible
   - reg
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml
index dfc1bf7..f5cdf33 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml
@@ -74,6 +74,13 @@ properties:
       The name can be "I2S1" or "I2S2" ... "I2Sx", where x depends
       on the maximum available instances on a Tegra SoC.
 
+  ports:
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
+
 required:
   - compatible
   - reg
-- 
2.7.4


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

* [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (9 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-19 22:16   ` Rob Herring
  2020-10-16 14:42 ` [PATCH v4 12/15] ASoC: tegra: Add audio graph based card driver Sameer Pujar
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
same DT bindings provided by generic audio graph driver. Along with this
few standard clock DT bindings are added which are specifically required
for Tegra audio.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 .../sound/nvidia,tegra-audio-graph-card.yaml       | 158 +++++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
new file mode 100644
index 0000000..284d185
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
@@ -0,0 +1,158 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Audio Graph based Tegra sound card driver
+
+description: |
+  This is based on generic audio graph card driver along with additional
+  customizations for Tegra platforms. It uses the same bindings with
+  additional standard clock DT bindings required for Tegra.
+
+  See{LINUX}/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
+
+maintainers:
+  - Jon Hunter <jonathanh@nvidia.com>
+  - Sameer Pujar <spujar@nvidia.com>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - nvidia,tegra210-audio-graph-card
+          - nvidia,tegra186-audio-graph-card
+
+  dais:
+    $ref: /schemas/sound/audio-graph-card.yaml#/properties/dais
+
+  label:
+    $ref: /schemas/sound/simple-card.yaml#/properties/label
+
+  pa-gpios:
+    $ref: /schemas/sound/audio-graph-card.yaml#/properties/pa-gpios
+
+  widgets:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/widgets
+
+  routing:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/routing
+
+  mclk-fs:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
+
+  prefix:
+    $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
+
+  clocks:
+   minItems: 2
+
+  clock-names:
+   minItems: 2
+   items:
+     - const: pll_a
+     - const: plla_out0
+
+  assigned-clocks:
+    minItems: 1
+    maxItems: 3
+
+  assigned-clock-parents:
+    minItems: 1
+    maxItems: 3
+
+  assigned-clock-rates:
+    minItems: 1
+    maxItems: 3
+
+  ports:
+    $ref: /schemas/sound/audio-graph-card.yaml#/properties/ports
+
+patternProperties:
+  "^port(@[0-9a-f]+)?$":
+    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
+
+additionalProperties: false
+
+required:
+  - compatible
+  - dais
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+
+examples:
+  - |
+    #include<dt-bindings/clock/tegra210-car.h>
+
+    tegra_sound {
+        compatible = "nvidia,tegra210-audio-graph-card";
+
+        clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
+                 <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
+        clock-names = "pll_a", "plla_out0";
+
+        assigned-clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
+                          <&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
+                          <&tegra_car TEGRA210_CLK_EXTERN1>;
+        assigned-clock-parents = <0>, <0>, <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
+        assigned-clock-rates = <368640000>, <49152000>, <12288000>;
+
+        dais = /* FE */
+               <&admaif1_port>,
+               /* Router */
+               <&xbar_i2s1_port>,
+               /* I/O DAP Ports */
+               <&i2s1_port>;
+
+        label = "jetson-tx1-ape";
+    };
+
+    tegra_ahub: ahub@702d0800 {
+        // ...
+
+        reg = <0x702d0800 0x800>;
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            xbar_i2s1_port: port@a {
+                reg = <0xa>;
+                xbar_i2s1_ep: endpoint {
+                    remote-endpoint = <&i2s1_cif_ep>;
+                };
+            };
+        };
+    };
+
+    tegra_i2s1: i2s@702d1000 {
+        // ...
+
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        reg = <0x702d1000 0x100>;
+
+        port@0 {
+            reg = <0>;
+
+            i2s1_cif_ep: endpoint {
+                remote-endpoint = <&xbar_i2s1_ep>;
+            };
+        };
+
+        i2s1_port: port@1 {
+            reg = <1>;
+
+            i2s1_dap: endpoint {
+                dai-format = "i2s";
+
+                // ...
+            };
+        };
+    };
+
+...
-- 
2.7.4


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

* [PATCH v4 12/15] ASoC: tegra: Add audio graph based card driver
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (10 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card Sameer Pujar
@ 2020-10-16 14:42 ` Sameer Pujar
  2020-10-16 14:43 ` [PATCH v4 13/15] arm64: defconfig: Enable Tegra audio graph " Sameer Pujar
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:42 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Add Tegra audio machine driver which is based on generic audio graph card
driver. It re-uses most of the common stuff from audio graph driver and
uses the same DT binding. Required Tegra specific customizations are done
in the driver and additional DT bindings are required for clock handling.

Details on the customizations done:

 - Update PLL rates at runtime: Tegra HW supports multiple sample rates
   (multiples of 8x and 11.025x) and both of these groups require different
   PLL rates. Hence there is a requirement to update this at runtime.
   This is achieved by providing a custom 'snd_soc_ops' and in hw_param()
   callback PLL rate is updated as per the sample rate.

 - Internal structure 'tegra_audio_graph_data' is used to maintain clock
   handles of PLL.

 - The 'force_dpcm' flag is set to use DPCM for all DAI links.

 - The 'component_chaining' flag is set to use DPCM with component model.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 sound/soc/tegra/Kconfig                  |   9 ++
 sound/soc/tegra/Makefile                 |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c | 255 +++++++++++++++++++++++++++++++
 3 files changed, 266 insertions(+)
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index 3d91bd3..9959605 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -118,6 +118,15 @@ config SND_SOC_TEGRA210_ADMAIF
 	  channel. Buffer size is configurable for each ADMAIIF channel.
 	  Say Y or M if you want to add support for Tegra210 ADMAIF module.
 
+config SND_SOC_TEGRA_AUDIO_GRAPH_CARD
+	tristate "Audio Graph Card based Tegra driver"
+	depends on SND_AUDIO_GRAPH_CARD
+	help
+	  Config to enable Tegra audio machine driver based on generic
+	  audio graph driver. It is a thin driver written to customize
+	  few things for Tegra audio. Most of the code is re-used from
+	  audio graph driver and the same DT bindings are used.
+
 config SND_SOC_TEGRA_RT5640
 	tristate "SoC Audio support for Tegra boards using an RT5640 codec"
 	depends on SND_SOC_TEGRA && I2C && GPIOLIB
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 60040a0..b17dd6e 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -38,6 +38,7 @@ snd-soc-tegra-trimslice-objs := trimslice.o
 snd-soc-tegra-alc5632-objs := tegra_alc5632.o
 snd-soc-tegra-max98090-objs := tegra_max98090.o
 snd-soc-tegra-sgtl5000-objs := tegra_sgtl5000.o
+snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o
 
 obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o
 obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o
@@ -48,3 +49,4 @@ obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o
 obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
 obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
 obj-$(CONFIG_SND_SOC_TEGRA_SGTL5000) += snd-soc-tegra-sgtl5000.o
+obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += snd-soc-tegra-audio-graph-card.o
diff --git a/sound/soc/tegra/tegra_audio_graph_card.c b/sound/soc/tegra/tegra_audio_graph_card.c
new file mode 100644
index 0000000..f4d826d
--- /dev/null
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
+//
+// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+
+#include <linux/math64.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <sound/graph_card.h>
+#include <sound/pcm_params.h>
+
+#define MAX_PLLA_OUT0_DIV 128
+
+#define simple_to_tegra_priv(simple) \
+		container_of(simple, struct tegra_audio_priv, simple)
+
+enum srate_type {
+	/*
+	 * Sample rates multiple of 8000 Hz and below are supported:
+	 * ( 8000, 16000, 32000, 48000, 96000, 192000 Hz )
+	 */
+	x8_RATE,
+
+	/*
+	 * Sample rates multiple of 11025 Hz and below are supported:
+	 * ( 11025, 22050, 44100, 88200, 176400 Hz )
+	 */
+	x11_RATE,
+
+	NUM_RATE_TYPE,
+};
+
+struct tegra_audio_priv {
+	struct asoc_simple_priv simple;
+	struct clk *clk_plla_out0;
+	struct clk *clk_plla;
+};
+
+/* Tegra audio chip data */
+struct tegra_audio_cdata {
+	unsigned int plla_rates[NUM_RATE_TYPE];
+	unsigned int plla_out0_rates[NUM_RATE_TYPE];
+};
+
+/* Setup PLL clock as per the given sample rate */
+static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
+					struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(rtd->card);
+	struct tegra_audio_priv *priv = simple_to_tegra_priv(simple);
+	struct device *dev = rtd->card->dev;
+	const struct tegra_audio_cdata *data = of_device_get_match_data(dev);
+	unsigned int plla_rate, plla_out0_rate, bclk;
+	unsigned int srate = params_rate(params);
+	int err;
+
+	/* There is nothing to configure */
+	if (!data)
+		return 0;
+
+	switch (srate) {
+	case 11025:
+	case 22050:
+	case 44100:
+	case 88200:
+	case 176400:
+		plla_out0_rate = data->plla_out0_rates[x11_RATE];
+		plla_rate = data->plla_rates[x11_RATE];
+		break;
+	case 8000:
+	case 16000:
+	case 32000:
+	case 48000:
+	case 96000:
+	case 192000:
+		plla_out0_rate = data->plla_out0_rates[x8_RATE];
+		plla_rate = data->plla_rates[x8_RATE];
+		break;
+	default:
+		dev_err(rtd->card->dev, "Unsupported sample rate %u\n",
+			srate);
+		return -EINVAL;
+	}
+
+	/*
+	 * Below is the clock relation:
+	 *
+	 *	PLLA
+	 *	  |
+	 *	  |--> PLLA_OUT0
+	 *		  |
+	 *		  |---> I2S modules
+	 *		  |
+	 *		  |---> DMIC modules
+	 *		  |
+	 *		  |---> DSPK modules
+	 *
+	 *
+	 * Default PLLA_OUT0 rate might be too high when I/O is running
+	 * at minimum PCM configurations. This may result in incorrect
+	 * clock rates and glitchy audio. The maximum divider is 128
+	 * and any thing higher than that won't work. Thus reduce PLLA_OUT0
+	 * to work for lower configurations.
+	 *
+	 * This problem is seen for I2S only, as DMIC and DSPK minimum
+	 * clock requirements are under allowed divider limits.
+	 */
+	bclk = srate * params_channels(params) * params_width(params);
+	if (div_u64(plla_out0_rate, bclk) > MAX_PLLA_OUT0_DIV)
+		plla_out0_rate >>= 1;
+
+	dev_dbg(rtd->card->dev,
+		"Update clock rates: PLLA(= %u Hz) and PLLA_OUT0(= %u Hz)\n",
+		plla_rate, plla_out0_rate);
+
+	/* Set PLLA rate */
+	err = clk_set_rate(priv->clk_plla, plla_rate);
+	if (err) {
+		dev_err(rtd->card->dev,
+			"Can't set plla rate for %u, err: %d\n",
+			plla_rate, err);
+		return err;
+	}
+
+	/* Set PLLA_OUT0 rate */
+	err = clk_set_rate(priv->clk_plla_out0, plla_out0_rate);
+	if (err) {
+		dev_err(rtd->card->dev,
+			"Can't set plla_out0 rate %u, err: %d\n",
+			plla_out0_rate, err);
+		return err;
+	}
+
+	return err;
+}
+
+static int tegra_audio_graph_hw_params(struct snd_pcm_substream *substream,
+				       struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+	int err;
+
+	/*
+	 * This gets called for each DAI link (FE or BE) when DPCM is used.
+	 * We may not want to update PLLA rate for each call. So PLLA update
+	 * must be restricted to external I/O links (I2S, DMIC or DSPK) since
+	 * they actually depend on it. I/O modules update their clocks in
+	 * hw_param() of their respective component driver and PLLA rate
+	 * update here helps them to derive appropriate rates.
+	 *
+	 * TODO: When more HW accelerators get added (like sample rate
+	 * converter, volume gain controller etc., which don't really
+	 * depend on PLLA) we need a better way to filter here.
+	 */
+	if (cpu_dai->driver->ops && rtd->dai_link->no_pcm) {
+		err = tegra_audio_graph_update_pll(substream, params);
+		if (err)
+			return err;
+	}
+
+	return asoc_simple_hw_params(substream, params);
+}
+
+static const struct snd_soc_ops tegra_audio_graph_ops = {
+	.startup	= asoc_simple_startup,
+	.shutdown	= asoc_simple_shutdown,
+	.hw_params	= tegra_audio_graph_hw_params,
+};
+
+static int tegra_audio_graph_card_probe(struct snd_soc_card *card)
+{
+	struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(card);
+	struct tegra_audio_priv *priv = simple_to_tegra_priv(simple);
+
+	priv->clk_plla = devm_clk_get(card->dev, "pll_a");
+	if (IS_ERR(priv->clk_plla)) {
+		dev_err(card->dev, "Can't retrieve clk pll_a\n");
+		return PTR_ERR(priv->clk_plla);
+	}
+
+	priv->clk_plla_out0 = devm_clk_get(card->dev, "plla_out0");
+	if (IS_ERR(priv->clk_plla_out0)) {
+		dev_err(card->dev, "Can't retrieve clk plla_out0\n");
+		return PTR_ERR(priv->clk_plla_out0);
+	}
+
+	return graph_card_probe(card);
+}
+
+static int tegra_audio_graph_probe(struct platform_device *pdev)
+{
+	struct tegra_audio_priv *priv;
+	struct device *dev = &pdev->dev;
+	struct snd_soc_card *card;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	card = simple_priv_to_card(&priv->simple);
+
+	card->probe = tegra_audio_graph_card_probe;
+
+	/* graph_parse_of() depends on below */
+	card->component_chaining = 1;
+	priv->simple.ops = &tegra_audio_graph_ops;
+	priv->simple.force_dpcm = 1;
+
+	return graph_parse_of(&priv->simple, dev);
+}
+
+static const struct tegra_audio_cdata tegra210_data = {
+	/* PLLA */
+	.plla_rates[x8_RATE] = 368640000,
+	.plla_rates[x11_RATE] = 338688000,
+	/* PLLA_OUT0 */
+	.plla_out0_rates[x8_RATE] = 49152000,
+	.plla_out0_rates[x11_RATE] = 45158400,
+};
+
+static const struct tegra_audio_cdata tegra186_data = {
+	/* PLLA */
+	.plla_rates[x8_RATE] = 245760000,
+	.plla_rates[x11_RATE] = 270950400,
+	/* PLLA_OUT0 */
+	.plla_out0_rates[x8_RATE] = 49152000,
+	.plla_out0_rates[x11_RATE] = 45158400,
+};
+
+static const struct of_device_id graph_of_tegra_match[] = {
+	{ .compatible = "nvidia,tegra210-audio-graph-card",
+	  .data = &tegra210_data },
+	{ .compatible = "nvidia,tegra186-audio-graph-card",
+	  .data = &tegra186_data },
+	{},
+};
+MODULE_DEVICE_TABLE(of, graph_of_tegra_match);
+
+static struct platform_driver tegra_audio_graph_card = {
+	.driver = {
+		.name = "tegra-audio-graph-card",
+		.pm = &snd_soc_pm_ops,
+		.of_match_table = graph_of_tegra_match,
+	},
+	.probe = tegra_audio_graph_probe,
+};
+module_platform_driver(tegra_audio_graph_card);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("ASoC Tegra Audio Graph Sound Card");
+MODULE_AUTHOR("Sameer Pujar <spujar@nvidia.com>");
-- 
2.7.4


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

* [PATCH v4 13/15] arm64: defconfig: Enable Tegra audio graph card driver
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (11 preceding siblings ...)
  2020-10-16 14:42 ` [PATCH v4 12/15] ASoC: tegra: Add audio graph based card driver Sameer Pujar
@ 2020-10-16 14:43 ` Sameer Pujar
  2020-10-16 14:43 ` [PATCH v4 14/15] arm64: tegra: Audio graph header for Tegra210 Sameer Pujar
  2020-10-16 14:43 ` [PATCH v4 15/15] arm64: tegra: Audio graph sound card for Jetson Nano and TX1 Sameer Pujar
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:43 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

This commit enables Tegra audio graph card driver which is based on
the generic audio-graph card driver. This is intended to be used
on platforms based on Tegra210 and later chips.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 17a2df6..903fba8 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -713,6 +713,7 @@ CONFIG_SND_SOC_TEGRA210_DMIC=m
 CONFIG_SND_SOC_TEGRA210_I2S=m
 CONFIG_SND_SOC_TEGRA186_DSPK=m
 CONFIG_SND_SOC_TEGRA210_ADMAIF=m
+CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
-- 
2.7.4


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

* [PATCH v4 14/15] arm64: tegra: Audio graph header for Tegra210
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (12 preceding siblings ...)
  2020-10-16 14:43 ` [PATCH v4 13/15] arm64: defconfig: Enable Tegra audio graph " Sameer Pujar
@ 2020-10-16 14:43 ` Sameer Pujar
  2020-10-16 14:43 ` [PATCH v4 15/15] arm64: tegra: Audio graph sound card for Jetson Nano and TX1 Sameer Pujar
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:43 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Expose a header which describes DT bindings required to use audio-graph
based sound card. All Tegra210 based platforms can include this header
and add platform specific information. Currently, from SoC point of view,
all links are exposed for ADMAIF, AHUB, I2S and DMIC components.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi      | 153 +++++++++++++++++++++
 1 file changed, 153 insertions(+)
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
new file mode 100644
index 0000000..5c54358
--- /dev/null
+++ b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/ {
+	tegra_sound {
+		status = "disabled";
+
+		clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
+			 <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
+		clock-names = "pll_a", "plla_out0";
+
+		assigned-clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
+				  <&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
+				  <&tegra_car TEGRA210_CLK_EXTERN1>;
+		assigned-clock-parents = <0>, <0>, <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
+		assigned-clock-rates = <368640000>, <49152000>, <12288000>;
+	};
+};
+
+&tegra_admaif {
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		admaif1_port: port@0 {
+			reg = <0>;
+			admaif1_ep: endpoint {
+				remote-endpoint = <&xbar_admaif1_ep>;
+			};
+		};
+		admaif2_port: port@1 {
+			reg = <1>;
+			admaif2_ep: endpoint {
+				remote-endpoint = <&xbar_admaif2_ep>;
+			};
+		};
+		admaif3_port: port@2 {
+			reg = <2>;
+			admaif3_ep: endpoint {
+				remote-endpoint = <&xbar_admaif3_ep>;
+			};
+		};
+		admaif4_port: port@3 {
+			reg = <3>;
+			admaif4_ep: endpoint {
+				remote-endpoint = <&xbar_admaif4_ep>;
+			};
+		};
+		admaif5_port: port@4 {
+			reg = <4>;
+			admaif5_ep: endpoint {
+				remote-endpoint = <&xbar_admaif5_ep>;
+			};
+		};
+		admaif6_port: port@5 {
+			reg = <5>;
+			admaif6_ep: endpoint {
+				remote-endpoint = <&xbar_admaif6_ep>;
+			};
+		};
+		admaif7_port: port@6 {
+			reg = <6>;
+			admaif7_ep: endpoint {
+				remote-endpoint = <&xbar_admaif7_ep>;
+			};
+		};
+		admaif8_port: port@7 {
+			reg = <7>;
+			admaif8_ep: endpoint {
+				remote-endpoint = <&xbar_admaif8_ep>;
+			};
+		};
+		admaif9_port: port@8 {
+			reg = <8>;
+			admaif9_ep: endpoint {
+				remote-endpoint = <&xbar_admaif9_ep>;
+			};
+		};
+		admaif10_port: port@9 {
+			reg = <9>;
+			admaif10_ep: endpoint {
+				remote-endpoint = <&xbar_admaif10_ep>;
+			};
+		};
+	};
+};
+
+&tegra_ahub {
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0x0>;
+			xbar_admaif1_ep: endpoint {
+				remote-endpoint = <&admaif1_ep>;
+			};
+		};
+		port@1 {
+			reg = <0x1>;
+			xbar_admaif2_ep: endpoint {
+				remote-endpoint = <&admaif2_ep>;
+			};
+		};
+		port@2 {
+			reg = <0x2>;
+			xbar_admaif3_ep: endpoint {
+				remote-endpoint = <&admaif3_ep>;
+			};
+		};
+		port@3 {
+			reg = <0x3>;
+			xbar_admaif4_ep: endpoint {
+				remote-endpoint = <&admaif4_ep>;
+			};
+		};
+		port@4 {
+			reg = <0x4>;
+			xbar_admaif5_ep: endpoint {
+				remote-endpoint = <&admaif5_ep>;
+			};
+		};
+		port@5 {
+			reg = <0x5>;
+			xbar_admaif6_ep: endpoint {
+				remote-endpoint = <&admaif6_ep>;
+			};
+		};
+		port@6 {
+			reg = <0x6>;
+			xbar_admaif7_ep: endpoint {
+				remote-endpoint = <&admaif7_ep>;
+			};
+		};
+		port@7 {
+			reg = <0x7>;
+			xbar_admaif8_ep: endpoint {
+				remote-endpoint = <&admaif8_ep>;
+			};
+		};
+		port@8 {
+			reg = <0x8>;
+			xbar_admaif9_ep: endpoint {
+				remote-endpoint = <&admaif9_ep>;
+			};
+		};
+		port@9 {
+			reg = <0x9>;
+			xbar_admaif10_ep: endpoint {
+				remote-endpoint = <&admaif10_ep>;
+			};
+		};
+	};
+};
-- 
2.7.4


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

* [PATCH v4 15/15] arm64: tegra: Audio graph sound card for Jetson Nano and TX1
  2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
                   ` (13 preceding siblings ...)
  2020-10-16 14:43 ` [PATCH v4 14/15] arm64: tegra: Audio graph header for Tegra210 Sameer Pujar
@ 2020-10-16 14:43 ` Sameer Pujar
  14 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-16 14:43 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, kuninori.morimoto.gx,
	pierre-louis.bossart, perex, tiwai, p.zabel, thierry.reding,
	jonathanh
  Cc: alsa-devel, devicetree, linux-tegra, linux-kernel, sharadg,
	mkumard, viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	swarren, nicoleotsuka, Sameer Pujar

Enable support for audio-graph based sound card on Jetson-Nano and
Jetson-TX1. Depending on the platform, required I/O interfaces are
enabled.

 * Jetson-Nano: Enable I2S3, I2S4, DMIC1 and DMIC2.
 * Jetson-TX1: Enable all I2S and DMIC interfaces.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +++++++++++++++++++++
 arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts | 146 ++++++++++++
 2 files changed, 408 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
index 4c9c2a0..dab24b4 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
@@ -3,6 +3,7 @@
 
 #include "tegra210-p2180.dtsi"
 #include "tegra210-p2597.dtsi"
+#include "tegra210-audio-graph.dtsi"
 
 / {
 	model = "NVIDIA Jetson TX1 Developer Kit";
@@ -127,4 +128,265 @@
 			status = "okay";
 		};
 	};
+
+	tegra_sound {
+		status = "okay";
+
+		compatible = "nvidia,tegra210-audio-graph-card";
+
+		dais = /* FE */
+		       <&admaif1_port>, <&admaif2_port>, <&admaif3_port>,
+		       <&admaif4_port>, <&admaif5_port>, <&admaif6_port>,
+		       <&admaif7_port>, <&admaif8_port>, <&admaif9_port>,
+		       <&admaif10_port>,
+		       /* Router */
+		       <&xbar_i2s1_port>, <&xbar_i2s2_port>, <&xbar_i2s3_port>,
+		       <&xbar_i2s4_port>, <&xbar_i2s5_port>, <&xbar_dmic1_port>,
+		       <&xbar_dmic2_port>, <&xbar_dmic3_port>,
+		       /* I/O DAP Ports */
+		       <&i2s1_port>, <&i2s2_port>, <&i2s3_port>, <&i2s4_port>,
+		       <&i2s5_port>, <&dmic1_port>, <&dmic2_port>, <&dmic3_port>;
+
+		label = "jetson-tx1-ape";
+	};
+};
+
+&tegra_admaif {
+	status = "okay";
+};
+
+&tegra_ahub {
+	status = "okay";
+
+	ports {
+		xbar_i2s1_port: port@a {
+			reg = <0xa>;
+			xbar_i2s1_ep: endpoint {
+				remote-endpoint = <&i2s1_cif_ep>;
+			};
+		};
+		xbar_i2s2_port: port@b {
+			reg = <0xb>;
+			xbar_i2s2_ep: endpoint {
+				remote-endpoint = <&i2s2_cif_ep>;
+			};
+		};
+		xbar_i2s3_port: port@c {
+			reg = <0xc>;
+			xbar_i2s3_ep: endpoint {
+				remote-endpoint = <&i2s3_cif_ep>;
+			};
+		};
+		xbar_i2s4_port: port@d {
+			reg = <0xd>;
+			xbar_i2s4_ep: endpoint {
+				remote-endpoint = <&i2s4_cif_ep>;
+			};
+		};
+		xbar_i2s5_port: port@e {
+			reg = <0xe>;
+			xbar_i2s5_ep: endpoint {
+				remote-endpoint = <&i2s5_cif_ep>;
+			};
+		};
+		xbar_dmic1_port: port@f {
+			reg = <0xf>;
+			xbar_dmic1_ep: endpoint {
+				remote-endpoint = <&dmic1_cif_ep>;
+			};
+		};
+		xbar_dmic2_port: port@10 {
+			reg = <0x10>;
+			xbar_dmic2_ep: endpoint {
+				remote-endpoint = <&dmic2_cif_ep>;
+			};
+		};
+		xbar_dmic3_port: port@11 {
+			reg = <0x11>;
+			xbar_dmic3_ep: endpoint {
+				remote-endpoint = <&dmic3_cif_ep>;
+			};
+		};
+	};
+};
+
+&tegra_i2s1 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s1_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s1_ep>;
+			};
+		};
+		i2s1_port: port@1 {
+			reg = <1>;
+			i2s1_dap: endpoint {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_i2s2 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s2_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s2_ep>;
+			};
+		};
+		i2s2_port: port@1 {
+			reg = <1>;
+			i2s2_dap: endpoint {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_i2s3 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s3_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s3_ep>;
+			};
+		};
+		i2s3_port: port@1 {
+			reg = <1>;
+			i2s3_dap_ep: endpoint {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_i2s4 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s4_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s4_ep>;
+			};
+		};
+		i2s4_port: port@1 {
+			reg = <1>;
+			i2s4_dap: endpoint {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_i2s5 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s5_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s5_ep>;
+			};
+		};
+		i2s5_port: port@1 {
+			reg = <1>;
+			i2s5_dap: endpoint {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_dmic1 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			dmic1_cif_ep: endpoint {
+				remote-endpoint = <&xbar_dmic1_ep>;
+			};
+		};
+		dmic1_port: port@1 {
+			reg = <1>;
+			dmic1_dap: endpoint {
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_dmic2 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			dmic2_cif_ep: endpoint {
+				remote-endpoint = <&xbar_dmic2_ep>;
+			};
+		};
+		dmic2_port: port@1 {
+			reg = <1>;
+			dmic2_dap: endpoint {
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_dmic3 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			dmic3_cif_ep: endpoint {
+				remote-endpoint = <&xbar_dmic3_ep>;
+			};
+		};
+		dmic3_port: port@1 {
+			reg = <1>;
+			dmic3_dap: endpoint {
+				/* Placeholder for external Codec */
+			};
+		};
+	};
 };
diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts b/arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts
index 859241d..1216b65c8 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts
@@ -6,6 +6,7 @@
 #include <dt-bindings/mfd/max77620.h>
 
 #include "tegra210.dtsi"
+#include "tegra210-audio-graph.dtsi"
 
 / {
 	model = "NVIDIA Jetson Nano Developer Kit";
@@ -870,4 +871,149 @@
 
 		vin-supply = <&vdd_5v0_sys>;
 	};
+
+	tegra_sound {
+		status = "okay";
+
+		compatible = "nvidia,tegra210-audio-graph-card";
+
+		dais = /* FE */
+		       <&admaif1_port>, <&admaif2_port>, <&admaif3_port>,
+		       <&admaif4_port>, <&admaif5_port>, <&admaif6_port>,
+		       <&admaif7_port>, <&admaif8_port>, <&admaif9_port>,
+		       <&admaif10_port>,
+		       /* Router */
+		       <&xbar_i2s3_port>, <&xbar_i2s4_port>,
+		       <&xbar_dmic1_port>, <&xbar_dmic2_port>,
+		       /* I/O DAP Ports */
+		       <&i2s3_port>, <&i2s4_port>,
+		       <&dmic1_port>, <&dmic2_port>;
+
+		label = "jetson-nano-ape";
+	};
+};
+
+&tegra_admaif {
+	status = "okay";
+};
+
+&tegra_ahub {
+	status = "okay";
+
+	ports {
+		xbar_i2s3_port: port@c {
+			reg = <0xc>;
+			xbar_i2s3_ep: endpoint {
+				remote-endpoint = <&i2s3_cif_ep>;
+			};
+		};
+		xbar_i2s4_port: port@d {
+			reg = <0xd>;
+			xbar_i2s4_ep: endpoint {
+				remote-endpoint = <&i2s4_cif_ep>;
+			};
+		};
+		xbar_dmic1_port: port@f {
+			reg = <0xf>;
+			xbar_dmic1_ep: endpoint {
+				remote-endpoint = <&dmic1_cif_ep>;
+			};
+		};
+		xbar_dmic2_port: port@10 {
+			reg = <0x10>;
+			xbar_dmic2_ep: endpoint {
+				remote-endpoint = <&dmic2_cif_ep>;
+			};
+		};
+	};
+};
+
+&tegra_i2s3 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s3_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s3_ep>;
+			};
+		};
+		i2s3_port: port@1 {
+			reg = <1>;
+			i2s3_dap_ep: endpoint {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_i2s4 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			i2s4_cif_ep: endpoint {
+				remote-endpoint = <&xbar_i2s4_ep>;
+			};
+		};
+		i2s4_port: port@1 {
+			reg = <1>;
+			i2s4_dap: endpoint@0 {
+				dai-format = "i2s";
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_dmic1 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			dmic1_cif_ep: endpoint@0 {
+				remote-endpoint = <&xbar_dmic1_ep>;
+			};
+		};
+		dmic1_port: port@1 {
+			reg = <1>;
+			dmic1_dap: endpoint@0 {
+				/* Placeholder for external Codec */
+			};
+		};
+	};
+};
+
+&tegra_dmic2 {
+	status = "okay";
+
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			dmic2_cif_ep: endpoint@0 {
+				remote-endpoint = <&xbar_dmic2_ep>;
+			};
+		};
+		dmic2_port: port@1 {
+			reg = <1>;
+			dmic2_dap: endpoint@0 {
+				/* Placeholder for external Codec */
+			};
+		};
+	};
 };
-- 
2.7.4


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

* Re: [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert bindings to json-schema
  2020-10-16 14:42 ` [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert " Sameer Pujar
@ 2020-10-19  2:50   ` Kuninori Morimoto
  2020-10-19  4:30     ` Sameer Pujar
  0 siblings, 1 reply; 29+ messages in thread
From: Kuninori Morimoto @ 2020-10-19  2:50 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: broonie, lgirdwood, robh+dt, pierre-louis.bossart, perex, tiwai,
	p.zabel, thierry.reding, jonathanh, alsa-devel, devicetree,
	linux-tegra, linux-kernel, sharadg, mkumard, viswanathl,
	rlokhande, dramesh, atalambedu, nwartikar, swarren, nicoleotsuka


Hi Sameer


> Convert device tree bindings of audio graph card to YAML format. Also
> expose some common definitions which can be used by similar graph based
> audio sound cards.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---

I'm posting this patch to Rob & DT ML.
Not yet accepted, though..

>  .../devicetree/bindings/sound/audio-graph-card.txt | 337 -------------
>  .../bindings/sound/audio-graph-card.yaml           | 548 +++++++++++++++++++++
>  2 files changed, 548 insertions(+), 337 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card.txt
>  create mode 100644 Documentation/devicetree/bindings/sound/audio-graph-card.yaml
> 
> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card.txt b/Documentation/devicetree/bindings/sound/audio-graph-card.txt
> deleted file mode 100644
> index d5f6919..0000000
> --- a/Documentation/devicetree/bindings/sound/audio-graph-card.txt
> +++ /dev/null
> @@ -1,337 +0,0 @@
> -Audio Graph Card:
> -
> -Audio Graph Card specifies audio DAI connections of SoC <-> codec.
> -It is based on common bindings for device graphs.
> -see ${LINUX}/Documentation/devicetree/bindings/graph.txt
> -
> -Basically, Audio Graph Card property is same as Simple Card.
> -see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.yaml
> -
> -Below are same as Simple-Card.
> -
> -- label
> -- widgets
> -- routing
> -- dai-format
> -- frame-master
> -- bitclock-master
> -- bitclock-inversion
> -- frame-inversion
> -- mclk-fs
> -- hp-det-gpio
> -- mic-det-gpio
> -- dai-tdm-slot-num
> -- dai-tdm-slot-width
> -- clocks / system-clock-frequency
> -
> -Required properties:
> -
> -- compatible				: "audio-graph-card";
> -- dais					: list of CPU DAI port{s}
> -
> -Optional properties:
> -- pa-gpios: GPIO used to control external amplifier.
> -
> ------------------------
> -Example: Single DAI case
> ------------------------
> -
> -	sound_card {
> -		compatible = "audio-graph-card";
> -
> -		dais = <&cpu_port>;
> -	};
> -
> -	dai-controller {
> -		...
> -		cpu_port: port {
> -			cpu_endpoint: endpoint {
> -				remote-endpoint = <&codec_endpoint>;
> -
> -				dai-format = "left_j";
> -				...
> -			};
> -		};
> -	};
> -
> -	audio-codec {
> -		...
> -		port {
> -			codec_endpoint: endpoint {
> -				remote-endpoint = <&cpu_endpoint>;
> -			};
> -		};
> -	};
> -
> ------------------------
> -Example: Multi DAI case
> ------------------------
> -
> -	sound-card {
> -		compatible = "audio-graph-card";
> -
> -		label = "sound-card";
> -
> -		dais = <&cpu_port0
> -			&cpu_port1
> -			&cpu_port2>;
> -	};
> -
> -	audio-codec@0 {
> -		...
> -		port {
> -			codec0_endpoint: endpoint {
> -				remote-endpoint = <&cpu_endpoint0>;
> -			};
> -		};
> -	};
> -
> -	audio-codec@1 {
> -		...
> -		port {
> -			codec1_endpoint: endpoint {
> -				remote-endpoint = <&cpu_endpoint1>;
> -			};
> -		};
> -	};
> -
> -	audio-codec@2 {
> -		...
> -		port {
> -			codec2_endpoint: endpoint {
> -				remote-endpoint = <&cpu_endpoint2>;
> -			};
> -		};
> -	};
> -
> -	dai-controller {
> -		...
> -		ports {
> -			cpu_port0: port@0 {
> -				cpu_endpoint0: endpoint {
> -					remote-endpoint = <&codec0_endpoint>;
> -
> -					dai-format = "left_j";
> -					...
> -				};
> -			};
> -			cpu_port1: port@1 {
> -				cpu_endpoint1: endpoint {
> -					remote-endpoint = <&codec1_endpoint>;
> -
> -					dai-format = "i2s";
> -					...
> -				};
> -			};
> -			cpu_port2: port@2 {
> -				cpu_endpoint2: endpoint {
> -					remote-endpoint = <&codec2_endpoint>;
> -
> -					dai-format = "i2s";
> -					...
> -				};
> -			};
> -		};
> -	};
> -
> -
> ------------------------
> -Example: Sampling Rate Conversion
> ------------------------
> -
> -	sound_card {
> -		compatible = "audio-graph-card";
> -
> -		label = "sound-card";
> -		prefix = "codec";
> -		routing = "codec Playback", "DAI0 Playback",
> -			  "DAI0 Capture",   "codec Capture";
> -		convert-rate = <48000>;
> -
> -		dais = <&cpu_port>;
> -	};
> -
> -	audio-codec {
> -		...
> -		port {
> -			codec_endpoint: endpoint {
> -				remote-endpoint = <&cpu_endpoint>;
> -			};
> -		};
> -	};
> -
> -	dai-controller {
> -		...
> -		cpu_port: port {
> -			cpu_endpoint: endpoint {
> -				remote-endpoint = <&codec_endpoint>;
> -
> -				dai-format = "left_j";
> -				...
> -			};
> -		};
> -	};
> -
> ------------------------
> -Example: 2 CPU 1 Codec (Mixing)
> ------------------------
> -
> -	sound_card {
> -		compatible = "audio-graph-card";
> -
> -		label = "sound-card";
> -		routing = "codec Playback", "DAI0 Playback",
> -			  "codec Playback", "DAI1 Playback",
> -			  "DAI0 Capture",   "codec Capture";
> -
> -		dais = <&cpu_port>;
> -	};
> -
> -	audio-codec {
> -		...
> -
> -		audio-graph-card,prefix = "codec";
> -		audio-graph-card,convert-rate = <48000>;
> -		port {
> -			reg = <0>;
> -			codec_endpoint0: endpoint@0 {
> -				remote-endpoint = <&cpu_endpoint0>;
> -			};
> -			codec_endpoint1: endpoint@1 {
> -				remote-endpoint = <&cpu_endpoint1>;
> -			};
> -		};
> -	};
> -
> -	dai-controller {
> -		...
> -		cpu_port: port {
> -			cpu_endpoint0: endpoint@0 {
> -				remote-endpoint = <&codec_endpoint0>;
> -
> -				dai-format = "left_j";
> -				...
> -			};
> -			cpu_endpoint1: endpoint@1 {
> -				remote-endpoint = <&codec_endpoint1>;
> -
> -				dai-format = "left_j";
> -				...
> -			};
> -		};
> -	};
> -
> ------------------------
> -Example: Multi DAI with DPCM
> ------------------------
> -
> -	CPU0 ------ ak4613
> -	CPU1 ------ HDMI
> -	CPU2 ------ PCM3168A-p	/* DPCM 1ch/2ch */
> -	CPU3 --/		/* DPCM 3ch/4ch */
> -	CPU4 --/		/* DPCM 5ch/6ch */
> -	CPU5 --/		/* DPCM 7ch/8ch */
> -	CPU6 ------ PCM3168A-c
> -
> -	sound_card: sound {
> -		compatible = "audio-graph-card";
> -
> -		label = "sound-card";
> -
> -		routing =	"pcm3168a Playback", "DAI2 Playback",
> -				"pcm3168a Playback", "DAI3 Playback",
> -				"pcm3168a Playback", "DAI4 Playback",
> -				"pcm3168a Playback", "DAI5 Playback";
> -
> -		dais = <&snd_port0	/* ak4613 */
> -			&snd_port1	/* HDMI0  */
> -			&snd_port2	/* pcm3168a playback */
> -			&snd_port3	/* pcm3168a capture  */
> -			>;
> -	};
> -
> -	ak4613: codec@10 {
> -		...
> -		port {
> -			ak4613_endpoint: endpoint {
> -				remote-endpoint = <&rsnd_endpoint0>;
> -			};
> -		};
> -	};
> -
> -	pcm3168a: audio-codec@44 {
> -		...
> -		audio-graph-card,prefix = "pcm3168a";
> -		audio-graph-card,convert-channels = <8>; /* TDM Split */
> -		ports {
> -			port@0 {
> -				reg = <0>;
> -				pcm3168a_endpoint_p1: endpoint@1 {
> -					remote-endpoint = <&rsnd_endpoint2>;
> -					...
> -				};
> -				pcm3168a_endpoint_p2: endpoint@2 {
> -					remote-endpoint = <&rsnd_endpoint3>;
> -					...
> -				};
> -				pcm3168a_endpoint_p3: endpoint@3 {
> -					remote-endpoint = <&rsnd_endpoint4>;
> -					...
> -				};
> -				pcm3168a_endpoint_p4: endpoint@4 {
> -					remote-endpoint = <&rsnd_endpoint5>;
> -					...
> -				};
> -			};
> -			port@1 {
> -				reg = <1>;
> -				pcm3168a_endpoint_c: endpoint {
> -					remote-endpoint = <&rsnd_endpoint6>;
> -					...
> -				};
> -			};
> -		};
> -	};
> -
> -	&sound {
> -		ports {
> -			snd_port0: port@0 {
> -				rsnd_endpoint0: endpoint {
> -					remote-endpoint = <&ak4613_endpoint>;
> -					...
> -				};
> -			};
> -			snd_port1: port@1 {
> -				rsnd_endpoint1: endpoint {
> -					remote-endpoint = <&dw_hdmi0_snd_in>;
> -					...
> -				};
> -			};
> -			snd_port2: port@2 {
> -				#address-cells = <1>;
> -				#size-cells = <0>;
> -				rsnd_endpoint2: endpoint@2 {
> -					remote-endpoint = <&pcm3168a_endpoint_p1>;
> -					...
> -				};
> -				rsnd_endpoint3: endpoint@3 {
> -					remote-endpoint = <&pcm3168a_endpoint_p2>;
> -					...
> -				};
> -				rsnd_endpoint4: endpoint@4 {
> -					remote-endpoint = <&pcm3168a_endpoint_p3>;
> -					...
> -				};
> -				rsnd_endpoint5: endpoint@5 {
> -					remote-endpoint = <&pcm3168a_endpoint_p4>;
> -					...
> -				};
> -			};
> -			snd_port3: port@6 {
> -				rsnd_endpoint6: endpoint {
> -					remote-endpoint = <&pcm3168a_endpoint_c>;
> -					...
> -				};
> -			};
> -		};
> -	};
> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card.yaml b/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
> new file mode 100644
> index 0000000..d4b56bd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
> @@ -0,0 +1,548 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/audio-graph-card.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Generic audio graph card
> +
> +description: |
> +  Audio Graph Card specifies audio DAI connections of SoC <-> codec.
> +  It is based on common bindings for device graphs.
> +  see ${LINUX}/Documentation/devicetree/bindings/graph.yaml
> +
> +  Basically, Audio Graph Card properties are similar to Simple Card.
> +  see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.yaml
> +  Common definitions required here are referenced from above.
> +
> +maintainers:
> +  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> +
> +definitions:
> +
> +  end-point:
> +    type: object
> +    properties:
> +      mclk-fs:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
> +
> +      prefix:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
> +
> +      convert-rate:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
> +
> +      convert-channels:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
> +
> +      frame-inversion:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/frame-inversion
> +
> +      bitclock-inversion:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/bitclock-inversion
> +
> +      frame-master:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/frame-master
> +
> +      bitclock-master:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/bitclock-master
> +
> +      dai-tdm-slot-num:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/dai-tdm-slot-num
> +
> +      dai-tdm-slot-width:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/dai-tdm-slot-width
> +
> +      clocks:
> +        maxItems: 1
> +
> +      system-clock-frequency:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/system-clock-frequency
> +
> +      system-clock-direction-out:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/system-clock-direction-out
> +
> +      dai-format:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/format
> +
> +      remote-endpoint:
> +        description: phandle to an 'endpoint' subnode of a remote device node.
> +        $ref: /schemas/types.yaml#/definitions/phandle
> +
> +  port:
> +    type: object
> +    description: |
> +      If there is more than one 'port' or more than one 'endpoint' node
> +      or 'reg' property present in the port and/or endpoint nodes then
> +      '#address-cells' and '#size-cells' properties are required in relevant
> +      parent node.
> +    properties:
> +      convert-rate:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
> +
> +      convert-channels:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
> +
> +      prefix:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
> +
> +      mclk-fs:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
> +
> +    patternProperties:
> +      "^endpoint(@[0-9a-f]+)?$":
> +        type: object
> +        $ref: "#/definitions/end-point"
> +
> +  ports:
> +    type: object
> +    properties:
> +      convert-rate:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
> +
> +      convert-channels:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
> +
> +      prefix:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
> +
> +      mclk-fs:
> +        $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
> +
> +    patternProperties:
> +      "^port(@[0-9a-f]+)?$":
> +        $ref: "#/definitions/port"
> +
> +properties:
> +  compatible:
> +    items:
> +      - const: audio-graph-card
> +
> +  dais:
> +    description: list of CPU DAI port{s}
> +    $ref: /schemas/types.yaml#/definitions/phandle-array
> +
> +  label:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/label
> +
> +  pa-gpios:
> +    description: GPIO used to control external amplifier.
> +
> +  widgets:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/widgets
> +
> +  routing:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/routing
> +
> +  convert-rate:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/convert-rate
> +
> +  convert-channels:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/convert-channels
> +
> +  mclk-fs:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
> +
> +  prefix:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
> +
> +  hp-det-gpio:
> +    maxItems: 1
> +
> +  mic-det-gpio:
> +    maxItems: 1
> +
> +  ports:
> +    $ref: "#/definitions/ports"
> +
> +patternProperties:
> +  "^port(@[0-9a-f]+)?$":
> +    $ref: "#/definitions/port"
> +
> +required:
> +  - compatible
> +  - dais
> +
> +additionalProperties: false
> +
> +examples:
> +  # ---------------
> +  # Single DAI case
> +  # ---------------
> +  - |
> +    sound_card {
> +        compatible = "audio-graph-card";
> +
> +        dais = <&cpu_port>;
> +    };
> +
> +    dai-controller {
> +        // ...
> +
> +        cpu_port: port {
> +            cpu_endpoint: endpoint {
> +                remote-endpoint = <&codec_endpoint>;
> +
> +                dai-format = "left_j";
> +
> +                // ...
> +            };
> +        };
> +    };
> +
> +    audio-codec {
> +        // ...
> +
> +        port {
> +            codec_endpoint: endpoint {
> +                remote-endpoint = <&cpu_endpoint>;
> +            };
> +        };
> +    };
> +
> +  # --------------
> +  # Multi DAI case
> +  # --------------
> +  - |
> +    sound-card {
> +        compatible = "audio-graph-card";
> +
> +        label = "sound-card";
> +
> +        dais = <&cpu_port0
> +                &cpu_port1
> +                &cpu_port2>;
> +    };
> +
> +    audio-codec-0 {
> +        // ...
> +
> +        port {
> +            codec0_endpoint: endpoint {
> +                remote-endpoint = <&cpu_endpoint0>;
> +            };
> +        };
> +    };
> +
> +    audio-codec-1 {
> +        // ...
> +
> +        port {
> +            codec1_endpoint: endpoint {
> +                remote-endpoint = <&cpu_endpoint1>;
> +            };
> +        };
> +    };
> +
> +    audio-codec-2 {
> +        // ...
> +
> +        port {
> +            codec2_endpoint: endpoint {
> +                remote-endpoint = <&cpu_endpoint2>;
> +            };
> +        };
> +    };
> +
> +    dai-controller {
> +        // ...
> +
> +        ports {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            cpu_port0: port@0 {
> +                reg = <0>;
> +
> +                cpu_endpoint0: endpoint {
> +                    remote-endpoint = <&codec0_endpoint>;
> +
> +                    dai-format = "left_j";
> +
> +                    // ...
> +                };
> +            };
> +            cpu_port1: port@1 {
> +                reg = <1>;
> +
> +                cpu_endpoint1: endpoint {
> +                    remote-endpoint = <&codec1_endpoint>;
> +
> +                    dai-format = "i2s";
> +
> +                    // ...
> +                };
> +            };
> +            cpu_port2: port@2 {
> +                reg = <2>;
> +
> +                cpu_endpoint2: endpoint {
> +                    remote-endpoint = <&codec2_endpoint>;
> +
> +                    dai-format = "i2s";
> +
> +                    // ...
> +                };
> +            };
> +        };
> +    };
> +
> +  # ------------------------
> +  # Sampling Rate Conversion
> +  # ------------------------
> +  - |
> +    sound_card {
> +        compatible = "audio-graph-card";
> +
> +        label = "sound-card";
> +        prefix = "codec";
> +        routing = "codec Playback", "DAI0 Playback",
> +                  "DAI0 Capture",   "codec Capture";
> +        convert-rate = <48000>;
> +
> +        dais = <&cpu_port_src>;
> +    };
> +
> +    audio-codec {
> +        // ...
> +
> +        port {
> +            codec_endpoint_src: endpoint {
> +                remote-endpoint = <&cpu_endpoint_src>;
> +            };
> +        };
> +    };
> +
> +    dai-controller {
> +        // ...
> +
> +        cpu_port_src: port {
> +            cpu_endpoint_src: endpoint {
> +                remote-endpoint = <&codec_endpoint_src>;
> +
> +                dai-format = "left_j";
> +
> +                // ...
> +            };
> +        };
> +    };
> +
> +  # ----------------------
> +  # 2 CPU 1 Codec (Mixing)
> +  # ----------------------
> +  - |
> +    sound_card {
> +        compatible = "audio-graph-card";
> +
> +        label = "sound-card";
> +        routing = "codec Playback", "DAI0 Playback",
> +                  "codec Playback", "DAI1 Playback",
> +                  "DAI0 Capture",   "codec Capture";
> +
> +        dais = <&cpu_port_mix>;
> +    };
> +
> +    audio-codec {
> +        // ...
> +
> +        audio-graph-card,prefix = "codec";
> +        audio-graph-card,convert-rate = <48000>;
> +
> +        port {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            codec_endpoint0_mix: endpoint@0 {
> +                reg = <0>;
> +
> +                remote-endpoint = <&cpu_endpoint0_mix>;
> +            };
> +            codec_endpoint1_mix: endpoint@1 {
> +                reg = <1>;
> +
> +                remote-endpoint = <&cpu_endpoint1_mix>;
> +            };
> +        };
> +    };
> +
> +    dai-controller {
> +        // ...
> +
> +        cpu_port_mix: port {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            cpu_endpoint0_mix: endpoint@0 {
> +                reg = <0>;
> +
> +                remote-endpoint = <&codec_endpoint0_mix>;
> +
> +                dai-format = "left_j";
> +
> +                // ...
> +            };
> +            cpu_endpoint1_mix: endpoint@1 {
> +                reg = <1>;
> +
> +                remote-endpoint = <&codec_endpoint1_mix>;
> +
> +                dai-format = "left_j";
> +
> +                // ...
> +            };
> +        };
> +    };
> +
> +  # -------------------
> +  # Multi DAI with DPCM
> +  #
> +  #  CPU0 ------ ak4613
> +  #  CPU1 ------ HDMI
> +  #  CPU2 ------ PCM3168A-p    /* DPCM 1ch/2ch */
> +  #  CPU3 --/                  /* DPCM 3ch/4ch */
> +  #  CPU4 --/                  /* DPCM 5ch/6ch */
> +  #  CPU5 --/                  /* DPCM 7ch/8ch */
> +  #  CPU6 ------ PCM3168A-c
> +  # -------------------
> +  - |
> +    sound_card: sound {
> +        compatible = "audio-graph-card";
> +
> +        label = "sound-card";
> +
> +        routing = "pcm3168a Playback", "DAI2 Playback",
> +                  "pcm3168a Playback", "DAI3 Playback",
> +                  "pcm3168a Playback", "DAI4 Playback",
> +                  "pcm3168a Playback", "DAI5 Playback";
> +
> +        dais = <&snd_port0    /* ak4613 */
> +                &snd_port1    /* HDMI0  */
> +                &snd_port2    /* pcm3168a playback */
> +                &snd_port3    /* pcm3168a capture  */
> +                >;
> +    };
> +
> +    ak4613: codec-10 {
> +        // ...
> +
> +        port {
> +            ak4613_endpoint: endpoint {
> +                remote-endpoint = <&rsnd_endpoint0>;
> +            };
> +        };
> +    };
> +
> +    pcm3168a: audio-codec-44 {
> +        // ...
> +
> +        audio-graph-card,prefix = "pcm3168a";
> +        audio-graph-card,convert-channels = <8>; /* TDM Split */
> +
> +        ports {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            port@0 {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                reg = <0>;
> +                pcm3168a_endpoint_p1: endpoint@1 {
> +                    reg = <1>;
> +                    remote-endpoint = <&rsnd_endpoint2>;
> +
> +                    // ...
> +                };
> +                pcm3168a_endpoint_p2: endpoint@2 {
> +                    reg = <2>;
> +                    remote-endpoint = <&rsnd_endpoint3>;
> +
> +                    // ...
> +                };
> +                pcm3168a_endpoint_p3: endpoint@3 {
> +                    reg = <3>;
> +                    remote-endpoint = <&rsnd_endpoint4>;
> +
> +                    // ...
> +                };
> +                pcm3168a_endpoint_p4: endpoint@4 {
> +                    reg = <4>;
> +                    remote-endpoint = <&rsnd_endpoint5>;
> +
> +                    // ...
> +                };
> +            };
> +            port@1 {
> +                reg = <1>;
> +                pcm3168a_endpoint_c: endpoint {
> +                    remote-endpoint = <&rsnd_endpoint6>;
> +
> +                    // ...
> +                };
> +            };
> +        };
> +    };
> +
> +    dai-controller {
> +        ports {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            snd_port0: port@0 {
> +                reg = <0>;
> +                rsnd_endpoint0: endpoint {
> +                    remote-endpoint = <&ak4613_endpoint>;
> +
> +                    // ...
> +                };
> +            };
> +            snd_port1: port@1 {
> +                reg = <1>;
> +                rsnd_endpoint1: endpoint {
> +                    remote-endpoint = <&dw_hdmi0_snd_in>;
> +
> +                    // ...
> +                };
> +            };
> +            snd_port2: port@2 {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                reg = <2>;
> +                rsnd_endpoint2: endpoint@2 {
> +                    reg = <2>;
> +                    remote-endpoint = <&pcm3168a_endpoint_p1>;
> +
> +                    // ...
> +                };
> +                rsnd_endpoint3: endpoint@3 {
> +                    reg = <3>;
> +                    remote-endpoint = <&pcm3168a_endpoint_p2>;
> +
> +                    // ...
> +                };
> +                rsnd_endpoint4: endpoint@4 {
> +                    reg = <4>;
> +                    remote-endpoint = <&pcm3168a_endpoint_p3>;
> +
> +                    // ...
> +                };
> +                rsnd_endpoint5: endpoint@5 {
> +                    reg = <5>;
> +                    remote-endpoint = <&pcm3168a_endpoint_p4>;
> +
> +                    // ...
> +                };
> +            };
> +            snd_port3: port@6 {
> +                reg = <6>;
> +                rsnd_endpoint6: endpoint {
> +                    remote-endpoint = <&pcm3168a_endpoint_c>;
> +
> +                    // ...
> +                };
> +            };
> +        };
> +    };
> +
> +...
> -- 
> 2.7.4
> 

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

* Re: [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert bindings to json-schema
  2020-10-19  2:50   ` Kuninori Morimoto
@ 2020-10-19  4:30     ` Sameer Pujar
  2020-10-19  4:41       ` Kuninori Morimoto
  0 siblings, 1 reply; 29+ messages in thread
From: Sameer Pujar @ 2020-10-19  4:30 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: broonie, lgirdwood, robh+dt, pierre-louis.bossart, perex, tiwai,
	p.zabel, thierry.reding, jonathanh, alsa-devel, devicetree,
	linux-tegra, linux-kernel, sharadg, mkumard, viswanathl,
	rlokhande, dramesh, atalambedu, nwartikar, swarren, nicoleotsuka

Hi Morimoto-san,

>> Convert device tree bindings of audio graph card to YAML format. Also
>> expose some common definitions which can be used by similar graph based
>> audio sound cards.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>> ---
> I'm posting this patch to Rob & DT ML.
> Not yet accepted, though..

Thanks for letting me know. I guess below is your patch,
http://patchwork.ozlabs.org/project/devicetree-bindings/patch/877dtlvsxk.wl-kuninori.morimoto.gx@renesas.com/
Do you have plans to resend this or send next revision?

I can drop my patch once yours is merged and refer the same for Tegra 
audio graph card.

Thanks,
Sameer.



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

* Re: [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert bindings to json-schema
  2020-10-19  4:30     ` Sameer Pujar
@ 2020-10-19  4:41       ` Kuninori Morimoto
  2020-10-19 22:11         ` Rob Herring
  0 siblings, 1 reply; 29+ messages in thread
From: Kuninori Morimoto @ 2020-10-19  4:41 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: broonie, lgirdwood, robh+dt, pierre-louis.bossart, perex, tiwai,
	p.zabel, thierry.reding, jonathanh, alsa-devel, devicetree,
	linux-tegra, linux-kernel, sharadg, mkumard, viswanathl,
	rlokhande, dramesh, atalambedu, nwartikar, swarren, nicoleotsuka


Hi Sameer

> >> Convert device tree bindings of audio graph card to YAML format. Also
> >> expose some common definitions which can be used by similar graph based
> >> audio sound cards.
> >> 
> >> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> >> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> >> ---
> > I'm posting this patch to Rob & DT ML.
> > Not yet accepted, though..
> 
> Thanks for letting me know. I guess below is your patch,
> http://patchwork.ozlabs.org/project/devicetree-bindings/patch/877dtlvsxk.wl-kuninori.morimoto.gx@renesas.com/
> Do you have plans to resend this or send next revision?
> 
> I can drop my patch once yours is merged and refer the same for Tegra
> audio graph card.

I'm waiting response from Rob now.
It is merge window now. I will re-post it without his response
if -rc1 was released.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema
  2020-10-16 14:42 ` [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema Sameer Pujar
@ 2020-10-19 21:56   ` Rob Herring
  2020-10-20  5:34     ` Sameer Pujar
  2020-10-20  8:30     ` Philipp Zabel
  0 siblings, 2 replies; 29+ messages in thread
From: Rob Herring @ 2020-10-19 21:56 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka

On Fri, Oct 16, 2020 at 08:12:55PM +0530, Sameer Pujar wrote:
> Convert device tree bindings of graph to YAML format.

Thanks for doing this.

> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  Documentation/devicetree/bindings/graph.txt  | 128 --------------------
>  Documentation/devicetree/bindings/graph.yaml | 170 +++++++++++++++++++++++++++
>  2 files changed, 170 insertions(+), 128 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/graph.txt
>  create mode 100644 Documentation/devicetree/bindings/graph.yaml

I'd like to move this to the dtschema repository instead.

> diff --git a/Documentation/devicetree/bindings/graph.yaml b/Documentation/devicetree/bindings/graph.yaml
> new file mode 100644
> index 0000000..67804c1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/graph.yaml
> @@ -0,0 +1,170 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

As the original text defaulted to GPL2, this needs Philipp's permission 
to re-license.

> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/graph.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Common bindings for device graphs
> +
> +description: |
> +  The hierarchical organisation of the device tree is well suited to describe
> +  control flow to devices, but there can be more complex connections between
> +  devices that work together to form a logical compound device, following an
> +  arbitrarily complex graph.
> +  There already is a simple directed graph between devices tree nodes using
> +  phandle properties pointing to other nodes to describe connections that
> +  can not be inferred from device tree parent-child relationships. The device
> +  tree graph bindings described herein abstract more complex devices that can
> +  have multiple specifiable ports, each of which can be linked to one or more
> +  ports of other devices.
> +
> +  These common bindings do not contain any information about the direction or
> +  type of the connections, they just map their existence. Specific properties
> +  may be described by specialized bindings depending on the type of connection.
> +
> +  To see how this binding applies to video pipelines, for example, see
> +  Documentation/devicetree/bindings/media/video-interfaces.txt.
> +  Here the ports describe data interfaces, and the links between them are
> +  the connecting data buses. A single port with multiple connections can
> +  correspond to multiple devices being connected to the same physical bus.
> +
> +maintainers:
> +  - Philipp Zabel <p.zabel@pengutronix.de>
> +
> +definitions:
> +
> +  port:
> +    type: object
> +    description: |
> +      If there is more than one 'port' or more than one 'endpoint' node
> +      or 'reg' property present in the port and/or endpoint nodes then
> +      '#address-cells' and '#size-cells' properties are required in relevant
> +      parent node.

reg property.

> +
> +    patternProperties:
> +      "^endpoint(@[0-9a-f]+)?$":
> +        type: object
> +        properties:

reg?

> +          remote-endpoint:
> +            description: |
> +              phandle to an 'endpoint' subnode of a remote device node.
> +            $ref: /schemas/types.yaml#/definitions/phandle
> +
> +  ports:
> +    type: object
> +    patternProperties:
> +      "^port(@[0-9a-f]+)?$":
> +        $ref: "#/definitions/port"

No reason for this to be under 'definitions'. Just move down.

> +
> +properties:
> +  ports:
> +    $ref: "#/definitions/ports"
> +
> +patternProperties:
> +  "^port(@[0-9a-f]+)?$":
> +    $ref: "#/definitions/port"
> +
> +additionalProperties: false

This needs to be true here. But you need this within 'ports' and 'port'. 
(I think... I think we only have extra properties within endpoint 
nodes.) 

> +
> +examples:
> +  # Organisation of ports and endpoints:
> +  #
> +  # Ports are described by child 'port' nodes contained in the device node.
> +  # Each port node contains an 'endpoint' subnode for each remote device port
> +  # connected to this port. If a single port is connected to more than one
> +  # remote device, an 'endpoint' child node must be provided for each link.
> +  # If more than one port is present in a device node or there is more than
> +  # one endpoint at a port, or a port node needs to be associated with a
> +  # selected hardware interface, a common scheme using '#address-cells',
> +  # '#size-cells' and 'reg' properties is used to number the nodes.
> +  - |
> +    device {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        port@0 {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +            reg = <0>;
> +
> +            endpoint@0 {
> +                reg = <0>;
> +                // ...
> +            };
> +            endpoint@1 {
> +                reg = <1>;
> +                // ...
> +            };
> +        };
> +
> +        port@1 {
> +            reg = <1>;
> +
> +            endpoint {
> +                // ...
> +            };
> +        };
> +    };
> +
> +  # All 'port' nodes can be grouped under an optional 'ports' node, which
> +  # allows to specify #address-cells, #size-cells properties for the 'port'
> +  # nodes independently from any other child device nodes a device might
> +  # have.
> +  - |
> +    device {
> +        // ...
> +        ports {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            port@0 {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +                reg = <0>;
> +                // ...
> +
> +                endpoint@0 {
> +                    reg = <0>;
> +                    // ...
> +                };
> +                endpoint@1 {
> +                    reg = <1>;
> +                    // ...
> +                };
> +            };
> +
> +            port@1 {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +                reg = <1>;
> +                // ...
> +            };
> +        };
> +    };
> +
> +  # Links between endpoints:
> +  #
> +  # Each endpoint should contain a 'remote-endpoint' phandle property that
> +  # points to the corresponding endpoint in the port of the remote device.
> +  # In turn, the remote endpoint should contain a 'remote-endpoint' property.
> +  # If it has one, it must not point to anything other than the local endpoint.
> +  # Two endpoints with their 'remote-endpoint' phandles pointing at each other
> +  # form a link between the containing ports.
> +  - |
> +    device-1 {
> +        port {
> +            device_1_output: endpoint {
> +                remote-endpoint = <&device_2_input>;
> +            };
> +        };
> +    };
> +
> +    device-2 {
> +        port {
> +            device_2_input: endpoint {
> +                remote-endpoint = <&device_1_output>;
> +            };
> +        };
> +    };
> +
> +...
> -- 
> 2.7.4
> 

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

* Re: [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings
  2020-10-16 14:42 ` [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings Sameer Pujar
@ 2020-10-19 22:11   ` Rob Herring
  2020-10-20  6:03     ` Sameer Pujar
  0 siblings, 1 reply; 29+ messages in thread
From: Rob Herring @ 2020-10-19 22:11 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka

On Fri, Oct 16, 2020 at 08:12:57PM +0530, Sameer Pujar wrote:
> Add device tree binding properties of generic graph to ASoC component
> devices. This allows to define audio ports out of these components or
> DAIs and audio graph based sound card can be realised with this.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> ---
>  Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml  | 7 +++++++
>  .../devicetree/bindings/sound/nvidia,tegra210-admaif.yaml          | 7 +++++++
>  Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml  | 7 +++++++
>  Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml  | 7 +++++++
>  Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml   | 7 +++++++
>  5 files changed, 35 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
> index ed2fb32..23875b1 100644
> --- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
> +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
> @@ -55,6 +55,13 @@ properties:
>        The name can be "DSPK1" or "DSPKx", where x depends on the maximum
>        available instances on a Tegra SoC.
>  
> +  ports:
> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
> +
> +patternProperties:
> +  "^port(@[0-9a-f]+)?$":
> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port

You should have either 'ports' or a single 'port' (yes, the graph 
binding allowed multiple port nodes without 'ports', but that should be 
deprecated IMO)

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

* Re: [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert bindings to json-schema
  2020-10-19  4:41       ` Kuninori Morimoto
@ 2020-10-19 22:11         ` Rob Herring
  0 siblings, 0 replies; 29+ messages in thread
From: Rob Herring @ 2020-10-19 22:11 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Sameer Pujar, broonie, lgirdwood, pierre-louis.bossart, perex,
	tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka

On Mon, Oct 19, 2020 at 01:41:40PM +0900, Kuninori Morimoto wrote:
> 
> Hi Sameer
> 
> > >> Convert device tree bindings of audio graph card to YAML format. Also
> > >> expose some common definitions which can be used by similar graph based
> > >> audio sound cards.
> > >> 
> > >> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> > >> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > >> ---
> > > I'm posting this patch to Rob & DT ML.
> > > Not yet accepted, though..
> > 
> > Thanks for letting me know. I guess below is your patch,
> > http://patchwork.ozlabs.org/project/devicetree-bindings/patch/877dtlvsxk.wl-kuninori.morimoto.gx@renesas.com/
> > Do you have plans to resend this or send next revision?
> > 
> > I can drop my patch once yours is merged and refer the same for Tegra
> > audio graph card.
> 
> I'm waiting response from Rob now.
> It is merge window now. I will re-post it without his response
> if -rc1 was released.

Sorry, fell off my radar. Now replied.

Rob

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

* Re: [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  2020-10-16 14:42 ` [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card Sameer Pujar
@ 2020-10-19 22:16   ` Rob Herring
  2020-10-20  6:16     ` Sameer Pujar
  0 siblings, 1 reply; 29+ messages in thread
From: Rob Herring @ 2020-10-19 22:16 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka

On Fri, Oct 16, 2020 at 08:12:58PM +0530, Sameer Pujar wrote:
> Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
> same DT bindings provided by generic audio graph driver. Along with this
> few standard clock DT bindings are added which are specifically required
> for Tegra audio.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> ---
>  .../sound/nvidia,tegra-audio-graph-card.yaml       | 158 +++++++++++++++++++++
>  1 file changed, 158 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
> 
> diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
> new file mode 100644
> index 0000000..284d185
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
> @@ -0,0 +1,158 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Audio Graph based Tegra sound card driver
> +
> +description: |
> +  This is based on generic audio graph card driver along with additional
> +  customizations for Tegra platforms. It uses the same bindings with
> +  additional standard clock DT bindings required for Tegra.
> +
> +  See{LINUX}/Documentation/devicetree/bindings/sound/audio-graph-card.yaml

You should be able to just $ref this at the top level.

> +
> +maintainers:
> +  - Jon Hunter <jonathanh@nvidia.com>
> +  - Sameer Pujar <spujar@nvidia.com>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - nvidia,tegra210-audio-graph-card
> +          - nvidia,tegra186-audio-graph-card
> +

> +  dais:
> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/dais
> +
> +  label:
> +    $ref: /schemas/sound/simple-card.yaml#/properties/label
> +
> +  pa-gpios:
> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/pa-gpios
> +
> +  widgets:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/widgets
> +
> +  routing:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/routing
> +
> +  mclk-fs:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
> +
> +  prefix:
> +    $ref: /schemas/sound/simple-card.yaml#/definitions/prefix

And drop all of these.

> +
> +  clocks:
> +   minItems: 2
> +
> +  clock-names:
> +   minItems: 2

Don't need this.

> +   items:
> +     - const: pll_a
> +     - const: plla_out0
> +
> +  assigned-clocks:
> +    minItems: 1
> +    maxItems: 3
> +
> +  assigned-clock-parents:
> +    minItems: 1
> +    maxItems: 3
> +
> +  assigned-clock-rates:
> +    minItems: 1
> +    maxItems: 3
> +
> +  ports:
> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/ports
> +
> +patternProperties:
> +  "^port(@[0-9a-f]+)?$":
> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port

And these can be dropped. Unless what each port is is Tegra specific.

> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - dais
> +  - clocks
> +  - clock-names
> +  - assigned-clocks
> +  - assigned-clock-parents
> +
> +examples:
> +  - |
> +    #include<dt-bindings/clock/tegra210-car.h>
> +
> +    tegra_sound {
> +        compatible = "nvidia,tegra210-audio-graph-card";
> +
> +        clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
> +                 <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
> +        clock-names = "pll_a", "plla_out0";
> +
> +        assigned-clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
> +                          <&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
> +                          <&tegra_car TEGRA210_CLK_EXTERN1>;
> +        assigned-clock-parents = <0>, <0>, <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
> +        assigned-clock-rates = <368640000>, <49152000>, <12288000>;
> +
> +        dais = /* FE */
> +               <&admaif1_port>,
> +               /* Router */
> +               <&xbar_i2s1_port>,
> +               /* I/O DAP Ports */
> +               <&i2s1_port>;
> +
> +        label = "jetson-tx1-ape";
> +    };
> +
> +    tegra_ahub: ahub@702d0800 {
> +        // ...
> +
> +        reg = <0x702d0800 0x800>;
> +
> +        ports {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            xbar_i2s1_port: port@a {
> +                reg = <0xa>;
> +                xbar_i2s1_ep: endpoint {
> +                    remote-endpoint = <&i2s1_cif_ep>;
> +                };
> +            };
> +        };
> +    };
> +
> +    tegra_i2s1: i2s@702d1000 {
> +        // ...
> +
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        reg = <0x702d1000 0x100>;
> +
> +        port@0 {
> +            reg = <0>;
> +
> +            i2s1_cif_ep: endpoint {
> +                remote-endpoint = <&xbar_i2s1_ep>;
> +            };
> +        };
> +
> +        i2s1_port: port@1 {
> +            reg = <1>;
> +
> +            i2s1_dap: endpoint {
> +                dai-format = "i2s";
> +
> +                // ...
> +            };
> +        };
> +    };
> +
> +...
> -- 
> 2.7.4
> 

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

* Re: [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema
  2020-10-19 21:56   ` Rob Herring
@ 2020-10-20  5:34     ` Sameer Pujar
  2020-10-20  8:30     ` Philipp Zabel
  1 sibling, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-20  5:34 UTC (permalink / raw)
  To: Rob Herring
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka


>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> Cc: Philipp Zabel <p.zabel@pengutronix.de>
>> ---
>>   Documentation/devicetree/bindings/graph.txt  | 128 --------------------
>>   Documentation/devicetree/bindings/graph.yaml | 170 +++++++++++++++++++++++++++
>>   2 files changed, 170 insertions(+), 128 deletions(-)
>>   delete mode 100644 Documentation/devicetree/bindings/graph.txt
>>   create mode 100644 Documentation/devicetree/bindings/graph.yaml
> I'd like to move this to the dtschema repository instead.

Do you mean I need to separately submit this patch for dtschema repo?

...
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/graph.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Common bindings for device graphs
>> +
>> +description: |
>> +  The hierarchical organisation of the device tree is well suited to describe
>> +  control flow to devices, but there can be more complex connections between
>> +  devices that work together to form a logical compound device, following an
>> +  arbitrarily complex graph.
>> +  There already is a simple directed graph between devices tree nodes using
>> +  phandle properties pointing to other nodes to describe connections that
>> +  can not be inferred from device tree parent-child relationships. The device
>> +  tree graph bindings described herein abstract more complex devices that can
>> +  have multiple specifiable ports, each of which can be linked to one or more
>> +  ports of other devices.
>> +
>> +  These common bindings do not contain any information about the direction or
>> +  type of the connections, they just map their existence. Specific properties
>> +  may be described by specialized bindings depending on the type of connection.
>> +
>> +  To see how this binding applies to video pipelines, for example, see
>> +  Documentation/devicetree/bindings/media/video-interfaces.txt.
>> +  Here the ports describe data interfaces, and the links between them are
>> +  the connecting data buses. A single port with multiple connections can
>> +  correspond to multiple devices being connected to the same physical bus.
>> +
>> +maintainers:
>> +  - Philipp Zabel <p.zabel@pengutronix.de>
>> +
>> +definitions:
>> +
>> +  port:
>> +    type: object
>> +    description: |
>> +      If there is more than one 'port' or more than one 'endpoint' node
>> +      or 'reg' property present in the port and/or endpoint nodes then
>> +      '#address-cells' and '#size-cells' properties are required in relevant
>> +      parent node.
> reg property.

done

>
>> +
>> +    patternProperties:
>> +      "^endpoint(@[0-9a-f]+)?$":
>> +        type: object
>> +        properties:
> reg?

done

>> +          remote-endpoint:
>> +            description: |
>> +              phandle to an 'endpoint' subnode of a remote device node.
>> +            $ref: /schemas/types.yaml#/definitions/phandle
>> +
>> +  ports:
>> +    type: object
>> +    patternProperties:
>> +      "^port(@[0-9a-f]+)?$":
>> +        $ref: "#/definitions/port"
> No reason for this to be under 'definitions'. Just move down.

Would definitions be needed if some schemas want to refer the base graph 
schema? Or is it like they can just directly include the base schema and 
definitions are not really required?

But what if they want to extend few properties. For example:

graph.yaml
----------
endpoint {
     remote-endpoint = <>;
};

*audio-graph-card.yaml
----------------------
endpoint {
     remote-endpoint = <>;

     property-x;
     node-x {
         ...
     };
};

>
>> +
>> +properties:
>> +  ports:
>> +    $ref: "#/definitions/ports"
>> +
>> +patternProperties:
>> +  "^port(@[0-9a-f]+)?$":
>> +    $ref: "#/definitions/port"
>> +
>> +additionalProperties: false
> This needs to be true here. But you need this within 'ports' and 'port'.
> (I think... I think we only have extra properties within endpoint
> nodes.)

I think currently audio-graph allows few properties at port/ports. I am 
not sure if Morimoto-san has plans to get rid of this.

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

* Re: [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings
  2020-10-19 22:11   ` Rob Herring
@ 2020-10-20  6:03     ` Sameer Pujar
  0 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-20  6:03 UTC (permalink / raw)
  To: Rob Herring
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka


>> Add device tree binding properties of generic graph to ASoC component
>> devices. This allows to define audio ports out of these components or
>> DAIs and audio graph based sound card can be realised with this.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> ---
>>   Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml  | 7 +++++++
>>   .../devicetree/bindings/sound/nvidia,tegra210-admaif.yaml          | 7 +++++++
>>   Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml  | 7 +++++++
>>   Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml  | 7 +++++++
>>   Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml   | 7 +++++++
>>   5 files changed, 35 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
>> index ed2fb32..23875b1 100644
>> --- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
>> +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
>> @@ -55,6 +55,13 @@ properties:
>>         The name can be "DSPK1" or "DSPKx", where x depends on the maximum
>>         available instances on a Tegra SoC.
>>
>> +  ports:
>> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/ports
>> +

>> +patternProperties:
>> +  "^port(@[0-9a-f]+)?$":
>> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
> You should have either 'ports' or a single 'port' (yes, the graph
> binding allowed multiple port nodes without 'ports', but that should be
> deprecated IMO)

OK, will drop this and just use 'port' here.

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

* Re: [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  2020-10-19 22:16   ` Rob Herring
@ 2020-10-20  6:16     ` Sameer Pujar
  2020-10-20 13:24       ` Rob Herring
  0 siblings, 1 reply; 29+ messages in thread
From: Sameer Pujar @ 2020-10-20  6:16 UTC (permalink / raw)
  To: Rob Herring
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, p.zabel, thierry.reding, jonathanh, alsa-devel,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar, swarren,
	nicoleotsuka


>> Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
>> same DT bindings provided by generic audio graph driver. Along with this
>> few standard clock DT bindings are added which are specifically required
>> for Tegra audio.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> ---
>>   .../sound/nvidia,tegra-audio-graph-card.yaml       | 158 +++++++++++++++++++++
>>   1 file changed, 158 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
>> new file mode 100644
>> index 0000000..284d185
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
>> @@ -0,0 +1,158 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Audio Graph based Tegra sound card driver
>> +
>> +description: |
>> +  This is based on generic audio graph card driver along with additional
>> +  customizations for Tegra platforms. It uses the same bindings with
>> +  additional standard clock DT bindings required for Tegra.
>> +
>> +  See{LINUX}/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
> You should be able to just $ref this at the top level.

I am seeing one problem while using $ref like below.
allOf:
   - $ref: /schemas/sound/audio-graph-card.yaml

I see below while running doc validator.
"Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.example.dt.yaml: 
tegra_sound: compatible:0: 'audio-graph-card' was expected"

Is there a way to avoid this?

>
>> +
>> +maintainers:
>> +  - Jon Hunter <jonathanh@nvidia.com>
>> +  - Sameer Pujar <spujar@nvidia.com>
>> +
>> +properties:
>> +  compatible:
>> +    items:
>> +      - enum:
>> +          - nvidia,tegra210-audio-graph-card
>> +          - nvidia,tegra186-audio-graph-card
>> +

>> +  dais:
>> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/dais
>> +
>> +  label:
>> +    $ref: /schemas/sound/simple-card.yaml#/properties/label
>> +
>> +  pa-gpios:
>> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/pa-gpios
>> +
>> +  widgets:
>> +    $ref: /schemas/sound/simple-card.yaml#/definitions/widgets
>> +
>> +  routing:
>> +    $ref: /schemas/sound/simple-card.yaml#/definitions/routing
>> +
>> +  mclk-fs:
>> +    $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
>> +
>> +  prefix:
>> +    $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
> And drop all of these.

Could not re-use because of above compatible problem. Also require some 
additional properties for Tegra.

>> +
>> +  clocks:
>> +   minItems: 2
>> +
>> +  clock-names:
>> +   minItems: 2
> Don't need this.

This is required for Tegra audio graph card to update clock rates at 
runtime.

>
>> +   items:
>> +     - const: pll_a
>> +     - const: plla_out0
>> +
>> +  assigned-clocks:
>> +    minItems: 1
>> +    maxItems: 3
>> +
>> +  assigned-clock-parents:
>> +    minItems: 1
>> +    maxItems: 3
>> +
>> +  assigned-clock-rates:
>> +    minItems: 1
>> +    maxItems: 3
>> +

It is required for initialisation of above clocks with specific rates.

>> +  ports:
>> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/ports
>> +
>> +patternProperties:
>> +  "^port(@[0-9a-f]+)?$":
>> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
> And these can be dropped. Unless what each port is is Tegra specific.

May be I can drop this if I could just directly include 
audio-graph-card.yaml and extend required properties for Tegra.

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

* Re: [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema
  2020-10-19 21:56   ` Rob Herring
  2020-10-20  5:34     ` Sameer Pujar
@ 2020-10-20  8:30     ` Philipp Zabel
  2020-10-23 13:45       ` Sameer Pujar
  1 sibling, 1 reply; 29+ messages in thread
From: Philipp Zabel @ 2020-10-20  8:30 UTC (permalink / raw)
  To: Rob Herring, Sameer Pujar
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, thierry.reding, jonathanh, alsa-devel, devicetree,
	linux-tegra, linux-kernel, sharadg, mkumard, viswanathl,
	rlokhande, dramesh, atalambedu, nwartikar, swarren, nicoleotsuka

Hi Sameer, Rob,

On Mon, 2020-10-19 at 16:56 -0500, Rob Herring wrote:
> On Fri, Oct 16, 2020 at 08:12:55PM +0530, Sameer Pujar wrote:
> > Convert device tree bindings of graph to YAML format.
> 
> Thanks for doing this.

Seconded.

> > Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> > Cc: Philipp Zabel <p.zabel@pengutronix.de>
> > ---
> >  Documentation/devicetree/bindings/graph.txt  | 128 --------------------

The removed Documentation/devicetree/bindings/graph.txt is referenced by
a lot of files, tree-wide. Should the references be updated in the same
series?

> >  Documentation/devicetree/bindings/graph.yaml | 170 +++++++++++++++++++++++++++
> >  2 files changed, 170 insertions(+), 128 deletions(-)
> >  delete mode 100644 Documentation/devicetree/bindings/graph.txt
> >  create mode 100644 Documentation/devicetree/bindings/graph.yaml
> 
> I'd like to move this to the dtschema repository instead.
> 
> > diff --git a/Documentation/devicetree/bindings/graph.yaml b/Documentation/devicetree/bindings/graph.yaml
> > new file mode 100644
> > index 0000000..67804c1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/graph.yaml
> > @@ -0,0 +1,170 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> 
> As the original text defaulted to GPL2, this needs Philipp's permission 
> to re-license.

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/graph.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Common bindings for device graphs
> > +
> > +description: |
> > +  The hierarchical organisation of the device tree is well suited to describe
> > +  control flow to devices, but there can be more complex connections between
> > +  devices that work together to form a logical compound device, following an
> > +  arbitrarily complex graph.
> > +  There already is a simple directed graph between devices tree nodes using
> > +  phandle properties pointing to other nodes to describe connections that
> > +  can not be inferred from device tree parent-child relationships. The device
> > +  tree graph bindings described herein abstract more complex devices that can
> > +  have multiple specifiable ports, each of which can be linked to one or more
> > +  ports of other devices.
> > +
> > +  These common bindings do not contain any information about the direction or
> > +  type of the connections, they just map their existence. Specific properties
> > +  may be described by specialized bindings depending on the type of connection.
> > +
> > +  To see how this binding applies to video pipelines, for example, see
> > +  Documentation/devicetree/bindings/media/video-interfaces.txt.
> > +  Here the ports describe data interfaces, and the links between them are
> > +  the connecting data buses. A single port with multiple connections can
> > +  correspond to multiple devices being connected to the same physical bus.
> > +
> > +maintainers:
> > +  - Philipp Zabel <p.zabel@pengutronix.de>
> > +
> > +definitions:
> > +
> > +  port:
> > +    type: object
> > +    description: |
> > +      If there is more than one 'port' or more than one 'endpoint' node
> > +      or 'reg' property present in the port and/or endpoint nodes then
> > +      '#address-cells' and '#size-cells' properties are required in relevant
> > +      parent node.
> 
> reg property.

What about #address-cells and #size-cells in port and ports nodes?
These must either be #address-cells = <1>, #size-cells = <0>, or they
can be absent if the parent node already has the same, or if a port node
only contains a single endpoint.

> > +
> > +    patternProperties:
> > +      "^endpoint(@[0-9a-f]+)?$":
> > +        type: object
> > +        properties:
> 
> reg?
> 
> > +          remote-endpoint:
> > +            description: |
> > +              phandle to an 'endpoint' subnode of a remote device node.
> > +            $ref: /schemas/types.yaml#/definitions/phandle
> > +
> > +  ports:
> > +    type: object
> > +    patternProperties:
> > +      "^port(@[0-9a-f]+)?$":
> > +        $ref: "#/definitions/port"
> 
> No reason for this to be under 'definitions'. Just move down.
> 
> > +
> > +properties:
> > +  ports:
> > +    $ref: "#/definitions/ports"
> > +
> > +patternProperties:
> > +  "^port(@[0-9a-f]+)?$":
> > +    $ref: "#/definitions/port"
> > +
> > +additionalProperties: false
> 
> This needs to be true here. But you need this within 'ports' and 'port'. 
> (I think... I think we only have extra properties within endpoint 
> nodes.) 
> 
> > +
> > +examples:
> > +  # Organisation of ports and endpoints:
> > +  #
> > +  # Ports are described by child 'port' nodes contained in the device node.
> > +  # Each port node contains an 'endpoint' subnode for each remote device port
> > +  # connected to this port. If a single port is connected to more than one
> > +  # remote device, an 'endpoint' child node must be provided for each link.
> > +  # If more than one port is present in a device node or there is more than
> > +  # one endpoint at a port, or a port node needs to be associated with a
> > +  # selected hardware interface, a common scheme using '#address-cells',
> > +  # '#size-cells' and 'reg' properties is used to number the nodes.
> > +  - |
> > +    device {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        port@0 {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +            reg = <0>;
> > +
> > +            endpoint@0 {
> > +                reg = <0>;
> > +                // ...
> > +            };
> > +            endpoint@1 {
> > +                reg = <1>;
> > +                // ...
> > +            };
> > +        };
> > +
> > +        port@1 {
> > +            reg = <1>;
> > +
> > +            endpoint {
> > +                // ...
> > +            };
> > +        };
> > +    };
> > +
> > +  # All 'port' nodes can be grouped under an optional 'ports' node, which
> > +  # allows to specify #address-cells, #size-cells properties for the 'port'
> > +  # nodes independently from any other child device nodes a device might
> > +  # have.
> > +  - |
> > +    device {
> > +        // ...
> > +        ports {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +
> > +            port@0 {
> > +                #address-cells = <1>;
> > +                #size-cells = <0>;
> > +                reg = <0>;
> > +                // ...
> > +
> > +                endpoint@0 {
> > +                    reg = <0>;
> > +                    // ...
> > +                };
> > +                endpoint@1 {
> > +                    reg = <1>;
> > +                    // ...
> > +                };
> > +            };
> > +
> > +            port@1 {
> > +                #address-cells = <1>;
> > +                #size-cells = <0>;
> > +                reg = <1>;
> > +                // ...
> > +            };
> > +        };
> > +    };
> > +
> > +  # Links between endpoints:
> > +  #
> > +  # Each endpoint should contain a 'remote-endpoint' phandle property that
> > +  # points to the corresponding endpoint in the port of the remote device.
> > +  # In turn, the remote endpoint should contain a 'remote-endpoint' property.
> > +  # If it has one, it must not point to anything other than the local endpoint.
> > +  # Two endpoints with their 'remote-endpoint' phandles pointing at each other
> > +  # form a link between the containing ports.
> > +  - |
> > +    device-1 {
> > +        port {
> > +            device_1_output: endpoint {
> > +                remote-endpoint = <&device_2_input>;
> > +            };
> > +        };
> > +    };
> > +
> > +    device-2 {
> > +        port {
> > +            device_2_input: endpoint {
> > +                remote-endpoint = <&device_1_output>;
> > +            };
> > +        };
> > +    };
> > +
> > +...
> > -- 
> > 2.7.4
> > 

regards
Philipp

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

* Re: [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  2020-10-20  6:16     ` Sameer Pujar
@ 2020-10-20 13:24       ` Rob Herring
  0 siblings, 0 replies; 29+ messages in thread
From: Rob Herring @ 2020-10-20 13:24 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: Mark Brown, Liam Girdwood, Kuninori Morimoto,
	Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai,
	Philipp Zabel, Thierry Reding, Jon Hunter, Linux-ALSA,
	devicetree, linux-tegra, linux-kernel, sharadg, mkumard,
	viswanathl, rlokhande, dramesh, atalambedu, nwartikar,
	Stephen Warren, Nicolin Chen

On Tue, Oct 20, 2020 at 1:16 AM Sameer Pujar <spujar@nvidia.com> wrote:
>
>
> >> Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
> >> same DT bindings provided by generic audio graph driver. Along with this
> >> few standard clock DT bindings are added which are specifically required
> >> for Tegra audio.
> >>
> >> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> >> ---
> >>   .../sound/nvidia,tegra-audio-graph-card.yaml       | 158 +++++++++++++++++++++
> >>   1 file changed, 158 insertions(+)
> >>   create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
> >> new file mode 100644
> >> index 0000000..284d185
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
> >> @@ -0,0 +1,158 @@
> >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> >> +%YAML 1.2
> >> +---
> >> +$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> +
> >> +title: Audio Graph based Tegra sound card driver
> >> +
> >> +description: |
> >> +  This is based on generic audio graph card driver along with additional
> >> +  customizations for Tegra platforms. It uses the same bindings with
> >> +  additional standard clock DT bindings required for Tegra.
> >> +
> >> +  See{LINUX}/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
> > You should be able to just $ref this at the top level.
>
> I am seeing one problem while using $ref like below.
> allOf:
>    - $ref: /schemas/sound/audio-graph-card.yaml
>
> I see below while running doc validator.
> "Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.example.dt.yaml:
> tegra_sound: compatible:0: 'audio-graph-card' was expected"
>
> Is there a way to avoid this?

Adjust the schemas so the constraints match. You can't say it must be
one thing in one place and something else here. Your choices are:

- Drop compatible from audio-graph-card.yaml. You can define a 2nd
schema that references audio-graph-card.yaml and defines the
compatible.
- Use 'contains' in audio-graph-card.yaml and then make
'audio-graph-card' a fallback here.

The best option depends on what existing users have.

> >> +maintainers:
> >> +  - Jon Hunter <jonathanh@nvidia.com>
> >> +  - Sameer Pujar <spujar@nvidia.com>
> >> +
> >> +properties:
> >> +  compatible:
> >> +    items:
> >> +      - enum:
> >> +          - nvidia,tegra210-audio-graph-card
> >> +          - nvidia,tegra186-audio-graph-card
> >> +
>
> >> +  dais:
> >> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/dais
> >> +
> >> +  label:
> >> +    $ref: /schemas/sound/simple-card.yaml#/properties/label
> >> +
> >> +  pa-gpios:
> >> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/pa-gpios
> >> +
> >> +  widgets:
> >> +    $ref: /schemas/sound/simple-card.yaml#/definitions/widgets
> >> +
> >> +  routing:
> >> +    $ref: /schemas/sound/simple-card.yaml#/definitions/routing
> >> +
> >> +  mclk-fs:
> >> +    $ref: /schemas/sound/simple-card.yaml#/definitions/mclk-fs
> >> +
> >> +  prefix:
> >> +    $ref: /schemas/sound/simple-card.yaml#/definitions/prefix
> > And drop all of these.
>
> Could not re-use because of above compatible problem. Also require some
> additional properties for Tegra.
>
> >> +
> >> +  clocks:
> >> +   minItems: 2
> >> +
> >> +  clock-names:
> >> +   minItems: 2
> > Don't need this.
>
> This is required for Tegra audio graph card to update clock rates at
> runtime.

I mean you can drop 'minItems: 2' as it is redundant. The 'items' list
size implies the size.

> >> +   items:
> >> +     - const: pll_a
> >> +     - const: plla_out0
> >> +
> >> +  assigned-clocks:
> >> +    minItems: 1
> >> +    maxItems: 3
> >> +
> >> +  assigned-clock-parents:
> >> +    minItems: 1
> >> +    maxItems: 3
> >> +
> >> +  assigned-clock-rates:
> >> +    minItems: 1
> >> +    maxItems: 3
> >> +
>
> It is required for initialisation of above clocks with specific rates.
>
> >> +  ports:
> >> +    $ref: /schemas/sound/audio-graph-card.yaml#/properties/ports
> >> +
> >> +patternProperties:
> >> +  "^port(@[0-9a-f]+)?$":
> >> +    $ref: /schemas/sound/audio-graph-card.yaml#/definitions/port
> > And these can be dropped. Unless what each port is is Tegra specific.
>
> May be I can drop this if I could just directly include
> audio-graph-card.yaml and extend required properties for Tegra.

There are numerous examples of doing that.

Rob

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

* Re: [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema
  2020-10-20  8:30     ` Philipp Zabel
@ 2020-10-23 13:45       ` Sameer Pujar
  0 siblings, 0 replies; 29+ messages in thread
From: Sameer Pujar @ 2020-10-23 13:45 UTC (permalink / raw)
  To: Philipp Zabel, Rob Herring
  Cc: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai, thierry.reding, jonathanh, alsa-devel, devicetree,
	linux-tegra, linux-kernel, sharadg, mkumard, viswanathl,
	rlokhande, dramesh, atalambedu, nwartikar, swarren, nicoleotsuka


>>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>>> Cc: Philipp Zabel <p.zabel@pengutronix.de>
>>> ---
>>>   Documentation/devicetree/bindings/graph.txt  | 128 --------------------
> The removed Documentation/devicetree/bindings/graph.txt is referenced by
> a lot of files, tree-wide. Should the references be updated in the same
> series?

May be possible to include in the same series if it is just about using 
'graph.yaml' reference instead of 'graph.txt' in various files.

...

>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/graph.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Common bindings for device graphs
>>> +
>>> +description: |
>>> +  The hierarchical organisation of the device tree is well suited to describe
>>> +  control flow to devices, but there can be more complex connections between
>>> +  devices that work together to form a logical compound device, following an
>>> +  arbitrarily complex graph.
>>> +  There already is a simple directed graph between devices tree nodes using
>>> +  phandle properties pointing to other nodes to describe connections that
>>> +  can not be inferred from device tree parent-child relationships. The device
>>> +  tree graph bindings described herein abstract more complex devices that can
>>> +  have multiple specifiable ports, each of which can be linked to one or more
>>> +  ports of other devices.
>>> +
>>> +  These common bindings do not contain any information about the direction or
>>> +  type of the connections, they just map their existence. Specific properties
>>> +  may be described by specialized bindings depending on the type of connection.
>>> +
>>> +  To see how this binding applies to video pipelines, for example, see
>>> +  Documentation/devicetree/bindings/media/video-interfaces.txt.
>>> +  Here the ports describe data interfaces, and the links between them are
>>> +  the connecting data buses. A single port with multiple connections can
>>> +  correspond to multiple devices being connected to the same physical bus.
>>> +
>>> +maintainers:
>>> +  - Philipp Zabel <p.zabel@pengutronix.de>
>>> +
>>> +definitions:
>>> +
>>> +  port:
>>> +    type: object
>>> +    description: |
>>> +      If there is more than one 'port' or more than one 'endpoint' node
>>> +      or 'reg' property present in the port and/or endpoint nodes then
>>> +      '#address-cells' and '#size-cells' properties are required in relevant
>>> +      parent node.
>> reg property.
> What about #address-cells and #size-cells in port and ports nodes?
> These must either be #address-cells = <1>, #size-cells = <0>, or they
> can be absent if the parent node already has the same, or if a port node
> only contains a single endpoint.

Yes, will list these properties for port/ports.

...

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

end of thread, back to index

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 01/15] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 02/15] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 03/15] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 04/15] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 05/15] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 06/15] ASoC: audio-graph: Expose new members for asoc_simple_priv Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 07/15] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema Sameer Pujar
2020-10-19 21:56   ` Rob Herring
2020-10-20  5:34     ` Sameer Pujar
2020-10-20  8:30     ` Philipp Zabel
2020-10-23 13:45       ` Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert " Sameer Pujar
2020-10-19  2:50   ` Kuninori Morimoto
2020-10-19  4:30     ` Sameer Pujar
2020-10-19  4:41       ` Kuninori Morimoto
2020-10-19 22:11         ` Rob Herring
2020-10-16 14:42 ` [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings Sameer Pujar
2020-10-19 22:11   ` Rob Herring
2020-10-20  6:03     ` Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card Sameer Pujar
2020-10-19 22:16   ` Rob Herring
2020-10-20  6:16     ` Sameer Pujar
2020-10-20 13:24       ` Rob Herring
2020-10-16 14:42 ` [PATCH v4 12/15] ASoC: tegra: Add audio graph based card driver Sameer Pujar
2020-10-16 14:43 ` [PATCH v4 13/15] arm64: defconfig: Enable Tegra audio graph " Sameer Pujar
2020-10-16 14:43 ` [PATCH v4 14/15] arm64: tegra: Audio graph header for Tegra210 Sameer Pujar
2020-10-16 14:43 ` [PATCH v4 15/15] arm64: tegra: Audio graph sound card for Jetson Nano and TX1 Sameer Pujar

Linux-Tegra Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-tegra/0 linux-tegra/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-tegra linux-tegra/ https://lore.kernel.org/linux-tegra \
		linux-tegra@vger.kernel.org
	public-inbox-index linux-tegra

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-tegra


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git