27.10.2015 Views

Advanced Configuration and Power Interface Specification

ACPI_6.0

ACPI_6.0

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ACPI Software Programming Model<br />

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

Store(0x16, DATA)<br />

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

Store(BUFF, FLD0)<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 a GenericSerialBus transaction to occur to the device. Reading the<br />

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

5.5.2.4.5.3.3 Read/Write Byte (AttribByte)<br />

The GenericSerialBus Read/Write Byte protocol (AttribByte) also transfers a single byte of data.<br />

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

virtual registers.<br />

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

accessed:<br />

OperationRegion(TOP1, GenericSerialBus, 0x00, 0x100) // GenericSerialBus device at comm<strong>and</strong> value<br />

offset<br />

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

{<br />

Connection(I2CSerialBus(0x5a,,100000,,"\_SB.I2C",,,,RawDataBuffer(){1,6}))<br />

AccessAs(BufferAcc, AttribByte) // Use the GenericSerialBus 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 />

// Create the GenericSerialBus data buffer<br />

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

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

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

CreateByteField(BUFF, 0x02, DATA) // 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 a<br />

GenericSerialBus transaction to occur to the device. Reading FLD1 results in a Read Byte with a<br />

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

5.5.2.4.5.3.4 Read/Write Word (AttribWord)<br />

The GenericSerialBus Read/Write Word protocol (AttribWord) transfers 2 bytes of data. This<br />

protocol also uses a comm<strong>and</strong> value to reference up to 256 word-sized virtual device registers.<br />

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

be accessed:<br />

Version 6.0 235

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

Saved successfully!

Ooh no, something went wrong!