linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] ARM: vexpress/TC2: cpufreq support
@ 2013-10-16 13:52 Sudeep KarkadaNagesha
  2013-10-16 13:52 ` [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys Sudeep KarkadaNagesha
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-16 13:52 UTC (permalink / raw)
  To: linux-arm-kernel, cpufreq, linux-pm
  Cc: Sudeep.KarkadaNagesha, Pawel Moll, Nicolas Pitre, Viresh Kumar,
	Lorenzo Pieralisi, Sudeep KarkadaNagesha

From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

Hi,

The SPC(Serial Power Controller) on Versatile Express V2P-CA15_A7(TC2)
not only controls low-power states, wake-up irqs and per-CPU jump addresses
but also the CPU performance operating points which is essential to provide
CPU DVFS. The M3 microcontroller can provide upto eight performance values,
one set for each cluster (CA15 or CA7). Each of this value contains the
frequency(kHz) and voltage(mV) at that performance level. It expects
these performance level to be passed through the SPC PERF_LVL registers.
    
This patch series adds support to populate those OPPs, add them to the
cpu devices and runtime programming of these performance levels through
clock framework. It also adds a small interface cpufreq driver to validate
the OPPs and register the arm_big_little cpufreq driver.

Regards,
Sudeep

Sudeep KarkadaNagesha (5):
  cpufreq: arm-big-little: use clk_get instead of clk_get_sys
  ARM: vexpress/TC2: add support for CPU DVFS
  ARM: vexpress/TC2: add cpu clock support
  cpufreq: arm_big_little: add vexpress SPC interface driver
  ARM: vexpress/TC2: register vexpress-spc cpufreq device

 arch/arm/mach-vexpress/Kconfig         |   2 +
 arch/arm/mach-vexpress/spc.c           | 361 ++++++++++++++++++++++++++++++++-
 arch/arm/mach-vexpress/spc.h           |   2 +-
 arch/arm/mach-vexpress/tc2_pm.c        |   7 +-
 drivers/cpufreq/Kconfig.arm            |   8 +
 drivers/cpufreq/Makefile               |   1 +
 drivers/cpufreq/arm_big_little.c       |   2 +-
 drivers/cpufreq/vexpress-spc-cpufreq.c |  69 +++++++
 8 files changed, 447 insertions(+), 5 deletions(-)
 create mode 100644 drivers/cpufreq/vexpress-spc-cpufreq.c

-- 
1.8.1.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys
  2013-10-16 13:52 [PATCH 0/5] ARM: vexpress/TC2: cpufreq support Sudeep KarkadaNagesha
@ 2013-10-16 13:52 ` Sudeep KarkadaNagesha
  2013-10-16 22:52   ` Rafael J. Wysocki
  2013-10-16 13:52 ` [PATCH 2/5] ARM: vexpress/TC2: add support for CPU DVFS Sudeep KarkadaNagesha
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-16 13:52 UTC (permalink / raw)
  To: linux-arm-kernel, cpufreq, linux-pm
  Cc: Sudeep.KarkadaNagesha, Pawel Moll, Nicolas Pitre, Viresh Kumar,
	Lorenzo Pieralisi, Sudeep KarkadaNagesha

From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

Currently clk_get_sys is used with cpu-cluster.<n> as the device id
which is incorrect. It should be connection/consumer ID instead.

It is possible to specify input clock in the cpu device node along
with the optional clock-name. clk_get_sys can't handle that.

This patch replaces clk_get_sys with clk_get to extend support for
clocks specified in the device tree cpu node.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/arm_big_little.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index 3549f07..501a091 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -127,7 +127,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev)
 	}
 
 	name[12] = cluster + '0';
-	clk[cluster] = clk_get_sys(name, NULL);
+	clk[cluster] = clk_get(cpu_dev, name);
 	if (!IS_ERR(clk[cluster])) {
 		dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n",
 				__func__, clk[cluster], freq_table[cluster],
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5] ARM: vexpress/TC2: add support for CPU DVFS
  2013-10-16 13:52 [PATCH 0/5] ARM: vexpress/TC2: cpufreq support Sudeep KarkadaNagesha
  2013-10-16 13:52 ` [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys Sudeep KarkadaNagesha
@ 2013-10-16 13:52 ` Sudeep KarkadaNagesha
  2013-10-18 18:27   ` Nicolas Pitre
  2013-10-16 13:52 ` [PATCH 3/5] ARM: vexpress/TC2: add cpu clock support Sudeep KarkadaNagesha
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-16 13:52 UTC (permalink / raw)
  To: linux-arm-kernel, cpufreq, linux-pm
  Cc: Sudeep.KarkadaNagesha, Pawel Moll, Nicolas Pitre, Viresh Kumar,
	Lorenzo Pieralisi, Sudeep KarkadaNagesha, Pawel Moll

From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

SPC(Serial Power Controller) on TC2 also controls the CPU performance
operating points which is essential to provide CPU DVFS. The M3
microcontroller provides two sets of eight performance values, one set
for each cluster (CA15 or CA7). Each of this value contains the
frequency(kHz) and voltage(mV) at that performance level. It expects
these performance level to be passed through the SPC PERF_LVL registers.

This patch adds support to populate these performance levels from M3,
build the mapping to CPU OPPs at the boot and then use it to get and
set the CPU performance level runtime.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Cc: Pawel Moll <Pawel.Moll@arm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm/mach-vexpress/Kconfig  |   2 +
 arch/arm/mach-vexpress/spc.c    | 240 +++++++++++++++++++++++++++++++++++++++-
 arch/arm/mach-vexpress/spc.h    |   2 +-
 arch/arm/mach-vexpress/tc2_pm.c |   7 +-
 4 files changed, 247 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 3657954..5989187 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -1,5 +1,7 @@
 config ARCH_VEXPRESS
 	bool "ARM Ltd. Versatile Express family" if ARCH_MULTI_V7
+	select ARCH_HAS_CPUFREQ
+	select ARCH_HAS_OPP
 	select ARCH_REQUIRE_GPIOLIB
 	select ARM_AMBA
 	select ARM_GIC
diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index eefb029..ef7e652 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -17,14 +17,26 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/opp.h>
 #include <linux/slab.h>
+#include <linux/semaphore.h>
 
 #include <asm/cacheflush.h>
 
 #define SPCLOG "vexpress-spc: "
 
+#define PERF_LVL_A15		0x00
+#define PERF_REQ_A15		0x04
+#define PERF_LVL_A7		0x08
+#define PERF_REQ_A7		0x0c
+#define COMMS			0x10
+#define COMMS_REQ		0x14
+#define PWC_STATUS		0x18
+#define PWC_FLAG		0x1c
 /* SPC wake-up IRQs status and mask */
 #define WAKE_INT_MASK		0x24
 #define WAKE_INT_RAW		0x28
@@ -35,6 +47,18 @@
 /* SPC per-CPU mailboxes */
 #define A15_BX_ADDR0		0x68
 #define A7_BX_ADDR0		0x78
+/* SPC system config interface registers */
+#define SYSCFG_WDATA		0x70
+#define SYSCFG_RDATA		0x74
+
+/* A15/A7 OPP virtual register base */
+#define A15_PERFVAL_BASE	0xC10
+#define A7_PERFVAL_BASE		0xC30
+
+/* Config interface control bits */
+#define SYSCFG_START		(1 << 31)
+#define SYSCFG_SCC		(6 << 20)
+#define SYSCFG_STAT		(14 << 20)
 
 /* wake-up interrupt masks */
 #define GBL_WAKEUP_INT_MSK	(0x3 << 10)
@@ -42,6 +66,26 @@
 /* TC2 static dual-cluster configuration */
 #define MAX_CLUSTERS		2
 
+/*
+ * Even though the SPC takes max 3-5 ms to complete any OPP/COMMS
+ * operation, the operation could start just before jiffie is about
+ * to be incremented. So setting timeout value of 20ms = 2jiffies@100Hz
+ */
+#define TIMEOUT_US	20000
+
+#define MAX_OPPS	8
+#define CA15_DVFS	0
+#define CA7_DVFS	1
+#define SPC_SYS_CFG	2
+#define STAT_COMPLETE(type)	((1 << 0) << (type << 2))
+#define STAT_ERR(type)		((1 << 1) << (type << 2))
+#define RESPONSE_MASK(type)	(STAT_COMPLETE(type) | STAT_ERR(type))
+
+struct ve_spc_opp {
+	unsigned long freq;
+	unsigned long u_volt;
+};
+
 struct ve_spc_drvdata {
 	void __iomem *baseaddr;
 	/*
@@ -49,6 +93,12 @@ struct ve_spc_drvdata {
 	 * It corresponds to A15 processors MPIDR[15:8] bitfield
 	 */
 	u32 a15_clusid;
+	uint32_t cur_rsp_mask;
+	uint32_t cur_rsp_stat;
+	struct semaphore sem;
+	struct completion done;
+	struct ve_spc_opp *opps[MAX_CLUSTERS];
+	int num_opps[MAX_CLUSTERS];
 };
 
 static struct ve_spc_drvdata *info;
