AppleDallasDriver.cpp [plain text]
#include <IOKit/IOLib.h>
#include <IOKit/IODeviceTreeSupport.h>
#include <IOKit/IORegistryEntry.h>
#include "AppleDallasDriver.h"
#include "DallasROM.h"
#include "AudioHardwareUtilities.h"
extern "C" {
#include <pexpert/pexpert.h>
}
#define super IOService
OSDefineMetaClassAndStructors(AppleDallasDriver, IOService)
bool ROMReset (UInt8 *gpioPtr)
{
AbsoluteTime start, now, finish;
UInt64 ns;
UInt8 bit;
UInt8 outputZero, outputTristate;
bool correctTiming;
bool bitEdge;
int errorCount = 0;
bool res;
outputZero = (*gpioPtr & ( dualEdge << intEdgeSEL )) | ( gpioDDR_OUTPUT << gpioDDR ); outputTristate = (*gpioPtr & ( dualEdge << intEdgeSEL )) | ( gpioDDR_INPUT << gpioDDR );
res = TRUE;
*gpioPtr = outputTristate; OSSynchronizeIO();
if ( ( *gpioPtr & ( 1 << gpioPIN_RO ) ) == 0 ) {
IOSleep(1);
FailWithAction ((*gpioPtr & ( 1 << gpioPIN_RO )) == 0, debugIOLog (3, "AppleDallasDriver::ROMReset No speaker ROM detected"), exit);
}
correctTiming = FALSE;
while (!correctTiming)
{
debugIOLog (3, "[DALLAS] ROM Reset");
correctTiming = TRUE;
clock_get_uptime(&start);
*gpioPtr = outputZero; OSSynchronizeIO();
IODelay(kROMResetPulseMin);
*gpioPtr = outputTristate; OSSynchronizeIO();
ns = kROMResetPulseMax * kNANOSECONDS_PER_MICROSECOND;
nanoseconds_to_absolutetime(ns, &finish);
ADD_ABSOLUTETIME(&finish, &start);
bitEdge = FALSE;
while (!bitEdge && correctTiming)
{
bit = *gpioPtr & ( 1 << gpioPIN_RO );
clock_get_uptime(&now);
if (CMP_ABSOLUTETIME(&now, &finish) > 0) {
correctTiming = FALSE;
debugIOLog (3, "[DALLAS] ROM Reset: Failed Reset Rising Edge");
} else if (bit) {
bitEdge = TRUE;
} else {
IODelay(1);
}
}
ns = kROMPresenceDelayMax * kNANOSECONDS_PER_MICROSECOND;
nanoseconds_to_absolutetime(ns, &finish);
ADD_ABSOLUTETIME(&finish, &now);
bitEdge = FALSE; while (!bitEdge && correctTiming)
{
bit = *gpioPtr & ( 1 << gpioPIN_RO );
clock_get_uptime(&now);
if (CMP_ABSOLUTETIME(&now, &finish)>0) {
correctTiming = FALSE;
IOSleep(1);
debugIOLog (3, "AppleDallasDriver::ROMReset Failed to detect Presence Pulse");
} else if (!bit) {
bitEdge = TRUE;
} else {
IODelay(1);
}
}
ns = kROMPresencePulseMax * kNANOSECONDS_PER_MICROSECOND;
nanoseconds_to_absolutetime(ns, &finish);
ADD_ABSOLUTETIME(&finish, &now);
bitEdge = FALSE; while (!bitEdge && correctTiming)
{
bit = *gpioPtr & ( 1 << gpioPIN_RO );
clock_get_uptime(&now);
if (CMP_ABSOLUTETIME(&now, &finish)>0) {
correctTiming = FALSE;
} else if (bit) {
bitEdge = TRUE;
} else {
IODelay(1);
}
}
if (!correctTiming)
{
FailWithAction(++errorCount > 10, debugIOLog (3, "[DALLAS] ROM Reset: Too many failures, bailing out"), exit);
}
IOSleep(1); }
res = FALSE;
exit:
return res;
}
bool ROMSendByte ( UInt8 *gpioPtr, UInt8 theByte, UInt8 msgRefCon )
{
AbsoluteTime start, now, finish, tLOW;
UInt64 ns;
UInt8 bit;
UInt8 outputZero, outputTristate;
bool correctTiming;
bool bitEdge;
bool res;
int bitIndex;
debugIOLog (3, "[DALLAS] ROM Send 0x%02X", theByte);
outputZero = (*gpioPtr & ( dualEdge << intEdgeSEL )) | ( gpioDDR_OUTPUT << gpioDDR ); outputTristate = (*gpioPtr & ( dualEdge << intEdgeSEL )) | ( gpioDDR_INPUT << gpioDDR );
res = FALSE; for ( bitIndex = 0; bitIndex < kBITS_PER_BYTE; bitIndex++)
{
clock_get_uptime(&start);
ns = kTSLOT_maximum * kNANOSECONDS_PER_MICROSECOND; nanoseconds_to_absolutetime(ns, &finish);
ADD_ABSOLUTETIME(&finish, &start);
correctTiming = TRUE;
if ( theByte & ( 1 << bitIndex ) ) { ns = kTLOW1_maximum * kNANOSECONDS_PER_MICROSECOND; nanoseconds_to_absolutetime(ns, &tLOW);
ADD_ABSOLUTETIME(&tLOW, &start);
*gpioPtr = outputZero; OSSynchronizeIO(); IODelay( kTLOW1_maximum / 2 ); *gpioPtr = outputTristate; OSSynchronizeIO();
bitEdge = FALSE; while (!bitEdge && correctTiming)
{
bit = *gpioPtr & ( 1 << gpioPIN_RO );
clock_get_uptime(&now);
if ( CMP_ABSOLUTETIME ( &now, &tLOW ) > 0 ) {
correctTiming = FALSE;
debugIOLog (3, "... ROM Send Byte: theByte %X, Failed Bit %d Rising Edge, msgRefCon %d",
(unsigned int)theByte,
(unsigned int)bitIndex,
(unsigned int)msgRefCon );
} else if (bit) {
bitEdge = TRUE;
} else {
IODelay(1);
}
}
} else { ns = kTLOW0_maximum * kNANOSECONDS_PER_MICROSECOND; nanoseconds_to_absolutetime(ns, &tLOW);
ADD_ABSOLUTETIME(&tLOW, &start);
*gpioPtr = outputZero; OSSynchronizeIO(); IODelay( ( kTLOW0_minimum + kTLOW0_maximum ) / 2 ); *gpioPtr = outputTristate; OSSynchronizeIO();
bitEdge = FALSE; while (!bitEdge && correctTiming)
{
bit = *gpioPtr & ( 1 << gpioPIN_RO );
clock_get_uptime(&now);
if (CMP_ABSOLUTETIME(&now, &tLOW)>0) {
correctTiming = FALSE;
debugIOLog (3, "... ROM Send Byte: theByte %X, Failed Bit %d Rising Edge, msgRefCon %d",
(unsigned int)theByte,
(unsigned int)bitIndex,
(unsigned int)msgRefCon );
} else if (bit) {
bitEdge = TRUE;
} else {
IODelay(1);
}
}
}
IODelay ( kTSLOT_minimum + kTREC );
if (!correctTiming)
res = TRUE;
}
IOSleep(1); if ( res ) { debugIOLog (3, "ROMSendByte FAILED!" ); }
return res;
}
bool ROMReadByte (UInt8 *gpioPtr, UInt8* theByte)
{
AbsoluteTime start, finish, tRdv, after;
UInt64 ns;
UInt8 bit, failedTRdv, failedTRelease, outputZero, outputTristate, theValue = 0;
bool correctTiming, bitEdge, res;
int bitIndex;
outputZero = (*gpioPtr & ( dualEdge << intEdgeSEL )) | ( gpioDDR_OUTPUT << gpioDDR ); outputTristate = (*gpioPtr & ( dualEdge << intEdgeSEL )) | ( gpioDDR_INPUT << gpioDDR );
res = FALSE; failedTRelease = failedTRdv = 0;
for ( bitIndex = 0; bitIndex < kBITS_PER_BYTE; bitIndex++)
{
correctTiming = TRUE;
clock_get_uptime ( &start );
ns = kTSLOT_maximum * kNANOSECONDS_PER_MICROSECOND; nanoseconds_to_absolutetime ( ns, &finish );
ADD_ABSOLUTETIME(&finish, &start);
ns = ( kTRDV + 1 ) * kNANOSECONDS_PER_MICROSECOND;
nanoseconds_to_absolutetime ( ns, &tRdv );
ADD_ABSOLUTETIME(&tRdv, &start);
*gpioPtr = outputZero; OSSynchronizeIO(); IODelay( kTLOWR_maximum / 3 ); *gpioPtr = outputTristate; OSSynchronizeIO();
IODelay ( kTRDV - ( kTLOWR_maximum / 3 ) - 1 );
bit = *gpioPtr & ( 1 << gpioPIN_RO );
clock_get_uptime(&after);
if ( CMP_ABSOLUTETIME ( &after, &tRdv ) > 0 ) {
correctTiming = FALSE;
res = TRUE;
failedTRdv |= ( 1 << bitIndex );
}
if ( 0 == bit ) {
bitEdge = FALSE;
correctTiming = TRUE;
while ( !bitEdge && correctTiming ) {
if ( *gpioPtr & ( 1 << gpioPIN_RO ) ) {
bitEdge = TRUE;
}
clock_get_uptime(&after);
if ( CMP_ABSOLUTETIME ( &after, &finish ) > 0 ) {
correctTiming = FALSE;
res = TRUE;
failedTRelease |= ( 1 << bitIndex );
}
}
}
IODelay( kTSLOT_minimum + kTREC );
theValue |= ( bit == 0 ? 0 << bitIndex : 1 << bitIndex );
}
if ( res ) {
debugIOLog (3, "[DALLAS] ROMReadByte tRDV failed on bits %X, tRELEASE failed on bits %X, data %X", (unsigned int)failedTRdv, (unsigned int)failedTRelease, (unsigned int)theValue );
}
IOSleep(1); *theByte = theValue;
debugIOLog (3, "[DALLAS] ROM Read 0x%02x", *theByte);
if ( res ) { debugIOLog (3, "ROMReadByte FAILED!" ); }
return res;
}
void ROMCheckCRC(UInt8 *bROM)
{
int index, j;
UInt8 crc[8] = {0, 0, 0, 0, 0, 0, 0, 0};
UInt8 currByte, newBit;
UInt8 finalCRC;
for (index=0; index<7; index++) {
currByte = bROM[index];
for (j=0; j<8; j++) {
newBit = crc[7] ^ (currByte&0x01);
crc[7] = crc[6];
crc[6] = crc[5];
crc[5] = crc[4] ^ newBit;
crc[4] = crc[3] ^ newBit;
crc[3] = crc[2];
crc[2] = crc[1];
crc[1] = crc[0];
crc[0] = newBit;
currByte >>= 1;
}
}
finalCRC = 0;
for (index=0; index<8; index++) {
finalCRC = (finalCRC << 1) | crc[index];
}
if (finalCRC != bROM[7]) {
debugIOLog (3, "[DALLAS] CRC Mismatch! 0x%02x 0x%02x", finalCRC, bROM[7]);
} else {
debugIOLog (3, "[DALLAS] ROM CRC Match: 0x%02x", finalCRC);
}
}
IORegistryEntry * FindEntryByProperty (const IORegistryEntry * start, const char * key, const char * value)
{
OSIterator *iterator;
IORegistryEntry *theEntry;
IORegistryEntry *tmpReg;
OSData *tmpData;
theEntry = NULL;
iterator = start->getChildIterator (gIODTPlane);
FailIf (NULL == iterator, Exit);
while (NULL == theEntry && (tmpReg = OSDynamicCast (IORegistryEntry, iterator->getNextObject ())) != NULL) {
tmpData = OSDynamicCast (OSData, tmpReg->getProperty (key));
if (NULL != tmpData && tmpData->isEqualTo (value, strlen (value))) {
theEntry = tmpReg;
}
}
Exit:
if (NULL != iterator) {
iterator->release ();
}
return theEntry;
}
bool AppleDallasDriver::init (OSDictionary *dict)
{
bool res = super::init (dict);
debugIOLog (3, "[DALLAS] AppleDallasDriver Initializing");
return res;
}
void AppleDallasDriver::free (void)
{
debugIOLog (3, "AppleDallasDriver Freeing");
CLEAN_RELEASE (gpioRegMem)
super::free ();
}
IOService *AppleDallasDriver::probe (IOService *provider, SInt32 *score)
{
IOService *res = super::probe (provider, score);
debugIOLog (3, "[DALLAS] AppleDallasDriver Probing");
return res;
}
bool AppleDallasDriver::readApplicationRegister (UInt8 *bAppReg)
{
IOMemoryMap *map = NULL;
UInt8 *gpioPtr = NULL;
int index;
bool failure;
bool resultSuccess;
int retryCount;
resultSuccess = FALSE;
map = gpioRegMem->map (0);
FailIf (!map, exit);
gpioPtr = (UInt8*)map->getVirtualAddress ();
debugIOLog (3, "[DALLAS] GPIO16 Register Value = 0x%02x", *gpioPtr);
FailIf (!gpioPtr, exit);
FailWithAction(ROMReset(gpioPtr), debugIOLog (3, "No speaker ROM detected"), exit);
failure = TRUE;
debugIOLog (3, "[DALLAS] Reading 64b Application Register");
retryCount = kRetryCountSeed;
for (index=0; index<8; index++) {
do {
while (failure && retryCount) {
ROMReset(gpioPtr);
failure = ROMSendByte(gpioPtr, kROMSkipROM, 0 );
failure = failure || ROMSendByte(gpioPtr, kROMReadAppReg, 1 );
failure = failure || ROMSendByte(gpioPtr, index, 2 );
retryCount--;
}
failure = ROMReadByte(gpioPtr, &bAppReg[index]);
} while (failure && retryCount);
}
if ( !failure ) {
resultSuccess = TRUE;
}
exit:
return resultSuccess;
}
bool AppleDallasDriver::readDataROM (UInt8 *bEEPROM,int dallasAddress, int size)
{
IOMemoryMap *map = NULL;
UInt8 tempData, *gpioPtr = NULL;
int index;
bool resultSuccess;
int retryCount, stateMachine;
debugIOLog (3, "+ AppleDallasDriver::readDataROM ( %X, %X, %X )", (unsigned int)bEEPROM, (unsigned int)dallasAddress, (unsigned int)size );
resultSuccess = FALSE;
FailIf ( NULL == bEEPROM, exit );
((DallasIDPtr)bEEPROM)->deviceFamily = kDeviceFamilyUndefined;
((DallasIDPtr)bEEPROM)->deviceType = kDallasSpeakerRESERVED;
((DallasIDPtr)bEEPROM)->deviceSubType = 0;
((DallasIDPtr)bEEPROM)->deviceReserved = 0;
map = gpioRegMem->map (0);
FailIf (!map, exit);
gpioPtr = (UInt8*)map->getVirtualAddress ();
debugIOLog (3, "[DALLAS] GPIO16 Register Value = 0x%02x", *gpioPtr );
FailIf (!gpioPtr, exit);
stateMachine = kSTATE_RESET_READ_MEMORY;
retryCount = kRetryCountSeed;
index = 0;
while( ( kSTATE_COMPLETED != stateMachine ) && ( 0 != retryCount ) ) {
switch ( stateMachine ) {
case kSTATE_RESET_READ_MEMORY:
if ( ROMReset ( gpioPtr ) ) {
debugIOLog (3, "... failed at kSTATE_RESET_READ_MEMORY %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSTATE_RESET_READ_MEMORY;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_CMD_SKIPROM_READ_MEMORY;
}
break;
case kSTATE_CMD_SKIPROM_READ_MEMORY:
if ( ROMSendByte ( gpioPtr, kROMSkipROM, stateMachine ) ) {
debugIOLog (3, "... failed at kSTATE_CMD_SKIPROM_READ_MEMORY %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSTATE_RESET_READ_MEMORY;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_CMD_READ_MEMORY;
}
break;
case kSTATE_CMD_READ_MEMORY:
if ( ROMSendByte ( gpioPtr, kROMReadMemory, stateMachine ) ) {
debugIOLog (3, "... failed at kSTATE_CMD_READ_MEMORY %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSTATE_RESET_READ_MEMORY;
if ( retryCount ) { retryCount--; }
} else {
if ( 0 != dallasAddress ) {
stateMachine = kSTATE_READ_MEMORY_ADDRESS;
} else {
stateMachine = kUSE_DESCRETE_BYTE_TRANSFER ? kSTATE_READ_MEMORY_ADDRESS : kSTATE_RESET_READ_SCRATCHPAD;
}
}
break;
case kSTATE_READ_MEMORY_ADDRESS:
if ( ROMSendByte ( gpioPtr, dallasAddress, stateMachine ) ) { debugIOLog (3, "... failed at kSTATE_READ_MEMORY_ADDRESS %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSTATE_RESET_READ_MEMORY;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_READ_MEMORY_DATA;
index = 0;
}
break;
case kSTATE_READ_MEMORY_DATA:
if ( ROMReadByte ( gpioPtr, &tempData ) ) {
debugIOLog (3, "... failed at kSTATE_READ_MEMORY_DATA %d, retryCount %d, byte %d", (unsigned int)stateMachine, (unsigned int)retryCount, (unsigned int)index );
stateMachine = kSTATE_RESET_READ_MEMORY;
if ( retryCount ) { retryCount--; }
} else {
index++;
if ( index == size ) { stateMachine = kSTATE_RESET_READ_SCRATCHPAD; }
}
break;
case kSTATE_RESET_READ_SCRATCHPAD:
if ( ROMReset ( gpioPtr ) ) {
debugIOLog (3, "... failed at kSTATE_RESET_READ_SCRATCHPAD %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSCRATCHPAD_RETRY_STATE;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_CMD_SKIPROM_SCRATCHPAD;
}
break;
case kSTATE_CMD_SKIPROM_SCRATCHPAD:
if ( ROMSendByte ( gpioPtr, kROMSkipROM, stateMachine ) ) {
debugIOLog (3, "... failed at kSTATE_CMD_SKIPROM_SCRATCHPAD %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSCRATCHPAD_RETRY_STATE;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_CMD_SCRATCHPAD;
}
break;
case kSTATE_CMD_SCRATCHPAD:
if ( ROMSendByte ( gpioPtr, kROMReadScratch, stateMachine ) ) {
debugIOLog (3, "... failed at kSTATE_CMD_SCRATCHPAD %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSCRATCHPAD_RETRY_STATE;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_SCRATCHPAD_ADDRESS;
}
break;
case kSTATE_SCRATCHPAD_ADDRESS:
if ( ROMSendByte ( gpioPtr, dallasAddress, stateMachine ) ) { debugIOLog (3, "... failed at kSTATE_SCRATCHPAD_ADDRESS %d, retryCount %d", (unsigned int)stateMachine, (unsigned int)retryCount );
stateMachine = kSCRATCHPAD_RETRY_STATE;
if ( retryCount ) { retryCount--; }
} else {
stateMachine = kSTATE_READ_SCRATCHPAD;
index = 0;
}
break;
case kSTATE_READ_SCRATCHPAD:
if ( ROMReadByte ( gpioPtr, &bEEPROM[index] ) ) {
debugIOLog (3, "... failed at kSTATE_READ_SCRATCHPAD %d, retryCount %d, byte %d", (unsigned int)stateMachine, (unsigned int)retryCount, (unsigned int)index );
stateMachine = kSCRATCHPAD_RETRY_STATE; if ( retryCount ) { retryCount--; }
} else {
switch ( index ) {
case 0:
if ( kDeviceFamilySpeaker == ((DallasIDPtr)bEEPROM)->deviceFamily ) {
index++;
if ( index >= size ) { stateMachine = kSTATE_COMPLETED; }
} else {
debugIOLog (3, "... failed with bad deviceFamily data %X, resetting state machine", ((DallasIDPtr)bEEPROM)->deviceFamily );
stateMachine = kSTATE_RESET_READ_MEMORY; }
break;
case 1:
if ( 0xFF != ((DallasIDPtr)bEEPROM)->deviceSubType ) {
index++;
if ( index >= size ) { stateMachine = kSTATE_COMPLETED; }
} else {
debugIOLog (3, "... failed with bad deviceSubType data %X, resetting state machine", ((DallasIDPtr)bEEPROM)->deviceSubType );
stateMachine = kSTATE_RESET_READ_MEMORY; }
break;
default:
index++;
if ( index >= size ) { stateMachine = kSTATE_COMPLETED; }
break;
}
}
break;
case kSTATE_COMPLETED:
break;
}
if ( retryCount && ( kSTATE_RESET_READ_MEMORY == stateMachine ) ) {
IOSleep ( 1 );
}
}
if ( kSTATE_COMPLETED == stateMachine ) { resultSuccess = TRUE; }
exit:
debugIOLog (3, "- AppleDallasDriver::readDataROM ( %X, %X, %X ) returns %X", (unsigned int)bEEPROM, (unsigned int)dallasAddress, (unsigned int)size, (unsigned int)resultSuccess );
debugIOLog (3, "[DALLAS] readDataROM returns %dx", (unsigned int)resultSuccess);
return resultSuccess;
}
bool AppleDallasDriver::readSerialNumberROM (UInt8 *bROM)
{
IOMemoryMap *map = NULL;
UInt8 *gpioPtr = NULL;
int index;
bool failure;
bool resultSuccess;
int retryCount;
resultSuccess = FALSE;
map = gpioRegMem->map (0);
FailIf (!map, exit);
gpioPtr = (UInt8*)map->getVirtualAddress ();
debugIOLog (3, "[DALLAS] GPIO16 Register Value = 0x%02x", *gpioPtr);
FailIf (!gpioPtr, exit);
FailWithAction(ROMReset(gpioPtr), debugIOLog (3, "[DALLAS] No speaker ROM detected"), exit);
failure = TRUE;
debugIOLog (3, "[DALLAS] Reading 64b ROM");
retryCount = kRetryCountSeed;
while (failure && retryCount) {
while (failure && retryCount) {
ROMReset(gpioPtr);
failure = ROMSendByte( gpioPtr, kROMReadROM, 0 );
retryCount--;
}
for ( index = 0; index < 8 && !failure; index++ ) {
failure |= ROMReadByte ( gpioPtr, &bROM[index] );
}
}
if ( !failure ) {
resultSuccess = TRUE;
}
exit:
return resultSuccess;
}
bool AppleDallasDriver::start(IOService *provider)
{
IORegistryEntry *gpio;
IORegistryEntry *dallasGPIO;
OSData *tmpData = NULL;
UInt32 *gpioAddr = NULL;
UInt8 bROM[8];
UInt8 bEEPROM[32];
UInt8 bAppReg[8];
bool result;
int index;
debugIOLog (3, "AppleDallasDriver Starting");
result = super::start(provider);
FailIf (FALSE == result, exit);
result = FALSE;
gpio = provider->getParentEntry (gIODTPlane);
FailIf (!gpio, exit);
dallasGPIO = FindEntryByProperty (gpio, "AAPL,driver-name", ".DallasDriver");
FailIf (!dallasGPIO, exit);
tmpData = OSDynamicCast (OSData, dallasGPIO->getProperty ("AAPL,address"));
FailIf (!tmpData, exit);
gpioAddr = (UInt32*)tmpData->getBytesNoCopy ();
FailIf (!gpioAddr, exit);
gpioRegMem = IODeviceMemory::withRange (*gpioAddr, sizeof (UInt8));
FailIf (!gpioRegMem, exit);
for (index = 0; index < 8; index++)
bROM[index] = 0;
for (index = 0; index < 32; index++)
bEEPROM[index] = 0;
for (index = 0; index < 8; index++)
bAppReg[index] = 0;
registerService ();
result = TRUE;
exit:
return result;
}
void AppleDallasDriver::stop (IOService *provider)
{
debugIOLog (3, "AppleDallasDriver Stopping");
super::stop (provider);
}
bool AppleDallasDriver::getSpeakerID (UInt8 *bEEPROM)
{
bool resultSuccess;
IOMemoryMap * map = NULL;
UInt8 * gpioPtr = NULL;
UInt8 savedGPIO;
debugIOLog (3, "+ AppleDallasDriver::getSpeakerID ( %X )", (unsigned int)bEEPROM );
resultSuccess = FALSE;
map = gpioRegMem->map (0);
FailIf (!map, exit);
gpioPtr = (UInt8*)map->getVirtualAddress ();
debugIOLog (3, "... GPIO16 Register Value = 0x%02x", *gpioPtr);
FailIf (!gpioPtr, exit);
savedGPIO = *gpioPtr;
if ( NULL != bEEPROM ) {
debugIOLog (3, "... About to readDataROM ( %X, %X, %X )", (unsigned int)bEEPROM, (unsigned int)kDallasIDAddress, (unsigned int)sizeof ( SpkrID ) );
resultSuccess = readDataROM (bEEPROM, kDallasIDAddress, sizeof ( SpkrID ) );
}
*gpioPtr = savedGPIO;
OSSynchronizeIO();
exit:
debugIOLog (3, "- AppleDallasDriver::getSpeakerID ( %X ) returns %X", (unsigned int)bEEPROM, (unsigned int)resultSuccess );
return resultSuccess;
}