public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: York Sun <yorksun@freescale.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>, <mturquette@linaro.org>
Cc: <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<lee.jones@linaro.org>, <andrey@elphel.com>,
	<rabeeh@solid-run.com>
Subject: Re: clock driver
Date: Wed, 27 May 2015 09:46:02 -0700	[thread overview]
Message-ID: <5565F4CA.4080105@freescale.com> (raw)
In-Reply-To: <5565F40E.70805@gmail.com>



On 05/27/2015 09:42 AM, Sebastian Hesselbarth wrote:
> On 27.05.2015 17:07, York Sun wrote:
>> On 05/27/2015 12:09 AM, Sebastian Hesselbarth wrote:
> [...]
>>> Also, why should a user ever be able to mess with the clocks? If you
>>> allow a user to change the clock rate of any output, you have to
>>> consider that he will likely be able to crash your system easily.
>>>
>>> As long as you cannot give a clear requirement for user-configurable
>>> clocks - especially in the detail of the driver you mentioned -
>>> mainline kernel is not the place for such a driver.
>>
>> This driver I am proposing supports SI5338 in a generic way. It can take device
>> tree as its default configuration. However I am using it differently, explained
>> in detail below.
> [...]
>>> (a) Clocks are limited to the PCI card and only need a limited set of
>>> configurable clocks. You should add functions to load the registers
>>> with either the full register map or parts of it in a table based
>>> approach. You don't expose the clocks with CCF but deal with rate
>>> change requests internally in the PCI driver. You could also consider
>>> to have the initial clock configuration as part of some firmware blob
>>> you request with the PCI driver.
>>
>> That's right. I only need to change a small portion of the configuration, such
>> as frequency, but keeping the reset the same, including output driver voltage,
>> input clock, etc.
> [...]
>> My application has a host SoC booting up Linux. Then the clocks on PCIe (FPGA)
>> cards get initialized with their clocks. The clocks are not used by host SoC, so
>> setting the wrong clocks doesn't crash the system. Each PCIe card has up to four
>> clock chips (with four clocks on each chip). It is required for users to be able
>> to change the clocks after system boots up.
> 
> Consider a userspace configurable clock driver, load the FPGA design
> which depends on a specific frequency generated by Si5338 and let the
> user mess with your sysfs files - that will certainly crash your system.
> 
> Still, I do not see any requirement for a clock driver for that use
> case. You have to load the FPGA design or at least configure it to
> use the Si5338 generated clocks _after_ configuring Si5338. You'll
> have to have a user interface for FPGA bitfile loading, so you can
> add another one for the clock generator config.
> 
>> I wrote my driver for the PCIe cards so the clocks can be initialized using the
>> data provided. But changing the clocks, or initializing with another set of
>> configuration requires an interface. There are many ways to solve this. I would
>> like to keep the clock driver generic so it can be reused. It looks like CCF may
>> not be the best fit for such driver. What is an acceptable way to write this
>> driver so it can be in the mainline kernel, or other maintained projects (I am
>> not aware of any though)?
> 
> IMHO "generic" as in a generic mainline kernel clock driver just means
> that other _drivers_ can request any clock rate from that chip. If you
> want to write a CCF driver for Si5338, you'll have to make your PCIe
> driver request that clock and hide the userspace configuration within
> your PCIe driver.
> 
> Adding userspace interfaces to generic CCF clock drivers will not happen
> just because messing with the clocks will break a running system. As I
> said before, AFAIKS i2c-dev should give you enough of an interface to
> configure the clock generator from userspace.
>

Sebastian,

Thanks for the insight. Looks like I should give up upstreaming this driver. I
will find other ways to make this driver available if anyone wants to use it.

York

  reply	other threads:[~2015-05-27 16:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 19:12 clock driver York Sun
2015-05-26 22:38 ` Guenter Roeck
2015-05-27  0:20   ` York Sun
2015-05-27  0:32     ` York Sun
2015-05-27  7:09       ` Sebastian Hesselbarth
2015-05-27 15:07         ` York Sun
2015-05-27 16:42           ` Sebastian Hesselbarth
2015-05-27 16:46             ` York Sun [this message]
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
2015-05-27 18:15           ` Guenter Roeck
2015-05-27 18:24             ` York Sun
2015-05-27 18:54               ` Guenter Roeck
2015-05-27 18:58                 ` York Sun
     [not found]                   ` <14d96cd6d64.f62a1a09739217.9114963256886461171@elphel.com>
2015-05-27 23:08                     ` Guenter Roeck
2015-05-27 23:58                       ` andrey
2015-05-28  0:10                         ` Guenter Roeck
2015-05-28  0:29                           ` andrey
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=5565F4CA.4080105@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