dt-bindings: clock: Add nvmem-clock
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.2167d5ad-7e99-4eb9-a313-030fc7a7d546@emailsignatures365.codetwo.com
PATCH v2 1/2 dt-bindings: clock: Add nvmem-clock
Add bindings for a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies using the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
---
Changes in v2:
Changed "fixed-clock" into "nvmem-clock" in dts example Add minItems:1 to nvmem-cell-names
.../bindings/clock/nvmem-clock.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/nvmem-clock.yaml
Documentation/devicetree/bindings/clock/nvmem-clock.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/nvmem-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Simple fixed-rate clock source from NVMEM + +maintainers: + - Mike Looijmans <[email protected]> + +description: + Provides a clock rate from NVMEM. Typical usage is that the factory places a + crystal on the board and writes the rate into an EEPROM or EFUSE. If some math + is required, one can add a fixed-factor clock using this clock as input. + +properties: + compatible: + const: nvmem-clock + + "#clock-cells": + const: 0 + + nvmem-cells: + minItems: 1 + maxItems: 2 + description: + Reads clock-frequency and optionally clock-accuracy from an NVMEM provider + in binary native integer format. The size of the NVMEM cell can be 1, 2, 4 + or 8 bytes. + + nvmem-cell-names: + minItems: 1 + items: + - const: clock-frequency + - const: clock-accuracy + + clock-accuracy: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + accuracy of clock in ppb (parts per billion). Alternative for providing + this through nvmem, the nvmem provided value takes precedence. + + clock-output-names: + maxItems: 1 + +required: + - compatible + - "#clock-cells" + - nvmem-cells + - nvmem-cell-names + +additionalProperties: false + +examples: + - | + xtal { + compatible = "nvmem-clock"; + #clock-cells = <0>; + nvmem-cells = <&efuse_xtal_freq>; + nvmem-cell-names = "clock-frequency"; + }; +...
Signature · 18 lines
2.17.1 Met vriendelijke groet / kind regards, Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: [email protected] W: www.topic.nl Please consider the environment before printing this e-mail
PATCH v2 2/2 clk: Add nvmem-clock provider
Adds a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies usign the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
---
(no changes since v1)
drivers/clk/Kconfig | 7 +++ drivers/clk/Makefile | 1 + drivers/clk/clk-nvmem.c | 107 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/clk/clk-nvmem.c
drivers/clk/Kconfig +7 -0
@@ -447,6 +447,13 @@ config COMMON_CLK_FIXED_MMIO help Support for Memory Mapped IO Fixed clocks +config COMMON_CLK_NVMEM + bool "Clock driver for NVMEM provided frequency" + depends on COMMON_CLK && OF + help + This driver allows a clock frequency to be provided by NVMEM data, for + example in an EEPROM, by fuses or other non-volatile storage. + config COMMON_CLK_K210 bool "Clock driver for the Canaan Kendryte K210 SoC" depends on OF && RISCV && SOC_CANAAN
drivers/clk/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_ARCH_MOXART) += clk-moxart.o obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o obj-$(CONFIG_ARCH_NPCM7XX) += clk-npcm7xx.o obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o +obj-$(CONFIG_COMMON_CLK_NVMEM) += clk-nvmem.o obj-$(CONFIG_COMMON_CLK_OXNAS) += clk-oxnas.o obj-$(CONFIG_COMMON_CLK_PALMAS) += clk-palmas.o obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o
drivers/clk/clk-nvmem.c new file +107 -0
107 lines not on this page · raw message
Signature · 18 lines
2.17.1 Met vriendelijke groet / kind regards, Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: [email protected] W: www.topic.nl Please consider the environment before printing this e-mail
Hey Mike,
I have no comments about whether this is a good idea or not, I'll leave that Stephen, Krzysztof etc..
Quoted 49 lines · Mike Looijmans
Add bindings for a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies using the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
Signed-off-by Mike Looijmans <[email protected]>---
Changes in v2:
Changed "fixed-clock" into "nvmem-clock" in dts example Add minItems:1 to nvmem-cell-names.../bindings/clock/nvmem-clock.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/nvmem-clock.yamlDocumentation/devicetree/bindings/clock/nvmem-clock.yaml new file +20
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/nvmem-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Simple fixed-rate clock source from NVMEM + +maintainers: + - Mike Looijmans <[email protected]> + +description: + Provides a clock rate from NVMEM. Typical usage is that the factory places a + crystal on the board and writes the rate into an EEPROM or EFUSE. If some math + is required, one can add a fixed-factor clock using this clock as input. + +properties: + compatible: + const: nvmem-clock +
Documentation/devicetree/bindings/clock/nvmem-clock.yaml line 30
Quoted 10 lines
Documentation/devicetree/bindings/clock/nvmem-clock.yaml new file +10
-0+ "#clock-cells": + const: 0 + + nvmem-cells: + minItems: 1 + maxItems: 2 + description: + Reads clock-frequency and optionally clock-accuracy from an NVMEM provider + in binary native integer format. The size of the NVMEM cell can be 1, 2, 4 + or 8 bytes.
How is that size communicated to the driver? Some nvmem magic just takes care of it?
Documentation/devicetree/bindings/clock/nvmem-clock.yaml line 38
Quoted 8 lines
Documentation/devicetree/bindings/clock/nvmem-clock.yaml new file +8
-0+ + nvmem-cell-names: + minItems: 1 + items: + - const: clock-frequency + - const: clock-accuracy + + clock-accuracy:
I think the common pattern is to add a unit suffix for things like this, which I guess would be -ppb?
Cheers,
Conor.
Quoted 44 lines
Documentation/devicetree/bindings/clock/nvmem-clock.yaml new file +25
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: + accuracy of clock in ppb (parts per billion). Alternative for providing + this through nvmem, the nvmem provided value takes precedence. + + clock-output-names: + maxItems: 1 + +required: + - compatible + - "#clock-cells" + - nvmem-cells + - nvmem-cell-names + +additionalProperties: false + +examples: + - | + xtal { + compatible = "nvmem-clock"; + #clock-cells = <0>; + nvmem-cells = <&efuse_xtal_freq>; + nvmem-cell-names = "clock-frequency"; + }; +...Signature · 18 lines
2.17.1 Met vriendelijke groet / kind regards, Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: [email protected] W: www.topic.nl Please consider the environment before printing this e-mail
Resending as my previous email probably got lost. If you got it twice, apologies.
Quoted 10 lines · Mike Looijmans
Add bindings for a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies using the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
This does not look like real hardware. I mean, the clock does not fetch its rate from nvmem, right? It's the Linux which does it, so basically you described here driver, not hardware.
Extend existing fixed-clock bindings to allow reading frequency via nvmem cells.
Best regards,
Krzysztof
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Mike Looijmans
Add bindings for a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies using the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
Quoted 3 lines
This does not look like real hardware. I mean, the clock does not fetch its rate from nvmem, right? It's the Linux which does it, so basically you described here driver, not hardware.
Right, this just reads a setting from an NVMEM provider.
Quoted 2 lines
Extend existing fixed-clock bindings to allow reading frequency via nvmem cells.
I just tried and implemented this, but it does not work. The reason is that the fixed-clock implementation returns "void" in its of_fixed_clk_setup() init function. The nvmem provider returns EPROBE_DEFER because it isn't ready at this early stage, and this error will not be propagated up because of the "void" signature. Thus, it's never retried and the clock just disappears.
Quoted 3 lines
Best regards,
Krzysztof
Signature · 10 lines
Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: [email protected] W: www.topic.nl
Quoted 19 lines · Mike Looijmans
Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Mike Looijmans
Add bindings for a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies using the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
Quoted 3 lines
This does not look like real hardware. I mean, the clock does not fetch its rate from nvmem, right? It's the Linux which does it, so basically you described here driver, not hardware.
Right, this just reads a setting from an NVMEM provider.
Quoted 2 lines
Extend existing fixed-clock bindings to allow reading frequency via nvmem cells.
Quoted 6 lines
I just tried and implemented this, but it does not work. The reason is that the fixed-clock implementation returns "void" in its
of_fixed_clk_setup()init function. The nvmem provider returnsEPROBE_DEFERbecause it isn't ready at this early stage, and this error will not be propagated up because of the "void" signature. Thus, it's never retried and the clock just disappears.
Linux driver problems are not a reason to add bindings for virtual hardware...
Best regards,
Krzysztof
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Mike Looijmans
Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Mike Looijmans
Add bindings for a fixed-rate clock that retrieves its rate from an NVMEM provider. This allows to store clock settings in EEPROM or EFUSE or similar device.
Component shortages lead to boards being shipped with different clock crystals, based on what was available at the time. The clock frequency was written to EEPROM at production time. Systems can adapt to a wide range of input frequencies using the clock framework, but this required us to patch the devicetree at runtime or use some custom driver. This provides a more generic solution.
Quoted 3 lines
This does not look like real hardware. I mean, the clock does not fetch its rate from nvmem, right? It's the Linux which does it, so basically you described here driver, not hardware.
Right, this just reads a setting from an NVMEM provider.
Quoted 2 lines
Extend existing fixed-clock bindings to allow reading frequency via nvmem cells.
Quoted 9 lines
Quoted 6 lines
I just tried and implemented this, but it does not work. The reason is that the fixed-clock implementation returns "void" in its
of_fixed_clk_setup()init function. The nvmem provider returnsEPROBE_DEFERbecause it isn't ready at this early stage, and this error will not be propagated up because of the "void" signature. Thus, it's never retried and the clock just disappears.Linux driver problems are not a reason to add bindings for virtual hardware...
Okay, so what are you proposing?
The implementation needs a compatible string other than "fixed-clock", because of the way the fixed-clock driver is being loaded (it can never be deferred).
So I should add another compatible string to fixed-clock.yaml? That'd make the syntax in fixed-clock.yaml rather awkward, since some properties would only apply to some compatible strings?
Signature · 10 lines
Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: [email protected] W: www.topic.nl