Skip to contentSkip to conversation

Add driver support for ESWIN EIC7700 HSP clock and reset generator

PATCH Superseded [email protected] 2 participants 7 messages May 19 – Jun 3

Subsystems (4)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

v6 cover Add driver support for ESWIN EIC7700 HSP clock and reset generator

From: Xuyang Dong <[email protected]>

Add support for the ESWIN EIC7700 HSP (high-speed peripherals). The drivers provide basic functionality to manage and control the clock and reset signals for EIC7700 HSP, including mmc, USB, ethernet, SATA and DMAC.

The clock and reset registers are mapped to overlapping I/O address ranges. This causes a resource conflict when two drivers attempt to request the same region. Use the auxiliary device framework: the main driver allocates the shared register region and passes it to auxiliary devices, avoiding resource contention and duplicate remapping.

Features:
Implements support for the ESWIN EIC7700 HSP clock and reset controller. Provide API to manage clock and reset signals for the EIC7700 HSP.

Supported chips:
ESWIN EIC7700 series SoC.

Test:
Test this patch on the Sifive HiFive Premier P550 (which used the EIC7700 SoC), include USB and other peripherals. All the drivers of these modules use the clock module and reset module.

Updates:
Changes in v6:
- Clock driver:
- Add 'select REGMAP_MMIO' for Kconfig entry (Sashiko review of v5).
- Reset driver:
- Add <linux/module.h> (Sashiko review of v5).

- Link to v5: https://lore.kernel.org/all/[email protected]/

Changes in v5:
- Clock driver:
- Add check for regmap_read().
- Add "Reviewed-by: Brian Masney <[email protected]>".

- Link to v4: https://lore.kernel.org/all/[email protected]/

Changes in v4:
- Clock driver:
- Remove "Reviewed-by: Benoît Monin <[email protected]>" and "Reviewed-by: Brian Masney <[email protected]>", because the clock driver has been updated.
- Remove inclusion of io.h.
- Add struct regmap to eic7700_hsp_clk_gate.
Replace 'void __iomem *reg' with 'unsigned int reg'.
Replace 'void __iomem *ref_reg' with 'unsigned int ref_reg'. Replace long with int for 'offset' and 'ref_offset'.
Remove 'spinlock_t *lock'.
Apply the same changes to hsp_clk_register_gate().
- Remove the structure eic7700_hsp_regmap_lock, and the functions eic7700_hsp_regmap_lock() and eic7700_hsp_regmap_unlock().
- Remove the 'guard(spinlock_irqsave)(gate->lock)' in hsp_clk_gate_endisable().
- Replace readl() and writel() with regmap_assign_bits() in hsp_clk_gate_endisable().
- Change the parameter enable from int to bool.
- Replace readl() with regmap_read() in hsp_clk_gate_is_enabled().
- Remove the lock_ctx variable.
- Move eic7700_hsp_regmap_config from inside the probe function to global scope.
Remove '.lock', '.unlock' and 'lock_arg'.
Add '.fast_io = true' and '.use_raw_spinlock = true'.
- Reset driver:
- Add "Reviewed-by: Philipp Zabel <[email protected]>" for reset.
- Drop the temporary variable, just return regmap_assign_bits(...) directly.
- Replace -EINVAL with -ENODEV for dev_get_regmap() check.
- Drop the '_dt'.

- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Bindings:
- Added "Acked-by: Conor Dooley <[email protected]>" for bindings.
- Clock driver:
- Remove 'gate_flags'.
- Add __acquires for eic7700_hsp_regmap_lock() and add __releases for eic7700_hsp_regmap_unlock().
- Move writel(USB_REF_XTAL24M, gate->ref_reg) into enable. Because this is only used for USB gate clock on the enable path. And modify the comments.
- Simplify to: 'return !!(readl(gate->reg) & BIT(gate->bit_idx));'.
- Drop const from eic7700_hsp_regmap_config.
- Declare eic7700_hsp_regmap_config as a regular variable at the top.

- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Bindings:
- Remove "hsp_" from clock-names.
- Replace "eswin,eic7700-clock.yaml" and "eswin,eic7700-hspcrg.yaml" with "eswin,eic7700*".
- Replace "eswin,eic7700-clock.h" and "eswin,eic7700-hspcrg.h" with "eswin,eic7700*".
- Clock driver:
- Use guard(spinlock_irqsave)(gate->lock) instead of spin_lock_irqsave() and remove spin_unlock_irqrestore().
- Remove the newline in function hsp_clk_gate_is_enabled().
- Use struct clk_init_data init = {}.
- Replace 'static struct clk_parent_data' with
'static const struct clk_parent_data'.
- Change '.fw_name' to '.index', because the function eswin_clk_register_fixed_factor() uses .index.
- The structures of clocks should use static struct. When registering a clock, the 'hw' field in the structure will be assigned.
- Remove __force.
- Create the regmap in the clock driver and remove (__force void*)data->base. The reset driver uses dev_get_regmap() to get the regmap from the clock.
- Move 'const struct regmap_config eic7700_hsp_regmap_config' from reset driver to clock driver.
- The USB clock gate (hsp_clk_gate_endisable) and the reset driver both perform read-modify-write cycles on registers 0x800 and 0x900. Use custom regmap lock callbacks so that regmap operations hold data->lock with IRQs disabled, the same lock the clock gate path uses, preventing concurrent RMW races on those shared registers.
- Change to 'ret = eswin_clk_register_fixed_factor(dev, eic7700_hsp_factor_clks,'. The next line will be over 80 characters and under 100 characters.
- Reset driver:
- Remove 'depends on COMMON_CLK_EIC7700_HSP' and 'default COMMON_CLK_EIC7700_HSP'.
- Use regmap_assign_bits() in assert and deassert functions.
- Remove eic7700_hsp_reset_reset().
- The clock driver creates the regmap, and the reset driver uses dev_get_regmap().
- Remove of_reset_n_cells.

- Link to v1: https://lore.kernel.org/all/[email protected]/

Xuyang Dong (3):
dt-bindings: clock: Add ESWIN eic7700 HSP clock and reset generator
clk: eswin: Add eic7700 HSP clock driver
reset: eswin: Add eic7700 HSP reset driver

 .../bindings/clock/eswin,eic7700-hspcrg.yaml  |  63 ++++
 MAINTAINERS                                   |   5 +-
 drivers/clk/eswin/Kconfig                     |  13 +
 drivers/clk/eswin/Makefile                    |   1 +
 drivers/clk/eswin/clk-eic7700-hsp.c           | 341 ++++++++++++++++++
 drivers/reset/Kconfig                         |  11 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-eic7700-hsp.c             | 113 ++++++
 .../dt-bindings/clock/eswin,eic7700-hspcrg.h  |  33 ++
 .../dt-bindings/reset/eswin,eic7700-hspcrg.h  |  21 ++
 10 files changed, 600 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/eswin,eic7700-hspcrg.yaml
 create mode 100644 drivers/clk/eswin/clk-eic7700-hsp.c
 create mode 100644 drivers/reset/reset-eic7700-hsp.c
 create mode 100644 include/dt-bindings/clock/eswin,eic7700-hspcrg.h
 create mode 100644 include/dt-bindings/reset/eswin,eic7700-hspcrg.h

--
2.34.1

author maintainer
#1 lore raw

PATCH v6 1/3 dt-bindings: clock: Add ESWIN eic7700 HSP clock and reset generator

Add bindings for the high-speed peripherals clock and reset generator on the ESWIN EIC7700 HSP.

---
 .../bindings/clock/eswin,eic7700-hspcrg.yaml  | 63 +++++++++++++++++++
 MAINTAINERS                                   |  5 +-
 .../dt-bindings/clock/eswin,eic7700-hspcrg.h  | 33 ++++++++++
 .../dt-bindings/reset/eswin,eic7700-hspcrg.h  | 21 +++++++
 4 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/eswin,eic7700-hspcrg.yaml
 create mode 100644 include/dt-bindings/clock/eswin,eic7700-hspcrg.h
 create mode 100644 include/dt-bindings/reset/eswin,eic7700-hspcrg.h
