soc: toshiba: tc9564: config system controller
Subsystems (3)
cover soc: toshiba: tc9564: config system controller
This series is comprised of some code that was previously sent separately. It now incorporates a new system controller driver that advertises clock and reset functionality, as well as regmap access to its address range. This combination is being treated as a new series. (Details of previous versions are below.)
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.
The system controller driver adds the clock and reset devices using the mfd_add_devices() interface. The clocks and resets are implemented by drivers included in this series.
-Alex
The system controller, along with its devicetree binding are new. My hope is that this new model addresses concerns that Krzysztof Kozlowski has expressed in prior versions of the clock and reset code ("fold into the parent").
The clock controller driver was last posted as version 3, and all feedback from prior versions has been addressed. This driver has essentially been completely rewritten. There are now three clock types (PLL, fixed factor, and gate), and each defined clock has a parent, and the is_enabled callback is implemented for the gate clocks.
The last version of the clock driver is here:
https://lore.kernel.org/lkml/[email protected]/
The reset controller driver was last posted as version 1. All feedback received on that version has been addressed, and it's a bit simpler than before.
The last version of the reset driver is here:
https://lore.kernel.org/lkml/[email protected]/
Alex Elder (4):
dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
soc: toshiba: tc9564: add a new syscon driver
clk: toshiba: introduce a TC9564 SoC clock driver
reset: toshiba: introduce a TC9564 SoC reset driver
.../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++ MAINTAINERS | 23 ++ drivers/clk/Kconfig | 12 + drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 288 ++++++++++++++++++ drivers/reset/Kconfig | 12 + drivers/reset/Makefile | 1 + drivers/reset/reset-tc9564.c | 135 ++++++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/toshiba/Kconfig | 12 + drivers/soc/toshiba/Makefile | 3 + drivers/soc/toshiba/tc9564-syscon.c | 42 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++ 14 files changed, 645 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml create mode 100644 drivers/clk/clk-tc9564.c create mode 100644 drivers/reset/reset-tc9564.c create mode 100644 drivers/soc/toshiba/Kconfig create mode 100644 drivers/soc/toshiba/Makefile create mode 100644 drivers/soc/toshiba/tc9564-syscon.c create mode 100644 include/dt-bindings/soc/toshiba,tc9564.h
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.53.0
PATCH 1/4 dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
Define the binding for the system controller that implements the clock and reset controller functionality present in the Toshiba TC9564 SoC.
--- .../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++++++++++++++++ MAINTAINERS | 8 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml create mode 100644 include/dt-bindings/soc/toshiba,tc9564.h
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +68 -0
@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/toshiba/toshiba,tc9564-config-syscon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 Multifunction System 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 switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals via its BARs. These peripherals include a simple + controller to gate internal clocks, as well as a reset controller. + + The clock controller uses registers within the same page as a reset + controller, so this system controller controls access to both. + + A total of 21 simple gated clocks are implemented within the SoC. + At this time, support for enabling and disabling only a subset of + them is provided at this time. Similarly, the SoC implements 13 + resets, but currently not all of them can be controlled. + +properties: + compatible: + items: + - const: toshiba,tc9564-config-syscon + - const: syscon + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + "#clock-cells": + const: 1 + description: + Clock ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + + "#reset-cells": + const: 1 + description: + Reset ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + +required: + - compatible + - reg + - clocks + - "#clock-cells" + - "#reset-cells" + +additionalProperties: false + +examples: + - | + syscon@0 { + compatible = "toshiba,tc9564-config-syscon", "syscon"; + reg = <0x0 0x2000>; + clocks = <&tc9564_xo_board>; + #clock-cells = <1>; + #reset-cells = <1>; + };
MAINTAINERS +8 -0
@@ -28339,6 +28339,14 @@ S: Maintained F: Documentation/devicetree/bindings/misc/pci1179,0220.yaml F: drivers/misc/tc9564-pci.c +TOSHIBA TC9564 SYSTEM CONTROLLER DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml +F: include/dt-bindings/soc/toshiba,tc9564.h + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]
include/dt-bindings/soc/toshiba,tc9564.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 2/4 soc: toshiba: tc9564: add a new syscon driver
In reply to Alex ElderIntroduce a new system controller driver for devices found within the Toshiba TC9564 SoC. The system controller manages access to an 8 KB region, and implements controllers for a set of clocks as well as a set of resets. The region also includes registers that indicate when initialization is done for the chip's two Ethernet interfaces.
The SoC has a single 25 MHz input clock, and from that derives clocks of various rates used by functional blocks within the chip.
--- MAINTAINERS | 1 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/toshiba/Kconfig | 12 +++++++++ drivers/soc/toshiba/Makefile | 3 +++ drivers/soc/toshiba/tc9564-syscon.c | 42 +++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+) create mode 100644 drivers/soc/toshiba/Kconfig create mode 100644 drivers/soc/toshiba/Makefile create mode 100644 drivers/soc/toshiba/tc9564-syscon.c
MAINTAINERS +1 -0
@@ -28345,6 +28345,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml +F: drivers/soc/toshiba/tc9564-syscon.c F: include/dt-bindings/soc/toshiba,tc9564.h TOSHIBA WMI HOTKEYS DRIVER
drivers/soc/Kconfig +1 -0
@@ -29,6 +29,7 @@ source "drivers/soc/starfive/Kconfig" source "drivers/soc/sunxi/Kconfig" source "drivers/soc/tegra/Kconfig" source "drivers/soc/ti/Kconfig" +source "drivers/soc/toshiba/Kconfig" source "drivers/soc/ux500/Kconfig" source "drivers/soc/versatile/Kconfig" source "drivers/soc/vt8500/Kconfig"
drivers/soc/Makefile +1 -0
@@ -35,6 +35,7 @@ obj-y += starfive/ obj-y += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-y += ti/ +obj-y += toshiba/ obj-$(CONFIG_ARCH_U8500) += ux500/ obj-y += versatile/ obj-y += vt8500/
drivers/soc/toshiba/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config SOC_TOSHIBA_TC9564_SYSCON + tristate "Toshiba TC9564 config system controller support" + depends on TC9564_PCI + depends on MFD_CORE + default TC9564_PCI + help + This enables support for the config system controller for the + TC9564 SoC. It implements an MMIO regmap to manage access to + two pages of I/O memory, and serves as a clock and reset + controller for IP blocks within the chip.
drivers/soc/toshiba/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_SOC_TOSHIBA_TC9564_SYSCON) += tc9564-syscon.o
drivers/soc/toshiba/tc9564-syscon.c new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 3/4 clk: toshiba: introduce a TC9564 SoC clock driver
In reply to Alex ElderDefine 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.
Two registers manage the state of the clocks. The registers are accessed via a regmap supplied by a system controller. Access to the memory region is provided via a BAR on a PCIe endpoint function embedded in the TC9564 SoC.
--- MAINTAINERS | 7 + drivers/clk/Kconfig | 12 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 288 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 308 insertions(+) create mode 100644 drivers/clk/clk-tc9564.c
MAINTAINERS +7 -0
@@ -28332,6 +28332,13 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC9564 CLOCK DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: drivers/clk/clk-tc9564.c + TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]>
drivers/clk/Kconfig +12 -0
@@ -293,6 +293,18 @@ config COMMON_CLK_S2MPS11 clock. These multi-function devices have two (S2MPS14) or three (S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each. +config COMMON_CLK_TC9564 + tristate "Toshiba TC9564 clock support" + depends on SOC_TOSHIBA_TC9564_SYSCON + select MFD_SYSCON + default SOC_TOSHIBA_TC9564_SYSCON + help + This enables support for the clock controller embedded in the + Toshiba TC9564 SoC. The state of each clock is controlled via + MMIO to a region managed by a system controller; this ensures + access to the region is coordinated between this and the reset + and XGMAC (stmmac) drivers. + config CLK_TWL tristate "Clock driver for the TWL PMIC family" depends on TWL4030_CORE
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 +288 -0
288 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 4/4 reset: toshiba: introduce a TC9564 SoC reset driver
In reply to Alex ElderDefine a new platform driver that manages reset signals implemented by the Toshiba TC9564 SoC. There are 13 reset signals available, but currently only the resets that are (or will soon be) used are defined to be controllable.
Two registers manage the state of the resets. The registers are accessed via a regmap supplied by a system controller. Access to the memory region is provided via a BAR on a PCIe endpoint function embedded in the TC9564 SoC.
--- MAINTAINERS | 7 ++ drivers/reset/Kconfig | 12 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-tc9564.c | 135 +++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 drivers/reset/reset-tc9564.c
MAINTAINERS +7 -0
@@ -28355,6 +28355,13 @@ F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.ya F: drivers/soc/toshiba/tc9564-syscon.c F: include/dt-bindings/soc/toshiba,tc9564.h +TOSHIBA TC9564 RESET DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: drivers/reset/reset-tc9564.c + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]
drivers/reset/Kconfig +12 -0
@@ -358,6 +358,18 @@ config RESET_SUNXI help This enables the reset driver for Allwinner SoCs. +config RESET_TC9564 + tristate "Toshiba TC9564 reset support" + depends on SOC_TOSHIBA_TC9564_SYSCON + select MFD_SYSCON + default SOC_TOSHIBA_TC9564_SYSCON + help + This enables support for the reset controller embedded in the + Toshiba TC9564 SoC. The state of reset lines is controlled + via MMIO to a region managed by a system controller; this + ensures access to the region is coordinated between this and + the clock and XGMAC (stmmac) drivers. + config RESET_TENSTORRENT_ATLANTIS tristate "Tenstorrent atlantis reset driver" depends on ARCH_TENSTORRENT || COMPILE_TEST
drivers/reset/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o +obj-$(CONFIG_RESET_TC9564) += reset-tc9564.o obj-$(CONFIG_RESET_TENSTORRENT_ATLANTIS) += reset-tenstorrent-atlantis.o obj-$(CONFIG_RESET_TH1520) += reset-th1520.o obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
drivers/reset/reset-tc9564.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 2/4] soc: toshiba: tc9564: add a new syscon driver
In reply to Alex ElderThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] soc: toshiba: SOC_TOSHIBA_TC9564_SYSCON depends on hidden MFD_CORE - [Low] soc: toshiba: MFD…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] soc: toshiba: SOC_TOSHIBA_TC9564_SYSCON depends on hidden MFD_CORE
- [Low] soc: toshiba: MFD driver calling devm_mfd_add_devices() outside drivers/mfd/
- [Low] soc: toshiba: Kconfig help and commit message mismatch tc9564-syscon.c --
commit 0d303444d1af16f91e36247fd63b0cb020f8be95
Author: Alex Elder <[email protected]>
soc: toshiba: tc9564: add a new syscon driver
This commit introduces a platform driver for the Toshiba TC9564 config system controller, registering MFD child devices for the chip's clock and reset controllers.
drivers/soc/toshiba/Kconfig line 7
Quoted 13 lines
drivers/soc/toshiba/Kconfig new file +7
-0@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config SOC_TOSHIBA_TC9564_SYSCON + tristate "Toshiba TC9564 config system controller support" + depends on TC9564_PCI + depends on MFD_CORE + default TC9564_PCI
[Severity: Medium]
Should SOC_TOSHIBA_TC9564_SYSCON use "select MFD_CORE" instead of "depends on MFD_CORE"?
In drivers/mfd/Kconfig, MFD_CORE is a promptless helper symbol with "default n":
config MFD_CORE
tristate
select IRQ_DOMAIN
default n
When a kernel configuration enables CONFIG_TC9564_PCI without any unrelated MFD driver that selects MFD_CORE, the dependency on MFD_CORE remains unmet and SOC_TOSHIBA_TC9564_SYSCON cannot be enabled. Similarly, if TC9564_PCI is built-in (y) and only modular drivers select MFD_CORE, SOC_TOSHIBA_TC9564_SYSCON is restricted to modular (m).
drivers/soc/toshiba/Kconfig line 12
Quoted 5 lines
drivers/soc/toshiba/Kconfig new file +5
-0+ help + This enables support for the config system controller for the + TC9564 SoC. It implements an MMIO regmap to manage access to + two pages of I/O memory, and serves as a clock and reset + controller for IP blocks within the chip.
[Severity: Low]
Does this help text (and the commit message) accurately describe what drivers/soc/toshiba/tc9564-syscon.c implements?
In tc9564_config_syscon_probe(), the driver only calls devm_mfd_add_devices() to register the toshiba-tc9564-clock and toshiba-tc9564-reset MFD cells; it does not set up an MMIO regmap (nor does SOC_TOSHIBA_TC9564_SYSCON select MFD_SYSCON) or implement the clock and reset controller providers itself. Could the help text and commit description be updated to reflect that this driver instantiates the clock and reset child devices?
[ ... ]
Quoted 20 lines
drivers/soc/toshiba/tc9564-syscon.c new file +14
-0@@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +#include <linux/device.h> +#include <linux/device-id/of.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/platform_device.h> + +static const struct mfd_cell tc9564_config_syscon_cells[] = { +MFD_CELL_NAME ("toshiba-tc9564-clock" ),
drivers/soc/toshiba/tc9564-syscon.c line 24
Quoted 10 lines
drivers/soc/toshiba/tc9564-syscon.c new file +10
-0+ MFD_CELL_NAME("toshiba-tc9564-reset"), +}; + +static int tc9564_config_syscon_probe (struct platform_device *pdev) +{ +return devm_mfd_add_devices (&pdev->dev,PLATFORM_DEVID_AUTO , + tc9564_config_syscon_cells, +ARRAY_SIZE (tc9564_config_syscon_cells), +NULL ,0 ,NULL ); +}
[Severity: Low]
Since tc9564_config_syscon_probe() in drivers/soc/toshiba/tc9564-syscon.c is purely an MFD driver calling devm_mfd_add_devices() to register child devices, should this driver be placed under drivers/mfd/ rather than drivers/soc/toshiba/ (with an "mfd: tc9564: ..." commit subject prefix) to follow MFD subsystem placement conventions?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH 3/4] clk: toshiba: introduce a TC9564 SoC clock driver
In reply to Alex ElderThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] clk: tc9564: duplicate clock names across chips due to using dev->id - [High] clk: tc9564…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: tc9564: duplicate clock names across chips due to using dev->id
- [High] clk: tc9564: uninitialized clk_data->num in tc9564_clk_probe()
--
commit d0d52063b982041aca91451199195cd79995784b
Author: Alex Elder <[email protected]>
clk: toshiba: introduce a TC9564 SoC clock driver
This commit adds a platform clock driver for the Toshiba TC9564 SoC, registering its PLL, fixed-factor, and gate clocks via a syscon regmap.
Quoted 6 lines
drivers/clk/clk-tc9564.c new file +0
-0@@ -0,0 +1,288 @@
[ ... ]
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+/* +* The full name of every clock has a prefix "tc9564" followed by a single +* character ('a', 'b', etc.) that differs for each chip/device number. +* Each clock's "name" defines the unique portion of the clock's full name. +*/ +#define FULL_NAME_SIZE 24/* Enough for formatted full name */ +#define NAME_SIZE 12/* Unique portion of the clock name */ +#define FORMAT_FULL_NAME (_full_name, _id, _name) \ + snprintf(_full_name, FULL_NAME_SIZE, "tc9564%c_%.*s", \ + 'a' + (_id), NAME_SIZE, _name)
[ ... ]
Quoted 21 lines
drivers/clk/clk-tc9564.c new file +21
-0+/* Parent is the input oscillator running at 25 MHz; PLL runs at 1250 MHz */ +static struct clk_hw *pll_register (struct device *dev, +const struct clock_init *init) +{ +char full_name[FULL_NAME_SIZE ]; + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + +return devm_clk_hw_register_fixed_factor_index (dev, full_name,0 ,0 , + init->mult,1 ); +} + +/* The PLL is the parent of all fixed clocks */ +static struct clk_hw *fixed_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +char full_name[FULL_NAME_SIZE ]; +struct clk_hw *pll_hw; + +FORMAT_FULL_NAME (full_name, dev->id, init->name);
[ ... ]
Quoted 5 lines
drivers/clk/clk-tc9564.c new file +5
-0+static struct clk_hw *gate_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +struct clk_init_data clk_init = { };
drivers/clk/clk-tc9564.c line 203
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+const struct clk_hw *parent_hw; +char full_name[FULL_NAME_SIZE ]; +struct gate_clock *clock; +int ret; + + clock =devm_kzalloc_obj (dev, *clock); +if (!clock) +return ERR_PTR (-ENOMEM ); + +FORMAT_FULL_NAME (full_name, dev->id, init->name);
[Severity: High]
Will passing dev->id to FORMAT_FULL_NAME() in pll_register(), fixed_register(), and gate_register() cause clock registration to fail with -EEXIST when more than one TC9564 device is present?
The clock MFD cell is registered as a platform device in tc9564_config_syscon_probe():
drivers/soc/toshiba/tc9564-syscon.c:tc9564_config_syscon_probe() {
...
return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
tc9564_config_syscon_cells,
ARRAY_SIZE(tc9564_config_syscon_cells),
NULL, 0, NULL);
}For platform devices, the platform bus stores the instance ID in pdev->id (struct platform_device::id), while dev->id (struct device::id) is never set and remains 0 for every instance. As a result, every TC9564 device formats its clocks with the "tc9564a_" prefix (such as "tc9564a_PLL"), so probing a second TC9564 device collides in __clk_core_init() when registering its clocks in the global clock namespace.
Note that pdev->id cannot be passed directly to 'a' + (_id) either, because PLATFORM_DEVID_AUTO allocates IDs from the system-wide platform_devid_ida shared across all auto-numbered platform devices rather than a 0-based per-chip index.
Quoted 40 lines
drivers/clk/clk-tc9564.c new file +40
-0+ + parent_hw = tc9564_clock->clk_data->hws[init->parent]; + + clk_init.name = full_name; + clk_init.ops = &gate_clk_ops; + clk_init.parent_hws = &parent_hw; + clk_init.num_parents =1 ; + + clock->hw.init = &clk_init; + clock->init = init; + + ret =devm_clk_hw_register (dev, &clock->hw); +if (ret) +return ERR_PTR (ret); + +return &clock->hw; +} + +static int tc9564_clk_probe (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data; +struct tc9564_clock *tc9564_clock; +struct device *dev = &pdev->dev; +struct device_node *parent_np; +int ret; + + parent_np =dev_of_node (dev->parent); +if (!parent_np) +return dev_err_probe (dev, -EINVAL ,"no devicetree node\n" ); + + tc9564_clock =devm_kzalloc_obj (dev, *tc9564_clock); +if (!tc9564_clock) +return -ENOMEM ; + +/* Note: MMIO regmap (no error checking needed when used) */ + tc9564_clock->regmap =device_node_to_regmap (parent_np); +if (IS_ERR (tc9564_clock->regmap)) +return dev_err_probe (dev,PTR_ERR (tc9564_clock->regmap), +"failed to get config regmap\n" ); +
drivers/clk/clk-tc9564.c line 253
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+ clk_data =devm_kzalloc_flex (dev, *tc9564_clock->clk_data, hws, +CLOCK_COUNT ); +if (!clk_data) +return -ENOMEM ; + tc9564_clock->clk_data = clk_data; + +dev_set_drvdata (dev, tc9564_clock); + +/* Initialize all the clocks */ +for (u32 i =0 ; i < clk_data->num; i++) {
[Severity: High]
Does clk_data->num remain 0 in tc9564_clk_probe() when building with compilers that do not support __builtin_counted_by_ref?
devm_kzalloc_flex() populates the __counted_by counter via __set_flex_counter():
include/linux/compiler_types.h:
#if __has_builtin(__builtin_counted_by_ref) && \
!defined(CONFIG_CC_HAS_BROKEN_COUNTED_BY_REF)
#define __flex_counter(FAM) __builtin_counted_by_ref(FAM)
#else
#define __flex_counter(FAM) ((void *)NULL)
#endif
include/linux/overflow.h:
#define __set_flex_counter(FAM, COUNT) \
({ \
*_Generic(__flex_counter(FAM), \
void *: &(size_t){ 0 }, \
default: __flex_counter(FAM)) = (COUNT); \
})On compilers without a working __builtin_counted_by_ref (such as GCC < 15.1 or Clang < 22.1), __set_flex_counter() writes COUNT into a temporary compound literal and leaves clk_data->num as 0. Without an explicit clk_data->num = CLOCK_COUNT assignment, the loop in tc9564_clk_probe() registers zero clocks and of_clk_hw_onecell_get() rejects all clock lookups with -EINVAL.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Philipp Zabel
maintainerRe: [PATCH 4/4] reset: toshiba: introduce a TC9564 SoC reset driver
In reply to Alex ElderQuoted 48 lines · Alex Elder
Define a new platform driver that manages reset signals implemented by the Toshiba TC9564 SoC. There are 13 reset signals available, but currently only the resets that are (or will soon be) used are defined to be controllable.
Two registers manage the state of the resets. The registers are accessed via a regmap supplied by a system controller. Access to the memory region is provided via a BAR on a PCIe endpoint function embedded in the TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 7 ++ drivers/reset/Kconfig | 12 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-tc9564.c | 135 +++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 drivers/reset/reset-tc9564.cMAINTAINERS +7
-0@@ -28355,6 +28355,13 @@ F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.ya F: drivers/soc/toshiba/tc9564-syscon.c F: include/dt-bindings/soc/toshiba,tc9564.h +TOSHIBA TC9564 RESET DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: drivers/reset/reset-tc9564.c + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]drivers/reset/Kconfig +1
-0@@ -358,6 +358,18 @@ config RESET_SUNXI help This enables the reset driver for Allwinner SoCs. +config RESET_TC9564
drivers/reset/Kconfig config RESET_SUNXI · line 371
Quoted 10 lines
drivers/reset/Kconfig +10
-0+ tristate "Toshiba TC9564 reset support" + depends on SOC_TOSHIBA_TC9564_SYSCON + select MFD_SYSCON + default SOC_TOSHIBA_TC9564_SYSCON + help + This enables support for the reset controller embedded in the + Toshiba TC9564 SoC. The state of reset lines is controlled + via MMIO to a region managed by a system controller; this + ensures access to the region is coordinated between this and + the clock and XGMAC (stmmac) drivers.
Drop the second sentence, explaining driver details to a user that just needs to decide whether to enable the driver or not is not helpful.
Quoted 22 lines
drivers/reset/Kconfig +1
-0+ config RESET_TENSTORRENT_ATLANTIS tristate "Tenstorrent atlantis reset driver" depends on ARCH_TENSTORRENT || COMPILE_TESTdrivers/reset/Makefile +1
-0@@ -45,6 +45,7 @@ obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o +obj-$(CONFIG_RESET_TC9564) += reset-tc9564.o obj-$(CONFIG_RESET_TENSTORRENT_ATLANTIS) += reset-tenstorrent-atlantis.o obj-$(CONFIG_RESET_TH1520) += reset-th1520.o obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.odrivers/reset/reset-tc9564.c new file +0
-0@@ -0,0 +1,135 @@
[...]
drivers/reset/reset-tc9564.c line 52
Quoted 8 lines
drivers/reset/reset-tc9564.c new file +8
-0+static void reset_manage (struct reset_controller_dev *rcdev, +unsigned long id,bool assert) +{ +const struct tc9564_reset *reset = &tc9564_reset[id]; +struct regmap *regmap =dev_get_drvdata (rcdev->dev); +u32 mask = reset->mask; + +regmap_update_bits (regmap, reset->offset, mask, assert ? mask :0 );
Just propagating the error value ...
drivers/reset/reset-tc9564.c line 59
Quoted 7 lines
drivers/reset/reset-tc9564.c new file +7
-0+} + +static int reset_assert (struct reset_controller_dev *rcdev,unsigned long id) +{ +reset_manage (rcdev, id, true); + +return 0 ;
... makes this even shorter.
Quoted 8 lines
drivers/reset/reset-tc9564.c new file +8
-0+} + +static int reset_deassert (struct reset_controller_dev *rcdev,unsigned long id) +{ +reset_manage (rcdev, id, false); + +return 0 ; +}
drivers/reset/reset-tc9564.c line 77
Quoted 10 lines
drivers/reset/reset-tc9564.c new file +10
-0+ +static int reset_status (struct reset_controller_dev *rcdev,unsigned long id) +{ +const struct tc9564_reset *reset = &tc9564_reset[id]; +struct regmap *regmap =dev_get_drvdata (rcdev->dev); +u32 val; + +regmap_read (regmap, reset->offset, &val); + +return val & reset->mask ?1 :0 ;
Consider using regmap_test_bits() here.
Quoted 11 lines
drivers/reset/reset-tc9564.c new file +11
-0+} + +static const struct reset_control_ops reset_control_ops = { + .assert = reset_assert, + .deassert = reset_deassert, + .status = reset_status, +}; + +static int tc9564_reset_probe (struct platform_device *pdev) +{ +struct reset_controller_dev *rcdev;
drivers/reset/reset-tc9564.c line 98
Quoted 10 lines
drivers/reset/reset-tc9564.c new file +10
-0+struct device *dev = &pdev->dev; +struct device_node *parent_np; +struct regmap *regmap; +int ret; + + parent_np =dev_of_node (dev->parent); +if (!parent_np) +return dev_err_probe (dev, -EINVAL ,"no devicetree node\n" ); + +/* Note: MMIO regmap (no error checking needed when used) */
I suggest you just add the unneeded error checks and drop this comment.
drivers/reset/reset-tc9564.c line 99
Quoted 1 line
drivers/reset/reset-tc9564.c new file +1
-0+ regmap =device_node_to_regmap (parent_np);
Can't you just use "dev_get_regmap(dev->parent, NULL)" ?
regards
Philipp
Re: [PATCH 2/4] soc: toshiba: tc9564: add a new syscon driver
In reply to [email protected]Quoted 2 lines · On 11/3/26 6:50 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] soc: toshiba:SOC_TOSHIBA_TC9564_SYSCONdepends on hiddenMFD_CORE
I explain more below, but I do not plan to act on the above issue.
Quoted 1 line
- [Low] soc: toshiba: MFD driver calling
devm_mfd_add_devices()outsidedrivers/mfd/
And I don't plan to act on this one either.
Quoted 1 line
- [Low] soc: toshiba:
Kconfighelp and commit message mismatchtc9564-syscon.c
I will do a minor rewording to address this one.
Quoted 20 lines
--
commit
0d303444d1af16f91e36247fd63b0cb020f8be95
Author: Alex Elder <[email protected]>soc: toshiba: tc9564: add a new syscon driver
This commit introduces a platform driver for the Toshiba TC9564 config system controller, registering MFD child devices for the chip's clock and reset controllers.
Quoted 9 lines
drivers/soc/toshiba/Kconfig new file +3
-0@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config SOC_TOSHIBA_TC9564_SYSCON
Quoted 8 lines
drivers/soc/toshiba/Kconfig line 7
Quoted 4 lines
drivers/soc/toshiba/Kconfig new file +4
-0+ tristate "Toshiba TC9564 config system controller support" + depends on TC9564_PCI + depends on MFD_CORE + default TC9564_PCI[Severity: Medium]
ShouldSOC_TOSHIBA_TC9564_SYSCONuse "selectMFD_CORE" instead of "depends onMFD_CORE"?
I would have used "select", however that leads to a recursive Kconfig dependency:
error: recursive dependency detected!
symbol SOC_TOSHIBA_TC9564_SYSCON depends on TC9564_PCI symbol TC9564_PCI depends on PCI_DYNAMIC_OF_NODES symbol PCI_DYNAMIC_OF_NODES depends on OF_IRQ symbol OF_IRQ depends on IRQ_DOMAIN
symbol IRQ_DOMAIN is selected by MFD_CORE symbol MFD_CORE is selected by SOC_TOSHIBA_TC9564_SYSCON
Using "depends on" does not exhibit that circular dependency.
So unless someone suggests a better way to fix this, I will keep this as-is.
Quoted 14 lines
In
drivers/mfd/Kconfig,MFD_COREis a promptless helper symbol with "default n":config
MFD_CORE
tristate
selectIRQ_DOMAIN
default nWhen a kernel configuration enables
CONFIG_TC9564_PCIwithout any unrelated MFD driver that selectsMFD_CORE, the dependency onMFD_COREremains unmet andSOC_TOSHIBA_TC9564_SYSCONcannot be enabled. Similarly, ifTC9564_PCIis built-in (y) and only modular drivers selectMFD_CORE,SOC_TOSHIBA_TC9564_SYSCONis restricted to modular (m).
Quoted 9 lines
drivers/soc/toshiba/Kconfig line 12
Quoted 5 lines
drivers/soc/toshiba/Kconfig new file +5
-0+ help + This enables support for the config system controller for the + TC9564 SoC. It implements an MMIO regmap to manage access to + two pages of I/O memory, and serves as a clock and reset + controller for IP blocks within the chip.[Severity: Low]
Does this help text (and the commit message) accurately describe whatdrivers/soc/toshiba/tc9564-syscon.cimplements?
Generally, I think it does. It talks about clock and reset, which are presented as provided by the system controller, even though the actual drivers for that functionality is implemented separately (and activated with entries in an MFD cell table). The regmap gets created automatically.
Quoted 7 lines
In
tc9564_config_syscon_probe(), the driver only callsdevm_mfd_add_devices()to register the toshiba-tc9564-clock and toshiba-tc9564-reset MFD cells; it does not set up an MMIO regmap (nor doesSOC_TOSHIBA_TC9564_SYSCONselectMFD_SYSCON) or implement the clock and reset controller providers itself. Could the help text and commit description be updated to reflect that this driver instantiates the clock and reset child devices?
It could. I'll plan to add a sentence to this effect when I post version 2 of the series.
Quoted 31 lines
[ ... ]
Quoted 29 lines
drivers/soc/toshiba/tc9564-syscon.c new file +23
-0@@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +#include <linux/device.h> +#include <linux/device-id/of.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/platform_device.h> + +static const struct mfd_cell tc9564_config_syscon_cells[] = { +MFD_CELL_NAME ("toshiba-tc9564-clock" ), +MFD_CELL_NAME ("toshiba-tc9564-reset" ), +}; + +static int tc9564_config_syscon_probe (struct platform_device *pdev) +{ +return devm_mfd_add_devices (&pdev->dev,PLATFORM_DEVID_AUTO , + tc9564_config_syscon_cells, +ARRAY_SIZE (tc9564_config_syscon_cells), +NULL ,0 ,NULL );
Quoted 8 lines
drivers/soc/toshiba/tc9564-syscon.c line 24
Quoted 1 line
drivers/soc/toshiba/tc9564-syscon.c new file +1
-0+}[Severity: Low]
Sincetc9564_config_syscon_probe()indrivers/soc/toshiba/tc9564-syscon.cis purely an MFD driver callingdevm_mfd_add_devices()to register child devices, should this driver be placed underdrivers/mfd/rather thandrivers/soc/toshiba/(with an "mfd: tc9564: ..." commit subject prefix) to follow MFD subsystem placement conventions?
It could be, and that's where I had it originally. I moved it under drivers/soc/toshiba based on a comment from Conor Dooley. Under drivers/soc I find 7 C files that call devm_mfd_add_devices() (although it is true that almost half of the C files under drivers/mfd call that function).
This driver has the same basic--trivial--structure as five other drivers under drivers/soc/*/*.c, so I plan to keep the code where it is.
-Alex
Re: [PATCH 3/4] clk: toshiba: introduce a TC9564 SoC clock driver
In reply to [email protected]Quoted 2 lines · On 11/3/26 6:54 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: tc9564: duplicate clock names across chips due to usingdev->id
I will address this issue by ensuring the name gets formatted using the TC9564 instance number, to ensure the names are unique.
Separately, I'll use PLATFORM_DEVID_NONE rather than PLATFORM_DEVID_AUTO when adding MFD devices. There is only clock and one reset per TC9564 instance.
Quoted 1 line
- [High] clk: tc9564: uninitialized
clk_data->numintc9564_clk_probe()
I didn't realize I couldn't count on devm_kzalloc_flex() to assign the flex array counter in a structure. I will fix this.
Quoted 68 lines
--
commit
d0d52063b982041aca91451199195cd79995784b
Author: Alex Elder <[email protected]>clk: toshiba: introduce a TC9564 SoC clock driver
This commit adds a platform clock driver for the Toshiba TC9564 SoC, registering its PLL, fixed-factor, and gate clocks via a syscon regmap.
Quoted 6 lines
drivers/clk/clk-tc9564.c new file +0
-0@@ -0,0 +1,288 @@[ ... ]
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+/* +* The full name of every clock has a prefix "tc9564" followed by a single +* character ('a', 'b', etc.) that differs for each chip/device number. +* Each clock's "name" defines the unique portion of the clock's full name. +*/ +#define FULL_NAME_SIZE 24/* Enough for formatted full name */ +#define NAME_SIZE 12/* Unique portion of the clock name */ +#define FORMAT_FULL_NAME (_full_name, _id, _name) \ + snprintf(_full_name, FULL_NAME_SIZE, "tc9564%c_%.*s", \ + 'a' + (_id), NAME_SIZE, _name)[ ... ]
Quoted 21 lines
drivers/clk/clk-tc9564.c new file +21
-0+/* Parent is the input oscillator running at 25 MHz; PLL runs at 1250 MHz */ +static struct clk_hw *pll_register (struct device *dev, +const struct clock_init *init) +{ +char full_name[FULL_NAME_SIZE ]; + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + +return devm_clk_hw_register_fixed_factor_index (dev, full_name,0 ,0 , + init->mult,1 ); +} + +/* The PLL is the parent of all fixed clocks */ +static struct clk_hw *fixed_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +char full_name[FULL_NAME_SIZE ]; +struct clk_hw *pll_hw; + +FORMAT_FULL_NAME (full_name, dev->id, init->name);[ ... ]
Quoted 12 lines
drivers/clk/clk-tc9564.c new file +12
-0+static struct clk_hw *gate_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +struct clk_init_data clk_init = { }; +const struct clk_hw *parent_hw; +char full_name[FULL_NAME_SIZE ]; +struct gate_clock *clock; +int ret; + + clock =devm_kzalloc_obj (dev, *clock); +if (!clock)
Quoted 8 lines
drivers/clk/clk-tc9564.c line 203
Quoted 3 lines
drivers/clk/clk-tc9564.c new file +3
-0+return ERR_PTR (-ENOMEM ); + +FORMAT_FULL_NAME (full_name, dev->id, init->name);[Severity: High]
Will passingdev->idtoFORMAT_FULL_NAME()inpll_register(),fixed_register(), andgate_register()cause clock registration to fail with-EEXISTwhen more than one TC9564 device is present?
Maybe. I have no machine (yet) with which to check this.
Quoted 11 lines
The clock MFD cell is registered as a platform device in
tc9564_config_syscon_probe():drivers/soc/toshiba/tc9564-syscon.c:tc9564_config_syscon_probe() { ... return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, tc9564_config_syscon_cells, ARRAY_SIZE(tc9564_config_syscon_cells), NULL, 0, NULL); }
Quoted 6 lines
For platform devices, the platform bus stores the instance ID in
pdev->id(structplatform_device::id), whiledev->id(structdevice::id) is never set and remains 0 for every instance. As a result, every TC9564 device formats its clocks with the "tc9564a_" prefix (such as "tc9564a_PLL"), so probing a second TC9564 device collides in__clk_core_init()when registering its clocks in the global clock namespace.
OK this is something I hadn't taken into account.
My intention is clear, but the code seems not to be doing what I want.
What I really want is for the "a" in "tc9564a_" to correspond to the TC9564 instance number (basically 0 or 1, though some future system could have more).
I will investigate this further and will find a solution that generates the names in the way I intend.
Quoted 5 lines
Note that
pdev->idcannot be passed directly to 'a' + (_id) either, becausePLATFORM_DEVID_AUTOallocates IDs from the system-wideplatform_devid_idashared across all auto-numbered platform devices rather than a 0-based per-chip index.
This actually highlights a different thing that I plan to change in the next version. I think PLATFORM_DEVID_NONE should be used rather than PLATFORM_ID_AUTO when adding the MFD devices, because there is exactly one instance of the clock and one instance of the reset for each TC9564 chip.
And based on my plan to have the "a" represent TC9564 instance 0 and "b" represent TC9564 instance 1, the (correct) statement from Sashiko about it being wrong to use pdev->id this way will be moot.
Quoted 46 lines
Quoted 46 lines
drivers/clk/clk-tc9564.c new file +46
-0+ + parent_hw = tc9564_clock->clk_data->hws[init->parent]; + + clk_init.name = full_name; + clk_init.ops = &gate_clk_ops; + clk_init.parent_hws = &parent_hw; + clk_init.num_parents =1 ; + + clock->hw.init = &clk_init; + clock->init = init; + + ret =devm_clk_hw_register (dev, &clock->hw); +if (ret) +return ERR_PTR (ret); + +return &clock->hw; +} + +static int tc9564_clk_probe (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data; +struct tc9564_clock *tc9564_clock; +struct device *dev = &pdev->dev; +struct device_node *parent_np; +int ret; + + parent_np =dev_of_node (dev->parent); +if (!parent_np) +return dev_err_probe (dev, -EINVAL ,"no devicetree node\n" ); + + tc9564_clock =devm_kzalloc_obj (dev, *tc9564_clock); +if (!tc9564_clock) +return -ENOMEM ; + +/* Note: MMIO regmap (no error checking needed when used) */ + tc9564_clock->regmap =device_node_to_regmap (parent_np); +if (IS_ERR (tc9564_clock->regmap)) +return dev_err_probe (dev,PTR_ERR (tc9564_clock->regmap), +"failed to get config regmap\n" ); + + clk_data =devm_kzalloc_flex (dev, *tc9564_clock->clk_data, hws, +CLOCK_COUNT ); +if (!clk_data) +return -ENOMEM ; + tc9564_clock->clk_data = clk_data; +
Quoted 8 lines
drivers/clk/clk-tc9564.c line 253
Quoted 4 lines
drivers/clk/clk-tc9564.c new file +4
-0+dev_set_drvdata (dev, tc9564_clock); + +/* Initialize all the clocks */ +for (u32 i =0 ; i < clk_data->num; i++) {[Severity: High]
Doesclk_data->numremain 0 intc9564_clk_probe()when building with compilers that do not support__builtin_counted_by_ref?
I did not expect this particular feature to work differently on different compilers.
Quoted 20 lines
devm_kzalloc_flex()populates the__counted_bycounter via__set_flex_counter():
include/linux/compiler_types.h:
#if__has_builtin(__builtin_counted_by_ref)&& \
!defined(CONFIG_CC_HAS_BROKEN_COUNTED_BY_REF)
#define__flex_counter(FAM)__builtin_counted_by_ref(FAM)
#else
#define__flex_counter(FAM)((void *)NULL)
#endif
include/linux/overflow.h:
#define__set_flex_counter(FAM, COUNT)\({ \ *_Generic(__flex_counter(FAM), \ void *: &(size_t){ 0 }, \ default: __flex_counter(FAM)) = (COUNT); \ })
Quoted 6 lines
On compilers without a working
__builtin_counted_by_ref(such as GCC < 15.1 or Clang < 22.1),__set_flex_counter()writes COUNT into a temporary compound literal and leavesclk_data->numas 0. Without an explicitclk_data->num=CLOCK_COUNTassignment, the loop intc9564_clk_probe()registers zero clocks andof_clk_hw_onecell_get()rejects all clock lookups with-EINVAL.
Given this report, I will assign the counted-by field after allocation.
-Alex
Re: [PATCH 4/4] reset: toshiba: introduce a TC9564 SoC reset driver
In reply to Philipp ZabelQuoted 48 lines · Philipp Zabel
Quoted 47 lines · Alex Elder
Define a new platform driver that manages reset signals implemented by the Toshiba TC9564 SoC. There are 13 reset signals available, but currently only the resets that are (or will soon be) used are defined to be controllable.
Two registers manage the state of the resets. The registers are accessed via a regmap supplied by a system controller. Access to the memory region is provided via a BAR on a PCIe endpoint function embedded in the TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 7 ++ drivers/reset/Kconfig | 12 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-tc9564.c | 135 +++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+)create mode 100644
drivers/reset/reset-tc9564.cMAINTAINERS +7
-0@@ -28355,6 +28355,13 @@ F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.ya F: drivers/soc/toshiba/tc9564-syscon.c F: include/dt-bindings/soc/toshiba,tc9564.h +TOSHIBA TC9564 RESET DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: drivers/reset/reset-tc9564.c + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]drivers/reset/Kconfig +0
-0@@ -358,6 +358,18 @@ config RESET_SUNXI help This enables the reset driver for Allwinner SoCs.
Quoted 14 lines
drivers/reset/Kconfig config RESET_SUNXI · line 371
Quoted 11 lines
drivers/reset/Kconfig +11
-0+config RESET_TC9564 + tristate "Toshiba TC9564 reset support" + depends on SOC_TOSHIBA_TC9564_SYSCON + select MFD_SYSCON + default SOC_TOSHIBA_TC9564_SYSCON + help + This enables support for the reset controller embedded in the + Toshiba TC9564 SoC. The state of reset lines is controlled + via MMIO to a region managed by a system controller; this + ensures access to the region is coordinated between this and + the clock and XGMAC (stmmac) drivers.Drop the second sentence, explaining driver details to a user that just needs to decide whether to enable the driver or not is not helpful.
OK. I think I originally had something to the effect of using a regmap to ensure multiple drivers could access the space safely. Then someone asked "which drivers" so I was more explicit.
Anyway, I'll just drop the sentence, as you suggest. I will also drop a similar sentence in the clock Kconfig file description for the COMMON_CLK_TC9564 option.
Quoted 33 lines
Quoted 21 lines
drivers/reset/Kconfig +0
-0config RESET_TENSTORRENT_ATLANTIS tristate "Tenstorrent atlantis reset driver" depends on ARCH_TENSTORRENT || COMPILE_TESTdrivers/reset/Makefile +1
-0@@ -45,6 +45,7 @@ obj-$(CONFIG_RESET_SKY1_AUDSS) += reset-sky1-audss.o obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o +obj-$(CONFIG_RESET_TC9564) += reset-tc9564.o obj-$(CONFIG_RESET_TENSTORRENT_ATLANTIS) += reset-tenstorrent-atlantis.o obj-$(CONFIG_RESET_TH1520) += reset-th1520.o obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.odrivers/reset/reset-tc9564.c new file +0
-0@@ -0,0 +1,135 @@[...]
drivers/reset/reset-tc9564.c line 52
Quoted 8 lines
drivers/reset/reset-tc9564.c new file +8
-0+static void reset_manage (struct reset_controller_dev *rcdev, +unsigned long id,bool assert) +{ +const struct tc9564_reset *reset = &tc9564_reset[id]; +struct regmap *regmap =dev_get_drvdata (rcdev->dev); +u32 mask = reset->mask; + +regmap_update_bits (regmap, reset->offset, mask, assert ? mask :0 );Just propagating the error value ...
Quoted 9 lines
drivers/reset/reset-tc9564.c line 59
Quoted 7 lines
drivers/reset/reset-tc9564.c new file +7
-0+} + +static int reset_assert (struct reset_controller_dev *rcdev,unsigned long id) +{ +reset_manage (rcdev, id, true); + +return 0 ;... makes this even shorter.
Yes I see what you mean. Just because we don't *have to* check for errors doesn't mean we must ignore the return value.
Quoted 13 lines
Quoted 13 lines
drivers/reset/reset-tc9564.c new file +12
-0+} + +static int reset_deassert (struct reset_controller_dev *rcdev,unsigned long id) +{ +reset_manage (rcdev, id, false); + +return 0 ; +} + +static int reset_status (struct reset_controller_dev *rcdev,unsigned long id) +{ +const struct tc9564_reset *reset = &tc9564_reset[id];
Quoted 8 lines
drivers/reset/reset-tc9564.c line 77
Quoted 6 lines
drivers/reset/reset-tc9564.c new file +6
-0+struct regmap *regmap =dev_get_drvdata (rcdev->dev); +u32 val; + +regmap_read (regmap, reset->offset, &val); + +return val & reset->mask ?1 :0 ;Consider using
regmap_test_bits()here.
I will.
Quoted 15 lines
Quoted 15 lines
drivers/reset/reset-tc9564.c new file +15
-0+} + +static const struct reset_control_ops reset_control_ops = { + .assert = reset_assert, + .deassert = reset_deassert, + .status = reset_status, +}; + +static int tc9564_reset_probe (struct platform_device *pdev) +{ +struct reset_controller_dev *rcdev; +struct device *dev = &pdev->dev; +struct device_node *parent_np; +struct regmap *regmap; +int ret;
Quoted 8 lines
drivers/reset/reset-tc9564.c line 98
Quoted 6 lines
drivers/reset/reset-tc9564.c new file +6
-0+ + parent_np =dev_of_node (dev->parent); +if (!parent_np) +return dev_err_probe (dev, -EINVAL ,"no devicetree node\n" ); + +/* Note: MMIO regmap (no error checking needed when used) */ I suggest you just add the unneeded error checks and drop this comment.
Yup, agreed.
Quoted 3 lines
drivers/reset/reset-tc9564.c line 99
Quoted 1 line
drivers/reset/reset-tc9564.c new file +1
-0+ regmap =device_node_to_regmap (parent_np);Can't you just use "
dev_get_regmap(dev->parent, NULL)" ?
I just tried what you suggest, and it returns a null pointer rather than the desired regmap.
device_node_to_regmap() searches the syscon_list for an entry that has the provided node pointer, and if found, returns that system controller's regmap. That does find a syscon, and returns its regmap.
of_syscon_register() seems to create a syscon but does *not* register any device resources (devres) on any device.
So I think when dev_get_regmap() simply scans the parent device for the latest regmap resource, it finds none.
I'm happy to discuss this further, but for now I will not be switching over to dev_get_regmap().
Thank you for the quick review.
-Alex
Quoted 2 lines
regards
Philipp
Re: [PATCH 1/4] dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
In reply to Alex Elderpw-bot: not-applicable
Re: [PATCH 1/4] dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
In reply to Alex ElderQuoted 2 lines · Alex Elder
Define the binding for the system controller that implements the clock and reset controller functionality present in the Toshiba TC9564 SoC.
Actually, can you mention the other features that this provides - the service it provides to the mac, for example.
Cheers,
Conor.
Quoted 160 lines
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++++++++++++++++ MAINTAINERS | 8 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml create mode 100644 include/dt-bindings/soc/toshiba,tc9564.hDocumentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +68
-0@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/toshiba/toshiba,tc9564-config-syscon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 Multifunction System 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 switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals via its BARs. These peripherals include a simple + controller to gate internal clocks, as well as a reset controller. + + The clock controller uses registers within the same page as a reset + controller, so this system controller controls access to both. + + A total of 21 simple gated clocks are implemented within the SoC. + At this time, support for enabling and disabling only a subset of + them is provided at this time. Similarly, the SoC implements 13 + resets, but currently not all of them can be controlled. + +properties: + compatible: + items: + - const: toshiba,tc9564-config-syscon + - const: syscon + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + "#clock-cells": + const: 1 + description: + Clock ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + + "#reset-cells": + const: 1 + description: + Reset ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + +required: + - compatible + - reg + - clocks + - "#clock-cells" + - "#reset-cells" + +additionalProperties: false + +examples: + - | + syscon@0 { + compatible = "toshiba,tc9564-config-syscon", "syscon"; + reg = <0x0 0x2000>; + clocks = <&tc9564_xo_board>; + #clock-cells = <1>; + #reset-cells = <1>; + };MAINTAINERS +8
-0@@ -28339,6 +28339,14 @@ S: Maintained F: Documentation/devicetree/bindings/misc/pci1179,0220.yaml F: drivers/misc/tc9564-pci.c +TOSHIBA TC9564 SYSTEM CONTROLLER DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml +F: include/dt-bindings/soc/toshiba,tc9564.h + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]include/dt-bindings/soc/toshiba,tc9564.h new file +46
-0@@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +#ifndef __SOC_TOSHIBA_TC9564_H__ +#define __SOC_TOSHIBA_TC9564_H__ + +/* Clock IDs */ + +#define CLOCK_PLL 0 + +#define CLOCK_62_5M 1 +#define CLOCK_125M 2 +#define CLOCK_250M 3 +#define CLOCK_312_5M 4 + +#define CLOCK_MSIGEN 5 + +#define CLOCK_MAC0_TX 6 +#define CLOCK_MAC0_RX 7 +#define CLOCK_MAC0_125M 8 +#define CLOCK_MAC0_312_5M 9 +#define CLOCK_MAC0_ALL 10 + +#define CLOCK_MAC1_TX 11 +#define CLOCK_MAC1_RX 12 +#define CLOCK_MAC1_125M 13 +#define CLOCK_MAC1_312_5M 14 +#define CLOCK_MAC1_ALL 15 +#define CLOCK_MAC1_RMII 16 + +/* Reset IDs */ + +#define RESET_MSIGEN 0 + +#define RESET_MAC0_MAC 1 +#define RESET_MAC0_PMA 2 +#define RESET_MAC0_XPCS 3 + +#define RESET_MAC1_MAC 4 +#define RESET_MAC1_PMA 5 +#define RESET_MAC1_XPCS 6 + +#endif /* __SOC_TOSHIBA_TC9564_H__*/ Signature · 1 line
2.53.0
Re: [PATCH 1/4] dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
Quoted 2 lines · Conor Dooley
Actually, can you mention the other features that this provides - the service it provides to the mac, for example.
Yes I will add that in the next version of the series. Thank you.
-Alex
Re: [PATCH 1/4] dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
In reply to Alex ElderQuoted 73 lines · Alex Elder
Define the binding for the system controller that implements the clock and reset controller functionality present in the Toshiba TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++++++++++++++++ MAINTAINERS | 8 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml create mode 100644 include/dt-bindings/soc/toshiba,tc9564.hDocumentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +53
-0@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/toshiba/toshiba,tc9564-config-syscon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 Multifunction System 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 switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals via its BARs. These peripherals include a simple + controller to gate internal clocks, as well as a reset controller. + + The clock controller uses registers within the same page as a reset + controller, so this system controller controls access to both. + + A total of 21 simple gated clocks are implemented within the SoC. + At this time, support for enabling and disabling only a subset of + them is provided at this time. Similarly, the SoC implements 13 + resets, but currently not all of them can be controlled. + +properties: + compatible: + items: + - const: toshiba,tc9564-config-syscon + - const: syscon + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + "#clock-cells": + const: 1 + description: + Clock ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + + "#reset-cells": + const: 1 + description: + Reset ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + +required: + - compatible + - reg
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml line 63
Quoted 10 lines
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +10
-0+ - clocks + - "#clock-cells" + - "#reset-cells" + +additionalProperties: false + +examples: + - | + syscon@0 { + compatible = "toshiba,tc9564-config-syscon", "syscon";
I disagree this to be syscon.
This is internal to the PCI device. I read Daniel Thompson answer:
https://lore.kernel.org/all/[email protected]/
And I accept arguments that you want to re-use a lot of existing bindings like DWMAC and so on. Syscon does not count there.
I remember you posted somewhere full DTS, but now I could not find it again and I do not see it in the cover letter here.
So again, why does it have to be a syscon, which is pure internal-register-access thingy?
Best regards,
Krzysztof
Quoted 12 lines · Alex Elder
This series is comprised of some code that was previously sent separately. It now incorporates a new system controller driver that advertises clock and reset functionality, as well as regmap access to its address range. This combination is being treated as a new series. (Details of previous versions are below.)
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.
Quoted 3 lines
The system controller driver adds the clock and reset devices using the
mfd_add_devices()interface. The clocks and resets are implemented by drivers included in this series.
Toshiba TC9564 bindings and DTS should be posted completely. We spent great amount of time on discussing already and I pointed more than once that big picture is missing.
You are not describing here parts of a SoC.
You are describing one, single device how the host sees it and DT maintainers (and writing bindings) ask for complete picture in such cases.
Best regards,
Krzysztof
Quoted 21 lines · Krzysztof Kozlowski
Quoted 12 lines · Alex Elder
This series is comprised of some code that was previously sent separately. It now incorporates a new system controller driver that advertises clock and reset functionality, as well as regmap access to its address range. This combination is being treated as a new series. (Details of previous versions are below.)
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.
Quoted 3 lines
The system controller driver adds the clock and reset devices using the
mfd_add_devices()interface. The clocks and resets are implemented by drivers included in this series.Toshiba TC9564 bindings and DTS should be posted completely. We spent great amount of time on discussing already and I pointed more than once that big picture is missing.
Quoted 7 lines
You are not describing here parts of a SoC.
You are describing one, single device how the host sees it and DT maintainers (and writing bindings) ask for complete picture in such cases.
Best regards,
Krzysztof
https://github.com/riscstar/linux/blob/tc9564-dts/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
Re: [PATCH 1/4] dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
In reply to Krzysztof KozlowskiQuoted 78 lines · Krzysztof Kozlowski
Quoted 77 lines · Alex Elder
Define the binding for the system controller that implements the clock and reset controller functionality present in the Toshiba TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++++++++++++++++ MAINTAINERS | 8 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++++++++++++ 3 files changed, 122 insertions(+)create mode 100644
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yamlcreate mode 100644include/dt-bindings/soc/toshiba,tc9564.hDocumentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +57
-0@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/toshiba/toshiba,tc9564-config-syscon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC9564 Multifunction System 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 switch + includes an embedded PCIe endpoint that provides access to various + SoC peripherals via its BARs. These peripherals include a simple + controller to gate internal clocks, as well as a reset controller. + + The clock controller uses registers within the same page as a reset + controller, so this system controller controls access to both. + + A total of 21 simple gated clocks are implemented within the SoC. + At this time, support for enabling and disabling only a subset of + them is provided at this time. Similarly, the SoC implements 13 + resets, but currently not all of them can be controlled. + +properties: + compatible: + items: + - const: toshiba,tc9564-config-syscon + - const: syscon + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + "#clock-cells": + const: 1 + description: + Clock ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + + "#reset-cells": + const: 1 + description: + Reset ids are defined in <include/dt-bindings/soc/toshiba,tc9564.h> + +required: + - compatible + - reg + - clocks + - "#clock-cells" + - "#reset-cells" +
Quoted 8 lines
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml line 63
Quoted 6 lines
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +6
-0+additionalProperties: false + +examples: + - | + syscon@0 { + compatible = "toshiba,tc9564-config-syscon", "syscon";I disagree this to be syscon.
Conor Ack'd this patch, and then followed up asking me to mention the other feature it provides, which I agreed to do. It is an important third use of the memory region.
https://lore.kernel.org/lkml/20261105-irregular-awaken-b329b9c37e70@spud/
In addition to the registers that control these clocks and resets, this address range contains two registers (one per PCI function) that indicate when a DWMAC hardware initialization step is complete. The nodes representing those Ethernet MACs refer to this syscon with a phandle property (and offset).
Is that additional use enough to warrant defining this as a syscon? I.e., with that third use, does this no longer represent a "pure internal-register-access thingy?
Quoted 7 lines
This is internal to the PCI device. I read Daniel Thompson answer:
https://lore.kernel.org/all/[email protected]/
And I accept arguments that you want to re-use a lot of existing bindings like DWMAC and so on. Syscon does not count there.I remember you posted somewhere full DTS, but now I could not find it again and I do not see it in the cover letter here.
I should have included it, and will include this in future messages. I squashed together the DTS commits into a single complete DTS that we are testing with, here:
https://github.com/riscstar/linux/blob/tc9564-dts/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
I'll also respond to your other message.
-Alex
Quoted 6 lines
So again, why does it have to be a syscon, which is pure internal-register-access thingy?
Best regards,
Krzysztof
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Alex Elder
This series is comprised of some code that was previously sent separately. It now incorporates a new system controller driver that advertises clock and reset functionality, as well as regmap access to its address range. This combination is being treated as a new series. (Details of previous versions are below.)
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.
Quoted 7 lines
Quoted 3 lines
The system controller driver adds the clock and reset devices using the
mfd_add_devices()interface. The clocks and resets are implemented by drivers included in this series.Toshiba TC9564 bindings and DTS should be posted completely. We spent great amount of time on discussing already and I pointed more than once that big picture is missing.
https://github.com/riscstar/linux/blob/tc9564-dts/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
Node pcie@3,0 is the third switch port (within the TC9564), which has an embedded PCIe endpoint with two functions. (You can ignore pci-ep-bus@0 for now.)
Quoted 4 lines
You are not describing here parts of a SoC.
You are describing one, single device how the host sees it and DT maintainers (and writing bindings) ask for complete picture in such cases.
I'm glad to provide whatever information you need. There is more than one way to provide the "complete picture" however, and I don't want to send something that isn't helpful.
If you want something different from just the DTS file linked above, please say so and I'll put something together.
For example:
- Would you prefer something that includes only the PCI hierarchy starting at the TC9564 embedded PCI endpoint and its two functions?
- Is a DTS file sufficient, or do you want the TC9564 bindings instead?
- Do you want any other high-level description of the chip?
- Do you want more information about the system that contains the chip?
Thank you.
-Alex
Quoted 2 lines
Best regards,
Krzysztof
Re: [PATCH 2/4] soc: toshiba: tc9564: add a new syscon driver
In reply to Alex ElderQuoted 27 lines · Alex Elder
Introduce a new system controller driver for devices found within the Toshiba TC9564 SoC. The system controller manages access to an 8 KB region, and implements controllers for a set of clocks as well as a set of resets. The region also includes registers that indicate when initialization is done for the chip's two Ethernet interfaces.
The SoC has a single 25 MHz input clock, and from that derives clocks of various rates used by functional blocks within the chip.
Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 1 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/toshiba/Kconfig | 12 +++++++++ drivers/soc/toshiba/Makefile | 3 +++ drivers/soc/toshiba/tc9564-syscon.c | 42 +++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+) create mode 100644 drivers/soc/toshiba/Kconfig create mode 100644 drivers/soc/toshiba/Makefile create mode 100644 drivers/soc/toshiba/tc9564-syscon.cMAINTAINERS +0
-0
MAINTAINERS M: Alex Elder <[email protected]> · line 28348
Quoted 4 lines
MAINTAINERS +1
-0@@ -28345,6 +28345,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml +F: drivers/soc/toshiba/tc9564-syscon.c
No, this has to stop. There IS NO TOSHIBA SOC here, how we understand SoC.
drivers/soc/ are ONLY for SoCs running Linux, not for regular devices, which you are describing here. You have standard PCI device, not drivers/soc/
And if this was Toshiba SoC, you did not even Cc Toshiba maintainer.
Best regards,
Krzysztof
Quoted 33 lines · Alex Elder
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Alex Elder
This series is comprised of some code that was previously sent separately. It now incorporates a new system controller driver that advertises clock and reset functionality, as well as regmap access to its address range. This combination is being treated as a new series. (Details of previous versions are below.)
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.
Quoted 7 lines
Quoted 3 lines
The system controller driver adds the clock and reset devices using the
mfd_add_devices()interface. The clocks and resets are implemented by drivers included in this series.Toshiba TC9564 bindings and DTS should be posted completely. We spent great amount of time on discussing already and I pointed more than once that big picture is missing.
https://github.com/riscstar/linux/blob/tc9564-dts/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
Node pcie@3,0 is the third switch port (within the TC9564), which has an embedded PCIe endpoint with two functions. (You can ignore pci-ep-bus@0 for now.)
Quoted 4 lines
You are not describing here parts of a SoC.
You are describing one, single device how the host sees it and DT maintainers (and writing bindings) ask for complete picture in such cases.
Quoted 6 lines
I'm glad to provide whatever information you need. There is more than one way to provide the "complete picture" however, and I don't want to send something that isn't helpful.
If you want something different from just the DTS file linked above, please say so and I'll put something together.
The DTS was enough and it shows that you described internals of the device. I keep my claim, that is not correct representation because it is too detailed and too complicated.
Nothing related to the syscon should be represented in DT, because these are internal registers handled by the device itself. DT does not describe internals of the devices, but how the device is being represented for the host.
And Rob Herring already expressed that, if I understand correctly:
https://lore.kernel.org/lkml/[email protected]/
"And really, a DT node for them should be completely optional (unless there's some power on ctrl needed)."
"Everything else like SPI, GPIO, UART, etc. should be under the PCIe switch upstream node in a pci-ep-bus."
You don't get multiple syscons and other internal routing elements.
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
In reply to Alex ElderDocumentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml
Quoted 19 lines · Alex Elder
Define the binding for the system controller that implements the clock and reset controller functionality present in the Toshiba TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++++++++++++++++ MAINTAINERS | 8 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml create mode 100644 include/dt-bindings/soc/toshiba,tc9564.hDocumentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yaml new file +0
-0
Additionally, if this binding somehow goes further, this cannot go to soc directory. This is not a SoC in this context and "soc" directory is not a dumping ground for things you don't know where to put.
...
include/dt-bindings/soc/toshiba,tc9564.h
Quoted 8 lines
TOSHIBA WMI HOTKEYS DRIVER
M: Azael Avalos <[email protected]>
L: [email protected]include/dt-bindings/soc/toshiba,tc9564.h new file +0
-0
Neither this. If you have clock controller, then header goes to clock. Soc directory is ONLY for a very small subset of SoC driver ABI, which you do not have here.
include/dt-bindings/soc/toshiba,tc9564.h line 2
Quoted 3 lines
include/dt-bindings/soc/toshiba,tc9564.h new file +2
-0@@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +
Best regards,
Krzysztof
Re: [PATCH 3/4] clk: toshiba: introduce a TC9564 SoC clock driver
In reply to Alex ElderQuoted 44 lines
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.
Two registers manage the state of the clocks. The registers are accessed via a regmap supplied by a system controller. Access to the memory region is provided via a BAR on a PCIe endpoint function embedded in the TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 7 + drivers/clk/Kconfig | 12 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 288 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 308 insertions(+) create mode 100644 drivers/clk/clk-tc9564.cMAINTAINERS +7
-0@@ -28332,6 +28332,13 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC9564 CLOCK DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: drivers/clk/clk-tc9564.c + TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]>drivers/clk/Kconfig +0
-0
drivers/clk/Kconfig config COMMON_CLK_S2MPS11 · line 298
Quoted 6 lines
drivers/clk/Kconfig +3
-0@@ -293,6 +293,18 @@ config COMMON_CLK_S2MPS11 clock. These multi-function devices have two (S2MPS14) or three (S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each. +config COMMON_CLK_TC9564 + tristate "Toshiba TC9564 clock support" + depends on SOC_TOSHIBA_TC9564_SYSCON
You agreed to add COMPILE_TEST on v3 but it is still missing now.
If have a good reason to ignore or disregard something we agreed on, it should be clearly flagged.
drivers/clk/Kconfig config COMMON_CLK_S2MPS11 · line 306
Quoted 8 lines
drivers/clk/Kconfig +8
-0+ select MFD_SYSCON + default SOC_TOSHIBA_TC9564_SYSCON + help + This enables support for the clock controller embedded in the + Toshiba TC9564 SoC. The state of each clock is controlled via + MMIO to a region managed by a system controller; this ensures + access to the region is coordinated between this and the reset + and XGMAC (stmmac) drivers.
As Philipp said, the 2nd part of description is not appropriate as a config description.
Quoted 22 lines
drivers/clk/Kconfig +1
-0+ config CLK_TWL tristate "Clock driver for the TWL PMIC family" depends on TWL4030_COREdrivers/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.odrivers/clk/clk-tc9564.c new file +0
-0
drivers/clk/clk-tc9564.c line 8
Quoted 8 lines
drivers/clk/clk-tc9564.c new file +8
-0@@ -0,0 +1,288 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +#include <linux/bits.h> +#include <linux/clk.h>
Not needed, this driver does not use the consumer API.
Quoted 8 lines
drivers/clk/clk-tc9564.c new file +8
-0+#include <linux/clk-provider.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#include <dt-bindings/soc/toshiba,tc9564.h> +
drivers/clk/clk-tc9564.c line 26
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+/* +* The full name of every clock has a prefix "tc9564" followed by a single +* character ('a', 'b', etc.) that differs for each chip/device number. +* Each clock's "name" defines the unique portion of the clock's full name. +*/ +#define FULL_NAME_SIZE 24/* Enough for formatted full name */ +#define NAME_SIZE 12/* Unique portion of the clock name */ +#define FORMAT_FULL_NAME (_full_name, _id, _name) \ + snprintf(_full_name, FULL_NAME_SIZE, "tc9564%c_%.*s", \ + 'a' + (_id), NAME_SIZE, _name)
dev->id will always be zero coming from a platform driver and this code is a lot of churn hidden in a macro. If you must factorize this (I don't think you do) make it a function
something like snprintf(name, sizeof(name), "%s-%s", dev_name(dev), init->name) should be enough. use kasprintf if you can't predict the size.
Quoted 9 lines
drivers/clk/clk-tc9564.c new file +9
-0+ +/* Two registers control whether gate clocks are enabled */ +#define CLK_CTRL0_OFFSET 0x1004/* Common and MAC0 gate clocks */ +#define CLK_CTRL1_OFFSET 0x100c/* MAC1 gate clocks */ + +enum clock_type {PLL ,FIXED ,GATE }; + +struct tc9564_clock { +struct regmap *regmap;
drivers/clk/clk-tc9564.c line 45
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+struct clk_hw_onecell_data *clk_data; +}; + +struct gate_clock { +struct clk_hw hw; +const struct clock_init *init; +}; + +struct clock_init { +const char name[NAME_SIZE ];
just const char *name ... you are asking for trouble with this.
Quoted 22 lines
drivers/clk/clk-tc9564.c new file +22
-0+enum clock_type type; +union { +u32 mult;/* PLL rate multiplier */ + +u32 div;/* Fixed rate clock divider */ + +struct {/* Gate clock */ +u16 parent;/* Parent clock ID, e.g. CLOCK_50M */ +u16 offset;/* CLK_CTRL0_OFFSET/CLK_CTRL1_OFFSET */ +u32 mask; + }; + }; +}; + +/* There is only one PLL */ +#define PLL_INIT (_name, _mult) \ + [CLOCK_##_name] = { \ + .name = #_name, \ + .type = PLL, \ + .mult = (_mult), \ + } +
drivers/clk/clk-tc9564.c line 77
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+/* The PLL is the parent of all the fixed rate clocks */ +#define FIXED_INIT (_name, _div) \ + [CLOCK_##_name] = { \ + .name = #_name, \ + .type = FIXED, \ + .div = (_div), \ + } + +#define GATE_INIT0 (_name, _bit, _pname) __GATE_INIT(_name, 0, _bit, _pname) +#define GATE_INIT1 (_name, _bit, _pname) __GATE_INIT(_name, 1, _bit, _pname)
So you are writing the param in the name ? what is the point of that ?
Quoted 7 lines
drivers/clk/clk-tc9564.c new file +7
-0+#define __GATE_INIT (_name, _reg, _bit, _pname) \ + [CLOCK_##_name] = { \ + .name = #_name, \ + .type = GATE, \ + .parent = CLOCK_##_pname, \ + .offset = CLK_CTRL ## _reg ## _OFFSET, \ + .mask = BIT(_bit), \
drivers/clk/clk-tc9564.c line 94
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+ } + +/* +* Clocks are initialized and registered in the order of their IDs. +* Parent clocks must be registered before their children. +*/ +static const struct clock_init clock_init[] = { +PLL_INIT (PLL ,50 ), + + FIXED_INIT(62_5M, 20),
Just pass literals here, and show it the table. you can then pass real name, not 125M which is very much tied to your ids.
Quoted 9 lines
drivers/clk/clk-tc9564.c new file +9
-0+ FIXED_INIT(125M, 10), + FIXED_INIT(250M, 5), + FIXED_INIT(312_5M, 4), + + GATE_INIT0(MSIGEN, 18, 62_5M), + + GATE_INIT0(MAC0_TX, 7, 250M), + GATE_INIT0(MAC0_RX, 14, 250M), + GATE_INIT0(MAC0_125M, 29, 125M),
drivers/clk/clk-tc9564.c line 113
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+ GATE_INIT0(MAC0_312_5M, 30, 312_5M), + GATE_INIT0(MAC0_ALL, 31, 250M), + + GATE_INIT1(MAC1_TX, 7, 250M), + GATE_INIT1(MAC1_RX, 14, 250M), + GATE_INIT1(MAC1_125M, 29, 125M), + GATE_INIT1(MAC1_312_5M, 30, 312_5M), + GATE_INIT1(MAC1_ALL, 31, 250M), + GATE_INIT1(MAC1_RMII, 15, 125M), +};
Could you explain why clock PCIe and I2C that where critical
in the previous version have been left out ? they are not critical anymore ?
Quoted 34 lines
drivers/clk/clk-tc9564.c new file +34
-0+#define CLOCK_COUNT ARRAY_SIZE(clock_init) + +/* Parent is the input oscillator running at 25 MHz; PLL runs at 1250 MHz */ +static struct clk_hw *pll_register (struct device *dev, +const struct clock_init *init) +{ +char full_name[FULL_NAME_SIZE ]; + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + +return devm_clk_hw_register_fixed_factor_index (dev, full_name,0 ,0 , + init->mult,1 ); +} + +/* The PLL is the parent of all fixed clocks */ +static struct clk_hw *fixed_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +char full_name[FULL_NAME_SIZE ]; +struct clk_hw *pll_hw; + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + + pll_hw = tc9564_clock->clk_data->hws[CLOCK_PLL ]; + +return devm_clk_hw_register_fixed_factor_parent_hw (dev, full_name, + pll_hw,0 , +1 , init->div); +} + +static const struct gate_clock *hw_to_gate_clock (struct clk_hw *hw) +{ + return container_of_const(hw, struct gate_clock, hw);
drivers/clk/clk-tc9564.c line 157
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+} + +static void gate_clk_manage (struct clk_hw *hw,bool enable) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (clk_hw_get_dev (hw)); +const struct gate_clock *clock =hw_to_gate_clock (hw); +u32 mask = clock->init->mask; + +regmap_update_bits (tc9564_clock->regmap, clock->init->offset, mask, + enable ? mask :0 );
how about returning the error if any ?
Quoted 11 lines
drivers/clk/clk-tc9564.c new file +11
-0+} + +static int gate_clk_enable (struct clk_hw *hw) +{ +gate_clk_manage (hw, true); + +return 0 ; +} + +static void gate_clk_disable (struct clk_hw *hw) +{
drivers/clk/clk-tc9564.c line 178
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+gate_clk_manage (hw, false); +} + +static int gate_clk_is_enabled (struct clk_hw *hw) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (clk_hw_get_dev (hw)); +const struct gate_clock *clock =hw_to_gate_clock (hw); +u32 val; + +regmap_read (tc9564_clock->regmap, clock->init->offset, &val);
here too
drivers/clk/clk-tc9564.c line 180
Quoted 2 lines
drivers/clk/clk-tc9564.c new file +2
-0+ +return val & clock->init->mask ?1 :0 ;
you might be using val uninitialised here.
Quoted 52 lines
drivers/clk/clk-tc9564.c new file +52
-0+} + +static const struct clk_ops gate_clk_ops = { + .enable = gate_clk_enable, + .disable = gate_clk_disable, + .is_enabled = gate_clk_is_enabled, +}; + +static struct clk_hw *gate_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +struct clk_init_data clk_init = { }; +const struct clk_hw *parent_hw; +char full_name[FULL_NAME_SIZE ]; +struct gate_clock *clock; +int ret; + + clock =devm_kzalloc_obj (dev, *clock); +if (!clock) +return ERR_PTR (-ENOMEM ); + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + + parent_hw = tc9564_clock->clk_data->hws[init->parent]; + + clk_init.name = full_name; + clk_init.ops = &gate_clk_ops; + clk_init.parent_hws = &parent_hw; + clk_init.num_parents =1 ; + + clock->hw.init = &clk_init; + clock->init = init; + + ret =devm_clk_hw_register (dev, &clock->hw); +if (ret) +return ERR_PTR (ret); + +return &clock->hw; +} + +static int tc9564_clk_probe (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data; +struct tc9564_clock *tc9564_clock; +struct device *dev = &pdev->dev; +struct device_node *parent_np; +int ret; + + parent_np =dev_of_node (dev->parent); +if (!parent_np) +return dev_err_probe (dev, -EINVAL ,"no devicetree node\n" );
drivers/clk/clk-tc9564.c line 242
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+ + tc9564_clock =devm_kzalloc_obj (dev, *tc9564_clock); +if (!tc9564_clock) +return -ENOMEM ; + +/* Note: MMIO regmap (no error checking needed when used) */ + tc9564_clock->regmap =device_node_to_regmap (parent_np); +if (IS_ERR (tc9564_clock->regmap)) +return dev_err_probe (dev,PTR_ERR (tc9564_clock->regmap), +"failed to get config regmap\n" );
If the parent registers the regmap you can get it with dev_get_regmap(dev->parent, NULL) with no syscon dep.
Signature · 1 line
Jerome
Re: [PATCH 3/4] clk: toshiba: introduce a TC9564 SoC clock driver
Quoted 5 lines · Jerome Brunet
Quoted 5 lines
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.
Quoted 8 lines
Quoted 8 lines
Two registers manage the state of the clocks. The registers are accessed via a regmap supplied by a system controller. Access to the memory region is provided via a BAR on a PCIe endpoint function embedded in the TC9564 SoC.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>
Sorry for the delayed response.
Quoted 34 lines
Quoted 34 lines
--- MAINTAINERS | 7 + drivers/clk/Kconfig | 12 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 288 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 308 insertions(+)create mode 100644
drivers/clk/clk-tc9564.cMAINTAINERS +7
-0@@ -28332,6 +28332,13 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.yaml F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC9564 CLOCK DRIVER +M: Lorenzo Bianconi <[email protected]> +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: drivers/clk/clk-tc9564.c + TOSHIBA TC9564 PCI DRIVER M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]>drivers/clk/Kconfig +0
-0@@ -293,6 +293,18 @@ config COMMON_CLK_S2MPS11 clock. These multi-function devices have two (S2MPS14) or three (S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each.
Quoted 5 lines
drivers/clk/Kconfig config COMMON_CLK_S2MPS11 · line 298
Quoted 3 lines
drivers/clk/Kconfig +3
-0+config COMMON_CLK_TC9564 + tristate "Toshiba TC9564 clock support" + depends on SOC_TOSHIBA_TC9564_SYSCONYou agreed to add
COMPILE_TESTon v3 but it is still missing now.
Yes I did agree to that, and I'm sorry I didn't mention that it had not been done yet. I have now done some additional testing with cross-compiling a few other architectures and have more confidence "COMPILE_TEST" will work correctly. This will be included in the next version of this code. (Really!)
Quoted 14 lines
If have a good reason to ignore or disregard something we agreed on, it should be clearly flagged.
drivers/clk/Kconfig config COMMON_CLK_S2MPS11 · line 306
Quoted 8 lines
drivers/clk/Kconfig +8
-0+ select MFD_SYSCON + default SOC_TOSHIBA_TC9564_SYSCON + help + This enables support for the clock controller embedded in the + Toshiba TC9564 SoC. The state of each clock is controlled via + MMIO to a region managed by a system controller; this ensures + access to the region is coordinated between this and the reset + and XGMAC (stmmac) drivers.As Philipp said, the 2nd part of description is not appropriate as a config description.
I will simplify this help text.
Quoted 25 lines
Quoted 25 lines
drivers/clk/Kconfig +1
-0+ config CLK_TWL tristate "Clock driver for the TWL PMIC family" depends on TWL4030_COREdrivers/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.odrivers/clk/clk-tc9564.c new file +2
-0@@ -0,0 +1,288 @@ +// SPDX-License-Identifier: GPL-2.0-only +
Quoted 8 lines
drivers/clk/clk-tc9564.c line 8
Quoted 6 lines
drivers/clk/clk-tc9564.c new file +6
-0+/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +#include <linux/bits.h> +#include <linux/clk.h> Not needed, this driver does not use the consumer API.
OK.
Quoted 14 lines
Quoted 14 lines
drivers/clk/clk-tc9564.c new file +13
-0+#include <linux/clk-provider.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#include <dt-bindings/soc/toshiba,tc9564.h> + +/* +* The full name of every clock has a prefix "tc9564" followed by a single +* character ('a', 'b', etc.) that differs for each chip/device number. +* Each clock's "name" defines the unique portion of the clock's full name. +*/
Quoted 8 lines
drivers/clk/clk-tc9564.c line 26
Quoted 5 lines
drivers/clk/clk-tc9564.c new file +5
-0+#define FULL_NAME_SIZE 24/* Enough for formatted full name */ +#define NAME_SIZE 12/* Unique portion of the clock name */ +#define FORMAT_FULL_NAME (_full_name, _id, _name) \ + snprintf(_full_name, FULL_NAME_SIZE, "tc9564%c_%.*s", \ + 'a' + (_id), NAME_SIZE, _name)
dev->idwill always be zero coming from a platform driver and this code is a lot of churn hidden in a macro. If you must factorize this (I don't think you do) make it a function
Sashiko also pointed out the dev->id being always 0.
Quoted 2 lines
something like
snprintf(name, sizeof(name), "%s-%s", dev_name(dev), init->name)should be enough. use kasprintf if you can't predict the size.
That's a lot simpler and almost certainly won't fail. I'll do what you suggest.
Quoted 13 lines
Quoted 13 lines
drivers/clk/clk-tc9564.c new file +13
-0+ +/* Two registers control whether gate clocks are enabled */ +#define CLK_CTRL0_OFFSET 0x1004/* Common and MAC0 gate clocks */ +#define CLK_CTRL1_OFFSET 0x100c/* MAC1 gate clocks */ + +enum clock_type {PLL ,FIXED ,GATE }; + +struct tc9564_clock { +struct regmap *regmap; +struct clk_hw_onecell_data *clk_data; +}; + +struct gate_clock {
Quoted 8 lines
drivers/clk/clk-tc9564.c line 45
Quoted 6 lines
drivers/clk/clk-tc9564.c new file +6
-0+struct clk_hw hw; +const struct clock_init *init; +}; + +struct clock_init { +const char name[NAME_SIZE ];just const char *name ... you are asking for trouble with this.
Right, this can happen once using kasprintf() for the name.
Quoted 27 lines
Quoted 27 lines
drivers/clk/clk-tc9564.c new file +26
-0+enum clock_type type; +union { +u32 mult;/* PLL rate multiplier */ + +u32 div;/* Fixed rate clock divider */ + +struct {/* Gate clock */ +u16 parent;/* Parent clock ID, e.g. CLOCK_50M */ +u16 offset;/* CLK_CTRL0_OFFSET/CLK_CTRL1_OFFSET */ +u32 mask; + }; + }; +}; + +/* There is only one PLL */ +#define PLL_INIT (_name, _mult) \ + [CLOCK_##_name] = { \ + .name = #_name, \ + .type = PLL, \ + .mult = (_mult), \ + } + +/* The PLL is the parent of all the fixed rate clocks */ +#define FIXED_INIT (_name, _div) \ + [CLOCK_##_name] = { \ + .name = #_name, \
Quoted 8 lines
drivers/clk/clk-tc9564.c line 77
Quoted 6 lines
drivers/clk/clk-tc9564.c new file +6
-0+ .type = FIXED, \ + .div = (_div), \ + } + +#define GATE_INIT0 (_name, _bit, _pname) __GATE_INIT(_name, 0, _bit, _pname) +#define GATE_INIT1 (_name, _bit, _pname) __GATE_INIT(_name, 1, _bit, _pname)So you are writing the param in the name ? what is the point of that ?
I'm not sure I understand this, but my next response below might address it.
Quoted 13 lines
Quoted 13 lines
drivers/clk/clk-tc9564.c new file +12
-0+#define __GATE_INIT (_name, _reg, _bit, _pname) \ + [CLOCK_##_name] = { \ + .name = #_name, \ + .type = GATE, \ + .parent = CLOCK_##_pname, \ + .offset = CLK_CTRL ## _reg ## _OFFSET, \ + .mask = BIT(_bit), \ + } + +/* +* Clocks are initialized and registered in the order of their IDs. +* Parent clocks must be registered before their children.
Quoted 8 lines
drivers/clk/clk-tc9564.c line 94
Quoted 5 lines
drivers/clk/clk-tc9564.c new file +5
-0+*/ +static const struct clock_init clock_init[] = { +PLL_INIT (PLL ,50 ), + + FIXED_INIT(62_5M, 20),Just pass literals here, and show it the table. you can then pass real name, not 125M which is very much tied to your ids.
Well, the IDs are fixed and named meaningfully. But I *think* you are suggesting not to use macros in initialization (and to not make the formatted name depend on the symbolic name). I think that's pretty reasonable, so that's what I will do.
Quoted 15 lines
Quoted 15 lines
drivers/clk/clk-tc9564.c new file +14
-0+ FIXED_INIT(125M, 10), + FIXED_INIT(250M, 5), + FIXED_INIT(312_5M, 4), + + GATE_INIT0(MSIGEN, 18, 62_5M), + + GATE_INIT0(MAC0_TX, 7, 250M), + GATE_INIT0(MAC0_RX, 14, 250M), + GATE_INIT0(MAC0_125M, 29, 125M), + GATE_INIT0(MAC0_312_5M, 30, 312_5M), + GATE_INIT0(MAC0_ALL, 31, 250M), + + GATE_INIT1(MAC1_TX, 7, 250M), + GATE_INIT1(MAC1_RX, 14, 250M),
Quoted 8 lines
drivers/clk/clk-tc9564.c line 113
Quoted 5 lines
drivers/clk/clk-tc9564.c new file +5
-0+ GATE_INIT1(MAC1_125M, 29, 125M), + GATE_INIT1(MAC1_312_5M, 30, 312_5M), + GATE_INIT1(MAC1_ALL, 31, 250M), + GATE_INIT1(MAC1_RMII, 15, 125M), +};Could you explain why clock PCIe and I2C that where critical
in the previous version have been left out ? they are not critical anymore ?
I pulled out support for all clocks whose ID was never used in software, including these two. They're never actually used in practice, which means they never got modified (and therefore never disabled).
That said, I don't mind adding these two back again and marking them CLK_IS_CRITICAL as you suggested. (Unfortunately I haven't found a comparable flag for resets.)
I said this elsewhere, but I do not have a real clock tree that explains what rates some of these even use. For those that aren't referenced in code, it might not matter anyway, but regardless, I'm trying to just avoid claiming anything about the unused clocks, so I'd rather leave them out.
So again, I'll plan to define and support the PCIe and I2C clocks in the next version, but the others I plan to just leave out until we get better information.
Quoted 38 lines
Quoted 38 lines
drivers/clk/clk-tc9564.c new file +38
-0+#define CLOCK_COUNT ARRAY_SIZE(clock_init) + +/* Parent is the input oscillator running at 25 MHz; PLL runs at 1250 MHz */ +static struct clk_hw *pll_register (struct device *dev, +const struct clock_init *init) +{ +char full_name[FULL_NAME_SIZE ]; + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + +return devm_clk_hw_register_fixed_factor_index (dev, full_name,0 ,0 , + init->mult,1 ); +} + +/* The PLL is the parent of all fixed clocks */ +static struct clk_hw *fixed_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +char full_name[FULL_NAME_SIZE ]; +struct clk_hw *pll_hw; + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + + pll_hw = tc9564_clock->clk_data->hws[CLOCK_PLL ]; + +return devm_clk_hw_register_fixed_factor_parent_hw (dev, full_name, + pll_hw,0 , +1 , init->div); +} + +static const struct gate_clock *hw_to_gate_clock (struct clk_hw *hw) +{ + return container_of_const(hw, struct gate_clock, hw); +} + +static void gate_clk_manage (struct clk_hw *hw,bool enable) +{
Quoted 8 lines
drivers/clk/clk-tc9564.c line 157
Quoted 6 lines
drivers/clk/clk-tc9564.c new file +6
-0+struct tc9564_clock *tc9564_clock =dev_get_drvdata (clk_hw_get_dev (hw)); +const struct gate_clock *clock =hw_to_gate_clock (hw); +u32 mask = clock->init->mask; + +regmap_update_bits (tc9564_clock->regmap, clock->init->offset, mask, + enable ? mask :0 );how about returning the error if any ?
I'll no longer be using a regmap in the next version, but I think I understand your point (gate_clk_enable() below can return what this returns) and will implement it that way.
Quoted 25 lines
Quoted 12 lines
drivers/clk/clk-tc9564.c new file +11
-0+} + +static int gate_clk_enable (struct clk_hw *hw) +{ +gate_clk_manage (hw, true); + +return 0 ; +} + +static void gate_clk_disable (struct clk_hw *hw) +{drivers/clk/clk-tc9564.c line 178
Quoted 10 lines
drivers/clk/clk-tc9564.c new file +10
-0+gate_clk_manage (hw, false); +} + +static int gate_clk_is_enabled (struct clk_hw *hw) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (clk_hw_get_dev (hw)); +const struct gate_clock *clock =hw_to_gate_clock (hw); +u32 val; + +regmap_read (tc9564_clock->regmap, clock->init->offset, &val);here too
Quoted 4 lines
drivers/clk/clk-tc9564.c line 180
Quoted 2 lines
drivers/clk/clk-tc9564.c new file +2
-0+ +return val & clock->init->mask ?1 :0 ;you might be using val uninitialised here.
The next version will not be using regmap (it will use readl() here), so this is moot.
Quoted 57 lines
Quoted 57 lines
drivers/clk/clk-tc9564.c new file +57
-0+} + +static const struct clk_ops gate_clk_ops = { + .enable = gate_clk_enable, + .disable = gate_clk_disable, + .is_enabled = gate_clk_is_enabled, +}; + +static struct clk_hw *gate_register (struct device *dev, +const struct clock_init *init) +{ +struct tc9564_clock *tc9564_clock =dev_get_drvdata (dev); +struct clk_init_data clk_init = { }; +const struct clk_hw *parent_hw; +char full_name[FULL_NAME_SIZE ]; +struct gate_clock *clock; +int ret; + + clock =devm_kzalloc_obj (dev, *clock); +if (!clock) +return ERR_PTR (-ENOMEM ); + +FORMAT_FULL_NAME (full_name, dev->id, init->name); + + parent_hw = tc9564_clock->clk_data->hws[init->parent]; + + clk_init.name = full_name; + clk_init.ops = &gate_clk_ops; + clk_init.parent_hws = &parent_hw; + clk_init.num_parents =1 ; + + clock->hw.init = &clk_init; + clock->init = init; + + ret =devm_clk_hw_register (dev, &clock->hw); +if (ret) +return ERR_PTR (ret); + +return &clock->hw; +} + +static int tc9564_clk_probe (struct platform_device *pdev) +{ +struct clk_hw_onecell_data *clk_data; +struct tc9564_clock *tc9564_clock; +struct device *dev = &pdev->dev; +struct device_node *parent_np; +int ret; + + parent_np =dev_of_node (dev->parent); +if (!parent_np) +return dev_err_probe (dev, -EINVAL ,"no devicetree node\n" ); + + tc9564_clock =devm_kzalloc_obj (dev, *tc9564_clock); +if (!tc9564_clock) +return -ENOMEM ; +
Quoted 8 lines
drivers/clk/clk-tc9564.c line 242
Quoted 5 lines
drivers/clk/clk-tc9564.c new file +5
-0+/* Note: MMIO regmap (no error checking needed when used) */ + tc9564_clock->regmap =device_node_to_regmap (parent_np); +if (IS_ERR (tc9564_clock->regmap)) +return dev_err_probe (dev,PTR_ERR (tc9564_clock->regmap), +"failed to get config regmap\n" );If the parent registers the regmap you can get it with
dev_get_regmap(dev->parent, NULL)with no syscon dep.
Thank you very much for your review.
-Alex
Quoted 12 lines · Alex Elder
This series is comprised of some code that was previously sent separately. It now incorporates a new system controller driver that advertises clock and reset functionality, as well as regmap access to its address range. This combination is being treated as a new series. (Details of previous versions are below.)
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.
Quoted 3 lines
The system controller driver adds the clock and reset devices using the
mfd_add_devices()interface. The clocks and resets are implemented by drivers included in this series.
Krzysztof Kozlowski questioned the use of the syscon for this chip, and after some offline discussion I agreed to go without it. This means Conor's ack won't be included, and I won't be doing anything I said I would that was related to the syscon.
The clock and reset drivers can each stand alone, without using a shared regmap.
Each of these drivers uses two registers. But in both cases, the two registers are discontiguous:
clock: 0x1004 and 0x100c
reset: 0x1008 and 0x1010
It has been suggested before that separating the reset and clock drivers has advantages, but I think in this case, the simplicity of the combined driver (especially because of the interleaved registers) is the better option.
For that reason, I intend to *combine* these two drivers into a single clock controller driver that provides both clocks and resets. The source code will reside under drivers/clk. The combined device will have a single DTS node, defined by a single devicetree binding, and will use a single contiguous address range:
clock+reset: base 0x1004, size 0x10
The next version of this series would have no syscon, and with the clock and reset support combined, it will basically be a new series. I'll provide links back to this and older code, but the next iteration will consist of:
- A single devicetree binding for the clock+reset combined.
- A header file defining clock and reset IDs, here:
include/dt-bindings/clock/toshiba,tc9564.h
- A single source file, drivers/clk/clk-tc9564.c (plus updates for Kconfig and Makefile)
-Alex
Quoted 56 lines
-Alex
The system controller, along with its devicetree binding are new. My hope is that this new model addresses concerns that Krzysztof Kozlowski has expressed in prior versions of the clock and reset code ("fold into the parent").
The clock controller driver was last posted as version 3, and all feedback from prior versions has been addressed. This driver has essentially been completely rewritten. There are now three clock types (PLL, fixed factor, and gate), and each defined clock has a parent, and the
is_enabledcallback is implemented for the gate clocks.The last version of the clock driver is here:
https://lore.kernel.org/lkml/[email protected]/The reset controller driver was last posted as version 1. All feedback received on that version has been addressed, and it's a bit simpler than before.
The last version of the reset driver is here:
https://lore.kernel.org/lkml/[email protected]/Alex Elder (4):
dt-bindings: soc: introduce toshiba,tc9564-config-syscon.yaml
soc: toshiba: tc9564: add a new syscon driver
clk: toshiba: introduce a TC9564 SoC clock driver
reset: toshiba: introduce a TC9564 SoC reset driver.../toshiba/toshiba,tc9564-config-syscon.yaml | 68 +++++ MAINTAINERS | 23 ++ drivers/clk/Kconfig | 12 + drivers/clk/Makefile | 1 + drivers/clk/clk-tc9564.c | 288 ++++++++++++++++++ drivers/reset/Kconfig | 12 + drivers/reset/Makefile | 1 + drivers/reset/reset-tc9564.c | 135 ++++++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/toshiba/Kconfig | 12 + drivers/soc/toshiba/Makefile | 3 + drivers/soc/toshiba/tc9564-syscon.c | 42 +++ include/dt-bindings/soc/toshiba,tc9564.h | 46 +++ 14 files changed, 645 insertions(+)create mode 100644
Documentation/devicetree/bindings/soc/toshiba/toshiba,tc9564-config-syscon.yamlcreate mode 100644drivers/clk/clk-tc9564.c
create mode 100644drivers/reset/reset-tc9564.c
create mode 100644drivers/soc/toshiba/Kconfig
create mode 100644drivers/soc/toshiba/Makefile
create mode 100644drivers/soc/toshiba/tc9564-syscon.c
create mode 100644include/dt-bindings/soc/toshiba,tc9564.hbase-commit:
6628e7d4c6b25c8d18f1345e3a20d21829aae7e4