From patchwork Thu May 10 08:44:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 8517 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DDC0823E37 for ; Thu, 10 May 2012 08:44:53 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id ADD2CA187FB for ; Thu, 10 May 2012 08:44:53 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so1509877yen.11 for ; Thu, 10 May 2012 01:44:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=xBkAaGdLDLbBMcOboPcP40TsvYHcIZW+EtvW1kgsvds=; b=eHpjashnjFX6fgXfbz+2oOOETio6Zj2Km9SGxbBO99BuE2ahH/y+BPZwQC2FTm2jS6 6mLpOto0/buVXlqKpKQoDGcQZA6h61OuV+WAXywMm33SvGia/LIV5AVrOaKwepxZK6Wt iK/+2VzgF8RyKK+zC2N4MyvtxnOUbgZaQU3bcG0lzHHiDX/O9tFiXVklFAeoCROoIJeM CwgXiW2B4VId9FXCbgC9gkOi0kkN54roK4MOrw9kuz9HB9Tiy8UZ/kjKbDJquFQeB0Wc HoS37KSN0s5eWL4DwEnEP9SQsdmrln1ADy38TzZx8ekjBaZ2id4kkHuQFyE3Ay35Zp4U hZhA== Received: by 10.42.130.7 with SMTP id t7mr1519149ics.43.1336639493281; Thu, 10 May 2012 01:44:53 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp77493ibj; Thu, 10 May 2012 01:44:52 -0700 (PDT) Received: by 10.14.127.130 with SMTP id d2mr620744eei.82.1336639491765; Thu, 10 May 2012 01:44:51 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id i1si885275wie.38.2012.05.10.01.44.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 May 2012 01:44:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by mail-wi0-f172.google.com with SMTP id hr2so165144wib.13 for ; Thu, 10 May 2012 01:44:51 -0700 (PDT) Received: by 10.180.75.241 with SMTP id f17mr7239989wiw.11.1336639491207; Thu, 10 May 2012 01:44:51 -0700 (PDT) Received: from localhost.localdomain (AToulouse-159-1-109-226.w92-134.abo.wanadoo.fr. [92.134.236.226]) by mx.google.com with ESMTPS id j3sm3109747wiw.1.2012.05.10.01.44.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 May 2012 01:44:50 -0700 (PDT) From: Daniel Lezcano To: nsekhar@ti.com, khilman@ti.com, lenb@kernel.org Cc: davinci-linux-open-source@linux.davincidsp.com, linux-pm@lists.linux-foundation.org, patches@linaro.org, linaro-dev@lists.linaro.org Subject: [PATCH 2/2] ARM: DAVINCI: cpuidle - remove ops Date: Thu, 10 May 2012 10:44:45 +0200 Message-Id: <1336639485-26955-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1336639485-26955-1-git-send-email-daniel.lezcano@linaro.org> References: <1336639485-26955-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQlV6YcXa9CXBXq1jXYk/FMEr1g7VzEhrv7pV6T1csBCFcQBl0arW8ih09ROACEnJ/IjSEx3 This patch removes the ops usage because we have the index passed as parameter to the idle function and we can determine if we do WFI or memory retention. The benefit of this cleanup is the removal of: * the ops * the statedata usage because we want to get rid of it in all the drivers * extra structure definition * extra functions definition * pointless macro definition BIT(0) It also benefits the readability. Signed-off-by: Daniel Lezcano --- arch/arm/mach-davinci/cpuidle.c | 81 +++++++++++++-------------------------- 1 files changed, 27 insertions(+), 54 deletions(-) diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c index f0f179c..61f4e52 100644 --- a/arch/arm/mach-davinci/cpuidle.c +++ b/arch/arm/mach-davinci/cpuidle.c @@ -25,35 +25,46 @@ #define DAVINCI_CPUIDLE_MAX_STATES 2 -struct davinci_ops { - void (*enter) (u32 flags); - void (*exit) (u32 flags); - u32 flags; -}; +static bool ddr2_pwdn = false; + +static void __iomem *ddr2_reg_base; + +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) { - struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; - struct davinci_ops *ops = cpuidle_get_statedata(state_usage); - - if (ops && ops->enter) - ops->enter(ops->flags); + if (index) + davinci_save_ddr_power(1, ddr2_pwdn); index = cpuidle_wrap_enter(dev, drv, index, arm_cpuidle_simple_enter); - if (ops && ops->exit) - ops->exit(ops->flags); + if (index) + davinci_save_ddr_power(0, ddr2_pwdn); return index; } -/* fields in davinci_ops.flags */ -#define DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN BIT(0) - static struct cpuidle_driver davinci_idle_driver = { .name = "cpuidle-davinci", .owner = THIS_MODULE, @@ -71,43 +82,6 @@ static struct cpuidle_driver davinci_idle_driver = { }; static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device); -static void __iomem *ddr2_reg_base; - -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); -} - -static void davinci_c2state_enter(u32 flags) -{ - davinci_save_ddr_power(1, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN)); -} - -static void davinci_c2state_exit(u32 flags) -{ - davinci_save_ddr_power(0, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN)); -} - -static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = { - [1] = { - .enter = davinci_c2state_enter, - .exit = davinci_c2state_exit, - }, -}; static int __init davinci_cpuidle_probe(struct platform_device *pdev) { @@ -125,8 +99,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev) ddr2_reg_base = pdata->ddr2_ctlr_base; if (pdata->ddr2_pdown) - davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN; - cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]); + ddr2_pwdn = true; ret = cpuidle_register_driver(&davinci_idle_driver); if (ret) {