Lines Matching +full:xps +full:- +full:gpio +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
6 Copyright (C) 2007 - 2014 Jean Delvare <jdelvare@suse.de>
18 * ---------------------------------------------------------------------------
43 * Lynx Point-LP (PCH) 0x9c22 32 hard yes yes yes
51 * Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes
54 * Sunrise Point-H (PCH) 0xa123 32 hard yes yes yes
55 * Sunrise Point-LP (PCH) 0x9d23 32 hard yes yes yes
61 * Kaby Lake PCH-H (PCH) 0xa2a3 32 hard yes yes yes
63 * Cannon Lake-H (PCH) 0xa323 32 hard yes yes yes
64 * Cannon Lake-LP (PCH) 0x9da3 32 hard yes yes yes
66 * Ice Lake-LP (PCH) 0x34a3 32 hard yes yes yes
67 * Ice Lake-N (PCH) 0x38a3 32 hard yes yes yes
69 * Comet Lake-H (PCH) 0x06a3 32 hard yes yes yes
71 * Tiger Lake-LP (PCH) 0xa0a3 32 hard yes yes yes
72 * Tiger Lake-H (PCH) 0x43a3 32 hard yes yes yes
74 * Comet Lake-V (PCH) 0xa3a3 32 hard yes yes yes
75 * Alder Lake-S (PCH) 0x7aa3 32 hard yes yes yes
76 * Alder Lake-P (PCH) 0x51a3 32 hard yes yes yes
77 * Alder Lake-M (PCH) 0x54a3 32 hard yes yes yes
78 * Raptor Lake-S (PCH) 0x7a23 32 hard yes yes yes
79 * Meteor Lake-P (SOC) 0x7e22 32 hard yes yes yes
80 * Meteor Lake SoC-S (SOC) 0xae22 32 hard yes yes yes
81 * Meteor Lake PCH-S (PCH) 0x7f23 32 hard yes yes yes
83 * Arrow Lake-H (SOC) 0x7722 32 hard yes yes yes
95 * See the file Documentation/i2c/busses/i2c-i801.rst for details.
109 #include <linux/i2c-mux.h>
110 #include <linux/i2c-smbus.h>
125 #include <linux/gpio/machine.h>
126 #include <linux/platform_data/i2c-mux-gpio.h>
130 #define SMBHSTSTS(p) (0 + (p)->smba)
131 #define SMBHSTCNT(p) (2 + (p)->smba)
132 #define SMBHSTCMD(p) (3 + (p)->smba)
133 #define SMBHSTADD(p) (4 + (p)->smba)
134 #define SMBHSTDAT0(p) (5 + (p)->smba)
135 #define SMBHSTDAT1(p) (6 + (p)->smba)
136 #define SMBBLKDAT(p) (7 + (p)->smba)
137 #define SMBPEC(p) (8 + (p)->smba) /* ICH3 and later */
138 #define SMBAUXSTS(p) (12 + (p)->smba) /* ICH4 and later */
139 #define SMBAUXCTL(p) (13 + (p)->smba) /* ICH4 and later */
140 #define SMBSLVSTS(p) (16 + (p)->smba) /* ICH3 and later */
141 #define SMBSLVCMD(p) (17 + (p)->smba) /* ICH3 and later */
142 #define SMBNTFDADD(p) (20 + (p)->smba) /* ICH3 and later */
155 #define SMBHSTCFG_SMB_SMI_EN BIT(1)
164 #define SMBAUXSTS_STCO BIT(1)
168 #define SMBAUXCTL_E32B BIT(1)
182 #define SMBHSTCNT_KILL BIT(1)
194 #define SMBHSTSTS_INTR BIT(1)
210 #define SMBUS_LEN_SENTINEL (I2C_SMBUS_BLOCK_MAX + 1)
269 unsigned gpios[2]; /* Relative to gpio_chip->base */
286 /* Command state used by isr for byte-by-byte block transactions */
308 #define FEATURE_BLOCK_BUFFER BIT(1)
340 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { in i801_get_block_len()
341 pci_err(priv->pci_dev, "Illegal SMBus block read size %u\n", len); in i801_get_block_len()
342 return -EPROTO; in i801_get_block_len()
352 if (!(priv->features & FEATURE_SMBUS_PEC)) in i801_check_and_clear_pec_error()
358 return -EBADMSG; in i801_check_and_clear_pec_error()
365 Return 0 if it is, -EBUSY if it is not. */
372 pci_err(priv->pci_dev, "SMBus is busy, can't use it!\n"); in i801_check_pre()
373 return -EBUSY; in i801_check_pre()
378 pci_dbg(priv->pci_dev, "Clearing status flags (%02x)\n", status); in i801_check_pre()
391 pci_dbg(priv->pci_dev, "Clearing aux status flag CRCE\n"); in i801_check_pre()
413 dev_dbg(&priv->pci_dev->dev, in i801_check_post()
415 return -ETIMEDOUT; in i801_check_post()
419 result = -EIO; in i801_check_post()
420 dev_err(&priv->pci_dev->dev, "Transaction failed\n"); in i801_check_post()
440 pci_dbg(priv->pci_dev, "PEC error\n"); in i801_check_post()
442 result = -ENXIO; in i801_check_post()
443 pci_dbg(priv->pci_dev, "No response\n"); in i801_check_post()
447 result = -EAGAIN; in i801_check_post()
448 dev_dbg(&priv->pci_dev->dev, "Lost arbitration\n"); in i801_check_post()
457 unsigned long timeout = jiffies + priv->adapter.timeout; in i801_wait_intr()
469 return -ETIMEDOUT; in i801_wait_intr()
475 unsigned long timeout = jiffies + priv->adapter.timeout; in i801_wait_byte_done()
485 return -ETIMEDOUT; in i801_wait_byte_done()
491 const struct i2c_adapter *adap = &priv->adapter; in i801_transaction()
493 if (priv->features & FEATURE_IRQ) { in i801_transaction()
494 reinit_completion(&priv->done); in i801_transaction()
497 result = wait_for_completion_timeout(&priv->done, adap->timeout); in i801_transaction()
498 return result ? priv->status : -ETIMEDOUT; in i801_transaction()
520 return -EOPNOTSUPP; in i801_block_transaction_by_block()
527 len = data->block[0]; in i801_block_transaction_by_block()
531 outb_p(data->block[i+1], SMBBLKDAT(priv)); in i801_block_transaction_by_block()
546 data->block[0] = len; in i801_block_transaction_by_block()
549 data->block[i + 1] = inb_p(SMBBLKDAT(priv)); in i801_block_transaction_by_block()
558 if (priv->is_read) { in i801_isr_byte_done()
564 if (priv->len == SMBUS_LEN_SENTINEL) { in i801_isr_byte_done()
565 priv->len = i801_get_block_len(priv); in i801_isr_byte_done()
566 if (priv->len < 0) in i801_isr_byte_done()
568 priv->len = I2C_SMBUS_BLOCK_MAX; in i801_isr_byte_done()
570 priv->data[-1] = priv->len; in i801_isr_byte_done()
574 if (priv->count < priv->len) in i801_isr_byte_done()
575 priv->data[priv->count++] = inb(SMBBLKDAT(priv)); in i801_isr_byte_done()
577 dev_dbg(&priv->pci_dev->dev, in i801_isr_byte_done()
581 if (priv->count == priv->len - 1) in i801_isr_byte_done()
582 outb_p(priv->cmd | SMBHSTCNT_LAST_BYTE, in i801_isr_byte_done()
584 } else if (priv->count < priv->len - 1) { in i801_isr_byte_done()
586 outb_p(priv->data[++priv->count], SMBBLKDAT(priv)); in i801_isr_byte_done()
594 addr = inb_p(SMBNTFDADD(priv)) >> 1; in i801_host_notify_isr()
597 * With the tested platforms, reading SMBNTFDDAT (22 + (p)->smba) in i801_host_notify_isr()
601 i2c_handle_smbus_host_notify(&priv->adapter, addr); in i801_host_notify_isr()
611 * 1) i801 signals transaction completion with one of these interrupts:
612 * INTR - Success
613 * DEV_ERR - Invalid command, NAK or communication timeout
614 * BUS_ERR - SMI# transaction collision
615 * FAILED - transaction was canceled due to a KILL request
616 * When any of these occur, update ->status and signal completion.
618 * 2) For byte-by-byte (I2C read/write) transactions, one BYTE_DONE interrupt
619 * occurs for each byte of a byte-by-byte to prepare the next byte.
630 pci_read_config_word(priv->pci_dev, PCI_STATUS, &pcists); in i801_isr()
634 if (priv->features & FEATURE_HOST_NOTIFY) { in i801_isr()
654 priv->status = status & STATUS_ERROR_FLAGS; in i801_isr()
655 complete(&priv->done); in i801_isr()
662 * For "byte-by-byte" block transactions:
663 * I2C write uses cmd=I801_BLOCK_DATA, I2C_EN=1
674 const struct i2c_adapter *adap = &priv->adapter; in i801_block_transaction_byte_by_byte()
677 return -EOPNOTSUPP; in i801_block_transaction_byte_by_byte()
679 len = data->block[0]; in i801_block_transaction_byte_by_byte()
683 outb_p(data->block[1], SMBBLKDAT(priv)); in i801_block_transaction_byte_by_byte()
692 if (priv->features & FEATURE_IRQ) { in i801_block_transaction_byte_by_byte()
693 priv->is_read = (read_write == I2C_SMBUS_READ); in i801_block_transaction_byte_by_byte()
694 if (len == 1 && priv->is_read) in i801_block_transaction_byte_by_byte()
696 priv->cmd = smbcmd | SMBHSTCNT_INTREN; in i801_block_transaction_byte_by_byte()
697 priv->len = len; in i801_block_transaction_byte_by_byte()
698 priv->count = 0; in i801_block_transaction_byte_by_byte()
699 priv->data = &data->block[1]; in i801_block_transaction_byte_by_byte()
701 reinit_completion(&priv->done); in i801_block_transaction_byte_by_byte()
702 outb_p(priv->cmd | SMBHSTCNT_START, SMBHSTCNT(priv)); in i801_block_transaction_byte_by_byte()
703 result = wait_for_completion_timeout(&priv->done, adap->timeout); in i801_block_transaction_byte_by_byte()
704 return result ? priv->status : -ETIMEDOUT; in i801_block_transaction_byte_by_byte()
707 if (len == 1 && read_write == I2C_SMBUS_READ) in i801_block_transaction_byte_by_byte()
711 for (i = 1; i <= len; i++) { in i801_block_transaction_byte_by_byte()
730 return -EPROTO; in i801_block_transaction_byte_by_byte()
732 data->block[0] = len; in i801_block_transaction_byte_by_byte()
736 data->block[i] = inb_p(SMBBLKDAT(priv)); in i801_block_transaction_byte_by_byte()
737 if (i == len - 1) in i801_block_transaction_byte_by_byte()
741 if (read_write == I2C_SMBUS_WRITE && i+1 <= len) in i801_block_transaction_byte_by_byte()
742 outb_p(data->block[i+1], SMBBLKDAT(priv)); in i801_block_transaction_byte_by_byte()
753 outb_p((addr << 1) | (read_write & 0x01), SMBHSTADD(priv)); in i801_set_hstadd()
776 outb_p(data->byte, SMBHSTDAT0(priv)); in i801_simple_transaction()
783 outb_p(data->word & 0xff, SMBHSTDAT0(priv)); in i801_simple_transaction()
784 outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); in i801_simple_transaction()
791 outb_p(data->word & 0xff, SMBHSTDAT0(priv)); in i801_simple_transaction()
792 outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); in i801_simple_transaction()
798 pci_err(priv->pci_dev, "Unsupported transaction %d\n", command); in i801_simple_transaction()
799 return -EOPNOTSUPP; in i801_simple_transaction()
809 data->byte = inb_p(SMBHSTDAT0(priv)); in i801_simple_transaction()
813 data->word = inb_p(SMBHSTDAT0(priv)) + in i801_simple_transaction()
826 data->block[0] = SMBUS_LEN_SENTINEL; in i801_smbus_block_transaction()
827 else if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) in i801_smbus_block_transaction()
828 return -EPROTO; in i801_smbus_block_transaction()
837 if (priv->features & FEATURE_BLOCK_BUFFER) in i801_smbus_block_transaction()
849 if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) in i801_i2c_block_transaction()
850 return -EPROTO; in i801_i2c_block_transaction()
857 priv->original_hstcfg & SMBHSTCFG_SPD_WD ? read_write : I2C_SMBUS_WRITE); in i801_i2c_block_transaction()
867 pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); in i801_i2c_block_transaction()
868 pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc | SMBHSTCFG_I2C_EN); in i801_i2c_block_transaction()
869 } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { in i801_i2c_block_transaction()
870 pci_err(priv->pci_dev, "I2C block read is unsupported!\n"); in i801_i2c_block_transaction()
871 return -EOPNOTSUPP; in i801_i2c_block_transaction()
879 pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); in i801_i2c_block_transaction()
892 if (priv->acpi_reserved) in i801_access()
893 return -EBUSY; in i801_access()
895 pm_runtime_get_sync(&priv->pci_dev->dev); in i801_access()
901 hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) in i801_access()
932 pm_runtime_mark_last_busy(&priv->pci_dev->dev); in i801_access()
933 pm_runtime_put_autosuspend(&priv->pci_dev->dev); in i801_access()
946 ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | in i801_func()
947 ((priv->features & FEATURE_BLOCK_PROC) ? in i801_func()
949 ((priv->features & FEATURE_I2C_BLOCK_READ) ? in i801_func()
951 ((priv->features & FEATURE_HOST_NOTIFY) ? in i801_func()
959 if (!(priv->features & FEATURE_HOST_NOTIFY)) in i801_enable_host_notify()
968 priv->original_slvcmd, SMBSLVCMD(priv)); in i801_enable_host_notify()
976 if (!(priv->features & FEATURE_HOST_NOTIFY)) in i801_disable_host_notify()
979 outb_p(priv->original_slvcmd, SMBSLVCMD(priv)); in i801_disable_host_notify()
1074 sizeof(signature)-1)) in bios_signature()
1089 apanel_addr = readb(p + 8 + 3) >> 1; in input_apanel_init()
1135 if (dm->type != DMI_ENTRY_ONBOARD_DEVICE) in dmi_check_onboard_devices()
1138 count = (dm->length - sizeof(struct dmi_header)) / 2; in dmi_check_onboard_devices()
1140 const u8 *d = (char *)(dm + 1) + (i * 2); in dmi_check_onboard_devices()
1141 const char *name = ((char *) dm) + dm->length; in dmi_check_onboard_devices()
1143 u8 s = d[1]; in dmi_check_onboard_devices()
1147 s--; in dmi_check_onboard_devices()
1149 name += strlen(name) + 1; in dmi_check_onboard_devices()
1150 s--; in dmi_check_onboard_devices()
1159 /* NOTE: Keep this list in sync with drivers/platform/x86/dell-smo8800.c */
1185 if (!(info->valid & ACPI_VALID_HID)) in check_acpi_smo88xx_device()
1188 hid = info->hardware_id.string; in check_acpi_smo88xx_device()
1208 void *err = ERR_PTR(-ENOENT); in is_dell_system_with_lis3lv02d()
1251 { "XPS 15 7590", 0x29 },
1268 dev_warn(&priv->pci_dev->dev, in register_dell_lis3lv02d_i2c_device()
1277 i2c_new_client_device(&priv->adapter, &info); in register_dell_lis3lv02d_i2c_device()
1284 if (priv->features & FEATURE_IDF) in i801_probe_optional_targets()
1293 i2c_new_client_device(&priv->adapter, &info); in i801_probe_optional_targets()
1297 dmi_walk(dmi_check_onboard_devices, &priv->adapter); in i801_probe_optional_targets()
1304 if (!priv->mux_pdev) in i801_probe_optional_targets()
1306 i2c_register_spd(&priv->adapter); in i801_probe_optional_targets()
1334 DMI_MATCH(DMI_BOARD_NAME, "Z8NA-D6(C)"),
1341 DMI_MATCH(DMI_BOARD_NAME, "Z8P(N)E-D12(X)"),
1348 DMI_MATCH(DMI_BOARD_NAME, "Z8NH-D12"),
1355 DMI_MATCH(DMI_BOARD_NAME, "Z8PH-D12/IFB"),
1362 DMI_MATCH(DMI_BOARD_NAME, "Z8NR-D12"),
1369 DMI_MATCH(DMI_BOARD_NAME, "Z8P(N)H-D12"),
1376 DMI_MATCH(DMI_BOARD_NAME, "Z8PG-D18"),
1383 DMI_MATCH(DMI_BOARD_NAME, "Z8PE-D18"),
1390 DMI_MATCH(DMI_BOARD_NAME, "Z8PS-D12"),
1404 dev->type != &i2c_adapter_type || in i801_notifier_call()
1405 i2c_root_adapter(dev) != &priv->adapter) in i801_notifier_call()
1417 struct device *dev = &priv->adapter.dev; in i801_add_mux()
1428 mux_config = id->driver_data; in i801_add_mux()
1432 gpio_data.parent = priv->adapter.nr; in i801_add_mux()
1433 gpio_data.values = mux_config->values; in i801_add_mux()
1434 gpio_data.n_values = mux_config->n_values; in i801_add_mux()
1437 /* Register GPIO descriptor lookup table */ in i801_add_mux()
1439 struct_size(lookup, table, mux_config->n_gpios + 1), in i801_add_mux()
1443 lookup->dev_id = "i2c-mux-gpio"; in i801_add_mux()
1444 for (i = 0; i < mux_config->n_gpios; i++) in i801_add_mux()
1445 lookup->table[i] = GPIO_LOOKUP(mux_config->gpio_chip, in i801_add_mux()
1446 mux_config->gpios[i], "mux", 0); in i801_add_mux()
1449 priv->mux_notifier_block.notifier_call = i801_notifier_call; in i801_add_mux()
1450 if (bus_register_notifier(&i2c_bus_type, &priv->mux_notifier_block)) in i801_add_mux()
1454 * because since we are referring to the GPIO chip by name we are in i801_add_mux()
1459 priv->mux_pdev = platform_device_register_data(dev, "i2c-mux-gpio", in i801_add_mux()
1462 if (IS_ERR(priv->mux_pdev)) { in i801_add_mux()
1465 dev_err(dev, "Failed to register i2c-mux-gpio device\n"); in i801_add_mux()
1467 priv->lookup = lookup; in i801_add_mux()
1473 bus_unregister_notifier(&i2c_bus_type, &priv->mux_notifier_block); in i801_del_mux()
1474 platform_device_unregister(priv->mux_pdev); in i801_del_mux()
1475 gpiod_remove_lookup_table(priv->lookup); in i801_del_mux()
1497 res = &tco_res[1]; in i801_add_tco_spt()
1498 ret = p2sb_bar(pci_dev->bus, 0, res); in i801_add_tco_spt()
1502 if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS) in i801_add_tco_spt()
1503 res->start += SBREG_SMBCTRL_DNV; in i801_add_tco_spt()
1505 res->start += SBREG_SMBCTRL; in i801_add_tco_spt()
1507 res->end = res->start + 3; in i801_add_tco_spt()
1509 return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, in i801_add_tco_spt()
1521 return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, in i801_add_tco_cnl()
1522 tco_res, 1, &pldata, sizeof(pldata)); in i801_add_tco_cnl()
1527 struct pci_dev *pci_dev = priv->pci_dev; in i801_add_tco()
1535 if (!(priv->features & (FEATURE_TCO_SPT | FEATURE_TCO_CNL))) in i801_add_tco()
1549 res->start = tco_base & ~1; in i801_add_tco()
1550 res->end = res->start + 32 - 1; in i801_add_tco()
1551 res->flags = IORESOURCE_IO; in i801_add_tco()
1553 if (priv->features & FEATURE_TCO_CNL) in i801_add_tco()
1554 priv->tco_pdev = i801_add_tco_cnl(pci_dev, tco_res); in i801_add_tco()
1556 priv->tco_pdev = i801_add_tco_spt(pci_dev, tco_res); in i801_add_tco()
1558 if (IS_ERR(priv->tco_pdev)) in i801_add_tco()
1559 dev_warn(&pci_dev->dev, "failed to create iTCO device\n"); in i801_add_tco()
1566 return address >= priv->smba && in i801_acpi_is_smbus_ioport()
1567 address <= pci_resource_end(priv->pci_dev, SMBBAR); in i801_acpi_is_smbus_ioport()
1575 struct pci_dev *pdev = priv->pci_dev; in i801_acpi_io_handler()
1583 i2c_lock_bus(&priv->adapter, I2C_LOCK_SEGMENT); in i801_acpi_io_handler()
1585 if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) { in i801_acpi_io_handler()
1586 priv->acpi_reserved = true; in i801_acpi_io_handler()
1588 dev_warn(&pdev->dev, "BIOS is accessing SMBus registers\n"); in i801_acpi_io_handler()
1589 dev_warn(&pdev->dev, "Driver SMBus register access inhibited\n"); in i801_acpi_io_handler()
1595 pm_runtime_get_sync(&pdev->dev); in i801_acpi_io_handler()
1603 i2c_unlock_bus(&priv->adapter, I2C_LOCK_SEGMENT); in i801_acpi_io_handler()
1610 acpi_handle ah = ACPI_HANDLE(&priv->pci_dev->dev); in i801_acpi_probe()
1618 return acpi_check_resource_conflict(&priv->pci_dev->resource[SMBBAR]); in i801_acpi_probe()
1623 acpi_handle ah = ACPI_HANDLE(&priv->pci_dev->dev); in i801_acpi_remove()
1634 unsigned char hstcfg = priv->original_hstcfg; in i801_setup_hstcfg()
1638 pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hstcfg); in i801_setup_hstcfg()
1643 outb_p(priv->original_hstcnt, SMBHSTCNT(priv)); in i801_restore_regs()
1644 pci_write_config_byte(priv->pci_dev, SMBHSTCFG, priv->original_hstcfg); in i801_restore_regs()
1652 priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); in i801_probe()
1654 return -ENOMEM; in i801_probe()
1656 i2c_set_adapdata(&priv->adapter, priv); in i801_probe()
1657 priv->adapter.owner = THIS_MODULE; in i801_probe()
1658 priv->adapter.class = I2C_CLASS_HWMON; in i801_probe()
1659 priv->adapter.algo = &smbus_algorithm; in i801_probe()
1660 priv->adapter.dev.parent = &dev->dev; in i801_probe()
1661 acpi_use_parent_companion(&priv->adapter.dev); in i801_probe()
1662 priv->adapter.retries = 3; in i801_probe()
1664 priv->pci_dev = dev; in i801_probe()
1665 priv->features = id->driver_data; in i801_probe()
1669 if (priv->features & disable_features & (1 << i)) in i801_probe()
1670 dev_notice(&dev->dev, "%s disabled by user\n", in i801_probe()
1673 priv->features &= ~disable_features; in i801_probe()
1676 if (!(priv->features & FEATURE_BLOCK_BUFFER)) in i801_probe()
1677 priv->features &= ~FEATURE_BLOCK_PROC; in i801_probe()
1681 dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n", in i801_probe()
1688 priv->smba = pci_resource_start(dev, SMBBAR); in i801_probe()
1689 if (!priv->smba) { in i801_probe()
1690 dev_err(&dev->dev, in i801_probe()
1692 return -ENODEV; in i801_probe()
1696 return -ENODEV; in i801_probe()
1698 err = pcim_iomap_regions(dev, 1 << SMBBAR, DRV_NAME); in i801_probe()
1700 dev_err(&dev->dev, in i801_probe()
1701 "Failed to request SMBus region 0x%lx-0x%Lx\n", in i801_probe()
1702 priv->smba, in i801_probe()
1708 pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &priv->original_hstcfg); in i801_probe()
1710 if (!(priv->original_hstcfg & SMBHSTCFG_HST_EN)) in i801_probe()
1711 dev_info(&dev->dev, "Enabling SMBus device\n"); in i801_probe()
1713 if (priv->original_hstcfg & SMBHSTCFG_SMB_SMI_EN) { in i801_probe()
1714 dev_dbg(&dev->dev, "SMBus using interrupt SMI#\n"); in i801_probe()
1716 priv->features &= ~FEATURE_IRQ; in i801_probe()
1718 if (priv->original_hstcfg & SMBHSTCFG_SPD_WD) in i801_probe()
1719 dev_info(&dev->dev, "SPD Write Disable is set\n"); in i801_probe()
1722 if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER)) in i801_probe()
1727 priv->adapter.timeout = HZ / 5; in i801_probe()
1729 if (dev->irq == IRQ_NOTCONNECTED) in i801_probe()
1730 priv->features &= ~FEATURE_IRQ; in i801_probe()
1732 if (priv->features & FEATURE_IRQ) { in i801_probe()
1736 pci_read_config_word(priv->pci_dev, PCI_STATUS, &pcists); in i801_probe()
1738 dev_warn(&dev->dev, "An interrupt is pending!\n"); in i801_probe()
1741 if (priv->features & FEATURE_IRQ) { in i801_probe()
1742 init_completion(&priv->done); in i801_probe()
1744 err = devm_request_irq(&dev->dev, dev->irq, i801_isr, in i801_probe()
1747 dev_err(&dev->dev, "Failed to allocate irq %d: %d\n", in i801_probe()
1748 dev->irq, err); in i801_probe()
1749 priv->features &= ~FEATURE_IRQ; in i801_probe()
1752 dev_info(&dev->dev, "SMBus using %s\n", in i801_probe()
1753 priv->features & FEATURE_IRQ ? "PCI interrupt" : "polling"); in i801_probe()
1756 if (!(priv->features & FEATURE_IRQ)) in i801_probe()
1757 priv->features &= ~FEATURE_HOST_NOTIFY; in i801_probe()
1760 priv->original_hstcnt = inb_p(SMBHSTCNT(priv)) & ~SMBHSTCNT_KILL; in i801_probe()
1761 if (priv->features & FEATURE_HOST_NOTIFY) in i801_probe()
1762 priv->original_slvcmd = inb_p(SMBSLVCMD(priv)); in i801_probe()
1770 snprintf(priv->adapter.name, sizeof(priv->adapter.name), in i801_probe()
1772 (priv->features & FEATURE_IDF) ? "I801 IDF" : "I801", in i801_probe()
1773 priv->smba); in i801_probe()
1775 err = i2c_add_adapter(&priv->adapter); in i801_probe()
1777 platform_device_unregister(priv->tco_pdev); in i801_probe()
1783 i801_enable_host_notify(&priv->adapter); in i801_probe()
1785 /* We ignore errors - multiplexing is optional */ in i801_probe()
1791 dev_pm_set_driver_flags(&dev->dev, DPM_FLAG_NO_DIRECT_COMPLETE); in i801_probe()
1792 pm_runtime_set_autosuspend_delay(&dev->dev, 1000); in i801_probe()
1793 pm_runtime_use_autosuspend(&dev->dev); in i801_probe()
1794 pm_runtime_put_autosuspend(&dev->dev); in i801_probe()
1795 pm_runtime_allow(&dev->dev); in i801_probe()
1806 i2c_del_adapter(&priv->adapter); in i801_remove()
1809 platform_device_unregister(priv->tco_pdev); in i801_remove()
1812 if (!priv->acpi_reserved) in i801_remove()
1813 pm_runtime_get_noresume(&dev->dev); in i801_remove()
1819 * some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010) in i801_remove()
1836 i2c_mark_adapter_suspended(&priv->adapter); in i801_suspend()
1847 i801_enable_host_notify(&priv->adapter); in i801_resume()
1848 i2c_mark_adapter_resumed(&priv->adapter); in i801_resume()