From patchwork Wed Jun 26 10:15:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 2787431 Return-Path: X-Original-To: patchwork-linux-arm@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 B6051C0AB1 for ; Wed, 26 Jun 2013 17:09:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C188205E6 for ; Wed, 26 Jun 2013 17:09:47 +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 76ABC205E4 for ; Wed, 26 Jun 2013 17:09:44 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Urt9C-0006YE-1Z; Wed, 26 Jun 2013 17:04:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Urt3K-0000rz-UK; Wed, 26 Jun 2013 16:58:42 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Urs7N-00037P-Jp for linux-arm-kernel@merlin.infradead.org; Wed, 26 Jun 2013 15:58:49 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Urmmf-0005y7-UJ for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2013 10:17:07 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MOZ00I4MWJC8BZ0@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2013 19:16:26 +0900 (KST) X-AuditID: cbfee61a-b7f3b6d000006edd-d5-51cabf7a9a8c Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D4.FD.28381.A7FBAC15; Wed, 26 Jun 2013 19:16:26 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MOZ008XEWIOKP80@mmp2.samsung.com>; Wed, 26 Jun 2013 19:16:25 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/8] ARM: davinci: move cpuidle driver to drivers/cpuidle/ Date: Wed, 26 Jun 2013 12:15:41 +0200 Message-id: <1372241747-21083-3-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1372241747-21083-1-git-send-email-b.zolnierkie@samsung.com> References: <1372241747-21083-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeLIzCtJLcpLzFFi42I5/e+xoG7V/lOBBtc/ylpsnLGe1WLSugNM FvM+y1o0b/3KaLFq6k4Wi94FV9ks7qxgtjjb9IbdYsqf5UwWmx5fY7X43HuE0WL5iqfMFg9W v2Wz+Ha5md1if+8GJot1D18wWfQv7GWyeLpuCbPFrS1NbBavDraxWOy/4uUg6rHg11YWj29f J7F4XH/1n8nj76oXzB47Z91l93h14Q6Lx51re9g8Ni+p95h4exqLR/9fA4++LasYPR4tbmH0 +L50DbvH8RvbmTzm/PzG4vF5k1yAYBSXTUpqTmZZapG+XQJXxsMnD5kKJlpVTF59j7GBcZFB FyMnh4SAicSmeYtZIWwxiQv31rN1MXJxCAlMZ5Q4dWciE4TTxSSx6WkrG0gVm4CVxMT2VYwg toiAhsSUrsfsIDazwD1miX0fc0FsYQEvidN9fSwgNouAqkT/r8lgG3gFPCQe/L7BBLFNXuLp /T6wmZwCnhJzZy4Fs4WAapauXco4gZF3ASPDKkbR1ILkguKk9FxDveLE3OLSvHS95PzcTYzg OHomtYNxZYPFIUYBDkYlHl6FrScDhVgTy4orcw8xSnAwK4nwvpl/KlCINyWxsiq1KD++qDQn tfgQozQHi5I474FW60AhgfTEktTs1NSC1CKYLBMHp1QDo+N/38C0oCA2RZZd3ZZhBVIlTXcu McXvY31zc9363iuvN/9KZfu63OD4nnOvVi9hqXo456Vx1pqKL2+XbQ4xjri4b01bq/Tc5qgj PpO3ak2+KqbK7sl8MufX1lZ2AwWxIH+p8xvvy22+mbZj45EzN7R2qx//3iT9ap72yzUn/3D5 d2TXrLi2RFKJpTgj0VCLuag4EQCkZRDqnwIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130626_111706_570956_8105DCEB X-CRM114-Status: GOOD ( 19.15 ) X-Spam-Score: -8.2 (--------) Cc: rjw@sisk.pl, kgene.kim@samsung.com, magnus.damm@gmail.com, ben-linux@fluff.org, linux-pm@vger.kernel.org, khilman@deeprootsystems.com, nsekhar@ti.com, linus.walleij@linaro.org, swarren@wwwdotorg.org, nicolas.ferre@atmel.com, daniel.lezcano@linaro.org, tony@atomide.com, kyungmin.park@samsung.com, horms@verge.net.au, srinidhi.kasagar@stericsson.com, kernel@pengutronix.de, shawn.guo@linaro.org, plagnioj@jcrosoft.com, linux@maxim.org.za, b.zolnierkie@samsung.com 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=-5.5 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 Compile tested only. Cc: Sekhar Nori Cc: Kevin Hilman Cc: Daniel Lezcano Cc: "Rafael J. Wysocki" Signed-off-by: Kyungmin Park Signed-off-by: Bartlomiej Zolnierkiewicz --- arch/arm/mach-davinci/Makefile | 1 - arch/arm/mach-davinci/cpuidle.c | 105 -------------------------------------- drivers/cpuidle/Makefile | 3 ++ drivers/cpuidle/cpuidle-davinci.c | 104 +++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 106 deletions(-) delete mode 100644 arch/arm/mach-davinci/cpuidle.c create mode 100644 drivers/cpuidle/cpuidle-davinci.c diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index 63997a1..76712e2 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile @@ -37,6 +37,5 @@ obj-$(CONFIG_MACH_MITYOMAPL138) += board-mityomapl138.o obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o # Power Management -obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_SUSPEND) += pm.o sleep.o obj-$(CONFIG_HAVE_CLK) += pm_domain.o diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c deleted file mode 100644 index 36aef3a..0000000 --- a/arch/arm/mach-davinci/cpuidle.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * CPU idle for DaVinci SoCs - * - * Copyright (C) 2009 Texas Instruments Incorporated. http://www.ti.com/ - * - * Derived from Marvell Kirkwood CPU idle code - * (arch/arm/mach-kirkwood/cpuidle.c) - * - * 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 -#include -#include -#include - -#include -#include - -#define DAVINCI_CPUIDLE_MAX_STATES 2 - -static void __iomem *ddr2_reg_base; -static bool ddr2_pdown; - -static void davinci_save_ddr_power(int enter, bool pdown) -{ - u32 val; - - val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET); - - if (enter) { - if (pdown) - val |= DDR2_SRPD_BIT; - else - val &= ~DDR2_SRPD_BIT; - val |= DDR2_LPMODEN_BIT; - } else { - val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT); - } - - __raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET); -} - -/* Actual code that puts the SoC in different idle states */ -static int davinci_enter_idle(struct cpuidle_device *dev, - struct cpuidle_driver *drv, int index) -{ - davinci_save_ddr_power(1, ddr2_pdown); - cpu_do_idle(); - davinci_save_ddr_power(0, ddr2_pdown); - - return index; -} - -static struct cpuidle_driver davinci_idle_driver = { - .name = "cpuidle-davinci", - .owner = THIS_MODULE, - .states[0] = ARM_CPUIDLE_WFI_STATE, - .states[1] = { - .enter = davinci_enter_idle, - .exit_latency = 10, - .target_residency = 100000, - .flags = CPUIDLE_FLAG_TIME_VALID, - .name = "DDR SR", - .desc = "WFI and DDR Self Refresh", - }, - .state_count = DAVINCI_CPUIDLE_MAX_STATES, -}; - -static int __init davinci_cpuidle_probe(struct platform_device *pdev) -{ - struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; - - if (!pdata) { - dev_err(&pdev->dev, "cannot get platform data\n"); - return -ENOENT; - } - - ddr2_reg_base = pdata->ddr2_ctlr_base; - - ddr2_pdown = pdata->ddr2_pdown; - - return cpuidle_register(&davinci_idle_driver, NULL); -} - -static struct platform_driver davinci_cpuidle_driver = { - .driver = { - .name = "cpuidle-davinci", - .owner = THIS_MODULE, - }, -}; - -static int __init davinci_cpuidle_init(void) -{ - return platform_driver_probe(&davinci_cpuidle_driver, - davinci_cpuidle_probe); -} -device_initcall(davinci_cpuidle_init); - diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index 9dd4091..3bbb828 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -9,5 +9,8 @@ ifeq ($(CONFIG_ARCH_AT91),y) obj-y += cpuidle-at91.o endif obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o +ifeq ($(CONFIG_ARCH_DAVINCI),y) + obj-y += cpuidle-davinci.o +endif obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o obj-$(CONFIG_CPU_IDLE_ZYNQ) += cpuidle-zynq.o diff --git a/drivers/cpuidle/cpuidle-davinci.c b/drivers/cpuidle/cpuidle-davinci.c new file mode 100644 index 0000000..b5a6476 --- /dev/null +++ b/drivers/cpuidle/cpuidle-davinci.c @@ -0,0 +1,104 @@ +/* + * CPU idle for DaVinci SoCs + * + * Copyright (C) 2009 Texas Instruments Incorporated. http://www.ti.com/ + * + * Derived from Marvell Kirkwood CPU idle code + * (arch/arm/mach-kirkwood/cpuidle.c) + * + * 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 +#include +#include +#include + +#include +#include + +#define DAVINCI_CPUIDLE_MAX_STATES 2 + +static void __iomem *ddr2_reg_base; +static bool ddr2_pdown; + +static void davinci_save_ddr_power(int enter, bool pdown) +{ + u32 val; + + val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET); + + if (enter) { + if (pdown) + val |= DDR2_SRPD_BIT; + else + val &= ~DDR2_SRPD_BIT; + val |= DDR2_LPMODEN_BIT; + } else { + val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT); + } + + __raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET); +} + +/* Actual code that puts the SoC in different idle states */ +static int davinci_enter_idle(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) +{ + davinci_save_ddr_power(1, ddr2_pdown); + cpu_do_idle(); + davinci_save_ddr_power(0, ddr2_pdown); + + return index; +} + +static struct cpuidle_driver davinci_idle_driver = { + .name = "cpuidle-davinci", + .owner = THIS_MODULE, + .states[0] = ARM_CPUIDLE_WFI_STATE, + .states[1] = { + .enter = davinci_enter_idle, + .exit_latency = 10, + .target_residency = 100000, + .flags = CPUIDLE_FLAG_TIME_VALID, + .name = "DDR SR", + .desc = "WFI and DDR Self Refresh", + }, + .state_count = DAVINCI_CPUIDLE_MAX_STATES, +}; + +static int __init davinci_cpuidle_probe(struct platform_device *pdev) +{ + struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; + + if (!pdata) { + dev_err(&pdev->dev, "cannot get platform data\n"); + return -ENOENT; + } + + ddr2_reg_base = pdata->ddr2_ctlr_base; + + ddr2_pdown = pdata->ddr2_pdown; + + return cpuidle_register(&davinci_idle_driver, NULL); +} + +static struct platform_driver davinci_cpuidle_driver = { + .driver = { + .name = "cpuidle-davinci", + .owner = THIS_MODULE, + }, +}; + +static int __init davinci_cpuidle_init(void) +{ + return platform_driver_probe(&davinci_cpuidle_driver, + davinci_cpuidle_probe); +} +device_initcall(davinci_cpuidle_init);