@@ -157,8 +207,177 @@ void ve_spc_powerdown(u32 cluster, bool enable)
 	writel_relaxed(enable, info->baseaddr + pwdrn_reg);
 }
 
-int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid)
+static int ve_spc_get_performance(int cluster, u32 *freq)
+{
+	struct ve_spc_opp *opps = info->opps[cluster];
+	u32 perf_cfg_reg = 0;
+	int perf;
+
+	perf_cfg_reg = cluster_is_a15(cluster) ? PERF_LVL_A15 : PERF_LVL_A7;
+
+	perf = readl_relaxed(info->baseaddr + perf_cfg_reg);
+	opps += perf;
+	*freq = opps->freq;
+
+	return 0;
+}
+
+/* find closest match to given frequency in OPP table */
+static int ve_spc_round_performance(int cluster, u32 freq)
+{
+	int idx, max_opp = info->num_opps[cluster];
+	struct ve_spc_opp *opps = info->opps[cluster];
+	u32 fmin = 0, fmax = ~0, ftmp;
+
+	freq /= 1000; /* OPP entries in kHz */
+	for (idx = 0; idx < max_opp; idx++, opps++) {
+		ftmp = opps->freq;
+		if (ftmp >= freq) {
+			if (ftmp <= fmax)
+				fmax = ftmp;
+		} else {
+			if (ftmp >= fmin)
+				fmin = ftmp;
+		}
+	}
+	if (fmax != ~0)
+		return fmax * 1000;
+	else
+		return fmin * 1000;
+}
+
+static int ve_spc_find_performance_index(int cluster, u32 freq)
+{
+	int idx, max_opp = info->num_opps[cluster];
+	struct ve_spc_opp *opps = info->opps[cluster];
+
+	for (idx = 0; idx < max_opp; idx++, opps++)
+		if (opps->freq == freq)
+			break;
+	return (idx == max_opp) ? -EINVAL : idx;
+}
+
+static int ve_spc_waitforcompletion(int req_type)
+{
+	int ret = wait_for_completion_interruptible_timeout(
+			&info->done, usecs_to_jiffies(TIMEOUT_US));
+	if (ret == 0)
+		ret = -ETIMEDOUT;
+	else if (ret > 0)
+		ret = info->cur_rsp_stat & STAT_COMPLETE(req_type) ? 0 : -EIO;
+	return ret;
+}
+
+static int ve_spc_set_performance(int cluster, u32 freq)
+{
+	u32 perf_cfg_reg, perf_stat_reg;
+	int ret, perf, req_type;
+
+	if (cluster_is_a15(cluster)) {
+		req_type = CA15_DVFS;
+		perf_cfg_reg = PERF_LVL_A15;
+		perf_stat_reg = PERF_REQ_A15;
+	} else {
+		req_type = CA7_DVFS;
+		perf_cfg_reg = PERF_LVL_A7;
+		perf_stat_reg = PERF_REQ_A7;
+	}
+
+	perf = ve_spc_find_performance_index(cluster, freq);
+
+	if (perf < 0)
+		return perf;
+
+	if (down_timeout(&info->sem, usecs_to_jiffies(TIMEOUT_US)))
+		return -ETIME;
+
+	init_completion(&info->done);
+	info->cur_rsp_mask = RESPONSE_MASK(req_type);
+
+	writel(perf, info->baseaddr + perf_cfg_reg);
+	ret = ve_spc_waitforcompletion(req_type);
+
+	info->cur_rsp_mask = 0;
+	up(&info->sem);
+
+	return ret;
+}
+
+static int ve_spc_read_sys_cfg(int func, int offset, uint32_t *data)
+{
+	int ret;
+
+	if (down_timeout(&info->sem, usecs_to_jiffies(TIMEOUT_US)))
+		return -ETIME;
+
+	init_completion(&info->done);
+	info->cur_rsp_mask = RESPONSE_MASK(SPC_SYS_CFG);
+
+	/* Set the control value */
+	writel(SYSCFG_START | func | offset >> 2, info->baseaddr + COMMS);
+	ret = ve_spc_waitforcompletion(SPC_SYS_CFG);
+
+	if (ret == 0)
+		*data = readl(info->baseaddr + SYSCFG_RDATA);
+
+	info->cur_rsp_mask = 0;
+	up(&info->sem);
+
+	return ret;
+}
+
+static irqreturn_t ve_spc_irq_handler(int irq, void *data)
+{
+	struct ve_spc_drvdata *drv_data = data;
+	uint32_t status = readl_relaxed(drv_data->baseaddr + PWC_STATUS);
+
+	if (info->cur_rsp_mask & status) {
+		info->cur_rsp_stat = status;
+		complete(&drv_data->done);
+	}
+
+	return IRQ_HANDLED;
+}
+
+/*
+ *  +--------------------------+
+ *  | 31      20 | 19        0 |
+ *  +--------------------------+
+ *  |   u_volt   |  freq(kHz)  |
+ *  +--------------------------+
+ */
+#define MULT_FACTOR	20
+#define VOLT_SHIFT	20
+#define FREQ_MASK	(0xFFFFF)
+static int ve_spc_populate_opps(uint32_t cluster)
+{
+	uint32_t data = 0, off, ret, idx;
+	struct ve_spc_opp *opps;
+
+	opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL);
+	if (!opps)
+		return -ENOMEM;
+
+	info->opps[cluster] = opps;
+
+	off = cluster_is_a15(cluster) ? A15_PERFVAL_BASE : A7_PERFVAL_BASE;
+	for (idx = 0; idx < MAX_OPPS; idx++, off += 4, opps++) {
+		ret = ve_spc_read_sys_cfg(SYSCFG_SCC, off, &data);
+		if (!ret) {
+			opps->freq = (data & FREQ_MASK) * MULT_FACTOR;
+			opps->u_volt = data >> VOLT_SHIFT;
+		} else {
+			break;
+		}
+	}
+	info->num_opps[cluster] = idx;
+
+	return ret;
+}
+
+int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)
 {
+	int ret;
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
 		pr_err(SPCLOG "unable to allocate mem\n");
@@ -168,6 +387,25 @@ int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid)
 	info->baseaddr = baseaddr;
 	info->a15_clusid = a15_clusid;
 
+	if (irq <= 0) {
+		pr_err(SPCLOG "Invalid IRQ %d\n", irq);
+		kfree(info);
+		return -EINVAL;
+	}
+
+	init_completion(&info->done);
+
+	readl_relaxed(info->baseaddr + PWC_STATUS);
+
+	ret = request_irq(irq, ve_spc_irq_handler, IRQF_TRIGGER_HIGH
+				| IRQF_ONESHOT, "vexpress-spc", info);
+	if (ret) {
+		pr_err(SPCLOG "IRQ %d request failed\n", irq);
+		kfree(info);
+		return -ENODEV;
+	}
+
+	sema_init(&info->sem, 1);
 	/*
 	 * Multi-cluster systems may need this data when non-coherent, during
 	 * cluster power-up/power-down. Make sure driver info reaches main
diff --git a/arch/arm/mach-vexpress/spc.h b/arch/arm/mach-vexpress/spc.h
index 5f7e4a4..dbd44c3 100644
--- a/arch/arm/mach-vexpress/spc.h
+++ b/arch/arm/mach-vexpress/spc.h
@@ -15,7 +15,7 @@
 #ifndef __SPC_H_
 #define __SPC_H_
 
-int __init ve_spc_init(void __iomem *base, u32 a15_clusid);
+int __init ve_spc_init(void __iomem *base, u32 a15_clusid, int irq);
 void ve_spc_global_wakeup_irq(bool set);
 void ve_spc_cpu_wakeup_irq(u32 cluster, u32 cpu, bool set);
 void ve_spc_set_resume_addr(u32 cluster, u32 cpu, u32 addr);
diff --git a/arch/arm/mach-vexpress/tc2_pm.c b/arch/arm/mach-vexpress/tc2_pm.c
index e6eb481..d38130a 100644
--- a/arch/arm/mach-vexpress/tc2_pm.c
+++ b/arch/arm/mach-vexpress/tc2_pm.c
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
 #include <linux/irqchip/arm-gic.h>
@@ -311,7 +312,7 @@ static void __naked tc2_pm_power_up_setup(unsigned int affinity_level)
 
 static int __init tc2_pm_init(void)
 {
-	int ret;
+	int ret, irq;
 	void __iomem *scc;
 	u32 a15_cluster_id, a7_cluster_id, sys_info;
 	struct device_node *np;
@@ -336,13 +337,15 @@ static int __init tc2_pm_init(void)
 	tc2_nr_cpus[a15_cluster_id] = (sys_info >> 16) & 0xf;
 	tc2_nr_cpus[a7_cluster_id] = (sys_info >> 20) & 0xf;
 
+	irq = irq_of_parse_and_map(np, 0);
+
 	/*
 	 * A subset of the SCC registers is also used to communicate
 	 * with the SPC (power controller). We need to be able to
 	 * drive it very early in the boot process to power up
 	 * processors, so we initialize the SPC driver here.
 	 */
