Skip to contentSkip to conversation

ARM: mstar: cpupll

PATCH RESEND Superseded Romain Perier 3 participants 7 messages Jun 3, 2022 – Oct 5, 2022

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Romain Perier

author maintainer
#0 lore raw

v5 cover ARM: mstar: cpupll

This is a resend of the remaining patches of this series. I have kept the cover letter in order to do not loose context of the previous series.

This series adds a basic driver for the PLL that generates the cpu clock on MStar/SigmaStar ARMv7 SoCs.

Unfortunately there isn't much documentation for this thing so there are few magic values and guesses.

This needs to come after the MPLL DT changes.

Changes since v4:
- Removed merged patches (dt-bindings documentation and dt-bindings)
- Rebased onto 5.19

Changes since v3:
- Added Reviewed-by on Daniel's patches
- Removed "[PATCH v3 8/9] ARM: mstar: Add OPP table for mercury5"

Changes since v2:
- Re-ordered Kconfig by name
- Re-ordered includes alphabetically and removed useless ones
- Used timeout for cpu_relax
- Returned DIV_ROUND_DOWN_ULL() directly in msc313_cpupll_frequencyforreg()
- Returned DIV_ROUND_DOWN_ULL() directly in msc313_cpupll_regforfrequecy()
- Reduced the number of lines for msc313_cpupll_of_match
- Removed CLK_IS_CRITICAL

Changes since v1:
- Re-worked the series and ensure that 'make dt_binding_check' passes. The required commit is merged now, so it is okay.
- Fixed coding style issues in the driver and makes check_patch.pl happy
- Added one more commit for extending the opp_table for infinity2m.

Daniel Palmer (1):
clk: mstar: msc313 cpupll clk driver

 drivers/clk/mstar/Kconfig             |   8 +
 drivers/clk/mstar/Makefile            |   2 +-
 drivers/clk/mstar/clk-msc313-cpupll.c | 221 ++++++++++++++++++++++++++
 3 files changed, 230 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mstar/clk-msc313-cpupll.c
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH RESEND v5 1/1 clk: mstar: msc313 cpupll clk driver

From: Daniel Palmer <[email protected]>

Add a driver for the CPU pll/ARM pll/MIPS pll that is present in MStar SoCs.

Currently there is no documentation for this block so it's possible this driver isn't entirely correct.

Only tested on the version of this IP in the MStar/SigmaStar ARMv7 SoCs.

---
 drivers/clk/mstar/Kconfig             |   8 +
 drivers/clk/mstar/Makefile            |   2 +-
 drivers/clk/mstar/clk-msc313-cpupll.c | 221 ++++++++++++++++++++++++++
 3 files changed, 230 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mstar/clk-msc313-cpupll.c
drivers/clk/mstar/Kconfig +8 -0
index de37e1bce2d2..146eeb637318 100644
@@ -1,4 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config MSTAR_MSC313_CPUPLL
+	bool "MStar CPUPLL driver"
+	depends on ARCH_MSTARV7 || COMPILE_TEST
+	default ARCH_MSTARV7
+	help
+	  Support for the CPU PLL present on MStar/Sigmastar SoCs.
+
 config MSTAR_MSC313_MPLL
 	bool "MStar MPLL driver"
 	depends on ARCH_MSTARV7 || COMPILE_TEST
@@ -7,3 +14,4 @@ config MSTAR_MSC313_MPLL
 	help
 	  Support for the MPLL PLL and dividers block present on
 	  MStar/Sigmastar SoCs.
+
drivers/clk/mstar/Makefile +1 -1
index f8dcd25ede1d..21296a04e65a 100644
@@ -2,5 +2,5 @@
 #
 # Makefile for mstar specific clk
 #
-
+obj-$(CONFIG_MSTAR_MSC313_CPUPLL) += clk-msc313-cpupll.o
 obj-$(CONFIG_MSTAR_MSC313_MPLL) += clk-msc313-mpll.o
drivers/clk/mstar/clk-msc313-cpupll.c new file +221 -0

221 lines not on this page · raw message

Signature · 1 line
2.35.1
maintainer
#2 lore raw

Re: [PATCH RESEND v5 1/1] clk: mstar: msc313 cpupll clk driver

Quoting Romain Perier (2022-06-03 12:05:09)

Quoted 5 lines

From: Daniel Palmer <[email protected]>

Add a driver for the CPU pll/ARM pll/MIPS pll that is present in MStar SoCs.

Quoted 7 lines

Currently there is no documentation for this block so it's possible this driver isn't entirely correct.

Only tested on the version of this IP in the MStar/SigmaStar ARMv7 SoCs.

This is not a standard tag, maybe Co-developed-by is what you want? A Signed-off-by tag should be here from Willy Tarreau then.

Quoted 1 line

Your Signed-off-by needs to be here. I can't apply this otherwise.

Quoted 38 lines
drivers/clk/mstar/Kconfig +8 -0
index de37e1bce2d2..146eeb637318 100644
@@ -1,4 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config MSTAR_MSC313_CPUPLL
+       bool "MStar CPUPLL driver"
+       depends on ARCH_MSTARV7 || COMPILE_TEST
+       default ARCH_MSTARV7
+       help
+         Support for the CPU PLL present on MStar/Sigmastar SoCs.
+
 config MSTAR_MSC313_MPLL
        bool "MStar MPLL driver"
        depends on ARCH_MSTARV7 || COMPILE_TEST
@@ -7,3 +14,4 @@ config MSTAR_MSC313_MPLL
        help
          Support for the MPLL PLL and dividers block present on
          MStar/Sigmastar SoCs.
+
drivers/clk/mstar/Makefile +1 -1
index f8dcd25ede1d..21296a04e65a 100644
@@ -2,5 +2,5 @@
 #
 # Makefile for mstar specific clk
 #
-
+obj-$(CONFIG_MSTAR_MSC313_CPUPLL) += clk-msc313-cpupll.o
 obj-$(CONFIG_MSTAR_MSC313_MPLL) += clk-msc313-mpll.o
drivers/clk/mstar/clk-msc313-cpupll.c new file +0 -0
new file mode 100644
index 000000000000..c57b509e8c20

drivers/clk/mstar/clk-msc313-cpupll.c line 8

Quoted 8 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +8 -0
@@ -0,0 +1,221 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Daniel Palmer <[email protected]>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>

Ought to include kernel.h and device.h too.

Quoted 1 line
drivers/clk/mstar/clk-msc313-cpupll.c new file +1 -0
+

[...]

drivers/clk/mstar/clk-msc313-cpupll.c line 178

Quoted 13 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +13 -0
+
+static const struct clk_ops msc313_cpupll_ops = {
+       .recalc_rate    = msc313_cpupll_recalc_rate,
+       .round_rate     = msc313_cpupll_round_rate,
+       .set_rate       = msc313_cpupll_set_rate,
+};
+
+static const struct of_device_id msc313_cpupll_of_match[] = {
+       { .compatible = "mstar,msc313-cpupll" },
+       {}
+};
+
+static const struct clk_parent_data cpupll_parent = {

Why not put this on the stack? It doesn't have to live forever.

Quoted 23 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +23 -0
+       .index  = 0,
+};
+
+static int msc313_cpupll_probe(struct platform_device *pdev)
+{
+       struct clk_init_data clk_init = {};
+       struct device *dev = &pdev->dev;
+       struct msc313_cpupll *cpupll;
+       int ret;
+
+       cpupll = devm_kzalloc(&pdev->dev, sizeof(*cpupll), GFP_KERNEL);
+       if (!cpupll)
+               return -ENOMEM;
+
+       cpupll->base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(cpupll->base))
+               return PTR_ERR(cpupll->base);
+
+       /* LPF might not contain the current frequency so fix that up */
+       msc313_cpupll_reg_write32(cpupll, REG_LPF_LOW_L,
+                                 msc313_cpupll_reg_read32(cpupll, REG_CURRENT));
+
+       clk_init.name = dev_name(dev);

drivers/clk/mstar/clk-msc313-cpupll.c line 211

Quoted 10 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +10 -0
+       clk_init.ops = &msc313_cpupll_ops;
+       clk_init.parent_data = &cpupll_parent;
+       clk_init.num_parents = 1;
+       cpupll->clk_hw.init = &clk_init;
+
+       ret = devm_clk_hw_register(dev, &cpupll->clk_hw);
+       if (ret)
+               return ret;
+
+       return of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_simple_get, &cpupll->clk_hw);

