IOI2CDriveBayMGPIO.h [plain text]
#ifndef _IOI2CDriveBayMGPIO_H
#define _IOI2CDriveBayMGPIO_H
#include <IOKit/IOService.h>
#include <IOI2C/IOI2CDevice.h>
#include "GPIOParent.h"
class IOI2CDriveBayMGPIO : public IOI2CDevice
{
OSDeclareDefaultStructors(IOI2CDriveBayMGPIO)
public:
virtual void free(void);
virtual bool start(IOService *provider);
using IOI2CDevice::callPlatformFunction;
virtual IOReturn callPlatformFunction(
const OSSymbol *functionName,
bool waitForFunction,
void *param1, void *param2,
void *param3, void *param4 );
private:
typedef void (*PCA9554ClientCallback)(IOService *, UInt8, UInt8);
typedef struct
{
UInt32 reg;
PCA9554ClientCallback handler;
IOService *client;
bool isEnabled;
} PCA9554CallbackInfo;
enum
{
kPresent = 3,
kSwitch = 4
};
IOService *fApplePMU;
IOService *fKeyswitch;
IOService *fDrivebaySense;
const OSSymbol *fDrivebaySenseSym;
const OSSymbol *fSymIntRegister;
const OSSymbol *fSymIntUnRegister;
const OSSymbol *fSymIntEnable;
const OSSymbol *fSymIntDisable;
bool fC3Mapping;
UInt32 fClientCount;
IOLock *fClientLock;
enum
{
kFlag_InterruptsRegistered = (1 << 0),
kFlag_InterruptsEnabled = (1 << 1),
};
UInt32 fFlags;
UInt32 fIntAddrInfo;
UInt8 fIntRegState;
UInt8 fConfigReg;
UInt8 fPolarityReg;
UInt8 fOutputReg;
#define kCLIENT_MAX 4
PCA9554CallbackInfo fClient[kCLIENT_MAX];
IOReturn registerClient(
UInt32 id,
PCA9554ClientCallback handler,
IOService *client,
bool isRegister);
IOReturn enableClient(
UInt32 id,
bool isEnable);
static void sProcessApplePMUInterrupt(
IOService *client,
UInt8 addressInfo,
UInt32 length,
UInt8 *buffer);
static void sProcessGPIOInterrupt(
IOI2CDriveBayMGPIO *self,
void *param2,
void *param3,
UInt8 newData);
void processGPIOInterrupt(
UInt8 newState);
virtual void processPowerEvent(UInt32 eventType);
};
#endif // _IOI2CPCA9554_H