From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Lina Iyer <lina.iyer@linaro.org>,
khilman@linaro.org, amit.kucheria@linaro.org,
sboyd@codeaurora.org, davidb@codeaurora.org,
galak@codeaurora.org, linux-arm-msm@vger.kernel.org
Cc: msivasub@codeaurora.org, Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>
Subject: Re: [PATCH v2 08/10] qcom: cpuidle: Add cpuidle driver for QCOM cpus
Date: Wed, 13 Aug 2014 13:22:09 +0200 [thread overview]
Message-ID: <53EB4A61.2040609@linaro.org> (raw)
In-Reply-To: <1407872640-6732-9-git-send-email-lina.iyer@linaro.org>
On 08/12/2014 09:43 PM, Lina Iyer wrote:
> Add cpuidle driver interface to allow cpus to go into C-States.
>
> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
Hi Lina,
I think you should based this driver on top of Lorenzo's work.
Cc Lorenzo.
> ---
> .../devicetree/bindings/arm/msm/qcom,cpuidle.txt | 73 +++++++++++
> drivers/cpuidle/Makefile | 1 +
> drivers/cpuidle/cpuidle-qcom.c | 140 +++++++++++++++++++++
> 3 files changed, 214 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,cpuidle.txt
> create mode 100644 drivers/cpuidle/cpuidle-qcom.c
>
> diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,cpuidle.txt b/Documentation/devicetree/bindings/arm/msm/qcom,cpuidle.txt
> new file mode 100644
> index 0000000..b094baf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/msm/qcom,cpuidle.txt
> @@ -0,0 +1,73 @@
> +Qualcomm CPUIdle driver
> +
> +The Qualcomm cpuidle driver enables the processor to enter low power modes
> +when idle. The processors support 4 low power modes.
> + wfi - also known as clock gating
> + retention - processor clock gated and processor power is reduced.
> + standalone-pc - processor is powered down and when reset, the core
> + boots into secure mode and trampolines back to the kernel.
> + Every core can individually enter this low power mode without
> + affecting the state of the other cores.
> + pc - essentially standalone power collapse, but indicates that the
> + latency to put SoC into a low power state is tolerable.
> +
> +The cpuidle node is comprised of nodes, each of which represent a C-State the
> +processor can achieve. Each node provides the latency and residency which
> +helps the cpuidle governor to choose the appropriate low power mode based on
> +the time available. Not all SoCs may support all the above low power modes.
> +
> +PROPERTIES
> +
> +- compatible:
> + Usage: required
> + Value type: <string>
> + Definition: Should be "qcom,cpuidle"
> +
> +- qcom,cpu-level:
> + Usage: required
> + Value type: { Node }
> + Definition: Describes a C-State of the processor
> +
> + PROPERTIES of qcom,cpu-level
> +
> + - reg:
> + Usage: required
> + Value type: <integer>
> + Definition: Index of the C-State
> +
> + - qcom,state-name:
> + Usage: required
> + Value type: <string>
> + Definition: C-State moniker
> +
> + - qcom,spm-cpu-mode:
> + Usage: required
> + Value type: <string>
> + Definition: The description of the h/w mode that will be
> + achieved in this C-State.
> +
> + - qcom,latency-us:
> + Usage: required
> + Value type: <integer>
> + Defintion: Time taken to exit from the C-State
> +
> + - qcom,residency-us:
> + Usage: required
> + Value type: <integer>
> + Defintion: Time to be spent in this C-State for the power
> + saving to be beneficial.
> +
> +Example:
> +
> + qcom,cpuidle {
> + compatible = "qcom,cpuidle";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + qcom,cpu-level@0 {
> + reg = <0x0>;
> + qcom,state-name = "C1";
> + qcom,spm-cpu-mode = "wfi";
> + qcom,latency-us = <1>;
> + qcom,residency-us = <1>;
> + };
> + };
> diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
> index 11edb31..4a2c446 100644
> --- a/drivers/cpuidle/Makefile
> +++ b/drivers/cpuidle/Makefile
> @@ -16,6 +16,7 @@ obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
> obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
> obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o
> obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o
> +obj-$(CONFIG_ARM_QCOM_CPUIDLE) += cpuidle-qcom.o
>
> ###############################################################################
> # MIPS drivers
> diff --git a/drivers/cpuidle/cpuidle-qcom.c b/drivers/cpuidle/cpuidle-qcom.c
> new file mode 100644
> index 0000000..8e70a88
> --- /dev/null
> +++ b/drivers/cpuidle/cpuidle-qcom.c
> @@ -0,0 +1,140 @@
> +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2014 Linaro.
> + *
> + * 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/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/cpuidle.h>
> +
> +#include <soc/qcom/pm.h>
> +
> +struct lookup {
> + enum msm_pm_sleep_mode mode;
> + char *name;
> +};
> +
> +static enum msm_pm_sleep_mode spm_sleep_modes[MSM_PM_SLEEP_MODE_NR];
> +
> +static int qcom_lpm_enter(struct cpuidle_device *dev,
> + struct cpuidle_driver *drv,
> + int index)
> +{
> + return msm_cpu_pm_enter_sleep(spm_sleep_modes[index], true);
> +}
> +
> +static struct cpuidle_driver qcom_cpuidle_driver = {
> + .name = "qcom_cpuidle",
> + .owner = THIS_MODULE,
> +};
> +
> +static int qcom_cpuidle_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct device_node *top = pdev->dev.of_node;
> + struct device_node *n;
> + char *key;
> + const char *val;
> + int index = 0;
> + int i;
> + struct cpuidle_state *state;
> + static const struct lookup pm_sm_lookup[] = {
> + {MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
> + "wfi"},
> + {MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
> + "standalone_pc"},
> + {MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
> + "pc"},
> + {MSM_PM_SLEEP_MODE_RETENTION,
> + "retention"},
> + };
> +
> + if (!top)
> + return -ENODEV;
> +
> + for_each_child_of_node(top, n) {
> + key = "qcom,cpu-level";
> + if (of_node_cmp(n->name, key))
> + continue;
> +
> + state = &qcom_cpuidle_driver.states[index];
> +
> + key = "qcom,spm-cpu-mode";
> + ret = of_property_read_string(n, key, &val);
> + if (ret)
> + goto failed;
> + for (i = 0; i < ARRAY_SIZE(pm_sm_lookup); i++) {
> + if (!strcmp(val, pm_sm_lookup[i].name)) {
> + spm_sleep_modes[index] = pm_sm_lookup[i].mode;
> + break;
> + }
> + }
> + if (i == ARRAY_SIZE(pm_sm_lookup)) {
> + ret = -EFAULT;
> + goto failed;
> + }
> +
> + strncpy(state->desc, val, CPUIDLE_DESC_LEN);
> +
> + key = "qcom,state-name";
> + ret = of_property_read_string(n, key, &val);
> + if (ret)
> + goto failed;
> + strncpy(state->name, val, CPUIDLE_NAME_LEN);
> +
> + key = "qcom,latency-us";
> + ret = of_property_read_u32(n, key, &state->exit_latency);
> + if (ret)
> + goto failed;
> +
> + key = "qcom,residency-us";
> + ret = of_property_read_u32(n, key, &state->target_residency);
> + if (ret)
> + goto failed;
> +
> + state->flags = CPUIDLE_FLAG_TIME_VALID;
> + state->enter = qcom_lpm_enter;
> + index++;
> + }
> +
> + qcom_cpuidle_driver.state_count = index;
> + qcom_cpuidle_driver.safe_state_index = 0;
> +
> + ret = cpuidle_register(&qcom_cpuidle_driver, NULL);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to register cpuidle driver\n");
> + return ret;
> + }
> +
> + return 0;
> +
> +failed:
> + dev_err(&pdev->dev, "error parsing key: %s\n", key);
> + return ret;
> +}
> +
> +static struct of_device_id qcom_cpuidle_match_tbl[] = {
> + {.compatible = "qcom,cpuidle"},
> + {},
> +};
> +
> +static struct platform_driver qcom_cpuidle_platform_driver = {
> + .probe = qcom_cpuidle_probe,
> + .driver = {
> + .name = "qcom,cpuidle",
> + .owner = THIS_MODULE,
> + .of_match_table = qcom_cpuidle_match_tbl,
> + },
> +};
> +
> +module_platform_driver(qcom_cpuidle_platform_driver);
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2014-08-13 11:22 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-12 19:43 [PATCH v2 00/10] QCOM 8074 cpuidle driver Lina Iyer
2014-08-12 19:43 ` [PATCH v2 01/10] msm: scm: Move scm-boot files to drivers/soc and include/soc Lina Iyer
2014-08-12 19:43 ` [PATCH v2 02/10] msm: scm: Add SCM warmboot flags for quad core targets Lina Iyer
2014-08-14 10:20 ` Pramod Gurav
2014-08-12 19:43 ` [PATCH v2 03/10] qcom: spm: Add Subsystem Power Manager (SPM) driver for QCOM chipsets Lina Iyer
2014-08-13 10:49 ` Daniel Lezcano
2014-08-13 14:00 ` Lina Iyer
2014-08-14 13:01 ` Pramod Gurav
2014-08-14 15:18 ` Lina Iyer
2014-08-14 15:16 ` Kumar Gala
2014-08-14 15:27 ` Lina Iyer
2014-08-14 15:33 ` Kumar Gala
2014-08-14 16:09 ` Kumar Gala
2014-08-14 16:18 ` Lina Iyer
2014-08-14 16:41 ` Kumar Gala
2014-08-15 4:18 ` Lina Iyer
2014-08-15 13:42 ` Kumar Gala
2014-08-16 3:41 ` Lina Iyer
2014-08-12 19:43 ` [PATCH v2 04/10] soc: qcom: Add QCOM Power management config Lina Iyer
2014-08-13 9:36 ` Daniel Lezcano
2014-08-12 19:43 ` [PATCH v2 05/10] arm: qcom-msm8974: Add CPU phandles to CPU definitions Lina Iyer
2014-08-12 21:09 ` Kumar Gala
2014-08-14 10:04 ` Pramod Gurav
2014-08-12 19:43 ` [PATCH v2 06/10] arm: dts: qcom: Add SPM device bindings for 8974 Lina Iyer
2014-08-12 21:10 ` Kumar Gala
2014-08-12 21:32 ` Lina Iyer
2014-08-13 7:39 ` Ivan T. Ivanov
2014-08-12 19:43 ` [PATCH v2 07/10] qcom: msm-pm: Add cpu low power mode functions Lina Iyer
2014-08-13 11:18 ` Daniel Lezcano
2014-08-13 14:16 ` Lina Iyer
2014-08-14 14:24 ` Daniel Lezcano
2014-08-14 14:53 ` Lina Iyer
2014-08-14 16:11 ` Daniel Lezcano
2014-08-14 19:22 ` Lina Iyer
2014-08-15 0:01 ` Daniel Lezcano
2014-08-15 1:02 ` Lina Iyer
2014-08-14 13:38 ` Pramod Gurav
2014-08-14 14:43 ` Lina Iyer
2014-08-12 19:43 ` [PATCH v2 08/10] qcom: cpuidle: Add cpuidle driver for QCOM cpus Lina Iyer
2014-08-13 11:22 ` Daniel Lezcano [this message]
2014-08-13 14:03 ` Lina Iyer
2014-08-12 19:43 ` [PATCH v2 09/10] qcom: cpuidle: Config option to enable QCOM cpuidle driver Lina Iyer
2014-08-13 11:18 ` Daniel Lezcano
2014-08-12 19:44 ` [PATCH v2 10/10] qcom: cpuidle: Add cpuidle device nodes for 8974 chipset Lina Iyer
2014-08-13 1:52 ` [PATCH v2 00/10] QCOM 8074 cpuidle driver Stephen Boyd
2014-08-13 2:17 ` Lina Iyer
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=53EB4A61.2040609@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=amit.kucheria@linaro.org \
--cc=davidb@codeaurora.org \
--cc=galak@codeaurora.org \
--cc=khilman@linaro.org \
--cc=lina.iyer@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=msivasub@codeaurora.org \
--cc=sboyd@codeaurora.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).