-	ret = ve_spc_init(scc + SPC_BASE, a15_cluster_id);
+	ret = ve_spc_init(scc + SPC_BASE, a15_cluster_id, irq);
 	if (ret)
 		return ret;
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5] ARM: vexpress/TC2: add cpu clock support
  2013-10-16 13:52 [PATCH 0/5] ARM: vexpress/TC2: cpufreq support Sudeep KarkadaNagesha
  2013-10-16 13:52 ` [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys Sudeep KarkadaNagesha
  2013-10-16 13:52 ` [PATCH 2/5] ARM: vexpress/TC2: add support for CPU DVFS Sudeep KarkadaNagesha
@ 2013-10-16 13:52 ` Sudeep KarkadaNagesha
  2013-10-18 18:53   ` Nicolas Pitre
  2013-10-16 13:52 ` [PATCH 4/5] cpufreq: arm_big_little: add vexpress SPC interface driver Sudeep KarkadaNagesha
  2013-10-16 13:52 ` [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device Sudeep KarkadaNagesha
  4 siblings, 1 reply; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-16 13:52 UTC (permalink / raw)
  To: linux-arm-kernel, cpufreq, linux-pm
  Cc: Sudeep.KarkadaNagesha, Pawel Moll, Nicolas Pitre, Viresh Kumar,
	Lorenzo Pieralisi, Sudeep KarkadaNagesha, Pawel Moll

From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

On TC2, the cpu clocks are controlled by the external M3 microcontroller
and SPC provides the interface between the CPU and the power controller.

The generic cpufreq drivers use the clock APIs to get the cpu clocks.
This patch add virtual spc clocks for all the cpus to control the cpu
operating frequency via the clock framework.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Cc: Pawel Moll <Pawel.Moll@arm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm/mach-vexpress/spc.c | 119 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 119 insertions(+)

diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index ef7e652..a8b8310 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -17,6 +17,9 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/cpu.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
@@ -416,3 +419,119 @@ int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)
 
 	return 0;
 }
