linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084
@ 2015-03-20 20:21 Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
                   ` (9 more replies)
  0 siblings, 10 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Hi,

This v17 revision of patch has minor changes since v16. Primarily rebased on
top of Daniels' changes [1].

Changes since v16:
- Dropped per-cpu cpuidle changes in the cpuidle-arm driver, Daniel submitted
  it as part of his series.
- Rebase on top of [1].
- Return -ENXIO when qcom_cpuidle_init() detects SPM device is not probed yet.
- Declare cpuidle_ops using CPUIDLE_METHOD_OF_DECLARE.

Changes since v15:
https://www.mail-archive.com/devicetree@vger.kernel.org/msg64700.html
- Clean up cpuidle-arm.c to use devm_kzalloc and print error codes.
- Remove qcom,idle-state-stby as a DT mode, instead use the ARM WFI defined in
  ARM cpuidle driver for clock gating/standby modes. The platform driver will
  default to standby for all cpus after executing any low power state. This allows
  us to be completely compatible with generic ARM cpuidle driver and not send out
  cpu_pm notifications that are sent out for all 'platform states'.
- Cleaned up comments around setting SPM states.
- Platform idle state (SPC) starts at index 1, previous patch was overwritting
  ARM WFI state, which is mandated to be default state at index 0. 
- Removed duplicate cpu_pm_enter() and cpu_pm_exit() callbacks.
- Re-introduce ARM_QCOM_CPUIDLE defconfig item to enable/disable QCOM cpuidle
  support.
- Update documentation on standby state to indicate that this state is no longer
  defined in the DT.
- Remove unused qcom,saw2-v1.* compatibles from documentation.
- Rebased on top of SCM changes that were pulled in Kumar's 'soc' branch [2].
- Removed Reviewed-by tags from DT patches due to change in idle states.

Changes since v14:
- Support for cpuidle_ops
- SPM probe changes to register cpuidle
- Rebase on top of 4.0-rc1
- Remove SCM patches from series. Rebased on top of Kumar's tree
- Removed cpuidle-qcom.c in favor of ARM generic cpuidle driver
- Included Daniel's change for supporting creating cpuidle devices by platform

Tested on: 8074, 8084.

Thanks,
Lina

[1]. https://lkml.org/lkml/2015/3/20/165


Lina Iyer (10):
  ARM: qcom: Add Subsystem Power Manager (SPM) driver
  ARM: cpuidle: qcom: Add documentation for qcom cpuidle states
  ARM: cpuidle: Add cpuidle support for QCOM cpus
  ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs
  ARM: dts: qcom: Add power-controller device node for 8084 Krait CPUs
  ARM: dts: qcom: Update power-controller device node for 8064 Krait
    CPUs
  ARM: dts: qcom: Add idle states device nodes for 8974/8074
  ARM: dts: qcom: Add idle states device nodes for 8084
  ARM: dts: qcom: Add idle state device nodes for 8064
  ARM: qcom: Update defconfig to enable cpuidle

 .../bindings/arm/msm/qcom,idle-state.txt           |  84 +++++
 .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
 arch/arm/boot/dts/qcom-apq8064.dtsi                |  30 +-
 arch/arm/boot/dts/qcom-apq8084.dtsi                |  40 +-
 arch/arm/boot/dts/qcom-msm8974.dtsi                |  40 +-
 arch/arm/configs/qcom_defconfig                    |   2 +
 drivers/cpuidle/Kconfig.arm                        |   7 +
 drivers/soc/qcom/Kconfig                           |   7 +
 drivers/soc/qcom/Makefile                          |   1 +
 drivers/soc/qcom/spm.c                             | 405 +++++++++++++++++++++
 10 files changed, 629 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt
 create mode 100644 drivers/soc/qcom/spm.c

-- 
2.1.0

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

* [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
       [not found]   ` <1426882877-33008-2-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
                     ` (2 more replies)
  2015-03-20 20:21 ` [PATCH v17 02/10] ARM: cpuidle: qcom: Add documentation for qcom cpuidle states Lina Iyer
                   ` (8 subsequent siblings)
  9 siblings, 3 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer,
	Arnd Bergmann

SPM is a hardware block that controls the peripheral logic surrounding
the application cores (cpu/l$). When the core executes WFI instruction,
the SPM takes over the putting the core in low power state as
configured. The wake up for the SPM is an interrupt at the GIC, which
then completes the rest of low power mode sequence and brings the core
out of low power mode.

The SPM has a set of control registers that configure the SPMs
individually based on the type of the core and the runtime conditions.
SPM is a finite state machine block to which a sequence is provided and
it interprets the bytes and executes them in sequence. Each low power
mode that the core can enter into is provided to the SPM as a sequence.

Configure the SPM to set the core (cpu or L2) into its low power mode,
the index of the first command in the sequence is set in the SPM_CTL
register. When the core executes ARM wfi instruction, it triggers the
SPM state machine to start executing from that index. The SPM state
machine waits until the interrupt occurs and starts executing the rest
of the sequence until it hits the end of the sequence. The end of the
sequence jumps the core out of its low power mode.

Add support for an idle driver to set up the SPM to place the core in
Standby or Standalone power collapse mode when the core is idle.

Based on work by: Mahesh Sivasubramanian <msivasub@codeaurora.org>,
Ai Li <ali@codeaurora.org>, Praveen Chidambaram <pchidamb@codeaurora.org>
Original tree available at -
git://codeaurora.org/quic/la/kernel/msm-3.10.git

Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
 drivers/soc/qcom/Kconfig                           |   7 +
 drivers/soc/qcom/Makefile                          |   1 +
 drivers/soc/qcom/spm.c                             | 405 +++++++++++++++++++++
 4 files changed, 436 insertions(+), 6 deletions(-)
 create mode 100644 drivers/soc/qcom/spm.c

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
index 1505fb8..664aa91 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
@@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)
 
 The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the
 Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
-micro-controller that transitions a piece of hardware (like a processor or
+power-controller that transitions a piece of hardware (like a processor or
 subsystem) into and out of low power modes via a direct connection to
 the PMIC. It can also be wired up to interact with other processors in the
 system, notifying them when a low power state is entered or exited.
 
+Multiple revisions of the SAW hardware are supported using these Device Nodes.
+SAW2 revisions differ in the register offset and configuration data. Also, the
+same revision of the SAW in different SoCs may have different configuration
+data due the the differences in hardware capabilities. Hence the SoC name, the
+version of the SAW hardware in that SoC and the distinction between cpu (big
+or Little) or cache, may be needed to uniquely identify the SAW register
+configuration and initialization data. The compatible string is used to
+indicate this parameter.
+
 PROPERTIES
 
 - compatible:
@@ -14,10 +23,11 @@ PROPERTIES
 	Value type: <string>
 	Definition: shall contain "qcom,saw2". A more specific value should be
 		    one of:
-			 "qcom,saw2-v1"
-			 "qcom,saw2-v1.1"
-			 "qcom,saw2-v2"
-			 "qcom,saw2-v2.1"
+			"qcom,saw2-v2"
+			"qcom,saw2-v2.1"
+			"qcom,apq8064-saw2-v1.1-cpu"
+			"qcom,msm8974-saw2-v2.1-cpu"
+			"qcom,apq8084-saw2-v2.1-cpu"
 
 - reg:
 	Usage: required
@@ -26,10 +36,17 @@ PROPERTIES
 		    the register region. An optional second element specifies
 		    the base address and size of the alias register region.
 
+- regulator:
+	Usage: optional
+	Value type: boolean
+	Definition: Indicates that this SPM device acts as a regulator device
+			device for the core (CPU or Cache) the SPM is attached
+			to.
 
 Example:
 
-	regulator@2099000 {
+	power-controller@2099000 {
 		compatible = "qcom,saw2";
 		reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
+		regulator;
 	};
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 7bd2c94..628bcba 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -9,3 +9,10 @@ config QCOM_GSBI
           functions for connecting the underlying serial UART, SPI, and I2C
           devices to the output pins.
 
+config QCOM_PM
+	bool "Qualcomm Power Management"
+	depends on ARCH_QCOM
+	help
+	  QCOM Platform specific power driver to manage cores and L2 low power
+	  modes. It interface with various system drivers to put the cores in
+	  low power modes.
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 4389012..931d385 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
+obj-$(CONFIG_QCOM_PM)	+=	spm.o
diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c
new file mode 100644
index 0000000..cda321c
--- /dev/null
+++ b/drivers/soc/qcom/spm.c
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014,2015, Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/cpuidle.h>
+#include <linux/cpu_pm.h>
+#include <linux/qcom_scm.h>
+
+#include <asm/cpuidle.h>
+#include <asm/proc-fns.h>
+#include <asm/suspend.h>
+
+#define MAX_PMIC_DATA		2
+#define MAX_SEQ_DATA		64
+#define SPM_CTL_INDEX		0x7f
+#define SPM_CTL_INDEX_SHIFT	4
+#define SPM_CTL_EN		BIT(0)
+
+enum pm_sleep_mode {
+	PM_SLEEP_MODE_STBY,
+	PM_SLEEP_MODE_RET,
+	PM_SLEEP_MODE_SPC,
+	PM_SLEEP_MODE_PC,
+	PM_SLEEP_MODE_NR,
+};
+
+enum spm_reg {
+	SPM_REG_CFG,
+	SPM_REG_SPM_CTL,
+	SPM_REG_DLY,
+	SPM_REG_PMIC_DLY,
+	SPM_REG_PMIC_DATA_0,
+	SPM_REG_PMIC_DATA_1,
+	SPM_REG_VCTL,
+	SPM_REG_SEQ_ENTRY,
+	SPM_REG_SPM_STS,
+	SPM_REG_PMIC_STS,
+	SPM_REG_NR,
+};
+
+struct spm_reg_data {
+	const u8 *reg_offset;
+	u32 spm_cfg;
+	u32 spm_dly;
+	u32 pmic_dly;
+	u32 pmic_data[MAX_PMIC_DATA];
+	u8 seq[MAX_SEQ_DATA];
+	u8 start_index[PM_SLEEP_MODE_NR];
+};
+
+struct spm_driver_data {
+	void __iomem *reg_base;
+	const struct spm_reg_data *reg_data;
+};
+
+static const u8 spm_reg_offset_v2_1[SPM_REG_NR] = {
+	[SPM_REG_CFG]		= 0x08,
+	[SPM_REG_SPM_CTL]	= 0x30,
+	[SPM_REG_DLY]		= 0x34,
+	[SPM_REG_SEQ_ENTRY]	= 0x80,
+};
+
+/* SPM register data for 8974, 8084 */
+static const struct spm_reg_data spm_reg_8974_8084_cpu  = {
+	.reg_offset = spm_reg_offset_v2_1,
+	.spm_cfg = 0x1,
+	.spm_dly = 0x3C102800,
+	.seq = { 0x03, 0x0B, 0x0F, 0x00, 0x20, 0x80, 0x10, 0xE8, 0x5B, 0x03,
+		0x3B, 0xE8, 0x5B, 0x82, 0x10, 0x0B, 0x30, 0x06, 0x26, 0x30,
+		0x0F },
+	.start_index[PM_SLEEP_MODE_STBY] = 0,
+	.start_index[PM_SLEEP_MODE_SPC] = 3,
+};
+
+static const u8 spm_reg_offset_v1_1[SPM_REG_NR] = {
+	[SPM_REG_CFG]		= 0x08,
+	[SPM_REG_SPM_CTL]	= 0x20,
+	[SPM_REG_PMIC_DLY]	= 0x24,
+	[SPM_REG_PMIC_DATA_0]	= 0x28,
+	[SPM_REG_PMIC_DATA_1]	= 0x2C,
+	[SPM_REG_SEQ_ENTRY]	= 0x80,
+};
+
+/* SPM register data for 8064 */
+static const struct spm_reg_data spm_reg_8064_cpu = {
+	.reg_offset = spm_reg_offset_v1_1,
+	.spm_cfg = 0x1F,
+	.pmic_dly = 0x02020004,
+	.pmic_data[0] = 0x0084009C,
+	.pmic_data[1] = 0x00A4001C,
+	.seq = { 0x03, 0x0F, 0x00, 0x24, 0x54, 0x10, 0x09, 0x03, 0x01,
+		0x10, 0x54, 0x30, 0x0C, 0x24, 0x30, 0x0F },
+	.start_index[PM_SLEEP_MODE_STBY] = 0,
+	.start_index[PM_SLEEP_MODE_SPC] = 2,
+};
+
+static DEFINE_PER_CPU(struct spm_driver_data *, cpu_spm_drv);
+
+typedef int (*idle_fn)(int);
+static DEFINE_PER_CPU(idle_fn*, qcom_idle_ops);
+
+static inline void spm_register_write(struct spm_driver_data *drv,
+					enum spm_reg reg, u32 val)
+{
+	if (drv->reg_data->reg_offset[reg])
+		writel_relaxed(val, drv->reg_base +
+				drv->reg_data->reg_offset[reg]);
+}
+
+/* Ensure a guaranteed write, before return */
+static inline void spm_register_write_sync(struct spm_driver_data *drv,
+					enum spm_reg reg, u32 val)
+{
+	u32 ret;
+
+	if (!drv->reg_data->reg_offset[reg])
+		return;
+
+	do {
+		writel_relaxed(val, drv->reg_base +
+				drv->reg_data->reg_offset[reg]);
+		ret = readl_relaxed(drv->reg_base +
+				drv->reg_data->reg_offset[reg]);
+		if (ret == val)
+			break;
+		cpu_relax();
+	} while (1);
+}
+
+static inline u32 spm_register_read(struct spm_driver_data *drv,
+					enum spm_reg reg)
+{
+	return readl_relaxed(drv->reg_base + drv->reg_data->reg_offset[reg]);
+}
+
+static void spm_set_low_power_mode(struct spm_driver_data *drv,
+					enum pm_sleep_mode mode)
+{
+	u32 start_index;
+	u32 ctl_val;
+
+	start_index = drv->reg_data->start_index[mode];
+
+	ctl_val = spm_register_read(drv, SPM_REG_SPM_CTL);
+	ctl_val &= ~(SPM_CTL_INDEX << SPM_CTL_INDEX_SHIFT);
+	ctl_val |= start_index << SPM_CTL_INDEX_SHIFT;
+	ctl_val |= SPM_CTL_EN;
+	spm_register_write_sync(drv, SPM_REG_SPM_CTL, ctl_val);
+}
+
+static int qcom_pm_collapse(unsigned long int unused)
+{
+	qcom_scm_cpu_power_down(QCOM_SCM_CPU_PWR_DOWN_L2_ON);
+
+	/*
+	 * Returns here only if there was a pending interrupt and we did not
+	 * power down as a result.
+	 */
+	return -1;
+}
+
+static int qcom_cpu_spc(int cpu)
+{
+	int ret;
+	struct spm_driver_data *drv = per_cpu(cpu_spm_drv, cpu);
+
+	spm_set_low_power_mode(drv, PM_SLEEP_MODE_SPC);
+	ret = cpu_suspend(0, qcom_pm_collapse);
+	/*
+	 * ARM common code executes WFI without calling into our driver and
+	 * if the SPM mode is not reset, then we may accidently power down the
+	 * cpu when we intended only to gate the cpu clock.
+	 * Ensure the state is set to standby before returning.
+	 */
+	spm_set_low_power_mode(drv, PM_SLEEP_MODE_STBY);
+
+	return ret;
+}
+
+static int qcom_idle_enter(int cpu, unsigned long index)
+{
+	return per_cpu(qcom_idle_ops, cpu)[index](cpu);
+}
+
+static const struct of_device_id qcom_idle_state_match[] __initconst = {
+	{ .compatible = "qcom,idle-state-spc", .data = qcom_cpu_spc },
+	{ },
+};
+
+static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu)
+{
+	const struct of_device_id *match_id;
+	struct device_node *state_node;
+	int i;
+	int state_count = 1;
+	idle_fn idle_fns[CPUIDLE_STATE_MAX];
+	idle_fn *fns;
+	cpumask_t mask;
+	bool use_scm_power_down = false;
+
+	for (i = 0; ; i++) {
+		state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i);
+		if (!state_node)
+			break;
+
+		if (!of_device_is_available(state_node))
+			continue;
+
+		if (i == CPUIDLE_STATE_MAX) {
+			pr_warn("%s: cpuidle states reached max possible\n",
+					__func__);
+			break;
+		}
+
+		match_id = of_match_node(qcom_idle_state_match, state_node);
+		if (!match_id)
+			return -ENODEV;
+
+		idle_fns[state_count] = match_id->data;
+
+		/* Check if any of the states allow power down */
+		if (match_id->data == qcom_cpu_spc)
+			use_scm_power_down = true;
+
+		state_count++;
+	}
+
+	if (state_count == 1)
+		goto check_spm;
+
+	fns = devm_kcalloc(get_cpu_device(cpu), state_count, sizeof(*fns),
+			GFP_KERNEL);
+	if (!fns)
+		return -ENOMEM;
+
+	for (i = 1; i < state_count; i++)
+		fns[i] = idle_fns[i];
+
+	if (use_scm_power_down) {
+		/* We have atleast one power down mode */
+		cpumask_clear(&mask);
+		cpumask_set_cpu(cpu, &mask);
+		qcom_scm_set_warm_boot_addr(cpu_resume, &mask);
+	}
+
+	per_cpu(qcom_idle_ops, cpu) = fns;
+
+	/*
+	 * Condition: cpuidle_driver_register() needs to happen before
+	 * cpuidle_register_device().
+	 * Check if the SPM probe has happened -
+	 * - If SPM probed successfully before arm_idle_init(), then defer
+	 *   the registration of cpuidle_device back to arm_idle_init()
+	 * - If the SPM probe happens in the future, then let the SPM probe
+	 *   register the cpuidle device, return -ENXIO.
+	 */
+check_spm:
+	return per_cpu(cpu_spm_drv, cpu) ? 0 : -ENXIO;
+}
+
+struct cpuidle_ops qcom_cpuidle_ops __initdata = {
+	.suspend = qcom_idle_enter,
+	.init = qcom_cpuidle_init,
+};
+
+CPUIDLE_METHOD_OF_DECLARE(qcom_idle_v1, "qcom,kpss-acc-v1", &qcom_cpuidle_ops);
+CPUIDLE_METHOD_OF_DECLARE(qcom_idle_v2, "qcom,kpss-acc-v2", &qcom_cpuidle_ops);
+
+static struct spm_driver_data *spm_get_drv(struct platform_device *pdev,
+		int *spm_cpu)
+{
+	struct spm_driver_data *drv = NULL;
+	struct device_node *cpu_node, *saw_node;
+	int cpu;
+	bool found;
+
+	for_each_possible_cpu(cpu) {
+		cpu_node = of_cpu_device_node_get(cpu);
+		if (!cpu_node)
+			continue;
+		saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
+		found = (saw_node == pdev->dev.of_node);
+		of_node_put(saw_node);
+		of_node_put(cpu_node);
+		if (found)
+			break;
+	}
+
+	if (found) {
+		drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
+		if (drv)
+			*spm_cpu = cpu;
+	}
+
+	return drv;
+}
+
+static const struct of_device_id spm_match_table[] = {
+	{ .compatible = "qcom,msm8974-saw2-v2.1-cpu",
+	  .data = &spm_reg_8974_8084_cpu },
+	{ .compatible = "qcom,apq8084-saw2-v2.1-cpu",
+	  .data = &spm_reg_8974_8084_cpu },
+	{ .compatible = "qcom,apq8064-saw2-v1.1-cpu",
+	  .data = &spm_reg_8064_cpu },
+	{ },
+};
+
+static int spm_dev_probe(struct platform_device *pdev)
+{
+	struct spm_driver_data *drv;
+	struct resource *res;
+	const struct of_device_id *match_id;
+	void __iomem *addr;
+	int cpu;
+	int ret = 0;
+
+	drv = spm_get_drv(pdev, &cpu);
+	if (!drv)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	drv->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(drv->reg_base))
+		return PTR_ERR(drv->reg_base);
+
+	match_id = of_match_node(spm_match_table, pdev->dev.of_node);
+	if (!match_id)
+		return -ENODEV;
+
+	drv->reg_data = match_id->data;
+
+	/* Write the SPM sequences first.. */
+	addr = drv->reg_base + drv->reg_data->reg_offset[SPM_REG_SEQ_ENTRY];
+	__iowrite32_copy(addr, drv->reg_data->seq,
+			ARRAY_SIZE(drv->reg_data->seq) / 4);
+
+	/*
+	 * ..and then the control registers.
+	 * On some SoC if the control registers are written first and if the
+	 * CPU was held in reset, the reset signal could trigger the SPM state
+	 * machine, before the sequences are completely written.
+	 */
+	spm_register_write(drv, SPM_REG_CFG, drv->reg_data->spm_cfg);
+	spm_register_write(drv, SPM_REG_DLY, drv->reg_data->spm_dly);
+	spm_register_write(drv, SPM_REG_PMIC_DLY, drv->reg_data->pmic_dly);
+	spm_register_write(drv, SPM_REG_PMIC_DATA_0,
+				drv->reg_data->pmic_data[0]);
+	spm_register_write(drv, SPM_REG_PMIC_DATA_1,
+				drv->reg_data->pmic_data[1]);
+
+	/* Set up Standby as the default low power mode */
+	spm_set_low_power_mode(drv, PM_SLEEP_MODE_STBY);
+
+	per_cpu(cpu_spm_drv, cpu) = drv;
+
+	/*
+	 * If the cpuidle ops have already been registered with cpuidle,
+	 * then we have been waiting on this SPM probe to register the
+	 * cpuidle device.
+	 */
+	if (per_cpu(qcom_idle_ops, cpu)) {
+		struct cpuidle_device *dev;
+
+		dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+		if (!dev)
+			return -ENOMEM;
+		dev->cpu = cpu;
+		ret = cpuidle_register_device(dev);
+	}
+
+	return ret;
+}
+
+static struct platform_driver spm_driver = {
+	.probe = spm_dev_probe,
+	.driver = {
+		.name = "saw",
+		.of_match_table = spm_match_table,
+	},
+};
+module_platform_driver(spm_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("SAW power controller driver");
+MODULE_ALIAS("platform:saw");
-- 
2.1.0

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

* [PATCH v17 02/10] ARM: cpuidle: qcom: Add documentation for qcom cpuidle states
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 03/10] ARM: cpuidle: Add cpuidle support for QCOM cpus Lina Iyer
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Add documentation for cpuidle states of QCOM cpus. In addition to
arm-idle-state compatible string, the ARM idle state definition must
define one of the following compatible strings -
	"qcom,idle-state-ret",
	"qcom,idle-state-spc",
	"qcom,idle-state-pc",

The compatibles helps the SPM platform driver to use the correct idle
function when the index to the idle state is passed to the platform
driver.

Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 .../bindings/arm/msm/qcom,idle-state.txt           | 84 ++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt b/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt
new file mode 100644
index 0000000..06df04c
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt
@@ -0,0 +1,84 @@
+QCOM Idle States for cpuidle driver
+
+ARM provides idle-state node to define the cpuidle states, as defined in [1].
+cpuidle-qcom is the cpuidle driver for Qualcomm SoCs and uses these idle
+states. Idle states have different enter/exit latency and residency values.
+The idle states supported by the QCOM SoC are defined as -
+
+    * Standby
+    * Retention
+    * Standalone Power Collapse (Standalone PC or SPC)
+    * Power Collapse (PC)
+
+Standby: Standby does a little more in addition to architectural clock gating.
+When the WFI instruction is executed the ARM core would gate its internal
+clocks. In addition to gating the clocks, QCOM cpus use this instruction as a
+trigger to execute the SPM state machine. The SPM state machine waits for the
+interrupt to trigger the core back in to active. This triggers the cache
+hierarchy to enter standby states, when all cpus are idle. An interrupt brings
+the SPM state machine out of its wait, the next step is to ensure that the
+cache hierarchy is also out of standby, and then the cpu is allowed to resume
+execution. This state is defined as a generic ARM WFI state by the ARM cpuidle
+driver and is not defined in the DT. The SPM state machine should be
+configured to execute this state by default and after executing every other
+state below.
+
+Retention: Retention is a low power state where the core is clock gated and
+the memory and the registers associated with the core are retained. The
+voltage may be reduced to the minimum value needed to keep the processor
+registers active. The SPM should be configured to execute the retention
+sequence and would wait for interrupt, before restoring the cpu to execution
+state. Retention may have a slightly higher latency than Standby.
+
+Standalone PC: A cpu can power down and warmboot if there is a sufficient time
+between the time it enters idle and the next known wake up. SPC mode is used
+to indicate a core entering a power down state without consulting any other
+cpu or the system resources. This helps save power only on that core.  The SPM
+sequence for this idle state is programmed to power down the supply to the
+core, wait for the interrupt, restore power to the core, and ensure the
+system state including cache hierarchy is ready before allowing core to
+resume. Applying power and resetting the core causes the core to warmboot
+back into Elevation Level (EL) which trampolines the control back to the
+kernel. Entering a power down state for the cpu, needs to be done by trapping
+into a EL. Failing to do so, would result in a crash enforced by the warm boot
+code in the EL for the SoC. On SoCs with write-back L1 cache, the cache has to
+be flushed in s/w, before powering down the core.
+
+Power Collapse: This state is similar to the SPC mode, but distinguishes
+itself in that the cpu acknowledges and permits the SoC to enter deeper sleep
+modes. In a hierarchical power domain SoC, this means L2 and other caches can
+be flushed, system bus, clocks - lowered, and SoC main XO clock gated and
+voltages reduced, provided all cpus enter this state.  Since the span of low
+power modes possible at this state is vast, the exit latency and the residency
+of this low power mode would be considered high even though at a cpu level,
+this essentially is cpu power down. The SPM in this state also may handshake
+with the Resource power manager (RPM) processor in the SoC to indicate a
+complete application processor subsystem shut down.
+
+The idle-state for QCOM SoCs are distinguished by the compatible property of
+the idle-states device node.
+
+The devicetree representation of the idle state should be -
+
+Required properties:
+
+- compatible: Must be one of -
+			"qcom,idle-state-ret",
+			"qcom,idle-state-spc",
+			"qcom,idle-state-pc",
+		and "arm,idle-state".
+
+Other required and optional properties are specified in [1].
+
+Example:
+
+	idle-states {
+		CPU_SPC: spc {
+			compatible = "qcom,idle-state-spc", "arm,idle-state";
+			entry-latency-us = <150>;
+			exit-latency-us = <200>;
+			min-residency-us = <2000>;
+		};
+	};
+
+[1]. Documentation/devicetree/bindings/arm/idle-states.txt
-- 
2.1.0

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

* [PATCH v17 03/10] ARM: cpuidle: Add cpuidle support for QCOM cpus
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 02/10] ARM: cpuidle: qcom: Add documentation for qcom cpuidle states Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs Lina Iyer
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer,
	Arnd Bergmann

Define ARM_QCOM_CPUIDLE config item to enable cpuidle support.

Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 drivers/cpuidle/Kconfig.arm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index 1f067bd..644a647 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -74,3 +74,10 @@ config ARM_MVEBU_V7_CPUIDLE
 	depends on ARCH_MVEBU
 	help
 	  Select this to enable cpuidle on Armada 370, 38x and XP processors.
+
+config ARM_QCOM_CPUIDLE
+	bool "CPU Idle Driver for QCOM processors"
+	depends on ARCH_QCOM
+	select ARM_CPUIDLE
+	help
+	  Select this to enable cpuidle on QCOM processors.
-- 
2.1.0

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

* [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
                   ` (2 preceding siblings ...)
  2015-03-20 20:21 ` [PATCH v17 03/10] ARM: cpuidle: Add cpuidle support for QCOM cpus Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
  2015-03-23 22:05   ` Kumar Gala
  2015-03-20 20:21 ` [PATCH v17 05/10] ARM: dts: qcom: Add power-controller device node for 8084 " Lina Iyer
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Each Krait CPU in the QCOM 8074/8974 SoC has an SAW power controller to
regulate the power to the cpu and aide the core in entering idle states.
Reference the SAW instance and associate the instance with the CPU core.

Cc: Kumar Gala <galak@codeaurora.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
---
 arch/arm/boot/dts/qcom-msm8974.dtsi | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
index e265ec1..5a41f44 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -21,6 +21,7 @@
 			reg = <0>;
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc0>;
+			qcom,saw = <&saw0>;
 		};
 
 		cpu@1 {
@@ -30,6 +31,7 @@
 			reg = <1>;
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc1>;
+			qcom,saw = <&saw1>;
 		};
 
 		cpu@2 {
@@ -39,6 +41,7 @@
 			reg = <2>;
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc2>;
+			qcom,saw = <&saw2>;
 		};
 
 		cpu@3 {
@@ -48,6 +51,7 @@
 			reg = <3>;
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc3>;
+			qcom,saw = <&saw3>;
 		};
 
 		L2: l2-cache {
@@ -144,7 +148,27 @@
 			};
 		};
 
-		saw_l2: regulator@f9012000 {
+		saw0: power-controller@f9089000 {
+			compatible = "qcom,msm8974-saw2-v2.1-cpu";
+			reg = <0xf9089000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw1: power-controller@f9099000 {
+			compatible = "qcom,msm8974-saw2-v2.1-cpu";
+			reg = <0xf9099000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw2: power-controller@f90a9000 {
+			compatible = "qcom,msm8974-saw2-v2.1-cpu";
+			reg = <0xf90a9000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw3: power-controller@f90b9000 {
+			compatible = "qcom,msm8974-saw2-v2.1-cpu";
+			reg = <0xf90b9000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw_l2: power-controller@f9012000 {
 			compatible = "qcom,saw2";
 			reg = <0xf9012000 0x1000>;
 			regulator;
-- 
2.1.0


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

* [PATCH v17 05/10] ARM: dts: qcom: Add power-controller device node for 8084 Krait CPUs
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
                   ` (3 preceding siblings ...)
  2015-03-20 20:21 ` [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 06/10] ARM: dts: qcom: Update power-controller device node for 8064 " Lina Iyer
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Each Krait CPU in the QCOM 8084 SoC has an SAW power controller to
regulate the power to the cpu and aide the core in entering idle states.
Reference the SAW instance and associate the instance with the CPU core.

Cc: Kumar Gala <galak@codeaurora.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
---
 arch/arm/boot/dts/qcom-apq8084.dtsi | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/qcom-apq8084.dtsi b/arch/arm/boot/dts/qcom-apq8084.dtsi
index 1f130bc..71182bf 100644
--- a/arch/arm/boot/dts/qcom-apq8084.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8084.dtsi
@@ -21,6 +21,7 @@
 			enable-method = "qcom,kpss-acc-v2";
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc0>;
+			qcom,saw = <&saw0>;
 		};
 
 		cpu@1 {
@@ -30,6 +31,7 @@
 			enable-method = "qcom,kpss-acc-v2";
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc1>;
+			qcom,saw = <&saw1>;
 		};
 
 		cpu@2 {
@@ -39,6 +41,7 @@
 			enable-method = "qcom,kpss-acc-v2";
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc2>;
+			qcom,saw = <&saw2>;
 		};
 
 		cpu@3 {
@@ -48,6 +51,7 @@
 			enable-method = "qcom,kpss-acc-v2";
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc3>;
+			qcom,saw = <&saw3>;
 		};
 
 		L2: l2-cache {
@@ -144,7 +148,27 @@
 			};
 		};
 
-		saw_l2: regulator@f9012000 {
+		saw0: power-controller@f9089000 {
+			compatible = "qcom,apq8084-saw2-v2.1-cpu";
+			reg = <0xf9089000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw1: power-controller@f9099000 {
+			compatible = "qcom,apq8084-saw2-v2.1-cpu";
+			reg = <0xf9099000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw2: power-controller@f90a9000 {
+			compatible = "qcom,apq8084-saw2-v2.1-cpu";
+			reg = <0xf90a9000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw3: power-controller@f90b9000 {
+			compatible = "qcom,apq8084-saw2-v2.1-cpu";
+			reg = <0xf90b9000 0x1000>, <0xf9009000 0x1000>;
+		};
+
+		saw_l2: power-controller@f9012000 {
 			compatible = "qcom,saw2";
 			reg = <0xf9012000 0x1000>;
 			regulator;
-- 
2.1.0


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

* [PATCH v17 06/10] ARM: dts: qcom: Update power-controller device node for 8064 Krait CPUs
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
                   ` (4 preceding siblings ...)
  2015-03-20 20:21 ` [PATCH v17 05/10] ARM: dts: qcom: Add power-controller device node for 8084 " Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 07/10] ARM: dts: qcom: Add idle states device nodes for 8974/8074 Lina Iyer
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Update the SAW2 DT bindings to add qcom,apq8064-saw2-v1.1-cpu compatible
binding string to configure SPM registers and allow the SPM to put the
core in deeper idle states when the core is idle.

Cc: Kumar Gala <galak@codeaurora.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
---
 arch/arm/boot/dts/qcom-apq8064.dtsi | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
index b3154c0..9fd24bc 100644
--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
@@ -139,26 +139,26 @@
 			reg = <0x020b8000 0x1000>, <0x02008000 0x1000>;
 		};
 
-		saw0: regulator@2089000 {
-			compatible = "qcom,saw2";
+		saw0: power-controller@2089000 {
+			compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2";
 			reg = <0x02089000 0x1000>, <0x02009000 0x1000>;
 			regulator;
 		};
 
-		saw1: regulator@2099000 {
-			compatible = "qcom,saw2";
+		saw1: power-controller@2099000 {
+			compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2";
 			reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
 			regulator;
 		};
 
-		saw2: regulator@20a9000 {
-			compatible = "qcom,saw2";
+		saw2: power-controller@20a9000 {
+			compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2";
 			reg = <0x020a9000 0x1000>, <0x02009000 0x1000>;
 			regulator;
 		};
 
-		saw3: regulator@20b9000 {
-			compatible = "qcom,saw2";
+		saw3: power-controller@20b9000 {
+			compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2";
 			reg = <0x020b9000 0x1000>, <0x02009000 0x1000>;
 			regulator;
 		};
-- 
2.1.0

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

* [PATCH v17 07/10] ARM: dts: qcom: Add idle states device nodes for 8974/8074
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
                   ` (5 preceding siblings ...)
  2015-03-20 20:21 ` [PATCH v17 06/10] ARM: dts: qcom: Update power-controller device node for 8064 " Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
       [not found] ` <1426882877-33008-1-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Add ARM common idle states device bindings for cpuidle support for APQ
