From patchwork Thu Sep 26 16:06:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2949511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECA3D9F288 for ; Thu, 26 Sep 2013 16:07:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEE3E202C3 for ; Thu, 26 Sep 2013 16:07:34 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C94C20328 for ; Thu, 26 Sep 2013 16:07:27 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VPE5m-0007Li-6o; Thu, 26 Sep 2013 16:07:02 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VPE5g-0003UK-Hc; Thu, 26 Sep 2013 16:06:56 +0000 Received: from mail-we0-f172.google.com ([74.125.82.172]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VPE5U-0003Rp-Eo for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2013 16:06:45 +0000 Received: by mail-we0-f172.google.com with SMTP id w61so1406027wes.31 for ; Thu, 26 Sep 2013 09:06: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5VQUULRSfZ9WbTki1LoiEkxGRDJxTUPKGW5nR/rraHM=; b=J/tfZlpOL6Ms08io2zpN+5Au41lbJS97Q8ulFrTRhglpUHnl8XVl0SlHRprlViy6pJ jeHRGhgxdSXRrUx/IIY2oOQJxKoQ1PemuR02JrszBU4M74fuU2tWXd4vRz+oN+bdw2gY MzrFHuKqEkb6By3L7hyDcwkn7J+1HWowRd2D0w8rHULwHsRKbmZCUkW5TCOsMW/3L4tG w6Fl9ErUq6P9Sc5+JTrMvbYZiqtBpuFdnb7hY9ZUaFA4hbi+PeLXgq++lmYaYosqA2NQ xZZOAydaUNB7rvbjHw4Wsu9Gq5xzdeIRE9F9KfLfCe7AzLOxyIv9nwwGePTc0RrcGof4 SY1A== X-Gm-Message-State: ALoCoQmR9INkmHhob3wRLljYi73Ipw8WkHl0FEdT/nOBXfa9iOaJ95CsFtjsTK6P0Gi3grUocUug X-Received: by 10.180.187.175 with SMTP id ft15mr1549820wic.20.1380211582503; Thu, 26 Sep 2013 09:06:22 -0700 (PDT) Received: from mai.home (AToulouse-654-1-326-179.w86-199.abo.wanadoo.fr. [86.199.213.179]) by mx.google.com with ESMTPSA id eg1sm1115636wib.11.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 09:06:20 -0700 (PDT) From: Daniel Lezcano To: linux@maxim.org.za, nicolas.ferre@atmel.com, plagnioj@jcrosoft.com Subject: [RFC PATCH 1/2] ARM: at91: cpuidle: convert to platform driver Date: Thu, 26 Sep 2013 18:06:06 +0200 Message-Id: <1380211567-2972-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380211567-2972-1-git-send-email-daniel.lezcano@linaro.org> References: <1380211567-2972-1-git-send-email-daniel.lezcano@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130926_120644_605802_8383AA5E X-CRM114-Status: GOOD ( 17.09 ) X-Spam-Score: -2.6 (--) Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Using the platform driver model is a good way to separate the cpuidle specific code from the low level pm code. It allows to remove the dependency between these two components. Signed-off-by: Daniel Lezcano --- arch/arm/mach-at91/cpuidle.c | 29 +++++++++++++++-------------- arch/arm/mach-at91/pm.c | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c index 4ec6a6d..6cdc76d 100644 --- a/arch/arm/mach-at91/cpuidle.c +++ b/arch/arm/mach-at91/cpuidle.c @@ -21,26 +21,17 @@ #include #include #include -#include - -#include "pm.h" #define AT91_MAX_STATES 2 +static void (*at91_standby)(void); + /* Actual code that puts the SoC in different idle states */ static int at91_enter_idle(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - if (cpu_is_at91rm9200()) - at91rm9200_standby(); - else if (cpu_is_at91sam9g45()) - at91sam9g45_standby(); - else if (cpu_is_at91sam9263()) - at91sam9263_standby(); - else - at91sam9_standby(); - + at91_standby(); return index; } @@ -60,9 +51,19 @@ static struct cpuidle_driver at91_idle_driver = { }; /* Initialize CPU idle by registering the idle states */ -static int __init at91_init_cpuidle(void) +static int __init at91_cpuidle_probe(struct platform_device *dev) { + at91_standby = (void *)(dev->dev.platform_data); + return cpuidle_register(&at91_idle_driver, NULL); } -device_initcall(at91_init_cpuidle); +static struct platform_driver at91_cpuidle_driver = { + .driver = { + .name = "cpuidle-at91", + .owner = THIS_MODULE, + }, + .probe = at91_cpuidle_probe, +}; + +module_platform_driver(at91_cpuidle_driver); diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 15afb5d..debdbf8 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -314,6 +314,10 @@ static const struct platform_suspend_ops at91_pm_ops = { .end = at91_pm_end, }; +static struct platform_device at91_cpuidle_device = { + .name = "cpuidle-at91", +}; + static int __init at91_pm_init(void) { #ifdef CONFIG_AT91_SLOW_CLOCK @@ -323,8 +327,18 @@ static int __init at91_pm_init(void) pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : "")); /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ - if (cpu_is_at91rm9200()) + if (cpu_is_at91rm9200()) { + at91_cpuidle_device.dev.platform_data = at91rm9200_standby; at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); + } else if (cpu_is_at91sam9g45()) { + at91_cpuidle_device.dev.platform_data = at91sam9g45_standby; + } else if (cpu_is_at91sam9263()) { + at91_cpuidle_device.dev.platform_data = at91sam9263_standby; + } else { + at91_cpuidle_device.dev.platform_data = at91sam9_standby; + } + + platform_device_register(&at91_cpuidle_device); suspend_set_ops(&at91_pm_ops);