+
+struct clk_spc {
+	struct clk_hw hw;
+	int cluster;
+};
+
+#define to_clk_spc(spc) container_of(spc, struct clk_spc, hw)
+static unsigned long spc_recalc_rate(struct clk_hw *hw,
+		unsigned long parent_rate)
+{
+	struct clk_spc *spc = to_clk_spc(hw);
+	u32 freq;
+
+	if (ve_spc_get_performance(spc->cluster, &freq))
+		return -EIO;
+
+	return freq * 1000;
+}
+
+static long spc_round_rate(struct clk_hw *hw, unsigned long drate,
+		unsigned long *parent_rate)
+{
+	struct clk_spc *spc = to_clk_spc(hw);
+
+	return ve_spc_round_performance(spc->cluster, drate);
+}
+
+static int spc_set_rate(struct clk_hw *hw, unsigned long rate,
+		unsigned long parent_rate)
+{
+	struct clk_spc *spc = to_clk_spc(hw);
+
+	return ve_spc_set_performance(spc->cluster, rate / 1000);
+}
+
+static struct clk_ops clk_spc_ops = {
+	.recalc_rate = spc_recalc_rate,
+	.round_rate = spc_round_rate,
+	.set_rate = spc_set_rate,
+};
+
+static struct clk *ve_spc_clk_register(struct device *cpu_dev)
+{
+	struct clk_init_data init;
+	struct clk_spc *spc;
+
+	spc = kzalloc(sizeof(*spc), GFP_KERNEL);
+	if (!spc) {
+		pr_err("could not allocate spc clk\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	spc->hw.init = &init;
+	spc->cluster = topology_physical_package_id(cpu_dev->id);
+
+	init.name = dev_name(cpu_dev);
+	init.ops = &clk_spc_ops;
+	init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE;
+	init.num_parents = 0;
+
+	return devm_clk_register(cpu_dev, &spc->hw);
+}
+
+static int ve_init_opp_table(struct device *cpu_dev)
+{
+	int cluster = topology_physical_package_id(cpu_dev->id);
+	int idx, ret = 0, max_opp = info->num_opps[cluster];
+	struct ve_spc_opp *opps = info->opps[cluster];
+
+	for (idx = 0; idx < max_opp; idx++, opps++) {
+		ret = opp_add(cpu_dev, opps->freq * 1000, opps->u_volt);
+		if (ret) {
+			dev_warn(cpu_dev, "failed to add opp %lu %lu\n",
+				 opps->freq, opps->u_volt);
+			return ret;
+		}
+	}
+	return ret;
+}
+
+static int __init ve_spc_clk_init(void)
+{
+	int cpu;
+	struct clk *clk;
+
+	if (!info)
+		return 0; /* Continue only if SPC is initialised */
+
+	if (ve_spc_populate_opps(0) || ve_spc_populate_opps(1)) {
+		pr_err("failed to build OPP table\n");
+		return -ENODEV;
+	}
+
+	for_each_possible_cpu(cpu) {
+		struct device *cpu_dev = get_cpu_device(cpu);
+		if (!cpu_dev) {
+			pr_warn("failed to get cpu%d device\n", cpu);
+			continue;
+		}
+		clk = ve_spc_clk_register(cpu_dev);
+		if (IS_ERR(clk)) {
+			pr_warn("failed to register cpu%d clock\n", cpu);
+			continue;
+		}
+		if (clk_register_clkdev(clk, NULL, dev_name(cpu_dev))) {
+			pr_warn("failed to register cpu%d clock lookup\n", cpu);
+			continue;
+		}
+
+		if (ve_init_opp_table(cpu_dev))
+			pr_warn("failed to initialise cpu%d opp table\n", cpu);
+	}
+
+	return 0;
+}
+module_init(ve_spc_clk_init);
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5] cpufreq: arm_big_little: add vexpress SPC interface driver
  2013-10-16 13:52 [PATCH 0/5] ARM: vexpress/TC2: cpufreq support Sudeep KarkadaNagesha
                   ` (2 preceding siblings ...)
  2013-10-16 13:52 ` [PATCH 3/5] ARM: vexpress/TC2: add cpu clock support Sudeep KarkadaNagesha
@ 2013-10-16 13:52 ` Sudeep KarkadaNagesha
  2013-10-18 18:59   ` Nicolas Pitre
  2013-10-16 13:52 ` [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device Sudeep KarkadaNagesha
  4 siblings, 1 reply; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-16 13:52 UTC (permalink / raw)
  To: linux-arm-kernel, cpufreq, linux-pm
  Cc: Sudeep.KarkadaNagesha, Pawel Moll, Nicolas Pitre, Viresh Kumar,
	Lorenzo Pieralisi, Sudeep KarkadaNagesha

From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

The TC2(i.e. CA15_A7) Versatile Express has external Cortex M3 based
power controller which is responsible for CPU DVFS and SPC provides
the interface for the same.

This patch adds a tiny interface driver to check if OPPs are
initialised by SPC platform code and register the arm_big_little
cpufreq driver.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/Kconfig.arm            |  8 ++++
 drivers/cpufreq/Makefile               |  1 +
 drivers/cpufreq/vexpress-spc-cpufreq.c | 69 ++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 drivers/cpufreq/vexpress-spc-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 0fa204b..d3bf733 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -235,3 +235,11 @@ config ARM_TEGRA_CPUFREQ
 	default y
 	help
 	  This adds the CPUFreq driver support for TEGRA SOCs.
+
+config ARM_VEXPRESS_SPC_CPUFREQ
+        tristate "Versatile Express SPC based CPUfreq driver"
+        select ARM_BIG_LITTLE_CPUFREQ
+        depends on ARCH_VEXPRESS_TC2_PM
+        help
+          This add the CPUfreq driver support for Versatile Express
+	  big.LITTLE platforms using SPC for power management.
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index ad5866c..a1c390f 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SA1100_CPUFREQ)	+= sa1100-cpufreq.o
 obj-$(CONFIG_ARM_SA1110_CPUFREQ)	+= sa1110-cpufreq.o
 obj-$(CONFIG_ARM_SPEAR_CPUFREQ)		+= spear-cpufreq.o
 obj-$(CONFIG_ARM_TEGRA_CPUFREQ)		+= tegra-cpufreq.o
+obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ)	+= vexpress-spc-cpufreq.o
 
 ##################################################################################
 # PowerPC platform drivers
diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c
new file mode 100644
index 0000000..f0508bf
--- /dev/null
+++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
@@ -0,0 +1,69 @@
+/*
+ * Versatile Express SPC CPUFreq Interface driver
+ *
+ * It provides necessary ops to arm_big_little cpufreq driver.
+ *
+ * Copyright (C) 2013 ARM Ltd.
+ * Sudeep KarkadaNagesha <sudeep.karkadanagesha@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.
+ *
+ * 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/cpufreq.h>
+#include <linux/opp.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+#include "arm_big_little.h"
+
+static int ve_spc_init_opp_table(struct device *cpu_dev)
+{
+	/*
+	 * platform specific SPC code must initialise the opp table
+	 * so just check if the OPP count is non-zero
+	 */
+	return opp_get_opp_count(cpu_dev) <= 0;
+}
+
+static int ve_spc_get_transition_latency(struct device *cpu_dev)
+{
+	return 1000000; /* 1 ms */
+}
+
+static struct cpufreq_arm_bL_ops ve_spc_cpufreq_ops = {
+	.name	= "vexpress-spc",
+	.get_transition_latency = ve_spc_get_transition_latency,
+	.init_opp_table = ve_spc_init_opp_table,
+};
+
+static int ve_spc_cpufreq_probe(struct platform_device *pdev)
+{
+	return bL_cpufreq_register(&ve_spc_cpufreq_ops);
+}
+
+static int ve_spc_cpufreq_remove(struct platform_device *pdev)
+{
+	bL_cpufreq_unregister(&ve_spc_cpufreq_ops);
+	return 0;
+}
+
+static struct platform_driver ve_spc_cpufreq_platdrv = {
+	.driver = {
+		.name	= "vexpress-spc-cpufreq",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= ve_spc_cpufreq_probe,
+	.remove		= ve_spc_cpufreq_remove,
+};
+module_platform_driver(ve_spc_cpufreq_platdrv);
+
+MODULE_LICENSE("GPL");
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device
  2013-10-16 13:52 [PATCH 0/5] ARM: vexpress/TC2: cpufreq support Sudeep KarkadaNagesha
                   ` (3 preceding siblings ...)
  2013-10-16 13:52 ` [PATCH 4/5] cpufreq: arm_big_little: add vexpress SPC interface driver Sudeep KarkadaNagesha
@ 2013-10-16 13:52 ` Sudeep KarkadaNagesha
  2013-10-18 18:58   ` Nicolas Pitre
  4 siblings, 1 reply; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-16 13:52 UTC (permalink / raw)
  To: linux-arm-kernel, cpufreq, linux-pm
  Cc: Sudeep.KarkadaNagesha, Pawel Moll, Nicolas Pitre, Viresh Kumar,
	Lorenzo Pieralisi, Sudeep KarkadaNagesha, Pawel Moll

From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

This patch adds vexpress-spc platform device to enables the vexpress
SPC cpufreq interface driver.

Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Cc: Pawel Moll <Pawel.Moll@arm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/arm/mach-vexpress/spc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index a8b8310..4ddfbfe 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/opp.h>
+#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/semaphore.h>
 
@@ -532,6 +533,7 @@ static int __init ve_spc_clk_init(void)
 			pr_warn("failed to initialise cpu%d opp table\n", cpu);
 	}
 
+	platform_device_register_simple("vexpress-spc-cpufreq", -1, NULL, 0);
 	return 0;
 }
 module_init(ve_spc_clk_init);
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys
  2013-10-16 13:52 ` [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys Sudeep KarkadaNagesha
@ 2013-10-16 22:52   ` Rafael J. Wysocki
  0 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2013-10-16 22:52 UTC (permalink / raw)
  To: Sudeep KarkadaNagesha
  Cc: linux-arm-kernel, cpufreq, linux-pm, Pawel Moll, Nicolas Pitre,
	Viresh Kumar, Lorenzo Pieralisi, Sudeep KarkadaNagesha

On Wednesday, October 16, 2013 02:52:39 PM Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> 
> Currently clk_get_sys is used with cpu-cluster.<n> as the device id
> which is incorrect. It should be connection/consumer ID instead.
> 
> It is possible to specify input clock in the cpu device node along
> with the optional clock-name. clk_get_sys can't handle that.
> 
> This patch replaces clk_get_sys with clk_get to extend support for
> clocks specified in the device tree cpu node.
> 
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

I've queued up this one for 3.13, for the rest of the series I need ACKs
from the people in the CC list.

Thanks!

> ---
>  drivers/cpufreq/arm_big_little.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
> index 3549f07..501a091 100644
> --- a/drivers/cpufreq/arm_big_little.c
> +++ b/drivers/cpufreq/arm_big_little.c
> @@ -127,7 +127,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev)
>  	}
>  
>  	name[12] = cluster + '0';
> -	clk[cluster] = clk_get_sys(name, NULL);
> +	clk[cluster] = clk_get(cpu_dev, name);
>  	if (!IS_ERR(clk[cluster])) {
>  		dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n",
>  				__func__, clk[cluster], freq_table[cluster],
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] ARM: vexpress/TC2: add support for CPU DVFS
  2013-10-16 13:52 ` [PATCH 2/5] ARM: vexpress/TC2: add support for CPU DVFS Sudeep KarkadaNagesha
@ 2013-10-18 18:27   ` Nicolas Pitre
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Pitre @ 2013-10-18 18:27 UTC (permalink / raw)
  To: Sudeep KarkadaNagesha
  Cc: linux-arm-kernel, cpufreq, linux-pm, Pawel Moll, Viresh Kumar,
	Lorenzo Pieralisi, Pawel Moll

On Wed, 16 Oct 2013, Sudeep KarkadaNagesha wrote:

> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> 
> SPC(Serial Power Controller) on TC2 also controls the CPU performance
> operating points which is essential to provide CPU DVFS. The M3
> microcontroller provides two sets of eight performance values, one set
> for each cluster (CA15 or CA7). Each of this value contains the
> frequency(kHz) and voltage(mV) at that performance level. It expects
> these performance level to be passed through the SPC PERF_LVL registers.
> 
> This patch adds support to populate these performance levels from M3,
> build the mapping to CPU OPPs at the boot and then use it to get and
> set the CPU performance level runtime.
> 
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> Cc: Pawel Moll <Pawel.Moll@arm.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>

Minor comments below.  With those addressed, you may add

Acked-by: Nicolas Pitre <nico@linaro.org>

> ---
>  arch/arm/mach-vexpress/Kconfig  |   2 +
>  arch/arm/mach-vexpress/spc.c    | 240 +++++++++++++++++++++++++++++++++++++++-
>  arch/arm/mach-vexpress/spc.h    |   2 +-
>  arch/arm/mach-vexpress/tc2_pm.c |   7 +-
>  4 files changed, 247 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
> index 3657954..5989187 100644
> --- a/arch/arm/mach-vexpress/Kconfig
> +++ b/arch/arm/mach-vexpress/Kconfig
> @@ -1,5 +1,7 @@
>  config ARCH_VEXPRESS
>  	bool "ARM Ltd. Versatile Express family" if ARCH_MULTI_V7
> +	select ARCH_HAS_CPUFREQ
> +	select ARCH_HAS_OPP
>  	select ARCH_REQUIRE_GPIOLIB
>  	select ARM_AMBA
>  	select ARM_GIC

This is probably a bit too wide a selection for all CONFIG_ARCH_VEXPRESS 
targets.

I'd suggest creating a new CONFIG_VEXPRESS_SPC entry, making the build 
of spc.o depend on it, and that config entry could select
ARCH_HAS_CPUFREQ, ARCH_HAS_OPP and (as discussed in private) PM_OPP.  

Then this VEXPRESS_SPC would be selected by ARCH_VEXPRESS_TC2_PM.

Also the config dependency for ARM_VEXPRESS_SPC_CPUFREQ (in the later 
patch) would be better represented by VEXPRESS_SPC rather than 
ARCH_VEXPRESS_TC2_PM.

> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
> index eefb029..ef7e652 100644
> --- a/arch/arm/mach-vexpress/spc.c
> +++ b/arch/arm/mach-vexpress/spc.c
> @@ -17,14 +17,26 @@
>   * GNU General Public License for more details.
>   */
>  
> +#include <linux/delay.h>
>  #include <linux/err.h>
> +#include <linux/interrupt.h>
>  #include <linux/io.h>
> +#include <linux/opp.h>
>  #include <linux/slab.h>
> +#include <linux/semaphore.h>
>  
>  #include <asm/cacheflush.h>
>  
>  #define SPCLOG "vexpress-spc: "
>  
> +#define PERF_LVL_A15		0x00
> +#define PERF_REQ_A15		0x04
> +#define PERF_LVL_A7		0x08
> +#define PERF_REQ_A7		0x0c
> +#define COMMS			0x10
> +#define COMMS_REQ		0x14
> +#define PWC_STATUS		0x18
> +#define PWC_FLAG		0x1c

Maybe a blank line here?

>  /* SPC wake-up IRQs status and mask */
>  #define WAKE_INT_MASK		0x24
>  #define WAKE_INT_RAW		0x28
> @@ -35,6 +47,18 @@
>  /* SPC per-CPU mailboxes */
>  #define A15_BX_ADDR0		0x68
>  #define A7_BX_ADDR0		0x78

Ditto.

> +/* SPC system config interface registers */
> +#define SYSCFG_WDATA		0x70
> +#define SYSCFG_RDATA		0x74
> +
> +/* A15/A7 OPP virtual register base */
> +#define A15_PERFVAL_BASE	0xC10
> +#define A7_PERFVAL_BASE		0xC30
> +
> +/* Config interface control bits */
> +#define SYSCFG_START		(1 << 31)
> +#define SYSCFG_SCC		(6 << 20)
> +#define SYSCFG_STAT		(14 << 20)
>  
>  /* wake-up interrupt masks */
>  #define GBL_WAKEUP_INT_MSK	(0x3 << 10)
> @@ -42,6 +66,26 @@
>  /* TC2 static dual-cluster configuration */
>  #define MAX_CLUSTERS		2
>  
> +/*
> + * Even though the SPC takes max 3-5 ms to complete any OPP/COMMS
> + * operation, the operation could start just before jiffie is about
> + * to be incremented. So setting timeout value of 20ms = 2jiffies@100Hz
> + */
> +#define TIMEOUT_US	20000
> +
> +#define MAX_OPPS	8
> +#define CA15_DVFS	0
> +#define CA7_DVFS	1
> +#define SPC_SYS_CFG	2
> +#define STAT_COMPLETE(type)	((1 << 0) << (type << 2))
> +#define STAT_ERR(type)		((1 << 1) << (type << 2))
> +#define RESPONSE_MASK(type)	(STAT_COMPLETE(type) | STAT_ERR(type))
> +
> +struct ve_spc_opp {
> +	unsigned long freq;
> +	unsigned long u_volt;
> +};
> +
>  struct ve_spc_drvdata {
>  	void __iomem *baseaddr;
>  	/*
> @@ -49,6 +93,12 @@ struct ve_spc_drvdata {
>  	 * It corresponds to A15 processors MPIDR[15:8] bitfield
>  	 */
>  	u32 a15_clusid;
> +	uint32_t cur_rsp_mask;
> +	uint32_t cur_rsp_stat;
> +	struct semaphore sem;
> +	struct completion done;
> +	struct ve_spc_opp *opps[MAX_CLUSTERS];
> +	int num_opps[MAX_CLUSTERS];
>  };
>  
>  static struct ve_spc_drvdata *info;
> @@ -157,8 +207,177 @@ void ve_spc_powerdown(u32 cluster, bool enable)
>  	writel_relaxed(enable, info->baseaddr + pwdrn_reg);
>  }
>  
> -int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid)
> +static int ve_spc_get_performance(int cluster, u32 *freq)
> +{
> +	struct ve_spc_opp *opps = info->opps[cluster];
> +	u32 perf_cfg_reg = 0;
> +	int perf;
> +
> +	perf_cfg_reg = cluster_is_a15(cluster) ? PERF_LVL_A15 : PERF_LVL_A7;
> +
> +	perf = readl_relaxed(info->baseaddr + perf_cfg_reg);
> +	opps += perf;

This might be a good idea to validate the hardware returned index before 
dereferencing memory i.e "if (perf >= info->num_opps[cluster]) ..." with 
perf declared as an unsigned int.

> +	*freq = opps->freq;
> +
> +	return 0;
> +}
> +
> +/* find closest match to given frequency in OPP table */
> +static int ve_spc_round_performance(int cluster, u32 freq)
> +{
> +	int idx, max_opp = info->num_opps[cluster];
> +	struct ve_spc_opp *opps = info->opps[cluster];
> +	u32 fmin = 0, fmax = ~0, ftmp;
> +
> +	freq /= 1000; /* OPP entries in kHz */
> +	for (idx = 0; idx < max_opp; idx++, opps++) {
> +		ftmp = opps->freq;
> +		if (ftmp >= freq) {
> +			if (ftmp <= fmax)
> +				fmax = ftmp;
> +		} else {
> +			if (ftmp >= fmin)
> +				fmin = ftmp;
> +		}
> +	}
> +	if (fmax != ~0)
> +		return fmax * 1000;
> +	else
> +		return fmin * 1000;
> +}
> +
> +static int ve_spc_find_performance_index(int cluster, u32 freq)
> +{
> +	int idx, max_opp = info->num_opps[cluster];
> +	struct ve_spc_opp *opps = info->opps[cluster];
> +
> +	for (idx = 0; idx < max_opp; idx++, opps++)
> +		if (opps->freq == freq)
> +			break;
> +	return (idx == max_opp) ? -EINVAL : idx;
> +}
> +
> +static int ve_spc_waitforcompletion(int req_type)
> +{
> +	int ret = wait_for_completion_interruptible_timeout(
> +			&info->done, usecs_to_jiffies(TIMEOUT_US));
> +	if (ret == 0)
> +		ret = -ETIMEDOUT;
> +	else if (ret > 0)
> +		ret = info->cur_rsp_stat & STAT_COMPLETE(req_type) ? 0 : -EIO;
> +	return ret;
> +}
> +
> +static int ve_spc_set_performance(int cluster, u32 freq)
> +{
> +	u32 perf_cfg_reg, perf_stat_reg;
> +	int ret, perf, req_type;
> +
> +	if (cluster_is_a15(cluster)) {
> +		req_type = CA15_DVFS;
> +		perf_cfg_reg = PERF_LVL_A15;
> +		perf_stat_reg = PERF_REQ_A15;
> +	} else {
> +		req_type = CA7_DVFS;
> +		perf_cfg_reg = PERF_LVL_A7;
> +		perf_stat_reg = PERF_REQ_A7;
> +	}
> +
> +	perf = ve_spc_find_performance_index(cluster, freq);
> +
> +	if (perf < 0)
> +		return perf;
> +
> +	if (down_timeout(&info->sem, usecs_to_jiffies(TIMEOUT_US)))
> +		return -ETIME;
> +
> +	init_completion(&info->done);
> +	info->cur_rsp_mask = RESPONSE_MASK(req_type);
> +
> +	writel(perf, info->baseaddr + perf_cfg_reg);
> +	ret = ve_spc_waitforcompletion(req_type);
> +
> +	info->cur_rsp_mask = 0;
> +	up(&info->sem);
> +
> +	return ret;
> +}
> +
> +static int ve_spc_read_sys_cfg(int func, int offset, uint32_t *data)
> +{
> +	int ret;
> +
> +	if (down_timeout(&info->sem, usecs_to_jiffies(TIMEOUT_US)))
> +		return -ETIME;
> +
> +	init_completion(&info->done);
> +	info->cur_rsp_mask = RESPONSE_MASK(SPC_SYS_CFG);
> +
> +	/* Set the control value */
> +	writel(SYSCFG_START | func | offset >> 2, info->baseaddr + COMMS);
> +	ret = ve_spc_waitforcompletion(SPC_SYS_CFG);
> +
> +	if (ret == 0)
> +		*data = readl(info->baseaddr + SYSCFG_RDATA);
> +
> +	info->cur_rsp_mask = 0;
> +	up(&info->sem);
> +
> +	return ret;
> +}
> +
> +static irqreturn_t ve_spc_irq_handler(int irq, void *data)
> +{
> +	struct ve_spc_drvdata *drv_data = data;
> +	uint32_t status = readl_relaxed(drv_data->baseaddr + PWC_STATUS);
> +
> +	if (info->cur_rsp_mask & status) {
> +		info->cur_rsp_stat = status;
> +		complete(&drv_data->done);
> +	}
> +
> +	return IRQ_HANDLED;
> +}
> +
> +/*
> + *  +--------------------------+
> + *  | 31      20 | 19        0 |
> + *  +--------------------------+
> + *  |   u_volt   |  freq(kHz)  |
> + *  +--------------------------+
> + */
> +#define MULT_FACTOR	20
> +#define VOLT_SHIFT	20
> +#define FREQ_MASK	(0xFFFFF)
> +static int ve_spc_populate_opps(uint32_t cluster)
> +{
> +	uint32_t data = 0, off, ret, idx;
> +	struct ve_spc_opp *opps;
> +
> +	opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL);
> +	if (!opps)
> +		return -ENOMEM;
> +
> +	info->opps[cluster] = opps;
> +
> +	off = cluster_is_a15(cluster) ? A15_PERFVAL_BASE : A7_PERFVAL_BASE;
> +	for (idx = 0; idx < MAX_OPPS; idx++, off += 4, opps++) {
> +		ret = ve_spc_read_sys_cfg(SYSCFG_SCC, off, &data);
> +		if (!ret) {
> +			opps->freq = (data & FREQ_MASK) * MULT_FACTOR;
> +			opps->u_volt = data >> VOLT_SHIFT;
> +		} else {
> +			break;
> +		}
> +	}
> +	info->num_opps[cluster] = idx;
> +
> +	return ret;
> +}
> +
> +int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)
>  {
> +	int ret;
>  	info = kzalloc(sizeof(*info), GFP_KERNEL);
>  	if (!info) {
>  		pr_err(SPCLOG "unable to allocate mem\n");
> @@ -168,6 +387,25 @@ int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid)
>  	info->baseaddr = baseaddr;
>  	info->a15_clusid = a15_clusid;
>  
> +	if (irq <= 0) {
> +		pr_err(SPCLOG "Invalid IRQ %d\n", irq);
> +		kfree(info);
> +		return -EINVAL;
> +	}
> +
> +	init_completion(&info->done);
> +
> +	readl_relaxed(info->baseaddr + PWC_STATUS);
> +
> +	ret = request_irq(irq, ve_spc_irq_handler, IRQF_TRIGGER_HIGH
> +				| IRQF_ONESHOT, "vexpress-spc", info);
> +	if (ret) {
> +		pr_err(SPCLOG "IRQ %d request failed\n", irq);
> +		kfree(info);
> +		return -ENODEV;
> +	}
> +
> +	sema_init(&info->sem, 1);
>  	/*
>  	 * Multi-cluster systems may need this data when non-coherent, during
>  	 * cluster power-up/power-down. Make sure driver info reaches main
> diff --git a/arch/arm/mach-vexpress/spc.h b/arch/arm/mach-vexpress/spc.h
> index 5f7e4a4..dbd44c3 100644
> --- a/arch/arm/mach-vexpress/spc.h
> +++ b/arch/arm/mach-vexpress/spc.h
> @@ -15,7 +15,7 @@
>  #ifndef __SPC_H_
>  #define __SPC_H_
>  
> -int __init ve_spc_init(void __iomem *base, u32 a15_clusid);
> +int __init ve_spc_init(void __iomem *base, u32 a15_clusid, int irq);
>  void ve_spc_global_wakeup_irq(bool set);
>  void ve_spc_cpu_wakeup_irq(u32 cluster, u32 cpu, bool set);
>  void ve_spc_set_resume_addr(u32 cluster, u32 cpu, u32 addr);
> diff --git a/arch/arm/mach-vexpress/tc2_pm.c b/arch/arm/mach-vexpress/tc2_pm.c
> index e6eb481..d38130a 100644
> --- a/arch/arm/mach-vexpress/tc2_pm.c
> +++ b/arch/arm/mach-vexpress/tc2_pm.c
> @@ -16,6 +16,7 @@
>  #include <linux/io.h>
>  #include <linux/kernel.h>
>  #include <linux/of_address.h>
> +#include <linux/of_irq.h>
>  #include <linux/spinlock.h>
>  #include <linux/errno.h>
>  #include <linux/irqchip/arm-gic.h>
> @@ -311,7 +312,7 @@ static void __naked tc2_pm_power_up_setup(unsigned int affinity_level)
>  
>  static int __init tc2_pm_init(void)
>  {
> -	int ret;
> +	int ret, irq;
>  	void __iomem *scc;
>  	u32 a15_cluster_id, a7_cluster_id, sys_info;
>  	struct device_node *np;
> @@ -336,13 +337,15 @@ static int __init tc2_pm_init(void)
>  	tc2_nr_cpus[a15_cluster_id] = (sys_info >> 16) & 0xf;
>  	tc2_nr_cpus[a7_cluster_id] = (sys_info >> 20) & 0xf;
>  
> +	irq = irq_of_parse_and_map(np, 0);
> +
>  	/*
>  	 * A subset of the SCC registers is also used to communicate
>  	 * with the SPC (power controller). We need to be able to
>  	 * drive it very early in the boot process to power up
>  	 * processors, so we initialize the SPC driver here.
>  	 */
> -	ret = ve_spc_init(scc + SPC_BASE, a15_cluster_id);
> +	ret = ve_spc_init(scc + SPC_BASE, a15_cluster_id, irq);
>  	if (ret)
>  		return ret;
>  
> -- 
> 1.8.1.2
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/5] ARM: vexpress/TC2: add cpu clock support
  2013-10-16 13:52 ` [PATCH 3/5] ARM: vexpress/TC2: add cpu clock support Sudeep KarkadaNagesha
@ 2013-10-18 18:53   ` Nicolas Pitre
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Pitre @ 2013-10-18 18:53 UTC (permalink / raw)
  To: Sudeep KarkadaNagesha
  Cc: linux-arm-kernel, cpufreq, linux-pm, Pawel Moll, Viresh Kumar,
	Lorenzo Pieralisi, Pawel Moll

On Wed, 16 Oct 2013, Sudeep KarkadaNagesha wrote:

> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> 
> On TC2, the cpu clocks are controlled by the external M3 microcontroller
> and SPC provides the interface between the CPU and the power controller.
> 
> The generic cpufreq drivers use the clock APIs to get the cpu clocks.
> This patch add virtual spc clocks for all the cpus to control the cpu
> operating frequency via the clock framework.
> 
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> Cc: Pawel Moll <Pawel.Moll@arm.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>

Ninor comment below.


> ---
>  arch/arm/mach-vexpress/spc.c | 119 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 119 insertions(+)
> 
> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
> index ef7e652..a8b8310 100644
> --- a/arch/arm/mach-vexpress/spc.c
> +++ b/arch/arm/mach-vexpress/spc.c
> @@ -17,6 +17,9 @@
>   * GNU General Public License for more details.
>   */
>  
> +#include <linux/clk-provider.h>
> +#include <linux/clkdev.h>
> +#include <linux/cpu.h>
>  #include <linux/delay.h>
>  #include <linux/err.h>
>  #include <linux/interrupt.h>
> @@ -416,3 +419,119 @@ int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)
>  
>  	return 0;
>  }
> +
> +struct clk_spc {
> +	struct clk_hw hw;
> +	int cluster;
> +};
> +
> +#define to_clk_spc(spc) container_of(spc, struct clk_spc, hw)
> +static unsigned long spc_recalc_rate(struct clk_hw *hw,
> +		unsigned long parent_rate)
> +{
> +	struct clk_spc *spc = to_clk_spc(hw);
> +	u32 freq;
> +
> +	if (ve_spc_get_performance(spc->cluster, &freq))
> +		return -EIO;
> +
> +	return freq * 1000;
> +}
> +
> +static long spc_round_rate(struct clk_hw *hw, unsigned long drate,
> +		unsigned long *parent_rate)
> +{
> +	struct clk_spc *spc = to_clk_spc(hw);
> +
> +	return ve_spc_round_performance(spc->cluster, drate);
> +}
> +
> +static int spc_set_rate(struct clk_hw *hw, unsigned long rate,
> +		unsigned long parent_rate)
> +{
> +	struct clk_spc *spc = to_clk_spc(hw);
> +
> +	return ve_spc_set_performance(spc->cluster, rate / 1000);
> +}
> +
> +static struct clk_ops clk_spc_ops = {
> +	.recalc_rate = spc_recalc_rate,
> +	.round_rate = spc_round_rate,
> +	.set_rate = spc_set_rate,
> +};
> +
> +static struct clk *ve_spc_clk_register(struct device *cpu_dev)
> +{
> +	struct clk_init_data init;
> +	struct clk_spc *spc;
> +
> +	spc = kzalloc(sizeof(*spc), GFP_KERNEL);
> +	if (!spc) {
> +		pr_err("could not allocate spc clk\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	spc->hw.init = &init;
> +	spc->cluster = topology_physical_package_id(cpu_dev->id);
> +
> +	init.name = dev_name(cpu_dev);
> +	init.ops = &clk_spc_ops;
> +	init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE;
> +	init.num_parents = 0;
> +
> +	return devm_clk_register(cpu_dev, &spc->hw);
> +}
> +
> +static int ve_init_opp_table(struct device *cpu_dev)
> +{
> +	int cluster = topology_physical_package_id(cpu_dev->id);
> +	int idx, ret = 0, max_opp = info->num_opps[cluster];
> +	struct ve_spc_opp *opps = info->opps[cluster];
> +
> +	for (idx = 0; idx < max_opp; idx++, opps++) {
> +		ret = opp_add(cpu_dev, opps->freq * 1000, opps->u_volt);
> +		if (ret) {
> +			dev_warn(cpu_dev, "failed to add opp %lu %lu\n",
> +				 opps->freq, opps->u_volt);
> +			return ret;
> +		}
> +	}
> +	return ret;
> +}
> +
> +static int __init ve_spc_clk_init(void)
> +{
> +	int cpu;
> +	struct clk *clk;
> +
> +	if (!info)
> +		return 0; /* Continue only if SPC is initialised */
> +
> +	if (ve_spc_populate_opps(0) || ve_spc_populate_opps(1)) {
> +		pr_err("failed to build OPP table\n");
> +		return -ENODEV;
> +	}
> +
> +	for_each_possible_cpu(cpu) {
> +		struct device *cpu_dev = get_cpu_device(cpu);
> +		if (!cpu_dev) {
> +			pr_warn("failed to get cpu%d device\n", cpu);
> +			continue;
> +		}
> +		clk = ve_spc_clk_register(cpu_dev);
> +		if (IS_ERR(clk)) {
> +			pr_warn("failed to register cpu%d clock\n", cpu);
> +			continue;
> +		}
> +		if (clk_register_clkdev(clk, NULL, dev_name(cpu_dev))) {
> +			pr_warn("failed to register cpu%d clock lookup\n", cpu);
> +			continue;
> +		}
> +
> +		if (ve_init_opp_table(cpu_dev))
> +			pr_warn("failed to initialise cpu%d opp table\n", cpu);
> +	}
> +
> +	return 0;
> +}
> +module_init(ve_spc_clk_init);

This file is not compilable as a module as it is needed to start up 
secondary CPUs during boot.  In that case the module_init() is converted 
to device_initcall() which is the same level as used by ve_spc_cpufreq 
when both are compiled in.  To avoid possible unordered init calls, I'd 
suggest making this into a higher priority init call such as 
subsys_initcall(() ... unless this one is already used by or earlier 
than the clock infrastructure initialization (I didn't check).  Despite 
the name fs_initcall() ought to do the job.

With that change, you may add

Acked-by: Nicolas Pitre <nico@linaro.org>


Nicolas

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device
  2013-10-16 13:52 ` [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device Sudeep KarkadaNagesha
@ 2013-10-18 18:58   ` Nicolas Pitre
  2013-10-21  9:19     ` Sudeep KarkadaNagesha
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Pitre @ 2013-10-18 18:58 UTC (permalink / raw)
  To: Sudeep KarkadaNagesha
  Cc: linux-arm-kernel, cpufreq, linux-pm, Pawel Moll, Viresh Kumar,
	Lorenzo Pieralisi, Pawel Moll

On Wed, 16 Oct 2013, Sudeep KarkadaNagesha wrote:

> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> 
> This patch adds vexpress-spc platform device to enables the vexpress
> SPC cpufreq interface driver.
> 
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> Cc: Pawel Moll <Pawel.Moll@arm.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  arch/arm/mach-vexpress/spc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
> index a8b8310..4ddfbfe 100644
> --- a/arch/arm/mach-vexpress/spc.c
> +++ b/arch/arm/mach-vexpress/spc.c
> @@ -25,6 +25,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/opp.h>
> +#include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/semaphore.h>
>  
> @@ -532,6 +533,7 @@ static int __init ve_spc_clk_init(void)
>  			pr_warn("failed to initialise cpu%d opp table\n", cpu);
>  	}
>  
> +	platform_device_register_simple("vexpress-spc-cpufreq", -1, NULL, 0);
>  	return 0;
>  }
>  module_init(ve_spc_clk_init);

OK... this solves my concern about initcall ordering.  Please just 
disregard my suggestions on patch #3.  I'd suggest folding this patch 
into patch 3/5 though.


Nicolas

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/5] cpufreq: arm_big_little: add vexpress SPC interface driver
  2013-10-16 13:52 ` [PATCH 4/5] cpufreq: arm_big_little: add vexpress SPC interface driver Sudeep KarkadaNagesha
@ 2013-10-18 18:59   ` Nicolas Pitre
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Pitre @ 2013-10-18 18:59 UTC (permalink / raw)
  To: Sudeep KarkadaNagesha
  Cc: linux-arm-kernel, cpufreq, linux-pm, Pawel Moll, Viresh Kumar,
	Lorenzo Pieralisi

