arm64: kernel: introduce cpu_init_idle CPU operation
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Thu, 17 Jul 2014 09:30:07 +0000 (10:30 +0100)
committerMark Brown <broonie@kernel.org>
Sun, 18 Jan 2015 12:39:59 +0000 (12:39 +0000)
The CPUidle subsystem on ARM64 machines requires the idle states
implementation back-end to initialize idle states parameter upon
boot. This patch adds a hook in the CPU operations structure that
should be initialized by the CPU operations back-end in order to
provide a function that initializes cpu idle states.

This patch also adds the infrastructure to arm64 kernel required
to export the CPU operations based initialization interface, so
that drivers (ie CPUidle) can use it when they are initialized
at probe time.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit d64f84f696463c58e1908510e45b0f5d450f737a)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
arch/arm64/kernel/Makefile

arch/arm/kernel/Makefile
arch/arm64/include/asm/cpu_ops.h
arch/arm64/include/asm/cpuidle.h [new file with mode: 0644]
arch/arm64/kernel/Makefile
arch/arm64/kernel/cpuidle.c [new file with mode: 0644]

index 5f3338eacad21024a75d7b1e7480f3fc58e804b8..67b88007bb1847c6a1d4a0f04d099f92ab9e276d 100644 (file)
@@ -32,6 +32,7 @@ obj-$(CONFIG_ARTHUR)          += arthur.o
 obj-$(CONFIG_ISA_DMA)          += dma-isa.o
 obj-$(CONFIG_PCI)              += bios32.o isa.o
 obj-$(CONFIG_ARM_CPU_SUSPEND)  += sleep.o suspend.o
+obj-$(CONFIG_ARM_CPU_IDLE)     += cpuidle.o
 obj-$(CONFIG_SMP)              += smp.o smp_tlb.o
 obj-$(CONFIG_HAVE_ARM_SCU)     += smp_scu.o
 obj-$(CONFIG_HAVE_ARM_TWD)     += smp_twd.o
index c4cdb5e5b73d24027955169fb0e8be03972f7973..1229034d185b389459a6b614963ef23c9aeb9987 100644 (file)
@@ -28,6 +28,8 @@ struct device_node;
  *             enable-method property.
  * @cpu_init:  Reads any data necessary for a specific enable-method from the
  *             devicetree, for a given cpu node and proposed logical id.
+ * @cpu_init_idle: Reads any data necessary to initialize CPU idle states from
+ *             devicetree, for a given cpu node and proposed logical id.
  * @cpu_prepare: Early one-time preparation step for a cpu. If there is a
  *             mechanism for doing so, tests whether it is possible to boot
  *             the given CPU.
@@ -43,6 +45,7 @@ struct device_node;
 struct cpu_operations {
        const char      *name;
        int             (*cpu_init)(struct device_node *, unsigned int);
+       int             (*cpu_init_idle)(struct device_node *, unsigned int);
        int             (*cpu_prepare)(unsigned int);
        int             (*cpu_boot)(unsigned int);
        void            (*cpu_postboot)(void);
diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h
new file mode 100644 (file)
index 0000000..b52a993
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __ASM_CPUIDLE_H
+#define __ASM_CPUIDLE_H
+
+#ifdef CONFIG_CPU_IDLE
+extern int cpu_init_idle(unsigned int cpu);
+#else
+static inline int cpu_init_idle(unsigned int cpu)
+{
+       return -EOPNOTSUPP;
+}
+#endif
+
+#endif
index b9b87fa61bac2409703ae276312e28a28679d463..fc6d2710556317f7c82ac8f4050acaabcac4eec5 100644 (file)
@@ -18,6 +18,7 @@ arm64-obj-$(CONFIG_SMP)                       += smp.o smp_spin_table.o
 arm64-obj-$(CONFIG_HW_PERF_EVENTS)     += perf_event.o
 arm64-obj-$(CONFIG_HAVE_HW_BREAKPOINT)+= hw_breakpoint.o
 arm64-obj-$(CONFIG_EARLY_PRINTK)       += early_printk.o
+arm64-obj-$(CONFIG_CPU_IDLE)           += cpuidle.o
 arm64-obj-$(CONFIG_KGDB)               += kgdb.o
 
 obj-y                                  += $(arm64-obj-y) vdso/
diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c
new file mode 100644 (file)
index 0000000..19d17f5
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ARM64 CPU idle arch support
+ *
+ * Copyright (C) 2014 ARM Ltd.
+ * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+ *
+ * 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.
+ */
+
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <asm/cpuidle.h>
+#include <asm/cpu_ops.h>
+
+int cpu_init_idle(unsigned int cpu)
+{
+       int ret = -EOPNOTSUPP;
+       struct device_node *cpu_node = of_cpu_device_node_get(cpu);
+
+       if (!cpu_node)
+               return -ENODEV;
+
+       if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_init_idle)
+               ret = cpu_ops[cpu]->cpu_init_idle(cpu_node, cpu);
+
+       of_node_put(cpu_node);
+       return ret;
+}