ichsmb.c (179622) | ichsmb.c (188077) |
---|---|
1/*- 2 * ichsmb.c 3 * 4 * Author: Archie Cobbs <archie@freebsd.org> 5 * Copyright (c) 2000 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 22 unchanged lines hidden (view full) --- 31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35 * OF SUCH DAMAGE. 36 */ 37 38#include <sys/cdefs.h> | 1/*- 2 * ichsmb.c 3 * 4 * Author: Archie Cobbs <archie@freebsd.org> 5 * Copyright (c) 2000 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 22 unchanged lines hidden (view full) --- 31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35 * OF SUCH DAMAGE. 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/dev/ichsmb/ichsmb.c 179622 2008-06-06 18:29:56Z jhb $"); | 39__FBSDID("$FreeBSD: head/sys/dev/ichsmb/ichsmb.c 188077 2009-02-03 16:14:37Z jhb $"); |
40 41/* 42 * Support for the SMBus controller logical device which is part of the 43 * Intel 81801AA (ICH) and 81801AB (ICH0) I/O controller hub chips. 44 * 45 * This driver assumes that the generic SMBus code will ensure that 46 * at most one process at a time calls into the SMBus methods below. 47 */ --- 129 unchanged lines hidden (view full) --- 177 KASSERT(sc->ich_cmd == -1, 178 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 179 switch (how) { 180 case SMB_QREAD: 181 case SMB_QWRITE: 182 mtx_lock(&sc->mutex); 183 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_QUICK; 184 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 40 41/* 42 * Support for the SMBus controller logical device which is part of the 43 * Intel 81801AA (ICH) and 81801AB (ICH0) I/O controller hub chips. 44 * 45 * This driver assumes that the generic SMBus code will ensure that 46 * at most one process at a time calls into the SMBus methods below. 47 */ --- 129 unchanged lines hidden (view full) --- 177 KASSERT(sc->ich_cmd == -1, 178 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 179 switch (how) { 180 case SMB_QREAD: 181 case SMB_QWRITE: 182 mtx_lock(&sc->mutex); 183 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_QUICK; 184 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
185 (slave << 1) | (how == SMB_QREAD ? | 185 slave | (how == SMB_QREAD ? |
186 ICH_XMIT_SLVA_READ : ICH_XMIT_SLVA_WRITE)); 187 bus_write_1(sc->io_res, ICH_HST_CNT, 188 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 189 smb_error = ichsmb_wait(sc); 190 mtx_unlock(&sc->mutex); 191 break; 192 default: 193 smb_error = SMB_ENOTSUPP; --- 9 unchanged lines hidden (view full) --- 203 int smb_error; 204 205 DBG("slave=0x%02x byte=0x%02x\n", slave, (u_char)byte); 206 KASSERT(sc->ich_cmd == -1, 207 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 208 mtx_lock(&sc->mutex); 209 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; 210 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 186 ICH_XMIT_SLVA_READ : ICH_XMIT_SLVA_WRITE)); 187 bus_write_1(sc->io_res, ICH_HST_CNT, 188 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 189 smb_error = ichsmb_wait(sc); 190 mtx_unlock(&sc->mutex); 191 break; 192 default: 193 smb_error = SMB_ENOTSUPP; --- 9 unchanged lines hidden (view full) --- 203 int smb_error; 204 205 DBG("slave=0x%02x byte=0x%02x\n", slave, (u_char)byte); 206 KASSERT(sc->ich_cmd == -1, 207 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 208 mtx_lock(&sc->mutex); 209 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; 210 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
211 (slave << 1) | ICH_XMIT_SLVA_WRITE); | 211 slave | ICH_XMIT_SLVA_WRITE); |
212 bus_write_1(sc->io_res, ICH_HST_CMD, byte); 213 bus_write_1(sc->io_res, ICH_HST_CNT, 214 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 215 smb_error = ichsmb_wait(sc); 216 mtx_unlock(&sc->mutex); 217 DBG("smb_error=%d\n", smb_error); 218 return (smb_error); 219} --- 5 unchanged lines hidden (view full) --- 225 int smb_error; 226 227 DBG("slave=0x%02x\n", slave); 228 KASSERT(sc->ich_cmd == -1, 229 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 230 mtx_lock(&sc->mutex); 231 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; 232 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 212 bus_write_1(sc->io_res, ICH_HST_CMD, byte); 213 bus_write_1(sc->io_res, ICH_HST_CNT, 214 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 215 smb_error = ichsmb_wait(sc); 216 mtx_unlock(&sc->mutex); 217 DBG("smb_error=%d\n", smb_error); 218 return (smb_error); 219} --- 5 unchanged lines hidden (view full) --- 225 int smb_error; 226 227 DBG("slave=0x%02x\n", slave); 228 KASSERT(sc->ich_cmd == -1, 229 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 230 mtx_lock(&sc->mutex); 231 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; 232 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
233 (slave << 1) | ICH_XMIT_SLVA_READ); | 233 slave | ICH_XMIT_SLVA_READ); |
234 bus_write_1(sc->io_res, ICH_HST_CNT, 235 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 236 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) 237 *byte = bus_read_1(sc->io_res, ICH_D0); 238 mtx_unlock(&sc->mutex); 239 DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte); 240 return (smb_error); 241} --- 6 unchanged lines hidden (view full) --- 248 249 DBG("slave=0x%02x cmd=0x%02x byte=0x%02x\n", 250 slave, (u_char)cmd, (u_char)byte); 251 KASSERT(sc->ich_cmd == -1, 252 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 253 mtx_lock(&sc->mutex); 254 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; 255 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 234 bus_write_1(sc->io_res, ICH_HST_CNT, 235 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 236 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) 237 *byte = bus_read_1(sc->io_res, ICH_D0); 238 mtx_unlock(&sc->mutex); 239 DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte); 240 return (smb_error); 241} --- 6 unchanged lines hidden (view full) --- 248 249 DBG("slave=0x%02x cmd=0x%02x byte=0x%02x\n", 250 slave, (u_char)cmd, (u_char)byte); 251 KASSERT(sc->ich_cmd == -1, 252 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 253 mtx_lock(&sc->mutex); 254 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; 255 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
256 (slave << 1) | ICH_XMIT_SLVA_WRITE); | 256 slave | ICH_XMIT_SLVA_WRITE); |
257 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 258 bus_write_1(sc->io_res, ICH_D0, byte); 259 bus_write_1(sc->io_res, ICH_HST_CNT, 260 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 261 smb_error = ichsmb_wait(sc); 262 mtx_unlock(&sc->mutex); 263 DBG("smb_error=%d\n", smb_error); 264 return (smb_error); --- 7 unchanged lines hidden (view full) --- 272 273 DBG("slave=0x%02x cmd=0x%02x word=0x%04x\n", 274 slave, (u_char)cmd, (u_int16_t)word); 275 KASSERT(sc->ich_cmd == -1, 276 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 277 mtx_lock(&sc->mutex); 278 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; 279 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 257 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 258 bus_write_1(sc->io_res, ICH_D0, byte); 259 bus_write_1(sc->io_res, ICH_HST_CNT, 260 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 261 smb_error = ichsmb_wait(sc); 262 mtx_unlock(&sc->mutex); 263 DBG("smb_error=%d\n", smb_error); 264 return (smb_error); --- 7 unchanged lines hidden (view full) --- 272 273 DBG("slave=0x%02x cmd=0x%02x word=0x%04x\n", 274 slave, (u_char)cmd, (u_int16_t)word); 275 KASSERT(sc->ich_cmd == -1, 276 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 277 mtx_lock(&sc->mutex); 278 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; 279 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
280 (slave << 1) | ICH_XMIT_SLVA_WRITE); | 280 slave | ICH_XMIT_SLVA_WRITE); |
281 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 282 bus_write_1(sc->io_res, ICH_D0, word & 0xff); 283 bus_write_1(sc->io_res, ICH_D1, word >> 8); 284 bus_write_1(sc->io_res, ICH_HST_CNT, 285 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 286 smb_error = ichsmb_wait(sc); 287 mtx_unlock(&sc->mutex); 288 DBG("smb_error=%d\n", smb_error); --- 7 unchanged lines hidden (view full) --- 296 int smb_error; 297 298 DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd); 299 KASSERT(sc->ich_cmd == -1, 300 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 301 mtx_lock(&sc->mutex); 302 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; 303 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 281 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 282 bus_write_1(sc->io_res, ICH_D0, word & 0xff); 283 bus_write_1(sc->io_res, ICH_D1, word >> 8); 284 bus_write_1(sc->io_res, ICH_HST_CNT, 285 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 286 smb_error = ichsmb_wait(sc); 287 mtx_unlock(&sc->mutex); 288 DBG("smb_error=%d\n", smb_error); --- 7 unchanged lines hidden (view full) --- 296 int smb_error; 297 298 DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd); 299 KASSERT(sc->ich_cmd == -1, 300 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 301 mtx_lock(&sc->mutex); 302 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; 303 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
304 (slave << 1) | ICH_XMIT_SLVA_READ); | 304 slave | ICH_XMIT_SLVA_READ); |
305 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 306 bus_write_1(sc->io_res, ICH_HST_CNT, 307 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 308 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) 309 *byte = bus_read_1(sc->io_res, ICH_D0); 310 mtx_unlock(&sc->mutex); 311 DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte); 312 return (smb_error); --- 6 unchanged lines hidden (view full) --- 319 int smb_error; 320 321 DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd); 322 KASSERT(sc->ich_cmd == -1, 323 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 324 mtx_lock(&sc->mutex); 325 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; 326 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 305 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 306 bus_write_1(sc->io_res, ICH_HST_CNT, 307 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 308 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) 309 *byte = bus_read_1(sc->io_res, ICH_D0); 310 mtx_unlock(&sc->mutex); 311 DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte); 312 return (smb_error); --- 6 unchanged lines hidden (view full) --- 319 int smb_error; 320 321 DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd); 322 KASSERT(sc->ich_cmd == -1, 323 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 324 mtx_lock(&sc->mutex); 325 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; 326 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
327 (slave << 1) | ICH_XMIT_SLVA_READ); | 327 slave | ICH_XMIT_SLVA_READ); |
328 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 329 bus_write_1(sc->io_res, ICH_HST_CNT, 330 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 331 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) { 332 *word = (bus_read_1(sc->io_res, 333 ICH_D0) & 0xff) 334 | (bus_read_1(sc->io_res, 335 ICH_D1) << 8); --- 11 unchanged lines hidden (view full) --- 347 348 DBG("slave=0x%02x cmd=0x%02x sdata=0x%04x\n", 349 slave, (u_char)cmd, (u_int16_t)sdata); 350 KASSERT(sc->ich_cmd == -1, 351 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 352 mtx_lock(&sc->mutex); 353 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_PROC_CALL; 354 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 328 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 329 bus_write_1(sc->io_res, ICH_HST_CNT, 330 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 331 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) { 332 *word = (bus_read_1(sc->io_res, 333 ICH_D0) & 0xff) 334 | (bus_read_1(sc->io_res, 335 ICH_D1) << 8); --- 11 unchanged lines hidden (view full) --- 347 348 DBG("slave=0x%02x cmd=0x%02x sdata=0x%04x\n", 349 slave, (u_char)cmd, (u_int16_t)sdata); 350 KASSERT(sc->ich_cmd == -1, 351 ("%s: ich_cmd=%d\n", __func__ , sc->ich_cmd)); 352 mtx_lock(&sc->mutex); 353 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_PROC_CALL; 354 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
355 (slave << 1) | ICH_XMIT_SLVA_WRITE); | 355 slave | ICH_XMIT_SLVA_WRITE); |
356 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 357 bus_write_1(sc->io_res, ICH_D0, sdata & 0xff); 358 bus_write_1(sc->io_res, ICH_D1, sdata >> 8); 359 bus_write_1(sc->io_res, ICH_HST_CNT, 360 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 361 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) { 362 *rdata = (bus_read_1(sc->io_res, 363 ICH_D0) & 0xff) --- 34 unchanged lines hidden (view full) --- 398 bcopy(buf, sc->block_data, count); 399 sc->block_count = count; 400 sc->block_index = 1; 401 sc->block_write = 1; 402 403 mtx_lock(&sc->mutex); 404 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; 405 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 356 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 357 bus_write_1(sc->io_res, ICH_D0, sdata & 0xff); 358 bus_write_1(sc->io_res, ICH_D1, sdata >> 8); 359 bus_write_1(sc->io_res, ICH_HST_CNT, 360 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 361 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) { 362 *rdata = (bus_read_1(sc->io_res, 363 ICH_D0) & 0xff) --- 34 unchanged lines hidden (view full) --- 398 bcopy(buf, sc->block_data, count); 399 sc->block_count = count; 400 sc->block_index = 1; 401 sc->block_write = 1; 402 403 mtx_lock(&sc->mutex); 404 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; 405 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
406 (slave << 1) | ICH_XMIT_SLVA_WRITE); | 406 slave | ICH_XMIT_SLVA_WRITE); |
407 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 408 bus_write_1(sc->io_res, ICH_D0, count); 409 bus_write_1(sc->io_res, ICH_BLOCK_DB, buf[0]); 410 bus_write_1(sc->io_res, ICH_HST_CNT, 411 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 412 smb_error = ichsmb_wait(sc); 413 mtx_unlock(&sc->mutex); 414 DBG("smb_error=%d\n", smb_error); --- 14 unchanged lines hidden (view full) --- 429 bzero(sc->block_data, sizeof(sc->block_data)); 430 sc->block_count = 0; 431 sc->block_index = 0; 432 sc->block_write = 0; 433 434 mtx_lock(&sc->mutex); 435 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; 436 bus_write_1(sc->io_res, ICH_XMIT_SLVA, | 407 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 408 bus_write_1(sc->io_res, ICH_D0, count); 409 bus_write_1(sc->io_res, ICH_BLOCK_DB, buf[0]); 410 bus_write_1(sc->io_res, ICH_HST_CNT, 411 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 412 smb_error = ichsmb_wait(sc); 413 mtx_unlock(&sc->mutex); 414 DBG("smb_error=%d\n", smb_error); --- 14 unchanged lines hidden (view full) --- 429 bzero(sc->block_data, sizeof(sc->block_data)); 430 sc->block_count = 0; 431 sc->block_index = 0; 432 sc->block_write = 0; 433 434 mtx_lock(&sc->mutex); 435 sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; 436 bus_write_1(sc->io_res, ICH_XMIT_SLVA, |
437 (slave << 1) | ICH_XMIT_SLVA_READ); | 437 slave | ICH_XMIT_SLVA_READ); |
438 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 439 bus_write_1(sc->io_res, ICH_D0, *count); /* XXX? */ 440 bus_write_1(sc->io_res, ICH_HST_CNT, 441 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 442 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) { 443 bcopy(sc->block_data, buf, min(sc->block_count, *count)); 444 *count = sc->block_count; 445 } --- 254 unchanged lines hidden --- | 438 bus_write_1(sc->io_res, ICH_HST_CMD, cmd); 439 bus_write_1(sc->io_res, ICH_D0, *count); /* XXX? */ 440 bus_write_1(sc->io_res, ICH_HST_CNT, 441 ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); 442 if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) { 443 bcopy(sc->block_data, buf, min(sc->block_count, *count)); 444 *count = sc->block_count; 445 } --- 254 unchanged lines hidden --- |