Skip to contentSkip to conversation

Add support for AST2700 clk driver

PATCH Superseded Ryan Chen 3 participants 14 messages Oct 28, 2024 – Dec 9, 2024

Subsystems (6)

v6 of 16 Superseded Latest is v16 →

lore
Share & tools
lore

Ryan Chen

author maintainer
#0 lore raw

v6 cover Add support for AST2700 clk driver

This patch series is add clk driver for AST2700.

AST2700 is the 8th generation of Integrated Remote Management Processor introduced by ASPEED Technology Inc. Which is Board Management controller (BMC) SoC family. AST2700 have two SoC connected, one is SoC0, another is SoC1, it has it's own scu, this driver inlcude SCU0 and SCU1 driver.

v7:
-reset-aspeed.h: fix declare static inline aspeed_reset_controller_register if the function is not used.

v6:
-patch-2: add reset-aspeed.h
-reset-aspeed: add include cleanup.h for guard() -reset-aspeed: change ids name clk_aspeed to reset_aspeed -reset-aspeed: move aspeed_reset_controller_register, aspeed_reset_adev_release, aspeed_reset_unregister_adev from clk-ast2700.c -reset-aspeed: drop base check, since it check in clk-ast2700.c -clk-ast2700: sync each gate name from *clk to *clk-gate name. -clk-ast2700: add CLK_GATE_ASPEED to diff clk_hw_register_gate and ast2700_clk_hw_register_gate.

v5:
-patch-2 Kconfig: add select AUXILIARY_BUS
-reset-aspeed: #define to_aspeed_reset(p) turn into static inline function. -reset-aspeed: modify spin_lock_irqsave to guard(spinlock_irqsave) -reset-aspeed: remove unnecessary parentheses.
-clk-ast2700: use <linux/units.h> and refrain from define clk

v4:
-yaml: keep size-cells=<1>.
-merge clk,reset dt binding header with yaml the same patch. -rename clk,reset dt binding header to aspeed,ast2700-scu.h -reset-aspeed: update tables tabs sapces to consistent spaces. -reset-aspeed: remove no use dev_set_drvdata.
-clk-ast2700: modify reset_name to const int scu in struct clk_data. -clk-ast2700: use scu number in clk_data generate reset_name for reset
driver register.
-clk-ast2700: fix pll number mix up scu0,scu1. -clk-ast2700: update dt-binding clock include file.

v3:
-yaml: v2 missing send yaml patch, v3 add. -yaml: drop 64bits address example.
-yaml: add discription about soc0 and soc1 -dt-bindings: remove (), *_NUMS, reserved. -dt-bindings: remove dulipated define number. -dt-bindings: merge clk and reset to be one patch. -reset-aspeed: add auxiliary device for reset driver. -clk-ast2700: modify reset to be auxiliary add. -clk-ast2700: modify to be platform driver. -clk-ast2700: modify each clk to const clk array.

v2:
-yaml: drop 64bits address example.
-yaml: add discription about soc0 and soc1
-dt-bindings: remove (), *_NUMS, reserved.
-dt-bindings: remove dulipated define number
-clk-ast2700: drop WARN_ON, weird comment.

Ryan Chen (3):
dt-bindings: mfd: aspeed: support for AST2700
reset: aspeed: register AST2700 reset auxiliary bus device
clk: aspeed: add AST2700 clock driver.

 .../bindings/mfd/aspeed,ast2x00-scu.yaml      |    8 +-
 drivers/clk/Kconfig                           |    8 +
 drivers/clk/Makefile                          |    1 +
 drivers/clk/clk-ast2700.c                     | 1513 +++++++++++++++++
 drivers/reset/Kconfig                         |    7 +
 drivers/reset/Makefile                        |    1 +
 drivers/reset/reset-aspeed.c                  |  302 ++++
 .../dt-bindings/clock/aspeed,ast2700-scu.h    |  163 ++
 .../dt-bindings/reset/aspeed,ast2700-scu.h    |  124 ++
 include/soc/aspeed/reset-aspeed.h             |   21 +
 10 files changed, 2147 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/clk-ast2700.c
 create mode 100644 drivers/reset/reset-aspeed.c
 create mode 100644 include/dt-bindings/clock/aspeed,ast2700-scu.h
 create mode 100644 include/dt-bindings/reset/aspeed,ast2700-scu.h
 create mode 100644 include/soc/aspeed/reset-aspeed.h
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v7 1/3 dt-bindings: mfd: aspeed: support for AST2700

Add reset, clk dt bindings headers, and update compatible support for AST2700 clk, silicon-id in yaml.

---
 .../bindings/mfd/aspeed,ast2x00-scu.yaml      |   8 +-
 .../dt-bindings/clock/aspeed,ast2700-scu.h    | 163 ++++++++++++++++++
 .../dt-bindings/reset/aspeed,ast2700-scu.h    | 124 +++++++++++++
 3 files changed, 294 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/clock/aspeed,ast2700-scu.h
 create mode 100644 include/dt-bindings/reset/aspeed,ast2700-scu.h
Documentation/devicetree/bindings/mfd/aspeed,ast2x00-scu.yaml +7 -1
index 86ee69c0f45b..c800d5e53b65 100644
@@ -9,6 +9,8 @@ title: Aspeed System Control Unit
 description:
   The Aspeed System Control Unit manages the global behaviour of the SoC,
   configuring elements such as clocks, pinmux, and reset.
+  In AST2700 SOC which has two soc connection, each soc have its own scu
+  register control, ast2700-scu0 for soc0, ast2700-scu1 for soc1.
 
 maintainers:
   - Joel Stanley <[email protected]>
@@ -21,6 +23,8 @@ properties:
           - aspeed,ast2400-scu
           - aspeed,ast2500-scu
           - aspeed,ast2600-scu
+          - aspeed,ast2700-scu0
+          - aspeed,ast2700-scu1
       - const: syscon
       - const: simple-mfd
 
@@ -30,7 +34,8 @@ properties:
   ranges: true
 
   '#address-cells':
-    const: 1
+    minimum: 1
+    maximum: 2
 
   '#size-cells':
     const: 1
@@ -76,6 +81,7 @@ patternProperties:
               - aspeed,ast2400-silicon-id
               - aspeed,ast2500-silicon-id
               - aspeed,ast2600-silicon-id
+              - aspeed,ast2700-silicon-id
           - const: aspeed,silicon-id
 
       reg:
include/dt-bindings/clock/aspeed,ast2700-scu.h new file +163 -0

163 lines not on this page · raw message

include/dt-bindings/reset/aspeed,ast2700-scu.h new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v7 2/3 reset: aspeed: register AST2700 reset auxiliary bus device

In reply to Ryan Chen

The AST2700 reset driver is registered as an auxiliary device due to reset and clock controller share the same register region.

---
 drivers/reset/Kconfig             |   7 +
 drivers/reset/Makefile            |   1 +
 drivers/reset/reset-aspeed.c      | 302 ++++++++++++++++++++++++++++++
 include/soc/aspeed/reset-aspeed.h |  21 +++
 4 files changed, 331 insertions(+)
 create mode 100644 drivers/reset/reset-aspeed.c
 create mode 100644 include/soc/aspeed/reset-aspeed.h
drivers/reset/Kconfig +7 -0
index 67bce340a87e..71a3accea7cb 100644
@@ -22,6 +22,13 @@ config RESET_A10SR
 	  This option enables support for the external reset functions for
 	  peripheral PHYs on the Altera Arria10 System Resource Chip.
 
+config RESET_ASPEED
+	tristate "ASPEED Reset Driver"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	select AUXILIARY_BUS
+	help
+	  This enables the reset controller driver for AST2700.
+
 config RESET_ATH79
 	bool "AR71xx Reset Driver" if COMPILE_TEST
 	default ATH79
drivers/reset/Makefile +1 -0
index 27b0bbdfcc04..97482bb56416 100644
@@ -5,6 +5,7 @@ obj-y += starfive/
 obj-y += sti/
 obj-y += tegra/
 obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
+obj-$(CONFIG_RESET_ASPEED) += reset-aspeed.o
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_AXS10X) += reset-axs10x.o
 obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o
drivers/reset/reset-aspeed.c new file +302 -0

302 lines not on this page · raw message

include/soc/aspeed/reset-aspeed.h new file +21 -0
new file mode 100644
index 000000000000..51a4d13fbe3d
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2024 ASPEED Technology Inc.
+ * Author: Ryan Chen <[email protected]>
+ */
+
+#ifndef __RESET_ASPEED_H__
+#define __RESET_ASPEED_H__
+
+#if IS_ENABLED(CONFIG_RESET_ASPEED)
+int aspeed_reset_controller_register(struct device *clk_dev, void __iomem *base,
+				     const char *adev_name);
+#else
+static inline int aspeed_reset_controller_register(struct device *clk_dev, void __iomem *base,
+				     const char *adev_name)
+{
+	return -ENODEV;
+}
+#endif /* if IS_ENABLED(CONFIG_RESET_ASPEED) */
+
+#endif /* __RESET_ASPEED_H__ */
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH v7 3/3 clk: aspeed: add AST2700 clock driver.

