From patchwork Fri Oct 25 07:11:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 3094411 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 B5D1E9F2B7 for ; Fri, 25 Oct 2013 07:12:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9E2820397 for ; Fri, 25 Oct 2013 07:11:59 +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 B644120336 for ; Fri, 25 Oct 2013 07:11:58 +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 1VZbYm-0007FU-0Q; Fri, 25 Oct 2013 07:11:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZbYj-0004U5-L4; Fri, 25 Oct 2013 07:11:49 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZbYg-0004Sw-0J for linux-arm-kernel@lists.infradead.org; Fri, 25 Oct 2013 07:11:46 +0000 Received: by mail-we0-f177.google.com with SMTP id x55so3351469wes.36 for ; Fri, 25 Oct 2013 00:11:15 -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=/DrzpXGVE3SpXhG4TQe4Ku2C54EGGY7FeMGb6cpgQtk=; b=hNjDDNEVm3xWSiURhMmw2MhbqH6uCHPiBRCe4siOYUmfSZ/VSKFTJV3NwjliGaOFyc urTEU7S9plRCssD9IW463LTzyzY7pfyBsX5Q8mwG6n9xYPIGCFnJ9wM8aJWWIg/QfVqc 5wvGItScyM3f/ntGnRWF8JUK9oB8k5ng6iS2pSPdtR3kxIPSzZ7Nez5jAjMU7r8TGIeS Ch9fYJAMc0e4amEeIKcILTj8/Y5v+UA7dNqCvIeXhrEjfA2WyqlTXhXfJkhdhqesB5bd +9gV/u74prirmr4W0Vt8aDUyMnfr37tS9+zTzWrRhLVmPvd10EcqFNtpltUrvoGWr35U I06w== X-Gm-Message-State: ALoCoQn8u+4BMoj1gSulUBD5QNltm1UgBvYpBtV4/8cpOJndoxdoHOWk2xGQrpFkuYAIt/VGMhrx X-Received: by 10.180.185.10 with SMTP id ey10mr1112498wic.29.1382685075612; Fri, 25 Oct 2013 00:11:15 -0700 (PDT) Received: from mai.home (AToulouse-654-1-445-47.w83-205.abo.wanadoo.fr. [83.205.196.47]) by mx.google.com with ESMTPSA id w10sm2897600wia.4.2013.10.25.00.11.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Oct 2013 00:11:14 -0700 (PDT) From: Daniel Lezcano To: ben-linux@fluff.org, kgene.kim@samsung.com Subject: [PATCH 1/2] ARM: s3c64xx: cpuidle: convert to platform driver Date: Fri, 25 Oct 2013 09:11:13 +0200 Message-Id: <1382685074-16502-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-20131025_031146_152573_D87FCD3D X-CRM114-Status: GOOD ( 22.44 ) X-Spam-Score: -2.6 (--) Cc: linux-samsung-soc@vger.kernel.org, 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.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 The driver is tied with the pm low level code making difficult to split the driver into a more arch independent code. The platform driver allows to move the standby callback into the platform data field and use a simple driver with no more dependency on the low level code. The standby callback has a portion of code to set the standby method and the effective cpu_do_idle switching the cpu to the right mode. As this code is redundant in the cpu suspend code, it has been factored out when implementing the standby methdod. By this way, the driver is ready to be moved out to the drivers/cpuidle. Signed-off-by: Daniel Lezcano --- arch/arm/mach-s3c64xx/cpuidle.c | 38 ++++++++++++++++---------------------- arch/arm/mach-s3c64xx/pm.c | 33 ++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c index 3c8ab07..8022f5f 100644 --- a/arch/arm/mach-s3c64xx/cpuidle.c +++ b/arch/arm/mach-s3c64xx/cpuidle.c @@ -9,33 +9,16 @@ * published by the Free Software Foundation. */ -#include -#include #include -#include -#include -#include +#include -#include - -#include - -#include "regs-sys.h" -#include "regs-syscon-power.h" +static void (*s3c64xx_standby)(void); static int s3c64xx_enter_idle(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - unsigned long tmp; - - /* Setup PWRCFG to enter idle mode */ - tmp = __raw_readl(S3C64XX_PWR_CFG); - tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK; - tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE; - __raw_writel(tmp, S3C64XX_PWR_CFG); - - cpu_do_idle(); + s3c64xx_standby(); return index; } @@ -56,8 +39,19 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = { .state_count = 1, }; -static int __init s3c64xx_init_cpuidle(void) +static int s3c64xx_cpuidle_probe(struct platform_device *dev) { + s3c64xx_standby = (void *)(dev->dev.platform_data); + return cpuidle_register(&s3c64xx_cpuidle_driver, NULL); } -device_initcall(s3c64xx_init_cpuidle); + +static struct platform_driver s3c64xx_driver_cpuidle = { + .driver = { + .name = "cpuidle-s3c64xx", + .owner = THIS_MODULE, + }, + .probe = s3c64xx_cpuidle_probe, +}; + +module_platform_driver(s3c64xx_driver_cpuidle); diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c index 6a1f91f..534fb4e 100644 --- a/arch/arm/mach-s3c64xx/pm.c +++ b/arch/arm/mach-s3c64xx/pm.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -259,6 +260,22 @@ void s3c_pm_save_core(void) s3c_pm_do_save(core_save, ARRAY_SIZE(core_save)); } +static void s3c64xx_set_standby(void) +{ + unsigned long tmp; + + tmp = __raw_readl(S3C64XX_PWR_CFG); + tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK; + tmp |= S3C64XX_PWRCFG_CFG_WFI_SLEEP; + __raw_writel(tmp, S3C64XX_PWR_CFG); +} + +static void s3c64xx_standby(void) +{ + s3c64xx_set_standby(); + cpu_do_idle(); +} + /* since both s3c6400 and s3c6410 share the same sleep pm calls, we * put the per-cpu code in here until any new cpu comes along and changes * this. @@ -269,11 +286,7 @@ static int s3c64xx_cpu_suspend(unsigned long arg) unsigned long tmp; /* set our standby method to sleep */ - - tmp = __raw_readl(S3C64XX_PWR_CFG); - tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK; - tmp |= S3C64XX_PWRCFG_CFG_WFI_SLEEP; - __raw_writel(tmp, S3C64XX_PWR_CFG); + s3c64xx_set_standby(); /* clear any old wakeup */ @@ -348,6 +361,13 @@ int __init s3c64xx_pm_init(void) return 0; } +static struct platform_device s3c64xx_cpuidle_device = { + .name = "cpuidle-s3c64xx", + .dev = { + .platform_data = s3c64xx_standby, + }, +}; + static __init int s3c64xx_pm_initcall(void) { pm_cpu_prep = s3c64xx_pm_prepare; @@ -364,8 +384,7 @@ static __init int s3c64xx_pm_initcall(void) gpio_direction_output(S3C64XX_GPN(14), 0); gpio_direction_output(S3C64XX_GPN(15), 0); #endif - - return 0; + return platform_device_register(&s3c64xx_cpuidle_device); } arch_initcall(s3c64xx_pm_initcall);