Re: [PATCH v4 2/4] clk: toshiba: introduce a TC9564 clock driver

From: Jerome Brunet

Date: Thu Dec 03 2026 - 08:52:55 EST


> Define a new platform driver that manages clocks 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. The I2C and PCIE clocks marked
> as CRITICAL to prevent their state from ever changing.
>
> Two registers in an MMIO region manage the state of the clocks. The
> region is provided via a BAR on one of the PCI functions embedded in
> the TC9564 SoC.
>
> This driver creates an auxiliary device responsible for managing the
> reset controller implemented within the SoC. Some common definitions
> are added to <linux/soc/qcom/tc9563.h> to define the interface between
> the clock and the reset driver.
>
> The clock driver should normally be present whenever the TC9564 PCI
> driver is enabled, so have TC9564_PCI *imply* the clock driver's config
> option, COMMON_CLK_TC9564.
>
> Co-developed-by: Daniel Thompson <daniel@xxxxxxxxxxxx>
> Signed-off-by: Daniel Thompson <daniel@xxxxxxxxxxxx>
> Signed-off-by: Alex Elder <elder@xxxxxxxxxxxx>
> ---
> v4: - The clocks are now separated by type. A clk_hw pointer is maintained
> for the PLL; a hw_onecell_data array holds the clk_hw pointers for
> the fixed rate clocks; and a separate hw_onecell_data array holds
> clk_hw pointers for the gate clocks.
> - The reset controller code has been removed from the clock driver
> and placed in a new source file (found in the next patch).
> - This clock driver now creates a reset controller auxiliary
> device, to bind with the separate reset driver.
> - The clock driver and reset device name are now defined in an
> existing header file, <linux/soc/qcom/tc9563.h>. This header
> is now included by both the clock and reset drivers. A data
> structure that describes what is passed from the clock driver
> to the reset driver via platform data is defined there as well.
> - The function that creates each clock's name is now called
> clock_name_alloc() to make it obvious the caller must free
> the returned pointer.
> - Calls to clock_name_alloc() now all assign the result to a
> local variable declared with __free(kfree), so that the
> returned pointer gets automatically freed.
> - COMMON_CLK_TC9564 no longer depends on TC9564_PCI, and does
> not assign a default value. Instead, TC9564_PCI now *implies*
> COMMON_CLK_TC9564, meaning no default value is required.
> - The driver's probe_type is no set to prefer asynchronous probing.
>
> MAINTAINERS | 1 +
> drivers/clk/Kconfig | 8 +
> drivers/clk/Makefile | 1 +
> drivers/clk/clk-tc9564.c | 401 ++++++++++++++++++++++++++++++++
> drivers/misc/Kconfig | 1 +
> include/linux/soc/qcom/tc9563.h | 9 +
> 6 files changed, 421 insertions(+)
> create mode 100644 drivers/clk/clk-tc9564.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ed55ac25ac4c..ecede53dd28b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -28338,6 +28338,7 @@ M: Alex Elder <elder@xxxxxxxxxx>
> M: Daniel Thompson <danielt@xxxxxxxxxx>
> 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 37a8e35d4178..457199682b7d 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -185,6 +185,14 @@ config COMMON_CLK_CDCE706
> help
> This driver supports TI CDCE706 programmable 3-PLL clock synthesizer.
>
> +config COMMON_CLK_TC9564
> + tristate "Toshiba TC9564 clock support"
> + help
> + This enables support for the clock controller embedded in the
> + Toshiba TC9564 SoC. It is also required to support the embedded
> + reset device, which is represented as an auxiliary device created
> + by the clock controller driver.
> +
> 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 52d138d4ffc8..a11a8326d79c 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 000000000000..ec72a0207fd8
> --- /dev/null
> +++ b/drivers/clk/clk-tc9564.c
> @@ -0,0 +1,401 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +/*
> + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved.
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#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 <linux/soc/qcom/tc9563.h>
> +
> +#include <dt-bindings/clock/toshiba,tc9564.h>
> +
> +/*
> + * Two registers implement the bits that control whether our clocks are
> + * enabled. These offsets are relative to the address space defined in
> + * devicetree.
> + */
> +#define CLOCK0_OFFSET 0x0
> +#define CLOCK1_OFFSET 0x8
> +
> +/* This struct just allows two structures to be allocated/freed together */
> +struct reset_aux {
> + struct auxiliary_device adev;
> + struct tc9564_aux_data aux_data;
> +};
> +
> +/*
> + * 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.
> + */
> +struct tc9564_clock {
> + void __iomem *ioaddr; /* Mapped clock/reset registers */
> + spinlock_t lock; /* Protects reset register updates */

Leftover from v3: the lock is never initialised nor used, and the reset
registers are handled by the reset driver, which has its own lock.
Please remove it.

> + struct clk_hw *pll_hw;
> + struct clk_hw_onecell_data *fixed_data;
> + struct clk_hw_onecell_data *gate_data;
> +};
> +
> +/* Indexes into the fixed_init[] array */
> +enum fixed_clock {
> + TC9564_CLK_62_5M,
> + TC9564_CLK_125M,
> + TC9564_CLK_250M,
> + TC9564_CLK_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;
> +};
> +
> +static const struct fixed_init fixed_init[] = {
> + [TC9564_CLK_312_5M] = {
> + .name = "312.5MHz",
> + .div = 4,
> + },
> + [TC9564_CLK_250M] = {
> + .name = "250MHz",
> + .div = 5,
> + },
> + [TC9564_CLK_125M] = {
> + .name = "125MHz",
> + .div = 10,
> + },
> + [TC9564_CLK_62_5M] = {
> + .name = "62.5MHz",
> + .div = 20,

I've already commented on way to make a onecell here
If you need to iterate per type, keep those table
just add
.id = <TC9564_WHATEVER_IT_IS_DT_BINDINGS>

and fill the right index of the provider table with it

--
Jerome