diff mbox series

[3/4] ASoC: fsl-asoc-card: Add optional dt property for setting mclk-id

Message ID 20211203134930.128703-4-ariel.dalessandro@collabora.com
State New
Headers show
Series fsl-asoc-card: Add optional dt property for setting mclk-id | expand

Commit Message

Ariel D'Alessandro Dec. 3, 2021, 1:49 p.m. UTC
Sound cards may allow using different main clock inputs. In the generic
fsl-asoc-card driver, these values are hardcoded for each specific card
configuration.

Let's make it more flexible, allowing setting mclk-id from the
device-tree node. Otherwise, the default value for each card
configuration is used.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
---
 Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 1 +
 sound/soc/fsl/fsl-asoc-card.c                             | 6 ++++++
 2 files changed, 7 insertions(+)

Comments

Rob Herring Dec. 13, 2021, 8:37 p.m. UTC | #1
On Fri, Dec 03, 2021 at 10:49:29AM -0300, Ariel D'Alessandro wrote:
> Sound cards may allow using different main clock inputs. In the generic
> fsl-asoc-card driver, these values are hardcoded for each specific card
> configuration.
> 
> Let's make it more flexible, allowing setting mclk-id from the
> device-tree node. Otherwise, the default value for each card
> configuration is used.
> 
> Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
> ---
>  Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 1 +
>  sound/soc/fsl/fsl-asoc-card.c                             | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
> index 23d83fa7609f..b219626a5403 100644
> --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
> +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
> @@ -82,6 +82,7 @@ Optional properties:
>    - dai-format		: audio format, for details see simple-card.yaml.
>    - frame-inversion	: dai-link uses frame clock inversion, for details see simple-card.yaml.
>    - bitclock-inversion	: dai-link uses bit clock inversion, for details see simple-card.yaml.
> +  - mclk-id		: main clock id, specific for each card configuration.

Ahh, there it is. This change and the header defines should be 1 patch 
and driver changes another.

>  
>  Optional unless SSI is selected as a CPU DAI:
>  
> diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
> index 90cbed496f98..bb962e04d40b 100644
> --- a/sound/soc/fsl/fsl-asoc-card.c
> +++ b/sound/soc/fsl/fsl-asoc-card.c
> @@ -693,6 +693,12 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
>  		goto asrc_fail;
>  	}
>  
> +	/*
> +	 * Allow setting mclk-id from the device-tree node. Otherwise, the
> +	 * default value for each card configuration is used.
> +	 */
> +	of_property_read_u32(np, "mclk-id", &priv->codec_priv.mclk_id);
> +
>  	/* Format info from DT is optional. */
>  	snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, &bitclkprovider, &frameprovider);
>  	if (bitclkprovider || frameprovider) {
> -- 
> 2.30.2
> 
>
Ariel D'Alessandro Dec. 13, 2021, 10:44 p.m. UTC | #2
Hi Rob,

On 12/13/21 5:37 PM, Rob Herring wrote:
> On Fri, Dec 03, 2021 at 10:49:29AM -0300, Ariel D'Alessandro wrote:
>> Sound cards may allow using different main clock inputs. In the generic
>> fsl-asoc-card driver, these values are hardcoded for each specific card
>> configuration.
>>
>> Let's make it more flexible, allowing setting mclk-id from the
>> device-tree node. Otherwise, the default value for each card
>> configuration is used.
>>
>> Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
>> ---
>>  Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 1 +
>>  sound/soc/fsl/fsl-asoc-card.c                             | 6 ++++++
>>  2 files changed, 7 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
>> index 23d83fa7609f..b219626a5403 100644
>> --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
>> +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
>> @@ -82,6 +82,7 @@ Optional properties:
>>    - dai-format		: audio format, for details see simple-card.yaml.
>>    - frame-inversion	: dai-link uses frame clock inversion, for details see simple-card.yaml.
>>    - bitclock-inversion	: dai-link uses bit clock inversion, for details see simple-card.yaml.
>> +  - mclk-id		: main clock id, specific for each card configuration.
> 
> Ahh, there it is. This change and the header defines should be 1 patch 
> and driver changes another.

Ah, I see. I'll split it and send a patchset v2 for this.

Thanks,
Ariel
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
index 23d83fa7609f..b219626a5403 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
@@ -82,6 +82,7 @@  Optional properties:
   - dai-format		: audio format, for details see simple-card.yaml.
   - frame-inversion	: dai-link uses frame clock inversion, for details see simple-card.yaml.
   - bitclock-inversion	: dai-link uses bit clock inversion, for details see simple-card.yaml.
+  - mclk-id		: main clock id, specific for each card configuration.
 
 Optional unless SSI is selected as a CPU DAI:
 
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 90cbed496f98..bb962e04d40b 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -693,6 +693,12 @@  static int fsl_asoc_card_probe(struct platform_device *pdev)
 		goto asrc_fail;
 	}
 
+	/*
+	 * Allow setting mclk-id from the device-tree node. Otherwise, the
+	 * default value for each card configuration is used.
+	 */
+	of_property_read_u32(np, "mclk-id", &priv->codec_priv.mclk_id);
+
 	/* Format info from DT is optional. */
 	snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, &bitclkprovider, &frameprovider);
 	if (bitclkprovider || frameprovider) {