Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // Copyright (C) 2013 Samsung Electronics Co., Ltd.
0004 //  Tomasz Figa <t.figa@samsung.com>
0005 // Copyright (C) 2008 Openmoko, Inc.
0006 // Copyright (C) 2004-2008 Simtec Electronics
0007 //  Ben Dooks <ben@simtec.co.uk>
0008 //  http://armlinux.simtec.co.uk/
0009 //
0010 // Samsung common power management helper functions.
0011 
0012 #include <linux/io.h>
0013 #include <linux/kernel.h>
0014 
0015 #include "pm-common.h"
0016 
0017 /* helper functions to save and restore register state */
0018 
0019 /**
0020  * s3c_pm_do_save() - save a set of registers for restoration on resume.
0021  * @ptr: Pointer to an array of registers.
0022  * @count: Size of the ptr array.
0023  *
0024  * Run through the list of registers given, saving their contents in the
0025  * array for later restoration when we wakeup.
0026  */
0027 void s3c_pm_do_save(struct sleep_save *ptr, int count)
0028 {
0029     for (; count > 0; count--, ptr++) {
0030         ptr->val = readl_relaxed(ptr->reg);
0031         S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val);
0032     }
0033 }
0034 
0035 /**
0036  * s3c_pm_do_restore() - restore register values from the save list.
0037  * @ptr: Pointer to an array of registers.
0038  * @count: Size of the ptr array.
0039  *
0040  * Restore the register values saved from s3c_pm_do_save().
0041  *
0042  * Note, we do not use S3C_PMDBG() in here, as the system may not have
0043  * restore the UARTs state yet
0044 */
0045 
0046 void s3c_pm_do_restore(const struct sleep_save *ptr, int count)
0047 {
0048     for (; count > 0; count--, ptr++) {
0049         pr_debug("restore %p (restore %08lx, was %08x)\n",
0050                 ptr->reg, ptr->val, readl_relaxed(ptr->reg));
0051 
0052         writel_relaxed(ptr->val, ptr->reg);
0053     }
0054 }
0055 
0056 /**
0057  * s3c_pm_do_restore_core() - early restore register values from save list.
0058  * @ptr: Pointer to an array of registers.
0059  * @count: Size of the ptr array.
0060  *
0061  * This is similar to s3c_pm_do_restore() except we try and minimise the
0062  * side effects of the function in case registers that hardware might need
0063  * to work has been restored.
0064  *
0065  * WARNING: Do not put any debug in here that may effect memory or use
0066  * peripherals, as things may be changing!
0067 */
0068 
0069 void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count)
0070 {
0071     for (; count > 0; count--, ptr++)
0072         writel_relaxed(ptr->val, ptr->reg);
0073 }