2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * 12 Nov 1998 suurballe Created.
29 #include <IOKit/adb/IOADBController.h>
30 #include <IOKit/IODeviceTreeSupport.h>
31 #include <IOKit/IOPlatformExpert.h>
32 #include <IOKit/IOSyncer.h>
34 class IOPMUADBController
: public IOADBController
36 OSDeclareDefaultStructors(IOPMUADBController
)
41 kPMUInitError
= 1, // PMU failed to initialize
42 kPMUParameterError
= 2, // Bad parameters
43 kPMUNotSupported
= 3, // PMU don't do that (Cuda does, though)
44 kPMUIOError
= 4 // Nonspecific I/O failure
48 kPMUpMgrADB
= 0x20, // send ADB command
49 kPMUpMgrADBoff
= 0x21, // turn ADB auto-poll off
50 kPMUreadADB
= 0x28, // Apple Desktop Bus
51 kPMUpMgrADBInt
= 0x2F, // get ADB interrupt data (Portable only)
55 kPMUADBAddressField
= 4
59 kPMUResetADBBus
= 0x00,
66 enum { // when kPMUADBint is set
68 kPMUenvironmentInt
= 0x40, // Environment changed (clamshell)
69 kPMUwaitinglsc
= 0x01, // waiting to listen to charger
70 kPMUautoSRQpolling
= 0x02, // auto/SRQ polling is enabled
71 kPMUautopoll
= 0x04 // input is autopoll data
74 // We need this to callPlatformFunction when sending to sendMiscCommand
75 typedef struct SendMiscCommandParameterBlock
{
81 } SendMiscCommandParameterBlock
;
82 typedef SendMiscCommandParameterBlock
*SendMiscCommandParameterBlockPtr
;
86 UInt32 pollList
; // ADB autopoll device bitmap
87 bool autopollOn
; // TRUE: PMU is autopolling
88 bool clamshellOpen
; // Normally TRUE
90 UInt32 dataLen
; // data len as result of an interrupt
91 UInt8 dataBuffer
[256]; // data as result of an interrupt
92 IOSyncer
*waitingForData
; // syncronizer for reads and writes.
94 // Local interrupt handlers:
95 static void handleADBInterrupt(IOService
*client
, UInt8 matchingMask
, UInt32 length
, UInt8
*buffer
);
97 // This lock protects the access to the common varialbes of this object:
98 IOLock
*requestMutexLock
;
100 // A simpler way to interface with the pmu SendMiscCommand
101 IOReturn
localSendMiscCommand(int command
, IOByteCount sLength
, UInt8
*sBuffer
);
104 IOService
*probe( IOService
* nub
, SInt32
* score
);
105 bool start ( IOService
* );
107 IOReturn
setAutoPollPeriod ( int microseconds
);
108 IOReturn
getAutoPollPeriod ( int * microseconds
);
109 IOReturn
setAutoPollList ( UInt16 activeAddressMask
);
110 IOReturn
getAutoPollList ( UInt16
* activeAddressMask
);
111 IOReturn
setAutoPollEnable ( bool enable
);
112 IOReturn
resetBus ( void );
113 IOReturn
cancelAllIO ( void );
114 IOReturn
flushDevice ( IOADBAddress address
);
115 IOReturn
readFromDevice ( IOADBAddress address
, IOADBRegister adbRegister
, UInt8
* data
, IOByteCount
* length
);
116 IOReturn
writeToDevice ( IOADBAddress address
, IOADBRegister adbRegister
, UInt8
* data
, IOByteCount
* length
);