Lines Matching +full:reset +full:- +full:on +full:- +full:timeout
1 // SPDX-License-Identifier: GPL-2.0-or-later
11 This is the driver for the SMB Host controller on
22 by comparing this driver to the i2c-ali15x3 driver.
26 ACPI-compliant Power Management Unit (PMU).
87 #define ALI1535_DEV10B_EN 0x80 /* Enable 10-bit addressing in */
89 #define ALI1535_T_OUT 0x08 /* Time-out Command (write) */
90 #define ALI1535_A_HIGH_BIT9 0x08 /* Bit 9 of 10-bit address in */
91 /* Alert-Response-Address */
94 #define ALI1535_A_HIGH_BIT8 0x04 /* Bit 8 of 10-bit address in */
95 /* Alert-Response-Address */
98 #define ALI1535_D_HI_MASK 0x03 /* Mask for isolating bits 9-8 */
99 /* of 10-bit address in I2C */
111 #define ALI1535_BLOCK_CLR 0x04 /* reset block data index */
116 /* -> Write = 0 */
117 /* -> Read = 1 */
134 - SMB I/O address is initialized in ali1535_setup()
135 - Device is enabled in ali1535_setup()
136 - We can use the addresses in ali1535_setup()
141 dev_err(&dev->dev, "ALI1535_smb can't enable device\n"); in ali1535_setup()
147 dev_dbg(&dev->dev, "ALI1535_smb is at offset 0x%04x\n", ali1535_offset); in ali1535_setup()
148 ali1535_offset &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1)); in ali1535_setup()
150 dev_warn(&dev->dev, in ali1535_setup()
151 "ALI1535_smb region uninitialized - upgrade BIOS?\n"); in ali1535_setup()
152 retval = -ENODEV; in ali1535_setup()
168 dev_err(&dev->dev, "ALI1535_smb region 0x%lx already in use!\n", in ali1535_setup()
170 retval = -EBUSY; in ali1535_setup()
177 dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n"); in ali1535_setup()
178 retval = -ENODEV; in ali1535_setup()
185 dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n"); in ali1535_setup()
186 retval = -ENODEV; in ali1535_setup()
198 dev_dbg(&dev->dev, "ALI1535 using Interrupt 9 for SMBus.\n"); in ali1535_setup()
201 dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); in ali1535_setup()
202 dev_dbg(&dev->dev, "ALI1535_smba = 0x%lx\n", ali1535_smba); in ali1535_setup()
216 int timeout = 0; in ali1535_transaction() local
218 dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, TYP=%02x, " in ali1535_transaction()
230 * in the previous transaction, resulting in a "SMBus Timeout" in ali1535_transaction()
231 * printk. I've tried the following to reset a stuck busy bit. in ali1535_transaction()
232 * 1. Reset the controller with an KILL command. (this in ali1535_transaction()
235 * 2. Reset the controller and the other SMBus devices with a in ali1535_transaction()
240 * case, nothing seems to work except power reset. in ali1535_transaction()
243 /* Try resetting entire SMB bus, including other devices - This in ali1535_transaction()
244 * may not work either - it clears the BUSY bit but then the in ali1535_transaction()
245 * BUSY bit may come back on when you try and use the chip in ali1535_transaction()
248 dev_info(&adap->dev, in ali1535_transaction()
257 /* do a clear-on-write */ in ali1535_transaction()
262 * power reset as one of the bits now appears to be in ali1535_transaction()
265 dev_err(&adap->dev, in ali1535_transaction()
266 "SMBus reset failed! (0x%02x) - controller or " in ali1535_transaction()
267 "device on bus is probably hung\n", temp); in ali1535_transaction()
268 return -EBUSY; in ali1535_transaction()
280 timeout = 0; in ali1535_transaction()
285 && (timeout++ < MAX_TIMEOUT)); in ali1535_transaction()
288 if (timeout > MAX_TIMEOUT) in ali1535_transaction()
289 result = -ETIMEDOUT; in ali1535_transaction()
292 result = -EIO; in ali1535_transaction()
293 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); in ali1535_transaction()
301 result = -ENXIO; in ali1535_transaction()
302 dev_dbg(&adap->dev, in ali1535_transaction()
309 result = -EIO; in ali1535_transaction()
310 dev_err(&adap->dev, "Error: device error\n"); in ali1535_transaction()
315 result = -ETIMEDOUT; in ali1535_transaction()
317 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, TYP=%02x, " in ali1535_transaction()
324 /* issue "kill" to reset host controller */ in ali1535_transaction()
328 /* issue "timeout" to reset all devices on bus */ in ali1535_transaction()
336 /* Return negative errno on error. */
343 int timeout; in ali1535_access() local
348 for (timeout = 0; in ali1535_access()
349 (timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE); in ali1535_access()
350 timeout++) { in ali1535_access()
354 if (timeout >= MAX_TIMEOUT) in ali1535_access()
355 dev_warn(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp); in ali1535_access()
357 /* clear status register (clear-on-write) */ in ali1535_access()
382 outb_p(data->byte, SMBHSTDAT0); in ali1535_access()
391 outb_p(data->word & 0xff, SMBHSTDAT0); in ali1535_access()
392 outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1); in ali1535_access()
402 len = data->block[0]; in ali1535_access()
405 data->block[0] = len; in ali1535_access()
409 data->block[0] = len; in ali1535_access()
412 /* Reset SMBBLKDAT */ in ali1535_access()
415 outb_p(data->block[i], SMBBLKDAT); in ali1535_access()
419 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); in ali1535_access()
420 result = -EOPNOTSUPP; in ali1535_access()
435 data->byte = inb_p(SMBHSTDAT0); in ali1535_access()
438 data->byte = inb_p(SMBHSTDAT0); in ali1535_access()
441 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); in ali1535_access()
447 data->block[0] = len; in ali1535_access()
448 /* Reset SMBBLKDAT */ in ali1535_access()
450 for (i = 1; i <= data->block[0]; i++) { in ali1535_access()
451 data->block[i] = inb_p(SMBBLKDAT); in ali1535_access()
452 dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n", in ali1535_access()
453 len, i, data->block[i]); in ali1535_access()
491 dev_warn(&dev->dev, in ali1535_probe()
493 return -ENODEV; in ali1535_probe()
497 ali1535_adapter.dev.parent = &dev->dev; in ali1535_probe()
518 * do not call pci_disable_device(dev) since it can cause hard hangs on in ali1535_remove()
519 * some systems during power-off in ali1535_remove()