2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* PXA250/210 Power Management Routines
|
|
|
|
*
|
|
|
|
* Original code for the SA11x0:
|
|
|
|
* Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
|
|
|
|
*
|
|
|
|
* Modified for the PXA250 by Nicolas Pitre:
|
|
|
|
* Copyright (c) 2002 Monta Vista Software, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
2005-11-06 23:03:23 +08:00
|
|
|
#include <linux/module.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/suspend.h>
|
|
|
|
#include <linux/errno.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "pm.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-07-18 18:38:45 +08:00
|
|
|
struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;
|
|
|
|
static unsigned long *sleep_save;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-06 23:03:23 +08:00
|
|
|
int pxa_pm_enter(suspend_state_t state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-18 18:38:45 +08:00
|
|
|
unsigned long sleep_save_checksum = 0, checksum = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
#ifdef CONFIG_IWMMXT
|
|
|
|
/* force any iWMMXt context to ram **/
|
[ARM] 3881/4: xscale: clean up cp0/cp1 handling
XScale cores either have a DSP coprocessor (which contains a single
40 bit accumulator register), or an iWMMXt coprocessor (which contains
eight 64 bit registers.)
Because of the small amount of state in the DSP coprocessor, access to
the DSP coprocessor (CP0) is always enabled, and DSP context switching
is done unconditionally on every task switch. Access to the iWMMXt
coprocessor (CP0/CP1) is enabled only when an iWMMXt instruction is
first issued, and iWMMXt context switching is done lazily.
CONFIG_IWMMXT is supposed to mean 'the cpu we will be running on will
have iWMMXt support', but boards are supposed to select this config
symbol by hand, and at least one pxa27x board doesn't get this right,
so on that board, proc-xscale.S will incorrectly assume that we have a
DSP coprocessor, enable CP0 on boot, and we will then only save the
first iWMMXt register (wR0) on context switches, which is Bad.
This patch redefines CONFIG_IWMMXT as 'the cpu we will be running on
might have iWMMXt support, and we will enable iWMMXt context switching
if it does.' This means that with this patch, running a CONFIG_IWMMXT=n
kernel on an iWMMXt-capable CPU will no longer potentially corrupt iWMMXt
state over context switches, and running a CONFIG_IWMMXT=y kernel on a
non-iWMMXt capable CPU will still do DSP context save/restore.
These changes should make iWMMXt work on PXA3xx, and as a side effect,
enable proper acc0 save/restore on non-iWMMXt capable xsc3 cores such
as IOP13xx and IXP23xx (which will not have CONFIG_CPU_XSCALE defined),
as well as setting and using HWCAP_IWMMXT properly.
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2006-12-04 01:51:14 +08:00
|
|
|
if (elf_hwcap & HWCAP_IWMMXT)
|
|
|
|
iwmmxt_task_disable(NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2008-01-14 15:50:54 +08:00
|
|
|
/* skip registers saving for standby */
|
2011-01-26 05:04:00 +08:00
|
|
|
if (state != PM_SUSPEND_STANDBY && pxa_cpu_pm_fns->save) {
|
2008-01-14 15:50:54 +08:00
|
|
|
pxa_cpu_pm_fns->save(sleep_save);
|
|
|
|
/* before sleeping, calculate and save a checksum */
|
2008-05-03 04:17:06 +08:00
|
|
|
for (i = 0; i < pxa_cpu_pm_fns->save_count - 1; i++)
|
2008-01-14 15:50:54 +08:00
|
|
|
sleep_save_checksum += sleep_save[i];
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* *** go zzz *** */
|
2007-07-18 18:38:45 +08:00
|
|
|
pxa_cpu_pm_fns->enter(state);
|
2005-06-20 01:39:33 +08:00
|
|
|
|
2011-01-26 05:04:00 +08:00
|
|
|
if (state != PM_SUSPEND_STANDBY && pxa_cpu_pm_fns->restore) {
|
2008-01-14 15:50:54 +08:00
|
|
|
/* after sleeping, validate the checksum */
|
2008-05-03 04:17:06 +08:00
|
|
|
for (i = 0; i < pxa_cpu_pm_fns->save_count - 1; i++)
|
2008-01-14 15:50:54 +08:00
|
|
|
checksum += sleep_save[i];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-01-14 15:50:54 +08:00
|
|
|
/* if invalid, display message and wait for a hardware reset */
|
|
|
|
if (checksum != sleep_save_checksum) {
|
2009-01-19 18:43:12 +08:00
|
|
|
|
|
|
|
lubbock_set_hexled(0xbadbadc5);
|
|
|
|
|
2008-01-14 15:50:54 +08:00
|
|
|
while (1)
|
|
|
|
pxa_cpu_pm_fns->enter(state);
|
|
|
|
}
|
|
|
|
pxa_cpu_pm_fns->restore(sleep_save);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-07-18 18:38:45 +08:00
|
|
|
pr_debug("*** made it back from resume\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-06 23:03:23 +08:00
|
|
|
EXPORT_SYMBOL_GPL(pxa_pm_enter);
|
|
|
|
|
2007-07-18 18:38:45 +08:00
|
|
|
static int pxa_pm_valid(suspend_state_t state)
|
|
|
|
{
|
|
|
|
if (pxa_cpu_pm_fns)
|
|
|
|
return pxa_cpu_pm_fns->valid(state);
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-06-11 23:25:09 +08:00
|
|
|
int pxa_pm_prepare(void)
|
2008-08-27 19:55:04 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->prepare)
|
|
|
|
ret = pxa_cpu_pm_fns->prepare();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-06-11 23:25:09 +08:00
|
|
|
void pxa_pm_finish(void)
|
2008-08-27 19:55:04 +08:00
|
|
|
{
|
|
|
|
if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->finish)
|
|
|
|
pxa_cpu_pm_fns->finish();
|
|
|
|
}
|
|
|
|
|
2010-11-16 21:14:02 +08:00
|
|
|
static const struct platform_suspend_ops pxa_pm_ops = {
|
2007-07-18 18:38:45 +08:00
|
|
|
.valid = pxa_pm_valid,
|
|
|
|
.enter = pxa_pm_enter,
|
2008-08-27 19:55:04 +08:00
|
|
|
.prepare = pxa_pm_prepare,
|
|
|
|
.finish = pxa_pm_finish,
|
2007-07-18 18:38:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init pxa_pm_init(void)
|
|
|
|
{
|
|
|
|
if (!pxa_cpu_pm_fns) {
|
|
|
|
printk(KERN_ERR "no valid pxa_cpu_pm_fns defined\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-05-03 04:17:06 +08:00
|
|
|
sleep_save = kmalloc(pxa_cpu_pm_fns->save_count * sizeof(unsigned long),
|
|
|
|
GFP_KERNEL);
|
2007-07-18 18:38:45 +08:00
|
|
|
if (!sleep_save) {
|
|
|
|
printk(KERN_ERR "failed to alloc memory for pm save\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2007-10-18 18:04:40 +08:00
|
|
|
suspend_set_ops(&pxa_pm_ops);
|
2007-07-18 18:38:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_initcall(pxa_pm_init);
|