IOI2CDriveBayGPIO.h [plain text]
#ifndef _IOI2CDriveBayGPIO_H
#define _IOI2CDriveBayGPIO_H
#include <IOKit/IOService.h>
#include <IOI2C/IOI2CDevice.h>
#include "GPIOParent.h"
#define kI2CGPIOCombined "i2c-combined"
enum {
kI2CReadRetryCount = 10,
kI2CWriteRetryCount = 10,
k9554InputPort = 0x00, k9554OutputPort = 0x01, k9554PolarityInv = 0x02, k9554Config = 0x03 };
typedef struct {
GPIOEventHandler handler;
void *self;
bool isEnabled;
} I2CGPIOCallbackInfo;
#define kNumGPIOs 8
enum {
kPresent = 3,
kSwitch = 4
};
class IOI2CDriveBayGPIO : public IOI2CDevice
{
OSDeclareDefaultStructors(IOI2CDriveBayGPIO)
public:
virtual void free(void);
virtual bool start(IOService *provider);
virtual void stop(IOService *provider);
using IOI2CDevice::callPlatformFunction;
virtual IOReturn callPlatformFunction( const OSSymbol *functionName,
bool waitForFunction,
void *param1, void *param2,
void *param3, void *param4 );
private:
IOService *fPCA9554M;
UInt8 fConfigReg;
UInt8 fPolarityReg;
UInt8 fOutputReg;
bool fC3Mapping;
UInt32 fReg;
UInt32 fIntAddrInfo;
IOLock *fClientLock;
I2CGPIOCallbackInfo fClient[kNumGPIOs];
UInt32 fClientsEnabled;
IOReturn registerGPIOClient(
UInt32 id,
GPIOEventHandler handler,
IOService *client,
bool isRegister);
IOReturn enableGPIOClient(
UInt32 id,
bool isEnable);
static void sProcess9554MInterrupt(
IOI2CDriveBayGPIO *client,
UInt8 eventMask,
UInt8 newState);
void process9554MInterrupt(
UInt8 eventMask,
UInt8 newState);
IOReturn readModifyWriteI2C(
UInt8 subAddr,
UInt8 value,
UInt8 mask);
IOReturn publishChildren(IOService *nub);
virtual void processPowerEvent(UInt32 eventType);
};
#endif // _IOI2CDriveBayGPIO_H