[PATCH 8/8] clk: tenstorrent: Add reset controller to Atlantis clock controller probe

Anirudh Srinivasan posted 8 patches 3 weeks, 4 days ago
There is a newer version of this series
[PATCH 8/8] clk: tenstorrent: Add reset controller to Atlantis clock controller probe
Posted by Anirudh Srinivasan 3 weeks, 4 days ago
Create a reset auxiliary device during probe of clock controller

Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
---
 drivers/clk/tenstorrent/atlantis-ccu.c | 59 ++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/clk/tenstorrent/atlantis-ccu.c b/drivers/clk/tenstorrent/atlantis-ccu.c
index f3a2ea49a82e..e4f56018907f 100644
--- a/drivers/clk/tenstorrent/atlantis-ccu.c
+++ b/drivers/clk/tenstorrent/atlantis-ccu.c
@@ -491,6 +491,7 @@ struct atlantis_ccu {
 struct atlantis_ccu_data {
 	struct clk_hw **hws;
 	size_t num;
+	const char *reset_name;
 };
 
 static const struct clk_parent_data osc_24m_clk[] = {
@@ -706,6 +707,7 @@ static struct clk_hw *atlantis_rcpu_clks[] = {
 static const struct atlantis_ccu_data atlantis_ccu_rcpu_data = {
 	.hws = atlantis_rcpu_clks,
 	.num = ARRAY_SIZE(atlantis_rcpu_clks),
+	.reset_name = "rcpu-reset"
 };
 
 static int atlantis_ccu_clocks_register(struct device *dev,
@@ -875,6 +877,59 @@ static int atlantis_ccu_clocks_register(struct device *dev,
 	return ret;
 }
 
+static void atlantis_cadev_release(struct device *dev)
+{
+	struct auxiliary_device *adev = to_auxiliary_dev(dev);
+
+	kfree(to_atlantis_ccu_adev(adev));
+}
+
+static void atlantis_adev_unregister(void *data)
+{
+	struct auxiliary_device *adev = data;
+
+	auxiliary_device_delete(adev);
+	auxiliary_device_uninit(adev);
+}
+
+static int atlantis_ccu_adev_register(struct device *dev,
+				      struct atlantis_ccu *ccu,
+				      const struct atlantis_ccu_data *data,
+				      const char *adev_name)
+{
+	struct atlantis_ccu_adev *cadev;
+	struct auxiliary_device *adev;
+	int ret;
+
+	cadev = kzalloc(sizeof(*cadev), GFP_KERNEL);
+	if (!cadev)
+		return -ENOMEM;
+
+	cadev->regmap = ccu->regmap;
+
+	adev = &cadev->adev;
+	adev->name = adev_name;
+	adev->dev.parent = dev;
+	adev->dev.release = atlantis_cadev_release;
+	adev->dev.of_node = dev->of_node;
+
+	ret = auxiliary_device_init(adev);
+	if (ret)
+		goto err_free_cadev;
+
+	ret = auxiliary_device_add(adev);
+	if (ret) {
+		auxiliary_device_uninit(adev);
+		return ret;
+	}
+
+	return devm_add_action_or_reset(dev, atlantis_adev_unregister, adev);
+
+err_free_cadev:
+	kfree(cadev);
+
+	return ret;
+}
 static int atlantis_ccu_probe(struct platform_device *pdev)
 {
 	const struct atlantis_ccu_data *data;
@@ -905,6 +960,10 @@ static int atlantis_ccu_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to register clocks\n");
 
+	ret = atlantis_ccu_adev_register(dev, ccu, data, data->reset_name);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to register resets\n");
+
 	return 0;
 }
 

-- 
2.43.0
Re: [PATCH 8/8] clk: tenstorrent: Add reset controller to Atlantis clock controller probe
Posted by Krzysztof Kozlowski 3 weeks, 3 days ago
On Thu, Jan 15, 2026 at 05:42:07PM -0600, Anirudh Srinivasan wrote:
> Create a reset auxiliary device during probe of clock controller
> 
> Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> ---
>  drivers/clk/tenstorrent/atlantis-ccu.c | 59 ++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/drivers/clk/tenstorrent/atlantis-ccu.c b/drivers/clk/tenstorrent/atlantis-ccu.c
> index f3a2ea49a82e..e4f56018907f 100644
> --- a/drivers/clk/tenstorrent/atlantis-ccu.c
> +++ b/drivers/clk/tenstorrent/atlantis-ccu.c
> @@ -491,6 +491,7 @@ struct atlantis_ccu {
>  struct atlantis_ccu_data {
>  	struct clk_hw **hws;
>  	size_t num;
> +	const char *reset_name;

You just added this file! Why are you adding incomplete or even buggy
code which immediately you fix?

Best regards,
Krzysztof
Re: [PATCH 8/8] clk: tenstorrent: Add reset controller to Atlantis clock controller probe
Posted by Anirudh Srinivasan 3 weeks, 3 days ago
Hi Krzysztof,

On Fri, Jan 16, 2026 at 3:08 AM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> Completely pointless. You do not have any user of this.
>
> Adding a few unused lines is not a logical change to the kernel. Why not
> adding it member by member like one patch for empty struct, then second
> patch for struct with adev, then third patch adding regmap?
>
>
> You just added this file! Why are you adding incomplete or even buggy
> code which immediately you fix?

Regarding your comments from patches 5, 6 and 8, I will clean up the
patches that add the auxdev and reset controller so that there are no
more unnecessary commits.