public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: emilio@elopez•com.ar (Emilio López)
To: linux-arm-kernel@lists•infradead.org
Subject: Common clock: function clock and bus clock
Date: Thu, 13 Mar 2014 00:16:35 -0300	[thread overview]
Message-ID: <53212313.9040305@elopez.com.ar> (raw)
In-Reply-To: <CADApbeh0zjd=qMguiqQGrn=0v+-SVqgnyL=Gk8D9MiQvHU2XGA@mail.gmail.com>

Hi,

El mi? 12 mar 2014 23:15:20 ART, Chao Xie escribi?:
> On Wed, Mar 12, 2014 at 6:14 PM, Grygorii Strashko
> <grygorii.strashko@ti•com> wrote:
>> On 03/12/2014 04:30 AM, Chao Xie wrote:
>>>
>>> On Tue, Mar 11, 2014 at 10:48 AM, Haojian Zhuang
>>> <haojian.zhuang@gmail•com> wrote:
>>>>
>>>> On Tue, Mar 11, 2014 at 10:06 AM, Chao Xie <xiechao.mail@gmail•com>
>>>> wrote:
>>>>>
>>>>> hi
>>>>>
>>>>> I can not find any examples for handling function clock and bus clock
>>>>> in drivers/clk/.
>>>>>
>>>>> For a device, it will have a function clock and bus clock. function
>>>>> clock will control the fucntionality of this device, while bus clock
>>>>> will control the communication part to the bus.
>>>>>
>>>>> For some SOCes, they do not export bus clock, so from the hardware it
>>>>> seems that function clock is combined with bus clock, while for some
>>>>> SOCes, they are not.
>>>>>
>>>>> For most of the device driver, they will enable/disable function clock
>>>>> and bus clock both. While for some devices, they may share bus clock,
>>>>> and have different function clocks.

You can define two normal clocks and use them like this

* If a device has both bus and module

clocks = <&abc ...>, <&xyz ...>;
clock-names = "bus", "module";

* If a device only has module clock

clocks = <&xyz ...>;
clock-names = "module";

Then on the driver to control this specific hardware you can do 
something like

/* mandatory module clock */
mod = devm_clk_get(dev, "module");
if (!IS_ERR(mod))
	clk_prepare_enable(mod)
else
	goto fail;	

/* optional bus clock */
bus = devm_clk_get(dev, "bus");
if (!IS_ERR(bus))
	clk_prepare_enable(bus)


The framework keeps count of how many times clocks have been enabled, so 
as long as a device needs the bus clock, it will remain operational.

You can find many examples of this pattern with

$ grep 'clock-names.*ahb' arch/arm/boot/dts/*dts*

Cheers,

Emilio

  reply	other threads:[~2014-03-13  3:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11  2:06 Common clock: function clock and bus clock Chao Xie
2014-03-11  2:48 ` Haojian Zhuang
2014-03-12  2:30   ` Chao Xie
2014-03-12 10:14     ` Grygorii Strashko
2014-03-13  2:15       ` Chao Xie
2014-03-13  3:16         ` Emilio López [this message]
2014-03-13 11:30           ` Grygorii Strashko
     [not found]             ` <20140319210428.31449.19420@quantum>
     [not found]               ` <CAPDyKFqg230Ob5Wxu0tvXqia+B3WG5+YdKTdxTQ0ySbZokb+7Q@mail.gmail.com>
2014-03-20 10:30                 ` Grygorii Strashko
2014-03-20 11:42         ` Russell King - ARM Linux
2014-03-20  9:45 ` Ben Dooks
2014-03-20 11:35   ` Russell King - ARM Linux

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=53212313.9040305@elopez.com.ar \
    --to=emilio@elopez$(echo .)com.ar \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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