2023-12-18 11:06:53

by Brandon Cheo Fusi

[permalink] [raw]
Subject: [PATCH v2 0/5] cpufreq support for the D1

This patch series adds support for cpufreq on the D1 SoC, and has been
tested on a Lichee RV module.

Changes in v2:
- Revert opp-microvolt-speed0 property to <target min max>
- Add dt-bindings for "allwinner,sun50i-h6-operating-points"
- Enable sun50i h6 cpufreq multiarch support by moving Kconfig option
to drivers/cpufreq/Kconfig instead of creating
drivers/cpufreq/Kconfig.riscv

Brandon Cheo Fusi (5):
riscv: dts: allwinner: Update opp table to allow CPU frequency scaling
dt-bindings: opp: sun50i: Add binding for D1 CPUs
cpufreq: sun50i: Add D1 support
cpufreq: dt-platdev: Blocklist allwinner,sun20i-d1 SoC
cpufreq: Make sun50i h6 cpufreq Kconfig option arch generic

.../allwinner,sun50i-h6-operating-points.yaml | 4 +++-
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi | 18 +++++++++++++++---
drivers/cpufreq/Kconfig | 12 ++++++++++++
drivers/cpufreq/Kconfig.arm | 12 ------------
drivers/cpufreq/Makefile | 2 +-
drivers/cpufreq/cpufreq-dt-platdev.c | 1 +
drivers/cpufreq/sun50i-cpufreq-nvmem.c | 1 +
7 files changed, 33 insertions(+), 17 deletions(-)

--
2.30.2



2023-12-18 11:08:05

by Brandon Cheo Fusi

[permalink] [raw]
Subject: [PATCH v2 3/5] cpufreq: sun50i: Add D1 support

Add support for D1 based devices to the Allwinner H6 cpufreq
driver

