Lines Matching +full:ati +full:- +full:target

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl> and
11 Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
12 ATI IXP200, IXP300, IXP400, SB600, SB700/SP5100, SB800
13 AMD Hudson-2, ML, CZ
32 #include <linux/i2c-smbus.h>
75 /* Multi-port constants */
89 * Hudson-2/Bolton port is always selected by bits 2:1 of register 0x2f.
129 DMI_MATCH(DMI_BOARD_NAME, "PC-AM2RD790"),
143 on Intel-based systems */
181 if (mmio_cfg->use_mmio) { in piix4_sb800_region_request()
190 return -EBUSY; in piix4_sb800_region_request()
199 return -ENOMEM; in piix4_sb800_region_request()
202 mmio_cfg->addr = addr; in piix4_sb800_region_request()
212 return -EBUSY; in piix4_sb800_region_request()
221 if (mmio_cfg->use_mmio) { in piix4_sb800_region_release()
222 iounmap(mmio_cfg->addr); in piix4_sb800_region_release()
238 return (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD && in piix4_sb800_use_mmio()
239 PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && in piix4_sb800_use_mmio()
240 PIIX4_dev->revision >= 0x51); in piix4_sb800_use_mmio()
249 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && in piix4_setup()
250 (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5)) in piix4_setup()
256 dev_err(&PIIX4_dev->dev, in piix4_setup()
258 return -EPERM; in piix4_setup()
263 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) { in piix4_setup()
264 dev_err(&PIIX4_dev->dev, "IBM system detected; this module " in piix4_setup()
267 return -EPERM; in piix4_setup()
278 dev_err(&PIIX4_dev->dev, "SMBus base address " in piix4_setup()
279 "uninitialized - upgrade BIOS or use " in piix4_setup()
281 return -ENODEV; in piix4_setup()
286 return -ENODEV; in piix4_setup()
289 dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n", in piix4_setup()
291 return -EBUSY; in piix4_setup()
302 dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to " in piix4_setup()
316 dev_notice(&PIIX4_dev->dev, in piix4_setup()
319 dev_err(&PIIX4_dev->dev, in piix4_setup()
322 return -ENODEV; in piix4_setup()
327 dev_dbg(&PIIX4_dev->dev, "Using IRQ for SMBus\n"); in piix4_setup()
329 dev_dbg(&PIIX4_dev->dev, "Using SMI# for SMBus\n"); in piix4_setup()
331 dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration " in piix4_setup()
335 dev_info(&PIIX4_dev->dev, in piix4_setup()
354 retval = piix4_sb800_region_request(&PIIX4_dev->dev, &mmio_cfg); in piix4_setup_sb800_smba()
368 piix4_sb800_region_release(&PIIX4_dev->dev, &mmio_cfg); in piix4_setup_sb800_smba()
381 dev_err(&PIIX4_dev->dev, in piix4_setup_sb800_smba()
383 return -ENODEV; in piix4_setup_sb800_smba()
400 dev_err(&PIIX4_dev->dev, "SMBus does not support " in piix4_setup_sb800()
402 return -EINVAL; in piix4_setup_sb800()
406 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_AMD && in piix4_setup_sb800()
407 PIIX4_dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && in piix4_setup_sb800()
408 PIIX4_dev->revision >= 0x41) || in piix4_setup_sb800()
409 (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD && in piix4_setup_sb800()
410 PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && in piix4_setup_sb800()
411 PIIX4_dev->revision >= 0x49) || in piix4_setup_sb800()
412 (PIIX4_dev->vendor == PCI_VENDOR_ID_HYGON && in piix4_setup_sb800()
413 PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS)) in piix4_setup_sb800()
425 return -ENODEV; in piix4_setup_sb800()
428 dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n", in piix4_setup_sb800()
430 return -EBUSY; in piix4_setup_sb800()
435 dev_info(&PIIX4_dev->dev, in piix4_setup_sb800()
443 dev_err(&PIIX4_dev->dev, "SMBus I2C bus config region " in piix4_setup_sb800()
446 return -EBUSY; in piix4_setup_sb800()
452 dev_dbg(&PIIX4_dev->dev, "Using IRQ for SMBus\n"); in piix4_setup_sb800()
454 dev_dbg(&PIIX4_dev->dev, "Using SMI# for SMBus\n"); in piix4_setup_sb800()
456 dev_info(&PIIX4_dev->dev, in piix4_setup_sb800()
461 if (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD || in piix4_setup_sb800()
462 PIIX4_dev->vendor == PCI_VENDOR_ID_HYGON) { in piix4_setup_sb800()
463 if (PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS || in piix4_setup_sb800()
464 (PIIX4_dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && in piix4_setup_sb800()
465 PIIX4_dev->revision >= 0x1F)) { in piix4_setup_sb800()
476 retval = piix4_sb800_region_request(&PIIX4_dev->dev, &mmio_cfg); in piix4_setup_sb800()
489 piix4_sb800_region_release(&PIIX4_dev->dev, &mmio_cfg); in piix4_setup_sb800()
492 dev_info(&PIIX4_dev->dev, in piix4_setup_sb800()
511 dev_dbg(&PIIX4_dev->dev, in piix4_setup_aux()
513 return -ENODEV; in piix4_setup_aux()
518 dev_dbg(&PIIX4_dev->dev, in piix4_setup_aux()
520 return -ENODEV; in piix4_setup_aux()
524 return -ENODEV; in piix4_setup_aux()
527 dev_err(&PIIX4_dev->dev, "Auxiliary SMBus region 0x%x " in piix4_setup_aux()
529 return -EBUSY; in piix4_setup_aux()
532 dev_info(&PIIX4_dev->dev, in piix4_setup_aux()
542 unsigned short piix4_smba = adapdata->smba; in piix4_transaction()
547 dev_dbg(&piix4_adapter->dev, "Transaction (pre): CNT=%02x, CMD=%02x, " in piix4_transaction()
554 dev_dbg(&piix4_adapter->dev, "SMBus busy (%02x). " in piix4_transaction()
558 dev_err(&piix4_adapter->dev, "Failed! (%02x)\n", temp); in piix4_transaction()
559 return -EBUSY; in piix4_transaction()
561 dev_dbg(&piix4_adapter->dev, "Successful!\n"); in piix4_transaction()
580 dev_err(&piix4_adapter->dev, "SMBus Timeout!\n"); in piix4_transaction()
581 result = -ETIMEDOUT; in piix4_transaction()
585 result = -EIO; in piix4_transaction()
586 dev_err(&piix4_adapter->dev, "Error: Failed bus transaction\n"); in piix4_transaction()
590 result = -EIO; in piix4_transaction()
591 dev_dbg(&piix4_adapter->dev, "Bus collision! SMBus may be " in piix4_transaction()
593 /* Clock stops and target is stuck in mid-transmission */ in piix4_transaction()
597 result = -ENXIO; in piix4_transaction()
598 dev_dbg(&piix4_adapter->dev, "Error: no response!\n"); in piix4_transaction()
605 dev_err(&piix4_adapter->dev, "Failed reset at end of " in piix4_transaction()
608 dev_dbg(&piix4_adapter->dev, "Transaction (post): CNT=%02x, CMD=%02x, " in piix4_transaction()
621 unsigned short piix4_smba = adapdata->smba; in piix4_access()
643 outb_p(data->byte, SMBHSTDAT0); in piix4_access()
651 outb_p(data->word & 0xff, SMBHSTDAT0); in piix4_access()
652 outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1); in piix4_access()
661 len = data->block[0]; in piix4_access()
663 return -EINVAL; in piix4_access()
667 outb_p(data->block[i], SMBBLKDAT); in piix4_access()
672 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); in piix4_access()
673 return -EOPNOTSUPP; in piix4_access()
689 data->byte = inb_p(SMBHSTDAT0); in piix4_access()
692 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); in piix4_access()
695 data->block[0] = inb_p(SMBHSTDAT0); in piix4_access()
696 if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX) in piix4_access()
697 return -EPROTO; in piix4_access()
699 for (i = 1; i <= data->block[0]; i++) in piix4_access()
700 data->block[i] = inb_p(SMBBLKDAT); in piix4_access()
723 return -EBUSY; in piix4_imc_sleep()
732 while (timeout--) { in piix4_imc_sleep()
741 return -ETIMEDOUT; in piix4_imc_sleep()
758 while (timeout--) { in piix4_imc_wakeup()
771 if (mmio_cfg->use_mmio) { in piix4_sb800_port_sel()
772 smba_en_lo = ioread8(mmio_cfg->addr + piix4_port_sel_sb800); in piix4_sb800_port_sel()
775 iowrite8(val, mmio_cfg->addr + piix4_port_sel_sb800); in piix4_sb800_port_sel()
803 unsigned short piix4_smba = adapdata->smba; in piix4_access_sb800()
809 retval = piix4_sb800_region_request(&adap->dev, &adapdata->mmio_cfg); in piix4_access_sb800()
824 } while (--retries); in piix4_access_sb800()
827 retval = -EBUSY; in piix4_access_sb800()
840 if ((size == I2C_SMBUS_BLOCK_DATA) && adapdata->notify_imc) { in piix4_access_sb800()
845 case -EBUSY: in piix4_access_sb800()
846 dev_warn(&adap->dev, in piix4_access_sb800()
850 case -ETIMEDOUT: in piix4_access_sb800()
851 dev_warn(&adap->dev, in piix4_access_sb800()
860 dev_warn(&adap->dev, in piix4_access_sb800()
862 adapdata->notify_imc = false; in piix4_access_sb800()
866 prev_port = piix4_sb800_port_sel(adapdata->port, &adapdata->mmio_cfg); in piix4_access_sb800()
871 piix4_sb800_port_sel(prev_port, &adapdata->mmio_cfg); in piix4_access_sb800()
876 if ((size == I2C_SMBUS_BLOCK_DATA) && adapdata->notify_imc) in piix4_access_sb800()
880 piix4_sb800_region_release(&adap->dev, &adapdata->mmio_cfg); in piix4_access_sb800()
943 return -ENOMEM; in piix4_add_adapter()
946 adap->owner = THIS_MODULE; in piix4_add_adapter()
947 adap->class = I2C_CLASS_HWMON; in piix4_add_adapter()
948 adap->algo = sb800_main ? &piix4_smbus_algorithm_sb800 in piix4_add_adapter()
955 return -ENOMEM; in piix4_add_adapter()
958 adapdata->mmio_cfg.use_mmio = piix4_sb800_use_mmio(dev); in piix4_add_adapter()
959 adapdata->smba = smba; in piix4_add_adapter()
960 adapdata->sb800_main = sb800_main; in piix4_add_adapter()
961 adapdata->port = port << piix4_port_shift_sb800; in piix4_add_adapter()
962 adapdata->notify_imc = notify_imc; in piix4_add_adapter()
965 adap->dev.parent = &dev->dev; in piix4_add_adapter()
967 if (has_acpi_companion(&dev->dev)) { in piix4_add_adapter()
968 acpi_preset_companion(&adap->dev, in piix4_add_adapter()
969 ACPI_COMPANION(&dev->dev), in piix4_add_adapter()
973 snprintf(adap->name, sizeof(adap->name), in piix4_add_adapter()
1005 if (dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS || in piix4_add_adapters_sb800()
1006 (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && in piix4_add_adapters_sb800()
1007 dev->revision >= 0x1F)) { in piix4_add_adapters_sb800()
1027 dev_err(&dev->dev, in piix4_add_adapters_sb800()
1029 while (--port >= 0) { in piix4_add_adapters_sb800()
1031 if (adapdata->smba) { in piix4_add_adapters_sb800()
1047 if ((dev->vendor == PCI_VENDOR_ID_ATI && in piix4_probe()
1048 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && in piix4_probe()
1049 dev->revision >= 0x40) || in piix4_probe()
1050 dev->vendor == PCI_VENDOR_ID_AMD || in piix4_probe()
1051 dev->vendor == PCI_VENDOR_ID_HYGON) { in piix4_probe()
1055 if ((dev->vendor == PCI_VENDOR_ID_AMD || in piix4_probe()
1056 dev->vendor == PCI_VENDOR_ID_HYGON) && in piix4_probe()
1057 dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS) { in piix4_probe()
1064 pci_bus_read_config_byte(dev->bus, PCI_DEVFN(0x14, 3), in piix4_probe()
1096 retval = -ENODEV; in piix4_probe()
1098 if (dev->vendor == PCI_VENDOR_ID_ATI && in piix4_probe()
1099 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS) { in piix4_probe()
1100 if (dev->revision < 0x40) { in piix4_probe()
1108 if (dev->vendor == PCI_VENDOR_ID_AMD && in piix4_probe()
1109 (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS || in piix4_probe()
1110 dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS)) { in piix4_probe()
1129 if (adapdata->smba) { in piix4_adap_remove()
1131 if (adapdata->port == (0 << piix4_port_shift_sb800)) in piix4_adap_remove()
1132 release_region(adapdata->smba, SMBIOSIZE); in piix4_adap_remove()
1142 while (--port >= 0) { in piix4_remove()