Linux-Clk Archive on lore.kernel.org
 help / color / Atom feed
From: Jonny Hall <jonny.hall@boxcast.com>
To: linux-clk@vger.kernel.org
Subject: Informing common clock framework driver of externally-derived base clock frequency
Date: Thu, 3 Jan 2019 21:35:47 -0500
Message-ID: <CAP_wsPYwykAPF=aedoHkZnKhLgFdbUNMK7tpFJkhMfr_X2Gnrg@mail.gmail.com> (raw)

I've been tasked with writing a driver for the Silabs si5342
programmable jitter attenuator / clock multiplier. Looking at existing
common clock framework drivers for similar parts (such as
clk-si5351.c), most of this is relatively straightforward -- it's a
composite device, with multiplexers that can select a parent clock,
and fractional-N dividers that support the set_rate and round_rate
functions. However, in all the examples I've seen, the ultimate parent
/ root clock source is specified in the device tree as a fixed
frequency -- a crystal / oscillator / other known-at-design-time
frequency source. However, in my application, the input frequency of
the si5342 is not known in advance, is derived from an external
source, and can change during runtime. The si5342 will need to be
(re)configured during operation with the frequency of this root clock
source in order to properly lock onto it and generate the correct
output frequencies -- it cannot independently determine the input
frequency, only "locked" / "unlocked" state.  The application software
(other drivers and usermode application code) will know the input
clock rate.  I've though of a couple ways to do this:

-Implement the root clock source as an "imaginary" divider where the
set_rate call actually configures the input dividers of the si5342.
This approach seems to abuse the common clock framework, as I'm not
actually *setting* the rate, I'm *informing* the driver of a rate that
was determined independently.

-Have my si5342 driver create a /dev/si5342 file or something in /sys/
where userspace functions can write the frequency to a file to inform
the driver. This approach seems dirty in that it's using two different
methods (common clock framework and device nodes) to access the same
hardware.

-Something else involving adding an inform_rate function to the common
clock framework to support clock sources derived from external,
variable rate sources -- this sounds beyond my skillset, and
potentially expanding the scope of the common clock framework beyond
what is intended.

Any thoughts on what approach would be the "best" in terms of working,
keeping with the spirit of the common clock framework, and not
breaking things?

Thanks,
  -Jonny

             reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190104023702epcas4p4e6b225121db059cb6ed167581c303e92@epcas4p4.samsung.com>
2019-01-04  2:35 ` Jonny Hall [this message]
2019-01-04  9:30   ` Sylwester Nawrocki
2019-01-04 21:29     ` Jonny Hall
2019-01-09 14:22       ` Sylwester Nawrocki
2019-01-29 22:26         ` Stephen Boyd

Reply instructions:

You may reply publically 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='CAP_wsPYwykAPF=aedoHkZnKhLgFdbUNMK7tpFJkhMfr_X2Gnrg@mail.gmail.com' \
    --to=jonny.hall@boxcast.com \
    --cc=linux-clk@vger.kernel.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

Linux-Clk Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
		linux-clk@vger.kernel.org linux-clk@archiver.kernel.org
	public-inbox-index linux-clk


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-clk


AGPL code for this site: git clone https://public-inbox.org/ public-inbox