From patchwork Fri Apr 4 07:47:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 27776 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A939D20369 for ; Fri, 4 Apr 2014 07:48:01 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf11074223pbc.0 for ; Fri, 04 Apr 2014 00:48:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=WpQuaoDi14aVQdXHclYRLLkM6u3UlYO6eDTzeE0zXWU=; b=mAHJUKjZnZIBD0sbpd/A22pPjQ5JcLGf9XOg5m7MQd5yA53x8OYoTCIom6t09+PZhM hHgClJJb+L7koEL8heM2MdDyRzw5RdfbqzkMSaNY2b6EFwX6NIUrpHaCe5JXI0soiuEI dousEqBVvNvdM852dVuykC0oCQa8GeAWeYOHzrfSlnTjTZ0Hv+6ZFummSkH9tKIL+neZ Kr/zaShQecpl1ftLKpMbiod4PgFtMjMZteefSQmnXEmPnr+g3siN09BCCqszKw1SyxjR mWNhlAtxqmJxWao/THAuPwv6lIE8dVM7hoZ60gDnEfwJ21mIXbiqN2pRQ9ElWYxOzncL KgOA== X-Gm-Message-State: ALoCoQkF83PJJA1MM3JGRXJy+3tskFevNDAH3ZqFvM/46Fq/sAG28jmFQQdc80flcnRsV28y/k5V X-Received: by 10.66.231.132 with SMTP id tg4mr3846172pac.31.1396597680861; Fri, 04 Apr 2014 00:48:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.100 with SMTP id u91ls898366qgu.74.gmail; Fri, 04 Apr 2014 00:48:00 -0700 (PDT) X-Received: by 10.220.198.197 with SMTP id ep5mr1113309vcb.21.1396597680726; Fri, 04 Apr 2014 00:48:00 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id gs7si1655688vdc.146.2014.04.04.00.48.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 00:48:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so2872174vcb.16 for ; Fri, 04 Apr 2014 00:48:00 -0700 (PDT) X-Received: by 10.52.191.100 with SMTP id gx4mr10052702vdc.4.1396597680642; Fri, 04 Apr 2014 00:48:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp92805vcv; Fri, 4 Apr 2014 00:48:00 -0700 (PDT) X-Received: by 10.66.241.66 with SMTP id wg2mr13233629pac.132.1396597679604; Fri, 04 Apr 2014 00:47:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iw3si4270530pac.96.2014.04.04.00.47.59; Fri, 04 Apr 2014 00:47:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752101AbaDDHr6 (ORCPT + 9 others); Fri, 4 Apr 2014 03:47:58 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:62824 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755AbaDDHr5 (ORCPT ); Fri, 4 Apr 2014 03:47:57 -0400 Received: by mail-wi0-f182.google.com with SMTP id d1so687025wiv.3 for ; Fri, 04 Apr 2014 00:47:56 -0700 (PDT) X-Received: by 10.194.58.180 with SMTP id s20mr17615454wjq.54.1396597676758; Fri, 04 Apr 2014 00:47:56 -0700 (PDT) Received: from localhost.localdomain (AToulouse-654-1-451-172.w83-205.abo.wanadoo.fr. [83.205.74.172]) by mx.google.com with ESMTPSA id t1sm3028163wia.1.2014.04.04.00.47.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 00:47:56 -0700 (PDT) From: Daniel Lezcano To: kgene.kim@samsung.com Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, t.figa@samsung.com, linaro-kernel@lists.linaro.org, rjw@rjwysocki.net Subject: [PATCH 07/17] ARM: exynos: cpuidle: Use the cpu_pm notifier Date: Fri, 4 Apr 2014 09:47:53 +0200 Message-Id: <1396597683-6969-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396597683-6969-1-git-send-email-daniel.lezcano@linaro.org> References: <1396597683-6969-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use the cpu_pm_enter/exit notifier to group some pm code inside the pm file. The save and restore code is duplicated across pm.c and cpuidle.c. By using the cpu_pm notifier, we can factor out the routine. Signed-off-by: Daniel Lezcano --- arch/arm/mach-exynos/cpuidle.c | 24 ------------------------ arch/arm/mach-exynos/pm.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c index a1e1882..4b090cf 100644 --- a/arch/arm/mach-exynos/cpuidle.c +++ b/arch/arm/mach-exynos/cpuidle.c @@ -66,26 +66,6 @@ static void exynos_set_wakeupmask(void) __raw_writel(0x0000ff3e, S5P_WAKEUP_MASK); } -static unsigned int g_pwr_ctrl, g_diag_reg; - -static void save_cpu_arch_register(void) -{ - /*read power control register*/ - asm("mrc p15, 0, %0, c15, c0, 0" : "=r"(g_pwr_ctrl) : : "cc"); - /*read diagnostic register*/ - asm("mrc p15, 0, %0, c15, c0, 1" : "=r"(g_diag_reg) : : "cc"); - return; -} - -static void restore_cpu_arch_register(void) -{ - /*write power control register*/ - asm("mcr p15, 0, %0, c15, c0, 0" : : "r"(g_pwr_ctrl) : "cc"); - /*write diagnostic register*/ - asm("mcr p15, 0, %0, c15, c0, 1" : : "r"(g_diag_reg) : "cc"); - return; -} - static int idle_finisher(unsigned long flags) { exynos_set_wakeupmask(); @@ -107,8 +87,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, { unsigned long tmp; - save_cpu_arch_register(); - /* Setting Central Sequence Register for power down mode */ tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); tmp &= ~S5P_CENTRAL_LOWPWR_CFG; @@ -123,8 +101,6 @@ static int exynos_enter_core0_aftr(struct cpuidle_device *dev, #endif cpu_pm_exit(); - restore_cpu_arch_register(); - /* * If PMU failed while entering sleep mode, WFI will be * ignored by PMU and then exiting cpu_do_idle(). diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c index 2326c67..b2a075e 100644 --- a/arch/arm/mach-exynos/pm.c +++ b/arch/arm/mach-exynos/pm.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -376,16 +377,38 @@ early_wakeup: return; } +static int exynos_cpu_pm_notifier(struct notifier_block *self, + unsigned long cmd, void *v) +{ + switch (cmd) { + case CPU_PM_ENTER: + exynos_cpu_save_register(); + break; + + case CPU_PM_EXIT: + exynos_cpu_restore_register(); + break; + } + + return NOTIFY_OK; +} + static struct syscore_ops exynos_pm_syscore_ops = { .suspend = exynos_pm_suspend, .resume = exynos_pm_resume, }; +static struct notifier_block exynos_cpu_pm_notifier_block = { + .notifier_call = exynos_cpu_pm_notifier, +}; static __init int exynos_pm_syscore_init(void) { if (soc_is_exynos5440()) return 0; + if (!soc_is_exynos5250()) + cpu_pm_register_notifier(&exynos_cpu_pm_notifier_block); + register_syscore_ops(&exynos_pm_syscore_ops); return 0; }