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: 9124101 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 02D629F1D3 for ; Thu, 19 May 2016 05:00:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2F21201BB for ; Thu, 19 May 2016 05:00:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3A7020219 for ; Thu, 19 May 2016 05:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751775AbcESFAk (ORCPT ); Thu, 19 May 2016 01:00:40 -0400 Received: from mail-oi0-f41.google.com ([209.85.218.41]:35704 "EHLO mail-oi0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610AbcESFAj (ORCPT ); Thu, 19 May 2016 01:00:39 -0400 Received: by mail-oi0-f41.google.com with SMTP id x19so111190446oix.2 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=MYZLclO5Db+nt1wBxDf9iF/PR/4rif7G4uIyg9PRWfMHmY1XqBrm4sliyx/eJu6uJR 9gMu45Z9zjlsJKrP2xFjQSRy9mdBVpZY0jFWPF/2cQifDL7z8jFwsFgt2jyotiw17nGd RnLE/p+ZgYi5w/VilK/4aOd8+sLoXs0RAFwmEnAX02BIDr/HWh1xZFDHJjlB06ni+Usv ECnFuDeevyruLE4amKTvC0j63xt64ewk3KaTfTAOnaZUaenfPkIIC1m8oSUd0k6uWXUz gbkl5bu8TdMXMoQq1w1snNPhNRkS9snukduvGUDaNYS02PgXZGBsqr2qFCS82DkASQhz dTcw== X-Gm-Message-State: AOPr4FWdWk0NadvA0q7gougPID3bSJi464I+oFHeddxj42IfpSg86D7l5sRLY3sv5hJgGymU 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 Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, stanimir.varbanov@linaro.org, Andy Gross 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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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);