home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Include / Linux / pm.h < prev    next >
C/C++ Source or Header  |  2002-04-26  |  5KB  |  246 lines

  1. /* $Id: pm.h,v 1.2 2002/04/26 23:09:14 smilcke Exp $ */
  2.  
  3. /*
  4.  *  pm.h - Power management interface
  5.  *
  6.  *  Copyright (C) 2000 Andrew Henroid
  7.  *
  8.  *  This program is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2 of the License, or
  11.  *  (at your option) any later version.
  12.  *
  13.  *  This program is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with this program; if not, write to the Free Software
  20.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  */
  22.  
  23. #ifndef _LINUX_PM_H
  24. #define _LINUX_PM_H
  25.  
  26. #ifdef __KERNEL__
  27.  
  28. #include <linux/config.h>
  29. #include <linux/list.h>
  30.  
  31. /*
  32.  * Power management requests
  33.  */
  34. enum
  35. {
  36.     PM_SUSPEND, /* enter D1-D3 */
  37.     PM_RESUME,  /* enter D0 */
  38.  
  39.     PM_SAVE_STATE,  /* save device's state */
  40.  
  41.     /* enable wake-on */
  42.     PM_SET_WAKEUP,
  43.  
  44.     /* bus resource management */
  45.     PM_GET_RESOURCES,
  46.     PM_SET_RESOURCES,
  47.  
  48.     /* base station management */
  49.     PM_EJECT,
  50.     PM_LOCK,
  51. };
  52.  
  53. typedef int pm_request_t;
  54.  
  55. /*
  56.  * Device types
  57.  */
  58. enum
  59. {
  60.     PM_UNKNOWN_DEV = 0, /* generic */
  61.     PM_SYS_DEV,        /* system device (fan, KB controller, ...) */
  62.     PM_PCI_DEV,        /* PCI device */
  63.     PM_USB_DEV,        /* USB device */
  64.     PM_SCSI_DEV,        /* SCSI device */
  65.     PM_ISA_DEV,        /* ISA device */
  66.     PM_MTD_DEV,        /* Memory Technology Device */
  67. };
  68.  
  69. typedef int pm_dev_t;
  70.  
  71. /*
  72.  * System device hardware ID (PnP) values
  73.  */
  74. enum
  75. {
  76.     PM_SYS_UNKNOWN = 0x00000000, /* generic */
  77.     PM_SYS_KBC =     0x41d00303, /* keyboard controller */
  78.     PM_SYS_COM =     0x41d00500, /* serial port */
  79.     PM_SYS_IRDA =     0x41d00510, /* IRDA controller */
  80.     PM_SYS_FDC =     0x41d00700, /* floppy controller */
  81.     PM_SYS_VGA =     0x41d00900, /* VGA controller */
  82.     PM_SYS_PCMCIA =     0x41d00e00, /* PCMCIA controller */
  83. };
  84.  
  85. /*
  86.  * Device identifier
  87.  */
  88. #define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
  89.  
  90. /*
  91.  * Request handler callback
  92.  */
  93. struct pm_dev;
  94.  
  95. typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
  96.  
  97. /*
  98.  * Dynamic device information
  99.  */
  100. struct pm_dev
  101. {
  102.     pm_dev_t     type;
  103.     unsigned long     id;
  104.     pm_callback     callback;
  105.     void        *data;
  106.  
  107.     unsigned long     flags;
  108.     int         state;
  109.     int         prev_state;
  110.  
  111.     struct list_head entry;
  112. };
  113.  
  114. #ifdef CONFIG_PM
  115.  
  116. extern int pm_active;
  117.  
  118. #define PM_IS_ACTIVE() (pm_active != 0)
  119.  
  120. /*
  121.  * Register a device with power management
  122.  */
  123. struct pm_dev *pm_register(pm_dev_t type,
  124.                unsigned long id,
  125.                pm_callback callback);
  126.  
  127. /*
  128.  * Unregister a device with power management
  129.  */
  130. void pm_unregister(struct pm_dev *dev);
  131.  
  132. /*
  133.  * Unregister all devices with matching callback
  134.  */
  135. void pm_unregister_all(pm_callback callback);
  136.  
  137. /*
  138.  * Send a request to a single device
  139.  */
  140. int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
  141.  
  142. /*
  143.  * Send a request to all devices
  144.  */
  145. int pm_send_all(pm_request_t rqst, void *data);
  146.  
  147. /*
  148.  * Find a device
  149.  */
  150. struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from);
  151.  
  152. #ifdef TARGET_OS2
  153. static __inline__
  154. #else
  155. static inline
  156. #endif
  157. void pm_access(struct pm_dev *dev) {}
  158. #ifdef TARGET_OS2
  159. static __inline__
  160. #else
  161. static inline
  162. #endif
  163. void pm_dev_idle(struct pm_dev *dev) {}
  164.  
  165. #else /* CONFIG_PM */
  166.  
  167. #define PM_IS_ACTIVE() 0
  168.  
  169. #ifdef TARGET_OS2
  170. static __inline__
  171. #else
  172. static inline
  173. #endif
  174. struct pm_dev *pm_register(pm_dev_t type,
  175.                      unsigned long id,
  176.                      pm_callback callback)
  177. {
  178.     return 0;
  179. }
  180.  
  181. #ifdef TARGET_OS2
  182. static __inline__
  183. #else
  184. static inline
  185. #endif
  186. void pm_unregister(struct pm_dev *dev) {}
  187.  
  188. #ifdef TARGET_OS2
  189. static __inline__
  190. #else
  191. static inline
  192. #endif
  193. void pm_unregister_all(pm_callback callback) {}
  194.  
  195. #ifdef TARGET_OS2
  196. static __inline__
  197. #else
  198. static inline
  199. #endif
  200. int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
  201. {
  202.     return 0;
  203. }
  204.  
  205. #ifdef TARGET_OS2
  206. static __inline__
  207. #else
  208. static inline
  209. #endif
  210. int pm_send_all(pm_request_t rqst, void *data)
  211. {
  212.     return 0;
  213. }
  214.  
  215. #ifdef TARGET_OS2
  216. static __inline__
  217. #else
  218. static inline
  219. #endif
  220. struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
  221. {
  222.     return 0;
  223. }
  224.  
  225. #ifdef TARGET_OS2
  226. static __inline__
  227. #else
  228. static inline
  229. #endif
  230. void pm_access(struct pm_dev *dev) {}
  231. #ifdef TARGET_OS2
  232. static __inline__
  233. #else
  234. static inline
  235. #endif
  236. void pm_dev_idle(struct pm_dev *dev) {}
  237.  
  238. #endif /* CONFIG_PM */
  239.  
  240. extern void (*pm_idle)(void);
  241. extern void (*pm_power_off)(void);
  242.  
  243. #endif /* __KERNEL__ */
  244.  
  245. #endif /* _LINUX_PM_H */
  246.