In reply to Ryan Chen

Add AST2700 clock controller driver and also use axiliary device framework register the reset controller driver. Due to clock and reset using the same register region.

---
 drivers/clk/Kconfig       |    8 +
 drivers/clk/Makefile      |    1 +
 drivers/clk/clk-ast2700.c | 1513 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1522 insertions(+)
 create mode 100644 drivers/clk/clk-ast2700.c
drivers/clk/Kconfig +8 -0
index 983ef4f36d8c..4cc35ecba1c0 100644
@@ -269,6 +269,14 @@ config COMMON_CLK_ASPEED
 	  The G4 and G5 series, including the ast2400 and ast2500, are supported
 	  by this driver.
 
+config COMMON_CLK_AST2700
+	bool "Clock driver for AST2700 SoC"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	help
+	  This driver provides support for clock on AST2700 SoC.
+	  The driver is responsible for managing the various clocks required
+	  by the peripherals and cores within the AST2700.
+
 config COMMON_CLK_S2MPS11
 	tristate "Clock driver for S2MPS1X/S5M8767 MFD"
 	depends on MFD_SEC_CORE || COMPILE_TEST
drivers/clk/Makefile +1 -0
index f793a16cad40..fe95203c3138 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_COMMON_CLK_FSL_SAI)	+= clk-fsl-sai.o
 obj-$(CONFIG_COMMON_CLK_GEMINI)		+= clk-gemini.o
 obj-$(CONFIG_COMMON_CLK_ASPEED)		+= clk-aspeed.o
 obj-$(CONFIG_MACH_ASPEED_G6)		+= clk-ast2600.o
+obj-$(CONFIG_COMMON_CLK_AST2700)	+= clk-ast2700.o
 obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
 obj-$(CONFIG_CLK_HSDK)			+= clk-hsdk-pll.o
 obj-$(CONFIG_COMMON_CLK_K210)		+= clk-k210.o
drivers/clk/clk-ast2700.c new file +1513 -0

1,513 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#4 lore raw

Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-27 22:30:18)

drivers/clk/clk-ast2700.c line 7

Quoted 13 lines
drivers/clk/clk-ast2700.c new file +7 -0
new file mode 100644
index 000000000000..db9ee5031b7c
@@ -0,0 +1,1513 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2024 ASPEED Technology Inc.
+ * Author: Ryan Chen <[email protected]>
+ */
+
+#include <linux/auxiliary_bus.h>

Is this include used?

drivers/clk/clk-ast2700.c line 9

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>

Is this include used?

drivers/clk/clk-ast2700.c line 10

Quoted 1 line
drivers/clk/clk-ast2700.c new file +1 -0
+#include <linux/of_device.h>

Probably should be mod_devicetable.h here

drivers/clk/clk-ast2700.c line 17

Quoted 7 lines
drivers/clk/clk-ast2700.c new file +7 -0
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/units.h>
+
+#include <dt-bindings/clock/aspeed,ast2700-scu.h>
+#include <soc/aspeed/reset-aspeed.h>

This include can go before dt-bindings.

Quoted 11 lines
drivers/clk/clk-ast2700.c new file +11 -0
+
+#define SCU_CLK_12MHZ (12 * HZ_PER_MHZ)
+#define SCU_CLK_24MHZ (24 * HZ_PER_MHZ)
+#define SCU_CLK_25MHZ (25 * HZ_PER_MHZ)
+#define SCU_CLK_192MHZ (192 * HZ_PER_MHZ)
+
+/* SOC0 */
+#define SCU0_HWSTRAP1 0x010
+#define SCU0_CLK_STOP 0x240
+#define SCU0_CLK_SEL1 0x280
+#define SCU0_CLK_SEL2 0x284

drivers/clk/clk-ast2700.c line 38

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+#define GET_USB_REFCLK_DIV(x) ((GENMASK(23, 20) & (x)) >> 20)
+#define UART_DIV13_EN BIT(30)
+#define SCU0_HPLL_PARAM 0x300
+#define SCU0_DPLL_PARAM 0x308
+#define SCU0_MPLL_PARAM 0x310
+#define SCU0_D0CLK_PARAM 0x320
+#define SCU0_D1CLK_PARAM 0x330
+#define SCU0_CRT0CLK_PARAM 0x340
+#define SCU0_CRT1CLK_PARAM 0x350
+#define SCU0_MPHYCLK_PARAM 0x360

It would be easier to read if these things were tabbed out a little.

#define SCU0_MPHYCLK_PARAM 0x360

Quoted 25 lines
drivers/clk/clk-ast2700.c new file +25 -0
+
+/* SOC1 */
+#define SCU1_REVISION_ID 0x0
+#define REVISION_ID GENMASK(23, 16)
+#define SCU1_CLK_STOP 0x240
+#define SCU1_CLK_STOP2 0x260
+#define SCU1_CLK_SEL1 0x280
+#define SCU1_CLK_SEL2 0x284
+#define UXCLK_MASK GENMASK(1, 0)
+#define HUXCLK_MASK GENMASK(4, 3)
+#define SCU1_HPLL_PARAM 0x300
+#define SCU1_APLL_PARAM 0x310
+#define SCU1_DPLL_PARAM 0x320
+#define SCU1_UXCLK_CTRL 0x330
+#define SCU1_HUXCLK_CTRL 0x334
+#define SCU1_MAC12_CLK_DLY 0x390
+#define SCU1_MAC12_CLK_DLY_100M 0x394
+#define SCU1_MAC12_CLK_DLY_10M 0x398
+
+enum {
+       CLK_MUX,
+       CLK_PLL,
+       CLK_GATE,
+       CLK_MISC,
+       CLK_FIXED,

drivers/clk/clk-ast2700.c line 73

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+       CLK_DIVIDER,
+       CLK_UART_PLL,
+       CLK_DIV_TABLE,
+       CLK_FIXED_FACTOR,
+       CLK_GATE_ASPEED,
+};
+
+struct ast2700_clk_info {
+       const char *name;
+       const char * const *parent_names;

Please don't use strings for parent names.

Quoted 13 lines
drivers/clk/clk-ast2700.c new file +13 -0
+       const struct clk_div_table *div_table;
+       unsigned long fixed_rate;
+       unsigned int mult;
+       unsigned int div;
+       u32 reg;
+       u32 flags;
+       u32 type;
+       u8 clk_idx;
+       u8 bit_shift;
+       u8 bit_width;
+       u8 num_parents;
+};
+

[...]

