Skip to contentSkip to conversation

pmdomain: airoha: Add Airoha CPU PM Domain support

PATCH In review Christian Marangi 3 participants 5 messages Jan 9, 2025 – Jan 17, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v10 1/2 pmdomain: airoha: Add Airoha CPU PM Domain support

Add Airoha CPU PM Domain support to control frequency and power of CPU present on Airoha EN7581 SoC.

Frequency and power can be controlled with the use of the SMC command by passing the performance state. The driver also expose a read-only clock that expose the current CPU frequency with SMC command.

---
Changes v10:
- Depends on HAVE_ARM_SMCCC
Changes v9:
- Fix compile error targetting wrong branch (remove_new change) Changes v8:
- Add this patch
- Use SMC invoke instead of 1.2

 drivers/pmdomain/mediatek/Kconfig             |  12 ++
 drivers/pmdomain/mediatek/Makefile            |   1 +
 .../pmdomain/mediatek/airoha-cpu-pmdomain.c   | 144 ++++++++++++++++++
 3 files changed, 157 insertions(+)
 create mode 100644 drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c
drivers/pmdomain/mediatek/Kconfig +12 -0
index 21305c4f17fe..0e34a517ab7d 100644
@@ -26,4 +26,16 @@ config MTK_SCPSYS_PM_DOMAINS
 	  Control Processor System (SCPSYS) has several power management related
 	  tasks in the system.
 
+config AIROHA_CPU_PM_DOMAIN
+	tristate "Airoha CPU power domain"
+	default ARCH_AIROHA
+	depends on HAVE_ARM_SMCCC
+	depends on PM
+	select PM_GENERIC_DOMAINS
+	help
+	  Say y here to enable CPU power domain support for Airoha SoC.
+
+	  CPU frequency and power is controlled by ATF with SMC command to
+	  set performance states.
+
 endmenu
drivers/pmdomain/mediatek/Makefile +1 -0
index 8cde09e654b3..0f6edce9239b 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_MTK_SCPSYS)		+= mtk-scpsys.o
 obj-$(CONFIG_MTK_SCPSYS_PM_DOMAINS) 	+= mtk-pm-domains.o
+obj-$(CONFIG_AIROHA_CPU_PM_DOMAIN) 	+= airoha-cpu-pmdomain.o
drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.45.2
#1 lore raw

PATCH v10 2/2 cpufreq: airoha: Add EN7581 CPUFreq SMCCC driver

Add simple CPU Freq driver for Airoha EN7581 SoC that control CPU frequency scaling with SMC APIs and register a generic "cpufreq-dt" device.

All CPU share the same frequency and can't be controlled independently. CPU frequency is controlled by the attached PM domain.

Add SoC compatible to cpufreq-dt-plat block list as a dedicated cpufreq driver is needed with OPP v2 nodes declared in DTS.

---
Changes v9:
- Fix compile error targetting wrong branch (remove_new change and new PM OPs) Changes v8:
- Split in dedicated PM domain driver
Changes v7:
- No changes
Changes v6:
- Improve Kconfig depends logic
- Select PM (PM_GENERIC_DOMAINS depends on it)
- Drop (int) cast for
Changes v5:
- Rename cpu_pd to perf for power domain name
- Use remove instead of remove_new
Changes v4:
- Rework to clk-only + PM set_performance_state implementation Changes v3:
- Adapt to new cpufreq-dt APIs
- Register cpufreq-dt instead of custom freq driver
Changes v2:
- Fix kernel bot error with missing slab.h and bitfield.h header
- Limit COMPILE_TEST to ARM64 due to smcc 1.2

 drivers/cpufreq/Kconfig.arm          |   8 ++
 drivers/cpufreq/Makefile             |   1 +
 drivers/cpufreq/airoha-cpufreq.c     | 152 +++++++++++++++++++++++++++
 drivers/cpufreq/cpufreq-dt-platdev.c |   2 +
 4 files changed, 163 insertions(+)
 create mode 100644 drivers/cpufreq/airoha-cpufreq.c
drivers/cpufreq/Kconfig.arm +8 -0
index 5f7e13e60c80..704e84d00639 100644
@@ -15,6 +15,14 @@ config ARM_ALLWINNER_SUN50I_CPUFREQ_NVMEM
 	  To compile this driver as a module, choose M here: the
 	  module will be called sun50i-cpufreq-nvmem.
 
