#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 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);
const OSSymbol *keyLargo_FCRNode;
const OSObject *fcrs[kPangeaFCRCount];
const OSArray *fcrArray;
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;
struct MPICTimers {
UInt32 currentCountRegister;
UInt32 baseCountRegister;
UInt32 vectorPriorityRegister;
UInt32 destinationRegister;
};
typedef struct MPICTimers MPICTimers;
typedef volatile MPICTimers *MPICTimersPtr;
struct KeyLargoMPICState {
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();
long clk31RefCount; long clk45RefCount; long clk49RefCount; long clk32RefCount; bool fI2SState[2]; void resetUniNEthernetPhy(void);
public:
virtual bool init(OSDictionary *);
virtual bool start(IOService *provider);
virtual void stop(IOService *provider);
virtual void processNub(IOService * nub);
virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
bool waitForFunction, void *param1, void *param2,
void *param3, void *param4);
virtual IOReturn callPlatformFunction( const char * functionName,
bool waitForFunction, void *param1, void *param2,
void *param3, void *param4);
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