Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) // Copyright (C) 2013 Samsung Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) //	Tomasz Figa <t.figa@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) // Copyright (C) 2008 Openmoko, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) // Copyright (C) 2004-2008 Simtec Electronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) //	Ben Dooks <ben@simtec.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) //	http://armlinux.simtec.co.uk/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) // Samsung common power management helper functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "pm-common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* helper functions to save and restore register state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  * s3c_pm_do_save() - save a set of registers for restoration on resume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * @ptr: Pointer to an array of registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * @count: Size of the ptr array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * Run through the list of registers given, saving their contents in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  * array for later restoration when we wakeup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) void s3c_pm_do_save(struct sleep_save *ptr, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	for (; count > 0; count--, ptr++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		ptr->val = readl_relaxed(ptr->reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  * s3c_pm_do_restore() - restore register values from the save list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  * @ptr: Pointer to an array of registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  * @count: Size of the ptr array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)  * Restore the register values saved from s3c_pm_do_save().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)  * Note, we do not use S3C_PMDBG() in here, as the system may not have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)  * restore the UARTs state yet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) void s3c_pm_do_restore(const struct sleep_save *ptr, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	for (; count > 0; count--, ptr++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		pr_debug("restore %p (restore %08lx, was %08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 				ptr->reg, ptr->val, readl_relaxed(ptr->reg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 		writel_relaxed(ptr->val, ptr->reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)  * s3c_pm_do_restore_core() - early restore register values from save list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)  * @ptr: Pointer to an array of registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)  * @count: Size of the ptr array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)  * This is similar to s3c_pm_do_restore() except we try and minimise the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)  * side effects of the function in case registers that hardware might need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)  * to work has been restored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)  * WARNING: Do not put any debug in here that may effect memory or use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)  * peripherals, as things may be changing!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	for (; count > 0; count--, ptr++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 		writel_relaxed(ptr->val, ptr->reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }