10 #include <linux/kernel.h>
11 #include <linux/list.h>
13 #include <linux/slab.h>
28 #ifdef CONFIG_ACPI_SLEEP
29 static int suspend_nvs_register(
unsigned long start,
unsigned long size);
31 static inline int suspend_nvs_register(
unsigned long a,
unsigned long b)
48 return suspend_nvs_register(start, size);
67 #ifdef CONFIG_ACPI_SLEEP
75 unsigned long phys_start;
94 static int suspend_nvs_register(
unsigned long start,
unsigned long size)
98 pr_info(
"PM: Registering ACPI NVS region [mem %#010lx-%#010lx] (%ld bytes)\n",
99 start, start + size - 1, size);
102 unsigned int nr_bytes;
104 entry = kzalloc(
sizeof(
struct nvs_page),
GFP_KERNEL);
109 entry->phys_start =
start;
111 entry->size = (size < nr_bytes) ? size : nr_bytes;
113 start += entry->size;
129 void suspend_nvs_free(
void)
131 struct nvs_page *
entry;
140 entry->unmap =
false;
153 int suspend_nvs_alloc(
void)
155 struct nvs_page *
entry;
170 int suspend_nvs_save(
void)
172 struct nvs_page *
entry;
178 unsigned long phys = entry->phys_start;
179 unsigned int size = entry->size;
183 entry->kaddr = acpi_os_ioremap(phys, size);
184 entry->unmap = !!entry->kaddr;
190 memcpy(entry->data, entry->kaddr, entry->size);
202 void suspend_nvs_restore(
void)
204 struct nvs_page *
entry;
210 memcpy(entry->kaddr, entry->data, entry->size);