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.
17 // Intel SMBus Controller 0:1f.3
21 Name (_ADR, 0x001f0003)
23 #ifdef ENABLE_SMBUS_METHODS
24 OperationRegion (SMBP, PCI_Config, 0x00, 0x100)
25 Field(SMBP, DWordAcc, NoLock, Preserve)
32 OperationRegion (SMBI, SystemIO, SMBUS_IO_BASE, 0x20)
33 Field (SMBI, ByteAcc, NoLock, Preserve)
35 HSTS, 8, // Host Status
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
57 // Kill all SMBus communication
58 Method (KILL, 0, Serialized)
60 Or (HCNT, 0x02, HCNT) // Send Kill
61 Or (HSTS, 0xff, HSTS) // Clean Status
64 // Check if last operation completed
65 // return Failure = 0, Success = 1
66 Method (CMPL, 0, Serialized)
68 Store (4000, Local0) // Timeout 200ms in 50us steps
70 If (And(HSTS, 0x02)) { // Completion Status?
71 Return (1) // Operation Completed
75 If (LEqual(Local0, 0)) {
85 // Wait for SMBus to become ready
86 Method (SRDY, 0, Serialized)
88 Store (200, Local0) // Timeout 200ms
90 If (And(HSTS, 0x40)) { // IN_USE?
92 Decrement(Local0) // timeout--
93 If (LEqual(Local0, 0)) {
97 Store (0, Local0) // We're ready
101 Store (4000, Local0) // Timeout 200ms (50us * 4000)
103 If (And (HSTS, 0x01)) { // Host Busy?
104 Stall(50) // Wait 50us
105 Decrement(Local0) // timeout--
106 If (LEqual(Local0, 0)) {
110 Return (0) // Success
114 Return (1) // Failure
120 // Return: 1 = Success, 0=Failure
122 Method (SSXB, 2, Serialized)
125 // Is the SMBus Controller Ready?
131 Store (0, I2CE) // SMBus Enable
133 Store (Arg0, TXSA) // Write Address
134 Store (Arg1, HCMD) // Write Data
136 Store (0x48, HCNT) // Start + Byte Data Protocol
139 Or (HSTS, 0xff, HSTS) // Clean up
140 Return (1) // Success
147 // SMBus Receive Byte
149 // Return: 0xffff = Failure, Data (8bit) = Success
151 Method (SRXB, 2, Serialized)
154 // Is the SMBus Controller Ready?
160 Store (0, I2CE) // SMBus Enable
162 Store (Or (Arg0, 1), TXSA) // Write Address
164 Store (0x44, HCNT) // Start
167 Or (HSTS, 0xff, HSTS) // Clean up
168 Return (DAT0) // Success
179 // Return: 1 = Success, 0=Failure
181 Method (SWRB, 3, Serialized)
184 // Is the SMBus Controller Ready?
190 Store (0, I2CE) // SMBus Enable
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
199 Or (HSTS, 0xff, HSTS) // Clean up
200 Return (1) // Success
210 // Return: 0xffff = Failure, Data (8bit) = Success
212 Method (SRDB, 2, Serialized)
215 // Is the SMBus Controller Ready?
221 Store (0, I2CE) // SMBus Enable
223 Store (Or (Arg0, 1), TXSA) // Write Address
224 Store (Arg1, HCMD) // Command
226 Store (0x48, HCNT) // Start
229 Or (HSTS, 0xff, HSTS) // Clean up
230 Return (DAT0) // Success