From: Haylen Chu <heylenay@4d2.org>
To: Yixun Lan <dlan@gentoo.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Haylen Chu <heylenay@outlook.com>,
linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
spacemit@lists.linux.dev, Inochi Amaoto <inochiama@outlook.com>,
Chen Wang <unicornxdotw@foxmail.com>,
Jisheng Zhang <jszhang@kernel.org>,
Meng Zhang <zhangmeng.kevin@linux.spacemit.com>
Subject: Re: [PATCH v5 3/5] clk: spacemit: Add clock support for Spacemit K1 SoC
Date: Fri, 7 Mar 2025 06:42:02 +0000 [thread overview]
Message-ID: <Z8qVOssDHaVDQmLY@ketchup> (raw)
In-Reply-To: <20250307005149-GYA66361@gentoo>
On Fri, Mar 07, 2025 at 12:51:49AM +0000, Yixun Lan wrote:
> On 17:57 Thu 06 Mar , Haylen Chu wrote:
> > The clock tree of K1 SoC contains three main types of clock hardware
> > (PLL/DDN/MIX) and has control registers split into several multifunction
> > devices: APBS (PLLs), MPMU, APBC and APMU.
> >
> > All register operations are done through regmap to ensure atomiciy
> > between concurrent operations of clock driver and reset,
> > power-domain driver that will be introduced in the future.
> >
> > Signed-off-by: Haylen Chu <heylenay@4d2.org>
> > ---
> > drivers/clk/Kconfig | 1 +
> > drivers/clk/Makefile | 1 +
> > drivers/clk/spacemit/Kconfig | 20 +
> > drivers/clk/spacemit/Makefile | 5 +
> > drivers/clk/spacemit/ccu-k1.c | 1714 +++++++++++++++++++++++++++++
> > drivers/clk/spacemit/ccu_common.h | 47 +
> > drivers/clk/spacemit/ccu_ddn.c | 80 ++
> > drivers/clk/spacemit/ccu_ddn.h | 48 +
> > drivers/clk/spacemit/ccu_mix.c | 284 +++++
> > drivers/clk/spacemit/ccu_mix.h | 246 +++++
> > drivers/clk/spacemit/ccu_pll.c | 146 +++
> > drivers/clk/spacemit/ccu_pll.h | 76 ++
> > 12 files changed, 2668 insertions(+)
> > create mode 100644 drivers/clk/spacemit/Kconfig
> > create mode 100644 drivers/clk/spacemit/Makefile
> > create mode 100644 drivers/clk/spacemit/ccu-k1.c
> > create mode 100644 drivers/clk/spacemit/ccu_common.h
> > create mode 100644 drivers/clk/spacemit/ccu_ddn.c
> > create mode 100644 drivers/clk/spacemit/ccu_ddn.h
> > create mode 100644 drivers/clk/spacemit/ccu_mix.c
> > create mode 100644 drivers/clk/spacemit/ccu_mix.h
> > create mode 100644 drivers/clk/spacemit/ccu_pll.c
> > create mode 100644 drivers/clk/spacemit/ccu_pll.h
> >
> ..
> > +static int k1_ccu_probe(struct platform_device *pdev)
> > +{
> > + struct regmap *base_regmap, *lock_regmap = NULL;
> > + 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");
> > +
> > + 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);
> > +
> you can simplify above with syscon_regmap_lookup_by_phandle(), which
> would save a few lines
>
> or further, just call syscon_regmap_lookup_by_compatible()? then
> won't be necessary to introduce the "spacemit,mpmu" property..
>
These syscon_* functions differ a little from device_node_to_regmap():
they get and enable the first item in "clocks" property when
instantiating a regmap, which isn't desired for a clock controller.
> > + if (IS_ERR(lock_regmap))
> > + return dev_err_probe(dev, PTR_ERR(lock_regmap),
> > + "failed to get lock regmap\n");
> > + }
> > +
> > + ret = spacemit_ccu_register(dev, base_regmap, lock_regmap,
> > + of_device_get_match_data(dev));
> > + if (ret)
> > + return dev_err_probe(dev, ret, "failed to register clocks\n");
> > +
> > + return 0;
> > +}
> > +
> > +static const struct of_device_id of_k1_ccu_match[] = {
> > + {
> > + .compatible = "spacemit,k1-pll",
> > + .data = k1_ccu_apbs_clks,
> > + },
> > + {
> > + .compatible = "spacemit,k1-syscon-mpmu",
> > + .data = k1_ccu_mpmu_clks,
> > + },
> > + {
> > + .compatible = "spacemit,k1-syscon-apbc",
> > + .data = k1_ccu_apbc_clks,
> > + },
> > + {
> > + .compatible = "spacemit,k1-syscon-apmu",
> > + .data = k1_ccu_apmu_clks,
> > + },
> > + { }
> > +};
> > +MODULE_DEVICE_TABLE(of, of_k1_ccu_match);
> > +
> > +static struct platform_driver k1_ccu_driver = {
> > + .driver = {
> > + .name = "spacemit,k1-ccu",
> > + .of_match_table = of_k1_ccu_match,
> > + },
> > + .probe = k1_ccu_probe,
> > +};
> > +module_platform_driver(k1_ccu_driver);
> > +
> > +MODULE_DESCRIPTION("Spacemit K1 CCU driver");
> > +MODULE_AUTHOR("Haylen Chu <heylenay@4d2.org>");
> > +MODULE_LICENSE("GPL");
>
...
> --
> Yixun Lan (dlan)
> Gentoo Linux Developer
> GPG Key ID AABEFD55
Best regards,
Haylen Chu
WARNING: multiple messages have this Message-ID (diff)
From: Haylen Chu <heylenay@4d2.org>
To: Yixun Lan <dlan@gentoo.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Haylen Chu <heylenay@outlook.com>,
linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
spacemit@lists.linux.dev, Inochi Amaoto <inochiama@outlook.com>,
Chen Wang <unicornxdotw@foxmail.com>,
Jisheng Zhang <jszhang@kernel.org>,
Meng Zhang <zhangmeng.kevin@linux.spacemit.com>
Subject: Re: [PATCH v5 3/5] clk: spacemit: Add clock support for Spacemit K1 SoC
Date: Fri, 7 Mar 2025 06:42:02 +0000 [thread overview]
Message-ID: <Z8qVOssDHaVDQmLY@ketchup> (raw)
In-Reply-To: <20250307005149-GYA66361@gentoo>
On Fri, Mar 07, 2025 at 12:51:49AM +0000, Yixun Lan wrote:
> On 17:57 Thu 06 Mar , Haylen Chu wrote:
> > The clock tree of K1 SoC contains three main types of clock hardware
> > (PLL/DDN/MIX) and has control registers split into several multifunction
> > devices: APBS (PLLs), MPMU, APBC and APMU.
> >
> > All register operations are done through regmap to ensure atomiciy
> > between concurrent operations of clock driver and reset,
> > power-domain driver that will be introduced in the future.
> >
> > Signed-off-by: Haylen Chu <heylenay@4d2.org>
> > ---
> > drivers/clk/Kconfig | 1 +
> > drivers/clk/Makefile | 1 +
> > drivers/clk/spacemit/Kconfig | 20 +
> > drivers/clk/spacemit/Makefile | 5 +
> > drivers/clk/spacemit/ccu-k1.c | 1714 +++++++++++++++++++++++++++++
> > drivers/clk/spacemit/ccu_common.h | 47 +
> > drivers/clk/spacemit/ccu_ddn.c | 80 ++
> > drivers/clk/spacemit/ccu_ddn.h | 48 +
> > drivers/clk/spacemit/ccu_mix.c | 284 +++++
> > drivers/clk/spacemit/ccu_mix.h | 246 +++++
> > drivers/clk/spacemit/ccu_pll.c | 146 +++
> > drivers/clk/spacemit/ccu_pll.h | 76 ++
> > 12 files changed, 2668 insertions(+)
> > create mode 100644 drivers/clk/spacemit/Kconfig
> > create mode 100644 drivers/clk/spacemit/Makefile
> > create mode 100644 drivers/clk/spacemit/ccu-k1.c
> > create mode 100644 drivers/clk/spacemit/ccu_common.h
> > create mode 100644 drivers/clk/spacemit/ccu_ddn.c
> > create mode 100644 drivers/clk/spacemit/ccu_ddn.h
> > create mode 100644 drivers/clk/spacemit/ccu_mix.c
> > create mode 100644 drivers/clk/spacemit/ccu_mix.h
> > create mode 100644 drivers/clk/spacemit/ccu_pll.c
> > create mode 100644 drivers/clk/spacemit/ccu_pll.h
> >
> ..
> > +static int k1_ccu_probe(struct platform_device *pdev)
> > +{
> > + struct regmap *base_regmap, *lock_regmap = NULL;
> > + 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");
> > +
> > + 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);
> > +
> you can simplify above with syscon_regmap_lookup_by_phandle(), which
> would save a few lines
>
> or further, just call syscon_regmap_lookup_by_compatible()? then
> won't be necessary to introduce the "spacemit,mpmu" property..
>
These syscon_* functions differ a little from device_node_to_regmap():
they get and enable the first item in "clocks" property when
instantiating a regmap, which isn't desired for a clock controller.
> > + if (IS_ERR(lock_regmap))
> > + return dev_err_probe(dev, PTR_ERR(lock_regmap),
> > + "failed to get lock regmap\n");
> > + }
> > +
> > + ret = spacemit_ccu_register(dev, base_regmap, lock_regmap,
> > + of_device_get_match_data(dev));
> > + if (ret)
> > + return dev_err_probe(dev, ret, "failed to register clocks\n");
> > +
> > + return 0;
> > +}
> > +
> > +static const struct of_device_id of_k1_ccu_match[] = {
> > + {
> > + .compatible = "spacemit,k1-pll",
> > + .data = k1_ccu_apbs_clks,
> > + },
> > + {
> > + .compatible = "spacemit,k1-syscon-mpmu",
> > + .data = k1_ccu_mpmu_clks,
> > + },
> > + {
> > + .compatible = "spacemit,k1-syscon-apbc",
> > + .data = k1_ccu_apbc_clks,
> > + },
> > + {
> > + .compatible = "spacemit,k1-syscon-apmu",
> > + .data = k1_ccu_apmu_clks,
> > + },
> > + { }
> > +};
> > +MODULE_DEVICE_TABLE(of, of_k1_ccu_match);
> > +
> > +static struct platform_driver k1_ccu_driver = {
> > + .driver = {
> > + .name = "spacemit,k1-ccu",
> > + .of_match_table = of_k1_ccu_match,
> > + },
> > + .probe = k1_ccu_probe,
> > +};
> > +module_platform_driver(k1_ccu_driver);
> > +
> > +MODULE_DESCRIPTION("Spacemit K1 CCU driver");
> > +MODULE_AUTHOR("Haylen Chu <heylenay@4d2.org>");
> > +MODULE_LICENSE("GPL");
>
...
> --
> Yixun Lan (dlan)
> Gentoo Linux Developer
> GPG Key ID AABEFD55
Best regards,
Haylen Chu
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-03-07 6:42 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 17:57 [PATCH v5 0/5] Add clock controller support for SpacemiT K1 Haylen Chu
2025-03-06 17:57 ` Haylen Chu
2025-03-06 17:57 ` [PATCH v5 1/5] dt-bindings: soc: spacemit: Add spacemit,k1-syscon Haylen Chu
2025-03-06 17:57 ` Haylen Chu
2025-03-07 8:16 ` Krzysztof Kozlowski
2025-03-07 8:16 ` Krzysztof Kozlowski
2025-03-06 17:57 ` [PATCH v5 2/5] dt-bindings: clock: spacemit: Add spacemit,k1-pll Haylen Chu
2025-03-06 17:57 ` Haylen Chu
2025-03-07 0:29 ` Yixun Lan
2025-03-07 0:29 ` Yixun Lan
2025-03-07 6:34 ` Haylen Chu
2025-03-07 6:34 ` Haylen Chu
2025-03-07 8:20 ` Krzysztof Kozlowski
2025-03-07 8:20 ` Krzysztof Kozlowski
2025-03-07 8:19 ` Krzysztof Kozlowski
2025-03-07 8:19 ` Krzysztof Kozlowski
2025-03-06 17:57 ` [PATCH v5 3/5] clk: spacemit: Add clock support for Spacemit K1 SoC Haylen Chu
2025-03-06 17:57 ` Haylen Chu
2025-03-07 0:51 ` Yixun Lan
2025-03-07 0:51 ` Yixun Lan
2025-03-07 6:42 ` Haylen Chu [this message]
2025-03-07 6:42 ` Haylen Chu
2025-03-07 8:26 ` Krzysztof Kozlowski
2025-03-07 8:26 ` Krzysztof Kozlowski
2025-03-11 23:19 ` Alex Elder
2025-03-11 23:19 ` Alex Elder
2025-03-20 22:39 ` Alex Elder
2025-03-20 22:39 ` Alex Elder
2025-03-24 11:14 ` Haylen Chu
2025-03-24 11:14 ` Haylen Chu
2025-03-28 14:00 ` Alex Elder
2025-03-28 14:00 ` Alex Elder
2025-03-29 10:21 ` Haylen Chu
2025-03-29 10:21 ` Haylen Chu
2025-03-12 20:17 ` kernel test robot
2025-03-12 20:17 ` kernel test robot
2025-03-18 5:37 ` Yixun Lan
2025-03-18 5:37 ` Yixun Lan
2025-03-18 5:43 ` Inochi Amaoto
2025-03-18 5:43 ` Inochi Amaoto
2025-03-23 8:55 ` Haylen Chu
2025-03-23 8:55 ` Haylen Chu
2025-03-06 17:57 ` [PATCH v5 4/5] clk: spacemit: k1: Add TWSI8 bus and function clocks Haylen Chu
2025-03-06 17:57 ` Haylen Chu
2025-03-07 6:30 ` Haylen Chu
2025-03-07 6:30 ` Haylen Chu
2025-03-06 17:57 ` [PATCH v5 5/5] riscv: dts: spacemit: Add clock tree for Spacemit K1 Haylen Chu
2025-03-06 17:57 ` Haylen Chu
2025-03-07 1:55 ` Inochi Amaoto
2025-03-07 1:55 ` Inochi Amaoto
2025-03-07 6:28 ` Haylen Chu
2025-03-07 6:28 ` Haylen Chu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z8qVOssDHaVDQmLY@ketchup \
--to=heylenay@4d2.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=heylenay@outlook.com \
--cc=inochiama@outlook.com \
--cc=jszhang@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=spacemit@lists.linux.dev \
--cc=unicornxdotw@foxmail.com \
--cc=zhangmeng.kevin@linux.spacemit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.