Re: [Patch v4] driver/clk/clk-si5338: Add common clock framework driver for si5338

2015-07-20 Thread York Sun
Dear Maintainers,

Please review and advise if any change is needed.

Thanks.

York

On 06/17/2015 11:49 AM, York Sun wrote:
 SI5338 is a programmable clock generator. It has 4 sets of inputs,
 PLL, multisynth and dividers to make 4 outputs. This driver splits
 them into multiple clocks to comply with common clock framework.
 
 See Documentation/devicetree/bindings/clock/silabs,si5338.txt for
 details.
 
 Export __clk_is_prepared from clk.c so drivers can check and unprepare
 clocks upon removal.
 
 Signed-off-by: York Sun york...@freescale.com
 CC: Mike Turquette mturque...@baylibre.com
 CC: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
 CC: Guenter Roeck li...@roeck-us.net
 CC: Andrey Filippov and...@elphel.com
 CC: Paul Bolle pebo...@tiscali.nl
 
 ---
 Change log:
   v4: Add binding silabs,pll-vco
   Set pll rate initial value
   Separate COMMON_CLK change from this patch
 
   v3: Add calling unprepare upon removal
   Add registering to clkdev so the clk can be acquired when device
 tree is not in use
   Add a dev_info message when driver is removed
   Add missing static to two functions in clk-si5338.c
   Cosmatic fix in dt-bindings.clock/clk-si5338.h
 
   v2: Fix handling name prefix if the driver is unloaded and loaded again
 
  .../devicetree/bindings/clock/silabs,si5338.txt|  178 +
  drivers/clk/Kconfig|   12 +
  drivers/clk/Makefile   |1 +
  drivers/clk/clk-si5338.c   | 3682 
 
  drivers/clk/clk-si5338.h   |  305 ++
  drivers/clk/clk.c  |1 +
  include/dt-bindings/clock/clk-si5338.h |   68 +
  include/linux/platform_data/si5338.h   |   49 +
  8 files changed, 4296 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/clock/silabs,si5338.txt
  create mode 100644 drivers/clk/clk-si5338.c
  create mode 100644 drivers/clk/clk-si5338.h
  create mode 100644 include/dt-bindings/clock/clk-si5338.h
  create mode 100644 include/linux/platform_data/si5338.h
 
 diff --git a/Documentation/devicetree/bindings/clock/silabs,si5338.txt 
 b/Documentation/devicetree/bindings/clock/silabs,si5338.txt
 new file mode 100644
 index 000..807d5f6
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/clock/silabs,si5338.txt
 @@ -0,0 +1,178 @@
 +Binding for Silicon Labs Si5338 programmable i2c clock generator.
 +
 +Reference
 +[1] Si5338 Data Sheet
 +http://www.silabs.com/Support%20Documents/TechnicalDocs/Si5338.pdf
 +
 +The Si5338 is a programmable i2c clock generators with up to 4 output
 +clocks. It has 4 sets of possible input clocks
 +
 +IN1/IN2: differential
 +IN3: single-ended
 +IN4: single-ended
 +IN5/IN6: differential
 +
 +Additionally, IN1/IN2 can be used as XTAL with different setting.
 +The clock tree looks like below (without support of zero-delay)
 +
 +
 +  IN1/IN2 IN3 IN4 IN5/IN6
 + | |   | |
 +   --| |   | |
 +   | | |   | |
 +   | \ /   \ /
 +   |  \   / \   /
 +   |   \ /   \ /
 + XTAL REFCLKFBCLK
 +   |   |  \ /   |
 +   |   |   \   /|
 +   |   | DIVREFCLK DIVFBCLK |
 +   |   | \   /  |
 +   |   |  \ /   |
 +   |   |   \   /|
 +   |   |PLL |
 +   |   |  / | | \   |
 +   |   | /  / \  \  |
 +   |   |/  /   \  \ |
 +   |   |   /   |   |   \|
 +   |   |   |   |   |   ||
 +   |   |  MS0 MS1 MS2 MS3   |
 +   |   |   |   |   |   ||
 +
 +   OUT0  OUT1  OUT2  OUT3
 +
 +The output clock can choose from any of the above clock as its source, with
 +exceptions: MS1 can only be used for OUT1, MS2 can only be used for OUT2, MS3
 +can only be used for OUT3.
 +
 +==I2C device node==
 +
 +Required properties:
 +- compatible: shall be silabs,si5338.
 +- reg: i2c device address, shall be 0x60, 0x61, 0x70, or 0x71
 +- #clock-cells: shall be set to 1 for multiple outputs
 +- clocks: list of parent clocks in the order of xtal, in1/2, in3, 
 in4, in5/6
 +  Note, xtal and in1/2 are mutually exclusive. Only one can be set.
 +- #address-cells: shall be set to 1.
 +- #size-cells: shall be set to 0.
 +
 +Optional properties if not set by platform driver:
 +- silab,ref-source: source of refclk, valid value is defined as
 + #define SI5338_REF_SRC_CLKIN12  0
 + #define SI5338_REF_SRC_CLKIN3   1
 + #define SI5338_REF_SRC_XTAL 4
 +- silab,fb-source:  source of fbclk, valid value is defined as
 + #define SI5338_FB_SRC_CLKIN42
 + #define SI5338_FB_SRC_CLKIN56   3
 + #define SI5338_FB_SRC_NOCLK 5
 +- silabs,pll-source: source of pll, valid value is defined as
 + #define 

