linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: moinejf@free.fr (Jean-Francois Moine)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ASoC: kirkwood: simplify clock handling
Date: Tue, 24 Sep 2013 21:04:42 +0200	[thread overview]
Message-ID: <20130924210442.6f617798@armhf> (raw)
In-Reply-To: <1380046355-7920-1-git-send-email-u.kleine-koenig@pengutronix.de>

On Tue, 24 Sep 2013 20:12:35 +0200
Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> wrote:

> There is no need to not use extclk if it is identical to the main clk.
> The main motivation for this patch is dropping devm_clk_put which is
> used in a wrong way by all other users.
> 
> While at it also extend the comments.
> 
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> ---
> Hello,
> 
> there might be some further optimisations possible. I only note them
> here because I don't have the hardware to test:
> 
>  - only enable extclk if it a clock rate used that makes use of the
>    external clock. Not sure if that works; hardware docs reading
>    necessary.
>  - only provide extclk if it's != the internal clock.
>  - The code uses:
> 
> 	priv->clk = devm_clk_get(&pdev->dev, np ? "internal" : NULL);
> 
>    i.e. provides a con_id in the dt-case. I think that using NULL
>    unconditionally should also work, i.e. return the first clk
>    associated to the device. OTOH the current code might make things
>    clearer because it's more explicit.
	[snip]

Uwe,

The code around line 104 in kirkwood-i2s.c is not what it should be
(the patch from Russell is lost somewhere in the mailing-list).
Instead of:

	if (rate == 44100 || rate == 48000 || rate == 96000) {
		/* use internal dco for the supported rates
		 * defined in kirkwood_i2s_dai */

it should be:

	if (IS_ERR(priv->extclk)) {	/* no external clock */
		/* use internal dco - the supported rates are
		 * defined in kirkwood_i2s_dai */

That is: if there is an external clock, use it.

In fact, the internal dco is used for two audio devices. When both
devices are used at the same time, at least one of them must always use
an external clock, otherwise, there is a clock rate conflict.

As only one clock is used, there is no need to declare 2 clocks in the
DT, but the driver must know if it uses the internal or external clock
(to set the right clock input and also because their rates are not set
the same way)

So, the probe code should be:

	/* check first if an external clock is declared */
	priv->extclk = devm_clk_get(&pdev->dev, "extclk");
	if (!IS_ERR(priv->extclk)) {
		... use the external clock ...
	} else {

		/* get the first clock which must be the dco */
		priv->clk = devm_clk_get(&pdev->dev, NULL);
		if (IS_ERR(priv->clk))
			.. error, no clock ..
		.. use the internal dco ...
	}

-- 
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

  parent reply	other threads:[~2013-09-24 19:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23 15:45 [PATCH] clk: fix function name in devm_clk_put kernel-doc comment Uwe Kleine-König
2013-09-23 15:53 ` [PATCH] serial: clps711x: drop needless devm_clk_put Uwe Kleine-König
2013-09-23 16:00 ` [PATCH] remoteproc/davinci: " Uwe Kleine-König
2014-02-24 15:07   ` Ohad Ben-Cohen
2013-09-23 16:13 ` [PATCH] video: mmp: drop needless devm cleanup Uwe Kleine-König
2013-09-23 16:19   ` Russell King - ARM Linux
2013-09-24  7:34     ` Tomi Valkeinen
2013-09-24  7:55       ` Zhou Zhu
2013-09-26  8:43   ` Tomi Valkeinen
2013-09-23 16:28 ` [PATCH] clk: fix function name in devm_clk_put kernel-doc comment Russell King - ARM Linux
2013-09-24 18:12 ` [PATCH] ASoC: kirkwood: simplify clock handling Uwe Kleine-König
2013-09-24 18:38   ` Russell King - ARM Linux
2013-09-24 19:04   ` Jean-Francois Moine [this message]
2013-09-24 19:05     ` Russell King - ARM Linux
2013-09-24 19:24       ` Uwe Kleine-König
2013-09-24 18:42 ` [PATCH] [media] marvell-ccic: simplify and fix clk handling (a bit) Uwe Kleine-König
2013-09-24 18:59   ` [PATCH v2] " Uwe Kleine-König
2013-09-25  7:15     ` Jonathan Corbet
2013-09-26  2:47       ` Libin Yang
2013-09-26  8:13         ` Uwe Kleine-König
2013-09-26  8:24           ` Russell King - ARM Linux
2013-09-26 10:08             ` Libin Yang
2013-09-26 10:03           ` Libin Yang
2013-09-24 19:20 ` [PATCH] [RFC] devm: drop devm_clk_put Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130924210442.6f617798@armhf \
    --to=moinejf@free.fr \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).