2 * This file is part of the coreboot project.
4 * Copyright (C) 2007-2009 coresystems GmbH
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
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22 // Intel SMBus Controller 0:1f.3
26 Name (_ADR, 0x001f0003)
28 #ifdef ENABLE_SMBUS_METHODS
29 OperationRegion (SMBP, PCI_Config, 0x00, 0x100)
30 Field(SMBP, DWordAcc, NoLock, Preserve)
37 OperationRegion (SMBI, SystemIO, SMBUS_IO_BASE, 0x20)
38 Field (SMBI, ByteAcc, NoLock, Preserve)
40 HSTS, 8, // Host Status
42 HCNT, 8, // Host Control
43 HCMD, 8, // Host Command
44 TXSA, 8, // Transmit Slave Address
45 DAT0, 8, // Host Data 0
46 DAT1, 8, // Host Data 1
47 HBDB, 8, // Host Block Data Byte
48 PECK, 8, // Packet Error Check
49 RXSA, 8, // Receive Slave Address
50 RXDA, 16, // Receive Slave Data
51 AUXS, 8, // Auxiliary Status
52 AUXC, 8, // Auxiliary Control
53 SLPC, 8, // SMLink Pin Control
54 SBPC, 8, // SMBus Pin Control
55 SSTS, 8, // Slave Status
56 SCMD, 8, // Slave Command
57 NADR, 8, // Notify Device Address
58 NDLB, 8, // Notify Data Low Byte
59 NDLH, 8, // Notify Data High Byte
62 // Kill all SMBus communication
63 Method (KILL, 0, Serialized)
65 Or (HCNT, 0x02, HCNT) // Send Kill
66 Or (HSTS, 0xff, HSTS) // Clean Status
69 // Check if last operation completed
70 // return Failure = 0, Success = 1
71 Method (CMPL, 0, Serialized)
73 Store (4000, Local0) // Timeout 200ms in 50us steps
75 If (And(HSTS, 0x02)) { // Completion Status?
76 Return (1) // Operation Completed
80 If (LEqual(Local0, 0)) {
90 // Wait for SMBus to become ready
91 Method (SRDY, 0, Serialized)
93 Store (200, Local0) // Timeout 200ms
95 If (And(HSTS, 0x40)) { // IN_USE?
97 Decrement(Local0) // timeout--
98 If (LEqual(Local0, 0)) {
102 Store (0, Local0) // We're ready
106 Store (4000, Local0) // Timeout 200ms (50us * 4000)
108 If (And (HSTS, 0x01)) { // Host Busy?
109 Stall(50) // Wait 50us
110 Decrement(Local0) // timeout--
111 If (LEqual(Local0, 0)) {
115 Return (0) // Success
119 Return (1) // Failure
125 // Return: 1 = Success, 0=Failure
127 Method (SSXB, 2, Serialized)
130 // Is the SMBus Controller Ready?
136 Store (0, I2CE) // SMBus Enable
138 Store (Arg0, TXSA) // Write Address
139 Store (Arg1, HCMD) // Write Data
141 Store (0x48, HCNT) // Start + Byte Data Protocol
144 Or (HSTS, 0xff, HSTS) // Clean up
145 Return (1) // Success
152 // SMBus Receive Byte
154 // Return: 0xffff = Failure, Data (8bit) = Success
156 Method (SRXB, 2, Serialized)
159 // Is the SMBus Controller Ready?
165 Store (0, I2CE) // SMBus Enable
167 Store (Or (Arg0, 1), TXSA) // Write Address
169 Store (0x44, HCNT) // Start
172 Or (HSTS, 0xff, HSTS) // Clean up
173 Return (DAT0) // Success
184 // Return: 1 = Success, 0=Failure
186 Method (SWRB, 3, Serialized)
189 // Is the SMBus Controller Ready?
195 Store (0, I2CE) // SMBus Enable
197 Store (Arg0, TXSA) // Write Address
198 Store (Arg1, HCMD) // Write Command
199 Store (Arg2, DAT0) // Write Data
201 Store (0x48, HCNT) // Start + Byte Protocol
204 Or (HSTS, 0xff, HSTS) // Clean up
205 Return (1) // Success
215 // Return: 0xffff = Failure, Data (8bit) = Success
217 Method (SRDB, 2, Serialized)
220 // Is the SMBus Controller Ready?
226 Store (0, I2CE) // SMBus Enable
228 Store (Or (Arg0, 1), TXSA) // Write Address
229 Store (Arg1, HCMD) // Command
231 Store (0x48, HCNT) // Start
234 Or (HSTS, 0xff, HSTS) // Clean up
235 Return (DAT0) // Success