From patchwork Tue Mar 18 10:20:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 26471 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BD348203C3 for ; Tue, 18 Mar 2014 10:19:22 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id i8sf16130253qcq.4 for ; Tue, 18 Mar 2014 03:19:22 -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=EED+IEPsxyNP94vQoi/FCTMYzHjyvB1c4stDRFxZYOo=; b=OdeR8rQlo131yTJ9fb6rhQ88yIdoFP2pvuEuT7SmXvRFhC7eT9ZJhnwBa7LAHhJDOA giT2VuVX1DUwK26wac/hCkERgvozx2LkRJbXMlv+Q0RyWFkFWH58af9uCvc8bVOyH0rS YFtVkePnzOcH1o4id3gJYWBIgnaXIcaaYyio3Wx4si0L5LtWxCtReewLfilq76Z0rGGI fo6XvMgYBzMiNxag1NjuW3/iID9K1QA6TdVaSiKbtsEGJbPY2T5T4a5p14odI9KwATxB PrHrI3VF2I4PiRvjlufYAt8kkdaxB60swZgKZt/DmdO+4dcf2foDgusvhfHISKcqjwsH 1qmg== X-Gm-Message-State: ALoCoQkNabGjLuiv8wEXin7WBUxWfRFdd5tinnpqYi98F/bToYOQxx39Es5oIqDd3ZwcAUDFrPJY X-Received: by 10.52.146.45 with SMTP id sz13mr10004367vdb.6.1395137962501; Tue, 18 Mar 2014 03:19:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.225 with SMTP id r88ls2023561qgr.2.gmail; Tue, 18 Mar 2014 03:19:22 -0700 (PDT) X-Received: by 10.220.99.72 with SMTP id t8mr24333262vcn.10.1395137962358; Tue, 18 Mar 2014 03:19:22 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id la9si1451863veb.38.2014.03.18.03.19.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 03:19:22 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id cz12so6611600veb.21 for ; Tue, 18 Mar 2014 03:19:22 -0700 (PDT) X-Received: by 10.59.7.170 with SMTP id dd10mr23750248ved.12.1395137962268; Tue, 18 Mar 2014 03:19:22 -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.220.78.9 with SMTP id i9csp193371vck; Tue, 18 Mar 2014 03:19:21 -0700 (PDT) X-Received: by 10.68.191.200 with SMTP id ha8mr31521614pbc.66.1395137961384; Tue, 18 Mar 2014 03:19:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yp10si12139647pab.134.2014.03.18.03.19.20; Tue, 18 Mar 2014 03:19:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754094AbaCRKTT (ORCPT + 11 others); Tue, 18 Mar 2014 06:19:19 -0400 Received: from service87.mimecast.com ([91.220.42.44]:54473 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753780AbaCRKTS (ORCPT ); Tue, 18 Mar 2014 06:19:18 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 18 Mar 2014 10:19:16 +0000 Received: from red-moon.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 18 Mar 2014 10:19:24 +0000 From: Lorenzo Pieralisi To: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: devicetree@vger.kernel.org, Lorenzo Pieralisi , 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 , Tomasz Figa Subject: [PATCH RFC 3/4] drivers: cpuidle: CPU idle ARM64 driver Date: Tue, 18 Mar 2014 10:20:27 +0000 Message-Id: <1395138028-19630-4-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1395138028-19630-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1395138028-19630-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 18 Mar 2014 10:19:24.0077 (UTC) FILETIME=[88DBDDD0:01CF4293] X-MC-Unique: 114031810191600801 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=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , This patch implements a generic CPU idle driver for ARM64 machines. It relies on the ARM idle states infrastructure to initialize idle states count and respective parameters. Current code assumes the driver is managing idle states on all possible CPUs but can be easily generalized to support heterogenous systems and build cpumasks at runtime using MIDRs or DT cpu nodes compatible properties. Signed-off-by: Lorenzo Pieralisi --- drivers/cpuidle/Kconfig | 5 +++++ drivers/cpuidle/Kconfig.arm64 | 13 +++++++++++++ drivers/cpuidle/Makefile | 4 ++++ drivers/cpuidle/cpuidle-arm64.c | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 drivers/cpuidle/Kconfig.arm64 create mode 100644 drivers/cpuidle/cpuidle-arm64.c diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index f04e25f..9b3f613 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -35,6 +35,11 @@ depends on ARM source "drivers/cpuidle/Kconfig.arm" endmenu +menu "ARM64 CPU Idle Drivers" +depends on ARM64 +source "drivers/cpuidle/Kconfig.arm64" +endmenu + menu "POWERPC CPU Idle Drivers" depends on PPC source "drivers/cpuidle/Kconfig.powerpc" diff --git a/drivers/cpuidle/Kconfig.arm64 b/drivers/cpuidle/Kconfig.arm64 new file mode 100644 index 0000000..42af83a --- /dev/null +++ b/drivers/cpuidle/Kconfig.arm64 @@ -0,0 +1,13 @@ +# +# ARM64 CPU Idle drivers +# + +config ARM64_CPUIDLE + bool "Generic ARM64 CPU idle Driver" + select ARM64_IDLE_STATES + help + Select this to enable generic cpuidle driver for ARM v8. + It provides a generic idle driver whose idle states are configured + at run-time through DT nodes. Idle protocol backends are initialized + by the device tree parsing code on matching the entry method for + the respective protocol. diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index f71ae1b..4051b37 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -15,6 +15,10 @@ obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o ############################################################################### +# ARM64 drivers +obj-$(CONFIG_ARM64_CPUIDLE) += cpuidle-arm64.o + +############################################################################### # POWERPC drivers obj-$(CONFIG_PSERIES_CPUIDLE) += cpuidle-pseries.o obj-$(CONFIG_POWERNV_CPUIDLE) += cpuidle-powernv.o diff --git a/drivers/cpuidle/cpuidle-arm64.c b/drivers/cpuidle/cpuidle-arm64.c new file mode 100644 index 0000000..08ffe16 --- /dev/null +++ b/drivers/cpuidle/cpuidle-arm64.c @@ -0,0 +1,41 @@ +/* + * ARM64 generic CPU idle driver. + * + * Copyright (C) 2014 ARM Ltd. + * Author: Lorenzo Pieralisi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include + +#include + +struct cpuidle_driver arm64_idle_driver = { + .name = "arm64_idle", + .owner = THIS_MODULE, +}; + +/* + * arm64_idle_init + * + * Registers the arm specific cpuidle driver with the cpuidle + * framework. It relies on core code to parse the idle states + * and initialize them in the driver accordingly. + */ +static int __init arm64_idle_init(void) +{ + int ret; + + arm64_idle_driver.cpumask = (struct cpumask *) cpu_possible_mask; + ret = arm_init_idle_driver(&arm64_idle_driver); + if (ret) + return ret; + return cpuidle_register(&arm64_idle_driver, NULL); +} +device_initcall(arm64_idle_init);