Annotation of XNU/iokit/Drivers/platform/drvApplePMU/pmupriv.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: #ifdef __cplusplus
                     23: 
                     24: #include <IOKit/IOService.h>
                     25: #include <IOKit/IOLocks.h>
                     26: #include <IOKit/IOTypes.h>
                     27: #include <IOKit/adb/adb.h>
                     28: #include "pmu.h"
                     29: 
                     30: extern "C" {
                     31: #include <pexpert/pexpert.h>
                     32: }
                     33: 
                     34: class IOSyncer;
                     35: class IOPMUADBController;
                     36: class IOPMUNVRAMController;
                     37: class IOPMURTCController;
                     38: /*
                     39: class IOPMUPwrController;
                     40: */
                     41: 
                     42: #else
                     43: 
                     44: #include <IOKit/IODevice.h>
                     45: #include <IOKit/adb/IOADBController.h>
                     46: 
                     47: #endif
                     48: 
                     49: #include <IOKit/IOInterruptEventSource.h>
                     50: #include <IOKit/IOWorkLoop.h>
                     51: #include <IOKit/IOCommandQueue.h>
                     52: #include "pmumisc.h"
                     53: 
                     54:         typedef volatile unsigned char  *VIAAddress;   // This is an address on the bus
                     55: 
                     56: // **********************************************************************************
                     57: //
                     58: // VIA definitions
                     59: //
                     60: // **********************************************************************************
                     61: 
                     62: enum {                                 // port B
                     63:                                                // M2 uses VIA2
                     64:        M2Req           = 2,                            // Power manager handshake request
                     65:        M2Ack           = 1,                            // Power manager handshake acknowledge
                     66:                                                // Hooper uses VIA1
                     67:        HooperReq       = 4,                            // request
                     68:        HooperAck       = 3                             // acknowledge
                     69: };
                     70: 
                     71: enum {                                 // IFR/IER
                     72:        ifCA2 = 0,                              // CA2 interrupt
                     73:        ifCA1 = 1,                              // CA1 interrupt
                     74:        ifSR  = 2,                              // SR shift register done
                     75:        ifCB2 = 3,                              // CB2 interrupt
                     76:        ifCB1 = 4,                              // CB1 interrupt
                     77:        ifT2  = 5,                              // T2 timer2 interrupt
                     78:        ifT1  = 6,                              // T1 timer1 interrupt
                     79:        ifIRQ = 7                               // any interrupt
                     80: };
                     81: 
                     82: // **********************************************************************************
                     83: // bits in response to kPMUReadInt command
                     84: // **********************************************************************************
                     85: 
                     86: enum {
                     87:        kPMUMD0Int              = 0x01,   // interrupt type 0 (machine-specific)
                     88:        kPMUMD1Int              = 0x02,   // interrupt type 1 (machine-specific)
                     89:        kPMUMD2Int              = 0x04,   // interrupt type 2 (machine-specific)
                     90:        kPMUbrightnessInt       = 0x08,   // brightness button has been pressed, value changed
                     91:        kPMUADBint              = 0x10,   // ADB
                     92:        kPMUbattInt             = 0x20,   // battery
                     93:        kPMUenvironmentInt      = 0x40,   // environment
                     94:        kPMUoneSecInt           = 0x80    // one second interrupt
                     95: };
                     96: 
                     97: enum {                                 // when kPMUADBint is set
                     98:        kPMUautopoll            = 0x04          // input is autopoll data
                     99: };
                    100: 
                    101: // **********************************************************************************
                    102: // states of the ISR
                    103: // **********************************************************************************
                    104: 
                    105: enum {
                    106:        kPMUidle,
                    107:        kPMUxmtLen,
                    108:        kPMUxmtData,
                    109:        kPMUreadLen_cmd,
                    110:        kPMUrcvLen_cmd,
                    111:        kPMUreadData,
                    112:        kPMUrcvData_cmd,
                    113:        kPMUdone,
                    114:        kPMUreadLen_int,
                    115:        kPMUrcvLen_int,
                    116:        kPMUrcvData_int
                    117: };
                    118: 
                    119: 
                    120: enum {
                    121:        kPMUADBAddressField = 4
                    122: };
                    123: 
                    124: enum {
                    125:        kPMUResetADBBus = 0x00,
                    126:        kPMUFlushADB            = 0x01,
                    127:        kPMUWriteADB            = 0x08,
                    128:        kPMUReadADB             = 0x0C,
                    129:        kPMURWMaskADB   = 0x0C
                    130: };
                    131: 
                    132: #define MISC_LENGTH 8
                    133: 
                    134: 
                    135: struct PMUrequest {
                    136:     UInt32             pmCommand;
                    137:     UInt32             pmSLength1;
                    138:     UInt8 *            pmSBuffer2;
                    139:     UInt32             pmSLength2;
                    140:     UInt8 *            pmRBuffer;
                    141:     UInt32             pmRLength;
                    142:     bool               pmFlag;
                    143:     UInt8              pmSBuffer1[MISC_LENGTH];
                    144:     struct PMUrequest *        next;
                    145:     struct PMUrequest *        prev;
                    146:     IOSyncer *         sync;
                    147: };
                    148: 
                    149: typedef struct PMUrequest PMUrequest;
                    150: 
                    151: 
                    152: class ApplePMU : IOService
                    153: {
                    154: OSDeclareDefaultStructors(ApplePMU)
                    155: 
                    156: public:
                    157:                                        // this stuff is public for the c-functions in the driver
                    158: //    IOInterruptEventSource * SRintEventSrc;
                    159: IOInterruptEventSource * cmdDoneEventSrc;
                    160: IOInterruptEventSource * unsolicitedEventSrc;
                    161: IOInterruptEventSource * PMUintEventSrc;
                    162: UInt32         PGE_ISR_state;
                    163: VIAAddress     VIA1_shift;             // pointers to VIA registers
                    164: VIAAddress     VIA1_auxillaryControl;
                    165: VIAAddress     VIA2_dataB;
                    166: UInt8          PMreq;                  // req bit
                    167: UInt8          PMack;                  // ack bit
                    168: UInt8          interruptState[12];
                    169: UInt8          receivedByte;
                    170: SInt32         charCountR;
                    171: SInt32         charCountR2;
                    172: UInt32         charCountS1;
                    173: UInt32         charCountS2;
                    174: UInt8 *                dataPointer;
                    175: UInt8 *                dataPointer1;
                    176: UInt8 *                dataPointer2;
                    177: PMUrequest *   clientRequest;
                    178: PMUrequest *    queueHead;             // our command queue
                    179: PMUrequest *   queueTail;
                    180: bool           adb_reading;            // TRUE: we have a register read outstanding
                    181: bool           PMU_int_pending;        // TRUE: PMU has requested service
                    182: pmCallback_func        RTCclient;              // Tick handler in RTC client
                    183: IOPMURTCController *   ourRTCinterface;
                    184: 
                    185: 
                    186: private:
                    187: 
                    188: IOWorkLoop *           workLoop;
                    189: IOCommandQueue *       commandQueue;
                    190: IOPMUADBController *   ourADBinterface;
                    191: IOPMUNVRAMController * ourNVRAMinterface;
                    192: /*
                    193: IOPMUPwrController *   ourPwrinterface;
                    194: */
                    195:                // pointers to VIA registers
                    196: VIAAddress     VIA1_interruptFlag;
                    197: VIAAddress     VIA1_interruptEnable;
                    198: UInt8          savedPGEintEn;
                    199: UInt8          savedSRintEn;
                    200: ADB_callback_func ADBclient;           // autopoll handler in ADB client
                    201: IOService *    ADBid;                  // pointer to ADB client
                    202: IOService *    RTCid;                  // pointer to RTC client
                    203: pmCallback_func        PWRclient;              // Button handler in Power Management client
                    204: IOService *    PWRid;                  // pointer to Power Management client
                    205: UInt8          firstChar;
                    206: mach_timespec_t        adb_read_timeout;       // timeout on read to absent adb device
                    207: AbsoluteTime   SR_to_ack_transition_delay;
                    208: 
                    209: void timeoutOccurred ( void );
                    210: void DisablePMUInterrupt ( void );
                    211: void EnablePMUInterrupt ( void );
                    212: void AcknowledgePMUInterrupt ( void );
                    213: void DisableSRInterrupt ( void );
                    214: void EnableSRInterrupt ( void );
                    215: static bool serializeBatteryInfo( void * target, void * ref, OSSerialize * s );
                    216: 
                    217: protected:
                    218: virtual void free ( void );
                    219: 
                    220: 
                    221: public:
                    222: 
                    223: bool init ( OSDictionary * properties = 0 );
                    224: bool start ( IOService * );
                    225: virtual IOWorkLoop *getWorkLoop() const;
                    226: 
                    227: //void poll_device ( void );
                    228: void enqueueCommand ( PMUrequest * theRequest );
                    229: void registerForADBInterrupts ( ADB_callback_func client, IOService * caller );
                    230: void registerForPowerInterrupts ( pmCallback_func buttonHandler, IOService * caller );
                    231: void registerForClockInterrupts ( pmCallback_func tickHandler, IOService * caller );
                    232: IOReturn sendMiscCommand ( UInt32 Command, IOByteCount  SLength,
                    233:                        UInt8 * SBuffer, IOByteCount * RLength, UInt8 * RBuffer );
                    234: //void serviceShiftRegister ( void );
                    235: void servicePMU ( void );
                    236: void StartPMUTransmission ( PMUrequest * plugInMessage );
                    237: void CheckRequestQueue ( void );
                    238: void ADBinput ( UInt32 theLength, UInt8 * theInput );
                    239: void buttonInput ( UInt32 theLength, UInt8 * theInput );
                    240: bool WaitForAckHi ( void );
                    241: bool WaitForAckLo( void );
                    242: 
                    243: };
                    244: 
                    245: 
                    246: 
                    247: 
                    248: 
                    249: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.