[Patch v4] driver/clk/clk-si5338: Add common clock framework driver for si5338

2015-06-17 Thread York Sun
SI5338 is a programmable clock generator. It has 4 sets of inputs,
PLL, multisynth and dividers to make 4 outputs. This driver splits
them into multiple clocks to comply with common clock framework.

See Documentation/devicetree/bindings/clock/silabs,si5338.txt for
details.

Export __clk_is_prepared from clk.c so drivers can check and unprepare
clocks upon removal.

Signed-off-by: York Sun york...@freescale.com
CC: Mike Turquette mturque...@baylibre.com
CC: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
CC: Guenter Roeck li...@roeck-us.net
CC: Andrey Filippov and...@elphel.com
CC: Paul Bolle pebo...@tiscali.nl

---
Change log:
  v4: Add binding silabs,pll-vco
  Set pll rate initial value
  Separate COMMON_CLK change from this patch

  v3: Add calling unprepare upon removal
  Add registering to clkdev so the clk can be acquired when device
tree is not in use
  Add a dev_info message when driver is removed
  Add missing static to two functions in clk-si5338.c
  Cosmatic fix in dt-bindings.clock/clk-si5338.h

  v2: Fix handling name prefix if the driver is unloaded and loaded again

 .../devicetree/bindings/clock/silabs,si5338.txt|  178 +
 drivers/clk/Kconfig|   12 +
 drivers/clk/Makefile   |1 +
 drivers/clk/clk-si5338.c   | 3682 
 drivers/clk/clk-si5338.h   |  305 ++
 drivers/clk/clk.c  |1 +
 include/dt-bindings/clock/clk-si5338.h |   68 +
 include/linux/platform_data/si5338.h   |   49 +
 8 files changed, 4296 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/silabs,si5338.txt
 create mode 100644 drivers/clk/clk-si5338.c
 create mode 100644 drivers/clk/clk-si5338.h
 create mode 100644 include/dt-bindings/clock/clk-si5338.h
 create mode 100644 include/linux/platform_data/si5338.h

diff --git a/Documentation/devicetree/bindings/clock/silabs,si5338.txt 
b/Documentation/devicetree/bindings/clock/silabs,si5338.txt
new file mode 100644
index 000..807d5f6
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/silabs,si5338.txt
@@ -0,0 +1,178 @@
+Binding for Silicon Labs Si5338 programmable i2c clock generator.
+
+Reference
+[1] Si5338 Data Sheet
+http://www.silabs.com/Support%20Documents/TechnicalDocs/Si5338.pdf
+
+The Si5338 is a programmable i2c clock generators with up to 4 output
+clocks. It has 4 sets of possible input clocks
+
+IN1/IN2: differential
+IN3: single-ended
+IN4: single-ended
+IN5/IN6: differential
+
+Additionally, IN1/IN2 can be used as XTAL with different setting.
+The clock tree looks like below (without support of zero-delay)
+
+
+  IN1/IN2 IN3 IN4 IN5/IN6
+ | |   | |
+   --| |   | |
+   | | |   | |
+   | \ /   \ /
+   |  \   / \   /
+   |   \ /   \ /
+ XTAL REFCLKFBCLK
+   |   |  \ /   |
+   |   |   \   /|
+   |   | DIVREFCLK DIVFBCLK |
+   |   | \   /  |
+   |   |  \ /   |
+   |   |   \   /|
+   |   |PLL |
+   |   |  / | | \   |
+   |   | /  / \  \  |
+   |   |/  /   \  \ |
+   |   |   /   |   |   \|
+   |   |   |   |   |   ||
+   |   |  MS0 MS1 MS2 MS3   |
+   |   |   |   |   |   ||
+
+   OUT0  OUT1  OUT2  OUT3
+
+The output clock can choose from any of the above clock as its source, with
+exceptions: MS1 can only be used for OUT1, MS2 can only be used for OUT2, MS3
+can only be used for OUT3.
+
+==I2C device node==
+
+Required properties:
+- compatible: shall be silabs,si5338.
+- reg: i2c device address, shall be 0x60, 0x61, 0x70, or 0x71
+- #clock-cells: shall be set to 1 for multiple outputs
+- clocks: list of parent clocks in the order of xtal, in1/2, in3, in4, 
in5/6
+  Note, xtal and in1/2 are mutually exclusive. Only one can be set.
+- #address-cells: shall be set to 1.
+- #size-cells: shall be set to 0.
+
+Optional properties if not set by platform driver:
+- silab,ref-source: source of refclk, valid value is defined as
+   #define SI5338_REF_SRC_CLKIN12  0
+   #define SI5338_REF_SRC_CLKIN3   1
+   #define SI5338_REF_SRC_XTAL 4
+- silab,fb-source:  source of fbclk, valid value is defined as
+   #define SI5338_FB_SRC_CLKIN42
+   #define SI5338_FB_SRC_CLKIN56   3
+   #define SI5338_FB_SRC_NOCLK 5
+- silabs,pll-source: source of pll, valid value is defined as
+   #define SI5338_PFD_IN_REF_REFCLK   0
+   #define SI5338_PFD_IN_REF_FBCLK1
+   #define SI5338_PFD_IN_REF_DIVREFCLK2
+   #define SI5338_PFD_IN_REF_DIVFBCLK 3
+   #define SI5338_PFD_IN_REF_XOCLK4