Skip to contentSkip to conversation

clk: Add driver for the si544 clock generator chip

PATCH Superseded Mike Looijmans 3 participants 8 messages Mar 15, 2018 – Mar 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 clk: Add driver for the si544 clock generator chip

This patch adds the driver and devicetree documentation for the Silicon Labs SI544 clock generator chip. This is an I2C controlled oscillator capable of generating clock signals ranging from 200kHz to 1500MHz.

---
v2: Add u64 cast to ls_div_bits calculation loop
When ls_div_bits is non-zero, the hs_div must always be even

 .../devicetree/bindings/clock/silabs,si544.txt     |  25 ++
 drivers/clk/Kconfig                                |  10 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk-si544.c                            | 422 +++++++++++++++++++++
 4 files changed, 458 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/silabs,si544.txt
 create mode 100644 drivers/clk/clk-si544.c
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +25 -0
new file mode 100644
index 0000000..eec1787
@@ -0,0 +1,25 @@
+Binding for Silicon Labs 544 programmable I2C clock generator.
+
+Reference
+This binding uses the common clock binding[1]. Details about the device can be
+found in the datasheet[2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Si544 datasheet
+    https://www.silabs.com/documents/public/data-sheets/si544-datasheet.pdf
+
+Required properties:
+ - compatible: One of "silabs,si514a", "silabs,si514b" "silabs,si514c" according
+               to the speed grade of the chip.
+ - reg: I2C device address.
+ - #clock-cells: From common clock bindings: Shall be 0.
+
+Optional properties:
+ - clock-output-names: From common clock bindings. Recommended to be "si544".
+
+Example:
+	si544: clock-generator@55 {
+		reg = <0x55>;
+		#clock-cells = <0>;
+		compatible = "silabs,si544b";
+	};
drivers/clk/Kconfig +10 -0
index 98ce9fc..5c7dc8e 100644
@@ -91,6 +91,16 @@ config COMMON_CLK_SI514
 	  This driver supports the Silicon Labs 514 programmable clock
 	  generator.
 
+config COMMON_CLK_SI544
+	tristate "Clock driver for SiLabs 544 devices"
+	depends on I2C
+	depends on OF
+	select REGMAP_I2C
+	help
+	---help---
+	  This driver supports the Silicon Labs 544 programmable clock
+	  generator.
+
 config COMMON_CLK_SI570
 	tristate "Clock driver for SiLabs 570 and compatible devices"
 	depends on I2C
drivers/clk/Makefile +1 -0
index 71ec41e..bde614a 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_COMMON_CLK_S2MPS11)	+= clk-s2mps11.o
 obj-$(CONFIG_COMMON_CLK_SCPI)           += clk-scpi.o
 obj-$(CONFIG_COMMON_CLK_SI5351)		+= clk-si5351.o
 obj-$(CONFIG_COMMON_CLK_SI514)		+= clk-si514.o
+obj-$(CONFIG_COMMON_CLK_SI544)		+= clk-si544.o
 obj-$(CONFIG_COMMON_CLK_SI570)		+= clk-si570.o
 obj-$(CONFIG_ARCH_STM32)		+= clk-stm32f4.o
 obj-$(CONFIG_ARCH_STM32)		+= clk-stm32h7.o
drivers/clk/clk-si544.c new file +422 -0

422 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 32 lines · Mike Looijmans

This patch adds the driver and devicetree documentation for the Silicon Labs SI544 clock generator chip. This is an I2C controlled oscillator capable of generating clock signals ranging from 200kHz to 1500MHz.

