ACPI SMBUS Control

/* 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))
                }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值