drivers/clk/clk-ast2700.c line 144

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+static const struct clk_div_table ast2700_clk_div_table2[] = {
+       { 0x0, 2 },
+       { 0x1, 4 },
+       { 0x2, 6 },
+       { 0x3, 8 },
+       { 0x4, 10 },
+       { 0x5, 12 },
+       { 0x6, 14 },
+       { 0x7, 16 },

Isn't this the default divider setting for struct clk_divider?

Quoted 7 lines
drivers/clk/clk-ast2700.c new file +7 -0
+       { 0 }
+};
+
+static const struct clk_div_table ast2700_clk_uart_div_table[] = {
+       { 0x0, 1 },
+       { 0x1, 13 },
+       { 0 }

[...]

Quoted 13 lines
drivers/clk/clk-ast2700.c new file +13 -0
+               .bit_shift = 23,
+               .bit_width = 3,
+               .div_table = ast2700_clk_div_table2,
+       },
+       [SCU0_CLK_GATE_MCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "mclk-gate",
+               .parent_names = (const char *[]){ "soc0-mpll", },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 0,
+               .flags = CLK_IS_CRITICAL,
+       },
+       [SCU0_CLK_GATE_ECLK] = {

drivers/clk/clk-ast2700.c line 330

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+               .type = CLK_GATE_ASPEED,
+               .name = "eclk-gate",
+               .parent_names = (const char *[]){  },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 1,
+       },
+       [SCU0_CLK_GATE_2DCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "gclk-gate",
+               .parent_names = (const char *[]){  },

This has no parent? Why is parent_names set to an empty array?

Quoted 4 lines
drivers/clk/clk-ast2700.c new file +4 -0
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 2,
+       },
+       [SCU0_CLK_GATE_VCLK] = {

[...]

Quoted 16 lines
drivers/clk/clk-ast2700.c new file +16 -0
+
+static struct clk_hw *ast2700_clk_hw_register_pll(int clk_idx, void __iomem *reg,
+                                                 const struct ast2700_clk_info *clk,
+                                                 struct ast2700_clk_ctrl *clk_ctrl)
+{
+       int scu = clk_ctrl->clk_data->scu;
+       unsigned int mult, div;
+       u32 val;
+
+       if (!scu && clk_idx == SCU0_CLK_HPLL) {
+               val = readl(clk_ctrl->base + SCU0_HWSTRAP1);
+               if ((val & GENMASK(3, 2)) != 0) {
+                       switch ((val & GENMASK(3, 2)) >> 2) {
+                       case 1:
+                               return devm_clk_hw_register_fixed_rate(clk_ctrl->dev, "soc0-hpll",
+                                                                      NULL, 0, 1900000000);

drivers/clk/clk-ast2700.c line 1253

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+                       case 2:
+                               return devm_clk_hw_register_fixed_rate(clk_ctrl->dev, "soc0-hpll",
+                                                                      NULL, 0, 1800000000);
+                       case 3:
+                               return devm_clk_hw_register_fixed_rate(clk_ctrl->dev, "soc0-hpll",
+                                                                      NULL, 0, 1700000000);
+                       default:
+                               return ERR_PTR(-EINVAL);
+                       }
+               }

What if it is 0? Were we supposed to return an error? Why isn't HPLL a different type of PLL so that this function can be broken up into two PLL registration functions?

Quoted 31 lines
drivers/clk/clk-ast2700.c new file +31 -0
+       }
+
+       val = readl(reg);
+
+       if (val & BIT(24)) {
+               /* Pass through mode */
+               mult = 1;
+               div = 1;
+       } else {
+               u32 m = val & 0x1fff;
+               u32 n = (val >> 13) & 0x3f;
+               u32 p = (val >> 19) & 0xf;
+
+               if (scu) {
+                       mult = (m + 1) / (n + 1);
+                       div = (p + 1);
+               } else {
+                       if (clk_idx == SCU0_CLK_MPLL) {
+                               mult = m / (n + 1);
+                               div = (p + 1);
+                       } else {
+                               mult = (m + 1) / (2 * (n + 1));
+                               div = (p + 1);
+                       }
+               }
+       }
+
+       return devm_clk_hw_register_fixed_factor(clk_ctrl->dev, clk->name,
+                                                clk->parent_names[0], 0, mult, div);
+}
+

[...]

Quoted 18 lines
drivers/clk/clk-ast2700.c new file +18 -0
+
+static int ast2700_soc_clk_probe(struct platform_device *pdev)
+{
+       struct ast2700_clk_data *clk_data;
+       struct ast2700_clk_ctrl *clk_ctrl;
+       struct clk_hw_onecell_data *clk_hw_data;
+       struct device *dev = &pdev->dev;
+       void __iomem *clk_base;
+       struct clk_hw **hws;
+       char *reset_name;
+       int ret;
+       int i;
+
+       clk_ctrl = devm_kzalloc(dev, sizeof(*clk_ctrl), GFP_KERNEL);
+       if (!clk_ctrl)
+               return -ENOMEM;
+       clk_ctrl->dev = dev;
+       dev_set_drvdata(&pdev->dev, clk_ctrl);

drivers/clk/clk-ast2700.c line 1418

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+       spin_lock_init(&clk_ctrl->lock);
+
+       clk_base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(clk_base))
+               return PTR_ERR(clk_base);
+
+       clk_ctrl->base = clk_base;
+
+       clk_data = (struct ast2700_clk_data *)of_device_get_match_data(dev);

Just

	clk_data = device_get_match_data(dev);

drivers/clk/clk-ast2700.c line 1420

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+       if (!clk_data)
+               return devm_of_platform_populate(dev);

What is being populated? Isn't there always clk_data?

Quoted 19 lines
drivers/clk/clk-ast2700.c new file +19 -0
+
+       clk_ctrl->clk_data = clk_data;
+       reset_name = devm_kasprintf(dev, GFP_KERNEL, "reset%d", clk_data->scu);
+
+       clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, clk_data->nr_clks),
+                                  GFP_KERNEL);
+       if (!clk_hw_data)
+               return -ENOMEM;
+
+       clk_hw_data->num = clk_data->nr_clks;
+       hws = clk_hw_data->hws;
+
+       for (i = 0; i < clk_data->nr_clks; i++) {
+               const struct ast2700_clk_info *clk = &clk_data->clk_info[i];
+               void __iomem *reg = clk_ctrl->base + clk->reg;
+
+               if (clk->type == CLK_FIXED) {
+                       hws[i] = devm_clk_hw_register_fixed_rate(dev, clk->name, NULL,
+                                                                clk->flags, clk->fixed_rate);

drivers/clk/clk-ast2700.c line 1449

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+               } else if (clk->type == CLK_FIXED_FACTOR) {
+                       hws[i] = devm_clk_hw_register_fixed_factor(dev, clk->name,
+                                                                  clk->parent_names[0], clk->flags,
+                                                                  clk->mult, clk->div);
+               } else if (clk->type == CLK_PLL) {
+                       hws[i] = ast2700_clk_hw_register_pll(i, reg, clk, clk_ctrl);
+               } else if (clk->type == CLK_UART_PLL) {
+                       hws[i] = ast2700_clk_hw_register_uartpll(i, reg, clk, clk_ctrl);
+               } else if (clk->type == CLK_MUX) {
+                       hws[i] = devm_clk_hw_register_mux(dev, clk->name, clk->parent_names,

Please don't use strings for parent_names. Use clk_hw pointers or DT indices.

Quoted 54 lines
drivers/clk/clk-ast2700.c new file +54 -0
+                                                         clk->num_parents, clk->flags, reg,
+                                                         clk->bit_shift, clk->bit_width,
+                                                         0, &clk_ctrl->lock);
+               } else if (clk->type == CLK_MISC) {
+                       hws[i] = ast2700_clk_hw_register_misc(i, reg, clk, clk_ctrl);
+               } else if (clk->type == CLK_DIVIDER) {
+                       hws[i] = devm_clk_hw_register_divider(dev, clk->name, clk->parent_names[0],
+                                                             clk->flags, reg, clk->bit_shift,
+                                                             clk->bit_width, 0,
+                                                             &clk_ctrl->lock);
+               } else if (clk->type == CLK_DIV_TABLE) {
+                       hws[i] = clk_hw_register_divider_table(dev, clk->name, clk->parent_names[0],
+                                                              clk->flags, reg, clk->bit_shift,
+                                                              clk->bit_width, 0,
+                                                              clk->div_table, &clk_ctrl->lock);
+               } else if (clk->type == CLK_GATE_ASPEED) {
+                       hws[i] = ast2700_clk_hw_register_gate(dev, clk->name, clk->parent_names[0],
+                                                             clk->flags, reg, clk->clk_idx,
+                                                             clk->flags, &clk_ctrl->lock);
+               } else {
+                       hws[i] = clk_hw_register_gate(dev, clk->name, clk->parent_names[0],
+                                                     clk->flags, reg, clk->clk_idx, clk->flags,
+                                                     &clk_ctrl->lock);
+               }
+
+               if (IS_ERR(hws[i]))
+                       return PTR_ERR(hws[i]);
+       }
+
+       ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
+       if (ret)
+               return ret;
+
+       return aspeed_reset_controller_register(dev, clk_base, reset_name);
+}
+
+static const struct ast2700_clk_data ast2700_clk0_data = {
+       .scu = 0,
+       .nr_clks = ARRAY_SIZE(ast2700_scu0_clk_info),
+       .clk_info = ast2700_scu0_clk_info,
+};
+
+static const struct ast2700_clk_data ast2700_clk1_data = {
+       .scu = 1,
+       .nr_clks = ARRAY_SIZE(ast2700_scu1_clk_info),
+       .clk_info = ast2700_scu1_clk_info,
+};
+
+static const struct of_device_id ast2700_scu_match[] = {
+       { .compatible = "aspeed,ast2700-scu0", .data = &ast2700_clk0_data },
+       { .compatible = "aspeed,ast2700-scu1", .data = &ast2700_clk1_data },
+       { /* sentinel */ }
+};
+

drivers/clk/clk-ast2700.c line 1513

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+MODULE_DEVICE_TABLE(of, ast2700_scu_match);
+
+static struct platform_driver ast2700_scu_driver = {
+       .driver = {
+               .name = "clk-ast2700",
+               .of_match_table = ast2700_scu_match,
+       },
+};
+
+builtin_platform_driver_probe(ast2700_scu_driver, ast2700_soc_clk_probe);

Use module_platform_driver_probe() and make the config tristate. I don't see what's preventing this from being a module.

author maintainer
#5 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoted 16 lines

Subject: Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-27 22:30:18)

drivers/clk/clk-ast2700.c line 6

Quoted 11 lines
drivers/clk/clk-ast2700.c new renamed from drivers/clk/clk-ast2700.c +0 -0

file mode 100644 index 000000000000..db9ee5031b7c

drivers/clk/clk-ast2700.c new file +6 -0
@@ -0,0 +1,1513 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2024 ASPEED Technology Inc.
+ * Author: Ryan Chen <[email protected]>  */
+
+#include <linux/auxiliary_bus.h>

Is this include used?

Will remove it.

Quoted 5 lines

