Home | History | Annotate | Line # | Download | only in dev
pm_direct.h revision 1.6
      1 /*	$NetBSD: pm_direct.h,v 1.6 2002/06/18 05:22:51 itojun 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[32];	/* data buffer (is it too much?)	*/
     45 }	PMData;
     46 
     47 int pmgrop __P((PMData *));
     48 void pm_adb_restart __P((void));
     49 void pm_adb_poweroff __P((void));
     50 void pm_read_date_time __P((u_long *));
     51 void pm_set_date_time __P((u_long));
     52 
     53 struct pmu_battery_info
     54 {
     55 	unsigned int flags;
     56 	unsigned int cur_charge;
     57 	unsigned int max_charge;
     58 	signed   int draw;
     59 	unsigned int voltage;
     60 };
     61 
     62 int pm_battery_info __P((int, struct pmu_battery_info *));
     63 
     64 int pm_read_nvram __P((int));
     65 void pm_write_nvram __P((int, int));
     66 int pm_read_brightness __P((void));
     67 void pm_set_brightness __P((int));
     68 void pm_init_brightness __P((void));
     69 void pm_eject_pcmcia __P((int));
     70 
     71 /* PMU commands */
     72 #define PMU_POWER_OFF		0x7e	/* Turn Power off */
     73 #define PMU_RESET_CPU		0xd0	/* Reset CPU */
     74 
     75 #define PMU_SET_RTC		0x30	/* Set realtime clock */
     76 #define PMU_READ_RTC		0x38	/* Read realtime clock */
     77 
     78 #define PMU_WRITE_PRAM		0x32	/* Write PRAM */
     79 #define PMU_READ_PRAM		0x3a	/* Read PRAM */
     80 
     81 #define PMU_WRITE_NVRAM		0x33	/* Write NVRAM */
     82 #define PMU_READ_NVRAM		0x3b	/* Read NVRAM */
     83 
     84 #define PMU_EJECT_PCMCIA	0x4c	/* Eject PCMCIA slot */
     85 
     86 #define PMU_SET_BRIGHTNESS	0x41	/* Set backlight brightness */
     87 #define PMU_READ_BRIGHTNESS	0xd9	/* Read brightness button position */
     88 
     89 #define PMU_POWER_EVENTS        0x8f    /* Send power-event commands to PMU */
     90 #define PMU_SYSTEM_READY        0xdf    /* tell PMU we are awake */
     91 
     92 #define PMU_SMART_BATTERY_STATE	0x6f	/* Read battery state */
     93 
     94 /* Bits in PMU interrupt and interrupt mask bytes */
     95 #define PMU_INT_ADB_AUTO	0x04	/* ADB autopoll, when PMU_INT_ADB */
     96 #define PMU_INT_PCEJECT		0x04	/* PC-card eject buttons */
     97 #define PMU_INT_SNDBRT		0x08	/* sound/brightness up/down buttons */
     98 #define PMU_INT_ADB		0x10	/* ADB autopoll or reply data */
     99 #define PMU_INT_BATTERY		0x20
    100 #define PMU_INT_WAKEUP		0x40
    101 #define PMU_INT_TICK		0x80	/* 1-second tick interrupt */
    102 
    103 /* Bits to use with the PMU_POWER_CTRL0 command */
    104 #define PMU_POW0_ON		0x80	/* OR this to power ON the device */
    105 #define PMU_POW0_OFF		0x00	/* leave bit 7 to 0 to power it OFF */
    106 
    107 /* Bits to use with the PMU_POWER_CTRL command */
    108 #define PMU_POW_ON		0x80	/* OR this to power ON the device */
    109 #define PMU_POW_OFF		0x00	/* leave bit 7 to 0 to power it OFF */
    110 #define PMU_POW_BACKLIGHT	0x01	/* backlight power */
    111 #define PMU_POW_CHARGER		0x02	/* battery charger power */
    112 #define PMU_POW_IRLED		0x04	/* IR led power (on wallstreet) */
    113 #define PMU_POW_MEDIABAY	0x08	/* media bay power (wallstreet/lombard ?) */
    114 
    115 /* PMU PMU_POWER_EVENTS commands */
    116 enum {
    117 	PMU_PWR_GET_POWERUP_EVENTS      = 0x00,
    118 	PMU_PWR_SET_POWERUP_EVENTS      = 0x01,
    119 	PMU_PWR_CLR_POWERUP_EVENTS      = 0x02,
    120 	PMU_PWR_GET_WAKEUP_EVENTS       = 0x03,
    121 	PMU_PWR_SET_WAKEUP_EVENTS       = 0x04,
    122 	PMU_PWR_CLR_WAKEUP_EVENTS       = 0x05,
    123 };
    124 
    125 /* PMU Power Information */
    126 
    127 #define PMU_PWR_AC_PRESENT	(1 << 0)
    128 #define PMU_PWR_BATT_PRESENT	(1 << 2)
    129 
    130