All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooks <andrew.cooks@opengear.com>
To: jdelvare@suse.com, linux-i2c@vger.kernel.org
Cc: platypus-sw@opengear.com,
	Andrew Cooks <andrew.cooks@opengear.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v2 2/3] i2c: piix4: fix number of SMBus ports on HUDSON2
Date: Thu, 14 Dec 2017 13:11:45 +1000	[thread overview]
Message-ID: <10a5f5d056511d07c1946d744fc84f243a6097cc.1513215039.git.andrew.cooks@opengear.com> (raw)
In-Reply-To: <cover.1513215039.git.andrew.cooks@opengear.com>

This prevents bus timeouts and resets on Hudson2 (Family 16h Models
30h), when probing reserved Port 4.

According to the AMD BIOS and Kernel Developer's Guides (BKDG), Port 3
and Port 4 are reserved on the following devices:
 - Family 15h Model 60h-6Fh,
 - Family 15h Model 70h-7Fh,
 - Family 16h Models 30h-3Fh,

Signed-off-by: Andrew Cooks <andrew.cooks@opengear.com>
---
 drivers/i2c/busses/i2c-piix4.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index b92ea5d..cc38dc3 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -82,6 +82,13 @@
 /* Multi-port constants */
 #define PIIX4_MAX_ADAPTERS 4
 
+/*
+ * Main adapter port count. At least one (Port 0) plus up to 3 additional
+ * (Ports 2-4)
+ */
+#define SB800_MAIN_PORTS 4
+#define HUDSON2_MAIN_PORTS 2 /* HUDSON2, reserves Port 3 and Port 4 */
+
 /* SB800 constants */
 #define SB800_PIIX4_SMB_IDX		0xcd6
 
@@ -802,6 +809,7 @@ MODULE_DEVICE_TABLE (pci, piix4_ids);
 
 static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS];
 static struct i2c_adapter *piix4_aux_adapter;
+static int piix4_adapter_count;
 
 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
 			     bool sb800_main, u8 port, bool notify_imc,
@@ -858,10 +866,17 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba,
 				    bool notify_imc)
 {
 	struct i2c_piix4_adapdata *adapdata;
-	int port;
+	int port, port_count;
 	int retval;
 
-	for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
+	if (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS ||
+	    dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS) {
+		port_count = HUDSON2_MAIN_PORTS;
+	} else {
+		port_count = SB800_MAIN_PORTS;
+	}
+
+	for (port = 0; port < port_count; port++) {
 		retval = piix4_add_adapter(dev, smba, true, port, notify_imc,
 					   piix4_main_port_names_sb800[port],
 					   &piix4_main_adapters[port]);
@@ -874,7 +889,7 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba,
 error:
 	dev_err(&dev->dev,
 		"Error setting up SB800 adapters. Unregistering!\n");
-	while (--port >= 0) {
+	while (--piix4_adapter_count >= 0) {
 		adapdata = i2c_get_adapdata(piix4_main_adapters[port]);
 		if (adapdata->smba) {
 			i2c_del_adapter(piix4_main_adapters[port]);
@@ -995,12 +1010,10 @@ static void piix4_adap_remove(struct i2c_adapter *adap)
 
 static void piix4_remove(struct pci_dev *dev)
 {
-	int port = PIIX4_MAX_ADAPTERS;
-
-	while (--port >= 0) {
-		if (piix4_main_adapters[port]) {
-			piix4_adap_remove(piix4_main_adapters[port]);
-			piix4_main_adapters[port] = NULL;
+	while (--piix4_adapter_count >= 0) {
+		if (piix4_main_adapters[piix4_adapter_count]) {
+			piix4_adap_remove(piix4_main_adapters[piix4_adapter_count]);
+			piix4_main_adapters[piix4_adapter_count] = NULL;
 		}
 	}
 
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Cooks <andrew.cooks@opengear.com>
To: jdelvare@suse.com, linux-i2c@vger.kernel.org
Cc: platypus-sw@opengear.com,
	Andrew Cooks <andrew.cooks@opengear.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	open list <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 2/3] i2c: piix4: fix number of SMBus ports on HUDSON2
Date: Thu, 14 Dec 2017 13:11:45 +1000	[thread overview]
Message-ID: <10a5f5d056511d07c1946d744fc84f243a6097cc.1513215039.git.andrew.cooks@opengear.com> (raw)
In-Reply-To: <cover.1513215039.git.andrew.cooks@opengear.com>

This prevents bus timeouts and resets on Hudson2 (Family 16h Models
30h), when probing reserved Port 4.

According to the AMD BIOS and Kernel Developer's Guides (BKDG), Port 3
and Port 4 are reserved on the following devices:
 - Family 15h Model 60h-6Fh,
 - Family 15h Model 70h-7Fh,
 - Family 16h Models 30h-3Fh,

Signed-off-by: Andrew Cooks <andrew.cooks@opengear.com>
---
 drivers/i2c/busses/i2c-piix4.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index b92ea5d..cc38dc3 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -82,6 +82,13 @@
 /* Multi-port constants */
 #define PIIX4_MAX_ADAPTERS 4
 
+/*
+ * Main adapter port count. At least one (Port 0) plus up to 3 additional
+ * (Ports 2-4)
+ */
+#define SB800_MAIN_PORTS 4
+#define HUDSON2_MAIN_PORTS 2 /* HUDSON2, reserves Port 3 and Port 4 */
+
 /* SB800 constants */
 #define SB800_PIIX4_SMB_IDX		0xcd6
 
@@ -802,6 +809,7 @@ MODULE_DEVICE_TABLE (pci, piix4_ids);
 
 static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS];
 static struct i2c_adapter *piix4_aux_adapter;
+static int piix4_adapter_count;
 
 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
 			     bool sb800_main, u8 port, bool notify_imc,
@@ -858,10 +866,17 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba,
 				    bool notify_imc)
 {
 	struct i2c_piix4_adapdata *adapdata;
-	int port;
+	int port, port_count;
 	int retval;
 
-	for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
+	if (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS ||
+	    dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS) {
+		port_count = HUDSON2_MAIN_PORTS;
+	} else {
+		port_count = SB800_MAIN_PORTS;
+	}
+
+	for (port = 0; port < port_count; port++) {
 		retval = piix4_add_adapter(dev, smba, true, port, notify_imc,
 					   piix4_main_port_names_sb800[port],
 					   &piix4_main_adapters[port]);
@@ -874,7 +889,7 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba,
 error:
 	dev_err(&dev->dev,
 		"Error setting up SB800 adapters. Unregistering!\n");
-	while (--port >= 0) {
+	while (--piix4_adapter_count >= 0) {
 		adapdata = i2c_get_adapdata(piix4_main_adapters[port]);
 		if (adapdata->smba) {
 			i2c_del_adapter(piix4_main_adapters[port]);
@@ -995,12 +1010,10 @@ static void piix4_adap_remove(struct i2c_adapter *adap)
 
 static void piix4_remove(struct pci_dev *dev)
 {
-	int port = PIIX4_MAX_ADAPTERS;
-
-	while (--port >= 0) {
-		if (piix4_main_adapters[port]) {
-			piix4_adap_remove(piix4_main_adapters[port]);
-			piix4_main_adapters[port] = NULL;
+	while (--piix4_adapter_count >= 0) {
+		if (piix4_main_adapters[piix4_adapter_count]) {
+			piix4_adap_remove(piix4_main_adapters[piix4_adapter_count]);
+			piix4_main_adapters[piix4_adapter_count] = NULL;
 		}
 	}
 
-- 
2.7.4

  parent reply	other threads:[~2017-12-14  3:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14  3:11 [PATCH v2 0/3] Enable ACPI-defined peripherals on i2c-piix4 SMBus Andrew Cooks
2018-01-29  3:54 ` [PATCH v3 " Andrew Cooks
2017-12-14  3:11 ` [PATCH v2 1/3] i2c: piix4: Fix SMBus port selection for AMD Family 16h chips Andrew Cooks
2017-12-14  3:11   ` Andrew Cooks
2017-12-14 23:58   ` Andrew Cooks
2017-12-14  3:11 ` Andrew Cooks [this message]
2017-12-14  3:11   ` [PATCH v2 2/3] i2c: piix4: fix number of SMBus ports on HUDSON2 Andrew Cooks
2017-12-14  3:11 ` [PATCH v2 3/3] i2c: add ACPI support for i2c-piix4 Andrew Cooks
2017-12-14  3:11   ` Andrew Cooks

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=10a5f5d056511d07c1946d744fc84f243a6097cc.1513215039.git.andrew.cooks@opengear.com \
    --to=andrew.cooks@opengear.com \
    --cc=jdelvare@suse.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platypus-sw@opengear.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 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.