drivers/clk/clk-ast2700.c line 9

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +2 -0
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>

Is this include used?

Will remove, and add #include <linux/io.h> fore readl/writel

Quoted 4 lines

drivers/clk/clk-ast2700.c line 10

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +1 -0
+#include <linux/of_device.h>

Probably should be mod_devicetable.h here

Yes, will add #include <linux/mod_devicetable.h>

Quoted 10 lines

drivers/clk/clk-ast2700.c line 17

Quoted 8 lines
drivers/clk/clk-ast2700.c new file +7 -0
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/units.h>
+
+#include <dt-bindings/clock/aspeed,ast2700-scu.h>
+#include <soc/aspeed/reset-aspeed.h>

This include can go before dt-bindings.

Will update following.
#include <soc/aspeed/reset-aspeed.h>
#include <dt-bindings/clock/aspeed,ast2700-scu.h>

Quoted 18 lines

drivers/clk/clk-ast2700.c line 18

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +2 -0
+
+#define SCU_CLK_12MHZ (12 * HZ_PER_MHZ) #define SCU_CLK_24MHZ

(24 *

drivers/clk/clk-ast2700.c line 31

Quoted 13 lines
drivers/clk/clk-ast2700.c new file +13 -0
+HZ_PER_MHZ) #define SCU_CLK_25MHZ (25 * HZ_PER_MHZ) #define
+SCU_CLK_192MHZ (192 * HZ_PER_MHZ)
+
+/* SOC0 */
+#define SCU0_HWSTRAP1 0x010
+#define SCU0_CLK_STOP 0x240
+#define SCU0_CLK_SEL1 0x280
+#define SCU0_CLK_SEL2 0x284
+#define GET_USB_REFCLK_DIV(x) ((GENMASK(23, 20) & (x)) >> 20) #define
+UART_DIV13_EN BIT(30) #define SCU0_HPLL_PARAM 0x300 #define
+SCU0_DPLL_PARAM 0x308 #define SCU0_MPLL_PARAM 0x310 #define
+SCU0_D0CLK_PARAM 0x320 #define SCU0_D1CLK_PARAM 0x330 #define
+SCU0_CRT0CLK_PARAM 0x340 #define SCU0_CRT1CLK_PARAM 0x350

#define

Quoted 5 lines

drivers/clk/clk-ast2700.c line 32

Quoted 1 line
drivers/clk/clk-ast2700.c new file +1 -0
+SCU0_MPHYCLK_PARAM 0x360

It would be easier to read if these things were tabbed out a little.

#define SCU0_MPHYCLK_PARAM 0x360

Thank, all those will update by tabbed.

Quoted 31 lines
Quoted 8 lines
drivers/clk/clk-ast2700.c new file +7 -0
+
+/* SOC1 */
+#define SCU1_REVISION_ID 0x0
+#define REVISION_ID GENMASK(23, 16)
+#define SCU1_CLK_STOP 0x240
+#define SCU1_CLK_STOP2 0x260
+#define SCU1_CLK_SEL1 0x280

drivers/clk/clk-ast2700.c

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+#define SCU1_CLK_SEL2 0x284
+#define UXCLK_MASK GENMASK(1, 0)
+#define HUXCLK_MASK GENMASK(4, 3)
+#define SCU1_HPLL_PARAM 0x300
+#define SCU1_APLL_PARAM 0x310
+#define SCU1_DPLL_PARAM 0x320
+#define SCU1_UXCLK_CTRL 0x330
+#define SCU1_HUXCLK_CTRL 0x334
+#define SCU1_MAC12_CLK_DLY 0x390
+#define SCU1_MAC12_CLK_DLY_100M 0x394 #define

SCU1_MAC12_CLK_DLY_10M

Quoted 12 lines
drivers/clk/clk-ast2700.c new file +12 -0
+0x398
+
+enum {
+       CLK_MUX,
+       CLK_PLL,
+       CLK_GATE,
+       CLK_MISC,
+       CLK_FIXED,
+       CLK_DIVIDER,
+       CLK_UART_PLL,
+       CLK_DIV_TABLE,
+       CLK_FIXED_FACTOR,
Quoted 8 lines

drivers/clk/clk-ast2700.c line 73

Quoted 6 lines
drivers/clk/clk-ast2700.c new file +6 -0
+       CLK_GATE_ASPEED,
+};
+
+struct ast2700_clk_info {
+       const char *name;
+       const char * const *parent_names;

Please don't use strings for parent names.

Sorry, do you mean use clk_parent_data struct for parent?
+const struct clk_parent_data parent; /* For gate */
+const struct clk_parent_data *parents; /* For mux */

Quoted 15 lines
Quoted 14 lines
drivers/clk/clk-ast2700.c new file +13 -0
+       const struct clk_div_table *div_table;
+       unsigned long fixed_rate;
+       unsigned int mult;
+       unsigned int div;
+       u32 reg;
+       u32 flags;
+       u32 type;
+       u8 clk_idx;
+       u8 bit_shift;
+       u8 bit_width;
+       u8 num_parents;
+};
+

[...]

Quoted 12 lines

drivers/clk/clk-ast2700.c line 144

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+static const struct clk_div_table ast2700_clk_div_table2[] = {
+       { 0x0, 2 },
+       { 0x1, 4 },
+       { 0x2, 6 },
+       { 0x3, 8 },
+       { 0x4, 10 },
+       { 0x5, 12 },
+       { 0x6, 14 },
+       { 0x7, 16 },

Isn't this the default divider setting for struct clk_divider?

Sorry, I don't catch your point.
the SoC do have default divider setting. But it can be modified. And also have different divider table setting.

Quoted 33 lines
Quoted 8 lines
drivers/clk/clk-ast2700.c new file +7 -0
+       { 0 }
+};
+
+static const struct clk_div_table ast2700_clk_uart_div_table[] = {
+       { 0x0, 1 },
+       { 0x1, 13 },
+       { 0 }

[...]

Quoted 13 lines
drivers/clk/clk-ast2700.c new file +13 -0
+               .bit_shift = 23,
+               .bit_width = 3,
+               .div_table = ast2700_clk_div_table2,
+       },
+       [SCU0_CLK_GATE_MCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "mclk-gate",
+               .parent_names = (const char *[]){ "soc0-mpll", },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 0,
+               .flags = CLK_IS_CRITICAL,
+       },
+       [SCU0_CLK_GATE_ECLK] = {

drivers/clk/clk-ast2700.c line 330

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+               .type = CLK_GATE_ASPEED,
+               .name = "eclk-gate",
+               .parent_names = (const char *[]){  },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 1,
+       },
+       [SCU0_CLK_GATE_2DCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "gclk-gate",
+               .parent_names = (const char *[]){  },
Quoted 1 line

This has no parent? Why is parent_names set to an empty array?

Due to I use clk->parent_names[0] for clk_hw_register_gate, const char *name parameter input. If null, that will cause panic for NULL point.

Quoted 36 lines
Quoted 5 lines
drivers/clk/clk-ast2700.c new file +4 -0
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 2,
+       },
+       [SCU0_CLK_GATE_VCLK] = {

[...]

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+
+static struct clk_hw *ast2700_clk_hw_register_pll(int clk_idx, void

__iomem *reg,

Quoted 1 line

+ const struct

ast2700_clk_info *clk,

drivers/clk/clk-ast2700.c

Quoted 12 lines
drivers/clk/clk-ast2700.c new file +12 -0
+                                                 struct
+ast2700_clk_ctrl *clk_ctrl) {
+       int scu = clk_ctrl->clk_data->scu;
+       unsigned int mult, div;
+       u32 val;
+
+       if (!scu && clk_idx == SCU0_CLK_HPLL) {
+               val = readl(clk_ctrl->base + SCU0_HWSTRAP1);
+               if ((val & GENMASK(3, 2)) != 0) {
+                       switch ((val & GENMASK(3, 2)) >> 2) {
+                       case 1:
+                               return

devm_clk_hw_register_fixed_rate(clk_ctrl->dev, "soc0-hpll",

Quoted 1 line

+

NULL, 0, 1900000000);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+                       case 2:
+                               return

devm_clk_hw_register_fixed_rate(clk_ctrl->dev, "soc0-hpll",

Quoted 1 line

+

NULL, 0, 1800000000);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+                       case 3:
+                               return

devm_clk_hw_register_fixed_rate(clk_ctrl->dev, "soc0-hpll",

Quoted 1 line

+

NULL, 0, 1700000000);

Quoted 8 lines

drivers/clk/clk-ast2700.c line 1253

Quoted 4 lines
drivers/clk/clk-ast2700.c new file +4 -0
+                       default:
+                               return ERR_PTR(-EINVAL);
+                       }
+               }

What if it is 0? Were we supposed to return an error? Why isn't HPLL a different type of PLL so that this function can be broken up into two PLL registration functions?

Sorry, I miss 0: It will be another fix clk. It need add.
And also I will separate another PLL registration function, add new enum clk type : CLK_HPLL_SOC0

Quoted 65 lines
Quoted 19 lines
drivers/clk/clk-ast2700.c new file +18 -0
+       }
+
+       val = readl(reg);
+
+       if (val & BIT(24)) {
+               /* Pass through mode */
+               mult = 1;
+               div = 1;
+       } else {
+               u32 m = val & 0x1fff;
+               u32 n = (val >> 13) & 0x3f;
+               u32 p = (val >> 19) & 0xf;
+
+               if (scu) {
+                       mult = (m + 1) / (n + 1);
+                       div = (p + 1);
+               } else {
+                       if (clk_idx == SCU0_CLK_MPLL) {

drivers/clk/clk-ast2700.c

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+                               mult = m / (n + 1);
+                               div = (p + 1);
+                       } else {
+                               mult = (m + 1) / (2 * (n + 1));
+                               div = (p + 1);
+                       }
+               }
+       }
+
+       return devm_clk_hw_register_fixed_factor(clk_ctrl->dev,

clk->name,

Quoted 1 line

+

clk->parent_names[0],

Quoted 2 lines

+0, mult, div); }
+

[...]

Quoted 18 lines
drivers/clk/clk-ast2700.c new file +18 -0
+
+static int ast2700_soc_clk_probe(struct platform_device *pdev) {
+       struct ast2700_clk_data *clk_data;
+       struct ast2700_clk_ctrl *clk_ctrl;
+       struct clk_hw_onecell_data *clk_hw_data;
+       struct device *dev = &pdev->dev;
+       void __iomem *clk_base;
+       struct clk_hw **hws;
+       char *reset_name;
+       int ret;
+       int i;
+
+       clk_ctrl = devm_kzalloc(dev, sizeof(*clk_ctrl), GFP_KERNEL);
+       if (!clk_ctrl)
+               return -ENOMEM;
+       clk_ctrl->dev = dev;
+       dev_set_drvdata(&pdev->dev, clk_ctrl);
+

drivers/clk/clk-ast2700.c

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+       spin_lock_init(&clk_ctrl->lock);
+
+       clk_base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(clk_base))
+               return PTR_ERR(clk_base);
+
+       clk_ctrl->base = clk_base;
+
+       clk_data = (struct ast2700_clk_data
+ *)of_device_get_match_data(dev);

Just

Quoted 1 line
	clk_data = device_get_match_data(dev);

Will update.

Quoted 5 lines

drivers/clk/clk-ast2700.c line 1420

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +2 -0
+       if (!clk_data)
+               return devm_of_platform_populate(dev);

What is being populated? Isn't there always clk_data?

Yes, it is always clk_data, I will modify to be following, is it ok? If(!clk_data)

	Return -ENODEV;
Quoted 35 lines

drivers/clk/clk-ast2700.c

Quoted 7 lines
drivers/clk/clk-ast2700.c new file +6 -0
+
+       clk_ctrl->clk_data = clk_data;
+       reset_name = devm_kasprintf(dev, GFP_KERNEL, "reset%d",
+ clk_data->scu);
+
+       clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws,

clk_data->nr_clks),

