Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: Tushar Behera <tushar.behera@linaro.org>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, tiwai@suse.de, perex@perex.cz,
	dianders@chromium.org, jerry.wong@maximintegrated.com
Subject: Re: [PATCH 1/2] ASoC: max98090: Add master clock handling
Date: Fri, 23 May 2014 00:36:28 +0100	[thread overview]
Message-ID: <20140522233628.GW12304@sirena.org.uk> (raw)
In-Reply-To: <537E7937.2010408@wwwdotorg.org>

[-- Attachment #1: Type: text/plain, Size: 2975 bytes --]

On Thu, May 22, 2014 at 04:24:55PM -0600, Stephen Warren wrote:

> My main worry is that this patch opens the door for set_sysclk() to
> perform some kind of calculation to determine the MCLK rate. Right now,
> this patch doesn't do that, but there's nothing obvious from the code
> that no CODEC is allowed to do that. After all, sysclk has a parameter
> to indicate *which* clock in the CODEC to set. Some CODEC driver author
> might write something where the machine driver tells the CODEC driver
> the desired rate of some CODEC-internal PLL, from which set_sysclk()
> calculates what it needs for MCLK, and then goes off and requests that
> value from the clock API.

I really think you're reading too much into this - the set_sysclk() API
isn't any different to the clock API here really and most of the
potential for doing really problematic stuff and defining your clocks to
mean funny things exists anyway.  Of course people could do tasteless
things but that's always going to be a risk and we also want to try to
minimise the amount of redundant code people have to write.

It should be fairly easy to spot substantial abuse since the driver
would need to call clk_set_rate() with a different rate.

> Ignoring that, I'm still not sure that the CODEC driver setting the MCLK
> rate is appropriate. If we have 1 MCLK output from an SoC, connected to
> 2 different CODECs, why wouldn't the overall machine driver call
> clk_set_rate() on that clock, and then notify the two CODEC drivers of
> that rate. Making each CODEC's set_sysclk() call clk_set_rate() on the
> same clock with the same value seems redundant, albeit it should work
> out fine since they both request the same rate.

Right, it should work fine and it's less work for the machine drivers.
The alternative is that every machine driver using a device with a
programmable input has the code to get that clock from the CODEC device
and set it in sync with telling the CODEC about it which is redundant
and makes life harder for generic drivers like simple card (which
obviously can't know the specifics of every CODEC it works with).

It's certainly a more normal thing from a device model and device tree
point of view for the CODEC to be responsible for getting the resource
and it seems natural to extend that to such basic management as setting
the rate.  

If anything I think want to expose some or all of the CODEC clock trees
to the clock API, sometimes (rarely but not never) the CODEC PLLs and
FLLs are used to supply things outside the audio subsystem if they
happen to be going spare, it's difficult to do that at the minute since
there's no guaranteed API for being a clock provider.  At the minute
we're mostly reimplementing a custom clock API which seems like the
wrong way to be doing things.  That might go towards answering your
concerns since set_sysclk() would end up as a clock API call (or at
least a thin wrapper around one).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-05-22 23:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22  9:17 [PATCH 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
2014-05-22  9:17 ` [PATCH 1/2] ASoC: max98090: Add master clock handling Tushar Behera
2014-05-22 10:30   ` Mark Brown
     [not found]     ` <20140522103039.GD12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-23  5:35       ` Tushar Behera
     [not found]         ` <CAHbNUh2QHv8n7Y19qfO7BagX5AWe0i17MjDvr7yOpHf6YNGW4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-23 11:14           ` Mark Brown
     [not found]             ` <20140523111446.GA12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-23 11:36               ` Tushar Behera
     [not found]                 ` <CAHbNUh152xgyVxcCHiv0M6PLw8DE7KZ990WG7uRWWFBc8sPWRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-23 11:41                   ` Mark Brown
     [not found]                     ` <20140523114113.GE12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-23 12:02                       ` Tushar Behera
2014-05-22 15:51   ` Stephen Warren
     [not found]     ` <537E1D0A.6020303-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-05-22 17:34       ` Mark Brown
     [not found]         ` <20140522173403.GL12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-22 17:50           ` Stephen Warren
     [not found]             ` <537E38FF.9000407-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-05-22 18:19               ` Mark Brown
2014-05-22 22:24                 ` Stephen Warren
2014-05-22 23:36                   ` Mark Brown [this message]
2014-05-22  9:17 ` [PATCH 2/2] ASoC: max98095: " Tushar Behera
2014-05-22 10:31   ` Mark Brown

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=20140522233628.GW12304@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=jerry.wong@maximintegrated.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=swarren@wwwdotorg.org \
    --cc=tiwai@suse.de \
    --cc=tushar.behera@linaro.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