Linux clock framework development
 help / color / mirror / Atom feed
From: Mike Looijmans <mike.looijmans@topic.nl>
To: devicetree@vger.kernel.org, linux-clk@vger.kernel.org
Cc: Mike Looijmans <mike.looijmans@topic.nl>,
	Conor Dooley <conor+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Rob Herring <robh+dt@kernel.org>, Stephen Boyd <sboyd@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] dt-bindings: clock: Add nvmem-clock
Date: Fri, 26 May 2023 16:05:12 +0200	[thread overview]
Message-ID: <20230526140513.6943-1-mike.looijmans@topic.nl> (raw)
In-Reply-To: 1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.4a78ae72-465e-443a-a075-45c4bdc136cb@emailsignatures365.codetwo.com

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 <mike.looijmans@topic.nl>

---

Note this patch causes dt_binding_check errors that I need some help
with. It claims "clock-frequency" is a required property, though I don't
want it to be, and it also doesn't like the nvmem entries, claiming they
should match "pinctrl-[0-9]+". Cannot make sense of the error messages...


 .../bindings/clock/nvmem-clock.yaml           | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/nvmem-clock.yaml

diff --git a/Documentation/devicetree/bindings/clock/nvmem-clock.yaml b/Documentation/devicetree/bindings/clock/nvmem-clock.yaml
new file mode 100644
index 000000000000..2e40df150b59
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/nvmem-clock.yaml
@@ -0,0 +1,62 @@
+# 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 <mike.looijmans@topic.nl>
+
+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:
+    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 = "fixed-clock";
+      #clock-cells = <0>;
+      nvmem-cells = <&efuse_xtal_freq>;
+      nvmem-cell-names = "clock-frequency";
+    };
+...
-- 
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: mike.looijmans@topicproducts.com
W: www.topic.nl

Please consider the environment before printing this e-mail

       reply	other threads:[~2023-05-26 14:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.4a78ae72-465e-443a-a075-45c4bdc136cb@emailsignatures365.codetwo.com>
2023-05-26 14:05 ` Mike Looijmans [this message]
2023-05-26 14:05   ` [PATCH 2/2] clk: Add nvmem-clock provider Mike Looijmans
2023-05-26 14:40   ` [PATCH 1/2] dt-bindings: clock: Add nvmem-clock Mike Looijmans

Reply instructions:

You may reply publicly 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=20230526140513.6943-1-mike.looijmans@topic.nl \
    --to=mike.looijmans@topic.nl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox