Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * Definitions for talking to the PMU.  The PMU is a microcontroller
0004  * which controls battery charging and system power on PowerBook 3400
0005  * and 2400 models as well as the RTC and various other things.
0006  *
0007  * Copyright (C) 1998 Paul Mackerras.
0008  */
0009 
0010 #ifndef _UAPI_LINUX_PMU_H
0011 #define _UAPI_LINUX_PMU_H
0012 
0013 #define PMU_DRIVER_VERSION  2
0014 
0015 /*
0016  * PMU commands
0017  */
0018 #define PMU_POWER_CTRL0     0x10    /* control power of some devices */
0019 #define PMU_POWER_CTRL      0x11    /* control power of some devices */
0020 #define PMU_ADB_CMD     0x20    /* send ADB packet */
0021 #define PMU_ADB_POLL_OFF    0x21    /* disable ADB auto-poll */
0022 #define PMU_WRITE_XPRAM     0x32    /* write eXtended Parameter RAM */
0023 #define PMU_WRITE_NVRAM     0x33    /* write non-volatile RAM */
0024 #define PMU_READ_XPRAM      0x3a    /* read eXtended Parameter RAM */
0025 #define PMU_READ_NVRAM      0x3b    /* read non-volatile RAM */
0026 #define PMU_SET_RTC     0x30    /* set real-time clock */
0027 #define PMU_READ_RTC        0x38    /* read real-time clock */
0028 #define PMU_SET_VOLBUTTON   0x40    /* set volume up/down position */
0029 #define PMU_BACKLIGHT_BRIGHT    0x41    /* set backlight brightness */
0030 #define PMU_GET_VOLBUTTON   0x48    /* get volume up/down position */
0031 #define PMU_PCEJECT     0x4c    /* eject PC-card from slot */
0032 #define PMU_BATTERY_STATE   0x6b    /* report battery state etc. */
0033 #define PMU_SMART_BATTERY_STATE 0x6f    /* report battery state (new way) */
0034 #define PMU_SET_INTR_MASK   0x70    /* set PMU interrupt mask */
0035 #define PMU_INT_ACK     0x78    /* read interrupt bits */
0036 #define PMU_SHUTDOWN        0x7e    /* turn power off */
0037 #define PMU_CPU_SPEED       0x7d    /* control CPU speed on some models */
0038 #define PMU_SLEEP       0x7f    /* put CPU to sleep */
0039 #define PMU_POWER_EVENTS    0x8f    /* Send power-event commands to PMU */
0040 #define PMU_I2C_CMD     0x9a    /* I2C operations */
0041 #define PMU_RESET       0xd0    /* reset CPU */
0042 #define PMU_GET_BRIGHTBUTTON    0xd9    /* report brightness up/down pos */
0043 #define PMU_GET_COVER       0xdc    /* report cover open/closed */
0044 #define PMU_SYSTEM_READY    0xdf    /* tell PMU we are awake */
0045 #define PMU_GET_VERSION     0xea    /* read the PMU version */
0046 
0047 /* Bits to use with the PMU_POWER_CTRL0 command */
0048 #define PMU_POW0_ON     0x80    /* OR this to power ON the device */
0049 #define PMU_POW0_OFF        0x00    /* leave bit 7 to 0 to power it OFF */
0050 #define PMU_POW0_HARD_DRIVE 0x04    /* Hard drive power (on wallstreet/lombard ?) */
0051 
0052 /* Bits to use with the PMU_POWER_CTRL command */
0053 #define PMU_POW_ON      0x80    /* OR this to power ON the device */
0054 #define PMU_POW_OFF     0x00    /* leave bit 7 to 0 to power it OFF */
0055 #define PMU_POW_BACKLIGHT   0x01    /* backlight power */
0056 #define PMU_POW_CHARGER     0x02    /* battery charger power */
0057 #define PMU_POW_IRLED       0x04    /* IR led power (on wallstreet) */
0058 #define PMU_POW_MEDIABAY    0x08    /* media bay power (wallstreet/lombard ?) */
0059 
0060 /* Bits in PMU interrupt and interrupt mask bytes */
0061 #define PMU_INT_PCEJECT     0x04    /* PC-card eject buttons */
0062 #define PMU_INT_SNDBRT      0x08    /* sound/brightness up/down buttons */
0063 #define PMU_INT_ADB     0x10    /* ADB autopoll or reply data */
0064 #define PMU_INT_BATTERY     0x20    /* Battery state change */
0065 #define PMU_INT_ENVIRONMENT 0x40    /* Environment interrupts */
0066 #define PMU_INT_TICK        0x80    /* 1-second tick interrupt */
0067 
0068 /* Other bits in PMU interrupt valid when PMU_INT_ADB is set */
0069 #define PMU_INT_ADB_AUTO    0x04    /* ADB autopoll, when PMU_INT_ADB */
0070 #define PMU_INT_WAITING_CHARGER 0x01    /* ??? */
0071 #define PMU_INT_AUTO_SRQ_POLL   0x02    /* ??? */
0072 
0073 /* Bits in the environement message (either obtained via PMU_GET_COVER,
0074  * or via PMU_INT_ENVIRONMENT on core99 */
0075 #define PMU_ENV_LID_CLOSED  0x01    /* The lid is closed */
0076 
0077 /* I2C related definitions */
0078 #define PMU_I2C_MODE_SIMPLE 0
0079 #define PMU_I2C_MODE_STDSUB 1
0080 #define PMU_I2C_MODE_COMBINED   2
0081 
0082 #define PMU_I2C_BUS_STATUS  0
0083 #define PMU_I2C_BUS_SYSCLK  1
0084 #define PMU_I2C_BUS_POWER   2
0085 
0086 #define PMU_I2C_STATUS_OK   0
0087 #define PMU_I2C_STATUS_DATAREAD 1
0088 #define PMU_I2C_STATUS_BUSY 0xfe
0089 
0090 
0091 /* Kind of PMU (model) */
0092 enum {
0093     PMU_UNKNOWN,
0094     PMU_OHARE_BASED,    /* 2400, 3400, 3500 (old G3 powerbook) */
0095     PMU_HEATHROW_BASED, /* PowerBook G3 series */
0096     PMU_PADDINGTON_BASED,   /* 1999 PowerBook G3 */
0097     PMU_KEYLARGO_BASED, /* Core99 motherboard (PMU99) */
0098     PMU_68K_V1,     /* Unused/deprecated */
0099     PMU_68K_V2,     /* Unused/deprecated */
0100 };
0101 
0102 /* PMU PMU_POWER_EVENTS commands */
0103 enum {
0104     PMU_PWR_GET_POWERUP_EVENTS  = 0x00,
0105     PMU_PWR_SET_POWERUP_EVENTS  = 0x01,
0106     PMU_PWR_CLR_POWERUP_EVENTS  = 0x02,
0107     PMU_PWR_GET_WAKEUP_EVENTS   = 0x03,
0108     PMU_PWR_SET_WAKEUP_EVENTS   = 0x04,
0109     PMU_PWR_CLR_WAKEUP_EVENTS   = 0x05,
0110 };
0111 
0112 /* Power events wakeup bits */
0113 enum {
0114     PMU_PWR_WAKEUP_KEY      = 0x01, /* Wake on key press */
0115     PMU_PWR_WAKEUP_AC_INSERT    = 0x02, /* Wake on AC adapter plug */
0116     PMU_PWR_WAKEUP_AC_CHANGE    = 0x04,
0117     PMU_PWR_WAKEUP_LID_OPEN     = 0x08,
0118     PMU_PWR_WAKEUP_RING     = 0x10,
0119 };
0120     
0121 /*
0122  * Ioctl commands for the /dev/pmu device
0123  */
0124 #include <linux/ioctl.h>
0125 
0126 /* no param */
0127 #define PMU_IOC_SLEEP       _IO('B', 0)
0128 /* out param: u32*  backlight value: 0 to 15 */
0129 #define PMU_IOC_GET_BACKLIGHT   _IOR('B', 1, size_t)
0130 /* in param: u32    backlight value: 0 to 15 */
0131 #define PMU_IOC_SET_BACKLIGHT   _IOW('B', 2, size_t)
0132 /* out param: u32*  PMU model */
0133 #define PMU_IOC_GET_MODEL   _IOR('B', 3, size_t)
0134 /* out param: u32*  has_adb: 0 or 1 */
0135 #define PMU_IOC_HAS_ADB     _IOR('B', 4, size_t) 
0136 /* out param: u32*  can_sleep: 0 or 1 */
0137 #define PMU_IOC_CAN_SLEEP   _IOR('B', 5, size_t) 
0138 /* no param, but historically was _IOR('B', 6, 0), meaning 4 bytes */
0139 #define PMU_IOC_GRAB_BACKLIGHT  _IOR('B', 6, size_t) 
0140 
0141 
0142 #endif /* _UAPI_LINUX_PMU_H */