---
v2: Add u64 cast to ls_div_bits calculation loop
When ls_div_bits is non-zero, the hs_div must always be even

 .../devicetree/bindings/clock/silabs,si544.txt     |  25 ++
 drivers/clk/Kconfig                                |  10 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk-si544.c                            | 422 +++++++++++++++++++++
 4 files changed, 458 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/silabs,si544.txt
 create mode 100644 drivers/clk/clk-si544.c
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +8 -0
new file mode 100644
index 0000000..eec1787
@@ -0,0 +1,25 @@
+Binding for Silicon Labs 544 programmable I2C clock generator.
+
+Reference
+This binding uses the common clock binding[1]. Details about the device can be
+found in the datasheet[2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Si544 datasheet

Documentation/devicetree/bindings/clock/silabs,si544.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +10 -0
+    https://www.silabs.com/documents/public/data-sheets/si544-datasheet.pdf
+
+Required properties:
+ - compatible: One of "silabs,si514a", "silabs,si514b" "silabs,si514c" according
+               to the speed grade of the chip.
+ - reg: I2C device address.
+ - #clock-cells: From common clock bindings: Shall be 0.
+
+Optional properties:
+ - clock-output-names: From common clock bindings. Recommended to be "si544".

What's the point if there is only 1 clock output?

Documentation/devicetree/bindings/clock/silabs,si544.txt line 21

Quoted 3 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +3 -0
+
+Example:
+	si544: clock-generator@55 {

clock-controller@55 is the standard node name.

Documentation/devicetree/bindings/clock/silabs,si544.txt line 25

Quoted 4 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +4 -0
+		reg = <0x55>;
+		#clock-cells = <0>;
+		compatible = "silabs,si544b";
+	};

Otherwise, for the binding:

#2 lore raw
Quoted 11 lines · Rob Herring
Quoted 10 lines · Mike Looijmans

This patch adds the driver and devicetree documentation for the Silicon Labs SI544 clock generator chip. This is an I2C controlled oscillator capable of generating clock signals ranging from 200kHz to 1500MHz.

---
v2: Add u64 cast to ls_div_bits calculation loop
When ls_div_bits is non-zero, the hs_div must always be even

Quoted 4 lines
Quoted 4 lines
  .../devicetree/bindings/clock/silabs,si544.txt     |  25 ++
  drivers/clk/Kconfig                                |  10 +
  drivers/clk/Makefile                               |   1 +

drivers/clk/clk-si544.c | 422 +++++++++++++=

++++++++

Quoted 2 lines
Quoted 2 lines
  4 files changed, 458 insertions(+)

create mode 100644 Documentation/devicetree/bindings/clock/silabs,si54=

4.txt

Quoted 3 lines

=

Quoted 3 lines

create mode 100644 drivers/clk/clk-si544.c

= renamed from Documentation/devicetree/bindings/clock/silabs,si544.txt +0 -0

Documentation/devicetree/bindings/clock/silabs,si544.txt

Quoted 9 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt line 4

Quoted 9 lines

new file mode 100644
index 0000000..eec1787

Documentation/devicetree/bindings/clock/silabs,si544.txt new file +4 -0
@@ -0,0 +1,25 @@
+Binding for Silicon Labs 544 programmable I2C clock generator.
+
+Reference
+This binding uses the common clock binding[1]. Details about the device=

can be

Quoted 5 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt

Quoted 5 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +5 -0
+found in the datasheet[2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Si544 datasheet
+    https://www.silabs.com/documents/public/data-sheets/si544-datasheet=

.pdf

Quoted 3 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt

Quoted 3 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +3 -0
+
+Required properties:
+ - compatible: One of "silabs,si514a", "silabs,si514b" "silabs,si514c" =

according

Quoted 6 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt

Quoted 6 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +6 -0
+               to the speed grade of the chip.
+ - reg: I2C device address.
+ - #clock-cells: From common clock bindings: Shall be 0.
+
+Optional properties:
+ - clock-output-names: From common clock bindings. Recommended to be "s=

i544".

Quoted 2 lines

=20
What's the point if there is only 1 clock output?

I have a board with 6 of these chips, and the clock registration fails if t= hey=20
don't have unique names. Providing a clock-output-names property was the=20 easiest way around it.

Should I just omit the line or change the wording to reflect the above or i= s=20
there a better solution (maybe I can use the DT node name as clock name in = the=20
driver, will look into that)

Quoted 6 lines

=20

Documentation/devicetree/bindings/clock/silabs,si544.txt line 21

Quoted 3 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +3 -0
+
+Example:
+	si544: clock-generator@55 {

=20
clock-controller@55 is the standard node name.

I'll change and post patch v3

Quoted 10 lines

=20

Documentation/devicetree/bindings/clock/silabs,si544.txt line 25

Quoted 4 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +4 -0
+		reg =3D <0x55>;
+		#clock-cells =3D <0>;
+		compatible =3D "silabs,si544b";
+	};

=20
Otherwise, for the binding:
=20

=20

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

maintainer
#3 lore raw

Quoting Mike Looijmans (2018-03-19 08:04:15)

Quoted 4 lines · Rob Herring
Quoted 3 lines · Mike Looijmans
Quoted 2 lines

+Required properties:
+ - compatible: One of "silabs,si514a", "silabs,si514b" "silabs,si514c=

" according

Quoted 6 lines
Quoted 6 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt

Quoted 6 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +6 -0
+               to the speed grade of the chip.
+ - reg: I2C device address.
+ - #clock-cells: From common clock bindings: Shall be 0.
+
+Optional properties:
+ - clock-output-names: From common clock bindings. Recommended to be =

"si544".

Quoted 6 lines
Quoted 3 lines

=

What's the point if there is only 1 clock output?

=

I have a board with 6 of these chips, and the clock registration fails if=

they =

Quoted 6 lines

don't have unique names. Providing a clock-output-names property was the =

easiest way around it.
=

Should I just omit the line or change the wording to reflect the above or=

is =

Quoted 1 line

there a better solution (maybe I can use the DT node name as clock name i=

n the =

Quoted 1 line

driver, will look into that)

I would leave clock-output-names for now. One day we can get off of strings in CCF. Soon perhaps.

Quoted 9 lines

=

Quoted 6 lines

=

Documentation/devicetree/bindings/clock/silabs,si544.txt line 21

Quoted 3 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +3 -0
+
+Example:
+    si544: clock-generator@55 {

=

Quoted 5 lines
Quoted 1 line

clock-controller@55 is the standard node name.

=

I'll change and post patch v3
=

I made some comments on v1. Please fold those into v3.

#4 lore raw
Quoted 5 lines · Stephen Boyd

Quoting Mike Looijmans (2018-03-19 08:04:15)

Quoted 4 lines · Rob Herring
Quoted 3 lines · Mike Looijmans
Quoted 2 lines

+Required properties:
+ - compatible: One of "silabs,si514a", "silabs,si514b" "silabs,si514c=

" according

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt

Quoted 6 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +6 -0
+               to the speed grade of the chip.
+ - reg: I2C device address.
+ - #clock-cells: From common clock bindings: Shall be 0.
+
+Optional properties:
+ - clock-output-names: From common clock bindings. Recommended to be =

"si544".

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

What's the point if there is only 1 clock output?

I have a board with 6 of these chips, and the clock registration fails i=

f they

Quoted 4 lines
Quoted 4 lines

don't have unique names. Providing a clock-output-names property was the easiest way around it.

Should I just omit the line or change the wording to reflect the above o=

r is

Quoted 1 line
Quoted 1 line

there a better solution (maybe I can use the DT node name as clock name =

in the

Quoted 13 lines
Quoted 1 line

driver, will look into that)

=20
I would leave clock-output-names for now. One day we can get off of strings in CCF. Soon perhaps.
=20

Quoted 8 lines
Quoted 7 lines

Documentation/devicetree/bindings/clock/silabs,si544.txt line 21

Quoted 5 lines
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +3 -0
+
+Example:
+    si544: clock-generator@55 {

clock-controller@55 is the standard node name.

Quoted 4 lines
Quoted 2 lines

I'll change and post patch v3

=20
I made some comments on v1. Please fold those into v3.

Thanks, found them on patchwork, somehow they didn't end up in my mailbox.

Comments are clear, will incorporate them, I only have trouble with your=20 remark on the DT documentation "Can this reference stuff go to the bottom o= f=20
this document?". I copied the style from the other documents in the same=20 directory, I'm slightly puzzled about where the reference part should go no= w.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

maintainer
#5 lore raw

Quoting Mike Looijmans (2018-03-20 00:15:36)

Quoted 6 lines

Thanks, found them on patchwork, somehow they didn't end up in my mailbox. =

Comments are clear, will incorporate them, I only have trouble with your =

remark on the DT documentation "Can this reference stuff go to the bottom=

of =

Quoted 3 lines

this document?". I copied the style from the other documents in the same =

directory, I'm slightly puzzled about where the reference part should go =

now.

Quoted 3 lines

=

=

Ok. It's fine either way.

#6 lore raw

PATCH v3 1/1 clk: Add driver for the si544 clock generator chip

In reply to Mike Looijmans

This patch adds the driver and devicetree documentation for the Silicon Labs SI544 clock generator chip. This is an I2C controlled oscillator capable of generating clock signals ranging from 200kHz to 1500MHz.

---
v2: Add u64 cast to ls_div_bits calculation loop
When ls_div_bits is non-zero, the hs_div must always be even
v3: Remove "depends on OF" from Kconfig
Use clock-controller@55 as example node name
SPDX style license
Add MIN_HSDIV_FREQ define
Various style issues (Stephen Boyd)
Remove rate==0 special casing (is_valid_frequency already checks) Reduce error messages
Use devm_of_clk_add_hw_provider()

 .../devicetree/bindings/clock/silabs,si544.txt     |  25 ++
 drivers/clk/Kconfig                                |   9 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk-si544.c                            | 411 +++++++++++++++++++++
 4 files changed, 446 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/silabs,si544.txt
 create mode 100644 drivers/clk/clk-si544.c
Documentation/devicetree/bindings/clock/silabs,si544.txt new file +25 -0
new file mode 100644
index 0000000..b86535b
@@ -0,0 +1,25 @@
+Binding for Silicon Labs 544 programmable I2C clock generator.
+
+Reference
+This binding uses the common clock binding[1]. Details about the device can be
+found in the datasheet[2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Si544 datasheet
+    https://www.silabs.com/documents/public/data-sheets/si544-datasheet.pdf
+
+Required properties:
+ - compatible: One of "silabs,si514a", "silabs,si514b" "silabs,si514c" according
+               to the speed grade of the chip.
+ - reg: I2C device address.
+ - #clock-cells: From common clock bindings: Shall be 0.
+
+Optional properties:
+ - clock-output-names: From common clock bindings. Recommended to be "si544".
+
+Example:
+	si544: clock-controller@55 {
+		reg = <0x55>;
+		#clock-cells = <0>;
+		compatible = "silabs,si544b";
+	};
drivers/clk/Kconfig +9 -0
index 98ce9fc..580fc04 100644
@@ -91,6 +91,15 @@ config COMMON_CLK_SI514
 	  This driver supports the Silicon Labs 514 programmable clock
 	  generator.
 
+config COMMON_CLK_SI544
+	tristate "Clock driver for SiLabs 544 devices"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	---help---
+	  This driver supports the Silicon Labs 544 programmable clock
+	  generator.
+
 config COMMON_CLK_SI570
 	tristate "Clock driver for SiLabs 570 and compatible devices"
 	depends on I2C
drivers/clk/Makefile +1 -0
index 71ec41e..bde614a 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_COMMON_CLK_S2MPS11)	+= clk-s2mps11.o
 obj-$(CONFIG_COMMON_CLK_SCPI)           += clk-scpi.o
 obj-$(CONFIG_COMMON_CLK_SI5351)		+= clk-si5351.o
 obj-$(CONFIG_COMMON_CLK_SI514)		+= clk-si514.o
+obj-$(CONFIG_COMMON_CLK_SI544)		+= clk-si544.o
 obj-$(CONFIG_COMMON_CLK_SI570)		+= clk-si570.o
 obj-$(CONFIG_ARCH_STM32)		+= clk-stm32f4.o
 obj-$(CONFIG_ARCH_STM32)		+= clk-stm32h7.o
drivers/clk/clk-si544.c new file +411 -0

411 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#7 lore raw

Quoting Mike Looijmans (2018-03-20 01:15:41)

Quoted 10 lines
drivers/clk/clk-si544.c new file +10 -0
+
+static bool is_valid_frequency(const struct clk_si544 *data,
+       unsigned long frequency)
+{
+       unsigned long max_freq;
+
+       if (frequency < SI544_MIN_FREQ)
+               return false;
+
+       switch (data->speed_grade) {

drivers/clk/clk-si544.c line 158

Quoted 10 lines
drivers/clk/clk-si544.c new file +10 -0
+       case si544a:
+               max_freq =3D 1500000000;
+               break;
+       case si544b:
+               max_freq =3D 800000000;
+               break;
+       case si544c:
+               max_freq =3D 350000000;
+               break;
+       }

Sad. My compiler complains about max_freq being possibly unassigned here, even though that seems impossible I guess we need to put back the default case. I'll take care of it when applying and assign max_freq to 0 by default.

Otherwise, applied to clk-next.