Documentation/devicetree/bindings/clock/eswin,eic7700-hspcrg.yaml new file +63 -0
new file mode 100644
index 000000000000..43df689ae647
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/eswin,eic7700-hspcrg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ESWIN EIC7700 HSP Clock and Reset Generator
+
+maintainers:
+  - Xuyang Dong <[email protected]>
+
+description:
+  Clock and reset generator for the ESWIN EIC7700 HSP (high-speed peripherals).
+
+properties:
+  compatible:
+    const: eswin,eic7700-hspcrg
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: HSP configuration top clock
+      - description: MMC top clock
+      - description: SATA top clock
+
+  clock-names:
+    items:
+      - const: cfg
+      - const: mmc
+      - const: sata
+
+  '#clock-cells':
+    const: 1
+    description:
+      See <dt-bindings/clock/eswin,eic7700-hspcrg.h> for valid indices.
+
+  '#reset-cells':
+    const: 1
+    description:
+      See <dt-bindings/reset/eswin,eic7700-hspcrg.h> for valid indices.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+  - '#reset-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@50440000 {
+        compatible = "eswin,eic7700-hspcrg";
+        reg = <0x50440000 0x2000>;
+        clocks = <&clock 171>, <&clock 254>, <&clock 187>;
+        clock-names = "cfg", "mmc", "sata";
+        #clock-cells = <1>;
+        #reset-cells = <1>;
+    };
MAINTAINERS +3 -2
index c2c6d79275c6..23d9e41e8927 100644
@@ -9554,9 +9554,10 @@ ESWIN EIC7700 CLOCK DRIVER
 M:	Yifeng Huang <[email protected]>
 M:	Xuyang Dong <[email protected]>
 S:	Maintained
-F:	Documentation/devicetree/bindings/clock/eswin,eic7700-clock.yaml
+F:	Documentation/devicetree/bindings/clock/eswin,eic7700*
 F:	drivers/clk/eswin/
-F:	include/dt-bindings/clock/eswin,eic7700-clock.h
+F:	include/dt-bindings/clock/eswin,eic7700*
+F:	include/dt-bindings/reset/eswin,eic7700-hspcrg.h
 
 ET131X NETWORK DRIVER
 M:	Mark Einon <[email protected]>
include/dt-bindings/clock/eswin,eic7700-hspcrg.h new file +33 -0
new file mode 100644
index 000000000000..1d1ff15c1154
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright 2026, Beijing ESWIN Computing Technology Co., Ltd..
+ * All rights reserved.
+ *
+ * Device Tree binding constants for EIC7700 HSP clock controller.
+ *
+ * Authors: Xuyang Dong <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_ESWIN_EIC7700_HSPCRG_CLOCK_H_
+#define _DT_BINDINGS_ESWIN_EIC7700_HSPCRG_CLOCK_H_
+
+#define EIC7700_HSP_CLK_FAC_CFG_DIV2		0
+#define EIC7700_HSP_CLK_FAC_CFG_DIV4		1
+#define EIC7700_HSP_CLK_FAC_MMC_DIV10		2
+#define EIC7700_HSP_CLK_MUX_EMMC_3MUX1		3
+#define EIC7700_HSP_CLK_MUX_SD0_3MUX1		4
+#define EIC7700_HSP_CLK_MUX_SD1_3MUX1		5
+#define EIC7700_HSP_CLK_MUX_EMMC_CQE_2MUX1	6
+#define EIC7700_HSP_CLK_MUX_SD0_CQE_2MUX1	7
+#define EIC7700_HSP_CLK_MUX_SD1_CQE_2MUX1	8
+#define EIC7700_HSP_CLK_GATE_MSHC0_TMR		9
+#define EIC7700_HSP_CLK_GATE_EMMC		10
+#define EIC7700_HSP_CLK_GATE_MSHC1_TMR		11
+#define EIC7700_HSP_CLK_GATE_SD0		12
+#define EIC7700_HSP_CLK_GATE_MSHC2_TMR		13
+#define EIC7700_HSP_CLK_GATE_SD1		14
+#define EIC7700_HSP_CLK_GATE_USB0		15
+#define EIC7700_HSP_CLK_GATE_USB1		16
+#define EIC7700_HSP_CLK_GATE_SATA		17
+
+#endif /* _DT_BINDINGS_ESWIN_EIC7700_HSPCRG_CLOCK_H_ */
include/dt-bindings/reset/eswin,eic7700-hspcrg.h new file +21 -0
new file mode 100644
index 000000000000..413fcd08c701
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright 2026, Beijing ESWIN Computing Technology Co., Ltd..
+ * All rights reserved.
+ *
+ * Device Tree binding constants for EIC7700 HSP reset controller.
+ *
+ * Authors: Xuyang Dong <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_ESWIN_EIC7700_HSPCRG_RESET_H_
+#define _DT_BINDINGS_ESWIN_EIC7700_HSPCRG_RESET_H_
+
+#define EIC7700_HSP_RST_SATA_P0		0
+#define EIC7700_HSP_RST_SATA_PHY	1
+#define EIC7700_HSP_RST_USB0		2
+#define EIC7700_HSP_RST_USB1		3
+#define EIC7700_HSP_RST_USB0_PHY	4
+#define EIC7700_HSP_RST_USB1_PHY	5
+
+#endif /* _DT_BINDINGS_ESWIN_EIC7700_HSPCRG_RESET_H_ */
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v6 2/3 clk: eswin: Add eic7700 HSP clock driver

In reply to [email protected]

From: Xuyang Dong <[email protected]>

Add driver for the ESWIN EIC7700 high-speed peripherals system clock controller and register an auxiliary device for system reset controller which is named as "hsp-reset".

---
 drivers/clk/eswin/Kconfig           |  13 ++
 drivers/clk/eswin/Makefile          |   1 +
 drivers/clk/eswin/clk-eic7700-hsp.c | 341 ++++++++++++++++++++++++++++
 3 files changed, 355 insertions(+)
 create mode 100644 drivers/clk/eswin/clk-eic7700-hsp.c
drivers/clk/eswin/Kconfig +13 -0
index 0406ec499ec9..37857bd77335 100644
@@ -13,3 +13,16 @@ config COMMON_CLK_EIC7700
 	  SoC. The clock controller generates and supplies clocks to various
 	  peripherals within the SoC.
 	  Say yes here to support the clock controller on the EIC7700 SoC.
+
+config COMMON_CLK_EIC7700_HSP
+	tristate "EIC7700 HSP Clock Driver"
+	depends on ARCH_ESWIN || COMPILE_TEST
+	select AUXILIARY_BUS
+	select COMMON_CLK_EIC7700
+	select RESET_EIC7700_HSP if RESET_CONTROLLER
+	select REGMAP_MMIO
+	help
+	  This driver provides support for clock controller on ESWIN EIC7700
+	  HSP. The clock controller generates and supplies clocks to high
+	  speed peripherals within the SoC.
+	  Say yes here to support the clock controller on the EIC7700 HSP.
drivers/clk/eswin/Makefile +1 -0
index 4a7c2af82164..21a09a3396df 100644
@@ -6,3 +6,4 @@
 obj-$(CONFIG_COMMON_CLK_ESWIN)		+= clk.o
 
 obj-$(CONFIG_COMMON_CLK_EIC7700)	+= clk-eic7700.o
+obj-$(CONFIG_COMMON_CLK_EIC7700_HSP)	+= clk-eic7700-hsp.o
drivers/clk/eswin/clk-eic7700-hsp.c new file +341 -0

