Add clock support for SpacemiT K3 SoC
Subsystems (4)
cover Add clock support for SpacemiT K3 SoC
I'm marking this series as RFC for now, as the driver is based on vendor code, and only tested on FPGA, the production SoC chip isn't ready yet.
The SpacemiT K3 SoC's CCU (clock control unit) is similar to old K1 generation, the clock and reset functionalities are distributed across several IP blocks, therefore, we model them as several clock tree accordingly.
The PLL clocks has changed register setting layout, so introduce a PLLA type. Some gate clocks has inverted enable/disable logic which writing 1 to disable, while writing 0 to enable.
---
Yixun Lan (4):
dt-bindings: soc: spacemit: add k3 syscon compatible
clk: spacemit: ccu_mix: add inverted enable gate clock
clk: spacemit: ccu_pll: add plla type clock
clk: spacemit: k3: add the clock tree
.../devicetree/bindings/clock/spacemit,k1-pll.yaml | 9 +- .../bindings/soc/spacemit/spacemit,k1-syscon.yaml | 13 +- drivers/clk/spacemit/Kconfig | 6 + drivers/clk/spacemit/Makefile | 11 +- drivers/clk/spacemit/ccu-k3.c | 1641 ++++++++++++++++++++ drivers/clk/spacemit/ccu_common.h | 1 + drivers/clk/spacemit/ccu_mix.c | 12 +- drivers/clk/spacemit/ccu_mix.h | 12 + drivers/clk/spacemit/ccu_pll.c | 117 ++ drivers/clk/spacemit/ccu_pll.h | 57 +- include/dt-bindings/clock/spacemit,k3-clocks.h | 390 +++++ include/soc/spacemit/ccu.h | 18 + include/soc/spacemit/k1-syscon.h | 12 +- include/soc/spacemit/k3-syscon.h | 273 ++++ 14 files changed, 2539 insertions(+), 33 deletions(-)
---
base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
change-id: 20251204-k3-clk-db2018389ae3
Best regards,
Signature · 1 line
Yixun Lan
RFC PATCH 1/4 dt-bindings: soc: spacemit: add k3 syscon compatible
The SpacemiT K3 SoC clock IP is scattered over several different blocks, which are APBC, APBS, APMU, DCIU, MPMU, all of them are capable of generating clock and reset signals. APMU and MPMU have additional Power Domain management functionality.
Following is a brief list that shows devices managed in each block:
APBC: UART, GPIO, PWM, SPI, TIMER, I2S, IR, DR, TSEN, IPC, CAN
APBS: various PPL clocks control
APMU: CCI, CPU, CSI, ISP, LCD, USB, QSPI, DMA, VPU, GPU, DSI, PCIe, EMAC..
DCID: SRAM, DMA, TCM
MPMU: various PLL1 derived clocks, UART, WATCHDOG, I2S
--- .../devicetree/bindings/clock/spacemit,k1-pll.yaml | 9 +- .../bindings/soc/spacemit/spacemit,k1-syscon.yaml | 13 +- include/dt-bindings/clock/spacemit,k3-clocks.h | 390 +++++++++++++++++++++ 3 files changed, 407 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml +6 -3
@@ -4,14 +4,17 @@ $id: http://devicetree.org/schemas/clock/spacemit,k1-pll.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: SpacemiT K1 PLL +title: SpacemiT K1/K3 PLL maintainers: - Haylen Chu <[email protected]> properties: compatible: - const: spacemit,k1-pll + contains: + enum: + - spacemit,k1-pll + - spacemit,k3-pll reg: maxItems: 1
@@ -28,7 +31,7 @@ properties: "#clock-cells": const: 1 description: - See <dt-bindings/clock/spacemit,k1-syscon.h> for valid indices. + See corresponding file under <dt-bindings/clock/> for valid indices. required: - compatible
Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml +11 -2
@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/soc/spacemit/spacemit,k1-syscon.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: SpacemiT K1 SoC System Controller +title: SpacemiT K1/K3 SoC System Controller maintainers: - Haylen Chu <[email protected]>
@@ -22,6 +22,10 @@ properties: - spacemit,k1-syscon-rcpu - spacemit,k1-syscon-rcpu2 - spacemit,k1-syscon-apbc2 + - spacemit,k3-syscon-apbc + - spacemit,k3-syscon-apmu + - spacemit,k3-syscon-dciu + - spacemit,k3-syscon-mpmu reg: maxItems: 1
@@ -39,7 +43,7 @@ properties: "#clock-cells": const: 1 description: - See <dt-bindings/clock/spacemit,k1-syscon.h> for valid indices. + See corresponding file under <dt-bindings/clock/> for valid indices. "#power-domain-cells": const: 1
@@ -60,6 +64,8 @@ allOf: enum: - spacemit,k1-syscon-apmu - spacemit,k1-syscon-mpmu + - spacemit,k3-syscon-apmu + - spacemit,k3-syscon-mpmu then: required: - "#power-domain-cells"
@@ -74,6 +80,9 @@ allOf: - spacemit,k1-syscon-apbc - spacemit,k1-syscon-apmu - spacemit,k1-syscon-mpmu + - spacemit,k3-syscon-apbc + - spacemit,k3-syscon-apmu + - spacemit,k3-syscon-mpmu then: required: - clocks
include/dt-bindings/clock/spacemit,k3-clocks.h new file +390 -0
390 lines not on this page · raw message
Signature · 1 line
2.51.0
Rob Herring (Arm)
maintainerRe: [PATCH RFC 1/4] dt-bindings: soc: spacemit: add k3 syscon compatible
Quoted 13 lines · Yixun Lan
The SpacemiT K3 SoC clock IP is scattered over several different blocks, which are APBC, APBS, APMU, DCIU, MPMU, all of them are capable of generating clock and reset signals. APMU and MPMU have additional Power Domain management functionality.
Following is a brief list that shows devices managed in each block:
APBC: UART, GPIO, PWM, SPI, TIMER, I2S, IR, DR, TSEN, IPC, CAN
APBS: various PPL clocks control
APMU: CCI, CPU, CSI, ISP, LCD, USB, QSPI, DMA, VPU, GPU, DSI, PCIe, EMAC..
DCID: SRAM, DMA, TCM
MPMU: various PLL1 derived clocks, UART, WATCHDOG, I2S
Quoted 7 lines
Signed-off-by Yixun Lan <[email protected]>--- .../devicetree/bindings/clock/spacemit,k1-pll.yaml | 9 +- .../bindings/soc/spacemit/spacemit,k1-syscon.yaml | 13 +- include/dt-bindings/clock/spacemit,k3-clocks.h | 390 +++++++++++++++++++++ 3 files changed, 407 insertions(+), 5 deletions(-)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/clock/spacemit,k1-pll.yaml:14:7: [warning] wrong indentation: expected 4 but found 6 (indentation)
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
RFC PATCH 2/4 clk: spacemit: ccu_mix: add inverted enable gate clock
In reply to Yixun LanK3 SoC has the clock IP which support to write value 0 for enabling the clock, while write 1 for disabling it, thus the enable BIT is inverted. So, introduce a flag to support the inverted gate clock.
--- drivers/clk/spacemit/ccu_mix.c | 12 ++++++++---- drivers/clk/spacemit/ccu_mix.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-)
drivers/clk/spacemit/ccu_mix.c +8 -4
@@ -16,17 +16,19 @@static void ccu_gate_disable (struct clk_hw *hw) {struct ccu_mix *mix =hw_to_ccu_mix (hw); +struct ccu_gate_config *gate = &mix->gate; +u32 val = gate->inverted ? gate->mask :0 ; -ccu_update (&mix->common, ctrl, mix->gate.mask,0 ); +ccu_update (&mix->common, ctrl, gate->mask, val); }static int ccu_gate_enable (struct clk_hw *hw) {struct ccu_mix *mix =hw_to_ccu_mix (hw);struct ccu_gate_config *gate = &mix->gate; +u32 val = gate->inverted ?0 : gate->mask; -ccu_update (&mix->common, ctrl, gate->mask, gate->mask); - +ccu_update (&mix->common, ctrl, gate->mask, val);return 0 ; }
@@ -34,8 +36,10 @@ static int ccu_gate_is_enabled(struct clk_hw *hw) {struct ccu_mix *mix =hw_to_ccu_mix (hw);struct ccu_gate_config *gate = &mix->gate; +u32 tmp =ccu_read (&mix->common, ctrl) & gate->mask; +u32 val = gate->inverted ?0 : gate->mask; -return (ccu_read (&mix->common, ctrl) & gate->mask) == gate->mask; +return !!(tmp == val); } static unsigned long ccu_factor_recalc_rate(struct clk_hw *hw,
drivers/clk/spacemit/ccu_mix.h +12 -0
@@ -16,9 +16,11 @@* * @mask: Mask to enable the gate. Some clocks may have more than one bit * set in this field. +* @inverted: Enable bit is inverted, 1 - disable clock, 0 - enable clock */ struct ccu_gate_config {u32 mask; +bool inverted; };struct ccu_factor_config {
@@ -48,6 +50,7 @@ struct ccu_mix {#define CCU_FACTOR_INIT (_div, _mul) { .div = _div, .mul = _mul }#define CCU_MUX_INIT (_shift, _width) { .shift = _shift, .width = _width }#define CCU_DIV_INIT (_shift, _width) { .shift = _shift, .width = _width } +#define CCU_GATE_FLAGS_INIT (_mask, _inverted) { .mask = _mask, .inverted = _inverted }#define CCU_PARENT_HW (_parent) { .hw = &_parent.common.hw }#define CCU_PARENT_NAME (_name) { .fw_name = #_name }
@@ -101,6 +104,15 @@ static struct ccu_mix _name = { \ } \ } +#define CCU_GATE_FLAGS_DEFINE (_name, _parent, _reg_ctrl, _mask_gate, _inverted, _flags) \ +static struct ccu_mix _name = { \ + .gate = CCU_GATE_FLAGS_INIT(_mask_gate, _inverted), \ + .common = { \ + .reg_ctrl = _reg_ctrl, \ + CCU_MIX_INITHW(_name, _parent, spacemit_ccu_gate_ops, _flags), \ + } \ +} +#define CCU_FACTOR_GATE_FLAGS_DEFINE (_name, _parent, _reg_ctrl, _mask_gate, _div, \ _mul, _flags) \ static struct ccu_mix _name = { \
Signature · 1 line
2.51.0
Re: [PATCH RFC 2/4] clk: spacemit: ccu_mix: add inverted enable gate clock
Quoted 24 lines · Yixun Lan
K3 SoC has the clock IP which support to write value 0 for enabling the clock, while write 1 for disabling it, thus the enable BIT is inverted. So, introduce a flag to support the inverted gate clock.
Signed-off-by Yixun Lan <[email protected]>--- drivers/clk/spacemit/ccu_mix.c | 12 ++++++++---- drivers/clk/spacemit/ccu_mix.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-)drivers/clk/spacemit/ccu_mix.c +3
-1@@ -16,17 +16,19 @@static void ccu_gate_disable (struct clk_hw *hw) {struct ccu_mix *mix =hw_to_ccu_mix (hw); +struct ccu_gate_config *gate = &mix->gate; +u32 val = gate->inverted ? gate->mask :0 ; -ccu_update (&mix->common, ctrl, mix->gate.mask,0 ); +ccu_update (&mix->common, ctrl, gate->mask, val); }
drivers/clk/spacemit/ccu_mix.c line 31
Quoted 10 lines
drivers/clk/spacemit/ccu_mix.c +2
-2static int ccu_gate_enable (struct clk_hw *hw) {struct ccu_mix *mix =hw_to_ccu_mix (hw);struct ccu_gate_config *gate = &mix->gate; +u32 val = gate->inverted ?0 : gate->mask; -ccu_update (&mix->common, ctrl, gate->mask, gate->mask); - +ccu_update (&mix->common, ctrl, gate->mask, val);
An unrelated blank line gets removed here, is this intended?
drivers/clk/spacemit/ccu_mix.c line 33
Quoted 2 lines
drivers/clk/spacemit/ccu_mix.c +0
-0return 0 ; }
Regards,
Yao Zi
RFC PATCH 3/4 clk: spacemit: ccu_pll: add plla type clock
In reply to Yixun LanIntroduce a new clock PLLA for SpacemiT's K3 SoC which has a different register layout comparing to previous PPL type. And, It is configured by swcr1, swcr3 and swcr2 BIT[15:8].
--- drivers/clk/spacemit/ccu_common.h | 1 + drivers/clk/spacemit/ccu_pll.c | 117 ++++++++++++++++++++++++++++++++++++++ drivers/clk/spacemit/ccu_pll.h | 57 +++++++++++++++---- 3 files changed, 165 insertions(+), 10 deletions(-)
drivers/clk/spacemit/ccu_common.h +1 -0
@@ -24,6 +24,7 @@ struct ccu_common {/* For PLL */ struct {u32 reg_swcr1; +u32 reg_swcr2;u32 reg_swcr3; }; };
drivers/clk/spacemit/ccu_pll.c +117 -0
132 lines not on this page · raw message
drivers/clk/spacemit/ccu_pll.h +47 -10
103 lines not on this page · raw message
Signature · 1 line
2.51.0
RFC PATCH 4/4 clk: spacemit: k3: add the clock tree
In reply to Yixun LanAdd clock support to SpacemiT K3 SoC, the clock tree consist of several blocks which are APBC, APBS, APMU, DCIU, MPUM.
--- drivers/clk/spacemit/Kconfig | 6 + drivers/clk/spacemit/Makefile | 11 +- drivers/clk/spacemit/ccu-k3.c | 1641 ++++++++++++++++++++++++++++++++++++++ include/soc/spacemit/ccu.h | 18 + include/soc/spacemit/k1-syscon.h | 12 +- include/soc/spacemit/k3-syscon.h | 273 +++++++ 6 files changed, 1947 insertions(+), 14 deletions(-)
drivers/clk/spacemit/Kconfig +6 -0
@@ -16,4 +16,10 @@ config SPACEMIT_K1_CCU help Support for clock controller unit in SpacemiT K1 SoC. +config SPACEMIT_K3_CCU + tristate "Support for SpacemiT K3 SoC" + depends on ARCH_SPACEMIT || COMPILE_TEST + help + Support for clock controller unit in SpacemiT K3 SoC. + endif
drivers/clk/spacemit/Makefile +8 -3
@@ -1,5 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_SPACEMIT_K1_CCU) = spacemit-ccu-k1.o -spacemit-ccu-k1-y = ccu_pll.o ccu_mix.o ccu_ddn.o -spacemit-ccu-k1-y += ccu-k1.o +obj-$(CONFIG_SPACEMIT_CCU) += spacemit-ccu.o +spacemit-ccu-objs := ccu_pll.o ccu_mix.o ccu_ddn.o + +obj-$(CONFIG_SPACEMIT_K1_CCU) += spacemit-ccu-k1.o +spacemit-ccu-k1-y := ccu-k1.o + +obj-$(CONFIG_SPACEMIT_K3_CCU) += spacemit-ccu-k3.o +spacemit-ccu-k3-y := ccu-k3.o
drivers/clk/spacemit/ccu-k3.c new file +1641 -0
1,641 lines not on this page · raw message
include/soc/spacemit/ccu.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __SOC_SPACEMIT_CCU_H__ +#define __SOC_SPACEMIT_CCU_H__ + +/* Auxiliary device used to represent a CCU reset controller */ +struct spacemit_ccu_adev { +struct auxiliary_device adev; +struct regmap *regmap; +}; + +static inline struct spacemit_ccu_adev * +to_spacemit_ccu_adev (struct auxiliary_device *adev) +{ + return container_of(adev, struct spacemit_ccu_adev, adev); +} + +#endif /* __SOC_SPACEMIT_CCU_H__ */
include/soc/spacemit/k1-syscon.h +1 -11
@@ -5,17 +5,7 @@#ifndef __SOC_K1_SYSCON_H__#define __SOC_K1_SYSCON_H__ -/* Auxiliary device used to represent a CCU reset controller */ -struct spacemit_ccu_adev { -struct auxiliary_device adev; -struct regmap *regmap; -}; - -static inline struct spacemit_ccu_adev * -to_spacemit_ccu_adev (struct auxiliary_device *adev) -{ - return container_of(adev, struct spacemit_ccu_adev, adev); -} +#include "ccu.h" /* APBS register offset */ #define APBS_PLL1_SWCR1 0x100
include/soc/spacemit/k3-syscon.h new file +273 -0
273 lines not on this page · raw message
Signature · 1 line
2.51.0
Re: [PATCH RFC 4/4] clk: spacemit: k3: add the clock tree
Quoted 12 lines · Yixun Lan
Add clock support to SpacemiT K3 SoC, the clock tree consist of several blocks which are APBC, APBS, APMU, DCIU, MPUM.
Signed-off-by Yixun Lan <[email protected]>--- drivers/clk/spacemit/Kconfig | 6 + drivers/clk/spacemit/Makefile | 11 +- drivers/clk/spacemit/ccu-k3.c | 1641 ++++++++++++++++++++++++++++++++++++++ include/soc/spacemit/ccu.h | 18 + include/soc/spacemit/k1-syscon.h | 12 +- include/soc/spacemit/k3-syscon.h | 273 +++++++ 6 files changed, 1947 insertions(+), 14 deletions(-)
...
Quoted 33 lines
drivers/clk/spacemit/ccu-k3.c new file +27
-0@@ -0,0 +1,1641 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2025 SpacemiT Technology Co. Ltd +*/ + +#include <linux/array_size.h> +#include <linux/auxiliary_bus.h> +#include <linux/clk-provider.h> +#include <linux/delay.h> +#include <linux/mfd/syscon.h> +#include <linux/minmax.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <soc/spacemit/k3-syscon.h> + +#include "ccu_common.h" +#include "ccu_pll.h" +#include "ccu_mix.h" +#include "ccu_ddn.h" + +#include <dt-bindings/clock/spacemit,k3-clocks.h> + +struct spacemit_ccu_data { +const char *reset_name; +struct clk_hw **hws; +size_t num; +};
...
Quoted 100 lines
drivers/clk/spacemit/ccu-k3.c new file +100
-0+static const struct spacemit_ccu_data k3_ccu_dciu_data = { + .reset_name ="dciu-reset" , + .hws = k3_ccu_dciu_hws, + .num =ARRAY_SIZE (k3_ccu_dciu_hws), +}; + +static int spacemit_ccu_register (struct device *dev, +struct regmap *regmap, +struct regmap *lock_regmap, +const struct spacemit_ccu_data *data) +{ +struct clk_hw_onecell_data *clk_data; +int i, ret; + +/* Nothing to do if the CCU does not implement any clocks */ +if (!data->hws) +return 0 ; + + clk_data =devm_kzalloc (dev,struct_size (clk_data, hws, data->num), +GFP_KERNEL ); +if (!clk_data) +return -ENOMEM ; + +for (i =0 ; i < data->num; i++) { +struct clk_hw *hw = data->hws[i]; +struct ccu_common *common; +const char *name; + +if (!hw) { + clk_data->hws[i] =ERR_PTR (-ENOENT ); +continue ; + } + + name = hw->init->name; + + common =hw_to_ccu_common (hw); + common->regmap = regmap; + common->lock_regmap = lock_regmap; + + ret =devm_clk_hw_register (dev, hw); +if (ret) { +dev_err (dev,"Cannot register clock %d - %s\n" , + i, name); +return ret; + } + + clk_data->hws[i] = hw; + } + + clk_data->num = data->num; + + ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_data); +if (ret) +dev_err (dev,"failed to add clock hardware provider (%d)\n" , ret); + +return ret; +} + +static void spacemit_cadev_release (struct device *dev) +{ +struct auxiliary_device *adev =to_auxiliary_dev (dev); + +kfree (to_spacemit_ccu_adev (adev)); +} + +static void spacemit_adev_unregister (void *data) +{ +struct auxiliary_device *adev = data; + +auxiliary_device_delete (adev); +auxiliary_device_uninit (adev); +} + +static int spacemit_ccu_reset_register (struct device *dev, +struct regmap *regmap, +const char *reset_name) +{ +struct spacemit_ccu_adev *cadev; +struct auxiliary_device *adev; +static u32 next_id; +int ret; + +/* Nothing to do if the CCU does not implement a reset controller */ +if (!reset_name) +return 0 ; + + cadev =devm_kzalloc (dev,sizeof (*cadev),GFP_KERNEL ); +if (!cadev) +return -ENOMEM ; + cadev->regmap = regmap; + + adev = &cadev->adev; + adev->name = reset_name; + adev->dev.parent = dev; + adev->dev.release = spacemit_cadev_release; + adev->dev.of_node = dev->of_node; + adev->id = next_id++; + + ret =auxiliary_device_init (adev); +if (ret)
drivers/clk/spacemit/ccu-k3.c line 1560
Quoted 10 lines
drivers/clk/spacemit/ccu-k3.c new file +10
-0+return ret; + + ret =auxiliary_device_add (adev); +if (ret) { +auxiliary_device_uninit (adev); +return ret; + } + +return devm_add_action_or_reset (dev, spacemit_adev_unregister, adev); +}
This piece of code looks quiet similar to types/functions with the same names in ccu-k1.c. If I'm correct, could we separate the logic into a new file and avoid duplication?
Quoted 33 lines
drivers/clk/spacemit/ccu-k3.c new file +33
-0+static int k3_ccu_probe (struct platform_device *pdev) +{ +struct regmap *base_regmap, *lock_regmap =NULL ; +const struct spacemit_ccu_data *data; +struct device *dev = &pdev->dev; +int ret; + + base_regmap =device_node_to_regmap (dev->of_node); +if (IS_ERR (base_regmap)) +return dev_err_probe (dev,PTR_ERR (base_regmap), +"failed to get regmap\n" ); +/* +* The lock status of PLLs locate in MPMU region, while PLLs themselves +* are in APBS region. Reference to MPMU syscon is required to check PLL +* status. +*/ +if (of_device_is_compatible (dev->of_node,"spacemit,k3-pll" )) { +struct device_node *mpmu =of_parse_phandle (dev->of_node,"spacemit,mpmu" ,0 ); + +if (!mpmu) +return dev_err_probe (dev, -ENODEV , +"Cannot parse MPMU region\n" ); + + lock_regmap =device_node_to_regmap (mpmu); +of_node_put (mpmu); + +if (IS_ERR (lock_regmap)) +return dev_err_probe (dev,PTR_ERR (lock_regmap), +"failed to get lock regmap\n" ); + } + + data =of_device_get_match_data (dev); +
drivers/clk/spacemit/ccu-k3.c line 1604
Quoted 10 lines
drivers/clk/spacemit/ccu-k3.c new file +10
-0+ ret =spacemit_ccu_register (dev, base_regmap, lock_regmap, data); +if (ret) +return dev_err_probe (dev, ret,"failed to register clocks\n" ); + + ret =spacemit_ccu_reset_register (dev, base_regmap, data->reset_name); +if (ret) +return dev_err_probe (dev, ret,"failed to register resets\n" ); + +return 0 ; +}
k3_ccu_probe looks quote similar to k1_ccu_probe, too. The only difference is that k3_ccu_probe checks for spacemit,k3-pll instead of spacemit,k1-pll.
We could share most of the probe code by writing a SoC-independent probe function,
int spacemit_ccu_probe(struct platform_dev *pdev, const char *pll_compatible);
and calling it in ccu-k1.c and ccu-k3.c with different pll_compatible.
Regards,
Yao Zi
Re: [PATCH RFC 4/4] clk: spacemit: k3: add the clock tree
Hi Yao,
Quoted 14 lines · Yao Zi
Quoted 12 lines · Yixun Lan
Add clock support to SpacemiT K3 SoC, the clock tree consist of several blocks which are APBC, APBS, APMU, DCIU, MPUM.
Signed-off-by Yixun Lan <[email protected]>--- drivers/clk/spacemit/Kconfig | 6 + drivers/clk/spacemit/Makefile | 11 +- drivers/clk/spacemit/ccu-k3.c | 1641 ++++++++++++++++++++++++++++++++++++++ include/soc/spacemit/ccu.h | 18 + include/soc/spacemit/k1-syscon.h | 12 +- include/soc/spacemit/k3-syscon.h | 273 +++++++ 6 files changed, 1947 insertions(+), 14 deletions(-)
...
Quoted 8 lines
drivers/clk/spacemit/ccu-k3.c line 1560
Quoted 3 lines
drivers/clk/spacemit/ccu-k3.c new file +3
-0+ +return devm_add_action_or_reset (dev, spacemit_adev_unregister, adev); +}This piece of code looks quiet similar to types/functions with the same names in
ccu-k1.c. If I'm correct, could we separate the logic into a new file and avoid duplication?
make sense, will do
Quoted 5 lines
k3_ccu_probelooks quote similar tok1_ccu_probe, too. The only difference is thatk3_ccu_probechecks for spacemit,k3-pll instead of spacemit,k1-pll.
Quoted 8 lines
We could share most of the probe code by writing a SoC-independent probe function,
int spacemit_ccu_probe(struct platform_dev *pdev, const char *pll_compatible);and calling it in
ccu-k1.candccu-k3.cwith differentpll_compatible.
ditto
thanks
Signature · 1 line
Yixun Lan (dlan)
kernel test robot
build botRe: [PATCH RFC 4/4] clk: spacemit: k3: add the clock tree
In reply to Yixun Lankernel test robot noticed the following build errors:
Hi Yixun,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on 7d0a66e4bb9081d75c82ec4957c50034cb0ea449]
url: https://github.com/intel-lab-lkp/linux/commits/Yixun-Lan/dt-bindings-soc-spacemit-add-k3-syscon-compatible/20251211-092723 base: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 patch link: https://lore.kernel.org/r/20251211-k3-clk-v1-4-8ee47c70c5bc%40gentoo.org patch subject: [PATCH RFC 4/4] clk: spacemit: k3: add the clock tree config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20251212/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251212/[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 >>):
drivers/clk/spacemit/ccu-k3.c: In function 'spacemit_cadev_release':
>> drivers/clk/spacemit/ccu-k3.c:1513:9: error: implicit declaration of function 'kfree' [-Wimplicit-function-declaration]
1513 | kfree(to_spacemit_ccu_adev(adev));
| ^~~~~vim +/kfree +1513 drivers/clk/spacemit/ccu-k3.c
1508
1509 static void spacemit_cadev_release(struct device *dev)
1510 {
1511 struct auxiliary_device *adev = to_auxiliary_dev(dev);
1512
> 1513 kfree(to_spacemit_ccu_adev(adev));
1514 }
1515
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH RFC 4/4] clk: spacemit: k3: add the clock tree
In reply to Yixun Lankernel test robot noticed the following build errors:
Hi Yixun,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on 7d0a66e4bb9081d75c82ec4957c50034cb0ea449]
url: https://github.com/intel-lab-lkp/linux/commits/Yixun-Lan/dt-bindings-soc-spacemit-add-k3-syscon-compatible/20251211-092723 base: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 patch link: https://lore.kernel.org/r/20251211-k3-clk-v1-4-8ee47c70c5bc%40gentoo.org patch subject: [PATCH RFC 4/4] clk: spacemit: k3: add the clock tree config: x86_64-allmodconfig (https://download.01.org/0day-ci/archive/20251213/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251213/[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 >>, old ones prefixed by <<):
ERROR: modpost: missing MODULE_LICENSE() in drivers/clk/spacemit/spacemit-ccu.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/spacemit/spacemit-ccu.o
>> ERROR: modpost: "spacemit_ccu_pll_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_factor_gate_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_factor_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_gate_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_ddn_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_div_gate_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_mux_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_mux_gate_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_mux_div_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined! >> ERROR: modpost: "spacemit_ccu_div_ops" [drivers/clk/spacemit/spacemit-ccu-k1.ko] undefined!
WARNING: modpost: suppressed 11 unresolved symbol warnings because there were too many)
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki