PPCI2CInterface.cpp [plain text]
#include "PPCI2CInterface.h"
extern "C" vm_offset_t ml_io_map(vm_offset_t phys_addr, vm_size_t size);
#define super IOService
OSDefineMetaClassAndStructors( PPCI2CInterface, IOService )
#define I2C_REGISTERDELAY 10
#if 1
#define INLINE inline
#else
#define INLINE
#endif
INLINE void
PPCI2CInterface::dumpI2CRegisters()
{
#ifdef DEBUGMODE
IOLog("mode 0x%08lx -> 0x%02x\n", (UInt32)mode,*mode);
IOLog("control 0x%08lx -> 0x%02x\n", (UInt32)control,*control);
IOLog("status 0x%08lx -> 0x%02x\n", (UInt32)status,*status);
IOLog("ISR 0x%08lx -> 0x%02x\n", (UInt32)ISR,*ISR);
IOLog("IER 0x%08lx -> 0x%02x\n", (UInt32)IER,*IER);
IOLog("address 0x%08lx -> 0x%02x\n", (UInt32)address,*address);
IOLog("subAddr 0x%08lx -> 0x%02x\n", (UInt32)subAddr,*subAddr);
#endif //DEBUGMODE
}
INLINE void
PPCI2CInterface::SetI2CBase(UInt8 *baseAddress, UInt8 steps)
{
I2CRegister base = (I2CRegister)baseAddress;
if (base != NULL) {
mode = base; control = mode + steps; status = control + steps; ISR = status + steps; IER = ISR + steps; address = IER + steps; subAddr = address + steps; data = subAddr + steps;
*status = 0x00;
*ISR = 0x00;
getMode();
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::SetI2CBase(0x%08lx,0x%02x)\n",(UInt32)baseAddress, steps);
dumpI2CRegisters();
#endif // DEBUGMODE
}
}
INLINE UInt8
PPCI2CInterface::shiftedMask(UInt8 mask, UInt8 shift)
{
return (mask << shift);
}
INLINE UInt8
PPCI2CInterface::shiftedCompMask(UInt8 mask, UInt8 shift)
{
return ~shiftedMask(mask, shift);
}
INLINE void
PPCI2CInterface::writeRegisterField(I2CRegister reg, UInt8 mask, UInt8 shift, UInt8 newData)
{
UInt8 registerValue = *reg;
UInt8 data = (newData & mask);
UInt8 nMask = shiftedCompMask(mask, shift);
*reg = (registerValue & nMask) | (data << shift);
eieio();
IODelay(I2C_REGISTERDELAY);
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::writeRegisterField(0x%08lx, 0x%02x, 0x%02x, 0x%02x)\n",(UInt32)reg, mask, shift, newData);
IOLog("PPCI2CInterface::writeRegisterField() registerValue=0x%02x\n", registerValue);
IOLog("PPCI2CInterface::writeRegisterField() data=0x%02x\n", data);
IOLog("PPCI2CInterface::writeRegisterField() nMask=0x%02x\n", nMask);
IOLog("PPCI2CInterface::writeRegisterField() *reg=0x%02x\n", *reg);
#endif // DEBUGMODE
}
INLINE UInt8
PPCI2CInterface::readRegisterField(I2CRegister reg, UInt8 mask, UInt8 shift)
{
UInt8 registerValue = *reg;
UInt8 returnValue = ((registerValue) >> shift) & mask;
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::readRegisterField(0x%08lx, 0x%02x, 0x%02x)\n",(UInt32)reg, mask, shift);
IOLog("PPCI2CInterface::readRegisterField() *reg=0x%02x\n", *reg);
IOLog("PPCI2CInterface::readRegisterField() returnValue=0x%02x\n", returnValue);
#endif // DEBUGMODE
return returnValue;
}
INLINE void
PPCI2CInterface::setPort(UInt8 newPort)
{
portSelect = newPort;
writeRegisterField(mode, (UInt8)kPortMask, (UInt8)I2CPortShift, (UInt8)newPort);
}
INLINE UInt8
PPCI2CInterface::getPort()
{
portSelect = (I2CMode)readRegisterField(mode, (UInt8)kPortMask, (UInt8)I2CPortShift);
return portSelect;
}
INLINE void
PPCI2CInterface::setMode(I2CMode newMode)
{
lastMode = newMode;
writeRegisterField(mode, (UInt8)kModeMask, (UInt8)I2CModeShift, (UInt8)newMode);
}
INLINE PPCI2CInterface::I2CMode
PPCI2CInterface::getMode()
{
lastMode = (I2CMode)readRegisterField(mode, (UInt8)kModeMask, (UInt8)I2CModeShift);
return lastMode;
}
INLINE void
PPCI2CInterface::setSpeed(I2CSpeed newSpeed)
{
writeRegisterField(mode, (UInt8)kSpeedMask, (UInt8)I2CSpeedShift, (UInt8)newSpeed);
}
INLINE PPCI2CInterface::I2CSpeed
PPCI2CInterface::getSpeed()
{
I2CSpeed speedValue;
speedValue = (I2CSpeed)readRegisterField(mode, (UInt8)kSpeedMask, (UInt8)I2CSpeedShift);
return speedValue;
}
INLINE void
PPCI2CInterface::setControl(I2CControl newControlValue)
{
*control = (UInt8)newControlValue;
eieio();
IODelay(I2C_REGISTERDELAY);
}
INLINE PPCI2CInterface::I2CControl
PPCI2CInterface::getControl()
{
I2CControl controlValue;
controlValue = (I2CControl)(*control);
return controlValue;
}
INLINE void
PPCI2CInterface::setStatus(I2CStatus newStatusValue)
{
*status = (UInt8)newStatusValue;
eieio();
IODelay(I2C_REGISTERDELAY);
}
INLINE PPCI2CInterface::I2CStatus
PPCI2CInterface::getStatus()
{
I2CStatus statusValue;
statusValue = (I2CStatus)(*status);
return statusValue;
}
INLINE void
PPCI2CInterface::setInterruptStatus(I2CInterruptStatus newStatusValue)
{
*ISR = (UInt8)newStatusValue;
eieio();
IODelay(I2C_REGISTERDELAY);
}
INLINE PPCI2CInterface::I2CInterruptStatus
PPCI2CInterface::getInterruptStatus()
{
I2CInterruptStatus intStatus;
intStatus = (I2CInterruptStatus)(*ISR);
return intStatus;
}
INLINE void
PPCI2CInterface::setInterruptEnable(I2CInterruptEnable newInterruptEnable)
{
*IER = (UInt8)newInterruptEnable;
eieio();
IODelay(I2C_REGISTERDELAY);
}
INLINE PPCI2CInterface::I2CInterruptEnable
PPCI2CInterface::setInterruptEnable()
{
I2CInterruptEnable interEnable;
interEnable = (I2CInterruptEnable)(*IER);
return interEnable;
}
INLINE void
PPCI2CInterface::setAddress(UInt8 newAddress)
{
writeRegisterField(address, (UInt8)kADDRMask, (UInt8)I2CAddressShift, (UInt8)newAddress);
eieio();
}
INLINE void
PPCI2CInterface::setAddressRegister(UInt8 newAddress, I2CRWMode readMode)
{
newAddress &= kADDRMask;
*address = (newAddress << I2CAddressShift) | readMode;
IODelay(I2C_REGISTERDELAY);
#ifdef DEBUGMODE
IOLog("setAddressRegister( 0x%02x, %d) = 0x%02x\n", newAddress, (UInt8)readMode, (UInt8)*address);
#endif // DEBUGMODE
eieio();
}
INLINE UInt8
PPCI2CInterface::getAddress()
{
return readRegisterField(address, (UInt8)kADDRMask, (UInt8)I2CAddressShift);
}
INLINE void
PPCI2CInterface::setReadWrite(I2CRWMode readMode)
{
writeRegisterField(address, (UInt8)kRWMask, (UInt8)I2CRWShift, (UInt8)readMode);
eieio();
}
INLINE PPCI2CInterface::I2CRWMode
PPCI2CInterface::getReadWrite()
{
return (I2CRWMode)readRegisterField(address, (UInt8)kRWMask, (UInt8)I2CRWShift);
}
INLINE void
PPCI2CInterface::setSubAddress(UInt8 newSubAddress)
{
*subAddr = newSubAddress;
eieio();
}
INLINE UInt8
PPCI2CInterface::getSubAddress()
{
return (*subAddr);
}
INLINE void
PPCI2CInterface::setData(UInt8 newByte)
{
*data = newByte;
eieio();
IODelay(I2C_REGISTERDELAY);
}
INLINE UInt8
PPCI2CInterface::getData()
{
return (*data);
}
INLINE bool
PPCI2CInterface::setAddressAndDirection()
{
transferWasSuccesful = true;
if (isReading) {
setAddressRegister(currentAddress, kReadADDR);
}
else {
setAddressRegister(currentAddress, kWriteADDR);
}
if (lastMode == kStandardSubMode)
setSubAddress(currentSubaddress);
currentState = ki2cStateWaitingForIADDR;
setControl((I2CControl)(getControl() | kXAddrCNTRL));
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setAddressAndDirection()\n");
#endif // DEBUGMODE
return(true);
}
bool
PPCI2CInterface::i2cStandardSubModeInterrupts(UInt8 interruptStatus)
{
bool success = true;
switch (currentState) {
case ki2cStateWaitingForIADDR:
#ifdef DEBUGMODE
IOLog("ki2cStateWaitingForIADDR: ");
#endif // DEBUGMODE
if ((interruptStatus & kIAddrISR) == 0) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::i2cStandardSubModeInterrupts (ki2cStateWaitingForIADDR): bad state ");
#endif
success = false;
}
if (success) {
if (getStatus() & kLastAakSTATUS) {
if (isReading) {
if (nBytes > 1)
setControl((I2CControl)(getControl() | kAakCNTRL));
}
else {
setData(*dataBuffer++);
nBytes--;
}
currentState = ki2cStateWaitingForIDATA;
}
else {
#ifdef DEBUGMODE
IOLog("...no slave...");
#endif
currentState = ki2cStateWaitingForISTOP;
success = false;
}
}
else {
abortTransfer();
}
setInterruptStatus(kIAddrISR);
break;
case ki2cStateWaitingForIDATA:
#ifdef DEBUGMODE
IOLog("ki2cStateWaitingForIDATA: ");
#endif
if ((interruptStatus & kIDataISR) == 0) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::i2cStandardSubModeInterrupts (ki2cStateWaitingForIDATA): bad state ");
#endif
success = false;
}
if (success) {
if (isReading) {
*dataBuffer++ = getData();
nBytes--;
if (nBytes == 0) currentState = ki2cStateWaitingForISTOP;
else setControl(kClrCNTRL);
}
else {
if (getStatus() & kLastAakSTATUS) {
if (nBytes == 0) {
currentState = ki2cStateWaitingForISTOP;
setControl((I2CControl)(getControl() | kStopCNTRL));
}
else {
setData(*dataBuffer++);
nBytes--;
}
}
else {
#ifdef DEBUGMODE
IOLog("...no slave...");
#endif
currentState = ki2cStateWaitingForISTOP;
success = false;
}
}
}
else {
abortTransfer();
}
setInterruptStatus(kIDataISR);
break;
case ki2cStateWaitingForISTOP:
#ifdef DEBUGMODE
IOLog("ki2cStateWaitingForISTOP: ");
#endif
if ((interruptStatus & kIStopISR) == 0) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::i2cStandardSubModeInterrupts (ki2cStateWaitingForISTOP): bad state ");
#endif
success = false;
}
setInterruptStatus(kIStopISR);
currentState = ki2cStateIdle;
semaphore_signal(mySync);
break;
case ki2cStateWaitingForISTART:
#ifdef DEBUGMODE
IOLog("ki2cStateWaitingForISTART: is not supposed to happen in this state machine ");
#endif
break;
case ki2cStateIdle:
#ifdef DEBUGMODE
IOLog("ki2cStateIdle: ");
#endif
break;
default:
break;
}
#ifdef DEBUGMODE
IOLog(" %s\n", (success ? "true" : "false"));
#endif
return success;
}
INLINE bool
PPCI2CInterface::abortTransfer()
{
currentState = ki2cStateWaitingForISTOP;
setControl((I2CControl)(getControl() | kStopCNTRL));
return false;
}
bool
PPCI2CInterface::waitForCompletion()
{
UInt16 loop = 50 + nBytes * 1500;
UInt8 intStat = getInterruptStatus();
if (intStat & kISRMask)
handleI2CInterrupt();
while((loop--) && (currentState != ki2cStateIdle)) {
IOSleep(1);
intStat = getInterruptStatus();
if (intStat & kISRMask)
handleI2CInterrupt();
}
if (currentState != ki2cStateIdle) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::waitForCompletion error loop is incomplete\n");
#endif
return false;
}
else {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::waitForCompletion loop is complete\n");
#endif
return true;
}
}
bool
PPCI2CInterface::setKhzSpeed(UInt speed)
{
switch (speed)
{
case 100:
setSpeed(k100KhzMode);
break;
case 50:
setSpeed(k50KhzMode);
break;
case 25:
setSpeed(k25KhzMode);
break;
default:
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setKhzSpeed Can not set bus speed %d is not allowed\n", speed);
#endif
return false;
break;
}
return true;
}
bool
PPCI2CInterface::initI2CBus(UInt8 *baseAddress, UInt8 steps)
{
pollingMode = true;
currentState = ki2cStateIdle;
SetI2CBase(baseAddress, steps);
return true;
}
void
PPCI2CInterface::handleHardwareInterrupt(OSObject *target, void *refCon, IOService *nub, int source)
{
PPCI2CInterface *ppcI2C = OSDynamicCast(PPCI2CInterface, target);
if (ppcI2C != NULL) {
ppcI2C->myProvider->disableInterrupt(0);
ppcI2C->handleI2CInterrupt();
ppcI2C->myProvider->enableInterrupt(0);
}
}
bool
PPCI2CInterface::handleI2CInterrupt()
{
bool success = false;
switch(lastMode)
{
case kDumbMode:
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::handleI2CInterrupt kDumbMode is an unsupported mode (for now)\n");
#endif
break;
case kStandardMode:
case kStandardSubMode:
success = i2cStandardSubModeInterrupts(getInterruptStatus());
break;
case kCombinedMode:
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::handleI2CInterrupt kCombinedMode is an unsupported mode (for now)\n");
#endif
break;
}
transferWasSuccesful = (transferWasSuccesful && success);
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::handleI2CInterrupt transferWasSuccesful = %s success= %s.\n",
((transferWasSuccesful) ? "true" : "false"),
(success ? "true" : "false"));
#endif // DEBUGMODE
return success;
}
bool
PPCI2CInterface::start(IOService *provider)
{
OSData *t;
UInt32 baseAddress;
UInt32 addressSteps;
UInt32 rate;
i2cRegisterMap = NULL;
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::start(%s)\n", provider->getName());
#endif
mutexLock = IORecursiveLockAlloc();
if (mutexLock == NULL) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::start can not create the IORecursiveLock so we bail off");
#endif
return false;
}
#if 1
t = OSDynamicCast(OSData, provider->getProperty("AAPL,address"));
if (t != NULL) {
baseAddress = *((UInt32*)t->getBytesNoCopy());
baseAddress = ml_io_map(baseAddress, 0x1000);
}
else {
#ifdef DEBUGMODE
IOLog( "PPCI2CInterface::start missing property AAPL,address in i2c registry\n");
#endif
return false;
}
#else
i2cRegisterMap = provider->mapDeviceMemoryWithIndex(1);
if ( i2cRegisterMap == NULL ) {
#ifdef DEBUGMODE
IOLog( "PPCI2CInterface::start missing i2cRegisterMap\n");
#endif
return false;
}
else
baseAddress = (UInt32)pmap_extract(kernel_pmap,(vm_address_t)i2cRegisterMap->getVirtualAddress());
#endif
t = OSDynamicCast(OSData, provider->getProperty("AAPL,address-step"));
if (t != NULL)
addressSteps = *((UInt32*)t->getBytesNoCopy());
else {
#ifdef DEBUGMODE
IOLog( "PPCI2CInterface::start missing property AAPL,address-step in i2c registry\n");
#endif
return false;
}
t = OSDynamicCast(OSData, provider->getProperty("AAPL,i2c-rate"));
if (t != NULL)
rate = *((UInt32*)t->getBytesNoCopy());
else {
#ifdef DEBUGMODE
IOLog( "PPCI2CInterface::start missing property AAPL,i2c-rate in i2c registry\n");
#endif
return false;
}
if (!initI2CBus((UInt8*)baseAddress, (UInt8)addressSteps))
return false;
if (!setKhzSpeed((UInt)rate))
return false;
myProvider = provider;
pollingMode = true;
publishResource(getResourceName(), this );
return true;
}
void
PPCI2CInterface::free()
{
if (mutexLock != NULL)
IORecursiveLockFree(mutexLock);
if (i2cRegisterMap != NULL)
i2cRegisterMap->release();
}
bool
PPCI2CInterface::setPollingMode(bool newPollingMode)
{
#ifdef DEBUGMODE
newPollingMode = true;
#endif // DEBUGMODE
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setPollingMode(%s) I am not the owner of the lock returns without doing anyting.\n",
(newPollingMode ? "true" : "false"));
#endif // DEBUGMODE
return false;
}
if (!pollingMode) {
myProvider->disableInterrupt(0);
myProvider->unregisterInterrupt(0);
}
pollingMode = newPollingMode;
if (!newPollingMode) {
if (myProvider->registerInterrupt(0, this, handleHardwareInterrupt, 0 ) != kIOReturnSuccess) {
pollingMode = true;
return false;
}
}
return true;
}
void
PPCI2CInterface::setDumbMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setDumbMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return;
}
setMode(kDumbMode);
}
void
PPCI2CInterface::setStandardMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setStandardMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return;
}
setMode(kStandardMode);
}
void
PPCI2CInterface::setStandardSubMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setStandardSubMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return;
}
setMode(kStandardSubMode);
}
void
PPCI2CInterface::setCombinedMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::setCombinedMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return;
}
setMode(kCombinedMode);
}
bool
PPCI2CInterface::isInDumbMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::isInDumbMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
return (getMode() == kDumbMode);
}
bool
PPCI2CInterface::isInStandardMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::isInStandardMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
return (getMode() == kStandardMode);
}
bool
PPCI2CInterface::isInStandardSubMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::isInStandardSubMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
return (getMode() == kStandardSubMode);
}
bool
PPCI2CInterface::isInCombinedMode()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::isInCombinedMode I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
return (getMode() == kCombinedMode);
}
UInt
PPCI2CInterface::getKhzSpeed()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::getKhzSpeed I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return 0;
}
switch((int)getSpeed())
{
case k100KhzMode:
return (100);
break;
case k50KhzMode:
return (50);
break;
case k25KhzMode:
return (25);
break;
}
return (0);
}
bool
PPCI2CInterface::openI2CBus(UInt8 port)
{
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::openI2CBus attempting to access to PPCI2CInterface->mutexLock.\n");
IORecursiveLockLock(mutexLock);
IOLog("PPCI2CInterface::openI2CBus PPCI2CInterface->mutexLock locked.\n");
#else // !DEBUGMODE
IORecursiveLockLock(mutexLock);
#endif // DEBUGMODE
setPort(port);
setPollingMode(true);
setInterruptEnable((I2CInterruptEnable)(kEDataIER | kEAddrIER | kEStopIER | kEStartIER));
return true;
}
bool
PPCI2CInterface::writeI2CBus(UInt8 address, UInt8 subAddress, UInt8 *newData, UInt16 len)
{
bool success = true;
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::writeI2CBus I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
dataBuffer = newData;
nBytes = len;
currentAddress = address;
currentSubaddress = subAddress;
isReading = false;
if (pollingMode) {
if ((success = setAddressAndDirection()) == true )
success = waitForCompletion();
}
else {
semaphore_create(current_task(), (semaphore**)&mySync, SYNC_POLICY_FIFO, 0);
myProvider->enableInterrupt(0);
if ((success = setAddressAndDirection()) == true ) {
semaphore_wait(mySync);
}
semaphore_destroy(current_task(), mySync);
myProvider->disableInterrupt(0);
}
return (transferWasSuccesful && success);
}
bool
PPCI2CInterface::readI2CBus(UInt8 address, UInt8 subAddress, UInt8 *newData, UInt16 len)
{
bool success = false;
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::readI2CBus I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
dataBuffer = data;
nBytes = len;
currentAddress = address;
currentSubaddress = subAddress;
isReading = true;
if (pollingMode) {
if ((success = setAddressAndDirection()) == true )
success = waitForCompletion();
}
else {
return false;
semaphore_create(current_task(), (semaphore**)&mySync, SYNC_POLICY_FIFO, 0);
myProvider->enableInterrupt(0);
if ((success = setAddressAndDirection()) == true ) {
semaphore_wait(mySync);
}
semaphore_destroy(current_task(), mySync);
myProvider->disableInterrupt(0);
}
return (transferWasSuccesful && success);
}
bool
PPCI2CInterface::closeI2CBus()
{
if (!IORecursiveLockHaveLock(mutexLock)) {
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::closeI2CBus I am not the owner of the lock returns without doing anyting.\n");
#endif // DEBUGMODE
return false;
}
setPollingMode(true);
IORecursiveLockUnlock(mutexLock);
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::closeI2CBus PPCI2CInterface->mutexLock unlocked.\n");
#endif // DEBUGMODE
return true;
}
const char *
PPCI2CInterface::getResourceName()
{
OSData *t;
strcpy(resourceName, getName());
t = OSDynamicCast(OSData, getProvider()->getProperty("AAPL,driver-name"));
if (t != NULL)
strncat(resourceName, (char*)t->getBytesNoCopy(), t->getLength());
#ifdef DEBUGMODE
IOLog("PPCI2CInterface::getResourceName returns \"%s\"\n",resourceName);
#endif // DEBUGMODE
return (resourceName);
}