tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / southbridge / intel / sch / acpi / smbus.asl
blob3354b03c4be5c08f95682a7d366139da66f93368
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
17 // Intel SMBus Controller 0:1f.3
19 Device (SBUS)
21         Name (_ADR, 0x001f0003)
23         OperationRegion (SMBP, PCI_Config, 0x00, 0x100)
24         Field(SMBP, DWordAcc, NoLock, Preserve)
25         {
26                 Offset(0x40),
27                 ,       2,
28                 I2CE,   1
29         }
31         /*
32         OperationRegion (SMBI, SystemIO, 0x400, 0x20)
33         Field (SMBI, ByteAcc, NoLock, Preserve)
34         {
35                 HSTS,   8,      // Host Status
36                 ,       8,
37                 HCNT,   8,      // Host Control
38                 HCMD,   8,      // Host Command
39                 TXSA,   8,      // Transmit Slave Address
40                 DAT0,   8,      // Host Data 0
41                 DAT1,   8,      // Host Data 1
42                 HBDB,   8,      // Host Block Data Byte
43                 PECK,   8,      // Packet Error Check
44                 RXSA,   8,      // Receive Slave Address
45                 RXDA,   16,     // Receive Slave Data
46                 AUXS,   8,      // Auxiliary Status
47                 AUXC,   8,      // Auxiliary Control
48                 SLPC,   8,      // SMLink Pin Control
49                 SBPC,   8,      // SMBus Pin Control
50                 SSTS,   8,      // Slave Status
51                 SCMD,   8,      // Slave Command
52                 NADR,   8,      // Notify Device Address
53                 NDLB,   8,      // Notify Data Low Byte
54                 NDLH,   8,      // Notify Data High Byte
55         }
57         // Kill all SMBus communication
58         Method (KILL, 0, Serialized)
59         {
60                 Or (HCNT, 0x02, HCNT)   // Send Kill
61                 Or (HSTS, 0xff, HSTS)   // Clean Status
62         }
64         // Check if last operation completed
65         // return       Failure = 0, Success = 1
66         Method (CMPL, 0, Serialized)
67         {
68                 Store (4000, Local0)            // Timeout 200ms in 50us steps
69                 While (Local0) {
70                         If (And(HSTS, 0x02)) {  // Completion Status?
71                                 Return (1)      // Operation Completed
72                         } Else {
73                                 Stall (50)
74                                 Decrement (Local0)
75                                 If (LEqual(Local0, 0)) {
76                                         KILL()
77                                 }
78                         }
79                 }
81                 Return (0)              //  Failure
82         }
85         // Wait for SMBus to become ready
86         Method (SRDY, 0, Serialized)
87         {
88                 Store (200, Local0)     // Timeout 200ms
89                 While (Local0) {
90                         If (And(HSTS, 0x40)) {          // IN_USE?
91                                 Sleep(1)                // Wait 1ms
92                                 Decrement(Local0)       // timeout--
93                                 If (LEqual(Local0, 0)) {
94                                         Return (1)
95                                 }
96                         } Else {
97                                 Store (0, Local0)       // We're ready
98                         }
99                 }
101                 Store (4000, Local0)    // Timeout 200ms (50us * 4000)
102                 While (Local0) {
103                         If (And (HSTS, 0x01)) {         // Host Busy?
104                                 Stall(50)               // Wait 50us
105                                 Decrement(Local0)       // timeout--
106                                 If (LEqual(Local0, 0)) {
107                                         KILL()
108                                 }
109                         } Else {
110                                 Return (0)              // Success
111                         }
112                 }
114                 Return (1)              // Failure
115         }
117         // SMBus Send Byte
118         // Arg0:        Address
119         // Arg1:        Data
120         // Return:      1 = Success, 0=Failure
122         Method (SSXB, 2, Serialized)
123         {
125                 // Is the SMBus Controller Ready?
126                 If (SRDY()) {
127                         Return (0)
128                 }
130                 // Send Byte
131                 Store (0, I2CE)         // SMBus Enable
132                 Store (0xbf, HSTS)
133                 Store (Arg0, TXSA)      // Write Address
134                 Store (Arg1, HCMD)      // Write Data
136                 Store (0x48, HCNT)      // Start + Byte Data Protocol
138                 If (CMPL()) {
139                         Or (HSTS, 0xff, HSTS)   // Clean up
140                         Return (1)              // Success
141                 }
143                 Return (0)
144         }
147         // SMBus Receive Byte
148         // Arg0:        Address
149         // Return:      0xffff = Failure, Data (8bit) = Success
151         Method (SRXB, 2, Serialized)
152         {
154                 // Is the SMBus Controller Ready?
155                 If (SRDY()) {
156                         Return (0xffff)
157                 }
159                 // Receive Byte
160                 Store (0, I2CE)         // SMBus Enable
161                 Store (0xbf, HSTS)
162                 Store (Or (Arg0, 1), TXSA)      // Write Address
164                 Store (0x44, HCNT)      // Start
166                 If (CMPL()) {
167                         Or (HSTS, 0xff, HSTS)   // Clean up
168                         Return (DAT0)           // Success
169                 }
171                 Return (0xffff)
172         }
175         // SMBus Write Byte
176         // Arg0:        Address
177         // Arg1:        Command
178         // Arg2:        Data
179         // Return:      1 = Success, 0=Failure
181         Method (SWRB, 3, Serialized)
182         {
184                 // Is the SMBus Controller Ready?
185                 If (SRDY()) {
186                         Return (0)
187                 }
189                 // Send Byte
190                 Store (0, I2CE)         // SMBus Enable
191                 Store (0xbf, HSTS)
192                 Store (Arg0, TXSA)      // Write Address
193                 Store (Arg1, HCMD)      // Write Command
194                 Store (Arg2, DAT0)      // Write Data
196                 Store (0x48, HCNT)      // Start + Byte Protocol
198                 If (CMPL()) {
199                         Or (HSTS, 0xff, HSTS)   // Clean up
200                         Return (1)              // Success
201                 }
203                 Return (0)
204         }
207         // SMBus Read Byte
208         // Arg0:        Address
209         // Arg1:        Command
210         // Return:      0xffff = Failure, Data (8bit) = Success
212         Method (SRDB, 2, Serialized)
213         {
215                 // Is the SMBus Controller Ready?
216                 If (SRDY()) {
217                         Return (0xffff)
218                 }
220                 // Receive Byte
221                 Store (0, I2CE)                 // SMBus Enable
222                 Store (0xbf, HSTS)
223                 Store (Or (Arg0, 1), TXSA)      // Write Address
224                 Store (Arg1, HCMD)              // Command
226                 Store (0x48, HCNT)              // Start
228                 If (CMPL()) {
229                         Or (HSTS, 0xff, HSTS)   // Clean up
230                         Return (DAT0)           // Success
231                 }
233                 Return (0xffff)
234         }
235         */
237         // Todo: Does anyone ever use these?
238         // Missing: Read / Write Word
239         // Missing: Read / Write Block