]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | /* | |
23 | * 12 Nov 1998 suurballe Created. | |
24 | */ | |
25 | ||
26 | #include <IOKit/adb/IOADBController.h> | |
27 | #include <IOKit/IODeviceTreeSupport.h> | |
28 | #include <IOKit/IOPlatformExpert.h> | |
29 | #include <IOKit/IOSyncer.h> | |
30 | ||
31 | class IOPMUADBController : public IOADBController | |
32 | { | |
33 | OSDeclareDefaultStructors(IOPMUADBController) | |
34 | ||
35 | private: | |
36 | enum { | |
37 | kPMUNoError = 0, | |
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 | |
42 | }; | |
43 | ||
44 | enum { | |
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) | |
49 | }; | |
50 | ||
51 | enum { | |
52 | kPMUADBAddressField = 4 | |
53 | }; | |
54 | ||
55 | enum { | |
56 | kPMUResetADBBus = 0x00, | |
57 | kPMUFlushADB = 0x01, | |
58 | kPMUWriteADB = 0x08, | |
59 | kPMUReadADB = 0x0C, | |
60 | kPMURWMaskADB = 0x0C | |
61 | }; | |
62 | ||
63 | enum { // when kPMUADBint is set | |
64 | kPMUADBint = 0x10, | |
65 | kPMUwaitinglsc = 0x01, // waiting to listen to charger | |
66 | kPMUautoSRQpolling = 0x02, // auto/SRQ polling is enabled | |
67 | kPMUautopoll = 0x04 // input is autopoll data | |
68 | }; | |
69 | ||
70 | // We need this to callPlatformFunction when sending to sendMiscCommand | |
71 | typedef struct SendMiscCommandParameterBlock { | |
72 | int command; | |
73 | IOByteCount sLength; | |
74 | UInt8 *sBuffer; | |
75 | IOByteCount *rLength; | |
76 | UInt8 *rBuffer; | |
77 | } SendMiscCommandParameterBlock; | |
78 | typedef SendMiscCommandParameterBlock *SendMiscCommandParameterBlockPtr; | |
79 | ||
80 | // Local data: | |
81 | IOService *PMUdriver; | |
82 | UInt32 pollList; // ADB autopoll device bitmap | |
83 | bool autopollOn; // TRUE: PMU is autopolling | |
84 | ||
85 | UInt32 dataLen; // data len as result of an interrupt | |
86 | UInt8 dataBuffer[256]; // data as result of an interrupt | |
87 | IOSyncer *waitingForData; // syncronizer for reads and writes. | |
88 | ||
89 | // Local interrupt handlers: | |
90 | static void handleADBInterrupt(IOService *client, UInt8 matchingMask, UInt32 length, UInt8 *buffer); | |
91 | ||
92 | // This lock protects the access to the common varialbes of this object: | |
93 | IOLock *requestMutexLock; | |
94 | ||
95 | // A simpler way to interface with the pmu SendMiscCommand | |
0b4e3aa0 | 96 | IOReturn localSendMiscCommand(int command, IOByteCount sLength, UInt8 *sBuffer); |
1c79356b A |
97 | |
98 | public: | |
99 | IOService *probe( IOService * nub, SInt32 * score ); | |
100 | bool start ( IOService * ); | |
101 | void free (); | |
102 | IOReturn setAutoPollPeriod ( int microseconds ); | |
103 | IOReturn getAutoPollPeriod ( int * microseconds ); | |
104 | IOReturn setAutoPollList ( UInt16 activeAddressMask ); | |
105 | IOReturn getAutoPollList ( UInt16 * activeAddressMask ); | |
106 | IOReturn setAutoPollEnable ( bool enable ); | |
107 | IOReturn resetBus ( void ); | |
0b4e3aa0 | 108 | IOReturn cancelAllIO ( void ); |
1c79356b A |
109 | IOReturn flushDevice ( IOADBAddress address ); |
110 | IOReturn readFromDevice ( IOADBAddress address, IOADBRegister adbRegister, UInt8 * data, IOByteCount * length ); | |
111 | IOReturn writeToDevice ( IOADBAddress address, IOADBRegister adbRegister, UInt8 * data, IOByteCount * length ); | |
112 | }; |