drivers/clk/clk-ast2700.c

Quoted 9 lines
drivers/clk/clk-ast2700.c new file +9 -0
+                                  GFP_KERNEL);
+       if (!clk_hw_data)
+               return -ENOMEM;
+
+       clk_hw_data->num = clk_data->nr_clks;
+       hws = clk_hw_data->hws;
+
+       for (i = 0; i < clk_data->nr_clks; i++) {
+               const struct ast2700_clk_info *clk =

&clk_data->clk_info[i];

drivers/clk/clk-ast2700.c

Quoted 4 lines
drivers/clk/clk-ast2700.c new file +4 -0
+               void __iomem *reg = clk_ctrl->base + clk->reg;
+
+               if (clk->type == CLK_FIXED) {
+                       hws[i] = devm_clk_hw_register_fixed_rate(dev,

clk->name, NULL,

Quoted 1 line

+

clk->flags, clk->fixed_rate);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_FIXED_FACTOR) {
+                       hws[i] =

devm_clk_hw_register_fixed_factor(dev, clk->name,

Quoted 1 line

+

clk->parent_names[0], clk->flags,

Quoted 1 line

+

clk->mult, clk->div);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_PLL) {
+                       hws[i] = ast2700_clk_hw_register_pll(i, reg,

clk, clk_ctrl);

Quoted 8 lines

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_UART_PLL) {
+                       hws[i] = ast2700_clk_hw_register_uartpll(i,

reg, clk, clk_ctrl);

drivers/clk/clk-ast2700.c

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +3 -0
+               } else if (clk->type == CLK_MUX) {
+                       hws[i] = devm_clk_hw_register_mux(dev,
+ clk->name, clk->parent_names,

Please don't use strings for parent_names. Use clk_hw pointers or DT indices.

Use clk_pareent_data is it ok ?

+const struct clk_parent_data parent; /* For gate */
+const struct clk_parent_data *parents; /* For mux */

Quoted 80 lines
Quoted 2 lines

+

clk->num_parents, clk->flags, reg,

Quoted 1 line

+

clk->bit_shift, clk->bit_width,

Quoted 1 line

+ 0,

&clk_ctrl->lock);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_MISC) {
+                       hws[i] = ast2700_clk_hw_register_misc(i, reg,

clk, clk_ctrl);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_DIVIDER) {
+                       hws[i] = devm_clk_hw_register_divider(dev,

clk->name, clk->parent_names[0],

Quoted 1 line

+

clk->flags, reg, clk->bit_shift,

Quoted 1 line

+

clk->bit_width, 0,

Quoted 1 line

+

&clk_ctrl->lock);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_DIV_TABLE) {
+                       hws[i] = clk_hw_register_divider_table(dev,

clk->name, clk->parent_names[0],

Quoted 1 line

+

clk->flags, reg, clk->bit_shift,

Quoted 1 line

+

clk->bit_width, 0,

Quoted 1 line

+

clk->div_table, &clk_ctrl->lock);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else if (clk->type == CLK_GATE_ASPEED) {
+                       hws[i] = ast2700_clk_hw_register_gate(dev,

clk->name, clk->parent_names[0],

Quoted 1 line

+

clk->flags, reg, clk->clk_idx,

Quoted 1 line

+

clk->flags, &clk_ctrl->lock);

drivers/clk/clk-ast2700.c

Quoted 2 lines
drivers/clk/clk-ast2700.c new file +2 -0
+               } else {
+                       hws[i] = clk_hw_register_gate(dev, clk->name,

clk->parent_names[0],

Quoted 1 line

+

clk->flags, reg, clk->clk_idx, clk->flags,

Quoted 1 line

+

&clk_ctrl->lock);

drivers/clk/clk-ast2700.c

Quoted 7 lines
drivers/clk/clk-ast2700.c new file +7 -0
+               }
+
+               if (IS_ERR(hws[i]))
+                       return PTR_ERR(hws[i]);
+       }
+
+       ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,

clk_hw_data);

Quoted 8 lines
drivers/clk/clk-ast2700.c new file +8 -0
+       if (ret)
+               return ret;
+
+       return aspeed_reset_controller_register(dev, clk_base,
+reset_name); }
+
+static const struct ast2700_clk_data ast2700_clk0_data = {
+       .scu = 0,

drivers/clk/clk-ast2700.c

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+       .nr_clks = ARRAY_SIZE(ast2700_scu0_clk_info),
+       .clk_info = ast2700_scu0_clk_info, };
+
+static const struct ast2700_clk_data ast2700_clk1_data = {
+       .scu = 1,
+       .nr_clks = ARRAY_SIZE(ast2700_scu1_clk_info),
+       .clk_info = ast2700_scu1_clk_info, };
+
+static const struct of_device_id ast2700_scu_match[] = {
+       { .compatible = "aspeed,ast2700-scu0", .data =

&ast2700_clk0_data },

Quoted 1 line

+ { .compatible = "aspeed,ast2700-scu1", .data =

&ast2700_clk1_data },

Quoted 9 lines
drivers/clk/clk-ast2700.c new file +9 -0
+       { /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, ast2700_scu_match);
+
+static struct platform_driver ast2700_scu_driver = {
+       .driver = {
+               .name = "clk-ast2700",
+               .of_match_table = ast2700_scu_match,
Quoted 8 lines

drivers/clk/clk-ast2700.c

Quoted 5 lines
drivers/clk/clk-ast2700.c new file +5 -0
+       },
+};
+
+builtin_platform_driver_probe(ast2700_scu_driver,
+ast2700_soc_clk_probe);

Use module_platform_driver_probe() and make the config tristate. I don't see what's preventing this from being a module.

Will update.

maintainer
#6 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-31 00:24:39)

Quoted 9 lines
Quoted 9 lines

Subject: Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-27 22:30:18)

Quoted 6 lines
drivers/clk/clk-ast2700.c new renamed from drivers/clk/clk-ast2700.c +0 -0

