From patchwork Mon Oct 28 16:49:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 3103361 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 2AF1E9F2B7 for ; Mon, 28 Oct 2013 16:50:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F091202EC for ; Mon, 28 Oct 2013 16:50:43 +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 C443E202EB for ; Mon, 28 Oct 2013 16:50:41 +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 1Vaq1C-0003Zk-V0; Mon, 28 Oct 2013 16:50:19 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vaq16-0002je-9R; Mon, 28 Oct 2013 16:50:12 +0000 Received: from mail-ob0-f173.google.com ([209.85.214.173]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vaq0s-0002fM-LI for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2013 16:49:59 +0000 Received: by mail-ob0-f173.google.com with SMTP id gq1so3889046obb.18 for ; Mon, 28 Oct 2013 09:49:37 -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; bh=legZU9XfVWfHJ7wYVDJBHTBB/2VqG0uiPOHhm7+8ktI=; b=hKvxWRmg1u66jJxjVtkk9MufoVTSDyj/HsNd8UDuup5lCRx1iYU0xiNuS8rqpLt+hg hQcdO7aiRif1IUis4jqU7JJF9/qcILnsdCV0La3gGC6k+RzU0sZ8v24ziMYvZRYVukvK O27IsEiq/bQfrLXzFt5MVekSoK1XzvpgSj68Afpix3kDv7o/AdQfI44GQr9O9lM0yL1G LKGNvuLrAp4F5hN9A1rr9EV864gk97/0CmO4yKzWAWFopo0oytETb0yTJzik3nciqpEu hAM1+dmUALQT4UNW7g07eq4INujU8rZhgh/PGnTP9atZPmInIt88wf9Vzae47sCBMQr7 pw/g== X-Gm-Message-State: ALoCoQnmlHHRLSuHgVHom4zz0iFjmlKF39b/RiwBfuoK2DmZ/+WwdnQnKqybUW+gH9h+IyohHK+y X-Received: by 10.182.34.194 with SMTP id b2mr15362980obj.41.1382978975321; Mon, 28 Oct 2013 09:49:35 -0700 (PDT) Received: from localhost.localdomain (sccc-66-78-236-243.smartcity.com. [66.78.236.243]) by mx.google.com with ESMTPSA id nw5sm27719940obc.9.2013.10.28.09.49.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Oct 2013 09:49:34 -0700 (PDT) From: Daniel Lezcano To: kernel@pengutronix.de Subject: [RFC PATCH 1/3] ARM: imx: cpuidle: Convert imx5 driver to platform driver Date: Mon, 28 Oct 2013 09:49:31 -0700 Message-Id: <1382978973-4034-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131028_124958_916577_6CEA0728 X-CRM114-Status: GOOD ( 18.18 ) X-Spam-Score: -2.6 (--) Cc: linux-arm-kernel@lists.infradead.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=-4.7 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 The PM low level code is tied and called from the cpuidle driver. The platform driver approach allows to split the pm code and the cpuidle driver, hence keeping the code encapsulated inside the pm code. The idle method called through the arm_pm_idle is changed by a callback in the cpuidle driver, assigned at init time from the platform_data field of the platform device passed in the probe function. Signed-off-by: Daniel Lezcano --- arch/arm/mach-imx/cpuidle-imx5.c | 20 +++++++++++++++++--- arch/arm/mach-imx/cpuidle.h | 5 ----- arch/arm/mach-imx/pm-imx5.c | 11 +++++++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c index 5a47e3c..2d49846 100644 --- a/arch/arm/mach-imx/cpuidle-imx5.c +++ b/arch/arm/mach-imx/cpuidle-imx5.c @@ -8,12 +8,14 @@ #include #include -#include +#include + +static void (*imx5_idle)(void); static int imx5_cpuidle_enter(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - arm_pm_idle(); + imx5_idle(); return index; } @@ -31,7 +33,19 @@ static struct cpuidle_driver imx5_cpuidle_driver = { .state_count = 1, }; -int __init imx5_cpuidle_init(void) +static int imx5_cpuidle_probe(struct platform_device *dev) { + imx5_idle = dev->dev.platform_data; + return cpuidle_register(&imx5_cpuidle_driver, NULL); } + +static struct platform_driver imx5_driver_cpuidle = { + .driver = { + .name = "cpuidle-imx5", + .owner = THIS_MODULE, + }, + .probe = imx5_cpuidle_probe, +}; + +module_platform_driver(imx5_driver_cpuidle); diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h index 786f98e..9e93ea0 100644 --- a/arch/arm/mach-imx/cpuidle.h +++ b/arch/arm/mach-imx/cpuidle.h @@ -11,13 +11,8 @@ */ #ifdef CONFIG_CPU_IDLE -extern int imx5_cpuidle_init(void); extern int imx6q_cpuidle_init(void); #else -static inline int imx5_cpuidle_init(void) -{ - return 0; -} static inline int imx6q_cpuidle_init(void) { return 0; diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c index 58aeaf5..9eeef85 100644 --- a/arch/arm/mach-imx/pm-imx5.c +++ b/arch/arm/mach-imx/pm-imx5.c @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include "common.h" -#include "cpuidle.h" #include "crm-regs-imx5.h" #include "hardware.h" @@ -149,6 +149,13 @@ static void imx5_pm_idle(void) imx5_cpu_do_idle(); } +static struct platform_device imx5_cpuidle_pdev = { + .name = "cpuidle-imx5", + .dev = { + .platform_data = imx5_pm_idle, + }, +}; + static int __init imx5_pm_common_init(void) { int ret; @@ -166,7 +173,7 @@ static int __init imx5_pm_common_init(void) /* Set the registers to the default cpu idle state. */ mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE); - return imx5_cpuidle_init(); + return platform_device_register(&imx5_cpuidle_pdev); } void __init imx5_pm_init(void)