From patchwork Sat Oct 12 15:51:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 20992 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 789FE25E03 for ; Sat, 12 Oct 2013 15:51:44 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id z20sf6282468yhz.3 for ; Sat, 12 Oct 2013 08:51:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=tUVl77GRRVzGGsyUbXMEfw2h7xnYlTFN2Zu7RXUNclA=; b=KsarDIfyJsxEY6HoJLHTkdjtav8/HcsI2y+1C6s+9XOKnIUUYsU7qFjUZ+6S/fF2Ab xvg616RKp1fU16IS15acbVuEdErqIMqvQFP7bmhP/aPgeROQxqVXEziQkLCMoPB2mVM8 E5GCoe7gpZ1e18AkZILsnCJh/T6hl+y5lHCfA1Phe6W1ScFKQsHcLBY8nBgftSj1018f RHb+Rh/eIgKz6yEu6AUAgx4OF4CF7/2MdJr/4LnNJVdiPu6u9m/66v2gJ2nHfxdAb2Br vrNmqlAd+KWyET86y7n/iOWouXmcyBLdWd6DzrZAHz8pXmCDiIqFKAl2BmhfiMjvEPy8 LhAQ== X-Received: by 10.236.4.69 with SMTP id 45mr24822728yhi.20.1381593103902; Sat, 12 Oct 2013 08:51:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.129.166 with SMTP id nx6ls40399qeb.12.gmail; Sat, 12 Oct 2013 08:51:43 -0700 (PDT) X-Received: by 10.220.58.1 with SMTP id e1mr5540845vch.0.1381593103805; Sat, 12 Oct 2013 08:51:43 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id ug9si18879383vcb.32.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 12 Oct 2013 08:51:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.50; Received: by mail-vb0-f50.google.com with SMTP id x14so3746787vbb.9 for ; Sat, 12 Oct 2013 08:51:43 -0700 (PDT) X-Gm-Message-State: ALoCoQnGB/sNlEtSpw2NAdDQ4mH9LOOvhQs0Ax0D7xHEcxhNUxPi955UXyME72f0BQFlopXSSUy8 X-Received: by 10.52.52.137 with SMTP id t9mr21952397vdo.22.1381593103493; Sat, 12 Oct 2013 08:51:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp118193vcz; Sat, 12 Oct 2013 08:51:42 -0700 (PDT) X-Received: by 10.180.99.99 with SMTP id ep3mr7725615wib.11.1381593102462; Sat, 12 Oct 2013 08:51:42 -0700 (PDT) Received: from mail-we0-f180.google.com (mail-we0-f180.google.com [74.125.82.180]) by mx.google.com with ESMTPS id p10si2712028wic.69.2013.10.12.08.51.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 12 Oct 2013 08:51:42 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.180 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=74.125.82.180; Received: by mail-we0-f180.google.com with SMTP id q59so5368170wes.39 for ; Sat, 12 Oct 2013 08:51:41 -0700 (PDT) X-Received: by 10.180.98.228 with SMTP id el4mr7901614wib.4.1381593101645; Sat, 12 Oct 2013 08:51:41 -0700 (PDT) Received: from mai.home (AToulouse-654-1-457-225.w83-205.abo.wanadoo.fr. [83.205.200.225]) by mx.google.com with ESMTPSA id gp9sm16132558wib.8.2013.10.12.08.51.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 12 Oct 2013 08:51:41 -0700 (PDT) From: Daniel Lezcano To: linux@maxim.org.za, nicolas.ferre@atmel.com, plagnioj@jcrosoft.com Cc: linux-arm-kernel@lists.infradead.org, patches@linaro.org, linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org Subject: [PATCH 1/2] ARM: at91: cpuidle: convert to platform driver Date: Sat, 12 Oct 2013 17:51:38 +0200 Message-Id: <1381593099-1184-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 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.212.50 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use the platform driver model to separate the cpuidle specific code from the low level pm code. It allows to remove the dependency between these two components. Tested-on usb-a9263 (at91sam9263) Signed-off-by: Daniel Lezcano --- arch/arm/mach-at91/cpuidle.c | 29 +++++++++++++++-------------- arch/arm/mach-at91/pm.c | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c index 4ec6a6d..6cdc76d 100644 --- a/arch/arm/mach-at91/cpuidle.c +++ b/arch/arm/mach-at91/cpuidle.c @@ -21,26 +21,17 @@ #include #include #include -#include - -#include "pm.h" #define AT91_MAX_STATES 2 +static void (*at91_standby)(void); + /* Actual code that puts the SoC in different idle states */ static int at91_enter_idle(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { - if (cpu_is_at91rm9200()) - at91rm9200_standby(); - else if (cpu_is_at91sam9g45()) - at91sam9g45_standby(); - else if (cpu_is_at91sam9263()) - at91sam9263_standby(); - else - at91sam9_standby(); - + at91_standby(); return index; } @@ -60,9 +51,19 @@ static struct cpuidle_driver at91_idle_driver = { }; /* Initialize CPU idle by registering the idle states */ -static int __init at91_init_cpuidle(void) +static int __init at91_cpuidle_probe(struct platform_device *dev) { + at91_standby = (void *)(dev->dev.platform_data); + return cpuidle_register(&at91_idle_driver, NULL); } -device_initcall(at91_init_cpuidle); +static struct platform_driver at91_cpuidle_driver = { + .driver = { + .name = "cpuidle-at91", + .owner = THIS_MODULE, + }, + .probe = at91_cpuidle_probe, +}; + +module_platform_driver(at91_cpuidle_driver); diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 15afb5d..debdbf8 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -314,6 +314,10 @@ static const struct platform_suspend_ops at91_pm_ops = { .end = at91_pm_end, }; +static struct platform_device at91_cpuidle_device = { + .name = "cpuidle-at91", +}; + static int __init at91_pm_init(void) { #ifdef CONFIG_AT91_SLOW_CLOCK @@ -323,8 +327,18 @@ static int __init at91_pm_init(void) pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : "")); /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ - if (cpu_is_at91rm9200()) + if (cpu_is_at91rm9200()) { + at91_cpuidle_device.dev.platform_data = at91rm9200_standby; at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); + } else if (cpu_is_at91sam9g45()) { + at91_cpuidle_device.dev.platform_data = at91sam9g45_standby; + } else if (cpu_is_at91sam9263()) { + at91_cpuidle_device.dev.platform_data = at91sam9263_standby; + } else { + at91_cpuidle_device.dev.platform_data = at91sam9_standby; + } + + platform_device_register(&at91_cpuidle_device); suspend_set_ops(&at91_pm_ops);