* [PATCH v3 0/4] clk: spacemit: refactor common ccu driver
@ 2026-01-03 7:26 Yixun Lan
2026-01-03 7:26 ` [PATCH v3 1/4] clk: spacemit: prepare common ccu header Yixun Lan
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Yixun Lan @ 2026-01-03 7:26 UTC (permalink / raw)
To: Stephen Boyd, Michael Turquette, Philipp Zabel
Cc: Alex Elder, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk,
linux-riscv, spacemit, Yixun Lan, Yao Zi
The goal here is to refactor the clock driver to extract common part, and
reuse it, so in the future, we can maximize the source code usage once
adding new clock driver (specifically, for the SpacemiT K3 SoC here)
Since reset driver register via auxiliary bus which requires a adjustment
of the auxiliary device id accordingly.
This patch will depend on Kconfig fix for building modules [1], and the idea
come from K3 clock's review[2]
Please note, Patch 1 is needed for both clock and reset driver, so extract it
out as single independent patch. Then it can be pulled into both subsystem.
Link: https://lore.kernel.org/all/20251219012819.440972-1-inochiama@gmail.com/ [1]
Link: https://lore.kernel.org/all/aTo8sCPpVM1o9PKX@pie [2]
Signed-off-by: Yixun Lan <dlan@gentoo.org>
---
Changes in v3:
- drop reset macro, and have separate patch for changing reset name
- extract common spacemit_ccu_probe(), leave SoC specific change out
- improve commit message
- Link to v2: https://lore.kernel.org/r/20251226-06-k1-clk-common-v2-0-28b59418b4df@gentoo.org
Changes in v2:
- extract common header file which shared by clock and reset
- add SoC namespace to differentiate reset for auxiliary bus
- Link to v1: https://lore.kernel.org/r/20251220-06-k1-clk-common-v1-0-df28a0a91621@gentoo.org
---
Yixun Lan (4):
clk: spacemit: prepare common ccu header
clk: spacemit: extract common ccu functions
clk: spacemit: add platform SoC prefix to reset name
reset: spacemit: fix auxiliary device id
drivers/clk/spacemit/ccu-k1.c | 191 +++-----------------------------------
drivers/clk/spacemit/ccu_common.c | 171 ++++++++++++++++++++++++++++++++++
drivers/clk/spacemit/ccu_common.h | 10 ++
drivers/reset/reset-spacemit.c | 2 +-
include/soc/spacemit/ccu.h | 21 +++++
include/soc/spacemit/k1-syscon.h | 12 +--
6 files changed, 215 insertions(+), 192 deletions(-)
---
base-commit: 99735a742f7e9a3e7f4cb6c58edf1b38101e7657
change-id: 20251217-06-k1-clk-common-8d1c57995047
prerequisite-message-id: 20251219012819.440972-1-inochiama@gmail.com
prerequisite-patch-id: df430730ed961011cee5c5d47b7ace84b3c5ebb7
prerequisite-patch-id: 64003618c33be925602e46b7543f2c13d3f36474
Best regards,
--
Yixun Lan
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v3 1/4] clk: spacemit: prepare common ccu header 2026-01-03 7:26 [PATCH v3 0/4] clk: spacemit: refactor common ccu driver Yixun Lan @ 2026-01-03 7:26 ` Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-03 7:26 ` [PATCH v3 2/4] clk: spacemit: extract common ccu functions Yixun Lan ` (2 subsequent siblings) 3 siblings, 1 reply; 13+ messages in thread From: Yixun Lan @ 2026-01-03 7:26 UTC (permalink / raw) To: Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Alex Elder, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yixun Lan In order to prepare adding clock driver for new K3 SoC, extract generic code to a separate common ccu header file, so they are not defined in K1 SoC-specific file, and then can be shared by all clock drivers. Signed-off-by: Yixun Lan <dlan@gentoo.org> --- include/soc/spacemit/ccu.h | 21 +++++++++++++++++++++ include/soc/spacemit/k1-syscon.h | 12 +----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/soc/spacemit/ccu.h b/include/soc/spacemit/ccu.h new file mode 100644 index 000000000000..84dcdecccc05 --- /dev/null +++ b/include/soc/spacemit/ccu.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __SOC_SPACEMIT_CCU_H__ +#define __SOC_SPACEMIT_CCU_H__ + +#include <linux/auxiliary_bus.h> +#include <linux/regmap.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__ */ diff --git a/include/soc/spacemit/k1-syscon.h b/include/soc/spacemit/k1-syscon.h index 354751562c55..0be7a2e8d445 100644 --- a/include/soc/spacemit/k1-syscon.h +++ b/include/soc/spacemit/k1-syscon.h @@ -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 -- 2.52.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3 1/4] clk: spacemit: prepare common ccu header 2026-01-03 7:26 ` [PATCH v3 1/4] clk: spacemit: prepare common ccu header Yixun Lan @ 2026-01-06 14:43 ` Alex Elder 0 siblings, 0 replies; 13+ messages in thread From: Alex Elder @ 2026-01-06 14:43 UTC (permalink / raw) To: Yixun Lan, Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit On 1/3/26 1:26 AM, Yixun Lan wrote: > In order to prepare adding clock driver for new K3 SoC, extract generic > code to a separate common ccu header file, so they are not defined > in K1 SoC-specific file, and then can be shared by all clock drivers. > > Signed-off-by: Yixun Lan <dlan@gentoo.org> Looks good. Reviewed-by: Alex Elder <elder@riscstar.com> > --- > include/soc/spacemit/ccu.h | 21 +++++++++++++++++++++ > include/soc/spacemit/k1-syscon.h | 12 +----------- > 2 files changed, 22 insertions(+), 11 deletions(-) > > diff --git a/include/soc/spacemit/ccu.h b/include/soc/spacemit/ccu.h > new file mode 100644 > index 000000000000..84dcdecccc05 > --- /dev/null > +++ b/include/soc/spacemit/ccu.h > @@ -0,0 +1,21 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > + > +#ifndef __SOC_SPACEMIT_CCU_H__ > +#define __SOC_SPACEMIT_CCU_H__ > + > +#include <linux/auxiliary_bus.h> > +#include <linux/regmap.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__ */ > diff --git a/include/soc/spacemit/k1-syscon.h b/include/soc/spacemit/k1-syscon.h > index 354751562c55..0be7a2e8d445 100644 > --- a/include/soc/spacemit/k1-syscon.h > +++ b/include/soc/spacemit/k1-syscon.h > @@ -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 > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 2/4] clk: spacemit: extract common ccu functions 2026-01-03 7:26 [PATCH v3 0/4] clk: spacemit: refactor common ccu driver Yixun Lan 2026-01-03 7:26 ` [PATCH v3 1/4] clk: spacemit: prepare common ccu header Yixun Lan @ 2026-01-03 7:26 ` Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-03 7:26 ` [PATCH v3 3/4] clk: spacemit: add platform SoC prefix to reset name Yixun Lan 2026-01-03 7:26 ` [PATCH v3 4/4] reset: spacemit: fix auxiliary device id Yixun Lan 3 siblings, 1 reply; 13+ messages in thread From: Yixun Lan @ 2026-01-03 7:26 UTC (permalink / raw) To: Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Alex Elder, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yixun Lan, Yao Zi Refactor the probe function of SpacemiT's clock, and extract a common ccu file, so new clock driver added in the future can share the same code, which would lower the burden of maintenance. Since this commit changes the module name where the auxiliary device registered, the auxiliary device id need to be adjusted. Idea of the patch comes from the review of K3 clock driver, please refer to this disucssion[1] for more detail. Link: https://lore.kernel.org/all/aTo8sCPpVM1o9PKX@pie/ [1] Suggested-by: Yao Zi <me@ziyao.cc> Signed-off-by: Yixun Lan <dlan@gentoo.org> --- drivers/clk/spacemit/ccu-k1.c | 179 ++------------------------------------ drivers/clk/spacemit/ccu_common.c | 171 ++++++++++++++++++++++++++++++++++++ drivers/clk/spacemit/ccu_common.h | 10 +++ 3 files changed, 186 insertions(+), 174 deletions(-) diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c index 01d9485b615d..02c792a73759 100644 --- a/drivers/clk/spacemit/ccu-k1.c +++ b/drivers/clk/spacemit/ccu-k1.c @@ -5,15 +5,10 @@ */ #include <linux/array_size.h> -#include <linux/auxiliary_bus.h> #include <linux/clk-provider.h> -#include <linux/delay.h> -#include <linux/idr.h> -#include <linux/mfd/syscon.h> #include <linux/minmax.h> #include <linux/module.h> #include <linux/platform_device.h> -#include <linux/slab.h> #include <soc/spacemit/k1-syscon.h> #include "ccu_common.h" @@ -23,14 +18,6 @@ #include <dt-bindings/clock/spacemit,k1-syscon.h> -struct spacemit_ccu_data { - const char *reset_name; - struct clk_hw **hws; - size_t num; -}; - -static DEFINE_IDA(auxiliary_ids); - /* APBS clocks start, APBS region contains and only contains all PLL clocks */ /* @@ -1001,167 +988,6 @@ static const struct spacemit_ccu_data k1_ccu_apbc2_data = { .reset_name = "apbc2-reset", }; -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; - - clk_data->num = data->num; - - 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; - } - - 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); - - ida_free(&auxiliary_ids, adev->id); - 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; - int ret; - - /* Nothing to do if the CCU does not implement a reset controller */ - if (!reset_name) - return 0; - - cadev = kzalloc(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; - ret = ida_alloc(&auxiliary_ids, GFP_KERNEL); - if (ret < 0) - goto err_free_cadev; - adev->id = ret; - - ret = auxiliary_device_init(adev); - if (ret) - goto err_free_aux_id; - - ret = auxiliary_device_add(adev); - if (ret) { - auxiliary_device_uninit(adev); - return ret; - } - - return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev); - -err_free_aux_id: - ida_free(&auxiliary_ids, adev->id); -err_free_cadev: - kfree(cadev); - - return ret; -} - -static int k1_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,k1-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); - - 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; -} - static const struct of_device_id of_k1_ccu_match[] = { { .compatible = "spacemit,k1-pll", @@ -1195,6 +1021,11 @@ static const struct of_device_id of_k1_ccu_match[] = { }; MODULE_DEVICE_TABLE(of, of_k1_ccu_match); +static int k1_ccu_probe(struct platform_device *pdev) +{ + return spacemit_ccu_probe(pdev, "spacemit,k1-pll"); +} + static struct platform_driver k1_ccu_driver = { .driver = { .name = "spacemit,k1-ccu", diff --git a/drivers/clk/spacemit/ccu_common.c b/drivers/clk/spacemit/ccu_common.c index 4412c4104dab..5f05b17f8452 100644 --- a/drivers/clk/spacemit/ccu_common.c +++ b/drivers/clk/spacemit/ccu_common.c @@ -1,6 +1,177 @@ // SPDX-License-Identifier: GPL-2.0-only +#include <linux/clk-provider.h> +#include <linux/device/devres.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/of.h> +#include <linux/slab.h> +#include <soc/spacemit/ccu.h> + +#include "ccu_common.h" + +static DEFINE_IDA(auxiliary_ids); +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; + + clk_data->num = data->num; + + 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; + } + + 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); + + ida_free(&auxiliary_ids, adev->id); + 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; + int ret; + + /* Nothing to do if the CCU does not implement a reset controller */ + if (!reset_name) + return 0; + + cadev = kzalloc(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; + ret = ida_alloc(&auxiliary_ids, GFP_KERNEL); + if (ret < 0) + goto err_free_cadev; + adev->id = ret; + + ret = auxiliary_device_init(adev); + if (ret) + goto err_free_aux_id; + + ret = auxiliary_device_add(adev); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev); + +err_free_aux_id: + ida_free(&auxiliary_ids, adev->id); +err_free_cadev: + kfree(cadev); + + return ret; +} + +int spacemit_ccu_probe(struct platform_device *pdev, const char *compat) +{ + 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 (compat && of_device_is_compatible(dev->of_node, compat)) { + 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); + + 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; +} +EXPORT_SYMBOL_NS_GPL(spacemit_ccu_probe, "CLK_SPACEMIT"); MODULE_DESCRIPTION("SpacemiT CCU common clock driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/clk/spacemit/ccu_common.h b/drivers/clk/spacemit/ccu_common.h index da72f3836e0b..7ae244b5eace 100644 --- a/drivers/clk/spacemit/ccu_common.h +++ b/drivers/clk/spacemit/ccu_common.h @@ -7,6 +7,8 @@ #ifndef _CCU_COMMON_H_ #define _CCU_COMMON_H_ +#include <linux/clk-provider.h> +#include <linux/platform_device.h> #include <linux/regmap.h> struct ccu_common { @@ -36,6 +38,12 @@ static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) return container_of(hw, struct ccu_common, hw); } +struct spacemit_ccu_data { + const char *reset_name; + struct clk_hw **hws; + size_t num; +}; + #define ccu_read(c, reg) \ ({ \ u32 tmp; \ @@ -45,4 +53,6 @@ static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) #define ccu_update(c, reg, mask, val) \ regmap_update_bits((c)->regmap, (c)->reg_##reg, mask, val) +int spacemit_ccu_probe(struct platform_device *pdev, const char *compat); + #endif /* _CCU_COMMON_H_ */ -- 2.52.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] clk: spacemit: extract common ccu functions 2026-01-03 7:26 ` [PATCH v3 2/4] clk: spacemit: extract common ccu functions Yixun Lan @ 2026-01-06 14:43 ` Alex Elder 2026-01-06 22:27 ` Yixun Lan 0 siblings, 1 reply; 13+ messages in thread From: Alex Elder @ 2026-01-06 14:43 UTC (permalink / raw) To: Yixun Lan, Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yao Zi On 1/3/26 1:26 AM, Yixun Lan wrote: > Refactor the probe function of SpacemiT's clock, and extract a common ccu > file, so new clock driver added in the future can share the same code, > which would lower the burden of maintenance. Since this commit changes the > module name where the auxiliary device registered, the auxiliary device id > need to be adjusted. Idea of the patch comes from the review of K3 clock > driver, please refer to this disucssion[1] for more detail. Are all of the hunks of moved code moved without change (I think so)? If so I think it's worth mentioning that. If not, you should explain whatever differs, and why. (I would expect the only thing that would have to change is making spacemit_ccu_probe() public.) I made one minor comment below. I didn't verify, but I assume this is all just moving the code around, and based on that: Reviewed-by: Alex Elder <elder@riscstar.com> > Link: https://lore.kernel.org/all/aTo8sCPpVM1o9PKX@pie/ [1] > Suggested-by: Yao Zi <me@ziyao.cc> > Signed-off-by: Yixun Lan <dlan@gentoo.org> > --- > drivers/clk/spacemit/ccu-k1.c | 179 ++------------------------------------ > drivers/clk/spacemit/ccu_common.c | 171 ++++++++++++++++++++++++++++++++++++ > drivers/clk/spacemit/ccu_common.h | 10 +++ > 3 files changed, 186 insertions(+), 174 deletions(-) > > diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c > index 01d9485b615d..02c792a73759 100644 > --- a/drivers/clk/spacemit/ccu-k1.c > +++ b/drivers/clk/spacemit/ccu-k1.c > @@ -5,15 +5,10 @@ > */ > > #include <linux/array_size.h> > -#include <linux/auxiliary_bus.h> > #include <linux/clk-provider.h> > -#include <linux/delay.h> > -#include <linux/idr.h> > -#include <linux/mfd/syscon.h> > #include <linux/minmax.h> > #include <linux/module.h> > #include <linux/platform_device.h> > -#include <linux/slab.h> > #include <soc/spacemit/k1-syscon.h> > > #include "ccu_common.h" > @@ -23,14 +18,6 @@ > > #include <dt-bindings/clock/spacemit,k1-syscon.h> > > -struct spacemit_ccu_data { > - const char *reset_name; > - struct clk_hw **hws; > - size_t num; > -}; > - > -static DEFINE_IDA(auxiliary_ids); > - > /* APBS clocks start, APBS region contains and only contains all PLL clocks */ > > /* > @@ -1001,167 +988,6 @@ static const struct spacemit_ccu_data k1_ccu_apbc2_data = { > .reset_name = "apbc2-reset", > }; > > -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; > - > - clk_data->num = data->num; > - > - 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; > - } > - > - 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); > - > - ida_free(&auxiliary_ids, adev->id); > - 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; > - int ret; > - > - /* Nothing to do if the CCU does not implement a reset controller */ > - if (!reset_name) > - return 0; > - > - cadev = kzalloc(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; > - ret = ida_alloc(&auxiliary_ids, GFP_KERNEL); > - if (ret < 0) > - goto err_free_cadev; > - adev->id = ret; > - > - ret = auxiliary_device_init(adev); > - if (ret) > - goto err_free_aux_id; > - > - ret = auxiliary_device_add(adev); > - if (ret) { > - auxiliary_device_uninit(adev); > - return ret; > - } > - > - return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev); > - > -err_free_aux_id: > - ida_free(&auxiliary_ids, adev->id); > -err_free_cadev: > - kfree(cadev); > - > - return ret; > -} > - > -static int k1_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,k1-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); > - > - 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; > -} > - > static const struct of_device_id of_k1_ccu_match[] = { > { > .compatible = "spacemit,k1-pll", > @@ -1195,6 +1021,11 @@ static const struct of_device_id of_k1_ccu_match[] = { > }; > MODULE_DEVICE_TABLE(of, of_k1_ccu_match); > > +static int k1_ccu_probe(struct platform_device *pdev) > +{ > + return spacemit_ccu_probe(pdev, "spacemit,k1-pll"); > +} > + > static struct platform_driver k1_ccu_driver = { > .driver = { > .name = "spacemit,k1-ccu", > diff --git a/drivers/clk/spacemit/ccu_common.c b/drivers/clk/spacemit/ccu_common.c > index 4412c4104dab..5f05b17f8452 100644 > --- a/drivers/clk/spacemit/ccu_common.c > +++ b/drivers/clk/spacemit/ccu_common.c > @@ -1,6 +1,177 @@ > // SPDX-License-Identifier: GPL-2.0-only > > +#include <linux/clk-provider.h> > +#include <linux/device/devres.h> > +#include <linux/mfd/syscon.h> > #include <linux/module.h> > +#include <linux/of.h> > +#include <linux/slab.h> > +#include <soc/spacemit/ccu.h> > + > +#include "ccu_common.h" > + > +static DEFINE_IDA(auxiliary_ids); I'd insert a space here to make the definition above stand out a bit more. > +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; > + > + clk_data->num = data->num; > + > + 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; > + } > + > + 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); > + > + ida_free(&auxiliary_ids, adev->id); > + 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; > + int ret; > + > + /* Nothing to do if the CCU does not implement a reset controller */ > + if (!reset_name) > + return 0; > + > + cadev = kzalloc(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; > + ret = ida_alloc(&auxiliary_ids, GFP_KERNEL); > + if (ret < 0) > + goto err_free_cadev; > + adev->id = ret; > + > + ret = auxiliary_device_init(adev); > + if (ret) > + goto err_free_aux_id; > + > + ret = auxiliary_device_add(adev); > + if (ret) { > + auxiliary_device_uninit(adev); > + return ret; > + } > + > + return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev); > + > +err_free_aux_id: > + ida_free(&auxiliary_ids, adev->id); > +err_free_cadev: > + kfree(cadev); > + > + return ret; > +} > + > +int spacemit_ccu_probe(struct platform_device *pdev, const char *compat) > +{ > + 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 (compat && of_device_is_compatible(dev->of_node, compat)) { > + 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); > + > + 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; > +} > +EXPORT_SYMBOL_NS_GPL(spacemit_ccu_probe, "CLK_SPACEMIT"); > > MODULE_DESCRIPTION("SpacemiT CCU common clock driver"); > MODULE_LICENSE("GPL"); > diff --git a/drivers/clk/spacemit/ccu_common.h b/drivers/clk/spacemit/ccu_common.h > index da72f3836e0b..7ae244b5eace 100644 > --- a/drivers/clk/spacemit/ccu_common.h > +++ b/drivers/clk/spacemit/ccu_common.h > @@ -7,6 +7,8 @@ > #ifndef _CCU_COMMON_H_ > #define _CCU_COMMON_H_ > > +#include <linux/clk-provider.h> > +#include <linux/platform_device.h> > #include <linux/regmap.h> > > struct ccu_common { > @@ -36,6 +38,12 @@ static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) > return container_of(hw, struct ccu_common, hw); > } > > +struct spacemit_ccu_data { > + const char *reset_name; > + struct clk_hw **hws; > + size_t num; > +}; > + > #define ccu_read(c, reg) \ > ({ \ > u32 tmp; \ > @@ -45,4 +53,6 @@ static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) > #define ccu_update(c, reg, mask, val) \ > regmap_update_bits((c)->regmap, (c)->reg_##reg, mask, val) > > +int spacemit_ccu_probe(struct platform_device *pdev, const char *compat); > + > #endif /* _CCU_COMMON_H_ */ > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] clk: spacemit: extract common ccu functions 2026-01-06 14:43 ` Alex Elder @ 2026-01-06 22:27 ` Yixun Lan 2026-01-06 23:42 ` Alex Elder 0 siblings, 1 reply; 13+ messages in thread From: Yixun Lan @ 2026-01-06 22:27 UTC (permalink / raw) To: Alex Elder Cc: Stephen Boyd, Michael Turquette, Philipp Zabel, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yao Zi Hi Alex, On 08:43 Tue 06 Jan , Alex Elder wrote: > On 1/3/26 1:26 AM, Yixun Lan wrote: > > Refactor the probe function of SpacemiT's clock, and extract a common ccu > > file, so new clock driver added in the future can share the same code, > > which would lower the burden of maintenance. Since this commit changes the > > module name where the auxiliary device registered, the auxiliary device id > > need to be adjusted. Idea of the patch comes from the review of K3 clock > > driver, please refer to this disucssion[1] for more detail. > > Are all of the hunks of moved code moved without change (I > think so)? If so I think it's worth mentioning that. If > not, you should explain whatever differs, and why. (I would yes, no literal changes with this patch except probe() refactored, and the real effective change is the module name changed which I mentioned already > expect the only thing that would have to change is making > spacemit_ccu_probe() public.) to make spacemit_ccu_probe() public, we move SoC specific code out of this function which should have no functionality change.. (I think the above commit message is ok, and would not plan to send out another version if no serious comment incoming, unless you insist) > > I made one minor comment below. I didn't verify, but I > assume this is all just moving the code around, and based > on that: > > Reviewed-by: Alex Elder <elder@riscstar.com> > [snip]... > > diff --git a/drivers/clk/spacemit/ccu_common.c b/drivers/clk/spacemit/ccu_common.c > > index 4412c4104dab..5f05b17f8452 100644 > > --- a/drivers/clk/spacemit/ccu_common.c > > +++ b/drivers/clk/spacemit/ccu_common.c > > @@ -1,6 +1,177 @@ > > // SPDX-License-Identifier: GPL-2.0-only > > > > +#include <linux/clk-provider.h> > > +#include <linux/device/devres.h> > > +#include <linux/mfd/syscon.h> > > #include <linux/module.h> > > +#include <linux/of.h> > > +#include <linux/slab.h> > > +#include <soc/spacemit/ccu.h> > > + > > +#include "ccu_common.h" > > + > > +static DEFINE_IDA(auxiliary_ids); > > I'd insert a space here to make the definition above stand out a > bit more. > do you mean a blank line? (I could do this while applying this patch since it's quite trivial..) -- Yixun Lan (dlan) _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] clk: spacemit: extract common ccu functions 2026-01-06 22:27 ` Yixun Lan @ 2026-01-06 23:42 ` Alex Elder 0 siblings, 0 replies; 13+ messages in thread From: Alex Elder @ 2026-01-06 23:42 UTC (permalink / raw) To: Yixun Lan Cc: Stephen Boyd, Michael Turquette, Philipp Zabel, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yao Zi On 1/6/26 4:27 PM, Yixun Lan wrote: > Hi Alex, > > On 08:43 Tue 06 Jan , Alex Elder wrote: >> On 1/3/26 1:26 AM, Yixun Lan wrote: >>> Refactor the probe function of SpacemiT's clock, and extract a common ccu >>> file, so new clock driver added in the future can share the same code, >>> which would lower the burden of maintenance. Since this commit changes the >>> module name where the auxiliary device registered, the auxiliary device id >>> need to be adjusted. Idea of the patch comes from the review of K3 clock >>> driver, please refer to this disucssion[1] for more detail. >> >> Are all of the hunks of moved code moved without change (I >> think so)? If so I think it's worth mentioning that. If >> not, you should explain whatever differs, and why. (I would > yes, no literal changes with this patch except probe() refactored, > and the real effective change is the module name changed which > I mentioned already Thanks for confirming. No need to change your description, just consider this for future patches. >> expect the only thing that would have to change is making >> spacemit_ccu_probe() public.) > to make spacemit_ccu_probe() public, we move SoC specific code > out of this function which should have no functionality change.. > > (I think the above commit message is ok, and would not plan to send > out another version if no serious comment incoming, unless you insist) > >> >> I made one minor comment below. I didn't verify, but I >> assume this is all just moving the code around, and based >> on that: >> >> Reviewed-by: Alex Elder <elder@riscstar.com> >> > [snip]... >>> diff --git a/drivers/clk/spacemit/ccu_common.c b/drivers/clk/spacemit/ccu_common.c >>> index 4412c4104dab..5f05b17f8452 100644 >>> --- a/drivers/clk/spacemit/ccu_common.c >>> +++ b/drivers/clk/spacemit/ccu_common.c >>> @@ -1,6 +1,177 @@ >>> // SPDX-License-Identifier: GPL-2.0-only >>> >>> +#include <linux/clk-provider.h> >>> +#include <linux/device/devres.h> >>> +#include <linux/mfd/syscon.h> >>> #include <linux/module.h> >>> +#include <linux/of.h> >>> +#include <linux/slab.h> >>> +#include <soc/spacemit/ccu.h> >>> + >>> +#include "ccu_common.h" >>> + >>> +static DEFINE_IDA(auxiliary_ids); >> >> I'd insert a space here to make the definition above stand out a >> bit more. >> > do you mean a blank line? > (I could do this while applying this patch since it's quite trivial..) Yes that's what I mean, and yes, fine to add that when applying. -Alex _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 3/4] clk: spacemit: add platform SoC prefix to reset name 2026-01-03 7:26 [PATCH v3 0/4] clk: spacemit: refactor common ccu driver Yixun Lan 2026-01-03 7:26 ` [PATCH v3 1/4] clk: spacemit: prepare common ccu header Yixun Lan 2026-01-03 7:26 ` [PATCH v3 2/4] clk: spacemit: extract common ccu functions Yixun Lan @ 2026-01-03 7:26 ` Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-03 7:26 ` [PATCH v3 4/4] reset: spacemit: fix auxiliary device id Yixun Lan 3 siblings, 1 reply; 13+ messages in thread From: Yixun Lan @ 2026-01-03 7:26 UTC (permalink / raw) To: Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Alex Elder, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yixun Lan This change is needed for adding future new SpacemiT K3 reset driver. Since both K1 and K3 reset code register via the same module which its name changed to spacemit_ccu, it's necessary to encode the platform/SoC in the reset auxiliary device name to distinguish them, otherwise two reset drivers will claim to support same "compatible" auxiliary device even in the case of only one CCU clock driver got registered, which in the end lead to a broken reset driver. Signed-off-by: Yixun Lan <dlan@gentoo.org> --- drivers/clk/spacemit/ccu-k1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c index 02c792a73759..dee14d25f75d 100644 --- a/drivers/clk/spacemit/ccu-k1.c +++ b/drivers/clk/spacemit/ccu-k1.c @@ -789,7 +789,7 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = { }; static const struct spacemit_ccu_data k1_ccu_mpmu_data = { - .reset_name = "mpmu-reset", + .reset_name = "k1-mpmu-reset", .hws = k1_ccu_mpmu_hws, .num = ARRAY_SIZE(k1_ccu_mpmu_hws), }; @@ -900,7 +900,7 @@ static struct clk_hw *k1_ccu_apbc_hws[] = { }; static const struct spacemit_ccu_data k1_ccu_apbc_data = { - .reset_name = "apbc-reset", + .reset_name = "k1-apbc-reset", .hws = k1_ccu_apbc_hws, .num = ARRAY_SIZE(k1_ccu_apbc_hws), }; @@ -971,21 +971,21 @@ static struct clk_hw *k1_ccu_apmu_hws[] = { }; static const struct spacemit_ccu_data k1_ccu_apmu_data = { - .reset_name = "apmu-reset", + .reset_name = "k1-apmu-reset", .hws = k1_ccu_apmu_hws, .num = ARRAY_SIZE(k1_ccu_apmu_hws), }; static const struct spacemit_ccu_data k1_ccu_rcpu_data = { - .reset_name = "rcpu-reset", + .reset_name = "k1-rcpu-reset", }; static const struct spacemit_ccu_data k1_ccu_rcpu2_data = { - .reset_name = "rcpu2-reset", + .reset_name = "k1-rcpu2-reset", }; static const struct spacemit_ccu_data k1_ccu_apbc2_data = { - .reset_name = "apbc2-reset", + .reset_name = "k1-apbc2-reset", }; static const struct of_device_id of_k1_ccu_match[] = { -- 2.52.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3 3/4] clk: spacemit: add platform SoC prefix to reset name 2026-01-03 7:26 ` [PATCH v3 3/4] clk: spacemit: add platform SoC prefix to reset name Yixun Lan @ 2026-01-06 14:43 ` Alex Elder 0 siblings, 0 replies; 13+ messages in thread From: Alex Elder @ 2026-01-06 14:43 UTC (permalink / raw) To: Yixun Lan, Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit On 1/3/26 1:26 AM, Yixun Lan wrote: > This change is needed for adding future new SpacemiT K3 reset driver. > > Since both K1 and K3 reset code register via the same module which its > name changed to spacemit_ccu, it's necessary to encode the platform/SoC > in the reset auxiliary device name to distinguish them, otherwise two > reset drivers will claim to support same "compatible" auxiliary device > even in the case of only one CCU clock driver got registered, which in > the end lead to a broken reset driver. > > Signed-off-by: Yixun Lan <dlan@gentoo.org> Looks good. Reviewed-by: Alex Elder <elder@riscstar.com> > --- > drivers/clk/spacemit/ccu-k1.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c > index 02c792a73759..dee14d25f75d 100644 > --- a/drivers/clk/spacemit/ccu-k1.c > +++ b/drivers/clk/spacemit/ccu-k1.c > @@ -789,7 +789,7 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = { > }; > > static const struct spacemit_ccu_data k1_ccu_mpmu_data = { > - .reset_name = "mpmu-reset", > + .reset_name = "k1-mpmu-reset", > .hws = k1_ccu_mpmu_hws, > .num = ARRAY_SIZE(k1_ccu_mpmu_hws), > }; > @@ -900,7 +900,7 @@ static struct clk_hw *k1_ccu_apbc_hws[] = { > }; > > static const struct spacemit_ccu_data k1_ccu_apbc_data = { > - .reset_name = "apbc-reset", > + .reset_name = "k1-apbc-reset", > .hws = k1_ccu_apbc_hws, > .num = ARRAY_SIZE(k1_ccu_apbc_hws), > }; > @@ -971,21 +971,21 @@ static struct clk_hw *k1_ccu_apmu_hws[] = { > }; > > static const struct spacemit_ccu_data k1_ccu_apmu_data = { > - .reset_name = "apmu-reset", > + .reset_name = "k1-apmu-reset", > .hws = k1_ccu_apmu_hws, > .num = ARRAY_SIZE(k1_ccu_apmu_hws), > }; > > static const struct spacemit_ccu_data k1_ccu_rcpu_data = { > - .reset_name = "rcpu-reset", > + .reset_name = "k1-rcpu-reset", > }; > > static const struct spacemit_ccu_data k1_ccu_rcpu2_data = { > - .reset_name = "rcpu2-reset", > + .reset_name = "k1-rcpu2-reset", > }; > > static const struct spacemit_ccu_data k1_ccu_apbc2_data = { > - .reset_name = "apbc2-reset", > + .reset_name = "k1-apbc2-reset", > }; > > static const struct of_device_id of_k1_ccu_match[] = { > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 4/4] reset: spacemit: fix auxiliary device id 2026-01-03 7:26 [PATCH v3 0/4] clk: spacemit: refactor common ccu driver Yixun Lan ` (2 preceding siblings ...) 2026-01-03 7:26 ` [PATCH v3 3/4] clk: spacemit: add platform SoC prefix to reset name Yixun Lan @ 2026-01-03 7:26 ` Yixun Lan 2026-01-06 14:43 ` Alex Elder 3 siblings, 1 reply; 13+ messages in thread From: Yixun Lan @ 2026-01-03 7:26 UTC (permalink / raw) To: Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Alex Elder, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit, Yixun Lan Due to the auxiliary register procedure moved to ccu common module where the module name changed to spacemit_ccu, then the reset auxiliary device register id also need to be adjusted in order to prepare for adding new K3 reset driver, otherwise two reset drivers will claim to support same "compatible" auxiliary device. Signed-off-by: Yixun Lan <dlan@gentoo.org> --- drivers/reset/reset-spacemit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/reset/reset-spacemit.c b/drivers/reset/reset-spacemit.c index e1272aff28f7..cc7fd1f8750d 100644 --- a/drivers/reset/reset-spacemit.c +++ b/drivers/reset/reset-spacemit.c @@ -278,7 +278,7 @@ static int spacemit_reset_probe(struct auxiliary_device *adev, #define K1_AUX_DEV_ID(_unit) \ { \ - .name = "spacemit_ccu_k1." #_unit "-reset", \ + .name = "spacemit_ccu.k1-" #_unit "-reset", \ .driver_data = (kernel_ulong_t)&k1_ ## _unit ## _reset_data, \ } -- 2.52.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3 4/4] reset: spacemit: fix auxiliary device id 2026-01-03 7:26 ` [PATCH v3 4/4] reset: spacemit: fix auxiliary device id Yixun Lan @ 2026-01-06 14:43 ` Alex Elder 2026-01-08 11:07 ` Philipp Zabel 0 siblings, 1 reply; 13+ messages in thread From: Alex Elder @ 2026-01-06 14:43 UTC (permalink / raw) To: Yixun Lan, Stephen Boyd, Michael Turquette, Philipp Zabel Cc: Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit On 1/3/26 1:26 AM, Yixun Lan wrote: > Due to the auxiliary register procedure moved to ccu common module where > the module name changed to spacemit_ccu, then the reset auxiliary device > register id also need to be adjusted in order to prepare for adding new > K3 reset driver, otherwise two reset drivers will claim to support same > "compatible" auxiliary device. > > Signed-off-by: Yixun Lan <dlan@gentoo.org> This would ideally be merged with the previous patch. Maybe Philipp can negotiate with Stephen to have that happen. Reviewed-by: Alex Elder <elder@riscstar.com> > --- > drivers/reset/reset-spacemit.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/reset/reset-spacemit.c b/drivers/reset/reset-spacemit.c > index e1272aff28f7..cc7fd1f8750d 100644 > --- a/drivers/reset/reset-spacemit.c > +++ b/drivers/reset/reset-spacemit.c > @@ -278,7 +278,7 @@ static int spacemit_reset_probe(struct auxiliary_device *adev, > > #define K1_AUX_DEV_ID(_unit) \ > { \ > - .name = "spacemit_ccu_k1." #_unit "-reset", \ > + .name = "spacemit_ccu.k1-" #_unit "-reset", \ > .driver_data = (kernel_ulong_t)&k1_ ## _unit ## _reset_data, \ > } > > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 4/4] reset: spacemit: fix auxiliary device id 2026-01-06 14:43 ` Alex Elder @ 2026-01-08 11:07 ` Philipp Zabel 2026-01-08 12:24 ` Yixun Lan 0 siblings, 1 reply; 13+ messages in thread From: Philipp Zabel @ 2026-01-08 11:07 UTC (permalink / raw) To: Alex Elder, Yixun Lan, Stephen Boyd, Michael Turquette Cc: Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit On Di, 2026-01-06 at 08:43 -0600, Alex Elder wrote: > On 1/3/26 1:26 AM, Yixun Lan wrote: > > Due to the auxiliary register procedure moved to ccu common module where > > the module name changed to spacemit_ccu, then the reset auxiliary device > > register id also need to be adjusted in order to prepare for adding new > > K3 reset driver, otherwise two reset drivers will claim to support same > > "compatible" auxiliary device. > > > > Signed-off-by: Yixun Lan <dlan@gentoo.org> > > This would ideally be merged with the previous patch. Maybe > Philipp can negotiate with Stephen to have that happen. > > Reviewed-by: Alex Elder <elder@riscstar.com> > > > --- > > drivers/reset/reset-spacemit.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/reset/reset-spacemit.c b/drivers/reset/reset-spacemit.c > > index e1272aff28f7..cc7fd1f8750d 100644 > > --- a/drivers/reset/reset-spacemit.c > > +++ b/drivers/reset/reset-spacemit.c > > @@ -278,7 +278,7 @@ static int spacemit_reset_probe(struct auxiliary_device *adev, > > > > #define K1_AUX_DEV_ID(_unit) \ > > { \ > > - .name = "spacemit_ccu_k1." #_unit "-reset", \ > > + .name = "spacemit_ccu.k1-" #_unit "-reset", \ > > .driver_data = (kernel_ulong_t)&k1_ ## _unit ## _reset_data, \ > > } > > Acked-by: Philipp Zabel <p.zabel@pengutronix.de> to be merged via the clock tree. Note that the commits for both patches 2 and 3 will fail to probe the reset driver when bisecting. If you don't want do merge the corresponding changes to K1_AUX_DEV_ID() into those two patches, to make this series (runtime) bisectable, you should add a warning to both their commit messages that the reset driver will be adapted in the following patch 4. regards Philipp _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 4/4] reset: spacemit: fix auxiliary device id 2026-01-08 11:07 ` Philipp Zabel @ 2026-01-08 12:24 ` Yixun Lan 0 siblings, 0 replies; 13+ messages in thread From: Yixun Lan @ 2026-01-08 12:24 UTC (permalink / raw) To: Philipp Zabel Cc: Alex Elder, Stephen Boyd, Michael Turquette, Guodong Xu, Inochi Amaoto, linux-kernel, linux-clk, linux-riscv, spacemit Hi Philipp, On 12:07 Thu 08 Jan , Philipp Zabel wrote: > On Di, 2026-01-06 at 08:43 -0600, Alex Elder wrote: > > On 1/3/26 1:26 AM, Yixun Lan wrote: > > > Due to the auxiliary register procedure moved to ccu common module where > > > the module name changed to spacemit_ccu, then the reset auxiliary device > > > register id also need to be adjusted in order to prepare for adding new > > > K3 reset driver, otherwise two reset drivers will claim to support same > > > "compatible" auxiliary device. > > > > > > Signed-off-by: Yixun Lan <dlan@gentoo.org> > > > > This would ideally be merged with the previous patch. Maybe > > Philipp can negotiate with Stephen to have that happen. > > > > Reviewed-by: Alex Elder <elder@riscstar.com> > > > > > --- > > > drivers/reset/reset-spacemit.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/reset/reset-spacemit.c b/drivers/reset/reset-spacemit.c > > > index e1272aff28f7..cc7fd1f8750d 100644 > > > --- a/drivers/reset/reset-spacemit.c > > > +++ b/drivers/reset/reset-spacemit.c > > > @@ -278,7 +278,7 @@ static int spacemit_reset_probe(struct auxiliary_device *adev, > > > > > > #define K1_AUX_DEV_ID(_unit) \ > > > { \ > > > - .name = "spacemit_ccu_k1." #_unit "-reset", \ > > > + .name = "spacemit_ccu.k1-" #_unit "-reset", \ > > > .driver_data = (kernel_ulong_t)&k1_ ## _unit ## _reset_data, \ > > > } > > > > > Acked-by: Philipp Zabel <p.zabel@pengutronix.de> > thanks > to be merged via the clock tree. > ok, got! and, here is my plan, I will prepare an immutable tag for the patch 4 - the change to reset driver ID, and merge it with the whole series, then send them along via clock tree. the tag would be useful if follow-up K3 reset patch[1] need to be merged, since both will change the reset driver, and with the tag, patch 4 can be pulled into both clock and reset subsystem, future reset patches can commit on top of it. even there is no price to pay if above doesn't happen. > Note that the commits for both patches 2 and 3 will fail to probe the > reset driver when bisecting. > If you don't want do merge the corresponding changes to K1_AUX_DEV_ID() > into those two patches, to make this series (runtime) bisectable, you no, I do not want to merge changes K1_AUX_DEV_ID() into patch 2/3 > should add a warning to both their commit messages that the reset > driver will be adapted in the following patch 4. ok, I will send a new version and add a warning message > > regards > Philipp Link: https://lore.kernel.org/all/20251229-k3-reset-v1-0-eda0747bded3@riscstar.com/ [1] -- Yixun Lan (dlan) _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-01-08 12:24 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-03 7:26 [PATCH v3 0/4] clk: spacemit: refactor common ccu driver Yixun Lan 2026-01-03 7:26 ` [PATCH v3 1/4] clk: spacemit: prepare common ccu header Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-03 7:26 ` [PATCH v3 2/4] clk: spacemit: extract common ccu functions Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-06 22:27 ` Yixun Lan 2026-01-06 23:42 ` Alex Elder 2026-01-03 7:26 ` [PATCH v3 3/4] clk: spacemit: add platform SoC prefix to reset name Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-03 7:26 ` [PATCH v3 4/4] reset: spacemit: fix auxiliary device id Yixun Lan 2026-01-06 14:43 ` Alex Elder 2026-01-08 11:07 ` Philipp Zabel 2026-01-08 12:24 ` Yixun Lan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox