/* Attached is the SMbus control sample code,
Customer may place this code into ACPI module and control CH7036 registers.
Change LVDS data format from 18bit to 24bit,
Write Reg03 to 04h (switch to Page 4)
Write Reg57[7:6] to 01
The method RBYT is for read i2c/smbus byte, and method WBYT is for write i2c/smbus byte.
The Arg0 is device address, it is 8bit for our CH7036 it should be 0xEC.
The Arg1 is the register index.
The Arg2 is the data for WBYT.
WBYT(0xEC, 0x03, 0x04)
WBYT(0xEC, 0x57, 0x40)
WBYT(0xEC, 0x03, 0x00) */
Name (SMBS, 0x0400)
OperationRegion (SMRG, SystemIO, SMBS, 0x10)
Field (SMRG, ByteAcc, NoLock, Preserve)
{
HSTS, 8,
SSTS, 8,
HSTC, 8,
HCMD, 8,
HADR, 8,
HDT0, 8,
HDT1, 8,
BLKD, 8
}
Method (SCMD, 4, NotSerialized)
{
Store (0x05, Local0)
While (Local0)
{
Store (Arg0, HADR)
Sleep (0x02)
Store (Arg1, HCMD)
Sleep (0x02)
Store (Arg2, Local1)
Store (Arg2, Local2)
And (Local2, 0xFF, Local2)
Store (Local2, HDT0)
Sleep (0x02)
ShiftRight (Local1, 0x08, Local1)
And (Local1, 0xFF, Local1)
Store (Local1, HDT1)
Sleep (0x02)
Store (0x02, Local2)
While (Local2)
{
Store (0xFF, HSTS)
Sleep (0x02)
And (HSTS, 0x02, Local2)
}
Store (Arg3, HSTC)
Sleep (0x02)
Store (0xFF, Local7)
While (Local7)
{
Decrement (Local7)
If (And (HSTS, 0x02))
{
Store (0x00, Local7)
Store (0x01, Local0)
}
}
Decrement (Local0)
}
If (And (HSTS, 0x02))
{
Store (HDT1, Local0)
Sleep (0x02)
ShiftLeft (Local0, 0x08, Local0)
Store (HDT0, Local1)
Return (Or (Local0, Local1))
}
Else
{
Return (0xFF)
}
}
Method (SBYT, 2, NotSerialized)
{
SCMD (Arg0, Arg1, 0x00, 0x44)
}
Method (WBYT, 3, NotSerialized)
{
SCMD (Arg0, Arg1, Arg2, 0x48)
}
Method (WWRD, 3, NotSerialized)
{
SCMD (Arg0, Arg1, Arg2, 0x4C)
}
Method (RSBT, 2, NotSerialized)
{
Or (Arg0, 0x01, Arg0)
Return (SCMD (Arg0, Arg1, 0x00, 0x44))
}
Method (RBYT, 2, NotSerialized)
{
Or (Arg0, 0x01, Arg0)
Return (SCMD (Arg0, Arg1, 0x00, 0x48))
}
Method (RWRD, 2, NotSerialized)
{
Or (Arg0, 0x01, Arg0)
Return (SCMD (Arg0, Arg1, 0x00, 0x4C))
}