All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andi Shyti <andi.shyti@kernel.org>, Jean Delvare <jdelvare@suse.com>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: [PATCH 2/2] i2c: i801: Use MMIO if available
Date: Wed, 12 Mar 2025 20:08:18 +0100	[thread overview]
Message-ID: <b4748b7a-aac5-445c-b813-20c4d2c23ec3@gmail.com> (raw)
In-Reply-To: <28ad9377-6d8a-4259-8cd4-7edaa00e26d7@gmail.com>

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 <hkallweit1@gmail.com>
---
 drivers/i2c/busses/i2c-i801.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index bf5702ccb..48e1af544 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -144,6 +144,7 @@
 #define SMBNTFDADD(p)	(20 + (p)->smba)	/* ICH3 and later */
 
 /* PCI Address Constants */
+#define SMBBAR_MMIO	0
 #define SMBBAR		4
 #define SMBHSTCFG	0x040
 #define TCOBASE		0x050
@@ -1522,7 +1523,7 @@ static void i801_restore_regs(struct i801_priv *priv)
 
 static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	int err, i;
+	int err, i, bar = SMBBAR;
 	struct i801_priv *priv;
 
 	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)
 	if (i801_acpi_probe(priv))
 		return -ENODEV;
 
-	priv->smba = pcim_iomap_region(dev, SMBBAR, DRV_NAME);
+	if (pci_resource_flags(dev, SMBBAR_MMIO) & IORESOURCE_MEM)
+		bar = SMBBAR_MMIO;
+
+	priv->smba = pcim_iomap_region(dev, bar, DRV_NAME);
 	if (IS_ERR(priv->smba)) {
 		pci_err(dev, "Failed to request SMBus region %pr\n",
-			pci_resource_n(dev, SMBBAR));
+			pci_resource_n(dev, bar));
 		i801_acpi_remove(priv);
 		return PTR_ERR(priv->smba);
 	}
-- 
2.48.1



  parent reply	other threads:[~2025-03-12 19:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12 19:06 [PATCH 0/2] i2c: i801: Use MMIO if available Heiner Kallweit
2025-03-12 19:07 ` [PATCH 1/2] i2c: i801: Switch to iomapped register access Heiner Kallweit
2025-03-18 22:18   ` Andy Shevchenko
2025-03-18 23:22     ` Andi Shyti
2025-03-19  7:17       ` Heiner Kallweit
2025-03-19  8:23         ` Andy Shevchenko
2025-03-19 19:33           ` Heiner Kallweit
2025-03-19 19:48             ` Andy Shevchenko
2025-03-19 20:26               ` Heiner Kallweit
2025-03-19 21:53                 ` Andi Shyti
2025-03-20 20:06                   ` Heiner Kallweit
2025-03-20 21:06                     ` Andy Shevchenko
2025-03-20 21:10                     ` Andi Shyti
2025-03-12 19:08 ` Heiner Kallweit [this message]
2025-03-12 23:58 ` [PATCH 0/2] i2c: i801: Use MMIO if available Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4748b7a-aac5-445c-b813-20c4d2c23ec3@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andi.shyti@kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-i2c@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.