27.10.2015 Views

Advanced Configuration and Power Interface Specification

ACPI_6.0

ACPI_6.0

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ACPI System Management Bus <strong>Interface</strong> <strong>Specification</strong><br />

// Receive a byte of data from the device<br />

Store(FLD0, BUFF)<br />

If(LEqual(STAT, 0x00))<br />

{<br />

// DATA = Received byte…<br />

}<br />

// Send the byte ‘0x16’ to the device<br />

Store(0x16, DATA)<br />

Store(BUFF, FLD0)<br />

// Invoke a Receive Byte transaction<br />

// Successful?<br />

// Save 0x16 into the data buffer<br />

// Invoke a Send Byte transaction<br />

In this example, a single field element (FLD0) at offset 0 is defined to represent the protocol’s data<br />

byte. Access to FLD0 will cause an SMBus transaction to occur to the device. Reading the field<br />

results in a Receive Byte, <strong>and</strong> writing to the field results in a Send Byte.<br />

13.3.3 Read/Write Byte (SMBByte)<br />

The SMBus Read/Write Byte protocol (SMBByte) also transfers a single byte of data. But unlike<br />

Send/Receive Byte, this protocol uses a comm<strong>and</strong> value to reference up to 256 byte-sized virtual<br />

registers.<br />

The following ASL code illustrates how a device supporting the Read/Write Byte protocol should be<br />

accessed:<br />

OperationRegion(SMBD, SMBus, 0x4200, 0x100) // SMBus device at slave address 0x42<br />

Field(SMBD, BufferAcc, NoLock, Preserve)<br />

{<br />

AccessAs(BufferAcc, SMBByte)<br />

// Use the SMBus Read/Write Byte protocol<br />

FLD0, 8, // Virtual register at comm<strong>and</strong> value 0.<br />

FLD1, 8, // Virtual register at comm<strong>and</strong> value 1.<br />

FLD2, 8 // Virtual register at comm<strong>and</strong> value 2.<br />

}<br />

Name(BUFF, Buffer(34){})<br />

CreateByteField(BUFF, 0x00, STAT)<br />

CreateByteField(BUFF, 0x02, DATA)<br />

// Create the SMBus data buffer<br />

// Create SMBus data buffer as BUFF<br />

// STAT = Status (Byte)<br />

// DATA = Data (Byte)<br />

// Read a byte of data from the device using comm<strong>and</strong> value 1<br />

Store(FLD1, BUFF)<br />

// Invoke a Read Byte transaction<br />

If(LEqual(STAT, 0x00))<br />

// Successful?<br />

{<br />

// DATA = Byte read from FLD1…<br />

}<br />

// Write the byte ‘0x16’ to the device using comm<strong>and</strong> value 2<br />

Store(0x16, DATA)<br />

// Save 0x16 into the data buffer<br />

Store(BUFF, FLD2)<br />

// Invoke a Write Byte transaction<br />

In this example, three field elements (FLD0, FLD1, <strong>and</strong> FLD2) are defined to represent the virtual<br />

registers for comm<strong>and</strong> values 0, 1, <strong>and</strong> 2. Access to any of the field elements will cause an SMBus<br />

transaction to occur to the device. Reading FLD1 results in a Read Byte with a comm<strong>and</strong> value of 1,<br />

<strong>and</strong> writing to FLD2 results in a Write Byte with comm<strong>and</strong> value 2.<br />

Version 6.0 671

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!