pm_direct.h revision 1.7 1 /* $NetBSD: pm_direct.h,v 1.7 2005/01/07 04:59:58 briggs Exp $ */
2
3 /*
4 * Copyright (C) 1997 Takashi Hamada
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Takashi Hamada.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 /* From: pm_direct.h 1.0 01/02/97 Takashi Hamada */
33
34 /*
35 * Public declarations that other routines may need.
36 */
37
38 /* data structure of the command of the Power Manager */
39 typedef struct {
40 short command; /* command of the Power Manager */
41 short num_data; /* number of data */
42 char *s_buf; /* pointer to buffer for sending */
43 char *r_buf; /* pointer to buffer for receiving */
44 char data[128]; /* data buffer (is it too much?) */
45 /* null command seen w/ 120 data bytes */
46 } PMData;
47
48 int pmgrop __P((PMData *));
49 void pm_adb_restart __P((void));
50 void pm_adb_poweroff __P((void));
51 void pm_read_date_time __P((u_long *));
52 void pm_set_date_time __P((u_long));
53
54 struct pmu_battery_info
55 {
56 unsigned int flags;
57 unsigned int cur_charge;
58 unsigned int max_charge;
59 signed int draw;
60 unsigned int voltage;
61 };
62
63 int pm_battery_info __P((int, struct pmu_battery_info *));
64
65 int pm_read_nvram __P((int));
66 void pm_write_nvram __P((int, int));
67 int pm_read_brightness __P((void));
68 void pm_set_brightness __P((int));
69 void pm_init_brightness __P((void));
70 void pm_eject_pcmcia __P((int));
71
72 /* PMU commands */
73 #define PMU_POWER_OFF 0x7e /* Turn Power off */
74 #define PMU_RESET_CPU 0xd0 /* Reset CPU */
75
76 #define PMU_SET_RTC 0x30 /* Set realtime clock */
77 #define PMU_READ_RTC 0x38 /* Read realtime clock */
78
79 #define PMU_WRITE_PRAM 0x32 /* Write PRAM */
80 #define PMU_READ_PRAM 0x3a /* Read PRAM */
81
82 #define PMU_WRITE_NVRAM 0x33 /* Write NVRAM */
83 #define PMU_READ_NVRAM 0x3b /* Read NVRAM */
84
85 #define PMU_EJECT_PCMCIA 0x4c /* Eject PCMCIA slot */
86
87 #define PMU_SET_BRIGHTNESS 0x41 /* Set backlight brightness */
88 #define PMU_READ_BRIGHTNESS 0xd9 /* Read brightness button position */
89
90 #define PMU_POWER_EVENTS 0x8f /* Send power-event commands to PMU */
91 #define PMU_SYSTEM_READY 0xdf /* tell PMU we are awake */
92
93 #define PMU_SMART_BATTERY_STATE 0x6f /* Read battery state */
94
95 /* Bits in PMU interrupt and interrupt mask bytes */
96 #define PMU_INT_ADB_AUTO 0x04 /* ADB autopoll, when PMU_INT_ADB */
97 #define PMU_INT_PCEJECT 0x04 /* PC-card eject buttons */
98 #define PMU_INT_SNDBRT 0x08 /* sound/brightness up/down buttons */
99 #define PMU_INT_ADB 0x10 /* ADB autopoll or reply data */
100 #define PMU_INT_BATTERY 0x20
101 #define PMU_INT_WAKEUP 0x40
102 #define PMU_INT_TICK 0x80 /* 1-second tick interrupt */
103
104 /* Bits to use with the PMU_POWER_CTRL0 command */
105 #define PMU_POW0_ON 0x80 /* OR this to power ON the device */
106 #define PMU_POW0_OFF 0x00 /* leave bit 7 to 0 to power it OFF */
107
108 /* Bits to use with the PMU_POWER_CTRL command */
109 #define PMU_POW_ON 0x80 /* OR this to power ON the device */
110 #define PMU_POW_OFF 0x00 /* leave bit 7 to 0 to power it OFF */
111 #define PMU_POW_BACKLIGHT 0x01 /* backlight power */
112 #define PMU_POW_CHARGER 0x02 /* battery charger power */
113 #define PMU_POW_IRLED 0x04 /* IR led power (on wallstreet) */
114 #define PMU_POW_MEDIABAY 0x08 /* media bay power (wallstreet/lombard ?) */
115
116 /* PMU PMU_POWER_EVENTS commands */
117 enum {
118 PMU_PWR_GET_POWERUP_EVENTS = 0x00,
119 PMU_PWR_SET_POWERUP_EVENTS = 0x01,
120 PMU_PWR_CLR_POWERUP_EVENTS = 0x02,
121 PMU_PWR_GET_WAKEUP_EVENTS = 0x03,
122 PMU_PWR_SET_WAKEUP_EVENTS = 0x04,
123 PMU_PWR_CLR_WAKEUP_EVENTS = 0x05,
124 };
125
126 /* PMU Power Information */
127
128 #define PMU_PWR_AC_PRESENT (1 << 0)
129 #define PMU_PWR_BATT_PRESENT (1 << 2)
130
131