On Wed, 16 Oct 2013, Sudeep KarkadaNagesha wrote:

> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> 
> The TC2(i.e. CA15_A7) Versatile Express has external Cortex M3 based
> power controller which is responsible for CPU DVFS and SPC provides
> the interface for the same.
> 
> This patch adds a tiny interface driver to check if OPPs are
> initialised by SPC platform code and register the arm_big_little
> cpufreq driver.
> 
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>

Acked-by: Nicolas Pitre <nico@linaro.org>


> ---
>  drivers/cpufreq/Kconfig.arm            |  8 ++++
>  drivers/cpufreq/Makefile               |  1 +
>  drivers/cpufreq/vexpress-spc-cpufreq.c | 69 ++++++++++++++++++++++++++++++++++
>  3 files changed, 78 insertions(+)
>  create mode 100644 drivers/cpufreq/vexpress-spc-cpufreq.c
> 
> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
> index 0fa204b..d3bf733 100644
> --- a/drivers/cpufreq/Kconfig.arm
> +++ b/drivers/cpufreq/Kconfig.arm
> @@ -235,3 +235,11 @@ config ARM_TEGRA_CPUFREQ
>  	default y
>  	help
>  	  This adds the CPUFreq driver support for TEGRA SOCs.
> +
> +config ARM_VEXPRESS_SPC_CPUFREQ
> +        tristate "Versatile Express SPC based CPUfreq driver"
> +        select ARM_BIG_LITTLE_CPUFREQ
> +        depends on ARCH_VEXPRESS_TC2_PM
> +        help
> +          This add the CPUfreq driver support for Versatile Express
> +	  big.LITTLE platforms using SPC for power management.
> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
> index ad5866c..a1c390f 100644
> --- a/drivers/cpufreq/Makefile
> +++ b/drivers/cpufreq/Makefile
> @@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SA1100_CPUFREQ)	+= sa1100-cpufreq.o
>  obj-$(CONFIG_ARM_SA1110_CPUFREQ)	+= sa1110-cpufreq.o
>  obj-$(CONFIG_ARM_SPEAR_CPUFREQ)		+= spear-cpufreq.o
>  obj-$(CONFIG_ARM_TEGRA_CPUFREQ)		+= tegra-cpufreq.o
> +obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ)	+= vexpress-spc-cpufreq.o
>  
>  ##################################################################################
>  # PowerPC platform drivers
> diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c
> new file mode 100644
> index 0000000..f0508bf
> --- /dev/null
> +++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
> @@ -0,0 +1,69 @@
> +/*
> + * Versatile Express SPC CPUFreq Interface driver
> + *
> + * It provides necessary ops to arm_big_little cpufreq driver.
> + *
> + * Copyright (C) 2013 ARM Ltd.
> + * Sudeep KarkadaNagesha <sudeep.karkadanagesha@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.
> + *
> + * 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/cpufreq.h>
> +#include <linux/opp.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/types.h>
> +#include "arm_big_little.h"
> +
> +static int ve_spc_init_opp_table(struct device *cpu_dev)
> +{
> +	/*
> +	 * platform specific SPC code must initialise the opp table
> +	 * so just check if the OPP count is non-zero
> +	 */
> +	return opp_get_opp_count(cpu_dev) <= 0;
> +}
> +
> +static int ve_spc_get_transition_latency(struct device *cpu_dev)
> +{
> +	return 1000000; /* 1 ms */
> +}
> +
> +static struct cpufreq_arm_bL_ops ve_spc_cpufreq_ops = {
> +	.name	= "vexpress-spc",
> +	.get_transition_latency = ve_spc_get_transition_latency,
> +	.init_opp_table = ve_spc_init_opp_table,
> +};
> +
> +static int ve_spc_cpufreq_probe(struct platform_device *pdev)
> +{
> +	return bL_cpufreq_register(&ve_spc_cpufreq_ops);
> +}
> +
> +static int ve_spc_cpufreq_remove(struct platform_device *pdev)
> +{
> +	bL_cpufreq_unregister(&ve_spc_cpufreq_ops);
> +	return 0;
> +}
> +
> +static struct platform_driver ve_spc_cpufreq_platdrv = {
> +	.driver = {
> +		.name	= "vexpress-spc-cpufreq",
> +		.owner	= THIS_MODULE,
> +	},
> +	.probe		= ve_spc_cpufreq_probe,
> +	.remove		= ve_spc_cpufreq_remove,
> +};
> +module_platform_driver(ve_spc_cpufreq_platdrv);
> +
> +MODULE_LICENSE("GPL");
> -- 
> 1.8.1.2
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device
  2013-10-18 18:58   ` Nicolas Pitre
@ 2013-10-21  9:19     ` Sudeep KarkadaNagesha
  2013-10-21 13:00       ` Nicolas Pitre
  0 siblings, 1 reply; 13+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-10-21  9:19 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: linux-arm-kernel@lists.infradead.org, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, Pawel Moll, Viresh Kumar,
	Lorenzo Pieralisi

Hi Nico,

On 18/10/13 19:58, Nicolas Pitre wrote:
> On Wed, 16 Oct 2013, Sudeep KarkadaNagesha wrote:
> 
>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> This patch adds vexpress-spc platform device to enables the vexpress
>> SPC cpufreq interface driver.
>>
>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>> Cc: Pawel Moll <Pawel.Moll@arm.com>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> ---
>>  arch/arm/mach-vexpress/spc.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
>> index a8b8310..4ddfbfe 100644
>> --- a/arch/arm/mach-vexpress/spc.c
>> +++ b/arch/arm/mach-vexpress/spc.c
>> @@ -25,6 +25,7 @@
>>  #include <linux/interrupt.h>
>>  #include <linux/io.h>
>>  #include <linux/opp.h>
>> +#include <linux/platform_device.h>
>>  #include <linux/slab.h>
>>  #include <linux/semaphore.h>
>>  
>> @@ -532,6 +533,7 @@ static int __init ve_spc_clk_init(void)
>>  			pr_warn("failed to initialise cpu%d opp table\n", cpu);
>>  	}
>>  
>> +	platform_device_register_simple("vexpress-spc-cpufreq", -1, NULL, 0);
>>  	return 0;
>>  }
>>  module_init(ve_spc_clk_init);
> 
> OK... this solves my concern about initcall ordering.  Please just 
> disregard my suggestions on patch #3.  I'd suggest folding this patch 
> into patch 3/5 though.
>
Thanks for the review. All the comments provided in other patches are fixed.
Since this would not cause any ordering issue, do you still think it needs to be
folded in PATCH 3/5. One concern I have with that is we will be adding device
first and then the driver. Either I will have to reorder patch 3 and 4 after
folding this patch or leave it as it is now.

Regards,
Sudeep


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device
  2013-10-21  9:19     ` Sudeep KarkadaNagesha