Use devm to add the provider too.

#3 lore raw

Re: [PATCH RESEND v5 1/1] clk: mstar: msc313 cpupll clk driver

Hi Stephen,

Quoted 9 lines · Stephen Boyd

Quoting Romain Perier (2022-06-03 12:05:09)

Quoted 8 lines

From: Daniel Palmer <[email protected]>

Add a driver for the CPU pll/ARM pll/MIPS pll that is present in MStar SoCs.

Currently there is no documentation for this block so it's possible this driver isn't entirely correct.

Quoted 6 lines
Quoted 4 lines

Only tested on the version of this IP in the MStar/SigmaStar ARMv7 SoCs.

This is not a standard tag, maybe Co-developed-by is what you want?

Yeah it's the same. We're seeing 122 co-authored-by tags in the kernel's history vs 3122 co-developed-by, so that's only 3% but at least not a fantasist one..

Quoted 1 line

A Signed-off-by tag should be here from Willy Tarreau then.

Not all commits follow this, but indeed some do. Regardless I really don't care at all about my name being listed there.

Quoted 3 lines
Quoted 1 line

Your Signed-off-by needs to be here. I can't apply this otherwise.

Quite frankly, we're talking about an old patch that was first submitted 9 months ago (!), let's not postpone it even further just for headers reason, please just drop this line mentioning my little contribution, I don't care a single second at all, really.

Thanks,
Willy

author maintainer
#4 lore raw

Re: [PATCH RESEND v5 1/1] clk: mstar: msc313 cpupll clk driver

Hi,

Quiet frankly I don't want to debate about this , as is it seems to be basically "the rule" (see
https://www.kernel.org/doc/html/v6.0/process/submitting-patches.html).
It is okay for you Willy, if I transform your tag to "Co-developed-by:" plus a "Signed-off-by" ? So Stephen can apply it , and everyone is happy :)

Cheers,
Romain

Quoted 40 lines · Willy Tarreau

Hi Stephen,

Quoted 9 lines · Stephen Boyd

Quoting Romain Perier (2022-06-03 12:05:09)

Quoted 8 lines

From: Daniel Palmer <[email protected]>

Add a driver for the CPU pll/ARM pll/MIPS pll that is present in MStar SoCs.

Currently there is no documentation for this block so it's possible this driver isn't entirely correct.

Quoted 6 lines
Quoted 4 lines

Only tested on the version of this IP in the MStar/SigmaStar ARMv7 SoCs.

This is not a standard tag, maybe Co-developed-by is what you want?

Yeah it's the same. We're seeing 122 co-authored-by tags in the kernel's history vs 3122 co-developed-by, so that's only 3% but at least not a fantasist one..

Quoted 1 line

A Signed-off-by tag should be here from Willy Tarreau then.

Not all commits follow this, but indeed some do. Regardless I really don't care at all about my name being listed there.

Quoted 3 lines
Quoted 1 line

Your Signed-off-by needs to be here. I can't apply this otherwise.

Quite frankly, we're talking about an old patch that was first submitted 9 months ago (!), let's not postpone it even further just for headers reason, please just drop this line mentioning my little contribution, I don't care a single second at all, really.

Thanks,
Willy

#5 lore raw

Re: [PATCH RESEND v5 1/1] clk: mstar: msc313 cpupll clk driver

Quoted 8 lines · Romain Perier

Hi,

Quiet frankly I don't want to debate about this , as is it seems to be basically "the rule" (see
https://www.kernel.org/doc/html/v6.0/process/submitting-patches.html).
It is okay for you Willy, if I transform your tag to "Co-developed-by:" plus a "Signed-off-by" ? So Stephen can apply it , and everyone is happy :)

Yes absolutely! I just wanted to avoid yet another round trip. Many thanks Romain!

Willy

author maintainer
#6 lore raw

Re: [PATCH RESEND v5 1/1] clk: mstar: msc313 cpupll clk driver

In reply to Stephen Boyd

Hi,

Quoted 116 lines · Stephen Boyd

Quoting Romain Perier (2022-06-03 12:05:09)

Quoted 5 lines

From: Daniel Palmer <[email protected]>

Add a driver for the CPU pll/ARM pll/MIPS pll that is present in MStar SoCs.

Quoted 7 lines

Currently there is no documentation for this block so it's possible this driver isn't entirely correct.

