2 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
3 * Tomasz Figa <t.figa@samsung.com>
4 * Copyright (C) 2008 Openmoko, Inc.
5 * Copyright (C) 2004-2008 Simtec Electronics
6 * Ben Dooks <ben@simtec.co.uk>
7 * http://armlinux.simtec.co.uk/
9 * Samsung common power management helper functions.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
17 #include <linux/kernel.h>
19 #include <plat/pm-common.h>
21 /* helper functions to save and restore register state */
24 * s3c_pm_do_save() - save a set of registers for restoration on resume.
25 * @ptr: Pointer to an array of registers.
26 * @count: Size of the ptr array.
28 * Run through the list of registers given, saving their contents in the
29 * array for later restoration when we wakeup.
31 void s3c_pm_do_save(struct sleep_save
*ptr
, int count
)
33 for (; count
> 0; count
--, ptr
++) {
34 ptr
->val
= __raw_readl(ptr
->reg
);
35 S3C_PMDBG("saved %p value %08lx\n", ptr
->reg
, ptr
->val
);
40 * s3c_pm_do_restore() - restore register values from the save list.
41 * @ptr: Pointer to an array of registers.
42 * @count: Size of the ptr array.
44 * Restore the register values saved from s3c_pm_do_save().
46 * Note, we do not use S3C_PMDBG() in here, as the system may not have
47 * restore the UARTs state yet
50 void s3c_pm_do_restore(const struct sleep_save
*ptr
, int count
)
52 for (; count
> 0; count
--, ptr
++) {
53 pr_debug("restore %p (restore %08lx, was %08x)\n",
54 ptr
->reg
, ptr
->val
, __raw_readl(ptr
->reg
));
56 __raw_writel(ptr
->val
, ptr
->reg
);
61 * s3c_pm_do_restore_core() - early restore register values from save list.
63 * This is similar to s3c_pm_do_restore() except we try and minimise the
64 * side effects of the function in case registers that hardware might need
65 * to work has been restored.
67 * WARNING: Do not put any debug in here that may effect memory or use
68 * peripherals, as things may be changing!
71 void s3c_pm_do_restore_core(const struct sleep_save
*ptr
, int count
)
73 for (; count
> 0; count
--, ptr
++)
74 __raw_writel(ptr
->val
, ptr
->reg
);