#ifndef _APPLEKEYLARGO_H
#define _APPLEKEYLARGO_H
#include <IOKit/IOLocks.h>
#include <IOKit/platform/AppleMacIO.h>
#include "USBKeyLargo.h"
#include "KeyLargoWatchDogTimer.h"
#include "KeyLargo.h"
class AppleK2Device : public AppleMacIODevice
{
OSDeclareDefaultStructors(AppleK2Device);
public:
bool compareName( OSString * name, OSString ** matched = 0 ) const;
IOReturn getResources( void );
};
class AppleKeyLargo : public KeyLargo
{
OSDeclareDefaultStructors(AppleKeyLargo);
private:
UInt32 keyLargoCPUVCoreSelectGPIO;
bool mediaIsOn;
bool keepSCCenabledInSleep;
void EnableSCC(bool state, UInt8 device, bool type);
void PowerModem(bool state);
void ModemResetLow();
void ModemResetHigh();
void PowerI2S (bool powerOn, UInt32 cellNum);
IOReturn SetPowerSupply (bool powerHi);
void EnableI2SModem(bool enable);
IOService *fProvider;
UInt32 fPHandle;
const OSSymbol *keyLargo_resetUniNEthernetPhy;
const OSSymbol *keyLargo_restoreRegisterState;
const OSSymbol *keyLargo_syncTimeBase;
const OSSymbol *keyLargo_recalibrateBusSpeeds;
const OSSymbol *keyLargo_saveRegisterState;
const OSSymbol *keyLargo_turnOffIO;
const OSSymbol *keyLargo_writeRegUInt8;
const OSSymbol *keyLargo_safeWriteRegUInt8;
const OSSymbol *keyLargo_safeReadRegUInt8;
const OSSymbol *keyLargo_safeWriteRegUInt32;
const OSSymbol *keyLargo_safeReadRegUInt32;
const OSSymbol *keyLargo_powerMediaBay;
const OSSymbol *keyLargo_getHostKeyLargo;
const OSSymbol *keyLargo_powerI2S;
const OSSymbol *keyLargo_setPowerSupply;
const OSSymbol *keyLargo_EnableI2SModem;
const OSSymbol *mac_io_publishChildren;
const OSSymbol *mac_io_publishChild;
struct MPICTimers {
UInt32 currentCountRegister;
UInt32 baseCountRegister;
UInt32 vectorPriorityRegister;
UInt32 destinationRegister;
};
typedef struct MPICTimers MPICTimers;
typedef volatile MPICTimers *MPICTimersPtr;
struct KeyLargoMPICState {
UInt32 mpicGlobal0;
UInt32 mpicIPI[kKeyLargoMPICIPICount];
UInt32 mpicSpuriousVector;
UInt32 mpicTimerFrequencyReporting;
MPICTimers mpicTimers[kKeyLargoMPICTimerCount];
UInt32 mpicInterruptSourceVectorPriority[kKeyLargoMPICVectorsCount];
UInt32 mpicInterruptSourceDestination[kKeyLargoMPICVectorsCount];
UInt32 mpicCurrentTaskPriorities[kKeyLargoMPICTaskPriorityCount];
};
typedef struct KeyLargoMPICState KeyLargoMPICState;
typedef volatile KeyLargoMPICState *KeyLargoMPICStatePtr;
struct KeyLargoGPIOState {
UInt32 gpioLevels[2];
UInt8 extIntGPIO[18];
UInt8 gpio[17];
};
typedef struct KeyLargoGPIOState KeyLargoGPIOState;
typedef volatile KeyLargoGPIOState *KeyLargoGPIOStatePtr;
struct KeyLargoConfigRegistersState {
UInt32 mediaBay;
UInt32 featureControl[kPangeaFCRCount]; };
typedef struct KeyLargoConfigRegistersState KeyLargoConfigRegistersState;
typedef volatile KeyLargoConfigRegistersState *KeyLargoConfigRegistersStatePtr;
struct DBDMAChannelRegisters {
UInt32 commandPtrLo;
UInt32 interruptSelect;
UInt32 branchSelect;
UInt32 waitSelect;
};
typedef struct DBDMAChannelRegisters DBDMAChannelRegisters;
typedef volatile DBDMAChannelRegisters *DBDMAChannelRegistersPtr;
struct KeyLargoDBDMAState {
DBDMAChannelRegisters dmaChannel[kKeyLargoDBDMAChannelCount];
};
typedef struct KeyLargoDBDMAState KeyLargoDBDMAState;
typedef volatile KeyLargoDBDMAState *KeyLargoDBDMAStatePtr;
struct KeyLargoAudioState {
UInt32 audio[kKeyLargoAudioRegisterCount];
};
typedef struct KeyLargoAudioState KeyLargoAudioState;
typedef volatile KeyLargoAudioState *KeyLargoAudioStateStatePtr;
struct KeyLargoI2SState {
UInt32 i2s[kKeyLargoI2SRegisterCount * kKeyLargoI2SChannelCount];
};
typedef struct KeyLargoI2SState KeyLargoI2SState;
typedef volatile KeyLargoI2SState *KeyLargoI2SStateStatePtr;
struct KeyLargoState {
bool thisStateIsValid;
KeyLargoMPICState savedMPICState;
KeyLargoGPIOState savedGPIOState;
KeyLargoConfigRegistersState savedConfigRegistersState;
KeyLargoDBDMAState savedDBDMAState;
KeyLargoAudioState savedAudioState;
KeyLargoI2SState savedI2SState;
UInt8 savedVIAState[9];
};
typedef struct KeyLargoState KeyLargoState;
KeyLargoState savedKeyLargoState;
typedef struct WirelessPower {
bool cardPower; UInt8 wirelessCardReg[5]; } WirelessPower;
WirelessPower cardStatus;
void saveKeyLargoState();
void restoreKeyLargoState();
IOSimpleLock *mutex;
long clk31RefCount; long clk45RefCount; long clk49RefCount; long clk32RefCount; bool fI2SState[2];
OSArray *fPlatformFuncArray;
void resetUniNEthernetPhy(void);
bool performFunction(IOPlatformFunction *func, void *pfParam1 = 0,
void *pfParam2 = 0, void *pfParam3 = 0, void *pfParam4 = 0);
public:
virtual bool init(OSDictionary *);
virtual bool start(IOService *provider);
virtual void stop(IOService *provider);
virtual void publishBelow( IORegistryEntry * root );
virtual void processNub( IOService * nub );
virtual IOService * createNub( IORegistryEntry * from );
virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
bool waitForFunction, void *param1, void *param2,
void *param3, void *param4);
bool gPreserveIODeviceTree;
virtual long long syncTimeBase(void);
virtual void recalibrateBusSpeeds(void);
virtual void turnOffKeyLargoIO(bool restart);
virtual void turnOffPangeaIO(bool restart);
virtual void turnOffIntrepidIO(bool restart);
virtual void powerWireless(bool powerOn);
virtual void setReferenceCounts (void);
virtual void saveRegisterState(void);
virtual void restoreRegisterState(void);
virtual void enableCells();
virtual void powerMediaBay(bool powerOn, UInt8 whichDevice);
void safeWriteRegUInt32(unsigned long offset, UInt32 mask, UInt32 data);
void initForPM (IOService *provider);
IOReturn setPowerState(unsigned long powerStateOrdinal, IOService* whatDevice);
};
#endif