~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-pxa/pm.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * PXA250/210 Power Management Routines
  3  *
  4  * Original code for the SA11x0:
  5  * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
  6  *
  7  * Modified for the PXA250 by Nicolas Pitre:
  8  * Copyright (c) 2002 Monta Vista Software, Inc.
  9  *
 10  * This program is free software; you can redistribute it and/or
 11  * modify it under the terms of the GNU General Public License.
 12  */
 13 #include <linux/init.h>
 14 #include <linux/module.h>
 15 #include <linux/suspend.h>
 16 #include <linux/errno.h>
 17 #include <linux/slab.h>
 18 
 19 #include "pm.h"
 20 
 21 struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;
 22 static unsigned long *sleep_save;
 23 
 24 int pxa_pm_enter(suspend_state_t state)
 25 {
 26         unsigned long sleep_save_checksum = 0, checksum = 0;
 27         int i;
 28 
 29 #ifdef CONFIG_IWMMXT
 30         /* force any iWMMXt context to ram **/
 31         if (elf_hwcap & HWCAP_IWMMXT)
 32                 iwmmxt_task_disable(NULL);
 33 #endif
 34 
 35         /* skip registers saving for standby */
 36         if (state != PM_SUSPEND_STANDBY && pxa_cpu_pm_fns->save) {
 37                 pxa_cpu_pm_fns->save(sleep_save);
 38                 /* before sleeping, calculate and save a checksum */
 39                 for (i = 0; i < pxa_cpu_pm_fns->save_count - 1; i++)
 40                         sleep_save_checksum += sleep_save[i];
 41         }
 42 
 43         /* *** go zzz *** */
 44         pxa_cpu_pm_fns->enter(state);
 45 
 46         if (state != PM_SUSPEND_STANDBY && pxa_cpu_pm_fns->restore) {
 47                 /* after sleeping, validate the checksum */
 48                 for (i = 0; i < pxa_cpu_pm_fns->save_count - 1; i++)
 49                         checksum += sleep_save[i];
 50 
 51                 /* if invalid, display message and wait for a hardware reset */
 52                 if (checksum != sleep_save_checksum) {
 53 
 54                         while (1)
 55                                 pxa_cpu_pm_fns->enter(state);
 56                 }
 57                 pxa_cpu_pm_fns->restore(sleep_save);
 58         }
 59 
 60         pr_debug("*** made it back from resume\n");
 61 
 62         return 0;
 63 }
 64 
 65 EXPORT_SYMBOL_GPL(pxa_pm_enter);
 66 
 67 static int pxa_pm_valid(suspend_state_t state)
 68 {
 69         if (pxa_cpu_pm_fns)
 70                 return pxa_cpu_pm_fns->valid(state);
 71 
 72         return -EINVAL;
 73 }
 74 
 75 int pxa_pm_prepare(void)
 76 {
 77         int ret = 0;
 78 
 79         if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->prepare)
 80                 ret = pxa_cpu_pm_fns->prepare();
 81 
 82         return ret;
 83 }
 84 
 85 void pxa_pm_finish(void)
 86 {
 87         if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->finish)
 88                 pxa_cpu_pm_fns->finish();
 89 }
 90 
 91 static const struct platform_suspend_ops pxa_pm_ops = {
 92         .valid          = pxa_pm_valid,
 93         .enter          = pxa_pm_enter,
 94         .prepare        = pxa_pm_prepare,
 95         .finish         = pxa_pm_finish,
 96 };
 97 
 98 static int __init pxa_pm_init(void)
 99 {
100         if (!pxa_cpu_pm_fns) {
101                 printk(KERN_ERR "no valid pxa_cpu_pm_fns defined\n");
102                 return -EINVAL;
103         }
104 
105         sleep_save = kmalloc_array(pxa_cpu_pm_fns->save_count,
106                                    sizeof(*sleep_save),
107                                    GFP_KERNEL);
108         if (!sleep_save)
109                 return -ENOMEM;
110 
111         suspend_set_ops(&pxa_pm_ops);
112         return 0;
113 }
114 
115 device_initcall(pxa_pm_init);
116 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php