+config ARM_AIROHA_SOC_CPUFREQ
+	tristate "Airoha EN7581 SoC CPUFreq support"
+	depends on ARCH_AIROHA || COMPILE_TEST
+	select PM_OPP
+	default ARCH_AIROHA
+	help
+	  This adds the CPUFreq driver for Airoha EN7581 SoCs.
+
 config ARM_APPLE_SOC_CPUFREQ
 	tristate "Apple Silicon SoC CPUFreq support"
 	depends on ARCH_APPLE || (COMPILE_TEST && 64BIT)
drivers/cpufreq/Makefile +1 -0
index d35a28dd9463..890fff99f37d 100644
@@ -53,6 +53,7 @@ obj-$(CONFIG_X86_AMD_FREQ_SENSITIVITY)	+= amd_freq_sensitivity.o
 
 ##################################################################################
 # ARM SoC drivers
+obj-$(CONFIG_ARM_AIROHA_SOC_CPUFREQ)	+= airoha-cpufreq.o
 obj-$(CONFIG_ARM_APPLE_SOC_CPUFREQ)	+= apple-soc-cpufreq.o
 obj-$(CONFIG_ARM_ARMADA_37XX_CPUFREQ)	+= armada-37xx-cpufreq.o
 obj-$(CONFIG_ARM_ARMADA_8K_CPUFREQ)	+= armada-8k-cpufreq.o
drivers/cpufreq/airoha-cpufreq.c new file +152 -0

152 lines not on this page · raw message

drivers/cpufreq/cpufreq-dt-platdev.c +2 -0
index 9c198bd4f7e9..2aa00769cf09 100644
@@ -103,6 +103,8 @@ static const struct of_device_id allowlist[] __initconst = {
  * platforms using "operating-points-v2" property.
  */
 static const struct of_device_id blocklist[] __initconst = {
+	{ .compatible = "airoha,en7581", },
+
 	{ .compatible = "allwinner,sun50i-a100" },
 	{ .compatible = "allwinner,sun50i-h6", },
 	{ .compatible = "allwinner,sun50i-h616", },
Signature · 1 line
2.45.2
maintainer
#2 lore raw
In reply to Christian Marangi

Ulf,

Quoted 8 lines · Christian Marangi

Add Airoha CPU PM Domain support to control frequency and power of CPU present on Airoha EN7581 SoC.

Frequency and power can be controlled with the use of the SMC command by passing the performance state. The driver also expose a read-only clock that expose the current CPU frequency with SMC command.

Quoted 8 lines

---
Changes v10:
- Depends on HAVE_ARM_SMCCC
Changes v9:
- Fix compile error targetting wrong branch (remove_new change) Changes v8:
- Add this patch
- Use SMC invoke instead of 1.2

Any inputs on this ?

Signature · 1 line
viresh
#3 lore raw
Quoted 21 lines · Viresh Kumar

Ulf,

Quoted 8 lines · Christian Marangi

Add Airoha CPU PM Domain support to control frequency and power of CPU present on Airoha EN7581 SoC.

Frequency and power can be controlled with the use of the SMC command by passing the performance state. The driver also expose a read-only clock that expose the current CPU frequency with SMC command.

Quoted 8 lines

---
Changes v10:
- Depends on HAVE_ARM_SMCCC
Changes v9:
- Fix compile error targetting wrong branch (remove_new change) Changes v8:
- Add this patch
- Use SMC invoke instead of 1.2

Quoted 1 line

Any inputs on this ?

Apologize for the delay! This looks good to me! So, applied for next to my pmdomain tree, thanks!

I assume Viresh will take the cpufreq patch via his tree? Please let me know if you prefer another route.

Kind regards
Uffe

maintainer
#4 lore raw
Quoted 22 lines · Ulf Hansson
Quoted 21 lines · Viresh Kumar

Ulf,

Quoted 16 lines · Christian Marangi

Add Airoha CPU PM Domain support to control frequency and power of CPU present on Airoha EN7581 SoC.

Frequency and power can be controlled with the use of the SMC command by passing the performance state. The driver also expose a read-only clock that expose the current CPU frequency with SMC command.

---
Changes v10:
- Depends on HAVE_ARM_SMCCC
Changes v9:
- Fix compile error targetting wrong branch (remove_new change) Changes v8:
- Add this patch
- Use SMC invoke instead of 1.2

Quoted 7 lines
Quoted 1 line

Any inputs on this ?

Apologize for the delay! This looks good to me! So, applied for next to my pmdomain tree, thanks!

I assume Viresh will take the cpufreq patch via his tree? Please let me know if you prefer another route.

Applied 2/2. Thanks.

Signature · 1 line
viresh