linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] clk: CCF clock primitives + custom IO accessors
@ 2014-02-28 23:34 Soren Brinkmann
  2014-02-28 23:34 ` [PATCH RFC 1/3] clk: Introduce I2C clock primitives Soren Brinkmann
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Soren Brinkmann @ 2014-02-28 23:34 UTC (permalink / raw)
  To: Mike Turquette, Stephen Boyd, Gerhard Sittig
  Cc: Michal Simek, linux-arm-kernel, linux-kernel, Sören Brinkmann

Hi,

I recently ran into a problem which seems to become common. I was trying
to write a driver for the TI CDCE913, a programmable clock synthesizer
on the I2C bus. Internally that device consists of a PLL and a bunch of
muxes, gates and dividers that eventually end up in three clock outputs.
Looking at that device, it seems rather easy to model it with the
available clock primitives, the problem though is, the clock
primitives assume accesses via memory mapped IO.

To overcome a similar problem the PPC folks introduced the
clk_(read|write)l wrappers, which seems to go into the right direction,
but that also only allows per ARCH overrides. I.e. wouldn't allow
mixing of MMIO clocks and clocks using I2C via regmap or similar.

So, the first thing I did, was essentially duplicating the clock
primitives I need and simply replacing the readl/writel with
regmap_read/write. So there is a lot of code duplication to use all the
fancy features the clk-mux and clk-div primitives provide, just to
replace the IO access.

In the next step, I encountered a divider clock whose divider is stored
in 2 I2C registers. So now, the simple IO access replacement doesn't
work anymore either since this clock needs 2 registers to be read and
then shifting around the bitfields accordingly.

Does anybody have a good idea how we could avoid all this code
duplication while enabling usage of the clock primitives with different
IO accessors?
Especially the divider and mux primitive have a lot of code that would
be painful to maintain twice.

	Thanks,
	Sören

Soren Brinkmann (3):
  clk: Introduce I2C clock primitives
  clk/i2c-div: Allow custom divider accessors
  clk: Add driver for TI CDCE913

 .../devicetree/bindings/clock/ti,cdce913.txt       |  32 +
 drivers/clk/Kconfig                                |  15 +
 drivers/clk/Makefile                               |   6 +
 drivers/clk/clk-cdce913.c                          | 841 +++++++++++++++++++++
 drivers/clk/clk-i2c-divider.c                      | 375 +++++++++
 drivers/clk/clk-i2c-mux.c                          | 173 +++++
 drivers/clk/clk-i2c.c                              |  22 +
 include/linux/clk-provider.h                       | 104 +++
 8 files changed, 1568 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti,cdce913.txt
 create mode 100644 drivers/clk/clk-cdce913.c
 create mode 100644 drivers/clk/clk-i2c-divider.c
 create mode 100644 drivers/clk/clk-i2c-mux.c
 create mode 100644 drivers/clk/clk-i2c.c

-- 
1.9.0.1.g4196000


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-03-03 19:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-28 23:34 [PATCH RFC 0/3] clk: CCF clock primitives + custom IO accessors Soren Brinkmann
2014-02-28 23:34 ` [PATCH RFC 1/3] clk: Introduce I2C clock primitives Soren Brinkmann
2014-02-28 23:34 ` [PATCH RFC 2/3] clk/i2c-div: Allow custom divider accessors Soren Brinkmann
2014-02-28 23:34 ` [PATCH RFC 3/3] clk: Add driver for TI CDCE913 Soren Brinkmann
2014-03-02 20:29 ` [PATCH RFC 0/3] clk: CCF clock primitives + custom IO accessors Gerhard Sittig
2014-03-03 17:35   ` Sören Brinkmann
2014-03-03 19:07     ` Gerhard Sittig
2014-03-03 19:13       ` Sören Brinkmann
2014-03-03 19:38         ` Stephen Boyd
2014-03-03 19:46           ` Sören Brinkmann

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).