mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver
@ 2026-11-25 20:21 Alex Elder
  2026-11-25 20:21 ` [PATCH v3 1/3] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-25 20:21 UTC (permalink / raw)
  To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt,
	p.zabel, andersson, konradybcio, abelvesa
  Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
	alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
	linux-arm-msm, linux-kernel

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/20261120183212.1264522-1-elder@riscstar.com/

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/20261104004332.2141282-1-elder@riscstar.com/

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
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/3] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml
  2026-11-25 20:21 [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
@ 2026-11-25 20:21 ` Alex Elder
  2026-11-25 20:21 ` [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-25 20:21 UTC (permalink / raw)
  To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt,
	p.zabel, andersson, konradybcio, abelvesa
  Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
	alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
	linux-arm-msm, linux-kernel

Define the binding for the clock and reset controller that present in
the Toshiba TC9564 SoC.

Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
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

diff --git a/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml b/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
new file mode 100644
index 0000000000000..026ed949f0f02
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/toshiba,tc9564-clock.yaml
@@ -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 <lorenzo.bianconi@oss.qualcomm.com>
+  - Alex Elder <elder@kernel.org>
+  - Daniel Thompson <danielt@kernel.org>
+
+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>;
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index 64f8b6153b870..36107e0790780 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <lorenzo.bianconi@oss.qualcomm.com>
+M:	Alex Elder <elder@kernel.org>
+M:	Daniel Thompson <danielt@kernel.org>
+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 <elder@kernel.org>
 M:	Daniel Thompson <danielt@kernel.org>
diff --git a/include/dt-bindings/clock/toshiba,tc9564.h b/include/dt-bindings/clock/toshiba,tc9564.h
new file mode 100644
index 0000000000000..7de8c8165199a
--- /dev/null
+++ b/include/dt-bindings/clock/toshiba,tc9564.h
@@ -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__*/
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver
  2026-11-25 20:21 [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
  2026-11-25 20:21 ` [PATCH v3 1/3] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