341 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v6 2/3] clk: eswin: Add eic7700 HSP clock driver

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Global static clock arrays are modified during probe without locking, breaking support for multiple…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Global static clock arrays are modified during probe without locking, breaking support for multiple instances.
- [Low] The Kconfig symbol COMMON_CLK_EIC7700_HSP lacks the default ARCH_ESWIN property, which is inconsistent with the base clock driver. --

commit 5c87f865ca8ae746d80ff71fdbbce73f7be502ec
Author: Xuyang Dong <[email protected]>

clk: eswin: Add eic7700 HSP clock driver

Add driver for the ESWIN EIC7700 high-speed peripherals system clock controller and register an auxiliary device for system reset controller which is named as "hsp-reset".

Quoted 4 lines
drivers/clk/eswin/Kconfig +0 -0
index 0406ec499ec9c..37857bd773356 100644

[ ... ]

drivers/clk/eswin/Kconfig config COMMON_CLK_EIC7700 · line 19

Quoted 8 lines
drivers/clk/eswin/Kconfig +4 -0
@@ -13,3 +13,16 @@ config COMMON_CLK_EIC7700
 	  SoC. The clock controller generates and supplies clocks to various
 	  peripherals within the SoC.
 	  Say yes here to support the clock controller on the EIC7700 SoC.
+
+config COMMON_CLK_EIC7700_HSP
+	tristate "EIC7700 HSP Clock Driver"
+	depends on ARCH_ESWIN || COMPILE_TEST

This isn't a bug, but should this config have default ARCH_ESWIN to match the base clock driver? Without it, the high-speed peripheral clocks might be unexpectedly disabled by default on ESWIN platforms.

Quoted 4 lines
drivers/clk/eswin/Kconfig +4 -0
+	select AUXILIARY_BUS
+	select COMMON_CLK_EIC7700
+	select RESET_EIC7700_HSP if RESET_CONTROLLER
+	select REGMAP_MMIO

[ ... ]

Quoted 5 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +0 -0
new file mode 100644
index 0000000000000..3383aa64948a6

[ ... ]

Quoted 8 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +8 -0
+static struct eswin_fixed_factor_clock eic7700_hsp_factor_clks[] = {
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_CFG_DIV2, "factor_hsp_cfg_div2",
+		     hsp_cfg, 1, 2, 0),
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_CFG_DIV4, "factor_hsp_cfg_div4",
+		     hsp_cfg, 1, 4, 0),
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_MMC_DIV10, "factor_hsp_mmc_div10",
+		     hsp_mmc, 1, 10, 0),
+};

[ ... ]

Quoted 13 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +13 -0
+static int eic7700_hsp_clk_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct auxiliary_device *adev;
+	struct eswin_clock_data *data;
+	struct regmap *regmap;
+	struct clk_hw *hw;
+	int i, ret;
+
+	data = eswin_clk_init(pdev, EIC7700_HSP_NR_CLKS);
+	if (IS_ERR(data))
+		return dev_err_probe(dev, PTR_ERR(data),
+				     "failed to get clk data!\n");

drivers/clk/eswin/clk-eic7700-hsp.c line 271

Quoted 10 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +10 -0
+
+	regmap = devm_regmap_init_mmio(dev, data->base,
+				       &eic7700_hsp_regmap_config);
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap),
+				     "failed to get regmap!\n");
+
+	ret = eswin_clk_register_fixed_factor(dev, eic7700_hsp_factor_clks,
+					      ARRAY_SIZE(eic7700_hsp_factor_clks),
+					      data);

Is it safe to pass the global static array eic7700_hsp_factor_clks to this function?

Looking at eswin_clk_register_fixed_factor() in drivers/clk/eswin/clk.c, it modifies the array during probe:

int eswin_clk_register_fixed_factor(...)

{
    ...
        clks[i].hw = *clk_hw;
        data->clk_data.hws[clks[i].id] = clk_hw;
    ...
}

