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: 9124111 Return-Path: X-Original-To: patchwork-linux-pm@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 E04C2BF29F 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 F096220221 for ; Thu, 19 May 2016 05:00:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 094E320218 for ; Thu, 19 May 2016 05:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750946AbcESFAl (ORCPT ); Thu, 19 May 2016 01:00:41 -0400 Received: from mail-oi0-f47.google.com ([209.85.218.47]:32987 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbcESFAj (ORCPT ); Thu, 19 May 2016 01:00:39 -0400 Received: by mail-oi0-f47.google.com with SMTP id v145so111080694oie.0 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=K9HpdfTmQijRZGZ/MYXOFM33cQqWOD9YdHy0fD0e/21dOD/1VIpFCO2eSdasTX/0XG UR6b0R7x02xgG3GpuO1ywdOyXwrugpPuBRFK2RB7jm50ZJLh84ifpfPZKCjzeuZC39ZA hxet6LVak2TIrtyKBYotiMM6OlsS0AQuJZOdT4qf50QTwzmJdL6WS+ikM3WRyimYw/Uh 6D4enfxK1vrvzZoGDcnIINbSeHJL1dXwXh1uhsvJyiXfDUWpuay5Q2taUKLPCubPGbb+ CCZb4Vq8UlTqpnVwBrZFNjRbWnFJOSzo+I4PMStpE03cH1E3fn0Wf82NNyuCB7KOlOqR HR9A== X-Gm-Message-State: AOPr4FUcOqjS2InXWYhc+2pnPSqgyKYiqeol+BEeGM5Qob4EH1b45/YoNJa5hdHHcBdO9qsh 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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=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);