@ 2026-11-25 20:21 ` Alex Elder
  2026-11-25 20:21 ` [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
  2026-11-25 20:33 ` [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-25 20:21 UTC (permalink / raw)
  To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt,
	p.zabel, andersson, konradybcio, abelvesa
  Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
	alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
	linux-arm-msm, linux-kernel

Define 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).

Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
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

diff --git a/MAINTAINERS b/MAINTAINERS
index 36107e0790780..ac27a9bf55c41 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28722,6 +28722,7 @@ M:	Alex Elder <elder@kernel.org>
 M:	Daniel Thompson <danielt@kernel.org>
 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
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 6bfa2c8fffe1b..897f4a4c74edc 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -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
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 99377a13ebc57..d67cfb6d623d3 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -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
diff --git a/drivers/clk/clk-tc9564.c b/drivers/clk/clk-tc9564.c
new file mode 100644
index 0000000000000..306781e2f7b4f
--- /dev/null
+++ b/drivers/clk/clk-tc9564.c
@@ -0,0 +1,456 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (C) 2026 by RISCstar Solutions Corporation.  All rights reserved.
+ */
+
+#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+
+#include <dt-bindings/clock/toshiba,tc9564.h>
+
+/*
+ * Define the offsets for the registers that implement clock enable/disable
+ * bits for gated clocks, and those that implement reset assertion bits for
+ * resets.  These offsets are relative to the address space defined in
+ * devicetree.
+ */
+#define CLOCK0_OFFSET	0x0
+#define CLOCK1_OFFSET	0x8
+
+#define RESET0_OFFSET	0x4
+#define RESET1_OFFSET	0xc
+
+/*
+ * A PLL driven by a 25 MHz input oscillator provides a clock source to
+ * the chip.  A set of fixed rate clocks is derived from the PLL, and a
+ * set of gate clocks are children of the fixed rate clocks.
+ *
+ * The clk_hw[] array within a clk_hw_onecell_data structure tracks all
+ * of them.  The following definitions describe how these are laid out
+ * based on their indexes into the clk_hw[] array.  Gate clocks are first,
+ * so their "raw" public IDs can be used as indexes into the array.
+ */
+#define GATE_BASE	0
+#define FIXED_BASE	(GATE_BASE + GATE_COUNT)
+#define CLOCK_PLL	(FIXED_BASE + FIXED_COUNT)
+
+/* The total number of clocks in the clk_hw[] array */
+#define CLOCK_COUNT	(GATE_COUNT + FIXED_COUNT + 1)
+
+struct tc9564_clock {
+	void __iomem *ioaddr;	/* Mapped clock/reset registers */
+	spinlock_t lock;	/* Protects reset register updates */
+	struct clk_hw_onecell_data *clk_data;
+	struct reset_controller_dev rcdev;
+};
+
+/* Indexes into the fixed_init[] array */
+enum fixed_clock {
+	CLOCK_62_5M,
+	CLOCK_125M,
+	CLOCK_250M,
+	CLOCK_312_5M,
+};
+
+struct fixed_init {
+	const char *name;
+	unsigned int div;	/* Rate is PLL rate divided by this */
+};
+
+struct gate_init {
+	const char *name;
+	enum fixed_clock parent;
+	u8 offset;		/* Control register offset (0x0 or 0x8) */
+	u8 bit;			/* Bit in the control register (0-31) */
+	bool critical;
+};
+
+struct reset_init {
+	u8 offset;		/* Control register offset (0x4 or 0xc) */
+	u8 bit;			/* Bit in the control register (0-31) */
+};
+
+/* Add FIXED_BASE to index values to get their index into the clk_hw[] array */
+static const struct fixed_init fixed_init[] = {
+	[CLOCK_312_5M] = {
+		.name = "312.5MHz",
+		.div = 4,
+	},
+	[CLOCK_250M] = {
+		.name = "250MHz",
+		.div = 5,
+	},
+	[CLOCK_125M] = {
+		.name = "125MHz",
+		.div = 10,
+	},
+	[CLOCK_62_5M] = {
+		.name = "62.5MHz",
+		.div = 20,
+	},
+};
+#define FIXED_COUNT	ARRAY_SIZE(fixed_init)
+
+/* Add GATE_BASE to index values to get their index into the clk_hw[] array */
+static const struct gate_init gate_init[] = {
+	[CLOCK_MAC0_TX] = {
+		.name = "MAC0-TX",
+		.parent = CLOCK_312_5M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 7,
+	},
+	[CLOCK_PCIE] = {
+		.name = "PCIe",
+		.parent = CLOCK_250M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 9,
+		.critical = true,
+	},
+	[CLOCK_I2C] = {
+		.name = "i2c",
+		.parent = CLOCK_62_5M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 12,
+		.critical = true,
+	},
+	[CLOCK_MAC0_RX] = {
+		.name = "MAC0-RX",
+		.parent = CLOCK_312_5M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 14,
+	},
+	[CLOCK_MSIGEN] = {
+		.name = "msigen",
+		.parent = CLOCK_125M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 18,
+	},
+	[CLOCK_MAC0_125M] = {
+		.name = "MAC0-125MHz",
+		.parent = CLOCK_125M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 29,
+	},
+	[CLOCK_MAC0_ALL] = {
+		.name = "MAC0-ALL",
+		.parent = CLOCK_250M,
+		.offset = CLOCK0_OFFSET,
+		.bit = 31,
+	},
+	[CLOCK_MAC1_TX] = {
+		.name = "MAC1-TX",
+		.parent = CLOCK_312_5M,
+		.offset = CLOCK1_OFFSET,
+		.bit = 7,
+	},
+	[CLOCK_MAC1_RX] = {
+		.name = "MAC1-RX",
+		.parent = CLOCK_312_5M,
+		.offset = CLOCK1_OFFSET,
+		.bit = 14,
+	},
+	[CLOCK_MAC1_125M] = {
+		.name = "MAC1-125MHz",
+		.parent = CLOCK_125M,
+		.offset = CLOCK1_OFFSET,
+		.bit = 29,
+	},
+	[CLOCK_MAC1_ALL] = {
+		.name = "MAC1-ALL",
+		.parent = CLOCK_250M,
+		.offset = CLOCK1_OFFSET,
+		.bit = 31,
+	},
+};
+#define GATE_COUNT	ARRAY_SIZE(gate_init)
+
+static const struct reset_init reset_init[] = {
+	[RESET_MAC0_MAC] = {
+		.offset = RESET0_OFFSET,
+		.bit = 7,
+	},
+	[RESET_PCIE] = {
+		.offset = RESET0_OFFSET,
+		.bit = 9,
+	},
+	[RESET_I2C] = {
+		.offset = RESET0_OFFSET,
+		.bit = 12,
+	},
+	[RESET_MSIGEN] = {
+		.offset = RESET0_OFFSET,
+		.bit = 18,
+	},
+	[RESET_MAC0_PMA] = {
+		.offset = RESET0_OFFSET,
+		.bit = 30,
+	},
+	[RESET_MAC0_XPCS] = {
+		.offset = RESET0_OFFSET,
+		.bit = 31,
+	},
+	[RESET_MAC1_MAC] = {
+		.offset = RESET1_OFFSET,
+		.bit = 7,
+	},
+	[RESET_MAC1_PMA] = {
+		.offset = RESET1_OFFSET,
+		.bit = 30,
+	},
+	[RESET_MAC1_XPCS] = {
+		.offset = RESET1_OFFSET,
+		.bit = 31,
+	},
+};
+#define RESET_COUNT	ARRAY_SIZE(reset_init)
+
+/* Caller must free the returned pointer if non-null */
+static const char *clock_name(struct device *dev, const char *name)
+{
+	return kasprintf(GFP_KERNEL, "%s-%s", dev_name(dev), name);
+}
+
+/* Initialize the PLL (parent is the input oscillator); called from probe */
+static int pll_init(struct device *dev, struct tc9564_clock *clock)
+{
+	struct clk_hw *hw;
+	const char *name;
+
+	/* Initialize the PLL clock first (input oscillator is parent) */
+	name = clock_name(dev, "pll");
+	if (!name)
+		return -ENOMEM;
+
+	hw = devm_clk_hw_register_fixed_factor_index(dev, name, 0, 0, 50, 1);
+	kfree(name);
+	if (IS_ERR(hw))
+		return dev_err_probe(dev, PTR_ERR(hw),
+				     "failed to register pll\n");
+
+	clock->clk_data->hws[CLOCK_PLL] = hw;
+
+	return 0;
+}
+
+/* Initialize the fixed rate clocks (PLL is parent); called from probe */
+static int fixed_clock_init(struct device *dev, struct tc9564_clock *clock)
+{
+	struct clk_hw_onecell_data *clk_data = clock->clk_data;
+	struct clk_hw *pll_hw = clk_data->hws[CLOCK_PLL];
+	const char *name;
+
+	for (u32 i = 0; i < FIXED_COUNT; i++) {
+		const struct fixed_init *init = &fixed_init[i];
+		struct clk_hw *hw;
+
+		name = clock_name(dev, init->name);
+		if (!name)
+			return -ENOMEM;
+
+		hw = devm_clk_hw_register_fixed_factor_parent_hw(dev, name,
+								 pll_hw, 0,
+								 1, init->div);
+		kfree(name);
+		if (IS_ERR(hw))
+			return dev_err_probe(dev, PTR_ERR(hw),
+					     "failed to register %s\n",
+					     init->name);
+
+		clk_data->hws[FIXED_BASE + i] = hw;
+	}
+
+	return 0;
+}
+
+/* Initialize the gate clocks; called from probe */
+static int gate_clock_init(struct device *dev, struct tc9564_clock *clock)
+{
+	struct clk_hw_onecell_data *clk_data = clock->clk_data;
+	struct clk_hw *parent_hw;
+	const char *name;
+
+	for (u32 i = 0; i < GATE_COUNT; i++) {
+		const struct gate_init *init = &gate_init[i];
+		unsigned long flags;
+		struct clk_hw *hw;
+		void __iomem *reg;
+		u32 parent_index;
+
+		name = clock_name(dev, init->name);
+		if (!name)
+			return -ENOMEM;
+
+		/* Each gate clock's parent is a fixed rate clock */
+		parent_index = FIXED_BASE + init->parent;
+		parent_hw = clk_data->hws[parent_index];
+		flags = init->critical ? CLK_IS_CRITICAL : 0;
+		reg = clock->ioaddr + init->offset;
+
+		hw = devm_clk_hw_register_gate_parent_hw(dev, name, parent_hw,
+							 flags, reg, init->bit,
+							 0, NULL);
+		kfree(name);
+		if (IS_ERR(hw))
+			return dev_err_probe(dev, PTR_ERR(hw),
+					     "failed to register %s\n",
+					     init->name);
+
+		clk_data->hws[GATE_BASE + i] = hw;
+	}
+
+	return 0;
+}
+
+static int reset_update(struct reset_controller_dev *rcdev,
+			unsigned long id, bool assert)
+{
+	const struct reset_init *reset;
+	struct tc9564_clock *clock;
+	unsigned long flags;
+	void __iomem *reg;
+	u32 mask;
+	u32 val;
+
+	/* Warn on any attempt to change state of a critical reset */
+	if (WARN_ON(id == RESET_I2C) || WARN_ON(id == RESET_PCIE))
+		return 0;
+
+	clock = dev_get_drvdata(rcdev->dev);
+	reset = &reset_init[id];
+	reg = clock->ioaddr + reset->offset;
+	mask = BIT(reset->bit);
+
+	spin_lock_irqsave(&clock->lock, flags);
+
+	val = readl(reg);
+	if (assert)
+		val |= mask;
+	else
+		val &= ~mask;
+	writel(val, reg);
+
+	spin_unlock_irqrestore(&clock->lock, flags);
+
+	return 0;
+}
+
+static int reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	return reset_update(rcdev, id, true);
+}
+
+static int reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	return reset_update(rcdev, id, false);
+}
+
+static int reset_status(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	struct tc9564_clock *clock = dev_get_drvdata(rcdev->dev);
+	const struct reset_init *reset = &reset_init[id];
+	void __iomem *reg;
+
+	reg = clock->ioaddr + reset->offset;
+
+	return readl(reg) & BIT(reset->bit) ? 1 : 0;
+}
+
+static const struct reset_control_ops reset_control_ops = {
+	.assert = reset_assert,
+	.deassert = reset_deassert,
+	.status = reset_status,
+};
+
+static int tc9564_clk_probe(struct platform_device *pdev)
+{
+	struct clk_hw_onecell_data *clk_data;
+	struct reset_controller_dev *rcdev;
+	struct tc9564_clock *clock;
+	struct device *dev = &pdev->dev;
+	struct device_node *np;
+	int ret;
+
+	np = dev_of_node(dev);
+	if (!np)
+		return dev_err_probe(dev, -EINVAL, "no devicetree node\n");
+
+	clock = devm_kzalloc_obj(dev, *clock);
+	if (!clock)
+		return -ENOMEM;
+
+	clock->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(clock->ioaddr))
+		return dev_err_probe(dev, PTR_ERR(clock->ioaddr),
+				     "failed to map registers\n");
+
+	clk_data = devm_kzalloc_flex(dev, *clock->clk_data, hws,
+				     CLOCK_COUNT);
+	if (!clk_data)
+		return -ENOMEM;
+	clk_data->num = CLOCK_COUNT;
+
+	clock->clk_data = clk_data;
+
+	/* We need the driver data pointer to initialize clocks and resets */
+	dev_set_drvdata(dev, clock);
+
+	/* Set up the clocks and register the provider */
+	ret = pll_init(dev, clock);
+	if (ret)
+		return ret;
+
+	ret = fixed_clock_init(dev, clock);
+	if (ret)
+		return ret;
+
+	ret = gate_clock_init(dev, clock);
+	if (ret)
+		return ret;
+
+	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to add clock provider\n");
+
+	/* Set up and register the reset controller */
+	rcdev = &clock->rcdev;
+	rcdev->ops = &reset_control_ops;
+	rcdev->owner = THIS_MODULE;
+	rcdev->dev = dev;
+	rcdev->of_node = np;
+	rcdev->nr_resets = RESET_COUNT;
+
+	spin_lock_init(&clock->lock);
+
+	ret = devm_reset_controller_register(dev, rcdev);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to register reset controller\n");
+
+	return 0;
+}
+
+static const struct of_device_id tc9564_clock_match[] = {
+	{ .compatible = "toshiba,tc9564-clock", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, tc9564_clock_match);
+
+static struct platform_driver tc9564_clk_driver = {
+	.probe = tc9564_clk_probe,
+	.driver = {
+		.name = KBUILD_MODNAME,
+		.of_match_table = tc9564_clock_match,
+		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
+	},
+};
+module_platform_driver(tc9564_clk_driver);
+
+MODULE_DESCRIPTION("Toshiba TC9564 Clock Driver");
+MODULE_LICENSE("GPL");
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
  2026-11-25 20:21 [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
  2026-11-25 20:21 ` [PATCH v3 1/3] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
  2026-11-25 20:21 ` [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
@ 2026-11-25 20:21 ` Alex Elder
  2026-11-25 20:33 ` [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-25 20:21 UTC (permalink / raw)
  To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt,
	p.zabel, andersson, konradybcio, abelvesa
  Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
	alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
	linux-arm-msm, linux-kernel

Add 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.

Co-developed-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Signed-off-by: Alex Elder <elder@riscstar.com>
---
v3: - This patch was previously not included in the series

 arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
index 682bcbc0b466b..b327f64885ef2 100644
--- a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
+++ b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
@@ -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>;
+					};
 				};
 			};
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver
  2026-11-25 20:21 [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
                   ` (2 preceding siblings ...)
  2026-11-25 20:21 ` [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
@ 2026-11-25 20:33 ` Alex Elder
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2026-11-25 20:33 UTC (permalink / raw)
  To: sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt,
	p.zabel, andersson, konradybcio, abelvesa
  Cc: daniel, mohd.anwar, lorenzo.bianconi, fabrice.gasnier,
	alexandre.torgue, marex, changhuang.liang, devicetree, linux-clk,
	linux-arm-msm, linux-kernel

On 11/25/26 2:21 PM, Alex Elder wrote:
> 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

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

> 
> Version 2 is available here:
>    https://lore.kernel.org/all/20261120183212.1264522-1-elder@riscstar.com/
> 
> 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/20261104004332.2141282-1-elder@riscstar.com/
> 
> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-25 20:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 20:21 [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
2026-11-25 20:21 ` [PATCH v3 1/3] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
2026-11-25 20:21 ` [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
2026-11-25 20:21 ` [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
2026-11-25 20:33 ` [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®