If multiple instances of this driver probe concurrently or defer, could this data race corrupt the CCF parent-child linkages? The same pattern appears to affect eic7700_hsp_gate_clks and eic7700_hsp_mux_clks.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#4 lore raw

Re: Re: [PATCH v6 2/3] clk: eswin: Add eic7700 HSP clock driver

Quoted 20 lines

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Global static clock arrays are modified during probe without locking, breaking support for multiple instances.
- [Low] The Kconfig symbol COMMON_CLK_EIC7700_HSP lacks the default ARCH_ESWIN property, which is inconsistent with the base clock driver. --

commit 5c87f865ca8ae746d80ff71fdbbce73f7be502ec
Author: Xuyang Dong <[email protected]>

clk: eswin: Add eic7700 HSP clock driver

Add driver for the ESWIN EIC7700 high-speed peripherals system clock controller and register an auxiliary device for system reset controller which is named as "hsp-reset".

Quoted 4 lines
drivers/clk/eswin/Kconfig +0 -0
index 0406ec499ec9c..37857bd773356 100644

[ ... ]

Quoted 13 lines

drivers/clk/eswin/Kconfig config COMMON_CLK_EIC7700 · line 19

Quoted 8 lines
drivers/clk/eswin/Kconfig +4 -0
@@ -13,3 +13,16 @@ config COMMON_CLK_EIC7700
 	  SoC. The clock controller generates and supplies clocks to various
 	  peripherals within the SoC.
 	  Say yes here to support the clock controller on the EIC7700 SoC.
+
+config COMMON_CLK_EIC7700_HSP
+	tristate "EIC7700 HSP Clock Driver"
+	depends on ARCH_ESWIN || COMPILE_TEST

This isn't a bug, but should this config have default ARCH_ESWIN to match the base clock driver? Without it, the high-speed peripheral clocks might be unexpectedly disabled by default on ESWIN platforms.

Hi Sashiko,

The HSP clock reset device can be built as a kernel module. However, if 'default ARCH_ESWIN' is set, it will be compiled directly into the kernel instead of as a module.

Quoted 59 lines
Quoted 4 lines
drivers/clk/eswin/Kconfig +4 -0
+	select AUXILIARY_BUS
+	select COMMON_CLK_EIC7700
+	select RESET_EIC7700_HSP if RESET_CONTROLLER
+	select REGMAP_MMIO

[ ... ]

Quoted 5 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +0 -0
new file mode 100644
index 0000000000000..3383aa64948a6

[ ... ]

Quoted 8 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +8 -0
+static struct eswin_fixed_factor_clock eic7700_hsp_factor_clks[] = {
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_CFG_DIV2, "factor_hsp_cfg_div2",
+		     hsp_cfg, 1, 2, 0),
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_CFG_DIV4, "factor_hsp_cfg_div4",
+		     hsp_cfg, 1, 4, 0),
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_MMC_DIV10, "factor_hsp_mmc_div10",
+		     hsp_mmc, 1, 10, 0),
+};

[ ... ]

Quoted 13 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +13 -0
+static int eic7700_hsp_clk_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct auxiliary_device *adev;
+	struct eswin_clock_data *data;
+	struct regmap *regmap;
+	struct clk_hw *hw;
+	int i, ret;
+
+	data = eswin_clk_init(pdev, EIC7700_HSP_NR_CLKS);
+	if (IS_ERR(data))
+		return dev_err_probe(dev, PTR_ERR(data),
+				     "failed to get clk data!\n");

drivers/clk/eswin/clk-eic7700-hsp.c line 271

Quoted 10 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +10 -0
+
+	regmap = devm_regmap_init_mmio(dev, data->base,
+				       &eic7700_hsp_regmap_config);
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap),
+				     "failed to get regmap!\n");
+
+	ret = eswin_clk_register_fixed_factor(dev, eic7700_hsp_factor_clks,
+					      ARRAY_SIZE(eic7700_hsp_factor_clks),
+					      data);

