From patchwork Mon Jul 21 16:06:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 33996 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B30DE20492 for ; Mon, 21 Jul 2014 16:07:01 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf56748245pab.5 for ; Mon, 21 Jul 2014 09:07:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=Jqmeq8yddw2lFiwhEkkIDyFAR9FkFdWcCjGDlOizhzI=; b=lG3H1eGymH85S4u++K8oCUtsA0SiqVTu8jnmPKu4VZqg6UAqRJxhZYKlKP4YGaBfmJ l5JzdXUoQbIv91HMVZHLDSzUzW0+mDdF2/Ke/Xn+WR1aQVBRhiWWWxOoBr5LcHQYsEo2 Lt0KNOpoEpXmMZOVjUeHVi5Mt0ElM186/KoyADJfD5IHxOkHujMUaAMWM/kV+0eETZ++ Xt5oM/L4EaxiwjOVGNdTJnDwfX7LFCKLmQmaa05JtZvesWFwZ0mtAi1cDrsk40wakybc C2UTGMJ9EX2ZE7a3Q77eC63nDlYSjm5jd+E8GNfbRa0Z9fCcNx0MZyq4B4HVqVvdRZr+ xwGA== X-Gm-Message-State: ALoCoQmwMYq5kOcqoNi+ZPI1RUN8cI5J2YN7ZfMZ4DZrCLcPC5IB/ZCHku95IwN7gr7GsXNs9jUs X-Received: by 10.68.222.194 with SMTP id qo2mr7757988pbc.6.1405958820487; Mon, 21 Jul 2014 09:07:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.37 with SMTP id q34ls2073066qgd.5.gmail; Mon, 21 Jul 2014 09:07:00 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr30615328vck.29.1405958820292; Mon, 21 Jul 2014 09:07:00 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ta7si11696145vdc.37.2014.07.21.09.06.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 09:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so12604185vcb.9 for ; Mon, 21 Jul 2014 09:06:59 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr2890165vdb.86.1405958819283; Mon, 21 Jul 2014 09:06:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp124840vcb; Mon, 21 Jul 2014 09:06:58 -0700 (PDT) X-Received: by 10.66.182.69 with SMTP id ec5mr4730295pac.125.1405958818173; Mon, 21 Jul 2014 09:06:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qe5si14693995pac.103.2014.07.21.09.06.57; Mon, 21 Jul 2014 09:06:57 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932887AbaGUQGt (ORCPT + 15 others); Mon, 21 Jul 2014 12:06:49 -0400 Received: from service87.mimecast.com ([91.220.42.44]:42271 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932793AbaGUQGt (ORCPT ); Mon, 21 Jul 2014 12:06:49 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 21 Jul 2014 17:06:44 +0100 Received: from red-moon.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 21 Jul 2014 17:06:42 +0100 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: devicetree@vger.kernel.org, Lorenzo Pieralisi , Chander Kashyap , Kukjin Kim , Tomasz Figa , Mark Rutland , Sudeep Holla , Catalin Marinas , Charles Garcia Tobin , Nicolas Pitre , Rob Herring , Grant Likely , Peter De Schrijver , Santosh Shilimkar , Daniel Lezcano , Amit Kucheria , Vincent Guittot , Antti Miettinen , Stephen Boyd , Kevin Hilman , Sebastian Capella , Mark Brown , Paul Walmsley , Geoff Levand , Bartlomiej Zolnierkiewicz Subject: [PATCH v6 7/7] drivers: cpuidle: initialize Exynos driver through DT Date: Mon, 21 Jul 2014 17:06:26 +0100 Message-Id: <1405958786-17243-8-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405958786-17243-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1405958786-17243-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 21 Jul 2014 16:06:42.0555 (UTC) FILETIME=[C33204B0:01CFA4FD] X-MC-Unique: 114072117064414101 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lorenzo.pieralisi@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , With the introduction of DT based idle states, CPUidle drivers for ARM can now initialize idle states data through properties in the device tree. This patch adds code to the Exynos CPUidle driver to dynamically initialize idle states data through the updated device tree source files. Cc: Chander Kashyap Cc: Kukjin Kim Cc: Tomasz Figa Signed-off-by: Lorenzo Pieralisi --- arch/arm/boot/dts/exynos4210.dtsi | 11 +++++++++++ arch/arm/boot/dts/exynos5250.dtsi | 11 +++++++++++ drivers/cpuidle/Kconfig.arm | 1 + drivers/cpuidle/cpuidle-exynos.c | 37 ++++++++++++++++++++++++------------- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi index bc2b444..0270100 100644 --- a/arch/arm/boot/dts/exynos4210.dtsi +++ b/arch/arm/boot/dts/exynos4210.dtsi @@ -39,12 +39,23 @@ device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0x900>; + cpu-idle-states = <&CLUSTER_SLEEP_0>; }; cpu@901 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0x901>; + cpu-idle-states = <&CLUSTER_SLEEP_0>; + }; + + idle-states { + CLUSTER_SLEEP_0: cluster-sleep-0 { + compatible = "arm,idle-state"; + entry-latency-us = <1000>; + exit-latency-us = <300>; + min-residency-us = <100000>; + }; }; }; diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index 834fb5a..631906e 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -63,12 +63,23 @@ compatible = "arm,cortex-a15"; reg = <0>; clock-frequency = <1700000000>; + cpu-idle-states = <&CLUSTER_SLEEP_0>; }; cpu@1 { device_type = "cpu"; compatible = "arm,cortex-a15"; reg = <1>; clock-frequency = <1700000000>; + cpu-idle-states = <&CLUSTER_SLEEP_0>; + }; + + idle-states { + CLUSTER_SLEEP_0: cluster-sleep-0 { + compatible = "arm,idle-state"; + entry-latency-us = <1000>; + exit-latency-us = <300>; + min-residency-us = <100000>; + }; }; }; diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm index a9b089c..d8a9cd2 100644 --- a/drivers/cpuidle/Kconfig.arm +++ b/drivers/cpuidle/Kconfig.arm @@ -60,5 +60,6 @@ config ARM_AT91_CPUIDLE config ARM_EXYNOS_CPUIDLE bool "Cpu Idle Driver for the Exynos processors" depends on ARCH_EXYNOS + select DT_IDLE_STATES help Select this to enable cpuidle for Exynos processors diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c index 7c01512..097c21d 100644 --- a/drivers/cpuidle/cpuidle-exynos.c +++ b/drivers/cpuidle/cpuidle-exynos.c @@ -13,11 +13,14 @@ #include #include #include +#include #include #include #include +#include "dt_idle_states.h" + static void (*exynos_enter_aftr)(void); static int idle_finisher(unsigned long flags) @@ -60,32 +63,40 @@ static struct cpuidle_driver exynos_idle_driver = { .owner = THIS_MODULE, .states = { [0] = ARM_CPUIDLE_WFI_STATE, - [1] = { - .enter = exynos_enter_lowpower, - .exit_latency = 300, - .target_residency = 100000, - .flags = CPUIDLE_FLAG_TIME_VALID, - .name = "C1", - .desc = "ARM power down", - }, }, - .state_count = 2, - .safe_state_index = 0, }; static int exynos_cpuidle_probe(struct platform_device *pdev) { - int ret; + int ret, i; + struct cpuidle_driver *drv = &exynos_idle_driver; exynos_enter_aftr = (void *)(pdev->dev.platform_data); - ret = cpuidle_register(&exynos_idle_driver, NULL); + drv->cpumask = kzalloc(cpumask_size(), GFP_KERNEL); + if (!drv->cpumask) + return -ENOMEM; + + /* Start at index 1, index 0 standard WFI */ + ret = dt_init_idle_driver(drv, 1); + if (ret) { + dev_err(&pdev->dev, "failed to initialize idle states\n"); + goto free_mem; + } + + for (i = 1; i < drv->state_count; i++) + drv->states[i].enter = exynos_enter_lowpower; + + ret = cpuidle_register(drv, NULL); if (ret) { dev_err(&pdev->dev, "failed to register cpuidle driver\n"); - return ret; + goto free_mem; } return 0; +free_mem: + kfree(drv->cpumask); + return ret; } static struct platform_driver exynos_cpuidle_driver = {