From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sam Protsenko <semen.protsenko@linaro.org>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
Sasha Levin <sashal@kernel.org>,
tomasz.figa@gmail.com, cw00.choi@samsung.com,
mturquette@baylibre.com, sboyd@kernel.org,
matthias.bgg@gmail.com, linux-samsung-soc@vger.kernel.org,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH AUTOSEL 5.16 02/52] clk: samsung: exynos850: Register clocks early
Date: Mon, 17 Jan 2022 11:58:03 -0500 [thread overview]
Message-ID: <20220117165853.1470420-2-sashal@kernel.org> (raw)
In-Reply-To: <20220117165853.1470420-1-sashal@kernel.org>
From: Sam Protsenko <semen.protsenko@linaro.org>
[ Upstream commit bcda841f9bf2cddcf2f000cba96f2e27f6f2bdbf ]
Some clocks must be registered before init calls. For example MCT clock
(from CMU_PERI) is needed for MCT timer driver, which is registered
with TIMER_OF_DECLARE(). By the time we get to core_initcall() used for
clk-exynos850 platform driver init, it's already too late. Inability to
get "mct" clock in MCT driver leads to kernel panic, as functions
registered with *_OF_DECLARE() can't do deferred calls. MCT timer driver
can't be fixed either, as it's acting as a clock source and it's
essential to register it in start_kernel() -> time_init().
Let's register CMU_PERI clocks early, using CLK_OF_DECLARE(). CMU_TOP
generates clocks needed for CMU_PERI, but it's already registered early.
While at it, let's cleanup the code a bit, by extracting everything
related to CMU initialization and registration to the separate function.
Similar issue was discussed at [1] and addressed in commit 1f7db7bbf031
("clk: renesas: cpg-mssr: Add early clock support"), as well as in
drivers/clk/mediatek/clk-mt2712.c.
[1] https://patchwork.kernel.org/project/linux-renesas-soc/patch/20180829132954.64862-2-chris.brandt@renesas.com/
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20211122144206.23134-1-semen.protsenko@linaro.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/clk/samsung/clk-exynos850.c | 70 ++++++++++++++++++++---------
1 file changed, 49 insertions(+), 21 deletions(-)
diff --git a/drivers/clk/samsung/clk-exynos850.c b/drivers/clk/samsung/clk-exynos850.c
index 2294989e244c5..79cce8ba88831 100644
--- a/drivers/clk/samsung/clk-exynos850.c
+++ b/drivers/clk/samsung/clk-exynos850.c
@@ -60,6 +60,43 @@ static void __init exynos850_init_clocks(struct device_node *np,
iounmap(reg_base);
}
+/**
+ * exynos850_register_cmu - Register specified Exynos850 CMU domain
+ * @dev: Device object; may be NULL if this function is not being
+ * called from platform driver probe function
+ * @np: CMU device tree node
+ * @cmu: CMU data
+ *
+ * Register specified CMU domain, which includes next steps:
+ *
+ * 1. Enable parent clock of @cmu CMU
+ * 2. Set initial registers configuration for @cmu CMU clocks
+ * 3. Register @cmu CMU clocks using Samsung clock framework API
+ */
+static void __init exynos850_register_cmu(struct device *dev,
+ struct device_node *np, const struct samsung_cmu_info *cmu)
+{
+ /* Keep CMU parent clock running (needed for CMU registers access) */
+ if (cmu->clk_name) {
+ struct clk *parent_clk;
+
+ if (dev)
+ parent_clk = clk_get(dev, cmu->clk_name);
+ else
+ parent_clk = of_clk_get_by_name(np, cmu->clk_name);
+
+ if (IS_ERR(parent_clk)) {
+ pr_err("%s: could not find bus clock %s; err = %ld\n",
+ __func__, cmu->clk_name, PTR_ERR(parent_clk));
+ } else {
+ clk_prepare_enable(parent_clk);
+ }
+ }
+
+ exynos850_init_clocks(np, cmu->clk_regs, cmu->nr_clk_regs);
+ samsung_cmu_register_one(np, cmu);
+}
+
/* ---- CMU_TOP ------------------------------------------------------------- */
/* Register Offset definitions for CMU_TOP (0x120e0000) */
@@ -347,10 +384,10 @@ static const struct samsung_cmu_info top_cmu_info __initconst = {
static void __init exynos850_cmu_top_init(struct device_node *np)
{
- exynos850_init_clocks(np, top_clk_regs, ARRAY_SIZE(top_clk_regs));
- samsung_cmu_register_one(np, &top_cmu_info);
+ exynos850_register_cmu(NULL, np, &top_cmu_info);
}
+/* Register CMU_TOP early, as it's a dependency for other early domains */
CLK_OF_DECLARE(exynos850_cmu_top, "samsung,exynos850-cmu-top",
exynos850_cmu_top_init);
@@ -615,6 +652,15 @@ static const struct samsung_cmu_info peri_cmu_info __initconst = {
.clk_name = "dout_peri_bus",
};
+static void __init exynos850_cmu_peri_init(struct device_node *np)
+{
+ exynos850_register_cmu(NULL, np, &peri_cmu_info);
+}
+
+/* Register CMU_PERI early, as it's needed for MCT timer */
+CLK_OF_DECLARE(exynos850_cmu_peri, "samsung,exynos850-cmu-peri",
+ exynos850_cmu_peri_init);
+
/* ---- CMU_CORE ------------------------------------------------------------ */
/* Register Offset definitions for CMU_CORE (0x12000000) */
@@ -779,24 +825,9 @@ static int __init exynos850_cmu_probe(struct platform_device *pdev)
{
const struct samsung_cmu_info *info;
struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
info = of_device_get_match_data(dev);
- exynos850_init_clocks(np, info->clk_regs, info->nr_clk_regs);
- samsung_cmu_register_one(np, info);
-
- /* Keep bus clock running, so it's possible to access CMU registers */
- if (info->clk_name) {
- struct clk *bus_clk;
-
- bus_clk = clk_get(dev, info->clk_name);
- if (IS_ERR(bus_clk)) {
- pr_err("%s: could not find bus clock %s; err = %ld\n",
- __func__, info->clk_name, PTR_ERR(bus_clk));
- } else {
- clk_prepare_enable(bus_clk);
- }
- }
+ exynos850_register_cmu(dev, dev->of_node, info);
return 0;
}
@@ -806,9 +837,6 @@ static const struct of_device_id exynos850_cmu_of_match[] = {
{
.compatible = "samsung,exynos850-cmu-hsi",
.data = &hsi_cmu_info,
- }, {
- .compatible = "samsung,exynos850-cmu-peri",
- .data = &peri_cmu_info,
}, {
.compatible = "samsung,exynos850-cmu-core",
.data = &core_cmu_info,
--
2.34.1
next prev parent reply other threads:[~2022-01-17 16:59 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 16:58 [PATCH AUTOSEL 5.16 01/52] clk: imx: Use div64_ul instead of do_div Sasha Levin
2022-01-17 16:58 ` Sasha Levin [this message]
2022-01-17 17:11 ` [PATCH AUTOSEL 5.16 02/52] clk: samsung: exynos850: Register clocks early Krzysztof Kozlowski
2022-01-17 19:18 ` Sam Protsenko
2022-01-22 18:39 ` Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 03/52] powerpc/6xx: add missing of_node_put Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 04/52] powerpc/powernv: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 05/52] powerpc/cell: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 06/52] powerpc/btext: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 07/52] powerpc/watchdog: Fix missed watchdog reset due to memory ordering race Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 08/52] ASoC: imx-hdmi: add put_device() after of_find_device_by_node() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 09/52] i2c: i801: Don't silently correct invalid transfer size Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 10/52] powerpc/smp: Move setup_profiling_timer() under CONFIG_PROFILING Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 11/52] i2c: mpc: Correct I2C reset procedure Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 12/52] clk: meson: gxbb: Fix the SDM_EN bit for MPLL0 on GXBB Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 13/52] powerpc/powermac: Add missing lockdep_register_key() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 14/52] KVM: PPC: Book3S: Suppress warnings when allocating too big memory slots Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 15/52] KVM: PPC: Book3S: Suppress failed alloc warning in H_COPY_TOFROM_GUEST Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 16/52] w1: Misuse of get_user()/put_user() reported by sparse Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 17/52] nvmem: core: set size for sysfs bin file Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 18/52] dm: fix alloc_dax error handling in alloc_dev Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 19/52] dm: make the DAX support depend on CONFIG_FS_DAX Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 20/52] ASoC: test-component: fix null pointer dereference Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 21/52] interconnect: qcom: rpm: Prevent integer overflow in rate Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 22/52] scsi: ufs: Fix a kernel crash during shutdown Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 23/52] scsi: lpfc: Fix leaked lpfc_dmabuf mbox allocations with NPIV Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 24/52] scsi: lpfc: Trigger SLI4 firmware dump before doing driver cleanup Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 25/52] ALSA: seq: Set upper limit of processed events Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 26/52] MIPS: Loongson64: Use three arguments for slti Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 27/52] powerpc/40x: Map 32Mbytes of memory at startup Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 28/52] selftests/powerpc/spectre_v2: Return skip code when miss_percent is high Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 29/52] powerpc: handle kdump appropriately with crash_kexec_post_notifiers option Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 30/52] powerpc/fadump: Fix inaccurate CPU state info in vmcore generated with panic Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 31/52] ASoC: SOF: Intel: hda: add quirks for HDAudio DMA position information Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 32/52] udf: Fix error handling in udf_new_inode() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 33/52] MIPS: OCTEON: add put_device() after of_find_device_by_node() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 34/52] irqchip/gic-v4: Disable redistributors' view of the VPE table at boot time Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 35/52] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 36/52] PCI/MSI: Decouple MSI[-X] disable from pcim_release() Sasha Levin
2022-01-17 17:08 ` Greg Kroah-Hartman
2022-01-22 18:39 ` Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 37/52] scsi: hisi_sas: Prevent parallel FLR and controller reset Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 38/52] ASoC: SOF: ipc: Add null pointer check for substream->runtime Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 39/52] selftests/powerpc: Add a test of sigreturning to the kernel Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 40/52] MIPS: Octeon: Fix build errors using clang Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 41/52] scsi: sr: Don't use GFP_DMA Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 42/52] scsi: mpi3mr: Fixes around reply request queues Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 43/52] ASoC: mediatek: mt8192-mt6359: fix device_node leak Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 44/52] phy: phy-mtk-tphy: add support efuse setting Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 45/52] ASoC: mediatek: mt8173: fix device_node leak Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 46/52] ASoC: mediatek: mt8183: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 47/52] habanalabs: change wait for interrupt timeout to 64 bit Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 48/52] habanalabs: skip read fw errors if dynamic descriptor invalid Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 49/52] phy: mediatek: Fix missing check in mtk_mipi_tx_probe Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 50/52] ASoC: amd: acp: acp-mach: Change default RT1019 amp dev id Sasha Levin
2022-01-18 16:18 ` Mark Brown
2022-01-22 18:43 ` Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 51/52] mailbox: change mailbox-mpfs compatible string Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 52/52] leds: leds-fsg: Drop FSG3 LED driver Sasha Levin
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=20220117165853.1470420-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mturquette@baylibre.com \
--cc=s.nawrocki@samsung.com \
--cc=sboyd@kernel.org \
--cc=semen.protsenko@linaro.org \
--cc=stable@vger.kernel.org \
--cc=tomasz.figa@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).