Skip to contentSkip to conversation

cpufreq: hisilicon: add acpu driver

PATCH Superseded Leo Yan 3 participants 4 messages Mar 26, 2015 – Mar 27, 2015 CPU frequency scaling framework

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH v2 1/1 cpufreq: hisilicon: add acpu driver

Add acpu driver for hisilicon SoC, acpu is application processor subsystem. Currently the acpu has the coupled clock domain for two clusters, so this driver will directly use cpufreq-dt driver as backend.

---
 drivers/cpufreq/Kconfig.arm         |  9 ++++++++
 drivers/cpufreq/Makefile            |  1 +
 drivers/cpufreq/hisi-acpu-cpufreq.c | 43 +++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/cpufreq/hisi-acpu-cpufreq.c
drivers/cpufreq/Kconfig.arm +9 -0
index 1b06fc4..4f3dbc8 100644
@@ -108,6 +108,15 @@ config ARM_HIGHBANK_CPUFREQ
 
 	  If in doubt, say N.
 
+config ARM_HISI_ACPU_CPUFREQ
+	tristate "Hisilicon ACPU CPUfreq driver"
+	depends on ARCH_HISI && CPUFREQ_DT
+	select PM_OPP
+	help
+	  This enables the hisilicon ACPU CPUfreq driver.
+
+	  If in doubt, say N.
+
 config ARM_IMX6Q_CPUFREQ
 	tristate "Freescale i.MX6 cpufreq support"
 	depends on ARCH_MXC
drivers/cpufreq/Makefile +1 -0
index 82a1821..6b7a3f0 100644
@@ -59,6 +59,7 @@ arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)	+= exynos4x12-cpufreq.o
 arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)	+= exynos5250-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)	+= exynos5440-cpufreq.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ)	+= highbank-cpufreq.o
+obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ)	+= hisi-acpu-cpufreq.o
 obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)		+= imx6q-cpufreq.o
 obj-$(CONFIG_ARM_INTEGRATOR)		+= integrator-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)	+= kirkwood-cpufreq.o
drivers/cpufreq/hisi-acpu-cpufreq.c new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#1 lore raw

PATCH v2 1/1 cpufreq: hisilicon: add acpu driver

Quoted 84 lines · Leo Yan

Add acpu driver for hisilicon SoC, acpu is application processor subsystem. Currently the acpu has the coupled clock domain for two clusters, so this driver will directly use cpufreq-dt driver as backend.

---
 drivers/cpufreq/Kconfig.arm         |  9 ++++++++
 drivers/cpufreq/Makefile            |  1 +
 drivers/cpufreq/hisi-acpu-cpufreq.c | 43 +++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/cpufreq/hisi-acpu-cpufreq.c
drivers/cpufreq/Kconfig.arm +9 -0
index 1b06fc4..4f3dbc8 100644
@@ -108,6 +108,15 @@ config ARM_HIGHBANK_CPUFREQ
 
          If in doubt, say N.
 
+config ARM_HISI_ACPU_CPUFREQ
+       tristate "Hisilicon ACPU CPUfreq driver"
+       depends on ARCH_HISI && CPUFREQ_DT
+       select PM_OPP
+       help
+         This enables the hisilicon ACPU CPUfreq driver.
+
+         If in doubt, say N.
+
 config ARM_IMX6Q_CPUFREQ
        tristate "Freescale i.MX6 cpufreq support"
        depends on ARCH_MXC
drivers/cpufreq/Makefile +1 -0
index 82a1821..6b7a3f0 100644
@@ -59,6 +59,7 @@ arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)   += exynos4x12-cpufreq.o
 arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)    += exynos5250-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)   += exynos5440-cpufreq.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ)     += highbank-cpufreq.o
+obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ)    += hisi-acpu-cpufreq.o
 obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)                += imx6q-cpufreq.o
 obj-$(CONFIG_ARM_INTEGRATOR)           += integrator-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)     += kirkwood-cpufreq.o
