drivers/clk/clk-scmi.c | 62 +++++++++++++++++++++++++++++++++++++-- drivers/firmware/arm_scmi/clock.c | 15 ++++++++-- include/dt-bindings/clock/scmi.h | 13 ++++++++ include/linux/scmi_protocol.h | 8 ++++- 4 files changed, 92 insertions(+), 6 deletions(-)
The ARM SCMI specification (DEN0056E) defines rounding‑mode flags for the
CLOCK_RATE_SET command, allowing a client to request that the firmware
round a requested clock rate down, up, or autonomously choose the
closest achievable rate.
This series introduces DT support in the SCMI clock provider to carry a
per‑clock rounding policy from the device tree into the SCMI protocol.
Patch 1 adds dt‑bindings constants for rounding modes:
ROUND_DOWN, ROUND_UP, ROUND_AUTO.
Patch 2 extends the SCMI clock provider to optionally support
"#clock-cells = <2>", where the second cell encodes the rounding mode.
The first consumer that references a given clock latches the per‑clock
policy. Subsequent consumers of the same clock must specify the same
mode; otherwise, the request is rejected to avoid non‑deterministic
behavior. The selected mode is passed through to the SCMI Clock protocol
and mapped to the corresponding CLOCK_SET_* flag.
Patch 2 includes changes to drivers/clk/clk-scmi.c and drivers/firmware
arm_scmi/clock.c, it is hard to separate the changes without breaking,
so I put the changes in one patch.
This design adopts a per‑clock policy model, not per‑consumer. The rounding
mode is applied by the provider per clock (index).
All consumers of the same clock must agree on the rounding mode.
Conflicting per‑consumer requests for the same clock are invalid and
are rejected during phandle translation.
This avoids silent clobbering and preserves deterministic behavior.
Existing device trees using #clock-cells = <1> continue to work and
default to ROUND_DOWN, exactly as before.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (2):
dt-bindings: clock: Add SCMI clock rounding mode declarations
clk: scmi: Add support for two #clock-cells to pass rate rounding mode
drivers/clk/clk-scmi.c | 62 +++++++++++++++++++++++++++++++++++++--
drivers/firmware/arm_scmi/clock.c | 15 ++++++++--
include/dt-bindings/clock/scmi.h | 13 ++++++++
include/linux/scmi_protocol.h | 8 ++++-
4 files changed, 92 insertions(+), 6 deletions(-)
---
base-commit: 3f9cd19e764b782706dbaacc69e502099cb014ba
change-id: 20260306-scmi-clk-round-1615258cf0fa
Best regards,
--
Peng Fan <peng.fan@nxp.com>
Hi Peng, On Fri, Mar 06, 2026 at 02:20:11PM +0800, Peng Fan (OSS) wrote: > The ARM SCMI specification (DEN0056E) defines rounding‑mode flags for the > CLOCK_RATE_SET command, allowing a client to request that the firmware > round a requested clock rate down, up, or autonomously choose the > closest achievable rate. > This series introduces DT support in the SCMI clock provider to carry a > per‑clock rounding policy from the device tree into the SCMI protocol. > > Patch 1 adds dt‑bindings constants for rounding modes: > ROUND_DOWN, ROUND_UP, ROUND_AUTO. > > Patch 2 extends the SCMI clock provider to optionally support > "#clock-cells = <2>", where the second cell encodes the rounding mode. > The first consumer that references a given clock latches the per‑clock > policy. Subsequent consumers of the same clock must specify the same > mode; otherwise, the request is rejected to avoid non‑deterministic > behavior. The selected mode is passed through to the SCMI Clock protocol > and mapped to the corresponding CLOCK_SET_* flag. > > Patch 2 includes changes to drivers/clk/clk-scmi.c and drivers/firmware > arm_scmi/clock.c, it is hard to separate the changes without breaking, > so I put the changes in one patch. > > This design adopts a per‑clock policy model, not per‑consumer. The rounding > mode is applied by the provider per clock (index). > All consumers of the same clock must agree on the rounding mode. > Conflicting per‑consumer requests for the same clock are invalid and > are rejected during phandle translation. > > This avoids silent clobbering and preserves deterministic behavior. > > Existing device trees using #clock-cells = <1> continue to work and > default to ROUND_DOWN, exactly as before. > > Signed-off-by: Peng Fan <peng.fan@nxp.com> My high level feedback about this: 1) Since you are making changes to the DT schema for the clock-cells, does the SCMI DT schema document also need to be updated to allow clock-cells to be 1 or 2? 2) For the ROUND_XXX constants, I would prefix them with something since the existing ROUND names are fairly generic sounding. Maybe CLK_SCMI_? Brian
Hi Brian, On Mon, Apr 06, 2026 at 11:38:30AM -0400, Brian Masney wrote: >Hi Peng, > >On Fri, Mar 06, 2026 at 02:20:11PM +0800, Peng Fan (OSS) wrote: >> The ARM SCMI specification (DEN0056E) defines rounding‑mode flags for the >> CLOCK_RATE_SET command, allowing a client to request that the firmware >> round a requested clock rate down, up, or autonomously choose the >> closest achievable rate. >> This series introduces DT support in the SCMI clock provider to carry a >> per‑clock rounding policy from the device tree into the SCMI protocol. >> >> Patch 1 adds dt‑bindings constants for rounding modes: >> ROUND_DOWN, ROUND_UP, ROUND_AUTO. >> >> Patch 2 extends the SCMI clock provider to optionally support >> "#clock-cells = <2>", where the second cell encodes the rounding mode. >> The first consumer that references a given clock latches the per‑clock >> policy. Subsequent consumers of the same clock must specify the same >> mode; otherwise, the request is rejected to avoid non‑deterministic >> behavior. The selected mode is passed through to the SCMI Clock protocol >> and mapped to the corresponding CLOCK_SET_* flag. >> >> Patch 2 includes changes to drivers/clk/clk-scmi.c and drivers/firmware >> arm_scmi/clock.c, it is hard to separate the changes without breaking, >> so I put the changes in one patch. >> >> This design adopts a per‑clock policy model, not per‑consumer. The rounding >> mode is applied by the provider per clock (index). >> All consumers of the same clock must agree on the rounding mode. >> Conflicting per‑consumer requests for the same clock are invalid and >> are rejected during phandle translation. >> >> This avoids silent clobbering and preserves deterministic behavior. >> >> Existing device trees using #clock-cells = <1> continue to work and >> default to ROUND_DOWN, exactly as before. >> >> Signed-off-by: Peng Fan <peng.fan@nxp.com> > >My high level feedback about this: > >1) Since you are making changes to the DT schema for the clock-cells, > does the SCMI DT schema document also need to be updated to allow > clock-cells to be 1 or 2? You are right. > >2) For the ROUND_XXX constants, I would prefix them with something > since the existing ROUND names are fairly generic sounding. Maybe > CLK_SCMI_? sounds good. I will wait a few more days to see if there are other comments, then will post out next version. Thanks, Peng > >Brian >
Hi All, On Fri, Mar 06, 2026 at 02:20:11PM +0800, Peng Fan (OSS) wrote: >The ARM SCMI specification (DEN0056E) defines rounding‑mode flags for the >CLOCK_RATE_SET command, allowing a client to request that the firmware >round a requested clock rate down, up, or autonomously choose the >closest achievable rate. Would you please give a look and give some feedback? Thanks, Peng >This series introduces DT support in the SCMI clock provider to carry a >per‑clock rounding policy from the device tree into the SCMI protocol. > >Patch 1 adds dt‑bindings constants for rounding modes: >ROUND_DOWN, ROUND_UP, ROUND_AUTO. > >Patch 2 extends the SCMI clock provider to optionally support >"#clock-cells = <2>", where the second cell encodes the rounding mode. >The first consumer that references a given clock latches the per‑clock >policy. Subsequent consumers of the same clock must specify the same >mode; otherwise, the request is rejected to avoid non‑deterministic >behavior. The selected mode is passed through to the SCMI Clock protocol >and mapped to the corresponding CLOCK_SET_* flag. > >Patch 2 includes changes to drivers/clk/clk-scmi.c and drivers/firmware >arm_scmi/clock.c, it is hard to separate the changes without breaking, >so I put the changes in one patch. > >This design adopts a per‑clock policy model, not per‑consumer. The rounding >mode is applied by the provider per clock (index). >All consumers of the same clock must agree on the rounding mode. >Conflicting per‑consumer requests for the same clock are invalid and >are rejected during phandle translation. > >This avoids silent clobbering and preserves deterministic behavior. > >Existing device trees using #clock-cells = <1> continue to work and >default to ROUND_DOWN, exactly as before. > >Signed-off-by: Peng Fan <peng.fan@nxp.com> >--- >Peng Fan (2): > dt-bindings: clock: Add SCMI clock rounding mode declarations > clk: scmi: Add support for two #clock-cells to pass rate rounding mode > > drivers/clk/clk-scmi.c | 62 +++++++++++++++++++++++++++++++++++++-- > drivers/firmware/arm_scmi/clock.c | 15 ++++++++-- > include/dt-bindings/clock/scmi.h | 13 ++++++++ > include/linux/scmi_protocol.h | 8 ++++- > 4 files changed, 92 insertions(+), 6 deletions(-) >--- >base-commit: 3f9cd19e764b782706dbaacc69e502099cb014ba >change-id: 20260306-scmi-clk-round-1615258cf0fa > >Best regards, >-- >Peng Fan <peng.fan@nxp.com> >
© 2016 - 2026 Red Hat, Inc.