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: 3094391 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20190BF924 for ; Fri, 25 Oct 2013 07:11:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E28A20397 for ; Fri, 25 Oct 2013 07:11:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03DD620336 for ; Fri, 25 Oct 2013 07:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457Ab3JYHLR (ORCPT ); Fri, 25 Oct 2013 03:11:17 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35773 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182Ab3JYHLQ (ORCPT ); Fri, 25 Oct 2013 03:11:16 -0400 Received: by mail-wi0-f172.google.com with SMTP id ez12so606093wid.17 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=U+H5Ps/N8NpejWOeAsN0nnQ9CobqksnDt3vTzJPK0+/ku3FWe6EqcvEAwsgYo1VNCg 35RKj1bkrTJf+ddenFU6yEqpzZD93IdaVzWZUk40fF75yDJvE/btQOZaAm9u1F+6LuPI R2d3LZk6L56kcvZKjJV0dJSSciDMV8+JEZZxqZQkEB8YNd9b5YIh9YKlSUpmZOK+SRub xi98jkhAYMsEELkvdpBJbMyqiEksy3V5cSIBh0BTL9qOa8TSqgpX4lHQxFuOPTR7qUaw VnTXP8q2LOgBz8fv7NEIA5VxVqFFKb6lfUwP6+WfiiawoJqkyL+XWXVoDz5IYDkZXDLV w6bQ== X-Gm-Message-State: ALoCoQlXrFgTWeDvt1gBtQOCJp4E1seTB+P98LQYWlyUI0/VZflqaHY59cr/vayoNa/DIpwAMN+4 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 Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org 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 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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);