2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 // Intel SMBus Controller 0:1f.3
19 Name (_ADR, 0x001f0003)
21 #ifdef ENABLE_SMBUS_METHODS
22 OperationRegion (SMBP, PCI_Config, 0x00, 0x100)
23 Field(SMBP, DWordAcc, NoLock, Preserve)
30 OperationRegion (SMBI, SystemIO, SMBUS_IO_BASE, 0x20)
31 Field (SMBI, ByteAcc, NoLock, Preserve)
33 HSTS, 8, // Host Status
35 HCNT, 8, // Host Control
36 HCMD, 8, // Host Command
37 TXSA, 8, // Transmit Slave Address
38 DAT0, 8, // Host Data 0
39 DAT1, 8, // Host Data 1
40 HBDB, 8, // Host Block Data Byte
41 PECK, 8, // Packet Error Check
42 RXSA, 8, // Receive Slave Address
43 RXDA, 16, // Receive Slave Data
44 AUXS, 8, // Auxiliary Status
45 AUXC, 8, // Auxiliary Control
46 SLPC, 8, // SMLink Pin Control
47 SBPC, 8, // SMBus Pin Control
48 SSTS, 8, // Slave Status
49 SCMD, 8, // Slave Command
50 NADR, 8, // Notify Device Address
51 NDLB, 8, // Notify Data Low Byte
52 NDLH, 8, // Notify Data High Byte
55 // Kill all SMBus communication
56 Method (KILL, 0, Serialized)
58 Or (HCNT, 0x02, HCNT) // Send Kill
59 Or (HSTS, 0xff, HSTS) // Clean Status
62 // Check if last operation completed
63 // return Failure = 0, Success = 1
64 Method (CMPL, 0, Serialized)
66 Store (4000, Local0) // Timeout 200ms in 50us steps
68 If (And(HSTS, 0x02)) { // Completion Status?
69 Return (1) // Operation Completed
73 If (LEqual(Local0, 0)) {
83 // Wait for SMBus to become ready
84 Method (SRDY, 0, Serialized)
86 Store (200, Local0) // Timeout 200ms
88 If (And(HSTS, 0x40)) { // IN_USE?
90 Decrement(Local0) // timeout--
91 If (LEqual(Local0, 0)) {
95 Store (0, Local0) // We're ready
99 Store (4000, Local0) // Timeout 200ms (50us * 4000)
101 If (And (HSTS, 0x01)) { // Host Busy?
102 Stall(50) // Wait 50us
103 Decrement(Local0) // timeout--
104 If (LEqual(Local0, 0)) {
108 Return (0) // Success
112 Return (1) // Failure
118 // Return: 1 = Success, 0=Failure
120 Method (SSXB, 2, Serialized)
123 // Is the SMBus Controller Ready?
129 Store (0, I2CE) // SMBus Enable
131 Store (Arg0, TXSA) // Write Address
132 Store (Arg1, HCMD) // Write Data
134 Store (0x48, HCNT) // Start + Byte Data Protocol
137 Or (HSTS, 0xff, HSTS) // Clean up
138 Return (1) // Success
145 // SMBus Receive Byte
147 // Return: 0xffff = Failure, Data (8bit) = Success
149 Method (SRXB, 2, Serialized)
152 // Is the SMBus Controller Ready?
158 Store (0, I2CE) // SMBus Enable
160 Store (Or (Arg0, 1), TXSA) // Write Address
162 Store (0x44, HCNT) // Start
165 Or (HSTS, 0xff, HSTS) // Clean up
166 Return (DAT0) // Success
177 // Return: 1 = Success, 0=Failure
179 Method (SWRB, 3, Serialized)
182 // Is the SMBus Controller Ready?
188 Store (0, I2CE) // SMBus Enable
190 Store (Arg0, TXSA) // Write Address
191 Store (Arg1, HCMD) // Write Command
192 Store (Arg2, DAT0) // Write Data
194 Store (0x48, HCNT) // Start + Byte Protocol
197 Or (HSTS, 0xff, HSTS) // Clean up
198 Return (1) // Success
208 // Return: 0xffff = Failure, Data (8bit) = Success
210 Method (SRDB, 2, Serialized)
213 // Is the SMBus Controller Ready?
219 Store (0, I2CE) // SMBus Enable
221 Store (Or (Arg0, 1), TXSA) // Write Address
222 Store (Arg1, HCMD) // Command
224 Store (0x48, HCNT) // Start
227 Or (HSTS, 0xff, HSTS) // Clean up
228 Return (DAT0) // Success