8974/8074.

Support Standalone power collapse (SPC) idle state (power down that does
not affect any SoC idle states) for each cpu.

Cc: Kumar Gala <galak@codeaurora.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 arch/arm/boot/dts/qcom-msm8974.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
index 5a41f44..1c28f0f 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -22,6 +22,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc0>;
 			qcom,saw = <&saw0>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@1 {
@@ -32,6 +33,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc1>;
 			qcom,saw = <&saw1>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@2 {
@@ -42,6 +44,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc2>;
 			qcom,saw = <&saw2>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@3 {
@@ -52,6 +55,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc3>;
 			qcom,saw = <&saw3>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		L2: l2-cache {
@@ -59,6 +63,16 @@
 			cache-level = <2>;
 			qcom,saw = <&saw_l2>;
 		};
+
+		idle-states {
+			CPU_SPC: spc {
+				compatible = "qcom,idle-state-spc",
+						"arm,idle-state";
+				entry-latency-us = <150>;
+				exit-latency-us = <200>;
+				min-residency-us = <2000>;
+			};
+		};
 	};
 
 	cpu-pmu {
-- 
2.1.0

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

* [PATCH v17 08/10] ARM: dts: qcom: Add idle states device nodes for 8084
       [not found] ` <1426882877-33008-1-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-03-20 20:21   ` Lina Iyer
  0 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
	khilman-QSEj5FYQhm4dnm+yROfE0A, sboyd-sgV2jX0FEOL9JmXXK+q4OQ,
	galak-sgV2jX0FEOL9JmXXK+q4OQ,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: lorenzo.pieralisi-5wv7dgnIgG8, msivasub-sgV2jX0FEOL9JmXXK+q4OQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA, agross-sgV2jX0FEOL9JmXXK+q4OQ,
	Lina Iyer

Add ARM common idle states device bindings for cpuidle support for APQ
8084.

Support Standalone power collapse (SPC) idle state (power down that does not
affect any SoC idle states) for each cpu.

Cc: Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Signed-off-by: Lina Iyer <lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 arch/arm/boot/dts/qcom-apq8084.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-apq8084.dtsi b/arch/arm/boot/dts/qcom-apq8084.dtsi
index 71182bf..6126d47 100644
--- a/arch/arm/boot/dts/qcom-apq8084.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8084.dtsi
@@ -22,6 +22,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc0>;
 			qcom,saw = <&saw0>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@1 {
@@ -32,6 +33,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc1>;
 			qcom,saw = <&saw1>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@2 {
@@ -42,6 +44,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc2>;
 			qcom,saw = <&saw2>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@3 {
@@ -52,6 +55,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc3>;
 			qcom,saw = <&saw3>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		L2: l2-cache {
@@ -59,6 +63,16 @@
 			cache-level = <2>;
 			qcom,saw = <&saw_l2>;
 		};
+
+		idle-states {
+			CPU_SPC: spc {
+				compatible = "qcom,idle-state-spc",
+						"arm,idle-state";
+				entry-latency-us = <150>;
+				exit-latency-us = <200>;
+				min-residency-us = <2000>;
+			};
+		};
 	};
 
 	cpu-pmu {
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v17 09/10] ARM: dts: qcom: Add idle state device nodes for 8064
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
                   ` (7 preceding siblings ...)
       [not found] ` <1426882877-33008-1-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-03-20 20:21 ` Lina Iyer
  2015-03-20 20:21 ` [PATCH v17 10/10] ARM: qcom: Update defconfig to enable cpuidle Lina Iyer
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Add ARM common idle state device bindings for cpuidle support for APQ
8064.

Support Standalone power collapse (SPC) idle state (power down that does not
affect any SoC idle states) for each cpu.

Cc: Kumar Gala <galak@codeaurora.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 arch/arm/boot/dts/qcom-apq8064.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
index 9fd24bc..592e985 100644
--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
@@ -23,6 +23,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc0>;
 			qcom,saw = <&saw0>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@1 {
@@ -33,6 +34,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc1>;
 			qcom,saw = <&saw1>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@2 {
@@ -43,6 +45,7 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc2>;
 			qcom,saw = <&saw2>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		cpu@3 {
@@ -53,12 +56,23 @@
 			next-level-cache = <&L2>;
 			qcom,acc = <&acc3>;
 			qcom,saw = <&saw3>;
+			cpu-idle-states = <&CPU_SPC>;
 		};
 
 		L2: l2-cache {
 			compatible = "cache";
 			cache-level = <2>;
 		};
+
+		idle-states {
+			CPU_SPC: spc {
+				compatible = "qcom,idle-state-spc",
+						"arm,idle-state";
+				entry-latency-us = <400>;
+				exit-latency-us = <900>;
+				min-residency-us = <3000>;
+			};
+		};
 	};
 
 	cpu-pmu {
-- 
2.1.0

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

* [PATCH v17 10/10] ARM: qcom: Update defconfig to enable cpuidle
  2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
                   ` (8 preceding siblings ...)
  2015-03-20 20:21 ` [PATCH v17 09/10] ARM: dts: qcom: Add idle state device nodes for 8064 Lina Iyer
@ 2015-03-20 20:21 ` Lina Iyer
  9 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-20 20:21 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer

Update defconfig to allow cpuidle for QCOM cpus.

* Enable QCOM_PM
* Enable ARM_QCOM_CPUIDLE

Cc: Kumar Gala <galak@codeaurora.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 arch/arm/configs/qcom_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/qcom_defconfig b/arch/arm/configs/qcom_defconfig
index 8c7da33..56bda6b 100644
--- a/arch/arm/configs/qcom_defconfig
+++ b/arch/arm/configs/qcom_defconfig
@@ -30,6 +30,7 @@ CONFIG_CLEANCACHE=y
 CONFIG_ARM_APPENDED_DTB=y
 CONFIG_ARM_ATAG_DTB_COMPAT=y
 CONFIG_CPU_IDLE=y
+CONFIG_ARM_QCOM_CPUIDLE=y
 CONFIG_VFP=y
 CONFIG_NEON=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
@@ -135,6 +136,7 @@ CONFIG_DMADEVICES=y
 CONFIG_QCOM_BAM_DMA=y
 CONFIG_STAGING=y
 CONFIG_QCOM_GSBI=y
+CONFIG_QCOM_PM=y
 CONFIG_COMMON_CLK_QCOM=y
 CONFIG_APQ_MMCC_8084=y
 CONFIG_IPQ_GCC_806X=y
-- 
2.1.0


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

* [PATCH v17] Currently SPM driver always initializes before the cpuidle driver
       [not found]   ` <1426882877-33008-2-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-03-23 15:46     ` Lina Iyer
  0 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-23 15:46 UTC (permalink / raw)
  To: daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
	khilman-QSEj5FYQhm4dnm+yROfE0A, sboyd-sgV2jX0FEOL9JmXXK+q4OQ,
	galak-sgV2jX0FEOL9JmXXK+q4OQ,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: lorenzo.pieralisi-5wv7dgnIgG8, msivasub-sgV2jX0FEOL9JmXXK+q4OQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA, agross-sgV2jX0FEOL9JmXXK+q4OQ,
	Lina Iyer

Remove unnecessary complexity in supporting initialization of SPM driver
after cpuidle driver. The current kernel initializes SPM driver before
cpuidle driver.

Signed-off-by: Lina Iyer <lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/soc/qcom/spm.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c
index cda321c..84344e7 100644
--- a/drivers/soc/qcom/spm.c
+++ b/drivers/soc/qcom/spm.c
@@ -266,13 +266,9 @@ static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu)
 	per_cpu(qcom_idle_ops, cpu) = fns;
 
 	/*
-	 * Condition: cpuidle_driver_register() needs to happen before
-	 * cpuidle_register_device().
-	 * Check if the SPM probe has happened -
-	 * - If SPM probed successfully before arm_idle_init(), then defer
-	 *   the registration of cpuidle_device back to arm_idle_init()
-	 * - If the SPM probe happens in the future, then let the SPM probe
-	 *   register the cpuidle device, return -ENXIO.
+	 * SPM probe for the cpu should have happened by now, if the
+	 * SPM device does not exist, return -ENXIO to indicate that the
+	 * cpu does not support idle states.
 	 */
 check_spm:
 	return per_cpu(cpu_spm_drv, cpu) ? 0 : -ENXIO;
@@ -332,7 +328,6 @@ static int spm_dev_probe(struct platform_device *pdev)
 	const struct of_device_id *match_id;
 	void __iomem *addr;
 	int cpu;
-	int ret = 0;
 
 	drv = spm_get_drv(pdev, &cpu);
 	if (!drv)
@@ -373,22 +368,7 @@ static int spm_dev_probe(struct platform_device *pdev)
 
 	per_cpu(cpu_spm_drv, cpu) = drv;
 
-	/*
-	 * If the cpuidle ops have already been registered with cpuidle,
-	 * then we have been waiting on this SPM probe to register the
-	 * cpuidle device.
-	 */
-	if (per_cpu(qcom_idle_ops, cpu)) {
-		struct cpuidle_device *dev;
-
-		dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
-		if (!dev)
-			return -ENOMEM;
-		dev->cpu = cpu;
-		ret = cpuidle_register_device(dev);
-	}
-
-	return ret;
+	return 0;
 }
 
 static struct platform_driver spm_driver = {
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver
  2015-03-20 20:21 ` [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
       [not found]   ` <1426882877-33008-2-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-03-23 18:53   ` Lina Iyer
  2015-03-23 22:06   ` [PATCH v17 " Kumar Gala
  2 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-23 18:53 UTC (permalink / raw)
  To: daniel.lezcano, khilman, sboyd, galak, linux-arm-msm, linux-pm,
	linux-arm-kernel
  Cc: lorenzo.pieralisi, msivasub, devicetree, agross, Lina Iyer,
	Arnd Bergmann

SPM is a hardware block that controls the peripheral logic surrounding
the application cores (cpu/l$). When the core executes WFI instruction,
the SPM takes over the putting the core in low power state as
configured. The wake up for the SPM is an interrupt at the GIC, which
then completes the rest of low power mode sequence and brings the core
out of low power mode.

The SPM has a set of control registers that configure the SPMs
individually based on the type of the core and the runtime conditions.
SPM is a finite state machine block to which a sequence is provided and
it interprets the bytes and executes them in sequence. Each low power
mode that the core can enter into is provided to the SPM as a sequence.

Configure the SPM to set the core (cpu or L2) into its low power mode,
the index of the first command in the sequence is set in the SPM_CTL
register. When the core executes ARM wfi instruction, it triggers the
SPM state machine to start executing from that index. The SPM state
machine waits until the interrupt occurs and starts executing the rest
of the sequence until it hits the end of the sequence. The end of the
sequence jumps the core out of its low power mode.

Add support for an idle driver to set up the SPM to place the core in
Standby or Standalone power collapse mode when the core is idle.

Based on work by: Mahesh Sivasubramanian <msivasub@codeaurora.org>,
Ai Li <ali@codeaurora.org>, Praveen Chidambaram <pchidamb@codeaurora.org>
Original tree available at -
git://codeaurora.org/quic/la/kernel/msm-3.10.git

Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
 drivers/soc/qcom/Kconfig                           |   7 +
 drivers/soc/qcom/Makefile                          |   1 +
 drivers/soc/qcom/spm.c                             | 385 +++++++++++++++++++++
 4 files changed, 416 insertions(+), 6 deletions(-)
 create mode 100644 drivers/soc/qcom/spm.c

diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
index 1505fb8..664aa91 100644
--- a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
+++ b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
@@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)
 
 The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the
 Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
-micro-controller that transitions a piece of hardware (like a processor or
+power-controller that transitions a piece of hardware (like a processor or
 subsystem) into and out of low power modes via a direct connection to
 the PMIC. It can also be wired up to interact with other processors in the
 system, notifying them when a low power state is entered or exited.
 
+Multiple revisions of the SAW hardware are supported using these Device Nodes.
+SAW2 revisions differ in the register offset and configuration data. Also, the
+same revision of the SAW in different SoCs may have different configuration
+data due the the differences in hardware capabilities. Hence the SoC name, the
+version of the SAW hardware in that SoC and the distinction between cpu (big
+or Little) or cache, may be needed to uniquely identify the SAW register
+configuration and initialization data. The compatible string is used to
+indicate this parameter.
+
 PROPERTIES
 
 - compatible:
@@ -14,10 +23,11 @@ PROPERTIES
 	Value type: <string>
 	Definition: shall contain "qcom,saw2". A more specific value should be
 		    one of:
-			 "qcom,saw2-v1"
-			 "qcom,saw2-v1.1"
-			 "qcom,saw2-v2"
-			 "qcom,saw2-v2.1"
+			"qcom,saw2-v2"
+			"qcom,saw2-v2.1"
+			"qcom,apq8064-saw2-v1.1-cpu"
+			"qcom,msm8974-saw2-v2.1-cpu"
+			"qcom,apq8084-saw2-v2.1-cpu"
 
 - reg:
 	Usage: required
@@ -26,10 +36,17 @@ PROPERTIES
 		    the register region. An optional second element specifies
 		    the base address and size of the alias register region.
 
+- regulator:
+	Usage: optional
+	Value type: boolean
+	Definition: Indicates that this SPM device acts as a regulator device
+			device for the core (CPU or Cache) the SPM is attached
+			to.
 
 Example:
 
-	regulator@2099000 {
+	power-controller@2099000 {
 		compatible = "qcom,saw2";
 		reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
+		regulator;
 	};
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 7bd2c94..628bcba 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -9,3 +9,10 @@ config QCOM_GSBI
           functions for connecting the underlying serial UART, SPI, and I2C
           devices to the output pins.
 
+config QCOM_PM
+	bool "Qualcomm Power Management"
+	depends on ARCH_QCOM
+	help
+	  QCOM Platform specific power driver to manage cores and L2 low power
+	  modes. It interface with various system drivers to put the cores in
+	  low power modes.
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 4389012..931d385 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
+obj-$(CONFIG_QCOM_PM)	+=	spm.o
diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c
new file mode 100644
index 0000000..84344e7
--- /dev/null
+++ b/drivers/soc/qcom/spm.c
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014,2015, Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/cpuidle.h>
+#include <linux/cpu_pm.h>
+#include <linux/qcom_scm.h>
+
+#include <asm/cpuidle.h>
+#include <asm/proc-fns.h>
+#include <asm/suspend.h>
+
+#define MAX_PMIC_DATA		2
+#define MAX_SEQ_DATA		64
+#define SPM_CTL_INDEX		0x7f
+#define SPM_CTL_INDEX_SHIFT	4
+#define SPM_CTL_EN		BIT(0)
+
+enum pm_sleep_mode {
+	PM_SLEEP_MODE_STBY,
+	PM_SLEEP_MODE_RET,
+	PM_SLEEP_MODE_SPC,
+	PM_SLEEP_MODE_PC,
+	PM_SLEEP_MODE_NR,
+};
+
+enum spm_reg {
+	SPM_REG_CFG,
+	SPM_REG_SPM_CTL,
+	SPM_REG_DLY,
+	SPM_REG_PMIC_DLY,
+	SPM_REG_PMIC_DATA_0,
+	SPM_REG_PMIC_DATA_1,
+	SPM_REG_VCTL,
+	SPM_REG_SEQ_ENTRY,
+	SPM_REG_SPM_STS,
+	SPM_REG_PMIC_STS,
+	SPM_REG_NR,
+};
+
+struct spm_reg_data {
+	const u8 *reg_offset;
+	u32 spm_cfg;
+	u32 spm_dly;
+	u32 pmic_dly;
+	u32 pmic_data[MAX_PMIC_DATA];
+	u8 seq[MAX_SEQ_DATA];
+	u8 start_index[PM_SLEEP_MODE_NR];
+};
+
+struct spm_driver_data {
+	void __iomem *reg_base;
+	const struct spm_reg_data *reg_data;
+};
+
+static const u8 spm_reg_offset_v2_1[SPM_REG_NR] = {
+	[SPM_REG_CFG]		= 0x08,
+	[SPM_REG_SPM_CTL]	= 0x30,
+	[SPM_REG_DLY]		= 0x34,
+	[SPM_REG_SEQ_ENTRY]	= 0x80,
+};
+
+/* SPM register data for 8974, 8084 */
+static const struct spm_reg_data spm_reg_8974_8084_cpu  = {
+	.reg_offset = spm_reg_offset_v2_1,
+	.spm_cfg = 0x1,
+	.spm_dly = 0x3C102800,
+	.seq = { 0x03, 0x0B, 0x0F, 0x00, 0x20, 0x80, 0x10, 0xE8, 0x5B, 0x03,
+		0x3B, 0xE8, 0x5B, 0x82, 0x10, 0x0B, 0x30, 0x06, 0x26, 0x30,
+		0x0F },
+	.start_index[PM_SLEEP_MODE_STBY] = 0,
+	.start_index[PM_SLEEP_MODE_SPC] = 3,
+};
+
+static const u8 spm_reg_offset_v1_1[SPM_REG_NR] = {
+	[SPM_REG_CFG]		= 0x08,
+	[SPM_REG_SPM_CTL]	= 0x20,
+	[SPM_REG_PMIC_DLY]	= 0x24,
+	[SPM_REG_PMIC_DATA_0]	= 0x28,
+	[SPM_REG_PMIC_DATA_1]	= 0x2C,
+	[SPM_REG_SEQ_ENTRY]	= 0x80,
+};
+
+/* SPM register data for 8064 */
+static const struct spm_reg_data spm_reg_8064_cpu = {
+	.reg_offset = spm_reg_offset_v1_1,
+	.spm_cfg = 0x1F,
+	.pmic_dly = 0x02020004,
+	.pmic_data[0] = 0x0084009C,
+	.pmic_data[1] = 0x00A4001C,
+	.seq = { 0x03, 0x0F, 0x00, 0x24, 0x54, 0x10, 0x09, 0x03, 0x01,
+		0x10, 0x54, 0x30, 0x0C, 0x24, 0x30, 0x0F },
+	.start_index[PM_SLEEP_MODE_STBY] = 0,
+	.start_index[PM_SLEEP_MODE_SPC] = 2,
+};
+
+static DEFINE_PER_CPU(struct spm_driver_data *, cpu_spm_drv);
+
+typedef int (*idle_fn)(int);
+static DEFINE_PER_CPU(idle_fn*, qcom_idle_ops);
+
+static inline void spm_register_write(struct spm_driver_data *drv,
+					enum spm_reg reg, u32 val)
+{
+	if (drv->reg_data->reg_offset[reg])
+		writel_relaxed(val, drv->reg_base +
+				drv->reg_data->reg_offset[reg]);
+}
+
+/* Ensure a guaranteed write, before return */
+static inline void spm_register_write_sync(struct spm_driver_data *drv,
+					enum spm_reg reg, u32 val)
+{
+	u32 ret;
+
+	if (!drv->reg_data->reg_offset[reg])
+		return;
+
+	do {
+		writel_relaxed(val, drv->reg_base +
+				drv->reg_data->reg_offset[reg]);
+		ret = readl_relaxed(drv->reg_base +
+				drv->reg_data->reg_offset[reg]);
+		if (ret == val)
+			break;
+		cpu_relax();
+	} while (1);
+}
+
+static inline u32 spm_register_read(struct spm_driver_data *drv,
+					enum spm_reg reg)
+{
+	return readl_relaxed(drv->reg_base + drv->reg_data->reg_offset[reg]);
+}
+
+static void spm_set_low_power_mode(struct spm_driver_data *drv,
+					enum pm_sleep_mode mode)
+{
+	u32 start_index;
+	u32 ctl_val;
+
+	start_index = drv->reg_data->start_index[mode];
+
+	ctl_val = spm_register_read(drv, SPM_REG_SPM_CTL);
+	ctl_val &= ~(SPM_CTL_INDEX << SPM_CTL_INDEX_SHIFT);
+	ctl_val |= start_index << SPM_CTL_INDEX_SHIFT;
+	ctl_val |= SPM_CTL_EN;
+	spm_register_write_sync(drv, SPM_REG_SPM_CTL, ctl_val);
+}
+
+static int qcom_pm_collapse(unsigned long int unused)
+{
+	qcom_scm_cpu_power_down(QCOM_SCM_CPU_PWR_DOWN_L2_ON);
+
+	/*
+	 * Returns here only if there was a pending interrupt and we did not
+	 * power down as a result.
+	 */
+	return -1;
+}
+
+static int qcom_cpu_spc(int cpu)
+{
+	int ret;
+	struct spm_driver_data *drv = per_cpu(cpu_spm_drv, cpu);
+
+	spm_set_low_power_mode(drv, PM_SLEEP_MODE_SPC);
+	ret = cpu_suspend(0, qcom_pm_collapse);
+	/*
+	 * ARM common code executes WFI without calling into our driver and
+	 * if the SPM mode is not reset, then we may accidently power down the
+	 * cpu when we intended only to gate the cpu clock.
+	 * Ensure the state is set to standby before returning.
+	 */
+	spm_set_low_power_mode(drv, PM_SLEEP_MODE_STBY);
+
+	return ret;
+}
+
+static int qcom_idle_enter(int cpu, unsigned long index)
+{
+	return per_cpu(qcom_idle_ops, cpu)[index](cpu);
+}
+
+static const struct of_device_id qcom_idle_state_match[] __initconst = {
+	{ .compatible = "qcom,idle-state-spc", .data = qcom_cpu_spc },
+	{ },
+};
+
+static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu)
+{
+	const struct of_device_id *match_id;
+	struct device_node *state_node;
+	int i;
+	int state_count = 1;
+	idle_fn idle_fns[CPUIDLE_STATE_MAX];
+	idle_fn *fns;
+	cpumask_t mask;
+	bool use_scm_power_down = false;
+
+	for (i = 0; ; i++) {
+		state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i);
+		if (!state_node)
+			break;
+
+		if (!of_device_is_available(state_node))
+			continue;
+
+		if (i == CPUIDLE_STATE_MAX) {
+			pr_warn("%s: cpuidle states reached max possible\n",
+					__func__);
+			break;
+		}
+
+		match_id = of_match_node(qcom_idle_state_match, state_node);
+		if (!match_id)
+			return -ENODEV;
+
+		idle_fns[state_count] = match_id->data;
+
+		/* Check if any of the states allow power down */
+		if (match_id->data == qcom_cpu_spc)
+			use_scm_power_down = true;
+
+		state_count++;
+	}
+
+	if (state_count == 1)
+		goto check_spm;
+
+	fns = devm_kcalloc(get_cpu_device(cpu), state_count, sizeof(*fns),
+			GFP_KERNEL);
+	if (!fns)
+		return -ENOMEM;
+
+	for (i = 1; i < state_count; i++)
+		fns[i] = idle_fns[i];
+
+	if (use_scm_power_down) {
+		/* We have atleast one power down mode */
+		cpumask_clear(&mask);
+		cpumask_set_cpu(cpu, &mask);
+		qcom_scm_set_warm_boot_addr(cpu_resume, &mask);
+	}
+
+	per_cpu(qcom_idle_ops, cpu) = fns;
+
+	/*
+	 * SPM probe for the cpu should have happened by now, if the
+	 * SPM device does not exist, return -ENXIO to indicate that the
+	 * cpu does not support idle states.
+	 */
+check_spm:
+	return per_cpu(cpu_spm_drv, cpu) ? 0 : -ENXIO;
+}
+
+struct cpuidle_ops qcom_cpuidle_ops __initdata = {
+	.suspend = qcom_idle_enter,
+	.init = qcom_cpuidle_init,
+};
+
+CPUIDLE_METHOD_OF_DECLARE(qcom_idle_v1, "qcom,kpss-acc-v1", &qcom_cpuidle_ops);
+CPUIDLE_METHOD_OF_DECLARE(qcom_idle_v2, "qcom,kpss-acc-v2", &qcom_cpuidle_ops);
+
+static struct spm_driver_data *spm_get_drv(struct platform_device *pdev,
+		int *spm_cpu)
+{
+	struct spm_driver_data *drv = NULL;
+	struct device_node *cpu_node, *saw_node;
+	int cpu;
+	bool found;
+
+	for_each_possible_cpu(cpu) {
+		cpu_node = of_cpu_device_node_get(cpu);
+		if (!cpu_node)
+			continue;
+		saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
+		found = (saw_node == pdev->dev.of_node);
+		of_node_put(saw_node);
+		of_node_put(cpu_node);
+		if (found)
+			break;
+	}
+
+	if (found) {
+		drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
+		if (drv)
+			*spm_cpu = cpu;
+	}
+
+	return drv;
+}
+
+static const struct of_device_id spm_match_table[] = {
+	{ .compatible = "qcom,msm8974-saw2-v2.1-cpu",
+	  .data = &spm_reg_8974_8084_cpu },
+	{ .compatible = "qcom,apq8084-saw2-v2.1-cpu",
+	  .data = &spm_reg_8974_8084_cpu },
+	{ .compatible = "qcom,apq8064-saw2-v1.1-cpu",
+	  .data = &spm_reg_8064_cpu },
+	{ },
+};
+
+static int spm_dev_probe(struct platform_device *pdev)
+{
+	struct spm_driver_data *drv;
+	struct resource *res;
+	const struct of_device_id *match_id;
+	void __iomem *addr;
+	int cpu;
+
+	drv = spm_get_drv(pdev, &cpu);
+	if (!drv)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	drv->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(drv->reg_base))
+		return PTR_ERR(drv->reg_base);
+
+	match_id = of_match_node(spm_match_table, pdev->dev.of_node);
+	if (!match_id)
+		return -ENODEV;
+
+	drv->reg_data = match_id->data;
+
+	/* Write the SPM sequences first.. */
+	addr = drv->reg_base + drv->reg_data->reg_offset[SPM_REG_SEQ_ENTRY];
+	__iowrite32_copy(addr, drv->reg_data->seq,
+			ARRAY_SIZE(drv->reg_data->seq) / 4);
+
+	/*
+	 * ..and then the control registers.
+	 * On some SoC if the control registers are written first and if the
+	 * CPU was held in reset, the reset signal could trigger the SPM state
+	 * machine, before the sequences are completely written.
+	 */
+	spm_register_write(drv, SPM_REG_CFG, drv->reg_data->spm_cfg);
+	spm_register_write(drv, SPM_REG_DLY, drv->reg_data->spm_dly);
+	spm_register_write(drv, SPM_REG_PMIC_DLY, drv->reg_data->pmic_dly);
+	spm_register_write(drv, SPM_REG_PMIC_DATA_0,
+				drv->reg_data->pmic_data[0]);
+	spm_register_write(drv, SPM_REG_PMIC_DATA_1,
+				drv->reg_data->pmic_data[1]);
+
+	/* Set up Standby as the default low power mode */
+	spm_set_low_power_mode(drv, PM_SLEEP_MODE_STBY);
+
+	per_cpu(cpu_spm_drv, cpu) = drv;
+
+	return 0;
+}
+
+static struct platform_driver spm_driver = {
+	.probe = spm_dev_probe,
+	.driver = {
+		.name = "saw",
+		.of_match_table = spm_match_table,
+	},
+};
+module_platform_driver(spm_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("SAW power controller driver");
+MODULE_ALIAS("platform:saw");
-- 
2.1.0

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

* Re: [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs
  2015-03-20 20:21 ` [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs Lina Iyer
@ 2015-03-23 22:05   ` Kumar Gala
  2015-03-23 23:06     ` Lina Iyer
  0 siblings, 1 reply; 19+ messages in thread
From: Kumar Gala @ 2015-03-23 22:05 UTC (permalink / raw)
  To: Lina Iyer
  Cc: daniel.lezcano, khilman, sboyd, linux-arm-msm, linux-pm,
	linux-arm-kernel, lorenzo.pieralisi, msivasub, devicetree,
	agross


On Mar 20, 2015, at 1:21 PM, Lina Iyer <lina.iyer@linaro.org> wrote:

> Each Krait CPU in the QCOM 8074/8974 SoC has an SAW power controller to
> regulate the power to the cpu and aide the core in entering idle states.
> Reference the SAW instance and associate the instance with the CPU core.
> 
> Cc: Kumar Gala <galak@codeaurora.org>
> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
> arch/arm/boot/dts/qcom-msm8974.dtsi | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
> index e265ec1..5a41f44 100644
> --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
> +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
> @@ -21,6 +21,7 @@
> 			reg = <0>;
> 			next-level-cache = <&L2>;
> 			qcom,acc = <&acc0>;
> +			qcom,saw = <&saw0>;
> 		};
> 
> 		cpu@1 {
> @@ -30,6 +31,7 @@
> 			reg = <1>;
> 			next-level-cache = <&L2>;
> 			qcom,acc = <&acc1>;
> +			qcom,saw = <&saw1>;
> 		};
> 
> 		cpu@2 {
> @@ -39,6 +41,7 @@
> 			reg = <2>;
> 			next-level-cache = <&L2>;
> 			qcom,acc = <&acc2>;
> +			qcom,saw = <&saw2>;
> 		};
> 
> 		cpu@3 {
> @@ -48,6 +51,7 @@
> 			reg = <3>;
> 			next-level-cache = <&L2>;
> 			qcom,acc = <&acc3>;
> +			qcom,saw = <&saw3>;
> 		};
> 
> 		L2: l2-cache {
> @@ -144,7 +148,27 @@
> 			};
> 		};
> 
> -		saw_l2: regulator@f9012000 {
> +		saw0: power-controller@f9089000 {
> +			compatible = "qcom,msm8974-saw2-v2.1-cpu”;

Should these include “qcom,saw”?

> +			reg = <0xf9089000 0x1000>, <0xf9009000 0x1000>;
> +		};
> +
> +		saw1: power-controller@f9099000 {
> +			compatible = "qcom,msm8974-saw2-v2.1-cpu";
> +			reg = <0xf9099000 0x1000>, <0xf9009000 0x1000>;
> +		};
> +
> +		saw2: power-controller@f90a9000 {
> +			compatible = "qcom,msm8974-saw2-v2.1-cpu";
> +			reg = <0xf90a9000 0x1000>, <0xf9009000 0x1000>;
> +		};
> +
> +		saw3: power-controller@f90b9000 {
> +			compatible = "qcom,msm8974-saw2-v2.1-cpu";
> +			reg = <0xf90b9000 0x1000>, <0xf9009000 0x1000>;
> +		};
> +
> +		saw_l2: power-controller@f9012000 {
> 			compatible = "qcom,saw2";
> 			reg = <0xf9012000 0x1000>;
> 			regulator;
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver
  2015-03-20 20:21 ` [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
       [not found]   ` <1426882877-33008-2-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2015-03-23 18:53   ` [PATCH 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
@ 2015-03-23 22:06   ` Kumar Gala
  2015-03-23 23:15     ` Lina Iyer
  2 siblings, 1 reply; 19+ messages in thread
From: Kumar Gala @ 2015-03-23 22:06 UTC (permalink / raw)
  To: Lina Iyer
  Cc: daniel.lezcano, khilman, sboyd, linux-arm-msm, linux-pm,
	linux-arm-kernel, lorenzo.pieralisi, msivasub, devicetree,
	agross, Arnd Bergmann


On Mar 20, 2015, at 1:21 PM, Lina Iyer <lina.iyer@linaro.org> wrote:

> 
> Based on work by: Mahesh Sivasubramanian <msivasub@codeaurora.org>,
> Ai Li <ali@codeaurora.org>, Praveen Chidambaram <pchidamb@codeaurora.org>
> Original tree available at -
> git://codeaurora.org/quic/la/kernel/msm-3.10.git
> 
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Kevin Hilman <khilman@linaro.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
> ---
> .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
> drivers/soc/qcom/Kconfig                           |   7 +
> drivers/soc/qcom/Makefile                          |   1 +
> drivers/soc/qcom/spm.c                             | 405 +++++++++++++++++++++
> 4 files changed, 436 insertions(+), 6 deletions(-)
> create mode 100644 drivers/soc/qcom/spm.c
> 
> diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
> index 1505fb8..664aa91 100644
> --- a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
> +++ b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
> @@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)
> 
> The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the
> Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
> -micro-controller that transitions a piece of hardware (like a processor or
> +power-controller that transitions a piece of hardware (like a processor or
> subsystem) into and out of low power modes via a direct connection to
> the PMIC. It can also be wired up to interact with other processors in the
> system, notifying them when a low power state is entered or exited.
> 
> +Multiple revisions of the SAW hardware are supported using these Device Nodes.
> +SAW2 revisions differ in the register offset and configuration data. Also, the
> +same revision of the SAW in different SoCs may have different configuration
> +data due the the differences in hardware capabilities. Hence the SoC name, the
> +version of the SAW hardware in that SoC and the distinction between cpu (big
> +or Little) or cache, may be needed to uniquely identify the SAW register
> +configuration and initialization data. The compatible string is used to
> +indicate this parameter.
> +
> PROPERTIES
> 
> - compatible:
> @@ -14,10 +23,11 @@ PROPERTIES
> 	Value type: <string>
> 	Definition: shall contain "qcom,saw2". A more specific value should be
> 		    one of:

Does “qcom,saw2” have any meaning anymore?  I see we use it in some places, but not everywhere on the .dts.  We also see to have the L2 just be a “qcom,saw2” node, do we expect that to change?

> -			 "qcom,saw2-v1"
> -			 "qcom,saw2-v1.1"
> -			 "qcom,saw2-v2"
> -			 "qcom,saw2-v2.1"
> +			"qcom,saw2-v2"
> +			"qcom,saw2-v2.1"
> +			"qcom,apq8064-saw2-v1.1-cpu"
> +			"qcom,msm8974-saw2-v2.1-cpu"
> +			"qcom,apq8084-saw2-v2.1-cpu"
> 
> - reg:
> 	Usage: required
> @@ -26,10 +36,17 @@ PROPERTIES
> 		    the register region. An optional second element specifies
> 		    the base address and size of the alias register region.
> 
> +- regulator:
> +	Usage: optional
> +	Value type: boolean
> +	Definition: Indicates that this SPM device acts as a regulator device
> +			device for the core (CPU or Cache) the SPM is attached
> +			to.
> 
> Example:
> 
> -	regulator@2099000 {
> +	power-controller@2099000 {
> 		compatible = "qcom,saw2";
> 		reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
> +		regulator;
> 	};

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs
  2015-03-23 22:05   ` Kumar Gala
@ 2015-03-23 23:06     ` Lina Iyer
  0 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-23 23:06 UTC (permalink / raw)
  To: Kumar Gala
  Cc: daniel.lezcano, khilman, sboyd, linux-arm-msm, linux-pm,
	linux-arm-kernel, lorenzo.pieralisi, msivasub, devicetree,
	agross

On Mon, Mar 23 2015 at 16:05 -0600, Kumar Gala wrote:
>
>On Mar 20, 2015, at 1:21 PM, Lina Iyer <lina.iyer@linaro.org> wrote:
>
>> Each Krait CPU in the QCOM 8074/8974 SoC has an SAW power controller to
>> regulate the power to the cpu and aide the core in entering idle states.
>> Reference the SAW instance and associate the instance with the CPU core.
>>
>> Cc: Kumar Gala <galak@codeaurora.org>
>> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
>> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
>> ---
>> arch/arm/boot/dts/qcom-msm8974.dtsi | 26 +++++++++++++++++++++++++-
>> 1 file changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
>> index e265ec1..5a41f44 100644
>> --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
>> +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
>> @@ -21,6 +21,7 @@
>> 			reg = <0>;
>> 			next-level-cache = <&L2>;
>> 			qcom,acc = <&acc0>;
>> +			qcom,saw = <&saw0>;
>> 		};
>>
>> 		cpu@1 {
>> @@ -30,6 +31,7 @@
>> 			reg = <1>;
>> 			next-level-cache = <&L2>;
>> 			qcom,acc = <&acc1>;
>> +			qcom,saw = <&saw1>;
>> 		};
>>
>> 		cpu@2 {
>> @@ -39,6 +41,7 @@
>> 			reg = <2>;
>> 			next-level-cache = <&L2>;
>> 			qcom,acc = <&acc2>;
>> +			qcom,saw = <&saw2>;
>> 		};
>>
>> 		cpu@3 {
>> @@ -48,6 +51,7 @@
>> 			reg = <3>;
>> 			next-level-cache = <&L2>;
>> 			qcom,acc = <&acc3>;
>> +			qcom,saw = <&saw3>;
>> 		};
>>
>> 		L2: l2-cache {
>> @@ -144,7 +148,27 @@
>> 			};
>> 		};
>>
>> -		saw_l2: regulator@f9012000 {
>> +		saw0: power-controller@f9089000 {
>> +			compatible = "qcom,msm8974-saw2-v2.1-cpu”;
>
>Should these include “qcom,saw”?
>
I believe the qcom,saw2 is a way for the regulator node to identify
which node is also a regulator.

Only saw_l2 is a regulator node as well on 8074 and thereby needs qcom,saw2.

>> +			reg = <0xf9089000 0x1000>, <0xf9009000 0x1000>;
>> +		};
>> +
>> +		saw1: power-controller@f9099000 {
>> +			compatible = "qcom,msm8974-saw2-v2.1-cpu";
>> +			reg = <0xf9099000 0x1000>, <0xf9009000 0x1000>;
>> +		};
>> +
>> +		saw2: power-controller@f90a9000 {
>> +			compatible = "qcom,msm8974-saw2-v2.1-cpu";
>> +			reg = <0xf90a9000 0x1000>, <0xf9009000 0x1000>;
>> +		};
>> +
>> +		saw3: power-controller@f90b9000 {
>> +			compatible = "qcom,msm8974-saw2-v2.1-cpu";
>> +			reg = <0xf90b9000 0x1000>, <0xf9009000 0x1000>;
>> +		};
>> +
>> +		saw_l2: power-controller@f9012000 {
>> 			compatible = "qcom,saw2";
>> 			reg = <0xf9012000 0x1000>;
>> 			regulator;
>> --
>> 2.1.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>-- 
>Qualcomm Innovation Center, Inc.
>The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>a Linux Foundation Collaborative Project
>

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

* Re: [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver
  2015-03-23 22:06   ` [PATCH v17 " Kumar Gala
@ 2015-03-23 23:15     ` Lina Iyer
  2015-03-23 23:38       ` Kumar Gala
  0 siblings, 1 reply; 19+ messages in thread
From: Lina Iyer @ 2015-03-23 23:15 UTC (permalink / raw)
  To: Kumar Gala
  Cc: daniel.lezcano, khilman, sboyd, linux-arm-msm, linux-pm,
	linux-arm-kernel, lorenzo.pieralisi, msivasub, devicetree,
	agross, Arnd Bergmann

On Mon, Mar 23 2015 at 16:06 -0600, Kumar Gala wrote:
>
>On Mar 20, 2015, at 1:21 PM, Lina Iyer <lina.iyer@linaro.org> wrote:
>
>>
>> Based on work by: Mahesh Sivasubramanian <msivasub@codeaurora.org>,
>> Ai Li <ali@codeaurora.org>, Praveen Chidambaram <pchidamb@codeaurora.org>
>> Original tree available at -
>> git://codeaurora.org/quic/la/kernel/msm-3.10.git
>>
>> Cc: Stephen Boyd <sboyd@codeaurora.org>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Kevin Hilman <khilman@linaro.org>
>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
>> ---
>> .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
>> drivers/soc/qcom/Kconfig                           |   7 +
>> drivers/soc/qcom/Makefile                          |   1 +
>> drivers/soc/qcom/spm.c                             | 405 +++++++++++++++++++++
>> 4 files changed, 436 insertions(+), 6 deletions(-)
>> create mode 100644 drivers/soc/qcom/spm.c
>>
>> diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>> index 1505fb8..664aa91 100644
>> --- a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>> +++ b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>> @@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)
>>
>> The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the
>> Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
>> -micro-controller that transitions a piece of hardware (like a processor or
>> +power-controller that transitions a piece of hardware (like a processor or
>> subsystem) into and out of low power modes via a direct connection to
>> the PMIC. It can also be wired up to interact with other processors in the
>> system, notifying them when a low power state is entered or exited.
>>
>> +Multiple revisions of the SAW hardware are supported using these Device Nodes.
>> +SAW2 revisions differ in the register offset and configuration data. Also, the
>> +same revision of the SAW in different SoCs may have different configuration
>> +data due the the differences in hardware capabilities. Hence the SoC name, the
>> +version of the SAW hardware in that SoC and the distinction between cpu (big
>> +or Little) or cache, may be needed to uniquely identify the SAW register
>> +configuration and initialization data. The compatible string is used to
>> +indicate this parameter.
>> +
>> PROPERTIES
>>
>> - compatible:
>> @@ -14,10 +23,11 @@ PROPERTIES
>> 	Value type: <string>
>> 	Definition: shall contain "qcom,saw2". A more specific value should be
>> 		    one of:
>
>Does “qcom,saw2” have any meaning anymore?  I see we use it in some places, but not everywhere on the .dts.  We also see to have the L2 just be a “qcom,saw2” node, do we expect that to change?
>
It does help match a regulator node as opposed to the specific values
below.

>> -			 "qcom,saw2-v1"
>> -			 "qcom,saw2-v1.1"
>> -			 "qcom,saw2-v2"
>> -			 "qcom,saw2-v2.1"
>> +			"qcom,saw2-v2"
>> +			"qcom,saw2-v2.1"
>> +			"qcom,apq8064-saw2-v1.1-cpu"
>> +			"qcom,msm8974-saw2-v2.1-cpu"
>> +			"qcom,apq8084-saw2-v2.1-cpu"
>>
>> - reg:
>> 	Usage: required
>> @@ -26,10 +36,17 @@ PROPERTIES
>> 		    the register region. An optional second element specifies
>> 		    the base address and size of the alias register region.
>>
>> +- regulator:
>> +	Usage: optional
>> +	Value type: boolean
>> +	Definition: Indicates that this SPM device acts as a regulator device
>> +			device for the core (CPU or Cache) the SPM is attached
>> +			to.
>>
>> Example:
>>
>> -	regulator@2099000 {
>> +	power-controller@2099000 {
>> 		compatible = "qcom,saw2";
>> 		reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
>> +		regulator;
>> 	};
>
>-- 
>Qualcomm Innovation Center, Inc.
>The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>a Linux Foundation Collaborative Project
>

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

* Re: [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver
  2015-03-23 23:15     ` Lina Iyer
@ 2015-03-23 23:38       ` Kumar Gala
  2015-03-23 23:48         ` Lina Iyer
  0 siblings, 1 reply; 19+ messages in thread
From: Kumar Gala @ 2015-03-23 23:38 UTC (permalink / raw)
  To: Lina Iyer
  Cc: daniel.lezcano, khilman, sboyd, linux-arm-msm, linux-pm,
	linux-arm-kernel, lorenzo.pieralisi, msivasub, devicetree,
	agross, Arnd Bergmann


On Mar 23, 2015, at 4:15 PM, Lina Iyer <lina.iyer@linaro.org> wrote:

> On Mon, Mar 23 2015 at 16:06 -0600, Kumar Gala wrote:
>> 
>> On Mar 20, 2015, at 1:21 PM, Lina Iyer <lina.iyer@linaro.org> wrote:
>> 
>>> 
>>> Based on work by: Mahesh Sivasubramanian <msivasub@codeaurora.org>,
>>> Ai Li <ali@codeaurora.org>, Praveen Chidambaram <pchidamb@codeaurora.org>
>>> Original tree available at -
>>> git://codeaurora.org/quic/la/kernel/msm-3.10.git
>>> 
>>> Cc: Stephen Boyd <sboyd@codeaurora.org>
>>> Cc: Arnd Bergmann <arnd@arndb.de>
>>> Cc: Kevin Hilman <khilman@linaro.org>
>>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>>> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
>>> ---
>>> .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
>>> drivers/soc/qcom/Kconfig                           |   7 +
>>> drivers/soc/qcom/Makefile                          |   1 +
>>> drivers/soc/qcom/spm.c                             | 405 +++++++++++++++++++++
>>> 4 files changed, 436 insertions(+), 6 deletions(-)
>>> create mode 100644 drivers/soc/qcom/spm.c
>>> 
>>> diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>>> index 1505fb8..664aa91 100644
>>> --- a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>>> +++ b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>>> @@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)
>>> 
>>> The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the
>>> Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
>>> -micro-controller that transitions a piece of hardware (like a processor or
>>> +power-controller that transitions a piece of hardware (like a processor or
>>> subsystem) into and out of low power modes via a direct connection to
>>> the PMIC. It can also be wired up to interact with other processors in the
>>> system, notifying them when a low power state is entered or exited.
>>> 
>>> +Multiple revisions of the SAW hardware are supported using these Device Nodes.
>>> +SAW2 revisions differ in the register offset and configuration data. Also, the
>>> +same revision of the SAW in different SoCs may have different configuration
>>> +data due the the differences in hardware capabilities. Hence the SoC name, the
>>> +version of the SAW hardware in that SoC and the distinction between cpu (big
>>> +or Little) or cache, may be needed to uniquely identify the SAW register
>>> +configuration and initialization data. The compatible string is used to
>>> +indicate this parameter.
>>> +
>>> PROPERTIES
>>> 
>>> - compatible:
>>> @@ -14,10 +23,11 @@ PROPERTIES
>>> 	Value type: <string>
>>> 	Definition: shall contain "qcom,saw2". A more specific value should be
>>> 		    one of:
>> 
>> Does “qcom,saw2” have any meaning anymore?  I see we use it in some places, but not everywhere on the .dts.  We also see to have the L2 just be a “qcom,saw2” node, do we expect that to change?
>> 
> It does help match a regulator node as opposed to the specific values
> below.

Than we should cleanup the wording.  Right now it reads such that ‘qcom,saw2’ is always required.

>>> -			 "qcom,saw2-v1"
>>> -			 "qcom,saw2-v1.1"
>>> -			 "qcom,saw2-v2"
>>> -			 "qcom,saw2-v2.1"
>>> +			"qcom,saw2-v2"
>>> +			"qcom,saw2-v2.1"
>>> +			"qcom,apq8064-saw2-v1.1-cpu"
>>> +			"qcom,msm8974-saw2-v2.1-cpu"
>>> +			"qcom,apq8084-saw2-v2.1-cpu"
>>> 
>>> - reg:
>>> 	Usage: required
>>> @@ -26,10 +36,17 @@ PROPERTIES
>>> 		    the register region. An optional second element specifies
>>> 		    the base address and size of the alias register region.
>>> 
>>> +- regulator:
>>> +	Usage: optional
>>> +	Value type: boolean
>>> +	Definition: Indicates that this SPM device acts as a regulator device
>>> +			device for the core (CPU or Cache) the SPM is attached
>>> +			to.
>>> 
>>> Example:
>>> 
>>> -	regulator@2099000 {
>>> +	power-controller@2099000 {
>>> 		compatible = "qcom,saw2";
>>> 		reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
>>> +		regulator;
>>> 	};

- k

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver
  2015-03-23 23:38       ` Kumar Gala
@ 2015-03-23 23:48         ` Lina Iyer
  0 siblings, 0 replies; 19+ messages in thread
From: Lina Iyer @ 2015-03-23 23:48 UTC (permalink / raw)
  To: Kumar Gala
  Cc: daniel.lezcano, khilman, sboyd, linux-arm-msm, linux-pm,
	linux-arm-kernel, lorenzo.pieralisi, msivasub, devicetree,
	agross, Arnd Bergmann

On Mon, Mar 23 2015 at 17:38 -0600, Kumar Gala wrote:
>
>On Mar 23, 2015, at 4:15 PM, Lina Iyer <lina.iyer@linaro.org> wrote:
>
>> On Mon, Mar 23 2015 at 16:06 -0600, Kumar Gala wrote:
>>>
>>> On Mar 20, 2015, at 1:21 PM, Lina Iyer <lina.iyer@linaro.org> wrote:
>>>
>>>>
>>>> Based on work by: Mahesh Sivasubramanian <msivasub@codeaurora.org>,
>>>> Ai Li <ali@codeaurora.org>, Praveen Chidambaram <pchidamb@codeaurora.org>
>>>> Original tree available at -
>>>> git://codeaurora.org/quic/la/kernel/msm-3.10.git
>>>>
>>>> Cc: Stephen Boyd <sboyd@codeaurora.org>
>>>> Cc: Arnd Bergmann <arnd@arndb.de>
>>>> Cc: Kevin Hilman <khilman@linaro.org>
>>>> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
>>>> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
>>>> ---
>>>> .../devicetree/bindings/arm/msm/qcom,saw2.txt      |  29 +-
>>>> drivers/soc/qcom/Kconfig                           |   7 +
>>>> drivers/soc/qcom/Makefile                          |   1 +
>>>> drivers/soc/qcom/spm.c                             | 405 +++++++++++++++++++++
>>>> 4 files changed, 436 insertions(+), 6 deletions(-)
>>>> create mode 100644 drivers/soc/qcom/spm.c
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>>>> index 1505fb8..664aa91 100644
>>>> --- a/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>>>> +++ b/Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt
>>>> @@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)
>>>>
>>>> The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the
>>>> Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
>>>> -micro-controller that transitions a piece of hardware (like a processor or
>>>> +power-controller that transitions a piece of hardware (like a processor or
>>>> subsystem) into and out of low power modes via a direct connection to
>>>> the PMIC. It can also be wired up to interact with other processors in the
>>>> system, notifying them when a low power state is entered or exited.
>>>>
>>>> +Multiple revisions of the SAW hardware are supported using these Device Nodes.
>>>> +SAW2 revisions differ in the register offset and configuration data. Also, the
>>>> +same revision of the SAW in different SoCs may have different configuration
>>>> +data due the the differences in hardware capabilities. Hence the SoC name, the
>>>> +version of the SAW hardware in that SoC and the distinction between cpu (big
>>>> +or Little) or cache, may be needed to uniquely identify the SAW register
>>>> +configuration and initialization data. The compatible string is used to
>>>> +indicate this parameter.
>>>> +
>>>> PROPERTIES
>>>>
>>>> - compatible:
>>>> @@ -14,10 +23,11 @@ PROPERTIES
>>>> 	Value type: <string>
>>>> 	Definition: shall contain "qcom,saw2". A more specific value should be
>>>> 		    one of:
>>>
>>> Does “qcom,saw2” have any meaning anymore?  I see we use it in some places, but not everywhere on the .dts.  We also see to have the L2 just be a “qcom,saw2” node, do we expect that to change?
>>>
>> It does help match a regulator node as opposed to the specific values
>> below.
>
>Than we should cleanup the wording.  Right now it reads such that ‘qcom,saw2’ is always required.
>
Ah Ok. Sure. I will respin a new patchset.

Anything else?

>>>> -			 "qcom,saw2-v1"
>>>> -			 "qcom,saw2-v1.1"
>>>> -			 "qcom,saw2-v2"
>>>> -			 "qcom,saw2-v2.1"
>>>> +			"qcom,saw2-v2"
>>>> +			"qcom,saw2-v2.1"
>>>> +			"qcom,apq8064-saw2-v1.1-cpu"
>>>> +			"qcom,msm8974-saw2-v2.1-cpu"
>>>> +			"qcom,apq8084-saw2-v2.1-cpu"
>>>>
>>>> - reg:
>>>> 	Usage: required
>>>> @@ -26,10 +36,17 @@ PROPERTIES
>>>> 		    the register region. An optional second element specifies
>>>> 		    the base address and size of the alias register region.
>>>>
>>>> +- regulator:
>>>> +	Usage: optional
>>>> +	Value type: boolean
>>>> +	Definition: Indicates that this SPM device acts as a regulator device
>>>> +			device for the core (CPU or Cache) the SPM is attached
>>>> +			to.
>>>>
>>>> Example:
>>>>
>>>> -	regulator@2099000 {
>>>> +	power-controller@2099000 {
>>>> 		compatible = "qcom,saw2";
>>>> 		reg = <0x02099000 0x1000>, <0x02009000 0x1000>;
>>>> +		regulator;
>>>> 	};
>
>- k
>
>-- 
>Qualcomm Innovation Center, Inc.
>The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>a Linux Foundation Collaborative Project
>

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

end of thread, other threads:[~2015-03-23 23:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-20 20:21 [PATCH v17 00/11] ARM: qcom: cpuidle support for 8064, 8074, 8084 Lina Iyer
2015-03-20 20:21 ` [PATCH v17 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
     [not found]   ` <1426882877-33008-2-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-23 15:46     ` [PATCH v17] Currently SPM driver always initializes before the cpuidle driver Lina Iyer
2015-03-23 18:53   ` [PATCH 01/10] ARM: qcom: Add Subsystem Power Manager (SPM) driver Lina Iyer
2015-03-23 22:06   ` [PATCH v17 " Kumar Gala
2015-03-23 23:15     ` Lina Iyer
2015-03-23 23:38       ` Kumar Gala
2015-03-23 23:48         ` Lina Iyer
2015-03-20 20:21 ` [PATCH v17 02/10] ARM: cpuidle: qcom: Add documentation for qcom cpuidle states Lina Iyer
2015-03-20 20:21 ` [PATCH v17 03/10] ARM: cpuidle: Add cpuidle support for QCOM cpus Lina Iyer
2015-03-20 20:21 ` [PATCH v17 04/10] ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs Lina Iyer
2015-03-23 22:05   ` Kumar Gala
2015-03-23 23:06     ` Lina Iyer
2015-03-20 20:21 ` [PATCH v17 05/10] ARM: dts: qcom: Add power-controller device node for 8084 " Lina Iyer
2015-03-20 20:21 ` [PATCH v17 06/10] ARM: dts: qcom: Update power-controller device node for 8064 " Lina Iyer
2015-03-20 20:21 ` [PATCH v17 07/10] ARM: dts: qcom: Add idle states device nodes for 8974/8074 Lina Iyer
     [not found] ` <1426882877-33008-1-git-send-email-lina.iyer-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-20 20:21   ` [PATCH v17 08/10] ARM: dts: qcom: Add idle states device nodes for 8084 Lina Iyer
2015-03-20 20:21 ` [PATCH v17 09/10] ARM: dts: qcom: Add idle state device nodes for 8064 Lina Iyer
2015-03-20 20:21 ` [PATCH v17 10/10] ARM: qcom: Update defconfig to enable cpuidle Lina Iyer

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).