file mode 100644 index 000000000000..db9ee5031b7c

drivers/clk/clk-ast2700.c new file +1 -0
@@ -0,0 +1,1513 @@
+// SPDX-License-Identifier: GPL-2.0

[...]

Quoted 8 lines
Quoted 5 lines

drivers/clk/clk-ast2700.c line 73

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +3 -0
+struct ast2700_clk_info {
+       const char *name;
+       const char * const *parent_names;

Please don't use strings for parent names.

Sorry, do you mean use clk_parent_data struct for parent?
+const struct clk_parent_data parent; /* For gate */
+const struct clk_parent_data *parents; /* For mux */

Yes.

Quoted 28 lines
Quoted 16 lines
Quoted 15 lines
drivers/clk/clk-ast2700.c new file +13 -0
+       const struct clk_div_table *div_table;
+       unsigned long fixed_rate;
+       unsigned int mult;
+       unsigned int div;
+       u32 reg;
+       u32 flags;
+       u32 type;
+       u8 clk_idx;
+       u8 bit_shift;
+       u8 bit_width;
+       u8 num_parents;
+};
+

[...]

Quoted 12 lines

drivers/clk/clk-ast2700.c line 144

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+static const struct clk_div_table ast2700_clk_div_table2[] = {
+       { 0x0, 2 },
+       { 0x1, 4 },
+       { 0x2, 6 },
+       { 0x3, 8 },
+       { 0x4, 10 },
+       { 0x5, 12 },
+       { 0x6, 14 },
+       { 0x7, 16 },

Isn't this the default divider setting for struct clk_divider?

Quoted 3 lines

Sorry, I don't catch your point.
the SoC do have default divider setting. But it can be modified. And also have different divider table setting.

I mean that this is the way that struct clk_divider works already. So you don't need to make the clk_div_table array for what is supported in code.

Quoted 33 lines
Quoted 33 lines
Quoted 8 lines
drivers/clk/clk-ast2700.c new file +7 -0
+       { 0 }
+};
+
+static const struct clk_div_table ast2700_clk_uart_div_table[] = {
+       { 0x0, 1 },
+       { 0x1, 13 },
+       { 0 }

[...]

Quoted 23 lines
drivers/clk/clk-ast2700.c new file +23 -0
+               .bit_shift = 23,
+               .bit_width = 3,
+               .div_table = ast2700_clk_div_table2,
+       },
+       [SCU0_CLK_GATE_MCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "mclk-gate",
+               .parent_names = (const char *[]){ "soc0-mpll", },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 0,
+               .flags = CLK_IS_CRITICAL,
+       },
+       [SCU0_CLK_GATE_ECLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "eclk-gate",
+               .parent_names = (const char *[]){  },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 1,
+       },
+       [SCU0_CLK_GATE_2DCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "gclk-gate",
+               .parent_names = (const char *[]){  },
Quoted 3 lines
Quoted 1 line

This has no parent? Why is parent_names set to an empty array?

Due to I use clk->parent_names[0] for clk_hw_register_gate, const char *name parameter input. If null, that will cause panic for NULL point.

But the parent is NULL? How many parents does this clk have?

Quoted 9 lines
Quoted 5 lines

drivers/clk/clk-ast2700.c line 1420

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +2 -0
+       if (!clk_data)
+               return devm_of_platform_populate(dev);

What is being populated? Isn't there always clk_data?

Yes, it is always clk_data, I will modify to be following, is it ok? If(!clk_data)

        Return -ENODEV;

Sure.

Quoted 3 lines
Quoted 2 lines

Please don't use strings for parent_names. Use clk_hw pointers or DT indices.

Use clk_pareent_data is it ok ?

Yes.

author maintainer
#7 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoted 14 lines
Quoted 9 lines
Quoted 9 lines

Subject: Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-27 22:30:18)

