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 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
30 #include <machine/machine_routines.h>
33 #include <IOKit/pwr_mgt/RootDomain.h>
35 #include <IOKit/IODeviceTreeSupport.h>
36 //#include <IOKit/ata/IOATAStandardInterface.h>
40 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
42 #define super ApplePlatformExpert
44 OSDefineMetaClassAndStructors(GossamerPE
, ApplePlatformExpert
);
46 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
48 bool GossamerPE::start(IOService
*provider
)
54 setChipSetType(kChipSetTypeGossamer
);
56 // Set the machine type.
57 if (IODTMatchNubWithKeys(provider
, "'AAPL,Gossamer'"))
58 machineType
= kGossamerTypeGossamer
;
59 else if (IODTMatchNubWithKeys(provider
, "'AAPL,PowerMac G3'"))
60 machineType
= kGossamerTypeSilk
;
61 else if (IODTMatchNubWithKeys(provider
, "'AAPL,PowerBook1998'"))
62 machineType
= kGossamerTypeWallstreet
;
63 else if (IODTMatchNubWithKeys(provider
, "'iMac,1'"))
64 machineType
= kGossamerTypeiMac
;
65 else if (IODTMatchNubWithKeys(provider
, "('PowerMac1,1', 'PowerMac1,2')"))
66 machineType
= kGossamerTypeYosemite
;
67 else if (IODTMatchNubWithKeys(provider
, "'PowerBook1,1'"))
68 machineType
= kGossamerType101
;
71 setMachineType(machineType
);
73 // Find out if this an all in one.
75 if (ml_probe_read(kGossamerMachineIDReg
, &tmpVal
)) {
76 switch (getMachineType()) {
77 case kGossamerTypeGossamer
:
78 case kGossamerTypeSilk
:
79 if (!(tmpVal
& kGossamerAllInOneMask
)) allInOne
= 1;
82 case kGossamerTypeiMac
:
87 if (allInOne
) setProperty("AllInOne", this);
89 // setup default power mgr features per machine
90 // NOTE: on Core99 and later hardware, this information
91 // is available from the "prim-info" property in the power-mgt
92 // node of the device tree. Prior to that, this information
93 // was just another hard-coded part of the ROM.
95 switch (getMachineType()) {
96 case kGossamerTypeGossamer
:
97 case kGossamerTypeSilk
:
98 case kGossamerTypeiMac
:
99 case kGossamerTypeYosemite
:
100 _pePMFeatures
= kStdDesktopPMFeatures
;
101 _pePrivPMFeatures
= kStdDesktopPrivPMFeatures
;
102 _peNumBatteriesSupported
= kStdDesktopNumBatteries
;
105 case kGossamerTypeWallstreet
:
106 _pePMFeatures
= kWallstreetPMFeatures
;
107 _pePrivPMFeatures
= kWallstreetPrivPMFeatures
;
108 _peNumBatteriesSupported
= kStdPowerBookNumBatteries
;
111 case kGossamerType101
:
112 _pePMFeatures
= k101PMFeatures
;
113 _pePrivPMFeatures
= k101PrivPMFeatures
;
114 _peNumBatteriesSupported
= kStdPowerBookNumBatteries
;
118 return super::start(provider
);
122 bool GossamerPE::platformAdjustService(IOService
*service
)
127 // Add the extra sound properties for Gossamer AIO
128 if (getProperty("AllInOne") &&
129 ((getMachineType() == kGossamerTypeGossamer
) ||
130 (getMachineType() == kGossamerTypeSilk
))) {
131 if (!strcmp(service
->getName(), "sound")) {
133 tmpData
= OSData::withBytes(&tmpNum
, sizeof(tmpNum
));
135 service
->setProperty("#-detects", tmpData
);
136 service
->setProperty("#-outputs", tmpData
);
143 // Set the loop snoop property for Wallstreet or Mainstreet.
144 if (getMachineType() == kGossamerTypeWallstreet
) {
145 if (IODTMatchNubWithKeys(service
, "('grackle', 'MOT,PPC106')")) {
146 // Add the property for set loop snoop.
147 service
->setProperty("set-loop-snoop", service
);
155 IOReturn
GossamerPE::callPlatformFunction(const OSSymbol
*functionName
,
156 bool waitForFunction
,
157 void *param1
, void *param2
,
158 void *param3
, void *param4
)
160 if (functionName
== gGetDefaultBusSpeedsKey
) {
161 getDefaultBusSpeeds((long *)param1
, (unsigned long **)param2
);
162 return kIOReturnSuccess
;
165 return super::callPlatformFunction(functionName
, waitForFunction
,
166 param1
, param2
, param3
, param4
);
169 static unsigned long gossamerSpeed
[] = { 66820000, 1 };
170 static unsigned long yosemiteSpeed
[] = { 99730000, 1 };
172 void GossamerPE::getDefaultBusSpeeds(long *numSpeeds
,
173 unsigned long **speedList
)
175 if ((numSpeeds
== 0) || (speedList
== 0)) return;
177 switch (getMachineType()) {
178 case kGossamerTypeGossamer
:
179 case kGossamerTypeSilk
:
181 *speedList
= gossamerSpeed
;
184 case kGossamerTypeYosemite
:
186 *speedList
= yosemiteSpeed
;
197 //*********************************************************************************
198 // PMInstantiatePowerDomains
200 // This overrides the vanilla implementation in IOPlatformExpert. It instantiates
201 // a root domain with two children, one for the USB bus (to handle the USB idle
202 // power budget), and one for the expansions slots on the PCI bus (to handle
203 // the idle PCI power budget)
204 //*********************************************************************************
206 void GossamerPE::PMInstantiatePowerDomains ( void )
208 root
= new IOPMrootDomain
;
214 /* All G3s support sleep (or pseudo-sleep) now
215 if ((getMachineType() == kGossamerType101) ||
216 (getMachineType() == kGossamerTypeWallstreet))
218 root
->setSleepSupported(kRootDomainSleepSupported
);
222 //*********************************************************************************
225 // This overrides the vanilla implementation in IOPlatformExpert.
226 //*********************************************************************************
228 //#define DONOTREGISTERATACONTROLLER 1
230 void GossamerPE::PMRegisterDevice(IOService
* theNub
, IOService
* theDevice
)
232 //#ifdef DONOTREGISTERATACONTROLLER
233 // do not add IOATAStandardDriver to the tree since on this platform they do not need resets
234 // if (OSDynamicCast(IOATAStandardDriver, theDevice) != NULL)
238 // Checks if the nub handles power states, if it does not gets its parent and so
239 // up until we reach the root, or we do not find anything:
240 while ((theNub
!= NULL
) && ( theNub
->addPowerChild(theDevice
) != IOPMNoErr
)) {
241 theNub
= theNub
->getProvider();
243 //#ifdef DONOTREGISTERATACONTROLLER
244 // IOATAStandardDriver are detached, and so would be evrething I attach to them so
245 // their childs go directly on the tree.
246 // if (OSDynamicCast(IOATAStandardDriver, theNub) != NULL) {
247 // theNub = theNub->getProvider();
252 if ( theNub
== NULL
) {
253 root
->addPowerChild ( theDevice
);