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

TOMOYO Linux Cross Reference
Linux/arch/unicore32/kernel/pm.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * linux/arch/unicore32/kernel/pm.c
  3  *
  4  * Code specific to PKUnity SoC and UniCore ISA
  5  *
  6  *      Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn>
  7  *      Copyright (C) 2001-2010 Guan Xuetao
  8  *
  9  * This program is free software; you can redistribute it and/or modify
 10  * it under the terms of the GNU General Public License version 2 as
 11  * published by the Free Software Foundation.
 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 #include <linux/io.h>
 19 
 20 #include <mach/hardware.h>
 21 #include <mach/pm.h>
 22 
 23 #include "setup.h"
 24 
 25 struct puv3_cpu_pm_fns *puv3_cpu_pm_fns;
 26 static unsigned long *sleep_save;
 27 
 28 int puv3_pm_enter(suspend_state_t state)
 29 {
 30         unsigned long sleep_save_checksum = 0, checksum = 0;
 31         int i;
 32 
 33         /* skip registers saving for standby */
 34         if (state != PM_SUSPEND_STANDBY) {
 35                 puv3_cpu_pm_fns->save(sleep_save);
 36                 /* before sleeping, calculate and save a checksum */
 37                 for (i = 0; i < puv3_cpu_pm_fns->save_count - 1; i++)
 38                         sleep_save_checksum += sleep_save[i];
 39         }
 40 
 41         /* *** go zzz *** */
 42         puv3_cpu_pm_fns->enter(state);
 43         cpu_init();
 44 #ifdef CONFIG_INPUT_KEYBOARD
 45         puv3_ps2_init();
 46 #endif
 47 #ifdef CONFIG_PCI
 48         pci_puv3_preinit();
 49 #endif
 50         if (state != PM_SUSPEND_STANDBY) {
 51                 /* after sleeping, validate the checksum */
 52                 for (i = 0; i < puv3_cpu_pm_fns->save_count - 1; i++)
 53                         checksum += sleep_save[i];
 54 
 55                 /* if invalid, display message and wait for a hardware reset */
 56                 if (checksum != sleep_save_checksum) {
 57                         while (1)
 58                                 puv3_cpu_pm_fns->enter(state);
 59                 }
 60                 puv3_cpu_pm_fns->restore(sleep_save);
 61         }
 62 
 63         pr_debug("*** made it back from resume\n");
 64 
 65         return 0;
 66 }
 67 EXPORT_SYMBOL_GPL(puv3_pm_enter);
 68 
 69 unsigned long sleep_phys_sp(void *sp)
 70 {
 71         return virt_to_phys(sp);
 72 }
 73 
 74 static int puv3_pm_valid(suspend_state_t state)
 75 {
 76         if (puv3_cpu_pm_fns)
 77                 return puv3_cpu_pm_fns->valid(state);
 78 
 79         return -EINVAL;
 80 }
 81 
 82 static int puv3_pm_prepare(void)
 83 {
 84         int ret = 0;
 85 
 86         if (puv3_cpu_pm_fns && puv3_cpu_pm_fns->prepare)
 87                 ret = puv3_cpu_pm_fns->prepare();
 88 
 89         return ret;
 90 }
 91 
 92 static void puv3_pm_finish(void)
 93 {
 94         if (puv3_cpu_pm_fns && puv3_cpu_pm_fns->finish)
 95                 puv3_cpu_pm_fns->finish();
 96 }
 97 
 98 static struct platform_suspend_ops puv3_pm_ops = {
 99         .valid          = puv3_pm_valid,
100         .enter          = puv3_pm_enter,
101         .prepare        = puv3_pm_prepare,
102         .finish         = puv3_pm_finish,
103 };
104 
105 static int __init puv3_pm_init(void)
106 {
107         if (!puv3_cpu_pm_fns) {
108                 printk(KERN_ERR "no valid puv3_cpu_pm_fns defined\n");
109                 return -EINVAL;
110         }
111 
112         sleep_save = kmalloc(puv3_cpu_pm_fns->save_count
113                                 * sizeof(unsigned long), GFP_KERNEL);
114         if (!sleep_save) {
115                 printk(KERN_ERR "failed to alloc memory for pm save\n");
116                 return -ENOMEM;
117         }
118 
119         suspend_set_ops(&puv3_pm_ops);
120         return 0;
121 }
122 
123 device_initcall(puv3_pm_init);
124 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp