From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
Christian Fetzer <fetzer.ch@gmail.com>,
Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH 1/3] i2c-piix4: Support alternative port selection register
Date: Fri, 29 Jan 2016 10:44:52 +0100 [thread overview]
Message-ID: <20160129104452.05e94c08@endymion.delvare> (raw)
In-Reply-To: <20160129104146.50f06562@endymion.delvare>
The SB800 register reference guide says that the SMBus port selection
bits may not always be in register Smbus0En (0x2c) but could
alternatively be found in register Smbus0Sel (0x2e) depending on the
settings in register Smbus0SelEn (0x2f.) Add support for this
configuration.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Christian Fetzer <fetzer.ch@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
---
drivers/i2c/busses/i2c-piix4.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
--- linux-4.5-rc0.orig/drivers/i2c/busses/i2c-piix4.c 2016-01-26 18:25:38.487310421 +0100
+++ linux-4.5-rc0/drivers/i2c/busses/i2c-piix4.c 2016-01-29 07:54:35.135765313 +0100
@@ -85,8 +85,13 @@
/* SB800 constants */
#define SB800_PIIX4_SMB_IDX 0xcd6
-/* SB800 port is selected by bits 2:1 of the smb_en register (0x2c) */
+/*
+ * SB800 port is selected by bits 2:1 of the smb_en register (0x2c)
+ * or the smb_sel register (0x2e), depending on bit 0 of register 0x2f.
+ */
#define SB800_PIIX4_PORT_IDX 0x2c
+#define SB800_PIIX4_PORT_IDX_ALT 0x2e
+#define SB800_PIIX4_PORT_IDX_SEL 0x2f
#define SB800_PIIX4_PORT_IDX_MASK 0x06
/* insmod parameters */
@@ -136,8 +141,13 @@ static const struct dmi_system_id piix4_
{ },
};
-/* SB800 globals */
+/*
+ * SB800 globals
+ * piix4_mutex_sb800 protects piix4_port_sel_sb800 and the pair
+ * of I/O ports at SB800_PIIX4_SMB_IDX.
+ */
static DEFINE_MUTEX(piix4_mutex_sb800);
+static u8 piix4_port_sel_sb800;
static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = {
" port 0", " port 2", " port 3", " port 4"
};
@@ -254,7 +264,7 @@ static int piix4_setup_sb800(struct pci_
const struct pci_device_id *id, u8 aux)
{
unsigned short piix4_smba;
- u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status;
+ u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status, port_sel;
u8 i2ccfg, i2ccfg_offset = 0x10;
/* SB800 and later SMBus does not support forcing address */
@@ -334,6 +344,18 @@ static int piix4_setup_sb800(struct pci_
"SMBus Host Controller at 0x%x, revision %d\n",
piix4_smba, i2ccfg >> 4);
+ /* Find which register is used for port selection */
+ mutex_lock(&piix4_mutex_sb800);
+ outb_p(SB800_PIIX4_PORT_IDX_SEL, SB800_PIIX4_SMB_IDX);
+ port_sel = inb_p(SB800_PIIX4_SMB_IDX + 1);
+ piix4_port_sel_sb800 = (port_sel & 0x01) ? SB800_PIIX4_PORT_IDX_ALT
+ : SB800_PIIX4_PORT_IDX;
+ mutex_unlock(&piix4_mutex_sb800);
+
+ dev_info(&PIIX4_dev->dev,
+ "Using register 0x%02x for SMBus port selection\n",
+ (unsigned int)piix4_port_sel_sb800);
+
return piix4_smba;
}
@@ -563,7 +585,7 @@ static s32 piix4_access_sb800(struct i2c
mutex_lock(&piix4_mutex_sb800);
- outb_p(SB800_PIIX4_PORT_IDX, SB800_PIIX4_SMB_IDX);
+ outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX);
smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
port = adapdata->port;
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2016-01-29 9:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-29 9:41 [PATCH 0/3] Improvements to the i2c-piix4 driver Jean Delvare
2016-01-29 9:44 ` Jean Delvare [this message]
2016-01-29 10:59 ` [PATCH 1/3] i2c-piix4: Support alternative port selection register Mika Westerberg
2016-01-29 12:04 ` Jean Delvare
2016-02-12 19:27 ` Wolfram Sang
2016-02-13 21:51 ` Jean Delvare
2016-02-14 8:39 ` fetzerch
2016-02-14 9:55 ` Jean Delvare
2016-02-15 17:30 ` Jean Delvare
2016-02-15 17:37 ` Wolfram Sang
2016-02-15 20:52 ` Jean Delvare
2016-01-29 9:45 ` [PATCH 2/3] i2c-piix4: Always use the same type for port Jean Delvare
2016-01-29 10:59 ` Mika Westerberg
2016-02-24 10:40 ` Wolfram Sang
2016-01-29 9:46 ` [PATCH 3/3] i2c-piix4: Pre-shift the port number Jean Delvare
2016-01-29 11:02 ` Mika Westerberg
2016-01-29 11:09 ` Jean Delvare
2016-02-24 10:42 ` Wolfram Sang
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=20160129104452.05e94c08@endymion.delvare \
--to=jdelvare@suse.de \
--cc=fetzer.ch@gmail.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).