linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: andy.gross@linaro.org (Andy Gross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] soc: qcom: Add suspend to idle support
Date: Thu, 19 May 2016 00:00:16 -0500	[thread overview]
Message-ID: <1463634020-17252-2-git-send-email-andy.gross@linaro.org> (raw)
In-Reply-To: <1463634020-17252-1-git-send-email-andy.gross@linaro.org>

This patch adds suspend to idle support for Qualcomm processors.  While
suspend to memory will be a valid state, there won't be any special
handling or power savings over the suspend to idle.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
---
 drivers/soc/qcom/Makefile  |  1 +
 drivers/soc/qcom/suspend.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 drivers/soc/qcom/suspend.c

diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index fdd664e..7c479d3 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
 obj-$(CONFIG_QCOM_SMP2P)	+= smp2p.o
 obj-$(CONFIG_QCOM_SMSM)	+= smsm.o
 obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
+obj-$(CONFIG_SUSPEND)	+=	suspend.o
diff --git a/drivers/soc/qcom/suspend.c b/drivers/soc/qcom/suspend.c
new file mode 100644
index 0000000..7d3f2dd
--- /dev/null
+++ b/drivers/soc/qcom/suspend.c
@@ -0,0 +1,77 @@
+/*
+ * (C) Copyright 2016 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/cpuidle.h>
+#include <linux/suspend.h>
+
+
+static void qcom_pm_enter_freeze(struct cpuidle_device *dev,
+	struct cpuidle_driver *drv,
+	int index)
+{
+	drv->states[index].enter(dev, drv, index);
+}
+
+static const struct of_device_id qcom_idle_state_match[] = {
+	{ .compatible = "qcom,idle-state-spc", },
+	{ },
+};
+
+static const struct platform_suspend_ops qcom_suspend_ops = {
+	.valid          = suspend_valid_only_mem,
+};
+
+static int __init qcom_pm_init(void)
+{
+	struct cpuidle_device *cpu_dev;
+	struct cpuidle_driver *cpu_drv;
+	int state_count;
+	struct device_node *state_np, *cpu_np;
+	const struct of_device_id *match;
+	int i;
+
+	/* configure CPU enter_freeze if applicable */
+	for_each_present_cpu(i) {
+		cpu_np = of_get_cpu_node(i, NULL);
+		cpu_dev = per_cpu_ptr(cpuidle_devices, i);
+		cpu_drv = cpuidle_get_cpu_driver(cpu_dev);
+
+		if (!cpu_dev || !cpu_drv) {
+			of_node_put(cpu_np);
+			return -EPROBE_DEFER;
+		}
+
+		state_count = 0;
+		state_np = of_parse_phandle(cpu_np, "cpu-idle-states",
+						  state_count);
+
+		while (state_np) {
+			match = of_match_node(qcom_idle_state_match,
+					      state_np);
+
+			state_count++;
+			if (match)
+				cpu_drv->states[state_count].enter_freeze =
+						&qcom_pm_enter_freeze;
+			of_node_put(state_np);
+
+			state_np = of_parse_phandle(cpu_np, "cpu-idle-states",
+						    state_count);
+		}
+
+		of_node_put(cpu_np);
+	}
+
+	suspend_set_ops(&qcom_suspend_ops);
+
+	return 0;
+}
+
+late_initcall(qcom_pm_init);
-- 
1.9.1

  reply	other threads:[~2016-05-19  5:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19  5:00 [PATCH 0/5] Qualcomm Suspend to Idle Support Andy Gross
2016-05-19  5:00 ` Andy Gross [this message]
2016-06-09  7:39   ` [PATCH 1/5] soc: qcom: Add suspend to idle support Ulf Hansson
2016-06-09 18:09     ` Andy Gross
2016-06-10  8:47       ` Ulf Hansson
2016-06-10 15:26         ` Andy Gross
2016-06-13 16:12       ` Daniel Lezcano
2016-05-19  5:00 ` [PATCH 2/5] arm: defconfig: Enable PM8941 pwr key Andy Gross
2016-06-10 20:25   ` Bjorn Andersson
2016-05-19  5:00 ` [PATCH 3/5] arm64: dts: msm8916: Add spc compat tag Andy Gross
2016-05-19 19:52   ` Stanimir Varbanov
2016-05-19 20:16     ` Andy Gross
2016-06-10 15:48   ` Mark Rutland
2016-06-10 16:12     ` Andy Gross
2016-06-10 16:25       ` Mark Rutland
2016-06-10 16:47         ` Andy Gross
2016-06-10 21:16           ` Lina Iyer
2016-06-10 21:52             ` Andy Gross
2016-06-13 11:00           ` Mark Rutland
2016-06-13 13:48             ` Lorenzo Pieralisi
2016-06-16  8:12               ` Andy Gross
2016-06-10 16:31       ` Lorenzo Pieralisi
2016-06-10 16:52         ` Andy Gross
2016-06-10 17:06           ` Lorenzo Pieralisi
2016-06-10 17:27             ` Andy Gross
2016-06-10 20:59               ` Lorenzo Pieralisi
2016-05-19  5:00 ` [PATCH 4/5] ARM: dts: qcom: Remove size elements from pmic reg Andy Gross
2016-06-10 20:26   ` Bjorn Andersson
2016-05-19  5:00 ` [PATCH 5/5] ARM: dts: qcom: pma8084: Add pwrkey entry Andy Gross
2016-06-10 20:29   ` Bjorn Andersson
2016-05-20  6:09 ` [PATCH 0/5] Qualcomm Suspend to Idle Support Pramod Gurav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463634020-17252-2-git-send-email-andy.gross@linaro.org \
    --to=andy.gross@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).