From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: linux@maxim.org.za, nicolas.ferre@atmel.com,
linux-arm-kernel@lists.infradead.org, patches@linaro.org,
linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: at91: cpuidle: convert to platform driver
Date: Mon, 14 Oct 2013 16:18:25 +0200 [thread overview]
Message-ID: <525BFD31.3020406@linaro.org> (raw)
In-Reply-To: <20131014140406.GH11420@ns203013.ovh.net>
On 10/14/2013 04:04 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 17:51 Sat 12 Oct , Daniel Lezcano wrote:
>> 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 <daniel.lezcano@linaro.org>
>> ---
>> 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 <linux/export.h>
>> #include <asm/proc-fns.h>
>> #include <asm/cpuidle.h>
>> -#include <mach/cpu.h>
>> -
>> -#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;
> no this is too dangerous when adding new SoC
>
> you must list the supported SoC
>
> and I prefer to move this code to the SoC init structure
Do you mean register the platform_device in eg. at91rm9200_initialize
with the right platform data ?
> so we can drop the if/else if/elsee
>
> and drop the issue of adding new and the arch_initcall
>
> Best Regards,
> J.
>> + }
>> +
>> + platform_device_register(&at91_cpuidle_device);
>>
>> suspend_set_ops(&at91_pm_ops);
>>
>> --
>> 1.7.9.5
>>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2013-10-14 14:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-12 15:51 [PATCH 1/2] ARM: at91: cpuidle: convert to platform driver Daniel Lezcano
2013-10-12 15:51 ` [PATCH 2/2] ARM: at91: cpuidle: Move driver to drivers/cpuidle Daniel Lezcano
2013-10-13 9:19 ` Thomas Petazzoni
2013-10-13 10:17 ` Daniel Lezcano
2013-10-14 10:20 ` Bartlomiej Zolnierkiewicz
2013-10-14 10:53 ` Daniel Lezcano
2013-10-14 14:04 ` [PATCH 1/2] ARM: at91: cpuidle: convert to platform driver Jean-Christophe PLAGNIOL-VILLARD
2013-10-14 14:18 ` Daniel Lezcano [this message]
2013-10-14 14:27 ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-14 16:30 ` Daniel Lezcano
2013-10-14 17:18 ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-14 17:59 ` Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=525BFD31.3020406@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@maxim.org.za \
--cc=nicolas.ferre@atmel.com \
--cc=patches@linaro.org \
--cc=plagnioj@jcrosoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).