linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: York Sun <yorksun@freescale.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Michael Turquette <mturquette@linaro.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	lee.jones@linaro.org, andrey@elphel.com,
	sebastian.hesselbarth@gmail.com, rabeeh@solid-run.com
Subject: Re: clock driver
Date: Wed, 27 May 2015 11:58:22 -0700	[thread overview]
Message-ID: <556613CE.8020906@freescale.com> (raw)
In-Reply-To: <20150527185442.GA6607@roeck-us.net>



On 05/27/2015 11:54 AM, Guenter Roeck wrote:
> On Wed, May 27, 2015 at 11:24:50AM -0700, York Sun wrote:
>>
>>>
>>> Someone suggested earlier that the clocks should be set from the PCIe driver.
>>> Question here is really if you need to control the clocks from user space.
>>> Even if you do, the driver for the chip _using_ the clocks would be better
>>> suited for changing the clock rates than the clock driver itself. This way it
>>> can ensure that the clock rates are sane for the given use case, and the use
>>> case is kept out of the clock driver.
>>>
>>>> I wrote a driver for the PCIe card to load FPGA images. To setup the clocks, I
>>>> rewrote the SI5338 driver and set the desired frequencies using sysfs. This
>>>> driver has a feature to import/dump the raw configuration data. That's one
>>>> feature I plan to use, at least for debugging.
>>>>
>>> With the above in mind, the idea would be for the PCIe driver to set the clock
>>> rates.
>>
>> I am interested in this path. Can you explain a little bit more about setting
>> the clock rates? I have no experience on CCF.
>>
> The API functions are documented in include/linux/clk.h. What you are looking
> for here would be clk_set_rate() and related functions such as clk_round_rate(),
> and of course support functions such as devm_clk_get(), clk_prepare_enable(),
> and clk_disable_unprepare().
> 
> You can find lots of examples on how this works if you search for clk_set_rate()
> in the kernel source.

Yes I saw them. I have no experience with CCF. It will take some learning time.
I am trying to find an SI5xx EVB board so I can try it out.

> 
>>>
>>>> I don't think device tree is the best for my application because I will have
>>>> about 30 clock chips to program in the complete system. It is easier to use user
>>>> space application to do so from I2C bus.
>>>>
>>> Devicetree is static, so you might have to use devicetree overlays if the
>>> programming changes at runtime. Not sure why the number of clock chips
>>> would make that non-feasible, though.
>>
>> I mean the existence is unknown for many chips. The baseline is I can't use
>> static data.
>>
>>>
>>> On a side note, we are using devicetree a lot for PCIe devices.
>>
>> It's tempting. I want to explore this direction at a later phase of my project.
>> I will appreciate if you can point me to something.
>>
> I can send you some devicetree files if you think that would help. Note that we
> are heavily using devicetree overlays, so this is all a bit WIP.

Yes, please send them to me.

> 
>>>
>>>> Earlier Guenter helped me to comb through the idea and we concluded CCF may not
>>>> be the best fit for this application. I wonder if CCF is the only way to get
>>>
>>> Well, you did ;-). I think it would be feasible, but you would have to change
>>> your viewpoint (in respect to how to control the clocks).
>>
>> Right, I did. I will revisit this after bring up the platform initially, when I
>> have more knowledge about those clocks. Maybe I should add an interface for my
>> FPGA driver to request clock rates, instead of setting them from clock driver.
>> It sounds better.
>>
> Yes, that would be the idea. Essentially your FPGA driver could either determine
> the clock rate(s) it needs internally, or you could set the clock rate(s)
> through sysfs attributes attached to the FPGA driver. The FPGA driver would then
> use clk_set_rate() to set the rate in the clock chip.
> 

Sounds promising. Thanks for the guidance.

York

  reply	other threads:[~2015-05-27 18:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 19:12 clock driver York Sun
     [not found] ` <5564C58B.9050400-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-05-26 22:38   ` Guenter Roeck
     [not found]     ` <20150526223829.GA26454-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2015-05-27  0:20       ` York Sun
     [not found]         ` <55650DBA.5000304-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-05-27  0:32           ` York Sun
     [not found]             ` <5565108D.2020502-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-05-27  7:09               ` Sebastian Hesselbarth
2015-05-27 15:07                 ` York Sun
2015-05-27 16:42                   ` Sebastian Hesselbarth
     [not found]                     ` <5565F40E.70805-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-27 16:46                       ` York Sun
     [not found]                         ` <5565F4CA.4080105-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-05-27 17:09                           ` Guenter Roeck
2015-05-27 17:10                             ` York Sun
2015-05-27 17:30               ` Michael Turquette
2015-05-27 17:45                 ` York Sun
     [not found]                   ` <556602BC.6040203-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-05-27 18:15                     ` Guenter Roeck
     [not found]                       ` <20150527181521.GA19448-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2015-05-27 18:24                         ` York Sun
2015-05-27 18:54                           ` Guenter Roeck
2015-05-27 18:58                             ` York Sun [this message]
     [not found]                               ` <14d96cd6d64.f62a1a09739217.9114963256886461171@elphel.com>
     [not found]                                 ` <14d96cd6d64.f62a1a09739217.9114963256886461171-MoRZu3FOBbXQT0dZR+AlfA@public.gmane.org>
2015-05-27 23:08                                   ` Guenter Roeck
2015-05-27 23:58                                     ` andrey
     [not found]                                       ` <14d97d05f05.c0c23a8c778110.9087956443203424916-MoRZu3FOBbXQT0dZR+AlfA@public.gmane.org>
2015-05-28  0:10                                         ` Guenter Roeck
2015-05-28  0:29                                           ` andrey
     [not found]                                             ` <14d97ec12ae.121e65c4b780118.1307005790953163680-MoRZu3FOBbXQT0dZR+AlfA@public.gmane.org>
2015-05-28  6:11                                               ` Michael Turquette
2015-05-28 15:24                                                 ` York Sun
2015-06-10  0:40                 ` York Sun

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=556613CE.8020906@freescale.com \
    --to=yorksun@freescale.com \
    --cc=andrey@elphel.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mturquette@linaro.org \
    --cc=rabeeh@solid-run.com \
    --cc=sebastian.hesselbarth@gmail.com \
    /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).