Is it safe to pass the global static array eic7700_hsp_factor_clks to this function?

Looking at eswin_clk_register_fixed_factor() in drivers/clk/eswin/clk.c, it modifies the array during probe:

int eswin_clk_register_fixed_factor(...)

{
    ...
        clks[i].hw = *clk_hw;
        data->clk_data.hws[clks[i].id] = clk_hw;
    ...
}
Quoted 4 lines

If multiple instances of this driver probe concurrently or defer, could this data race corrupt the CCF parent-child linkages? The same pattern appears to affect eic7700_hsp_gate_clks and eic7700_hsp_mux_clks.

No. There is only one compatible string in the DTS, so there will only be a single driver instance. Therefore, concurrent probing cannot occur, and the CCF parent-child linkages will not be corrupted by a data race.

Best regards,
Xuyang Dong

Quoted 2 lines
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#5 lore raw

Re: Re: Re: [PATCH v6 2/3] clk: eswin: Add eic7700 HSP clock driver

Quoted 100 lines
Quoted 21 lines

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Global static clock arrays are modified during probe without locking, breaking support for multiple instances.
- [Low] The Kconfig symbol COMMON_CLK_EIC7700_HSP lacks the default ARCH_ESWIN property, which is inconsistent with the base clock driver. --

commit 5c87f865ca8ae746d80ff71fdbbce73f7be502ec
Author: Xuyang Dong <[email protected]>

clk: eswin: Add eic7700 HSP clock driver

Add driver for the ESWIN EIC7700 high-speed peripherals system clock controller and register an auxiliary device for system reset controller which is named as "hsp-reset".

Quoted 4 lines
drivers/clk/eswin/Kconfig +0 -0
index 0406ec499ec9c..37857bd773356 100644

[ ... ]

Quoted 13 lines

drivers/clk/eswin/Kconfig config COMMON_CLK_EIC7700 · line 19

Quoted 8 lines
drivers/clk/eswin/Kconfig +4 -0
@@ -13,3 +13,16 @@ config COMMON_CLK_EIC7700
 	  SoC. The clock controller generates and supplies clocks to various
 	  peripherals within the SoC.
 	  Say yes here to support the clock controller on the EIC7700 SoC.
+
+config COMMON_CLK_EIC7700_HSP
+	tristate "EIC7700 HSP Clock Driver"
+	depends on ARCH_ESWIN || COMPILE_TEST

This isn't a bug, but should this config have default ARCH_ESWIN to match the base clock driver? Without it, the high-speed peripheral clocks might be unexpectedly disabled by default on ESWIN platforms.

Hi Sashiko,

The HSP clock reset device can be built as a kernel module. However, if 'default ARCH_ESWIN' is set, it will be compiled directly into the kernel instead of as a module.

Quoted 59 lines
Quoted 4 lines
drivers/clk/eswin/Kconfig +4 -0
+	select AUXILIARY_BUS
+	select COMMON_CLK_EIC7700
+	select RESET_EIC7700_HSP if RESET_CONTROLLER
+	select REGMAP_MMIO

[ ... ]

Quoted 5 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +0 -0
new file mode 100644
index 0000000000000..3383aa64948a6

[ ... ]

Quoted 8 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +8 -0
+static struct eswin_fixed_factor_clock eic7700_hsp_factor_clks[] = {
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_CFG_DIV2, "factor_hsp_cfg_div2",
+		     hsp_cfg, 1, 2, 0),
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_CFG_DIV4, "factor_hsp_cfg_div4",
+		     hsp_cfg, 1, 4, 0),
+	ESWIN_FACTOR(EIC7700_HSP_CLK_FAC_MMC_DIV10, "factor_hsp_mmc_div10",
+		     hsp_mmc, 1, 10, 0),
+};

[ ... ]