drivers/cpufreq/hisi-acpu-cpufreq.c new file +33 -0
new file mode 100644
index 0000000..2c7a705
@@ -0,0 +1,43 @@
+/*
+ * Hisilicon Platforms Using ACPU CPUFreq Support
+ *
+ * Copyright (c) 2015 Hisilicon Limited.
+ * Copyright (c) 2015 Linaro Limited.
+ *
+ * Leo Yan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+static int __init hisi_acpu_cpufreq_driver_init(void)
+{
+       struct platform_device_info devinfo = { .name = "cpufreq-dt", };
+       struct platform_device *pdev;
+
+       if (!of_machine_is_compatible("hisilicon,hi6220"))

drivers/cpufreq/hisi-acpu-cpufreq.c line 43

Quoted 10 lines
drivers/cpufreq/hisi-acpu-cpufreq.c new file +10 -0
+               return -ENODEV;
+
+       pdev = platform_device_register_full(&devinfo);
+       return PTR_ERR_OR_ZERO(pdev);
+}
+module_init(hisi_acpu_cpufreq_driver_init);
+
+MODULE_AUTHOR("Leo Yan <[email protected]>");
+MODULE_DESCRIPTION("Hisilicon acpu cpufreq driver");
+MODULE_LICENSE("GPL v2");
#2 lore raw

PATCH v2 1/1 cpufreq: hisilicon: add acpu driver

In reply to Leo Yan
Quoted 78 lines · Leo Yan

Add acpu driver for hisilicon SoC, acpu is application processor subsystem. Currently the acpu has the coupled clock domain for two clusters, so this driver will directly use cpufreq-dt driver as backend.

---
  drivers/cpufreq/Kconfig.arm         |  9 ++++++++
  drivers/cpufreq/Makefile            |  1 +
  drivers/cpufreq/hisi-acpu-cpufreq.c | 43 +++++++++++++++++++++++++++++++++++++
  3 files changed, 53 insertions(+)

create mode 100644 drivers/cpufreq/hisi-acpu-cpufreq.c

drivers/cpufreq/Kconfig.arm +9 -0
index 1b06fc4..4f3dbc8 100644
@@ -108,6 +108,15 @@ config ARM_HIGHBANK_CPUFREQ
 
  	  If in doubt, say N.
 
+config ARM_HISI_ACPU_CPUFREQ
+	tristate "Hisilicon ACPU CPUfreq driver"
+	depends on ARCH_HISI && CPUFREQ_DT
+	select PM_OPP
+	help
+	  This enables the hisilicon ACPU CPUfreq driver.
+
+	  If in doubt, say N.
+
  config ARM_IMX6Q_CPUFREQ
  	tristate "Freescale i.MX6 cpufreq support"
  	depends on ARCH_MXC
drivers/cpufreq/Makefile +1 -0
index 82a1821..6b7a3f0 100644
@@ -59,6 +59,7 @@ arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)	+= exynos4x12-cpufreq.o
  arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)	+= exynos5250-cpufreq.o
  obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)	+= exynos5440-cpufreq.o
  obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ)	+= highbank-cpufreq.o
+obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ)	+= hisi-acpu-cpufreq.o
  obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)		+= imx6q-cpufreq.o
  obj-$(CONFIG_ARM_INTEGRATOR)		+= integrator-cpufreq.o
  obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)	+= kirkwood-cpufreq.o
drivers/cpufreq/hisi-acpu-cpufreq.c new file +27 -0
new file mode 100644
index 0000000..2c7a705
@@ -0,0 +1,43 @@
+/*
+ * Hisilicon Platforms Using ACPU CPUFreq Support
+ *
+ * Copyright (c) 2015 Hisilicon Limited.
+ * Copyright (c) 2015 Linaro Limited.
+ *
+ * Leo Yan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+

drivers/cpufreq/hisi-acpu-cpufreq.c line 37

Quoted 10 lines
drivers/cpufreq/hisi-acpu-cpufreq.c new file +10 -0
+static int __init hisi_acpu_cpufreq_driver_init(void)
+{
+	struct platform_device_info devinfo = { .name = "cpufreq-dt", };
+	struct platform_device *pdev;
+
+	if (!of_machine_is_compatible("hisilicon,hi6220"))
+		return -ENODEV;
+
+	pdev = platform_device_register_full(&devinfo);
+	return PTR_ERR_OR_ZERO(pdev);

Since you are not using anything other than name, you can simplify it further by something like:
platform_device_register_simple("cpufreq-dt", -1, NULL, 0)

And IMO it need not be a separate driver too, you can add this in mach if it exists(i.e. arm32 though not recommended) or clock code that registers cpu clock. Thoughts ?

Regards,
Sudeep

author
#3 lore raw

PATCH v2 1/1 cpufreq: hisilicon: add acpu driver

hi Sudeep,

Thanks for reviewing.

Quoted 16 lines · Sudeep Holla

drivers/cpufreq/hisi-acpu-cpufreq.c line 37

Quoted 10 lines · Leo Yan
drivers/cpufreq/hisi-acpu-cpufreq.c new file +10 -0
+static int __init hisi_acpu_cpufreq_driver_init(void)
+{
+	struct platform_device_info devinfo = { .name = "cpufreq-dt", };
+	struct platform_device *pdev;
+
+	if (!of_machine_is_compatible("hisilicon,hi6220"))
+		return -ENODEV;
+
+	pdev = platform_device_register_full(&devinfo);
+	return PTR_ERR_OR_ZERO(pdev);

Since you are not using anything other than name, you can simplify it further by something like:
platform_device_register_simple("cpufreq-dt", -1, NULL, 0)

Will use this way and resend patch.

Quoted 3 lines

And IMO it need not be a separate driver too, you can add this in mach if it exists(i.e. arm32 though not recommended) or clock code that registers cpu clock. Thoughts ?

This driver will be firstly used for hikey board w/t ARMv8 SoC and i prefer de-couple the cpufreq driver w/t clk driver. w/t this cpufreq driver, we can easily enhance it and init SoC's specific operations for later more hisilicon SoCs.

Thanks,
Leo Yan