From patchwork Thu May 19 05:00:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Gross X-Patchwork-Id: 9124231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D903FBF29F for ; Thu, 19 May 2016 05:02:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE944201BB for ; Thu, 19 May 2016 05:02:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1094A2011E for ; Thu, 19 May 2016 05:02:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b3G57-0001qk-0Y; Thu, 19 May 2016 05:01:09 +0000 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b3G4x-0000cf-UM for linux-arm-kernel@lists.infradead.org; Thu, 19 May 2016 05:01:00 +0000 Received: by mail-oi0-x235.google.com with SMTP id x201so111266062oif.3 for ; Wed, 18 May 2016 22:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I8Zayg1ognZPllB4A7U6grN+01+J16XIDGxBK0O0xCc=; b=SKAEqHIamhqBYDMTSonWDtkUjLojtBqreBuJ+jkGvUtSRjFySeaXXpUQbrROi0D3gb wOaCkqCbrRHCuYjbz0BLIi1QDJaY5bdy+SIbmy+3+eEZY3zEzb7FFQYqIyZBs5pt7okh W1qzfqlSj+aNKw+/3vp5ixA4jHQUwLW7nJnXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I8Zayg1ognZPllB4A7U6grN+01+J16XIDGxBK0O0xCc=; b=PdgwkmUSaZxv2XOQEEaHX6c/bxDJpLUF2NfVcBBazC70x43NfzksYVxd35IkQS04eY w/xGx8ekzE3K9AxBJ9Kz6p0i7/9H58cc8IAyDbfPJ2cuT0a6Qsy2AvAzB9Ock3itI8nR VM+0HZYmEsshM1fOIXEaLGddlV+In4MOzmMaK/1vw+4SNKMsb8dJ1rdJyk3GDOo3AZO9 f0WMYXfqpEh2XqhcJZcRmisJc3qK9L2hZ+FGzrFowq4m5rdKRfKZRsoeGpNoliQE0Emc e7aSk8Y4XoudLlkYbgq0QbTEBZLObp91OD0HUCMHg1LsBF3SIZupEGG1Jmeyfqv7jt3Y Rrxw== X-Gm-Message-State: AOPr4FUuO8eDbiAPzOTLqSe0OwqJMYZzOqND4kpt0//WzIqRACIHJU8Ka2LTe+Ba1toGESx7 X-Received: by 10.157.14.236 with SMTP id 99mr6274427otj.83.1463634038900; Wed, 18 May 2016 22:00:38 -0700 (PDT) Received: from localhost ([2602:306:c558:19b0:a405:4675:28db:e07c]) by smtp.gmail.com with ESMTPSA id d75sm3446371oig.15.2016.05.18.22.00.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 18 May 2016 22:00:38 -0700 (PDT) From: Andy Gross To: linux-pm@vger.kernel.org Subject: [PATCH 1/5] soc: qcom: Add suspend to idle support Date: Thu, 19 May 2016 00:00:16 -0500 Message-Id: <1463634020-17252-2-git-send-email-andy.gross@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463634020-17252-1-git-send-email-andy.gross@linaro.org> References: <1463634020-17252-1-git-send-email-andy.gross@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160518_220100_048832_F005AA90 X-CRM114-Status: GOOD ( 18.37 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Gross , linux-arm-msm@vger.kernel.org, stanimir.varbanov@linaro.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 +#include +#include +#include + + +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);