clk: tc9564: introduce a clock and reset driver
v3 cover clk: tc9564: introduce a clock and reset driver
This series introduces a devicetree binding and single driver to support the clock and reset components present within the Toshiba TC9564 chip.
The Toshiba TC9564 is an SoC that attaches to a host system via PCIe. It includes a PCIe switch with three downstream ports. To one of these ports an embedded PCIe endpoint is attached, and that implements two PCI functions. BAR 4 for both PCI functions provides access to registers controlling blocks within the SoC, including the clock and reset controllers supported by this series.
The first version of this series included a system controller, which has since been removed. This version addresses all review feedback received on version 2.
-Alex
Version 2 is available here:
https://lore.kernel.org/all/[email protected]/
Between version 2 and version 3:
- Added Lorenzo's Reviewed-by on the devicetree binding patch
- The devicetree binding now uses @kernel.org e-mail addresses for Daniel and me
- Cleaned up the patch header text in patch 2
- The Kconfig option now depends on RESET_CONTROLLER
- The Kconfig option can now be enabled if COMPILE_TEST is enabled
- The generic gate clock controller code is now used rather than implementing a custom one
- Only the gate clock IDs are now published in "toshiba,tc9564.h"; the PLL and internal fixed clocks are implemented and accessed only within "clk-tc9564.c"
- The PLL is initialialized, followed by all fixed rate clocks, followed by the gate clocks, to ensure each clock's parent is initialized before the clock is
- Updating the reset registers (read/modify/write) is now protected by a spinlock
- There are no more "unnecessary newlines" in the initialization arrays for clocks and resets
- An update to the DTS file is now included as the last patch in this series
The version prior to v2 of this code was included in this series:
https://lore.kernel.org/all/[email protected]/
Between that series (v1) and this one (v2):
- There is no more syscon, so its devicetree binding and driver have been dropped
- The clock and reset components now have a single devicetree binding
- We no longer use a syscon-generated regmap for accessing the common range of memory used by multiple drivers; specific sub-ranges are instead mapped
- The clock and reset drivers have been combined into a single driver located under drivers/clk
- The config option for the driver includes COMPILE_TEST, as requested (last month) by Jerome Brunet
- The help text for the config option is simplified, first suggested by Philipp Zabel
- The driver now names clocks using dev_name() rather than trying to hand-code a unique name into a fixed-size name array (also suggested by Jerome)
- Certain functions now always return 0, which simplifies callers so they can simply return what the called function returns
- As suggested by sashiko, a counted-by field in a flex array is now assigned explicitly
Alex Elder (3):
dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
clk: toshiba: introduce a TC9564 clock/reset driver
arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
.../bindings/clock/toshiba,tc9564-clock.yaml | 73 +++ MAINTAINERS | 9 + arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 15 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 456 ++++++++++++++++++ include/dt-bindings/clock/toshiba,tc9564.h | 40 ++ 7 files changed, 603 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml create mode 100644 drivers/clk/clk-tc9564.c create mode 100644 include/dt-bindings/clock/toshiba,tc9564.h
base-commit: 9437046953b2fb3bf55b36582450ea0267df82a7
Signature · 1 line
2.53.0
PATCH v3 1/3 dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
Define the binding for the clock and reset controller that present in the Toshiba TC9564 SoC.
---
v3: - Added Lorenzo's Reviewed-by
- Changed to @kernel.org e-mails for Daniel and me
- Only the gated clock IDs are now published in "toshiba,tc9564.h"; the PLL and internal fixed clocks are implemented and accessed only within "clk-tc9564.c"
.../bindings/clock/toshiba,tc9564-clock.yaml | 73 +++++++++++++++++++ MAINTAINERS | 8 ++ include/dt-bindings/clock/toshiba,tc9564.h | 40 ++++++++++ 3 files changed, 121 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml create mode 100644 include/dt-bindings/clock/toshiba,tc9564.h
Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml new file +73 -0
@@ -0,0 +1,73 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/toshiba,tc9564-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 Clock and Reset Controller + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Alex Elder <[email protected]> + - Daniel Thompson <[email protected]> + +description: + The Toshiba TC9564 is an SoC accessed by a host system through the + upstream PCIe port on the PCIe switch it implements. The chip includes + an embedded PCIe endpoint that provides access to various peripherals + within the SoC via its BARs. These peripherals include a simple + controller to gate internal clocks, and a reset controller. + + The TC9564 chip has a single input clock. Internally that clock is + multiplied by a PLL, and the PLL signal is divided internally into + a set of fixed rate, always-on clocks. + + The clock controller exposes a set of simple gated clocks, which are + controlled by two registers. Each is derived from one of the internal + fixed-rate clocks. A total of 21 gated clocks are implemented within + the chip, but support for enabling and disabling only a subset of them + is provided at this time. Two clocks (I2C and PCIE) are marked critical + to make it clear that they should never be disabled. + + The reset controller uses two other registers to control a set of 13 + resets that can be asserted or deasserted. Here too, only a subset + of the resets can currently be managed, and the I2C and PCIE resets + are treated as critical. + + Clock and reset IDs are defined <dt-bindings/clock/toshiba,tc9564.h>. + +properties: + compatible: + items: + - const: toshiba,tc9564-clock + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + "#clock-cells": + const: 1 + + "#reset-cells": + const: 1 + +required: + - compatible + - reg + - clocks + - "#clock-cells" + - "#reset-cells" + +additionalProperties: false + +examples: + - | + clock-controller@1004 { + compatible = "toshiba,tc9564-clock"; + reg = <0x1004 0x10>; + clocks = <&tc9564_xo_board>; + #clock-cells = <1>; + #reset-cells = <1>; + };
MAINTAINERS +8 -0
@@ -28716,6 +28716,14 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC9564 CLOCK/RESET CONTROLLER DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml +F: include/dt-bindings/clock/toshiba,tc9564.h + TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]>
include/dt-bindings/clock/toshiba,tc9564.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +#ifndef __CLOCK_TOSHIBA_TC9564_H__ +#define __CLOCK_TOSHIBA_TC9564_H__ + +/* Clock IDs */ + +#define CLOCK_I2C 0/* critical */ +#define CLOCK_PCIE 1/* critical */ +#define CLOCK_MSIGEN 2 + +#define CLOCK_MAC0_TX 3 +#define CLOCK_MAC0_RX 4 +#define CLOCK_MAC0_125M 5 +#define CLOCK_MAC0_ALL 6 + +#define CLOCK_MAC1_TX 7 +#define CLOCK_MAC1_RX 8 +#define CLOCK_MAC1_125M 9 +#define CLOCK_MAC1_ALL 10 + +/* Reset IDs */ + +#define RESET_I2C 0/* critical */ +#define RESET_PCIE 1/* critical */ +#define RESET_MSIGEN 2 + +#define RESET_MAC0_MAC 3 +#define RESET_MAC0_PMA 4 +#define RESET_MAC0_XPCS 5 + +#define RESET_MAC1_MAC 6 +#define RESET_MAC1_PMA 7 +#define RESET_MAC1_XPCS 8 + +#endif /* __CLOCK_TOSHIBA_TC9564_H__*/
Signature · 1 line
2.53.0
PATCH v3 2/3 clk: toshiba: introduce a TC9564 clock/reset driver
In reply to Alex ElderDefine a new platform driver that manages clocks and resets implemented by the Toshiba TC9564 SoC. There are 21 gate clocks that can be enabled and disabled, but currently only the clocks that are (or will soon be) used are defined to be controllable. There are also 13 resets that can be asserted or deasserted, but support for some of these is omitted as well.
Two registers manage the state of the clocks, and two others manage the state of the resets. All four registers are found in a region mapped for MMIO. The region is provided via a BAR on one of the PCI functions embedded in the TC9564 SoC.
The I2C and PCIE clocks and resets are treated as CRITICAL, meaning their state should never be changed (and a warning is issued if changing their state is attempted).
---
v3: - Fixed problems/garbage in the patch header
- The Kconfig option now depends on RESET_CONTROLLER, and can now be enabled if COMPILE_TEST is enabled
- The generic gate clock controller code is now used rather than implementing a custom one
- The PLL and internal fixed clocks IDs are no longer available outside "clk-tc9564.c"
- The PLL is initialialized, followed by all fixed rate clocks, followed by the gate clocks, to ensure each clock's parent is initialized before the clock is
- Updating the reset registers (read/modify/write) is now protected by a spinlock
- "Unnecessary newlines" have been removed
MAINTAINERS | 1 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 456 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 467 insertions(+) create mode 100644 drivers/clk/clk-tc9564.c
MAINTAINERS +1 -0
@@ -28722,6 +28722,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml +F: drivers/clk/clk-tc9564.c F: include/dt-bindings/clock/toshiba,tc9564.h TOSHIBA TC9564 PCI DRIVER
drivers/clk/Kconfig +9 -0
@@ -185,6 +185,15 @@ config COMMON_CLK_CDCE706 help This driver supports TI CDCE706 programmable 3-PLL clock synthesizer. +config COMMON_CLK_TC9564 + tristate "Toshiba TC9564 clock and reset support" + depends on TC9564_PCI || COMPILE_TEST + depends on RESET_CONTROLLER + default TC9564_PCI + help + This enables support for the clock and reset controllers embedded + in the Toshiba TC9564 SoC. + config COMMON_CLK_TPS68470 tristate "Clock Driver for TI TPS68470 PMIC" depends on I2C
drivers/clk/Makefile +1 -0
@@ -111,6 +111,7 @@ obj-$(CONFIG_COMMON_CLK_SI570) += clk-si570.o obj-$(CONFIG_COMMON_CLK_SP7021) += clk-sp7021.o obj-$(CONFIG_COMMON_CLK_STM32F) += clk-stm32f4.o obj-$(CONFIG_COMMON_CLK_STM32H7) += clk-stm32h7.o +obj-$(CONFIG_COMMON_CLK_TC9564) += clk-tc9564.o obj-$(CONFIG_COMMON_CLK_TPS68470) += clk-tps68470.o obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o obj-$(CONFIG_CLK_TWL) += clk-twl.o
drivers/clk/clk-tc9564.c new file +456 -0
456 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v3 3/3 arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
In reply to Alex ElderAdd a node for the clock and reset controller found within the Toshiba TC9564 SoC. Also add a node representing the fixed rate 25 MHz crystal that supplies the chip.
---
v3: - This patch was previously not included in the series
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +15 -0
@@ -890,6 +890,13 @@ pcie@0,0 { pinctrl-0 = <&tc9563_resx_n>; pinctrl-names = "default"; + tc9564_xo_board: clock-25000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; + clock-output-names = "tc9564_xo_board"; + }; + pcie1_switch0_dsp1: pcie@1,0 { reg = <0x20800 0x0 0x0 0x0 0x0>; #address-cells = <3>;
@@ -969,6 +976,14 @@ pci-ep-bus@4 { #size-cells = <1>; /* Map 0x0-0x1fffff to BAR 4 */ ranges = <0x0 0x4 0x0 0x0 0x200000>; + + clock-controller@1004 { + compatible = "toshiba,tc9564-clock"; + reg = <0x1004 0x10>; + clocks = <&tc9564_xo_board>; + #clock-cells = <1>; + #reset-cells = <1>; + }; }; };
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] arm64: dts: qcom: clock-25000000 under pcie@0,0 shifts tc9563 port indexing --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] arm64: dts: qcom: clock-25000000 under pcie@0,0 shifts tc9563 port indexing
--
commit c4e2dd0c5c7aea169ea475dfdf59cb2e475d33be
Author: Alex Elder <[email protected]>
arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
This commit adds a devicetree node for the Toshiba TC9564 clock and reset controller along with a 25 MHz fixed-clock node supplying it.
Quoted 8 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +0
-0@@ -890,6 +890,13 @@ pcie@0,0 { pinctrl-0 = <&tc9563_resx_n>; pinctrl-names = "default";
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts pcie@0,0 { · line 902
Quoted 10 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +7
-0+ tc9564_xo_board: clock-25000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; + clock-output-names = "tc9564_xo_board"; + }; + pcie1_switch0_dsp1: pcie@1,0 { reg = <0x20800 0x0 0x0 0x0 0x0>; #address-cells = <3>;
[Severity: High]
Does placing clock-25000000 as the first child of pcie@0,0 shift the downstream port indexing in the tc9563 power control driver?
Both tc9563_pwrctrl_probe() and tc9563_pwrctrl_parse_reset_line() map the direct children of the pci1179,0623 node positionally to TC9563_DSP1, TC9563_DSP2, and TC9563_VDSP:
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c:tc9563_pwrctrl_probe() {
...
port = TC9563_USP;
for_each_child_of_node_scoped(node, child) {
if (++port >= TC9563_MAX)
break;
ret = tc9563_pwrctrl_parse_device_dt(child, &tc9563->cfg[port]);
...
}With clock-25000000 ahead of pcie@1,0, pcie@2,0, and pcie@3,0, the driver treats clock-25000000 as TC9563_DSP1, shifts pcie@1,0 and pcie@2,0 into TC9563_DSP2 and TC9563_VDSP (misassociating per-port settings, reset GPIOs, and the integrated Ethernet endpoint), and stops before reaching pcie@3,0. It also violates Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml, which only permits pcie@[1-2],0 and pcie@[3],0 child nodes. Should tc9564_xo_board live under the root /clocks node instead?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
Quoted 5 lines · On 11/25/26 2:28 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] arm64: dts: qcom: clock-25000000 under pcie@0,0 shifts tc9563 port indexing
--
This was a great catch on a seemingly unrelated problem.
I will consider how to address it. Off hand I can think of two options, but I'm sure there are others:
- Move the tc9564_xo_board *after* the downstream ports (after the end of the pcie@3,0 node). In this case I would add a clear comment in the DTS file explaining why this is necessary.
- Make the logic in "pci-pwrctrl-tc9563.c" more robust, possibly by skipping nodes that aren't of type "pci" (or possibly "pciex"?).
I think the second option is better, but I'm open to other suggestions.
However, at the very end of this message there is another observation that might make the above moot. I think this clock node should probably be defined closer to the root of the tree. I'll verify that and will fix it.
Quoted 16 lines
commit
c4e2dd0c5c7aea169ea475dfdf59cb2e475d33be
Author: Alex Elder <[email protected]>arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
This commit adds a devicetree node for the Toshiba TC9564 clock and reset controller along with a 25 MHz fixed-clock node supplying it.
Quoted 8 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +0
-0@@ -890,6 +890,13 @@ pcie@0,0 { pinctrl-0 = <&tc9563_resx_n>; pinctrl-names = "default";
Quoted 14 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts pcie@0,0 { · line 902
Quoted 10 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +7
-0+ tc9564_xo_board: clock-25000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; + clock-output-names = "tc9564_xo_board"; + }; + pcie1_switch0_dsp1: pcie@1,0 { reg = <0x20800 0x0 0x0 0x0 0x0>; #address-cells = <3>;[Severity: High]
Does placing clock-25000000 as the first child of pcie@0,0 shift the downstream port indexing in the tc9563 power control driver?
I think it currently does.
Quoted 10 lines
Both
tc9563_pwrctrl_probe()andtc9563_pwrctrl_parse_reset_line()map the direct children of the pci1179,0623 node positionally toTC9563_DSP1,TC9563_DSP2, andTC9563_VDSP:drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c:tc9563_pwrctrl_probe() { ... port = TC9563_USP; for_each_child_of_node_scoped(node, child) { if (++port >= TC9563_MAX) break;
If the second option above is chosen, this function should be updated the same way.
Quoted 11 lines
ret = tc9563_pwrctrl_parse_device_dt(child, &tc9563->cfg[port]); ... }With clock-25000000 ahead of pcie@1,0, pcie@2,0, and pcie@3,0, the driver treats clock-25000000 as
TC9563_DSP1, shifts pcie@1,0 and pcie@2,0 intoTC9563_DSP2andTC9563_VDSP(misassociating per-port settings, reset GPIOs, and the integrated Ethernet endpoint), and stops before reaching pcie@3,0. It also violatesDocumentation/devicetree/bindings/pci/toshiba,tc9563.yaml, which only permits pcie@[1-2],0 and pcie@[3],0 child nodes. Shouldtc9564_xo_boardlive under the root /clocks node instead?
The 25 MHz oscillator comes from *outside* the TC9564 chip, not under the upstream PCIe switch port.
For this reason, it should be defined somewhere on the board, not within the TC9564 chip.
I will investigate the right way to represent this and will correct it.
-Alex
Quoted 10 lines · Alex Elder
This series introduces a devicetree binding and single driver to support the clock and reset components present within the Toshiba TC9564 chip.
The Toshiba TC9564 is an SoC that attaches to a host system via PCIe. It includes a PCIe switch with three downstream ports. To one of these ports an embedded PCIe endpoint is attached, and that implements two PCI functions. BAR 4 for both PCI functions provides access to registers controlling blocks within the SoC, including the clock and reset controllers supported by this series.
Quoted 5 lines
The first version of this series included a system controller, which has since been removed. This version addresses all review feedback received on version 2.
-Alex
As I provided last time, a copy of a working DTS file that uses this binding and driver is available here:
https://github.com/riscstar/linux/tree/tc9564-dts
Isolated in this commit:
https://github.com/riscstar/linux/commit/e1f8e40b04137798ffd410fc675d9eccfb1c13f9
-Alex
Quoted 69 lines
Version 2 is available here:
https://lore.kernel.org/all/[email protected]/Between version 2 and version 3:
- Added Lorenzo's Reviewed-by on the devicetree binding patch
- The devicetree binding now uses @kernel.org e-mail addresses for Daniel and me
- Cleaned up the patch header text in patch 2
- TheKconfigoption now depends onRESET_CONTROLLER
- TheKconfigoption can now be enabled ifCOMPILE_TESTis enabled
- The generic gate clock controller code is now used rather than implementing a custom one
- Only the gate clock IDs are now published in "toshiba,tc9564.h"; the PLL and internal fixed clocks are implemented and accessed only within "clk-tc9564.c"
- The PLL is initialialized, followed by all fixed rate clocks, followed by the gate clocks, to ensure each clock's parent is initialized before the clock is
- Updating the reset registers (read/modify/write) is now protected by a spinlock
- There are no more "unnecessary newlines" in the initialization arrays for clocks and resets
- An update to the DTS file is now included as the last patch in this seriesThe version prior to v2 of this code was included in this series:
https://lore.kernel.org/all/[email protected]/Between that series (v1) and this one (v2):
- There is no more syscon, so its devicetree binding and driver have been dropped
- The clock and reset components now have a single devicetree binding
- We no longer use a syscon-generated regmap for accessing the common range of memory used by multiple drivers; specific sub-ranges are instead mapped
- The clock and reset drivers have been combined into a single driver located underdrivers/clk
- The config option for the driver includesCOMPILE_TEST, as requested (last month) by Jerome Brunet
- The help text for the config option is simplified, first suggested by Philipp Zabel
- The driver now names clocks usingdev_name()rather than trying to hand-code a unique name into a fixed-size name array (also suggested by Jerome)
- Certain functions now always return 0, which simplifies callers so they can simply return what the called function returns
- As suggested by sashiko, a counted-by field in a flex array is now assigned explicitlyAlex Elder (3):
dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
clk: toshiba: introduce a TC9564 clock/reset driver
arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node.../bindings/clock/toshiba,tc9564-clock.yaml | 73 +++ MAINTAINERS | 9 + arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 15 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 456 ++++++++++++++++++ include/dt-bindings/clock/toshiba,tc9564.h | 40 ++ 7 files changed, 603 insertions(+)create mode 100644
Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yamlcreate mode 100644drivers/clk/clk-tc9564.c
create mode 100644include/dt-bindings/clock/toshiba,tc9564.hbase-commit:
9437046953b2fb3bf55b36582450ea0267df82a7