Quoted 13 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +13 -0
+static int eic7700_hsp_clk_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct auxiliary_device *adev;
+	struct eswin_clock_data *data;
+	struct regmap *regmap;
+	struct clk_hw *hw;
+	int i, ret;
+
+	data = eswin_clk_init(pdev, EIC7700_HSP_NR_CLKS);
+	if (IS_ERR(data))
+		return dev_err_probe(dev, PTR_ERR(data),
+				     "failed to get clk data!\n");

drivers/clk/eswin/clk-eic7700-hsp.c line 271

Quoted 10 lines
drivers/clk/eswin/clk-eic7700-hsp.c new file +10 -0
+
+	regmap = devm_regmap_init_mmio(dev, data->base,
+				       &eic7700_hsp_regmap_config);
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap),
+				     "failed to get regmap!\n");
+
+	ret = eswin_clk_register_fixed_factor(dev, eic7700_hsp_factor_clks,
+					      ARRAY_SIZE(eic7700_hsp_factor_clks),
+					      data);

Is it safe to pass the global static array eic7700_hsp_factor_clks to this function?

Looking at eswin_clk_register_fixed_factor() in drivers/clk/eswin/clk.c, it modifies the array during probe:

int eswin_clk_register_fixed_factor(...)

{
    ...
        clks[i].hw = *clk_hw;
        data->clk_data.hws[clks[i].id] = clk_hw;
    ...
}
Quoted 9 lines
Quoted 4 lines

If multiple instances of this driver probe concurrently or defer, could this data race corrupt the CCF parent-child linkages? The same pattern appears to affect eic7700_hsp_gate_clks and eic7700_hsp_mux_clks.

No. There is only one compatible string in the DTS, so there will only be a single driver instance. Therefore, concurrent probing cannot occur, and the CCF parent-child linkages will not be corrupted by a data race.

Hi Sashiko,

I have clarified your comments above. Please let me know if my replies are acceptable.
If there are no further issues, I will send the next version of the patch.

Best regards,
Xuyang Dong

Quoted 3 lines
Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#6 lore raw

PATCH v6 3/3 reset: eswin: Add eic7700 HSP reset driver

In reply to [email protected]

Add auxiliary driver to support ESWIN EIC7700 high-speed peripherals system. The reset controller is created using the auxiliary device framework and set up in the clock driver.

---
 drivers/reset/Kconfig             |  11 +++
 drivers/reset/Makefile            |   1 +
 drivers/reset/reset-eic7700-hsp.c | 113 ++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/reset/reset-eic7700-hsp.c
drivers/reset/Kconfig +11 -0
index d009eb0849a3..f63e89ed6a4e 100644
@@ -83,6 +83,17 @@ config RESET_EIC7700
 	  The driver supports eic7700 series chips and provides functionality for
 	  asserting and deasserting resets on the chip.
 
+config RESET_EIC7700_HSP
+	tristate "EIC7700 HSP Reset controller"
+	depends on ARCH_ESWIN || COMPILE_TEST
+	select AUXILIARY_BUS
+	help
+	  This enables the HSP reset controller driver for ESWIN SoCs. This
+	  driver is specific to ESWIN SoCs and should only be enabled if using
+	  such hardware.
+	  The driver supports EIC7700 series chips and provides functionality
+	  for asserting and deasserting resets on the chip.
+
 config RESET_EYEQ
 	bool "Mobileye EyeQ reset controller"
 	depends on EYEQ || COMPILE_TEST
drivers/reset/Makefile +1 -0
index 3e52569bd276..a75af831ef58 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
 obj-$(CONFIG_RESET_BRCMSTB) += reset-brcmstb.o
 obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o
 obj-$(CONFIG_RESET_EIC7700) += reset-eic7700.o
+obj-$(CONFIG_RESET_EIC7700_HSP) += reset-eic7700-hsp.o
 obj-$(CONFIG_RESET_EYEQ) += reset-eyeq.o
 obj-$(CONFIG_RESET_GPIO) += reset-gpio.o
 obj-$(CONFIG_RESET_HSDK) += reset-hsdk.o
drivers/reset/reset-eic7700-hsp.c new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.34.1