Skip to content

Commit d50f2f5

Browse files
hkallweitAndi Shyti
authored andcommitted
i2c: i801: Use MMIO if available
Newer versions of supported chips support MMIO in addition to legacy PMIO register access. Probe the MMIO PCI BAR and use faster MMIO register access if available. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4a3f77e commit d50f2f5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
#define SMBNTFDADD(p) (20 + (p)->smba) /* ICH3 and later */
145145

146146
/* PCI Address Constants */
147+
#define SMBBAR_MMIO 0
147148
#define SMBBAR 4
148149
#define SMBHSTCFG 0x040
149150
#define TCOBASE 0x050
@@ -1522,7 +1523,7 @@ static void i801_restore_regs(struct i801_priv *priv)
15221523

15231524
static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
15241525
{
1525-
int err, i;
1526+
int err, i, bar = SMBBAR;
15261527
struct i801_priv *priv;
15271528

15281529
priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
@@ -1570,10 +1571,13 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
15701571
if (i801_acpi_probe(priv))
15711572
return -ENODEV;
15721573

1573-
priv->smba = pcim_iomap_region(dev, SMBBAR, DRV_NAME);
1574+
if (pci_resource_flags(dev, SMBBAR_MMIO) & IORESOURCE_MEM)
1575+
bar = SMBBAR_MMIO;
1576+
1577+
priv->smba = pcim_iomap_region(dev, bar, DRV_NAME);
15741578
if (IS_ERR(priv->smba)) {
15751579
pci_err(dev, "Failed to request SMBus region %pr\n",
1576-
pci_resource_n(dev, SMBBAR));
1580+
pci_resource_n(dev, bar));
15771581
i801_acpi_remove(priv);
15781582
return PTR_ERR(priv->smba);
15791583
}

0 commit comments

Comments
 (0)