Signed-off-by: Brandon Cheo Fusi <[email protected]>
---
drivers/cpufreq/sun50i-cpufreq-nvmem.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
index 32a9c88f8..ccf83780f 100644
--- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
@@ -160,6 +160,7 @@ static struct platform_driver sun50i_cpufreq_driver = {

static const struct of_device_id sun50i_cpufreq_match_list[] = {
{ .compatible = "allwinner,sun50i-h6" },
+ { .compatible = "allwinner,sun20i-d1" },
{}
};
MODULE_DEVICE_TABLE(of, sun50i_cpufreq_match_list);
--
2.30.2


2023-12-18 11:08:42

by Brandon Cheo Fusi

[permalink] [raw]
Subject: [PATCH v2 5/5] cpufreq: Make sun50i h6 cpufreq Kconfig option arch generic

Move the Allwinner SUN50I cpufreq driver from Kconfig.arm to the
main Kconfig file so it supports other architectures, like RISC-V
in our case, and drop the 'ARM_' prefix.

Signed-off-by: Brandon Cheo Fusi <[email protected]>
---
drivers/cpufreq/Kconfig | 12 ++++++++++++
drivers/cpufreq/Kconfig.arm | 12 ------------
drivers/cpufreq/Makefile | 2 +-
3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 35efb53d5..50aa66cfc 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -301,5 +301,17 @@ config QORIQ_CPUFREQ
This adds the CPUFreq driver support for Freescale QorIQ SoCs
which are capable of changing the CPU's frequency dynamically.

+config ALLWINNER_SUN50I_CPUFREQ_NVMEM
+ tristate "Allwinner nvmem based SUN50I CPUFreq driver"
+ depends on ARCH_SUNXI
+ depends on NVMEM_SUNXI_SID
+ select PM_OPP
+ help
+ This adds the nvmem based CPUFreq driver for Allwinner
+ h6/D1 SoCs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called sun50i-cpufreq-nvmem.
+
endif
endmenu
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index f91160689..98b8e6eef 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -29,18 +29,6 @@ config ACPI_CPPC_CPUFREQ_FIE

If in doubt, say N.

-config ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM
- tristate "Allwinner nvmem based SUN50I CPUFreq driver"
- depends on ARCH_SUNXI
- depends on NVMEM_SUNXI_SID
- select PM_OPP
- help
- This adds the nvmem based CPUFreq driver for Allwinner
- h6 SoC.
-
- To compile this driver as a module, choose M here: the
- module will be called sun50i-cpufreq-nvmem.
-
config ARM_APPLE_SOC_CPUFREQ
tristate "Apple Silicon SoC CPUFreq support"
depends on ARCH_APPLE || (COMPILE_TEST && 64BIT)
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 8d141c71b..110b676d2 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -78,7 +78,7 @@ obj-$(CONFIG_ARM_SCMI_CPUFREQ) += scmi-cpufreq.o
obj-$(CONFIG_ARM_SCPI_CPUFREQ) += scpi-cpufreq.o
obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o
obj-$(CONFIG_ARM_STI_CPUFREQ) += sti-cpufreq.o
-obj-$(CONFIG_ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM) += sun50i-cpufreq-nvmem.o
+obj-$(CONFIG_ALLWINNER_SUN50I_CPUFREQ_NVMEM) += sun50i-cpufreq-nvmem.o
obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o
obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o
obj-$(CONFIG_ARM_TEGRA186_CPUFREQ) += tegra186-cpufreq.o
--
2.30.2


2023-12-18 11:09:07

by Brandon Cheo Fusi

[permalink] [raw]
Subject: [PATCH v2 2/5] dt-bindings: opp: sun50i: Add binding for D1 CPUs

Add binding for D1 CPU OPPs.

Signed-off-by: Brandon Cheo Fusi <[email protected]>
---
.../bindings/opp/allwinner,sun50i-h6-operating-points.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml b/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
index 51f62c3ae..fddaa3216 100644
--- a/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
+++ b/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
@@ -23,7 +23,9 @@ allOf:

properties:
compatible:
- const: allwinner,sun50i-h6-operating-points
+ enum:
+ - allwinner,sun50i-h6-operating-points
+ - allwinner,sun20i-d1-operating-points

nvmem-cells:
description: |
--
2.30.2


2023-12-18 11:10:05

by Brandon Cheo Fusi

[permalink] [raw]
Subject: [PATCH v2 4/5] cpufreq: dt-platdev: Blocklist allwinner,sun20i-d1 SoC

The Allwinner D1 uses H6 cpufreq driver. Add it to blocklist
so the "cpufreq-dt" device is not created twice.

Signed-off-by: Brandon Cheo Fusi <[email protected]>
---
drivers/cpufreq/cpufreq-dt-platdev.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index bd1e1357c..2febcfc2c 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -104,6 +104,7 @@ static const struct of_device_id allowlist[] __initconst = {
*/
static const struct of_device_id blocklist[] __initconst = {
{ .compatible = "allwinner,sun50i-h6", },
+ { .compatible = "allwinner,sun20i-d1", },

{ .compatible = "apple,arm-platform", },

--
2.30.2


2023-12-18 14:54:54

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2 2/5] dt-bindings: opp: sun50i: Add binding for D1 CPUs

On Mon, Dec 18, 2023 at 12:05:40PM +0100, Brandon Cheo Fusi wrote:
> Add binding for D1 CPU OPPs.
>
> Signed-off-by: Brandon Cheo Fusi <[email protected]>
> ---
> .../bindings/opp/allwinner,sun50i-h6-operating-points.yaml | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml b/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
> index 51f62c3ae..fddaa3216 100644
> --- a/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
> +++ b/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
> @@ -23,7 +23,9 @@ allOf:
>
> properties:
> compatible:
> - const: allwinner,sun50i-h6-operating-points
> + enum:
> + - allwinner,sun50i-h6-operating-points
> + - allwinner,sun20i-d1-operating-points

This doesn't match what you have in your devicetree.

>
> nvmem-cells:
> description: |
> --
> 2.30.2
>


Attachments:
(No filename) (1.03 kB)
signature.asc (235.00 B)
Download all attachments

2023-12-18 14:55:58

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] cpufreq: sun50i: Add D1 support

On Mon, Dec 18, 2023 at 12:05:41PM +0100, Brandon Cheo Fusi wrote:
> Add support for D1 based devices to the Allwinner H6 cpufreq
> driver
>
> Signed-off-by: Brandon Cheo Fusi <[email protected]>
> ---
> drivers/cpufreq/sun50i-cpufreq-nvmem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> index 32a9c88f8..ccf83780f 100644
> --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> @@ -160,6 +160,7 @@ static struct platform_driver sun50i_cpufreq_driver = {
>
> static const struct of_device_id sun50i_cpufreq_match_list[] = {
> { .compatible = "allwinner,sun50i-h6" },
> + { .compatible = "allwinner,sun20i-d1" },

I thought the feedback in v2 was to drop this change, since the
devicetree has the sun50i-h6 as a fallback compatible?


Attachments:
(No filename) (900.00 B)
signature.asc (235.00 B)
Download all attachments

2023-12-18 15:54:21

by Andre Przywara

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] cpufreq: sun50i: Add D1 support

On Mon, 18 Dec 2023 14:55:30 +0000
Conor Dooley <[email protected]> wrote:

Hi,

> On Mon, Dec 18, 2023 at 12:05:41PM +0100, Brandon Cheo Fusi wrote:
> > Add support for D1 based devices to the Allwinner H6 cpufreq
> > driver
> >
> > Signed-off-by: Brandon Cheo Fusi <[email protected]>
> > ---
> > drivers/cpufreq/sun50i-cpufreq-nvmem.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > index 32a9c88f8..ccf83780f 100644
> > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > @@ -160,6 +160,7 @@ static struct platform_driver sun50i_cpufreq_driver = {
> >
> > static const struct of_device_id sun50i_cpufreq_match_list[] = {
> > { .compatible = "allwinner,sun50i-h6" },
> > + { .compatible = "allwinner,sun20i-d1" },
>
> I thought the feedback in v2 was to drop this change, since the
> devicetree has the sun50i-h6 as a fallback compatible?

Well, this is the *board* (fallback) compatible string, so we cannot assign
it as we like. The whole (existing) scheme is admittedly somewhat weird,
because we not only match on a particular device compatible
(like allwinner,sun20i-d1-operating-points), but also need to blocklist and
re-match some parts against the *board compatible*, owing to the
cpufreq-dt driver. The board name is basically used as a placeholder to
find out the SoC, because there is (or was?) no other good way - the
CPU DT nodes don't work for this. Back when this was introduced, this was
the "least worst" solution.

I don't remember all the details, and didn't find time yet to look into
this in more detail, but fixing this is non-trivial. If this isn't 6.8
material, I might have a look at this later this week/month.

Cheers,
Andre

2023-12-18 16:15:28

by Jernej Škrabec

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] cpufreq: sun50i: Add D1 support

Dne ponedeljek, 18. december 2023 ob 16:53:45 CET je Andre Przywara napisal(a):
> On Mon, 18 Dec 2023 14:55:30 +0000
> Conor Dooley <[email protected]> wrote:
>
> Hi,
>
> > On Mon, Dec 18, 2023 at 12:05:41PM +0100, Brandon Cheo Fusi wrote:
> > > Add support for D1 based devices to the Allwinner H6 cpufreq
> > > driver
> > >
> > > Signed-off-by: Brandon Cheo Fusi <[email protected]>
> > > ---
> > > drivers/cpufreq/sun50i-cpufreq-nvmem.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > index 32a9c88f8..ccf83780f 100644
> > > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > @@ -160,6 +160,7 @@ static struct platform_driver sun50i_cpufreq_driver = {
> > >
> > > static const struct of_device_id sun50i_cpufreq_match_list[] = {
> > > { .compatible = "allwinner,sun50i-h6" },
> > > + { .compatible = "allwinner,sun20i-d1" },
> >
> > I thought the feedback in v2 was to drop this change, since the
> > devicetree has the sun50i-h6 as a fallback compatible?
>
> Well, this is the *board* (fallback) compatible string, so we cannot assign
> it as we like. The whole (existing) scheme is admittedly somewhat weird,
> because we not only match on a particular device compatible
> (like allwinner,sun20i-d1-operating-points), but also need to blocklist and
> re-match some parts against the *board compatible*, owing to the
> cpufreq-dt driver. The board name is basically used as a placeholder to
> find out the SoC, because there is (or was?) no other good way - the
> CPU DT nodes don't work for this. Back when this was introduced, this was
> the "least worst" solution.
>
> I don't remember all the details, and didn't find time yet to look into
> this in more detail, but fixing this is non-trivial. If this isn't 6.8
> material, I might have a look at this later this week/month.

I would say it's 6.9 material. -rc6 already passed and it's not yet aligned
with all maintainers.

Best regards,
Jernej



2023-12-18 16:25:14

by Jernej Škrabec

[permalink] [raw]
Subject: Re: [PATCH v2 5/5] cpufreq: Make sun50i h6 cpufreq Kconfig option arch generic

Dne ponedeljek, 18. december 2023 ob 12:05:43 CET je Brandon Cheo Fusi napisal(a):
> Move the Allwinner SUN50I cpufreq driver from Kconfig.arm to the
> main Kconfig file so it supports other architectures, like RISC-V
> in our case, and drop the 'ARM_' prefix.
>
> Signed-off-by: Brandon Cheo Fusi <[email protected]>
> ---
> drivers/cpufreq/Kconfig | 12 ++++++++++++
> drivers/cpufreq/Kconfig.arm | 12 ------------
> drivers/cpufreq/Makefile | 2 +-
> 3 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
> index 35efb53d5..50aa66cfc 100644
> --- a/drivers/cpufreq/Kconfig
> +++ b/drivers/cpufreq/Kconfig
> @@ -301,5 +301,17 @@ config QORIQ_CPUFREQ
> This adds the CPUFreq driver support for Freescale QorIQ SoCs
> which are capable of changing the CPU's frequency dynamically.
>
> +config ALLWINNER_SUN50I_CPUFREQ_NVMEM
> + tristate "Allwinner nvmem based SUN50I CPUFreq driver"
> + depends on ARCH_SUNXI
> + depends on NVMEM_SUNXI_SID
> + select PM_OPP
> + help
> + This adds the nvmem based CPUFreq driver for Allwinner
> + h6/D1 SoCs.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called sun50i-cpufreq-nvmem.
> +
> endif
> endmenu
> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
> index f91160689..98b8e6eef 100644
> --- a/drivers/cpufreq/Kconfig.arm
> +++ b/drivers/cpufreq/Kconfig.arm
> @@ -29,18 +29,6 @@ config ACPI_CPPC_CPUFREQ_FIE
>
> If in doubt, say N.
>
> -config ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM
> - tristate "Allwinner nvmem based SUN50I CPUFreq driver"
> - depends on ARCH_SUNXI
> - depends on NVMEM_SUNXI_SID
> - select PM_OPP
> - help
> - This adds the nvmem based CPUFreq driver for Allwinner
> - h6 SoC.
> -
> - To compile this driver as a module, choose M here: the
> - module will be called sun50i-cpufreq-nvmem.
> -
> config ARM_APPLE_SOC_CPUFREQ
> tristate "Apple Silicon SoC CPUFreq support"
> depends on ARCH_APPLE || (COMPILE_TEST && 64BIT)
> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
> index 8d141c71b..110b676d2 100644
> --- a/drivers/cpufreq/Makefile
> +++ b/drivers/cpufreq/Makefile
> @@ -78,7 +78,7 @@ obj-$(CONFIG_ARM_SCMI_CPUFREQ) += scmi-cpufreq.o
> obj-$(CONFIG_ARM_SCPI_CPUFREQ) += scpi-cpufreq.o
> obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o
> obj-$(CONFIG_ARM_STI_CPUFREQ) += sti-cpufreq.o
> -obj-$(CONFIG_ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM) += sun50i-cpufreq-nvmem.o
> +obj-$(CONFIG_ALLWINNER_SUN50I_CPUFREQ_NVMEM) += sun50i-cpufreq-nvmem.o

This should be moved, so it's sorted alphabetically.

Best regards,
Jernej

> obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o
> obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o
> obj-$(CONFIG_ARM_TEGRA186_CPUFREQ) += tegra186-cpufreq.o
>





2023-12-18 16:27:53

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2 3/5] cpufreq: sun50i: Add D1 support

On Mon, Dec 18, 2023 at 03:53:45PM +0000, Andre Przywara wrote:
> On Mon, 18 Dec 2023 14:55:30 +0000
> Conor Dooley <[email protected]> wrote:
>
> Hi,
>
> > On Mon, Dec 18, 2023 at 12:05:41PM +0100, Brandon Cheo Fusi wrote:
> > > Add support for D1 based devices to the Allwinner H6 cpufreq
> > > driver
> > >
> > > Signed-off-by: Brandon Cheo Fusi <[email protected]>
> > > ---
> > > drivers/cpufreq/sun50i-cpufreq-nvmem.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > index 32a9c88f8..ccf83780f 100644
> > > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > @@ -160,6 +160,7 @@ static struct platform_driver sun50i_cpufreq_driver = {
> > >
> > > static const struct of_device_id sun50i_cpufreq_match_list[] = {
> > > { .compatible = "allwinner,sun50i-h6" },
> > > + { .compatible = "allwinner,sun20i-d1" },
> >
> > I thought the feedback in v2 was to drop this change, since the
> > devicetree has the sun50i-h6 as a fallback compatible?
>
> Well, this is the *board* (fallback) compatible string, so we cannot assign

Oh of course... That's both me and Jernej that tripped up on this.
Brandon, please ignore the comment from me on this patch.

Thanks,
Conor.


Attachments:
(No filename) (1.34 kB)
signature.asc (235.00 B)
Download all attachments

2023-12-18 16:28:17

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2 2/5] dt-bindings: opp: sun50i: Add binding for D1 CPUs

On Mon, Dec 18, 2023 at 02:54:35PM +0000, Conor Dooley wrote:
> On Mon, Dec 18, 2023 at 12:05:40PM +0100, Brandon Cheo Fusi wrote:
> > Add binding for D1 CPU OPPs.
> >
> > Signed-off-by: Brandon Cheo Fusi <[email protected]>
> > ---
> > .../bindings/opp/allwinner,sun50i-h6-operating-points.yaml | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml b/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
> > index 51f62c3ae..fddaa3216 100644
> > --- a/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
> > +++ b/Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.yaml
> > @@ -23,7 +23,9 @@ allOf:
> >
> > properties:
> > compatible:
> > - const: allwinner,sun50i-h6-operating-points
> > + enum:
> > + - allwinner,sun50i-h6-operating-points
> > + - allwinner,sun20i-d1-operating-points
>
> This doesn't match what you have in your devicetree.

Per Samuel's comments in
<[email protected]>
it looks like this binding is correct but the devicetree is wrong.

Thanks,
Conor.


Attachments:
(No filename) (1.23 kB)
signature.asc (235.00 B)
Download all attachments