Quoted 6 lines
drivers/clk/clk-ast2700.c new file +1 -0
new file mode 100644 index 000000000000..db9ee5031b7c
@@ -0,0 +1,1513 @@
+// SPDX-License-Identifier: GPL-2.0

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/clk/clk-ast2700.c new file +3 -0
+struct ast2700_clk_info {
+       const char *name;
+       const char * const *parent_names;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please don't use strings for parent names.

Sorry, do you mean use clk_parent_data struct for parent?
+const struct clk_parent_data parent; /* For gate */
+const struct clk_parent_data *parents; /*

For mux */

Yes.

And I find a better way for parent_data. The following is my modification. And parent_data will be union data structure. Like following. Is this good direction?

#define DIVIDER_CLK(_id, _name, _parent, _reg, _shift, _width, _div_table) \
	[_id] = { \
		.type = CLK_DIVIDER, \
		.name = _name, \
		.data = { \
			.div = { \
				.parent = _parent, \
				.reg = _reg, \
				.bit_shift = _shift, \
				.bit_width = _width, \
				.div_table = _div_table, \
			}, \
		}, \
	}
struct ast2700_clk_info {
	const char *name;
	u8 clk_idx;
	u32 reg;
	u32 type;
	union {
		struct ast2700_clk_fixed_factor_data factor;
		struct ast2700_clk_fixed_rate_data rate;
		struct ast2700_clk_gate_data gate;
		struct ast2700_clk_div_data div;
		struct ast2700_clk_pll_data pll;
		struct ast2700_clk_mux_data mux;
	} data;
};
struct ast2700_clk_div_data {
	const struct clk_div_table *div_table;
	const struct clk_parent_data *parent;
	u8 bit_shift;
	u8 bit_width;
	u32 reg;
};

static const struct ast2700_clk_info ast2700_scu0_clk_info[] __initconst = {
...........................

	DIVIDER_CLK(SCU0_CLK_AHB, "soc0-ahb", soc0_ahbmux,
		    SCU0_HWSTRAP1, 5, 2, ast2700_hclk_div_table),

......................

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 16 lines
drivers/clk/clk-ast2700.c new file +13 -0
+       const struct clk_div_table *div_table;
+       unsigned long fixed_rate;
+       unsigned int mult;
+       unsigned int div;
+       u32 reg;
+       u32 flags;
+       u32 type;
+       u8 clk_idx;
+       u8 bit_shift;
+       u8 bit_width;
+       u8 num_parents;
+};
+

[...]

drivers/clk/clk-ast2700.c line 144

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+static const struct clk_div_table ast2700_clk_div_table2[] = {
+       { 0x0, 2 },
+       { 0x1, 4 },
+       { 0x2, 6 },
+       { 0x3, 8 },
+       { 0x4, 10 },
+       { 0x5, 12 },
+       { 0x6, 14 },
+       { 0x7, 16 },

Isn't this the default divider setting for struct clk_divider?

Quoted 6 lines
Quoted 3 lines

Sorry, I don't catch your point.
the SoC do have default divider setting. But it can be modified. And also have different divider table setting.

I mean that this is the way that struct clk_divider works already. So you don't need to make the clk_div_table array for what is supported in code.

Sorry, I understand your point. But I trace the code didn't get any clue. "clk_divider work already". finally function call will be __clk_hw_register_divider
https://github.com/torvalds/linux/blob/master/drivers/clk/clk-divider.c#L589
It still need table point need to address. Can you give me more direction or example?

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 9 lines
drivers/clk/clk-ast2700.c new file +7 -0
+       { 0 }
+};
+
+static const struct clk_div_table ast2700_clk_uart_div_table[] = {
+       { 0x0, 1 },
+       { 0x1, 13 },
+       { 0 }

[...]

Quoted 23 lines
drivers/clk/clk-ast2700.c new file +23 -0
+               .bit_shift = 23,
+               .bit_width = 3,
+               .div_table = ast2700_clk_div_table2,
+       },
+       [SCU0_CLK_GATE_MCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "mclk-gate",
+               .parent_names = (const char *[]){ "soc0-mpll", },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 0,
+               .flags = CLK_IS_CRITICAL,
+       },
+       [SCU0_CLK_GATE_ECLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "eclk-gate",
+               .parent_names = (const char *[]){  },
+               .reg = SCU0_CLK_STOP,
+               .clk_idx = 1,
+       },
+       [SCU0_CLK_GATE_2DCLK] = {
+               .type = CLK_GATE_ASPEED,
+               .name = "gclk-gate",
+               .parent_names = (const char *[]){  },
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

This has no parent? Why is parent_names set to an empty array?

Due to I use clk->parent_names[0] for clk_hw_register_gate, const char

*name parameter input.

Quoted 1 line

If null, that will cause panic for NULL point.

But the parent is NULL? How many parents does this clk have?

I will remove this in array.
I will do parent_names = parent ? &parent->name : NULL; to check null.

Quoted 19 lines
Quoted 10 lines
Quoted 6 lines

drivers/clk/clk-ast2700.c line 1420

Quoted 4 lines
drivers/clk/clk-ast2700.c new file +2 -0
+       if (!clk_data)
+               return devm_of_platform_populate(dev);

What is being populated? Isn't there always clk_data?

Yes, it is always clk_data, I will modify to be following, is it ok? If(!clk_data)

        Return -ENODEV;

Sure.

Quoted 2 lines
Quoted 2 lines

Please don't use strings for parent_names. Use clk_hw pointers or DT

indices.

Quoted 1 line

Use clk_pareent_data is it ok ?

Yes.

maintainer
#8 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-12-01 19:12:01)

Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines

Subject: Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-27 22:30:18)

Quoted 6 lines
drivers/clk/clk-ast2700.c new file +1 -0
new file mode 100644 index 000000000000..db9ee5031b7c
@@ -0,0 +1,1513 @@
+// SPDX-License-Identifier: GPL-2.0

[...]

Quoted 8 lines
Quoted 5 lines

drivers/clk/clk-ast2700.c line 73

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +3 -0
+struct ast2700_clk_info {
+       const char *name;
+       const char * const *parent_names;

Please don't use strings for parent names.

Sorry, do you mean use clk_parent_data struct for parent?
+const struct clk_parent_data parent; /* For gate */
+const struct clk_parent_data *parents; /*

Quoted 6 lines
Quoted 3 lines

For mux */

Yes.

And I find a better way for parent_data. The following is my modification. And parent_data will be union data structure. Like following. Is this good direction?

Looks OK.

Quoted 38 lines
#define DIVIDER_CLK(_id, _name, _parent, _reg, _shift, _width, _div_table) \
        [_id] = { \
                .type = CLK_DIVIDER, \
                .name = _name, \
                .data = { \
                        .div = { \
                                .parent = _parent, \
                                .reg = _reg, \
                                .bit_shift = _shift, \
                                .bit_width = _width, \
                                .div_table = _div_table, \
                        }, \
                }, \
        }
struct ast2700_clk_info {
        const char *name;
        u8 clk_idx;
        u32 reg;
        u32 type;
        union {
                struct ast2700_clk_fixed_factor_data factor;
                struct ast2700_clk_fixed_rate_data rate;
                struct ast2700_clk_gate_data gate;
                struct ast2700_clk_div_data div;
                struct ast2700_clk_pll_data pll;
                struct ast2700_clk_mux_data mux;
        } data;
};
struct ast2700_clk_div_data {
        const struct clk_div_table *div_table;
        const struct clk_parent_data *parent;
        u8 bit_shift;
        u8 bit_width;
        u32 reg;
};
Quoted 3 lines

static const struct ast2700_clk_info ast2700_scu0_clk_info[] __initconst = {
...........................

        DIVIDER_CLK(SCU0_CLK_AHB, "soc0-ahb", soc0_ahbmux,

Can you also show what soc0_ahbmux is?

Quoted 35 lines
                    SCU0_HWSTRAP1, 5, 2, ast2700_hclk_div_table),

......................

Quoted 33 lines
Quoted 32 lines
Quoted 17 lines
Quoted 16 lines
drivers/clk/clk-ast2700.c new file +13 -0
+       const struct clk_div_table *div_table;
+       unsigned long fixed_rate;
+       unsigned int mult;
+       unsigned int div;
+       u32 reg;
+       u32 flags;
+       u32 type;
+       u8 clk_idx;
+       u8 bit_shift;
+       u8 bit_width;
+       u8 num_parents;
+};
+

[...]

Quoted 12 lines

drivers/clk/clk-ast2700.c line 144

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+static const struct clk_div_table ast2700_clk_div_table2[] = {
+       { 0x0, 2 },
+       { 0x1, 4 },
+       { 0x2, 6 },
+       { 0x3, 8 },
+       { 0x4, 10 },
+       { 0x5, 12 },
+       { 0x6, 14 },
+       { 0x7, 16 },

Isn't this the default divider setting for struct clk_divider?

Sorry, I don't catch your point.
the SoC do have default divider setting. But it can be modified. And also have different divider table setting.

Quoted 8 lines
Quoted 2 lines

I mean that this is the way that struct clk_divider works already. So you don't need to make the clk_div_table array for what is supported in code.

Sorry, I understand your point. But I trace the code didn't get any clue. "clk_divider work already". finally function call will be __clk_hw_register_divider
https://github.com/torvalds/linux/blob/master/drivers/clk/clk-divider.c#L589
It still need table point need to address. Can you give me more direction or example?

The 'table' member is optional. When the table is NULL, we treat each number that fits into the divider field width as a divider. It may be CLK_DIVIDER_EVEN_INTEGERS that you have here though.

author maintainer
#9 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoted 71 lines

Subject: RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-12-01 19:12:01)

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

Subject: Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-10-27 22:30:18)

Quoted 7 lines
(quoted diff) +0 -0

b/drivers/clk/clk-ast2700.c new file mode 100644 index 000000000000..db9ee5031b7c

drivers/clk/clk-ast2700.c new file +1 -0
@@ -0,0 +1,1513 @@
+// SPDX-License-Identifier: GPL-2.0

[...]

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

drivers/clk/clk-ast2700.c line 73

Quoted 3 lines
drivers/clk/clk-ast2700.c new file +3 -0
+struct ast2700_clk_info {
+       const char *name;
+       const char * const *parent_names;

Please don't use strings for parent names.

Sorry, do you mean use clk_parent_data struct for parent?
+const struct clk_parent_data parent; /* For

gate */

Quoted 1 line
Quoted 1 line
Quoted 1 line
        +const struct clk_parent_data   *parents;

/*

Quoted 6 lines
Quoted 3 lines

For mux */

Yes.

And I find a better way for parent_data. The following is my modification. And parent_data will be union data structure. Like following. Is this good direction?

Looks OK.

Quoted 38 lines
#define DIVIDER_CLK(_id, _name, _parent, _reg, _shift, _width, _div_table) \
        [_id] = { \
                .type = CLK_DIVIDER, \
                .name = _name, \
                .data = { \
                        .div = { \
                                .parent = _parent, \
                                .reg = _reg, \
                                .bit_shift = _shift, \
                                .bit_width = _width, \
                                .div_table = _div_table, \
                        }, \
                }, \
        }
struct ast2700_clk_info {
        const char *name;
        u8 clk_idx;
        u32 reg;
        u32 type;
        union {
                struct ast2700_clk_fixed_factor_data factor;
                struct ast2700_clk_fixed_rate_data rate;
                struct ast2700_clk_gate_data gate;
                struct ast2700_clk_div_data div;
                struct ast2700_clk_pll_data pll;
                struct ast2700_clk_mux_data mux;
        } data;
};
struct ast2700_clk_div_data {
        const struct clk_div_table *div_table;
        const struct clk_parent_data *parent;
        u8 bit_shift;
        u8 bit_width;
        u32 reg;
};
Quoted 5 lines
Quoted 3 lines

static const struct ast2700_clk_info ast2700_scu0_clk_info[] __initconst = { ...........................

        DIVIDER_CLK(SCU0_CLK_AHB, "soc0-ahb", soc0_ahbmux,

Can you also show what soc0_ahbmux is?

It will be following.

static const struct clk_parent_data soc0_ahbmux[] = {
	{ .fw_name = "soc0-ahbmux", .name = "soc0-ahbmux" },
};
Quoted 48 lines
Quoted 38 lines
                    SCU0_HWSTRAP1, 5, 2, ast2700_hclk_div_table),

......................

Quoted 35 lines
Quoted 29 lines
Quoted 17 lines
Quoted 16 lines
drivers/clk/clk-ast2700.c new file +13 -0
+       const struct clk_div_table *div_table;
+       unsigned long fixed_rate;
+       unsigned int mult;
+       unsigned int div;
+       u32 reg;
+       u32 flags;
+       u32 type;
+       u8 clk_idx;
+       u8 bit_shift;
+       u8 bit_width;
+       u8 num_parents;
+};
+

[...]

Quoted 12 lines

drivers/clk/clk-ast2700.c line 144

Quoted 10 lines
drivers/clk/clk-ast2700.c new file +10 -0
+
+static const struct clk_div_table ast2700_clk_div_table2[] = {
+       { 0x0, 2 },
+       { 0x1, 4 },
+       { 0x2, 6 },
+       { 0x3, 8 },
+       { 0x4, 10 },
+       { 0x5, 12 },
+       { 0x6, 14 },
+       { 0x7, 16 },

Isn't this the default divider setting for struct clk_divider?

Quoted 3 lines

Sorry, I don't catch your point.
the SoC do have default divider setting. But it can be modified. And also have different divider table setting.

I mean that this is the way that struct clk_divider works already. So you don't need to make the clk_div_table array for what is supported in

code.

Quoted 2 lines

Sorry, I understand your point. But I trace the code didn't get any clue.

"clk_divider work already".

Quoted 5 lines

finally function call will be __clk_hw_register_divider
https://github.com/torvalds/linux/blob/master/drivers/clk/clk-divider.
c#L589 It still need table point need to address. Can you give me more direction or example?

Quoted 3 lines

The 'table' member is optional. When the table is NULL, we treat each number that fits into the divider field width as a divider. It may be CLK_DIVIDER_EVEN_INTEGERS that you have here though.

Got it, will use this flag.

maintainer
#10 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-12-04 16:48:42)

Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
struct ast2700_clk_info {
        const char *name;
        u8 clk_idx;
        u32 reg;
        u32 type;
        union {
                struct ast2700_clk_fixed_factor_data factor;
                struct ast2700_clk_fixed_rate_data rate;
                struct ast2700_clk_gate_data gate;
                struct ast2700_clk_div_data div;
                struct ast2700_clk_pll_data pll;
                struct ast2700_clk_mux_data mux;
        } data;
};
struct ast2700_clk_div_data {
        const struct clk_div_table *div_table;
        const struct clk_parent_data *parent;
        u8 bit_shift;
        u8 bit_width;
        u32 reg;
};

static const struct ast2700_clk_info ast2700_scu0_clk_info[] __initconst = { ...........................

        DIVIDER_CLK(SCU0_CLK_AHB, "soc0-ahb", soc0_ahbmux,
Quoted 6 lines
Quoted 1 line

Can you also show what soc0_ahbmux is?

It will be following.

static const struct clk_parent_data soc0_ahbmux[] = {
        { .fw_name = "soc0-ahbmux", .name = "soc0-ahbmux" },
};

Instead of that, please use only the index.

static const struct clk_parent_data soc0_ahbmux[] = {
{ .index = <number from DT binding> },
};

author maintainer
#11 lore raw

RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoted 33 lines

Subject: RE: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

Quoting Ryan Chen (2024-12-04 16:48:42)

Quoted 30 lines
Quoted 23 lines
Quoted 23 lines
struct ast2700_clk_info {
        const char *name;
        u8 clk_idx;
        u32 reg;
        u32 type;
        union {
                struct ast2700_clk_fixed_factor_data factor;
                struct ast2700_clk_fixed_rate_data rate;
                struct ast2700_clk_gate_data gate;
                struct ast2700_clk_div_data div;
                struct ast2700_clk_pll_data pll;
                struct ast2700_clk_mux_data mux;
        } data;
};
struct ast2700_clk_div_data {
        const struct clk_div_table *div_table;
        const struct clk_parent_data *parent;
        u8 bit_shift;
        u8 bit_width;
        u32 reg;
};
Quoted 5 lines
Quoted 3 lines

static const struct ast2700_clk_info ast2700_scu0_clk_info[] __initconst = { ...........................

        DIVIDER_CLK(SCU0_CLK_AHB, "soc0-ahb", soc0_ahbmux,

Can you also show what soc0_ahbmux is?

It will be following.

Quoted 7 lines
Quoted 2 lines
static const struct clk_parent_data soc0_ahbmux[] = {
        { .fw_name = "soc0-ahbmux", .name = "soc0-ahbmux" }, };

Instead of that, please use only the index.

 static const struct clk_parent_data soc0_ahbmux[] = {
         { .index = <number from DT binding> },  };

Sorry, if I use index instead, It can’t get parent data name for devm_clk_hw_register_fixed_factor parent_name parameters. Does there have reference driver use index implement?

In probe function I implement for function for each clk register. For example CLK_DIVIDER
Use div->parent->name get parent name for parameter.

			hws[i] = devm_clk_hw_register_divider_table(dev, clk->name,
								    div->parent->name, 0,
								    reg, div->bit_shift,
								    div->bit_width, 0,
								    div->div_table,
								    &clk_ctrl->lock);

Full implement is following.

	for (i = 0; i < clk_data->nr_clks; i++) {
		const struct ast2700_clk_info *clk = &clk_data->clk_info[i];
		void __iomem *reg = clk_ctrl->base + clk->reg;

		if (clk->type == CLK_FIXED) {
			const struct ast2700_clk_fixed_rate_data *fixed_rate = &clk->data.rate;

			hws[i] = devm_clk_hw_register_fixed_rate(dev, clk->name, NULL, 0,
								 fixed_rate->fixed_rate);
		} else if (clk->type == CLK_FIXED_FACTOR) {
			const struct ast2700_clk_fixed_factor_data *factor = &clk->data.factor;

			hws[i] = devm_clk_hw_register_fixed_factor(dev, clk->name,
								   factor->parent->name,
								   0, factor->mult, factor->div);
		} else if (clk->type == DCLK_FIXED) {
			const struct ast2700_clk_pll_data *pll = &clk->data.pll;

			reg = clk_ctrl->base + pll->reg;
			hws[i] = ast2700_clk_hw_register_dclk(i, reg, clk->name, clk_ctrl);
		} else if (clk->type == CLK_HPLL) {
			const struct ast2700_clk_pll_data *pll = &clk->data.pll;

			reg = clk_ctrl->base + pll->reg;
			hws[i] = ast2700_clk_hw_register_hpll(i, reg, clk->name,
							      pll->parent->name, clk_ctrl);
		} else if (clk->type == CLK_PLL) {
			const struct ast2700_clk_pll_data *pll = &clk->data.pll;

			reg = clk_ctrl->base + pll->reg;
			hws[i] = ast2700_clk_hw_register_pll(i, reg, clk->name,
							     pll->parent->name, clk_ctrl);
		} else if (clk->type == CLK_UART_PLL) {
			const struct ast2700_clk_pll_data *pll = &clk->data.pll;

			reg = clk_ctrl->base + pll->reg;
			hws[i] = ast2700_clk_hw_register_uartpll(i, reg, clk->name,
								 pll->parent->name, clk_ctrl);
		} else if (clk->type == CLK_MUX) {
			const struct ast2700_clk_mux_data *mux = &clk->data.mux;

			reg = clk_ctrl->base + mux->reg;
			hws[i] = devm_clk_hw_register_mux_parent_data_table(dev, clk->name,
									    mux->parents,
									    mux->num_parents, 0,
									    reg, mux->bit_shift,
									    mux->bit_width, 0,
									    NULL, &clk_ctrl->lock);
		} else if (clk->type == CLK_MISC) {
			const struct ast2700_clk_pll_data *misc = &clk->data.pll;

			reg = clk_ctrl->base + misc->reg;
			hws[i] = ast2700_clk_hw_register_misc(i, reg, clk->name,
							      misc->parent->name, clk_ctrl);
		} else if (clk->type == CLK_DIVIDER) {
			const struct ast2700_clk_div_data *div = &clk->data.div;

			reg = clk_ctrl->base + div->reg;
			hws[i] = devm_clk_hw_register_divider_table(dev, clk->name,
								    div->parent->name, 0,
								    reg, div->bit_shift,
								    div->bit_width, 0,
								    div->div_table,
								    &clk_ctrl->lock);
		} else if (clk->type == CLK_GATE_ASPEED) {
			const struct ast2700_clk_gate_data *gate = &clk->data.gate;

			reg = clk_ctrl->base + gate->reg;
			hws[i] = ast2700_clk_hw_register_gate(dev, clk->name, gate->parent,
							      reg, gate->bit, gate->flags, 0);

		} else {
			const struct ast2700_clk_gate_data *gate = &clk->data.gate;

			reg = clk_ctrl->base + gate->reg;
			hws[i] = devm_clk_hw_register_gate_parent_data(dev, clk->name, gate->parent,
								       0, reg, clk->clk_idx, 0,
								       &clk_ctrl->lock);
		}

		if (IS_ERR(hws[i]))
			return PTR_ERR(hws[i]);
	}
maintainer
#12 lore raw

Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

In reply to Ryan Chen

One more thing. Please remove the period from the subject. No other patch in this series has a period at the end.

#13 lore raw

Re: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.

In reply to Ryan Chen
kernel test robot noticed the following build errors:

Hi Ryan,

kernel test robot noticed the following build errors:

[auto build test ERROR on clk/clk-next]
[also build test ERROR on pza/reset/next lee-mfd/for-mfd-next lee-leds/for-leds-next linus/master lee-mfd/for-mfd-fixes v6.12-rc5 next-20241030] [cannot apply to pza/imx-drm/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan-Chen/dt-bindings-mfd-aspeed-support-for-AST2700/20241028-133255
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
patch link:    https://lore.kernel.org/r/20241028053018.2579200-4-ryan_chen%40aspeedtech.com
patch subject: [PATCH v7 3/3] clk: aspeed: add AST2700 clock driver.
config: csky-randconfig-001-20241031 (https://download.01.org/0day-ci/archive/20241031/[email protected]/config)
compiler: csky-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241031/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

csky-linux-ld: drivers/clk/clk-ast2700.o: in function `ast2700_soc_clk_probe':
clk-ast2700.c:(.text+0x530): undefined reference to `aspeed_reset_controller_register'

>> csky-linux-ld: clk-ast2700.c:(.text+0x558): undefined reference to `aspeed_reset_controller_register'
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki