diff mbox

[6/8] ASoC: atmel: support CCF based clks

Message ID 1395049541-28128-7-git-send-email-voice.shen@atmel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bo Shen March 17, 2014, 9:45 a.m. UTC
From: Boris BREZILLON <b.brezillon@overkiz.com>

Provide dev to clk_get function if we're using CCF based clks.
CCF based prog clks support automatic parent selection when asking for a
specific rate: remove the clk32k clk retrieval if we're using these clks.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
[voice.shen@atmel.com: switch to devm manage function]
Signed-off-by: Bo Shen <voice.shen@atmel.com>

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---

 sound/soc/atmel/atmel_wm8904.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

Bo Shen March 17, 2014, 9:55 a.m. UTC | #1
On 03/17/2014 05:45 PM, Bo Shen wrote:
> From: Boris BREZILLON <b.brezillon@overkiz.com>
>
> Provide dev to clk_get function if we're using CCF based clks.
> CCF based prog clks support automatic parent selection when asking for a
> specific rate: remove the clk32k clk retrieval if we're using these clks.
>
> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
> [voice.shen@atmel.com: switch to devm manage function]
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>
> Signed-off-by: Bo Shen <voice.shen@atmel.com>

Oh, sorry for multi SOBs. Please remove it when apply.

> ---
>
>   sound/soc/atmel/atmel_wm8904.c | 25 +++++++++++++------------
>   1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c
> index b4e3690..a797d33 100644
> --- a/sound/soc/atmel/atmel_wm8904.c
> +++ b/sound/soc/atmel/atmel_wm8904.c
> @@ -170,25 +170,26 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>
> -	mclk = clk_get(NULL, "pck0");
> +	mclk = devm_clk_get(&pdev->dev, "pck0");
>   	if (IS_ERR(mclk)) {
>   		dev_err(&pdev->dev, "failed to get pck0\n");
>   		ret = PTR_ERR(mclk);
>   		goto err_set_audio;
>   	}
>
> -	clk_src = clk_get(NULL, "clk32k");
> -	if (IS_ERR(clk_src)) {
> -		dev_err(&pdev->dev, "failed to get clk32k\n");
> -		ret = PTR_ERR(clk_src);
> -		goto err_set_audio;
> -	}
> +	if (!IS_ENABLED(CONFIG_COMMON_CLK)) {
> +		clk_src = devm_clk_get(&pdev->dev, "clk32k");
> +		if (IS_ERR(clk_src)) {
> +			dev_err(&pdev->dev, "failed to get clk32k\n");
> +			ret = PTR_ERR(clk_src);
> +			goto err_set_audio;
> +		}
>
> -	ret = clk_set_parent(mclk, clk_src);
> -	clk_put(clk_src);
> -	if (ret != 0) {
> -		dev_err(&pdev->dev, "failed to set MCLK parent\n");
> -		goto err_set_audio;
> +		ret = clk_set_parent(mclk, clk_src);
> +		if (ret != 0) {
> +			dev_err(&pdev->dev, "failed to set MCLK parent\n");
> +			goto err_set_audio;
> +		}
>   	}
>
>   	dev_info(&pdev->dev, "setting pck0 to %dHz\n", MCLK_RATE);
>

Best Regards,
Bo Shen
Boris BREZILLON March 17, 2014, 10:31 a.m. UTC | #2
Le 17/03/2014 10:45, Bo Shen a écrit :
> From: Boris BREZILLON <b.brezillon@overkiz.com>
>
> Provide dev to clk_get function if we're using CCF based clks.
> CCF based prog clks support automatic parent selection when asking for a
> specific rate: remove the clk32k clk retrieval if we're using these clks.
I would have split this patch:
1) make use of devm in the existing code
2) add CCF support


> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
> [voice.shen@atmel.com: switch to devm manage function]
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
>
>   sound/soc/atmel/atmel_wm8904.c | 25 +++++++++++++------------
>   1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c
> index b4e3690..a797d33 100644
> --- a/sound/soc/atmel/atmel_wm8904.c
> +++ b/sound/soc/atmel/atmel_wm8904.c
> @@ -170,25 +170,26 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	mclk = clk_get(NULL, "pck0");
> +	mclk = devm_clk_get(&pdev->dev, "pck0");

I wonder if we shouldn't change the requested clk name when using CCF.
After all this is a board decision to choose which programmable clk 
should be used.
The "pck0" implies that you're always connecting programmable clk 0 to 
the wm8904 chip.

What about "pck" instead of "pck0" ?


Best Regards,

Boris
>   	if (IS_ERR(mclk)) {
>   		dev_err(&pdev->dev, "failed to get pck0\n");
>   		ret = PTR_ERR(mclk);
>   		goto err_set_audio;
>   	}
>   
> -	clk_src = clk_get(NULL, "clk32k");
> -	if (IS_ERR(clk_src)) {
> -		dev_err(&pdev->dev, "failed to get clk32k\n");
> -		ret = PTR_ERR(clk_src);
> -		goto err_set_audio;
> -	}
> +	if (!IS_ENABLED(CONFIG_COMMON_CLK)) {
> +		clk_src = devm_clk_get(&pdev->dev, "clk32k");
> +		if (IS_ERR(clk_src)) {
> +			dev_err(&pdev->dev, "failed to get clk32k\n");
> +			ret = PTR_ERR(clk_src);
> +			goto err_set_audio;
> +		}
>   
> -	ret = clk_set_parent(mclk, clk_src);
> -	clk_put(clk_src);
> -	if (ret != 0) {
> -		dev_err(&pdev->dev, "failed to set MCLK parent\n");
> -		goto err_set_audio;
> +		ret = clk_set_parent(mclk, clk_src);
> +		if (ret != 0) {
> +			dev_err(&pdev->dev, "failed to set MCLK parent\n");
> +			goto err_set_audio;
> +		}
>   	}
>   
>   	dev_info(&pdev->dev, "setting pck0 to %dHz\n", MCLK_RATE);
diff mbox

Patch

diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c
index b4e3690..a797d33 100644
--- a/sound/soc/atmel/atmel_wm8904.c
+++ b/sound/soc/atmel/atmel_wm8904.c
@@ -170,25 +170,26 @@  static int atmel_asoc_wm8904_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	mclk = clk_get(NULL, "pck0");
+	mclk = devm_clk_get(&pdev->dev, "pck0");
 	if (IS_ERR(mclk)) {
 		dev_err(&pdev->dev, "failed to get pck0\n");
 		ret = PTR_ERR(mclk);
 		goto err_set_audio;
 	}
 
-	clk_src = clk_get(NULL, "clk32k");
-	if (IS_ERR(clk_src)) {
-		dev_err(&pdev->dev, "failed to get clk32k\n");
-		ret = PTR_ERR(clk_src);
-		goto err_set_audio;
-	}
+	if (!IS_ENABLED(CONFIG_COMMON_CLK)) {
+		clk_src = devm_clk_get(&pdev->dev, "clk32k");
+		if (IS_ERR(clk_src)) {
+			dev_err(&pdev->dev, "failed to get clk32k\n");
+			ret = PTR_ERR(clk_src);
+			goto err_set_audio;
+		}
 
-	ret = clk_set_parent(mclk, clk_src);
-	clk_put(clk_src);
-	if (ret != 0) {
-		dev_err(&pdev->dev, "failed to set MCLK parent\n");
-		goto err_set_audio;
+		ret = clk_set_parent(mclk, clk_src);
+		if (ret != 0) {
+			dev_err(&pdev->dev, "failed to set MCLK parent\n");
+			goto err_set_audio;
+		}
 	}
 
 	dev_info(&pdev->dev, "setting pck0 to %dHz\n", MCLK_RATE);