Lines Matching +full:smbus +full:- +full:timeout +full:- +full:disable

1 // SPDX-License-Identifier: GPL-2.0-or-later
34 ACPI-compliant Power Management Unit (PMU).
47 /* Note: we assume there can only be one ALI15X3, with one SMBus interface */
59 /* ALI15X3 SMBus address offsets */
127 - SMB I/O address is initialized in ali15x3_setup()
128 - Device is enabled in ali15x3_setup()
129 - We can use the addresses in ali15x3_setup()
133 The data sheet says that the address registers are read-only in ali15x3_setup()
143 /* Determine the address of the SMBus area */ in ali15x3_setup()
145 ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1)); in ali15x3_setup()
147 dev_err(&ALI15X3_dev->dev, "ALI15X3_smb region uninitialized " in ali15x3_setup()
148 "- upgrade BIOS or use force_addr=0xaddr\n"); in ali15x3_setup()
149 return -ENODEV; in ali15x3_setup()
153 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); in ali15x3_setup()
157 return -EBUSY; in ali15x3_setup()
161 dev_err(&ALI15X3_dev->dev, in ali15x3_setup()
164 return -ENODEV; in ali15x3_setup()
170 dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n", in ali15x3_setup()
178 if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { in ali15x3_setup()
180 dev_err(&ALI15X3_dev->dev, in ali15x3_setup()
181 "force address failed - not supported?\n"); in ali15x3_setup()
188 dev_info(&ALI15X3_dev->dev, "enabling SMBus device\n"); in ali15x3_setup()
195 dev_info(&ALI15X3_dev->dev, "enabling SMBus controller\n"); in ali15x3_setup()
207 dev_dbg(&ALI15X3_dev->dev, "ALI15X3 using Interrupt 9 for SMBus.\n"); in ali15x3_setup()
210 dev_dbg(&ALI15X3_dev->dev, "SMBREV = 0x%X\n", temp); in ali15x3_setup()
211 dev_dbg(&ALI15X3_dev->dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba); in ali15x3_setup()
216 return -ENODEV; in ali15x3_setup()
224 int timeout = 0; in ali15x3_transaction() local
226 dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, " in ali15x3_transaction()
234 /* Make sure the SMBus host is ready to start transmitting */ in ali15x3_transaction()
239 previous transaction, resulting in a "SMBus Timeout" Dev. in ali15x3_transaction()
244 2. Reset the controller and the other SMBus devices with a in ali15x3_transaction()
248 3. Disable and reenable the controller in SMBHSTCFG in ali15x3_transaction()
251 /* Abort - reset the host controller */ in ali15x3_transaction()
253 Try resetting entire SMB bus, including other devices - in ali15x3_transaction()
254 This may not work either - it clears the BUSY bit but in ali15x3_transaction()
258 dev_info(&adap->dev, "Resetting entire SMB Bus to " in ali15x3_transaction()
266 /* do a clear-on-write */ in ali15x3_transaction()
273 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " in ali15x3_transaction()
276 return -EBUSY; in ali15x3_transaction()
289 timeout = 0; in ali15x3_transaction()
294 && (timeout++ < MAX_TIMEOUT)); in ali15x3_transaction()
296 /* If the SMBus is still busy, we give up */ in ali15x3_transaction()
297 if (timeout > MAX_TIMEOUT) in ali15x3_transaction()
298 result = -ETIMEDOUT; in ali15x3_transaction()
301 result = -EIO; in ali15x3_transaction()
302 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); in ali15x3_transaction()
312 result = -ENXIO; in ali15x3_transaction()
313 dev_dbg(&adap->dev, in ali15x3_transaction()
320 result = -EIO; in ali15x3_transaction()
321 dev_err(&adap->dev, "Error: device error\n"); in ali15x3_transaction()
323 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " in ali15x3_transaction()
337 int timeout; in ali15x3_access() local
339 /* clear all the bits (clear-on-write) */ in ali15x3_access()
341 /* make sure SMBus is idle */ in ali15x3_access()
343 for (timeout = 0; in ali15x3_access()
344 (timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE); in ali15x3_access()
345 timeout++) { in ali15x3_access()
349 if (timeout >= MAX_TIMEOUT) { in ali15x3_access()
350 dev_err(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp); in ali15x3_access()
371 outb_p(data->byte, SMBHSTDAT0); in ali15x3_access()
379 outb_p(data->word & 0xff, SMBHSTDAT0); in ali15x3_access()
380 outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1); in ali15x3_access()
389 len = data->block[0]; in ali15x3_access()
392 data->block[0] = len; in ali15x3_access()
396 data->block[0] = len; in ali15x3_access()
402 outb_p(data->block[i], SMBBLKDAT); in ali15x3_access()
407 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); in ali15x3_access()
408 return -EOPNOTSUPP; in ali15x3_access()
423 data->byte = inb_p(SMBHSTDAT0); in ali15x3_access()
426 data->byte = inb_p(SMBHSTDAT0); in ali15x3_access()
429 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); in ali15x3_access()
435 data->block[0] = len; in ali15x3_access()
438 for (i = 1; i <= data->block[0]; i++) { in ali15x3_access()
439 data->block[i] = inb_p(SMBBLKDAT); in ali15x3_access()
440 dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n", in ali15x3_access()
441 len, i, data->block[i]); in ali15x3_access()
476 dev_err(&dev->dev, in ali15x3_probe()
478 return -ENODEV; in ali15x3_probe()
482 ali15x3_adapter.dev.parent = &dev->dev; in ali15x3_probe()
485 "SMBus ALI15X3 adapter at %04x", ali15x3_smba); in ali15x3_probe()
507 MODULE_DESCRIPTION("ALI15X3 SMBus driver");