2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * 12 Nov 1998 suurballe Created.
26 #include <IOKit/adb/IOADBController.h>
27 #include <IOKit/IODeviceTreeSupport.h>
28 #include <IOKit/IOPlatformExpert.h>
29 #include <IOKit/IOSyncer.h>
31 class IOPMUADBController
: public IOADBController
33 OSDeclareDefaultStructors(IOPMUADBController
)
38 kPMUInitError
= 1, // PMU failed to initialize
39 kPMUParameterError
= 2, // Bad parameters
40 kPMUNotSupported
= 3, // PMU don't do that (Cuda does, though)
41 kPMUIOError
= 4 // Nonspecific I/O failure
45 kPMUpMgrADB
= 0x20, // send ADB command
46 kPMUpMgrADBoff
= 0x21, // turn ADB auto-poll off
47 kPMUreadADB
= 0x28, // Apple Desktop Bus
48 kPMUpMgrADBInt
= 0x2F, // get ADB interrupt data (Portable only)
52 kPMUADBAddressField
= 4
56 kPMUResetADBBus
= 0x00,
63 enum { // when kPMUADBint is set
65 kPMUenvironmentInt
= 0x40, // Environment changed (clamshell)
66 kPMUwaitinglsc
= 0x01, // waiting to listen to charger
67 kPMUautoSRQpolling
= 0x02, // auto/SRQ polling is enabled
68 kPMUautopoll
= 0x04 // input is autopoll data
71 // We need this to callPlatformFunction when sending to sendMiscCommand
72 typedef struct SendMiscCommandParameterBlock
{
78 } SendMiscCommandParameterBlock
;
79 typedef SendMiscCommandParameterBlock
*SendMiscCommandParameterBlockPtr
;
83 UInt32 pollList
; // ADB autopoll device bitmap
84 bool autopollOn
; // TRUE: PMU is autopolling
85 bool clamshellOpen
; // Normally TRUE
87 UInt32 dataLen
; // data len as result of an interrupt
88 UInt8 dataBuffer
[256]; // data as result of an interrupt
89 IOSyncer
*waitingForData
; // syncronizer for reads and writes.
91 // Local interrupt handlers:
92 static void handleADBInterrupt(IOService
*client
, UInt8 matchingMask
, UInt32 length
, UInt8
*buffer
);
94 // This lock protects the access to the common varialbes of this object:
95 IOLock
*requestMutexLock
;
97 // A simpler way to interface with the pmu SendMiscCommand
98 IOReturn
localSendMiscCommand(int command
, IOByteCount sLength
, UInt8
*sBuffer
);
101 IOService
*probe( IOService
* nub
, SInt32
* score
);
102 bool start ( IOService
* );
104 IOReturn
setAutoPollPeriod ( int microseconds
);
105 IOReturn
getAutoPollPeriod ( int * microseconds
);
106 IOReturn
setAutoPollList ( UInt16 activeAddressMask
);
107 IOReturn
getAutoPollList ( UInt16
* activeAddressMask
);
108 IOReturn
setAutoPollEnable ( bool enable
);
109 IOReturn
resetBus ( void );
110 IOReturn
cancelAllIO ( void );
111 IOReturn
flushDevice ( IOADBAddress address
);
112 IOReturn
readFromDevice ( IOADBAddress address
, IOADBRegister adbRegister
, UInt8
* data
, IOByteCount
* length
);
113 IOReturn
writeToDevice ( IOADBAddress address
, IOADBRegister adbRegister
, UInt8
* data
, IOByteCount
* length
);