@ 2013-10-21 13:00       ` Nicolas Pitre
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Pitre @ 2013-10-21 13:00 UTC (permalink / raw)
  To: Sudeep KarkadaNagesha
  Cc: linux-arm-kernel@lists.infradead.org, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, Pawel Moll, Viresh Kumar,
	Lorenzo Pieralisi

On Mon, 21 Oct 2013, Sudeep KarkadaNagesha wrote:

> Hi Nico,
> 
> On 18/10/13 19:58, Nicolas Pitre wrote:
> > On Wed, 16 Oct 2013, Sudeep KarkadaNagesha wrote:
> > 
> >> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> >>
> >> This patch adds vexpress-spc platform device to enables the vexpress
> >> SPC cpufreq interface driver.
> >>
> >> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> >> Cc: Pawel Moll <Pawel.Moll@arm.com>
> >> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> >> ---
> >>  arch/arm/mach-vexpress/spc.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
> >> index a8b8310..4ddfbfe 100644
> >> --- a/arch/arm/mach-vexpress/spc.c
> >> +++ b/arch/arm/mach-vexpress/spc.c
> >> @@ -25,6 +25,7 @@
> >>  #include <linux/interrupt.h>
> >>  #include <linux/io.h>
> >>  #include <linux/opp.h>
> >> +#include <linux/platform_device.h>
> >>  #include <linux/slab.h>
> >>  #include <linux/semaphore.h>
> >>  
> >> @@ -532,6 +533,7 @@ static int __init ve_spc_clk_init(void)
> >>  			pr_warn("failed to initialise cpu%d opp table\n", cpu);
> >>  	}
> >>  
> >> +	platform_device_register_simple("vexpress-spc-cpufreq", -1, NULL, 0);
> >>  	return 0;
> >>  }
> >>  module_init(ve_spc_clk_init);
> > 
> > OK... this solves my concern about initcall ordering.  Please just 
> > disregard my suggestions on patch #3.  I'd suggest folding this patch 
> > into patch 3/5 though.
> >
> Thanks for the review. All the comments provided in other patches are fixed.
> Since this would not cause any ordering issue, do you still think it needs to be
> folded in PATCH 3/5. One concern I have with that is we will be adding device
> first and then the driver. Either I will have to reorder patch 3 and 4 after
> folding this patch or leave it as it is now.

It doesn't matter if you introduce the device before the driver.  It is 
just that this patch on its own seemed a bit thin.

In any case this is not very important and doesn't justify another post.



Nicolas

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-10-21 13:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16 13:52 [PATCH 0/5] ARM: vexpress/TC2: cpufreq support Sudeep KarkadaNagesha
2013-10-16 13:52 ` [PATCH 1/5] cpufreq: arm-big-little: use clk_get instead of clk_get_sys Sudeep KarkadaNagesha
2013-10-16 22:52   ` Rafael J. Wysocki
2013-10-16 13:52 ` [PATCH 2/5] ARM: vexpress/TC2: add support for CPU DVFS Sudeep KarkadaNagesha
2013-10-18 18:27   ` Nicolas Pitre
2013-10-16 13:52 ` [PATCH 3/5] ARM: vexpress/TC2: add cpu clock support Sudeep KarkadaNagesha
2013-10-18 18:53   ` Nicolas Pitre
2013-10-16 13:52 ` [PATCH 4/5] cpufreq: arm_big_little: add vexpress SPC interface driver Sudeep KarkadaNagesha
2013-10-18 18:59   ` Nicolas Pitre
2013-10-16 13:52 ` [PATCH 5/5] ARM: vexpress/TC2: register vexpress-spc cpufreq device Sudeep KarkadaNagesha
2013-10-18 18:58   ` Nicolas Pitre
2013-10-21  9:19     ` Sudeep KarkadaNagesha
2013-10-21 13:00       ` Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).