aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2019-08-31 10:24:02 -0400
committerWolfram Sang <wsa@the-dreams.de>2019-09-03 13:48:02 -0400
commitb84398d6d7f900805662b1619223fd644d862d7c (patch)
tree33fc52be73f263a770cd1d74480a0928ef4c32ad /drivers/i2c
parentda23b6faa8bf0f1c50a0700440e9ff3f52b3bd9a (diff)
i2c: i801: Use iTCO version 6 in Cannon Lake PCH and beyond
Intel Cannon Lake PCH moved the NO_REBOOT bit to reside as part of the TCO registers instead so update the i2c-i801 driver so that for Cannon Lake and beyond register platform device for iTCO using version 6. The affected PCHs are Cannon Lake, Cedar Fork, Comet Lake, Elkhart Lake and Ice Lake. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-i801.c142
1 files changed, 88 insertions, 54 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index a6469978e735..38afd16c857a 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -292,7 +292,8 @@ struct i801_priv {
292#define FEATURE_HOST_NOTIFY BIT(5) 292#define FEATURE_HOST_NOTIFY BIT(5)
293/* Not really a feature, but it's convenient to handle it as such */ 293/* Not really a feature, but it's convenient to handle it as such */
294#define FEATURE_IDF BIT(15) 294#define FEATURE_IDF BIT(15)
295#define FEATURE_TCO BIT(16) 295#define FEATURE_TCO_SPT BIT(16)
296#define FEATURE_TCO_CNL BIT(17)
296 297
297static const char *i801_feature_names[] = { 298static const char *i801_feature_names[] = {
298 "SMBus PEC", 299 "SMBus PEC",
@@ -1491,57 +1492,23 @@ static inline unsigned int i801_get_adapter_class(struct i801_priv *priv)
1491} 1492}
1492#endif 1493#endif
1493 1494
1494static const struct itco_wdt_platform_data tco_platform_data = { 1495static const struct itco_wdt_platform_data spt_tco_platform_data = {
1495 .name = "Intel PCH", 1496 .name = "Intel PCH",
1496 .version = 4, 1497 .version = 4,
1497}; 1498};
1498 1499
1499static DEFINE_SPINLOCK(p2sb_spinlock); 1500static DEFINE_SPINLOCK(p2sb_spinlock);
1500 1501
1501static void i801_add_tco(struct i801_priv *priv) 1502static struct platform_device *
1503i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
1504 struct resource *tco_res)
1502{ 1505{
1503 struct pci_dev *pci_dev = priv->pci_dev; 1506 struct resource *res;
1504 struct resource tco_res[3], *res;
1505 struct platform_device *pdev;
1506 unsigned int devfn; 1507 unsigned int devfn;
1507 u32 tco_base, tco_ctl;
1508 u32 base_addr, ctrl_val;
1509 u64 base64_addr; 1508 u64 base64_addr;
1509 u32 base_addr;
1510 u8 hidden; 1510 u8 hidden;
1511 1511
1512 if (!(priv->features & FEATURE_TCO))
1513 return;
1514
1515 pci_read_config_dword(pci_dev, TCOBASE, &tco_base);
1516 pci_read_config_dword(pci_dev, TCOCTL, &tco_ctl);
1517 if (!(tco_ctl & TCOCTL_EN))
1518 return;
1519
1520 memset(tco_res, 0, sizeof(tco_res));
1521
1522 res = &tco_res[ICH_RES_IO_TCO];
1523 res->start = tco_base & ~1;
1524 res->end = res->start + 32 - 1;
1525 res->flags = IORESOURCE_IO;
1526
1527 /*
1528 * Power Management registers.
1529 */
1530 devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2);
1531 pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr);
1532
1533 res = &tco_res[ICH_RES_IO_SMI];
1534 res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF;
1535 res->end = res->start + 3;
1536 res->flags = IORESOURCE_IO;
1537
1538 /*
1539 * Enable the ACPI I/O space.
1540 */
1541 pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val);
1542 ctrl_val |= ACPICTRL_EN;
1543 pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val);
1544
1545 /* 1512 /*
1546 * We must access the NO_REBOOT bit over the Primary to Sideband 1513 * We must access the NO_REBOOT bit over the Primary to Sideband
1547 * bridge (P2SB). The BIOS prevents the P2SB device from being 1514 * bridge (P2SB). The BIOS prevents the P2SB device from being
@@ -1577,15 +1544,76 @@ static void i801_add_tco(struct i801_priv *priv)
1577 res->end = res->start + 3; 1544 res->end = res->start + 3;
1578 res->flags = IORESOURCE_MEM; 1545 res->flags = IORESOURCE_MEM;
1579 1546
1580 pdev = platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1547 return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
1581 tco_res, 3, &tco_platform_data, 1548 tco_res, 3, &spt_tco_platform_data,
1582 sizeof(tco_platform_data)); 1549 sizeof(spt_tco_platform_data));
1583 if (IS_ERR(pdev)) { 1550}
1584 dev_warn(&pci_dev->dev, "failed to create iTCO device\n"); 1551
1552static const struct itco_wdt_platform_data cnl_tco_platform_data = {
1553 .name = "Intel PCH",
1554 .version = 6,
1555};
1556
1557static struct platform_device *
1558i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev,
1559 struct resource *tco_res)
1560{
1561 return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
1562 tco_res, 2, &cnl_tco_platform_data,
1563 sizeof(cnl_tco_platform_data));
1564}
1565
1566static void i801_add_tco(struct i801_priv *priv)
1567{
1568 u32 base_addr, tco_base, tco_ctl, ctrl_val;
1569 struct pci_dev *pci_dev = priv->pci_dev;
1570 struct resource tco_res[3], *res;
1571 unsigned int devfn;
1572
1573 /* If we have ACPI based watchdog use that instead */
1574 if (acpi_has_watchdog())
1575 return;
1576
1577 if (!(priv->features & (FEATURE_TCO_SPT | FEATURE_TCO_CNL)))
1585 return; 1578 return;
1586 }
1587 1579
1588 priv->tco_pdev = pdev; 1580 pci_read_config_dword(pci_dev, TCOBASE, &tco_base);
1581 pci_read_config_dword(pci_dev, TCOCTL, &tco_ctl);
1582 if (!(tco_ctl & TCOCTL_EN))
1583 return;
1584
1585 memset(tco_res, 0, sizeof(tco_res));
1586
1587 res = &tco_res[ICH_RES_IO_TCO];
1588 res->start = tco_base & ~1;
1589 res->end = res->start + 32 - 1;
1590 res->flags = IORESOURCE_IO;
1591
1592 /*
1593 * Power Management registers.
1594 */
1595 devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2);
1596 pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr);
1597
1598 res = &tco_res[ICH_RES_IO_SMI];
1599 res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF;
1600 res->end = res->start + 3;
1601 res->flags = IORESOURCE_IO;
1602
1603 /*
1604 * Enable the ACPI I/O space.
1605 */
1606 pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val);
1607 ctrl_val |= ACPICTRL_EN;
1608 pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val);
1609
1610 if (priv->features & FEATURE_TCO_CNL)
1611 priv->tco_pdev = i801_add_tco_cnl(priv, pci_dev, tco_res);
1612 else
1613 priv->tco_pdev = i801_add_tco_spt(priv, pci_dev, tco_res);
1614
1615 if (IS_ERR(priv->tco_pdev))
1616 dev_warn(&pci_dev->dev, "failed to create iTCO device\n");
1589} 1617}
1590 1618
1591#ifdef CONFIG_ACPI 1619#ifdef CONFIG_ACPI
@@ -1695,13 +1723,21 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
1695 switch (dev->device) { 1723 switch (dev->device) {
1696 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS: 1724 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS:
1697 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS: 1725 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS:
1698 case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS:
1699 case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS:
1700 case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS: 1726 case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS:
1701 case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS: 1727 case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS:
1702 case PCI_DEVICE_ID_INTEL_CDF_SMBUS:
1703 case PCI_DEVICE_ID_INTEL_DNV_SMBUS: 1728 case PCI_DEVICE_ID_INTEL_DNV_SMBUS:
1704 case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS: 1729 case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS:
1730 priv->features |= FEATURE_I2C_BLOCK_READ;
1731 priv->features |= FEATURE_IRQ;
1732 priv->features |= FEATURE_SMBUS_PEC;
1733 priv->features |= FEATURE_BLOCK_BUFFER;
1734 priv->features |= FEATURE_TCO_SPT;
1735 priv->features |= FEATURE_HOST_NOTIFY;
1736 break;
1737
1738 case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS:
1739 case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS:
1740 case PCI_DEVICE_ID_INTEL_CDF_SMBUS:
1705 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: 1741 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS:
1706 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: 1742 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS:
1707 case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS: 1743 case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS:
@@ -1711,9 +1747,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
1711 priv->features |= FEATURE_IRQ; 1747 priv->features |= FEATURE_IRQ;
1712 priv->features |= FEATURE_SMBUS_PEC; 1748 priv->features |= FEATURE_SMBUS_PEC;
1713 priv->features |= FEATURE_BLOCK_BUFFER; 1749 priv->features |= FEATURE_BLOCK_BUFFER;
1714 /* If we have ACPI based watchdog use that instead */ 1750 priv->features |= FEATURE_TCO_CNL;
1715 if (!acpi_has_watchdog())
1716 priv->features |= FEATURE_TCO;
1717 priv->features |= FEATURE_HOST_NOTIFY; 1751 priv->features |= FEATURE_HOST_NOTIFY;
1718 break; 1752 break;
1719 1753