Only tested on the version of this IP in the MStar/SigmaStar ARMv7 SoCs.

This is not a standard tag, maybe Co-developed-by is what you want? A Signed-off-by tag should be here from Willy Tarreau then.

Quoted 1 line

Your Signed-off-by needs to be here. I can't apply this otherwise.

Quoted 38 lines
drivers/clk/mstar/Kconfig +8 -0
index de37e1bce2d2..146eeb637318 100644
@@ -1,4 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config MSTAR_MSC313_CPUPLL
+       bool "MStar CPUPLL driver"
+       depends on ARCH_MSTARV7 || COMPILE_TEST
+       default ARCH_MSTARV7
+       help
+         Support for the CPU PLL present on MStar/Sigmastar SoCs.
+
 config MSTAR_MSC313_MPLL
        bool "MStar MPLL driver"
        depends on ARCH_MSTARV7 || COMPILE_TEST
@@ -7,3 +14,4 @@ config MSTAR_MSC313_MPLL
        help
          Support for the MPLL PLL and dividers block present on
          MStar/Sigmastar SoCs.
+
drivers/clk/mstar/Makefile +1 -1
index f8dcd25ede1d..21296a04e65a 100644
@@ -2,5 +2,5 @@
 #
 # Makefile for mstar specific clk
 #
-
+obj-$(CONFIG_MSTAR_MSC313_CPUPLL) += clk-msc313-cpupll.o
 obj-$(CONFIG_MSTAR_MSC313_MPLL) += clk-msc313-mpll.o
drivers/clk/mstar/clk-msc313-cpupll.c new file +0 -0
new file mode 100644
index 000000000000..c57b509e8c20

drivers/clk/mstar/clk-msc313-cpupll.c line 8

Quoted 8 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +8 -0
@@ -0,0 +1,221 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Daniel Palmer <[email protected]>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>

Ought to include kernel.h and device.h too.

Quoted 1 line
drivers/clk/mstar/clk-msc313-cpupll.c new file +1 -0
+

[...]

drivers/clk/mstar/clk-msc313-cpupll.c line 178

Quoted 13 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +13 -0
+
+static const struct clk_ops msc313_cpupll_ops = {
+       .recalc_rate    = msc313_cpupll_recalc_rate,
+       .round_rate     = msc313_cpupll_round_rate,
+       .set_rate       = msc313_cpupll_set_rate,
+};
+
+static const struct of_device_id msc313_cpupll_of_match[] = {
+       { .compatible = "mstar,msc313-cpupll" },
+       {}
+};
+
+static const struct clk_parent_data cpupll_parent = {

Why not put this on the stack? It doesn't have to live forever.

Quoted 27 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +27 -0
+       .index  = 0,
+};
+
+static int msc313_cpupll_probe(struct platform_device *pdev)
+{
+       struct clk_init_data clk_init = {};
+       struct device *dev = &pdev->dev;
+       struct msc313_cpupll *cpupll;
+       int ret;
+
+       cpupll = devm_kzalloc(&pdev->dev, sizeof(*cpupll), GFP_KERNEL);
+       if (!cpupll)
+               return -ENOMEM;
+
+       cpupll->base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(cpupll->base))
+               return PTR_ERR(cpupll->base);
+
+       /* LPF might not contain the current frequency so fix that up */
+       msc313_cpupll_reg_write32(cpupll, REG_LPF_LOW_L,
+                                 msc313_cpupll_reg_read32(cpupll, REG_CURRENT));
+
+       clk_init.name = dev_name(dev);
+       clk_init.ops = &msc313_cpupll_ops;
+       clk_init.parent_data = &cpupll_parent;
+       clk_init.num_parents = 1;
+       cpupll->clk_hw.init = &clk_init;
Quoted 8 lines

drivers/clk/mstar/clk-msc313-cpupll.c line 211

Quoted 6 lines
drivers/clk/mstar/clk-msc313-cpupll.c new file +6 -0
+
+       ret = devm_clk_hw_register(dev, &cpupll->clk_hw);
+       if (ret)
+               return ret;
+
+       return of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_simple_get, &cpupll->clk_hw);

Use devm to add the provider too.

Ok, it does not seem to be huge to change, I will send another iteration.

Thanks,
Cheers,
Romain