From: Christian Fetzer <fetzer.ch@gmail.com>
To: linux-i2c@vger.kernel.org
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Wolfram Sang <wsa@the-dreams.de>,
galandilias@gmail.com, Christian Fetzer <fetzer.ch@gmail.com>
Subject: [PATCH v3 3/5] i2c-piix4: Request base address index region once for SB800
Date: Sat, 7 Nov 2015 12:35:24 +0100 [thread overview]
Message-ID: <1446896126-13369-4-git-send-email-fetzer.ch@gmail.com> (raw)
In-Reply-To: <1446896126-13369-1-git-send-email-fetzer.ch@gmail.com>
Request the SMBus base address index region once in piix4_probe. This
is particularly useful when using the multiplexed adapter in SB800 as
it avoids requesting and releasing the region on every transfer.
Signed-off-by: Christian Fetzer <fetzer.ch@gmail.com>
---
drivers/i2c/busses/i2c-piix4.c | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 0e4ae60..67ada1e 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -78,6 +78,9 @@
/* Multi-port constants */
#define PIIX4_MAX_ADAPTERS 4
+/* SB800 constants */
+#define SB800_PIIX4_SMB_IDX 0xCD6
+
/* insmod parameters */
/* If force is set to anything different from 0, we forcibly enable the
@@ -125,6 +128,9 @@ static const struct dmi_system_id piix4_dmi_ibm[] = {
{ },
};
+/* SB800 globals */
+static bool piix4_smb_idx_sb800;
+
struct i2c_piix4_adapdata {
unsigned short smba;
};
@@ -232,7 +238,6 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
const struct pci_device_id *id, u8 aux)
{
unsigned short piix4_smba;
- unsigned short smba_idx = 0xcd6;
u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status;
u8 i2ccfg, i2ccfg_offset = 0x10;
@@ -254,16 +259,10 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
else
smb_en = (aux) ? 0x28 : 0x2c;
- if (!request_region(smba_idx, 2, "smba_idx")) {
- dev_err(&PIIX4_dev->dev, "SMBus base address index region "
- "0x%x already in use!\n", smba_idx);
- return -EBUSY;
- }
- outb_p(smb_en, smba_idx);
- smba_en_lo = inb_p(smba_idx + 1);
- outb_p(smb_en + 1, smba_idx);
- smba_en_hi = inb_p(smba_idx + 1);
- release_region(smba_idx, 2);
+ outb_p(smb_en, SB800_PIIX4_SMB_IDX);
+ smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
+ outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX);
+ smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1);
if (!smb_en) {
smb_en_status = smba_en_lo & 0x10;
@@ -621,11 +620,20 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
if ((dev->vendor == PCI_VENDOR_ID_ATI &&
dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
dev->revision >= 0x40) ||
- dev->vendor == PCI_VENDOR_ID_AMD)
+ dev->vendor == PCI_VENDOR_ID_AMD) {
+ if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) {
+ dev_err(&dev->dev,
+ "SMBus base address index region 0x%x already in use!\n",
+ SB800_PIIX4_SMB_IDX);
+ return -EBUSY;
+ }
+ piix4_smb_idx_sb800 = true;
+
/* base address location etc changed in SB800 */
retval = piix4_setup_sb800(dev, id, 0);
- else
+ } else {
retval = piix4_setup(dev, id);
+ }
/* If no main SMBus found, give up */
if (retval < 0)
@@ -692,6 +700,9 @@ static void piix4_remove(struct pci_dev *dev)
piix4_adap_remove(piix4_aux_adapter, true);
piix4_aux_adapter = NULL;
}
+
+ if (piix4_smb_idx_sb800)
+ release_region(SB800_PIIX4_SMB_IDX, 2);
}
static struct pci_driver piix4_driver = {
--
1.9.1
next prev parent reply other threads:[~2015-11-07 11:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-07 11:35 [PATCH v3 0/5] Support multiplexed main SMBus interface on SB800 Christian Fetzer
2015-11-07 11:35 ` [PATCH v3 1/5] i2c-piix4: Optionally release smba in piix4_adap_remove Christian Fetzer
2015-11-09 11:24 ` Mika Westerberg
2015-11-07 11:35 ` [PATCH v3 2/5] i2c-piix4: Convert piix4_main_adapter to array Christian Fetzer
2015-11-07 11:35 ` Christian Fetzer [this message]
2015-11-09 10:40 ` [PATCH v3 3/5] i2c-piix4: Request base address index region once for SB800 Andy Shevchenko
2015-11-07 11:35 ` [PATCH v3 4/5] i2c-piix4: Add support for multiplexed main adapter in SB800 Christian Fetzer
2015-11-09 10:45 ` Andy Shevchenko
2016-01-22 12:39 ` Jean Delvare
2016-01-22 13:20 ` Andy Shevchenko
2015-11-07 11:35 ` [PATCH v3 5/5] i2c-piix4: Add adapter port name support for SB800 chipset Christian Fetzer
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=1446896126-13369-4-git-send-email-fetzer.ch@gmail.com \
--to=fetzer.ch@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=galandilias@gmail.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=wsa@the-dreams.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).