aboutsummaryrefslogtreecommitdiffstats
path: root/i2c
diff options
context:
space:
mode:
author <greg@echidna.(none)>2005-09-28 16:04:25 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-28 16:04:25 -0700
commitec26580b1071b2113c7bbc2b32ef9bee3e13d2bf (patch)
treedcd29a3a27c8028499e9341984dbb01bb853482e /i2c
parent1c894cb4fcc706cf35cae20dce29fac29695f5cc (diff)
downloadpatches-ec26580b1071b2113c7bbc2b32ef9bee3e13d2bf.tar.gz
i2c patches
Diffstat (limited to 'i2c')
-rw-r--r--i2c/i2c-viapro-01.patch31
-rw-r--r--i2c/i2c-viapro-02.patch246
-rw-r--r--i2c/i2c-viapro-03.patch144
-rw-r--r--i2c/i2c-viapro-04.patch350
-rw-r--r--i2c/i2c-viapro-05.patch76
-rw-r--r--i2c/i2c-viapro-06.patch48
-rw-r--r--i2c/i2c-viapro-07.patch80
-rw-r--r--i2c/i2c-viapro-08.patch47
8 files changed, 1022 insertions, 0 deletions
diff --git a/i2c/i2c-viapro-01.patch b/i2c/i2c-viapro-01.patch
new file mode 100644
index 0000000000000..7ffe67435660b
--- /dev/null
+++ b/i2c/i2c-viapro-01.patch
@@ -0,0 +1,31 @@
+From khali@linux-fr.org Fri Sep 23 00:04:16 2005
+Date: Thu, 22 Sep 2005 21:47:58 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (1/7) i2c-viapro: New maintainer
+Message-Id: <20050922214758.3052c5e1.khali@linux-fr.org>
+
+I am taking over the maintenance of the i2c-viapro SMBus driver.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ MAINTAINERS | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- gregkh-2.6.orig/MAINTAINERS 2005-09-28 15:53:19.000000000 -0700
++++ gregkh-2.6/MAINTAINERS 2005-09-28 15:54:04.000000000 -0700
+@@ -2704,6 +2704,12 @@
+ M: rl@hellgate.ch
+ S: Maintained
+
++VIAPRO SMBUS DRIVER
++P: Jean Delvare
++M: khali@linux-fr.org
++L: lm-sensors@lm-sensors.org
++S: Maintained
++
+ UCLINUX (AND M68KNOMMU)
+ P: Greg Ungerer
+ M: gerg@uclinux.org
diff --git a/i2c/i2c-viapro-02.patch b/i2c/i2c-viapro-02.patch
new file mode 100644
index 0000000000000..5bd00bf5d9835
--- /dev/null
+++ b/i2c/i2c-viapro-02.patch
@@ -0,0 +1,246 @@
+From khali@linux-fr.org Fri Sep 23 00:04:19 2005
+Date: Thu, 22 Sep 2005 21:50:47 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (2/7) i2c-viapro: Coding style fixes
+Message-Id: <20050922215047.78084409.khali@linux-fr.org>
+
+Before I go on cleaning up and improving the i2c-viapro driver, let's
+fix all the coding style issues: mostly trailing white space, and
+spaces used where tabs should be.
+
+Signed-off-by: Jean Delvare <khali@linux-fr>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ Documentation/i2c/busses/i2c-viapro | 12 ++---
+ drivers/i2c/busses/i2c-viapro.c | 76 ++++++++++++++++++------------------
+ 2 files changed, 43 insertions(+), 45 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-20 08:14:19.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:06.000000000 -0700
+@@ -1,7 +1,7 @@
+ /*
+ i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware
+ monitoring
+- Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
++ Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
+ Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
+ Mark D. Studebaker <mdsxyz123@yahoo.com>
+
+@@ -46,9 +46,9 @@
+
+ static struct pci_dev *vt596_pdev;
+
+-#define SMBBA1 0x90
+-#define SMBBA2 0x80
+-#define SMBBA3 0xD0
++#define SMBBA1 0x90
++#define SMBBA2 0x80
++#define SMBBA3 0xD0
+
+ /* SMBus address offsets */
+ static unsigned short vt596_smba;
+@@ -68,26 +68,26 @@
+ /* PCI Address Constants */
+
+ /* SMBus data in configuration space can be found in two places,
+- We try to select the better one*/
++ We try to select the better one */
+
+ static unsigned short smb_cf_hstcfg = 0xD2;
+
+-#define SMBHSTCFG (smb_cf_hstcfg)
+-#define SMBSLVC (smb_cf_hstcfg + 1)
+-#define SMBSHDW1 (smb_cf_hstcfg + 2)
+-#define SMBSHDW2 (smb_cf_hstcfg + 3)
+-#define SMBREV (smb_cf_hstcfg + 4)
++#define SMBHSTCFG (smb_cf_hstcfg)
++#define SMBSLVC (smb_cf_hstcfg + 1)
++#define SMBSHDW1 (smb_cf_hstcfg + 2)
++#define SMBSHDW2 (smb_cf_hstcfg + 3)
++#define SMBREV (smb_cf_hstcfg + 4)
+
+ /* Other settings */
+ #define MAX_TIMEOUT 500
+ #define ENABLE_INT9 0
+
+ /* VT82C596 constants */
+-#define VT596_QUICK 0x00
+-#define VT596_BYTE 0x04
+-#define VT596_BYTE_DATA 0x08
+-#define VT596_WORD_DATA 0x0C
+-#define VT596_BLOCK_DATA 0x14
++#define VT596_QUICK 0x00
++#define VT596_BYTE 0x04
++#define VT596_BYTE_DATA 0x08
++#define VT596_WORD_DATA 0x0C
++#define VT596_BLOCK_DATA 0x14
+
+
+ /* If force is set to anything different from 0, we forcibly enable the
+@@ -115,19 +115,19 @@
+ int timeout = 0;
+
+ dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
+- "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
+- inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
++ "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
++ inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
+ inb_p(SMBHSTDAT1));
+
+ /* Make sure the SMBus host is ready to start transmitting */
+ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+ dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). "
+- "Resetting...\n", temp);
+-
++ "Resetting...\n", temp);
++
+ outb_p(temp, SMBHSTSTS);
+ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+ dev_dbg(&vt596_adapter.dev, "Failed! (0x%02x)\n", temp);
+-
++
+ return -1;
+ } else {
+ dev_dbg(&vt596_adapter.dev, "Successfull!\n");
+@@ -137,7 +137,7 @@
+ /* start the transaction by setting bit 6 */
+ outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT);
+
+- /* We will always wait for a fraction of a second!
++ /* We will always wait for a fraction of a second!
+ I don't know if VIA needs this, Intel did */
+ do {
+ msleep(1);
+@@ -177,16 +177,16 @@
+
+ dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
+ "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
+- inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
++ inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
+ inb_p(SMBHSTDAT1));
+-
++
+ return result;
+ }
+
+ /* Return -1 on error. */
+ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
+- unsigned short flags, char read_write, u8 command,
+- int size, union i2c_smbus_data *data)
++ unsigned short flags, char read_write, u8 command,
++ int size, union i2c_smbus_data *data)
+ {
+ int i, len;
+
+@@ -256,7 +256,7 @@
+ case VT596_BYTE:
+ /* Where is the result put? I assume here it is in
+ * SMBHSTDAT0 but it might just as well be in the
+- * SMBHSTCMD. No clue in the docs
++ * SMBHSTCMD. No clue in the docs
+ */
+ data->byte = inb_p(SMBHSTDAT0);
+ break;
+@@ -302,7 +302,7 @@
+ {
+ unsigned char temp;
+ int error = -ENODEV;
+-
++
+ /* Determine the address of the SMBus areas */
+ if (force_addr) {
+ vt596_smba = force_addr & 0xfff0;
+@@ -333,10 +333,10 @@
+ return -ENODEV;
+ }
+
+- found:
++found:
+ if (!request_region(vt596_smba, 8, "viapro-smbus")) {
+ dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
+- vt596_smba);
++ vt596_smba);
+ return -ENODEV;
+ }
+
+@@ -348,13 +348,13 @@
+ pci_write_config_word(pdev, id->driver_data, vt596_smba);
+ pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
+ dev_warn(&pdev->dev, "WARNING: SMBus interface set to new "
+- "address 0x%04x!\n", vt596_smba);
++ "address 0x%04x!\n", vt596_smba);
+ } else if ((temp & 1) == 0) {
+ if (force) {
+- /* NOTE: This assumes I/O space and other allocations
+- * WERE done by the Bios! Don't complain if your
+- * hardware does weird things after enabling this.
+- * :') Check for Bios updates before resorting to
++ /* NOTE: This assumes I/O space and other allocations
++ * WERE done by the Bios! Don't complain if your
++ * hardware does weird things after enabling this.
++ * :') Check for Bios updates before resorting to
+ * this.
+ */
+ pci_write_config_byte(pdev, SMBHSTCFG, temp | 1);
+@@ -381,8 +381,8 @@
+
+ vt596_adapter.dev.parent = &pdev->dev;
+ snprintf(vt596_adapter.name, I2C_NAME_SIZE,
+- "SMBus Via Pro adapter at %04x", vt596_smba);
+-
++ "SMBus Via Pro adapter at %04x", vt596_smba);
++
+ vt596_pdev = pci_dev_get(pdev);
+ if (i2c_add_adapter(&vt596_adapter)) {
+ pci_dev_put(vt596_pdev);
+@@ -395,7 +395,7 @@
+ */
+ return -ENODEV;
+
+- release_region:
++release_region:
+ release_region(vt596_smba, 8);
+ return error;
+ }
+@@ -420,7 +420,7 @@
+ { 0, }
+ };
+
+-MODULE_DEVICE_TABLE (pci, vt596_ids);
++MODULE_DEVICE_TABLE(pci, vt596_ids);
+
+ static struct pci_driver vt596_driver = {
+ .name = "vt596_smbus",
+--- gregkh-2.6.orig/Documentation/i2c/busses/i2c-viapro 2005-08-28 16:41:01.000000000 -0700
++++ gregkh-2.6/Documentation/i2c/busses/i2c-viapro 2005-09-28 15:54:06.000000000 -0700
+@@ -4,17 +4,17 @@
+ * VIA Technologies, Inc. VT82C596A/B
+ Datasheet: Sometimes available at the VIA website
+
+- * VIA Technologies, Inc. VT82C686A/B
++ * VIA Technologies, Inc. VT82C686A/B
+ Datasheet: Sometimes available at the VIA website
+
+ * VIA Technologies, Inc. VT8231, VT8233, VT8233A, VT8235, VT8237
+ Datasheet: available on request from Via
+
+ Authors:
+- Frodo Looijaard <frodol@dds.nl>,
+- Philip Edelbrock <phil@netroedge.com>,
+- Kyösti Mälkki <kmalkki@cc.hut.fi>,
+- Mark D. Studebaker <mdsxyz123@yahoo.com>
++ Frodo Looijaard <frodol@dds.nl>,
++ Philip Edelbrock <phil@netroedge.com>,
++ Kyösti Mälkki <kmalkki@cc.hut.fi>,
++ Mark D. Studebaker <mdsxyz123@yahoo.com>
+
+ Module Parameters
+ -----------------
+@@ -43,5 +43,3 @@
+
+ If none of these show up, you should look in the BIOS for settings like
+ enable ACPI / SMBus or even USB.
+-
+-
diff --git a/i2c/i2c-viapro-03.patch b/i2c/i2c-viapro-03.patch
new file mode 100644
index 0000000000000..ddbe2f3c40f12
--- /dev/null
+++ b/i2c/i2c-viapro-03.patch
@@ -0,0 +1,144 @@
+From khali@linux-fr.org Fri Sep 23 00:04:35 2005
+Date: Thu, 22 Sep 2005 21:58:41 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (3/7) i2c-viapro: Implement I2C Block transactions
+Message-Id: <20050922215841.424507df.khali@linux-fr.org>
+
+Implement the I2C block transactions on VIA chips which support them:
+VT82C686B, VT8233, VT8233A, VT8235 and VT8237R. This speeds up EEPROM
+accesses by a factor 10 or so.
+
+I would like to thank Antonino A. Daplas, Hinko Kocevar, Salah Coronya
+and Andreas Henriksson for their help in testing this new feature.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ Documentation/i2c/busses/i2c-viapro | 7 +++++-
+ drivers/i2c/busses/i2c-viapro.c | 39 +++++++++++++++++++++++++++++++++---
+ 2 files changed, 42 insertions(+), 4 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:07.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:08.000000000 -0700
+@@ -4,6 +4,7 @@
+ Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
+ Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
+ Mark D. Studebaker <mdsxyz123@yahoo.com>
++ Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+@@ -88,6 +89,7 @@
+ #define VT596_BYTE_DATA 0x08
+ #define VT596_WORD_DATA 0x0C
+ #define VT596_BLOCK_DATA 0x14
++#define VT596_I2C_BLOCK_DATA 0x34
+
+
+ /* If force is set to anything different from 0, we forcibly enable the
+@@ -107,6 +109,9 @@
+
+ static struct i2c_adapter vt596_adapter;
+
++#define FEATURE_I2CBLOCK (1<<0)
++static unsigned int vt596_features;
++
+ /* Another internally used function */
+ static int vt596_transaction(void)
+ {
+@@ -225,6 +230,12 @@
+ }
+ size = VT596_WORD_DATA;
+ break;
++ case I2C_SMBUS_I2C_BLOCK_DATA:
++ if (!(vt596_features & FEATURE_I2CBLOCK))
++ return -1;
++ if (read_write == I2C_SMBUS_READ)
++ outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0);
++ /* Fall through */
+ case I2C_SMBUS_BLOCK_DATA:
+ outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
+ SMBHSTADD);
+@@ -240,11 +251,12 @@
+ for (i = 1; i <= len; i++)
+ outb_p(data->block[i], SMBBLKDAT);
+ }
+- size = VT596_BLOCK_DATA;
++ size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ?
++ VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA;
+ break;
+ }
+
+- outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
++ outb_p((size & 0x3C) + (ENABLE_INT9 & 1), SMBHSTCNT);
+
+ if (vt596_transaction()) /* Error in transaction */
+ return -1;
+@@ -266,6 +278,7 @@
+ case VT596_WORD_DATA:
+ data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8);
+ break;
++ case VT596_I2C_BLOCK_DATA:
+ case VT596_BLOCK_DATA:
+ data->block[0] = inb_p(SMBHSTDAT0);
+ if (data->block[0] > I2C_SMBUS_BLOCK_MAX)
+@@ -280,9 +293,13 @@
+
+ static u32 vt596_func(struct i2c_adapter *adapter)
+ {
+- return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
++ u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
+ I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
+ I2C_FUNC_SMBUS_BLOCK_DATA;
++
++ if (vt596_features & FEATURE_I2CBLOCK)
++ func |= I2C_FUNC_SMBUS_I2C_BLOCK;
++ return func;
+ }
+
+ static struct i2c_algorithm smbus_algorithm = {
+@@ -379,6 +396,22 @@
+ dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp);
+ dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
+
++ switch (pdev->device) {
++ case PCI_DEVICE_ID_VIA_8237:
++ case PCI_DEVICE_ID_VIA_8235:
++ case PCI_DEVICE_ID_VIA_8233A:
++ case PCI_DEVICE_ID_VIA_8233_0:
++ vt596_features |= FEATURE_I2CBLOCK;
++ break;
++ case PCI_DEVICE_ID_VIA_82C686_4:
++ /* The VT82C686B (rev 0x40) does support I2C block
++ transactions, but the VT82C686A (rev 0x30) doesn't */
++ if (!pci_read_config_byte(pdev, PCI_REVISION_ID, &temp)
++ && temp >= 0x40)
++ vt596_features |= FEATURE_I2CBLOCK;
++ break;
++ }
++
+ vt596_adapter.dev.parent = &pdev->dev;
+ snprintf(vt596_adapter.name, I2C_NAME_SIZE,
+ "SMBus Via Pro adapter at %04x", vt596_smba);
+--- gregkh-2.6.orig/Documentation/i2c/busses/i2c-viapro 2005-09-28 15:54:07.000000000 -0700
++++ gregkh-2.6/Documentation/i2c/busses/i2c-viapro 2005-09-28 15:54:08.000000000 -0700
+@@ -14,7 +14,8 @@
+ Frodo Looijaard <frodol@dds.nl>,
+ Philip Edelbrock <phil@netroedge.com>,
+ Kyösti Mälkki <kmalkki@cc.hut.fi>,
+- Mark D. Studebaker <mdsxyz123@yahoo.com>
++ Mark D. Studebaker <mdsxyz123@yahoo.com>,
++ Jean Delvare <khali@linux-fr.org>
+
+ Module Parameters
+ -----------------
+@@ -43,3 +44,7 @@
+
+ If none of these show up, you should look in the BIOS for settings like
+ enable ACPI / SMBus or even USB.
++
++Except for the oldest chips (VT82C596A/B, VT82C686A and most probably
++VT8231), this driver supports I2C block transactions. Such transactions
++are mainly useful to read from and write to EEPROMs.
diff --git a/i2c/i2c-viapro-04.patch b/i2c/i2c-viapro-04.patch
new file mode 100644
index 0000000000000..e1f36fd8bf2a2
--- /dev/null
+++ b/i2c/i2c-viapro-04.patch
@@ -0,0 +1,350 @@
+From khali@linux-fr.org Fri Sep 23 00:04:50 2005
+Date: Thu, 22 Sep 2005 22:01:07 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (4/7) i2c-viapro: Code cleanups
+Message-Id: <20050922220107.68c01347.khali@linux-fr.org>
+
+Cleanups to the i2c-viapro driver:
+* Kill unused defines.
+* Kill interrupt-related code, as the driver doesn't use interrupts.
+* Fix broken comments (some copied from i2c-piix4.)
+* Centralize the unsupported command error case in vt596_access.
+ That way we'll catch all unsupported commands, not only
+ I2C_SMBUS_PROC_CALL.
+* Refactor some code.
+* Convert some dev_dbg into dev_err. Errors better be reported even in
+ non-debug mode.
+* Do not verify that the final reset succeeded. It'll be checked at
+ the beginning of the next transaction anyway.
+* Use the driver name to reserve the I/O region.
+* Do not print the contents of the SMBREV register, it reads 0 on all
+ chips I've seen so far.
+* Some other minor fixes all over the place.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ drivers/i2c/busses/i2c-viapro.c | 122 +++++++++++++---------------------------
+ 1 file changed, 41 insertions(+), 81 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:09.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:11.000000000 -0700
+@@ -39,7 +39,6 @@
+ #include <linux/pci.h>
+ #include <linux/kernel.h>
+ #include <linux/stddef.h>
+-#include <linux/sched.h>
+ #include <linux/ioport.h>
+ #include <linux/i2c.h>
+ #include <linux/init.h>
+@@ -54,34 +53,22 @@
+ /* SMBus address offsets */
+ static unsigned short vt596_smba;
+ #define SMBHSTSTS (vt596_smba + 0)
+-#define SMBHSLVSTS (vt596_smba + 1)
+ #define SMBHSTCNT (vt596_smba + 2)
+ #define SMBHSTCMD (vt596_smba + 3)
+ #define SMBHSTADD (vt596_smba + 4)
+ #define SMBHSTDAT0 (vt596_smba + 5)
+ #define SMBHSTDAT1 (vt596_smba + 6)
+ #define SMBBLKDAT (vt596_smba + 7)
+-#define SMBSLVCNT (vt596_smba + 8)
+-#define SMBSHDWCMD (vt596_smba + 9)
+-#define SMBSLVEVT (vt596_smba + 0xA)
+-#define SMBSLVDAT (vt596_smba + 0xC)
+
+ /* PCI Address Constants */
+
+ /* SMBus data in configuration space can be found in two places,
+ We try to select the better one */
+
+-static unsigned short smb_cf_hstcfg = 0xD2;
+-
+-#define SMBHSTCFG (smb_cf_hstcfg)
+-#define SMBSLVC (smb_cf_hstcfg + 1)
+-#define SMBSHDW1 (smb_cf_hstcfg + 2)
+-#define SMBSHDW2 (smb_cf_hstcfg + 3)
+-#define SMBREV (smb_cf_hstcfg + 4)
++static unsigned short SMBHSTCFG = 0xD2;
+
+ /* Other settings */
+ #define MAX_TIMEOUT 500
+-#define ENABLE_INT9 0
+
+ /* VT82C596 constants */
+ #define VT596_QUICK 0x00
+@@ -107,12 +94,13 @@
+ "EXTREMELY DANGEROUS!");
+
+
++static struct pci_driver vt596_driver;
+ static struct i2c_adapter vt596_adapter;
+
+ #define FEATURE_I2CBLOCK (1<<0)
+ static unsigned int vt596_features;
+
+-/* Another internally used function */
++/* Return -1 on error, 0 on success */
+ static int vt596_transaction(void)
+ {
+ int temp;
+@@ -127,23 +115,21 @@
+ /* Make sure the SMBus host is ready to start transmitting */
+ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+ dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). "
+- "Resetting...\n", temp);
++ "Resetting... ", temp);
+
+ outb_p(temp, SMBHSTSTS);
+ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+- dev_dbg(&vt596_adapter.dev, "Failed! (0x%02x)\n", temp);
+-
++ printk("Failed! (0x%02x)\n", temp);
+ return -1;
+ } else {
+- dev_dbg(&vt596_adapter.dev, "Successfull!\n");
++ printk("Successful!\n");
+ }
+ }
+
+- /* start the transaction by setting bit 6 */
+- outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT);
++ /* Start the transaction by setting bit 6 */
++ outb_p(inb(SMBHSTCNT) | 0x40, SMBHSTCNT);
+
+- /* We will always wait for a fraction of a second!
+- I don't know if VIA needs this, Intel did */
++ /* We will always wait for a fraction of a second */
+ do {
+ msleep(1);
+ temp = inb_p(SMBHSTSTS);
+@@ -152,33 +138,32 @@
+ /* If the SMBus is still busy, we give up */
+ if (timeout >= MAX_TIMEOUT) {
+ result = -1;
+- dev_dbg(&vt596_adapter.dev, "SMBus Timeout!\n");
++ dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
+ }
+
+ if (temp & 0x10) {
+ result = -1;
+- dev_dbg(&vt596_adapter.dev, "Error: Failed bus transaction\n");
++ dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
++ inb_p(SMBHSTCNT) & 0x3C);
+ }
+
+ if (temp & 0x08) {
+ result = -1;
+- dev_info(&vt596_adapter.dev, "Bus collision! SMBus may be "
+- "locked until next hard\nreset. (sorry!)\n");
+- /* Clock stops and slave is stuck in mid-transmission */
++ dev_err(&vt596_adapter.dev, "SMBus collision!\n");
+ }
+
+ if (temp & 0x04) {
+ result = -1;
+- dev_dbg(&vt596_adapter.dev, "Error: no response!\n");
++ /* Quick commands are used to probe for chips, so
++ errors are expected, and we don't want to frighten the
++ user. */
++ if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK)
++ dev_err(&vt596_adapter.dev, "Transaction error!\n");
+ }
+
+- if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
++ /* Resetting status register */
++ if (temp & 0x1F)
+ outb_p(temp, SMBHSTSTS);
+- if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+- dev_warn(&vt596_adapter.dev, "Failed reset at end "
+- "of transaction (%02x)\n", temp);
+- }
+- }
+
+ dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
+ "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
+@@ -188,41 +173,29 @@
+ return result;
+ }
+
+-/* Return -1 on error. */
++/* Return -1 on error, 0 on success */
+ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
+ unsigned short flags, char read_write, u8 command,
+ int size, union i2c_smbus_data *data)
+ {
+- int i, len;
++ int i;
+
+ switch (size) {
+- case I2C_SMBUS_PROC_CALL:
+- dev_info(&vt596_adapter.dev,
+- "I2C_SMBUS_PROC_CALL not supported!\n");
+- return -1;
+ case I2C_SMBUS_QUICK:
+- outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
+- SMBHSTADD);
+ size = VT596_QUICK;
+ break;
+ case I2C_SMBUS_BYTE:
+- outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
+- SMBHSTADD);
+ if (read_write == I2C_SMBUS_WRITE)
+ outb_p(command, SMBHSTCMD);
+ size = VT596_BYTE;
+ break;
+ case I2C_SMBUS_BYTE_DATA:
+- outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
+- SMBHSTADD);
+ outb_p(command, SMBHSTCMD);
+ if (read_write == I2C_SMBUS_WRITE)
+ outb_p(data->byte, SMBHSTDAT0);
+ size = VT596_BYTE_DATA;
+ break;
+ case I2C_SMBUS_WORD_DATA:
+- outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
+- SMBHSTADD);
+ outb_p(command, SMBHSTCMD);
+ if (read_write == I2C_SMBUS_WRITE) {
+ outb_p(data->word & 0xff, SMBHSTDAT0);
+@@ -232,31 +205,30 @@
+ break;
+ case I2C_SMBUS_I2C_BLOCK_DATA:
+ if (!(vt596_features & FEATURE_I2CBLOCK))
+- return -1;
++ goto exit_unsupported;
+ if (read_write == I2C_SMBUS_READ)
+ outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0);
+ /* Fall through */
+ case I2C_SMBUS_BLOCK_DATA:
+- outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
+- SMBHSTADD);
+ outb_p(command, SMBHSTCMD);
+ if (read_write == I2C_SMBUS_WRITE) {
+- len = data->block[0];
+- if (len < 0)
+- len = 0;
++ u8 len = data->block[0];
+ if (len > I2C_SMBUS_BLOCK_MAX)
+ len = I2C_SMBUS_BLOCK_MAX;
+ outb_p(len, SMBHSTDAT0);
+- i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
++ inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
+ for (i = 1; i <= len; i++)
+ outb_p(data->block[i], SMBBLKDAT);
+ }
+ size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ?
+ VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA;
+ break;
++ default:
++ goto exit_unsupported;
+ }
+
+- outb_p((size & 0x3C) + (ENABLE_INT9 & 1), SMBHSTCNT);
++ outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD);
++ outb_p((size & 0x3C), SMBHSTCNT);
+
+ if (vt596_transaction()) /* Error in transaction */
+ return -1;
+@@ -266,12 +238,6 @@
+
+ switch (size) {
+ case VT596_BYTE:
+- /* Where is the result put? I assume here it is in
+- * SMBHSTDAT0 but it might just as well be in the
+- * SMBHSTCMD. No clue in the docs
+- */
+- data->byte = inb_p(SMBHSTDAT0);
+- break;
+ case VT596_BYTE_DATA:
+ data->byte = inb_p(SMBHSTDAT0);
+ break;
+@@ -283,12 +249,17 @@
+ data->block[0] = inb_p(SMBHSTDAT0);
+ if (data->block[0] > I2C_SMBUS_BLOCK_MAX)
+ data->block[0] = I2C_SMBUS_BLOCK_MAX;
+- i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
++ inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
+ for (i = 1; i <= data->block[0]; i++)
+ data->block[i] = inb_p(SMBBLKDAT);
+ break;
+ }
+ return 0;
++
++exit_unsupported:
++ dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n",
++ size);
++ return -1;
+ }
+
+ static u32 vt596_func(struct i2c_adapter *adapter)
+@@ -311,7 +282,6 @@
+ .owner = THIS_MODULE,
+ .class = I2C_CLASS_HWMON,
+ .algo = &smbus_algorithm,
+- .name = "unset",
+ };
+
+ static int __devinit vt596_probe(struct pci_dev *pdev,
+@@ -328,12 +298,12 @@
+ }
+
+ if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) ||
+- !(vt596_smba & 0x1)) {
++ !(vt596_smba & 0x0001)) {
+ /* try 2nd address and config reg. for 596 */
+ if (id->device == PCI_DEVICE_ID_VIA_82C596_3 &&
+ !pci_read_config_word(pdev, SMBBA2, &vt596_smba) &&
+- (vt596_smba & 0x1)) {
+- smb_cf_hstcfg = 0x84;
++ (vt596_smba & 0x0001)) {
++ SMBHSTCFG = 0x84;
+ } else {
+ /* no matches at all */
+ dev_err(&pdev->dev, "Cannot configure "
+@@ -351,7 +321,7 @@
+ }
+
+ found:
+- if (!request_region(vt596_smba, 8, "viapro-smbus")) {
++ if (!request_region(vt596_smba, 8, vt596_driver.name)) {
+ dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
+ vt596_smba);
+ return -ENODEV;
+@@ -366,7 +336,7 @@
+ pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
+ dev_warn(&pdev->dev, "WARNING: SMBus interface set to new "
+ "address 0x%04x!\n", vt596_smba);
+- } else if ((temp & 1) == 0) {
++ } else if (!(temp & 0x01)) {
+ if (force) {
+ /* NOTE: This assumes I/O space and other allocations
+ * WERE done by the Bios! Don't complain if your
+@@ -374,7 +344,7 @@
+ * :') Check for Bios updates before resorting to
+ * this.
+ */
+- pci_write_config_byte(pdev, SMBHSTCFG, temp | 1);
++ pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
+ dev_info(&pdev->dev, "Enabling SMBus device\n");
+ } else {
+ dev_err(&pdev->dev, "SMBUS: Error: Host SMBus "
+@@ -384,16 +354,6 @@
+ }
+ }
+
+- if ((temp & 0x0E) == 8)
+- dev_dbg(&pdev->dev, "using Interrupt 9 for SMBus.\n");
+- else if ((temp & 0x0E) == 0)
+- dev_dbg(&pdev->dev, "using Interrupt SMI# for SMBus.\n");
+- else
+- dev_dbg(&pdev->dev, "Illegal Interrupt configuration "
+- "(or code out of date)!\n");
+-
+- pci_read_config_byte(pdev, SMBREV, &temp);
+- dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp);
+ dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
+
+ switch (pdev->device) {
diff --git a/i2c/i2c-viapro-05.patch b/i2c/i2c-viapro-05.patch
new file mode 100644
index 0000000000000..d0f6a3af276a4
--- /dev/null
+++ b/i2c/i2c-viapro-05.patch
@@ -0,0 +1,76 @@
+From khali@linux-fr.org Fri Sep 23 00:05:06 2005
+Date: Thu, 22 Sep 2005 22:09:07 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (5/7) i2c-viapro: Update supported devices list
+Message-Id: <20050922220907.34c266cb.khali@linux-fr.org>
+
+Make it clearer which chips are supported by the i2c-viapro driver,
+and which support I2C block transactions.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ Documentation/i2c/busses/i2c-viapro | 12 ++++++------
+ drivers/i2c/busses/i2c-viapro.c | 22 +++++++++++++---------
+ 2 files changed, 19 insertions(+), 15 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:12.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:13.000000000 -0700
+@@ -22,15 +22,19 @@
+ */
+
+ /*
+- Supports Via devices:
+- 82C596A/B (0x3050)
+- 82C596B (0x3051)
+- 82C686A/B
+- 8231
+- 8233
+- 8233A (0x3147 and 0x3177)
+- 8235
+- 8237
++ Supports the following VIA south bridges:
++
++ Chip name PCI ID REV I2C block
++ VT82C596A 0x3050 no
++ VT82C596B 0x3051 no
++ VT82C686A 0x3057 0x30 no
++ VT82C686B 0x3057 0x40 yes
++ VT8231 0x8235 no?
++ VT8233 0x3074 yes
++ VT8233A 0x3147 yes?
++ VT8235 0x3177 yes
++ VT8237R 0x3227 yes
++
+ Note: we assume there can only be one device, with one SMBus interface.
+ */
+
+--- gregkh-2.6.orig/Documentation/i2c/busses/i2c-viapro 2005-09-28 15:54:09.000000000 -0700
++++ gregkh-2.6/Documentation/i2c/busses/i2c-viapro 2005-09-28 15:54:13.000000000 -0700
+@@ -29,18 +29,18 @@
+ -----------
+
+ i2c-viapro is a true SMBus host driver for motherboards with one of the
+-supported VIA southbridges.
++supported VIA south bridges.
+
+ Your lspci -n listing must show one of these :
+
+- device 1106:3050 (VT82C596 function 3)
+- device 1106:3051 (VT82C596 function 3)
++ device 1106:3050 (VT82C596A function 3)
++ device 1106:3051 (VT82C596B function 3)
+ device 1106:3057 (VT82C686 function 4)
+ device 1106:3074 (VT8233)
+ device 1106:3147 (VT8233A)
+- device 1106:8235 (VT8231)
+- devide 1106:3177 (VT8235)
+- devide 1106:3227 (VT8237)
++ device 1106:8235 (VT8231 function 4)
++ device 1106:3177 (VT8235)
++ device 1106:3227 (VT8237R)
+
+ If none of these show up, you should look in the BIOS for settings like
+ enable ACPI / SMBus or even USB.
diff --git a/i2c/i2c-viapro-06.patch b/i2c/i2c-viapro-06.patch
new file mode 100644
index 0000000000000..4a59bf8ea31a2
--- /dev/null
+++ b/i2c/i2c-viapro-06.patch
@@ -0,0 +1,48 @@
+From khali@linux-fr.org Fri Sep 23 00:05:12 2005
+Date: Thu, 22 Sep 2005 22:15:53 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (6/7) i2c-viapro: Refactor control outb
+Message-Id: <20050922221553.1a51a3a0.khali@linux-fr.org>
+
+By slightly shifting the interface between vt596_access and
+vt596_transaction, we can save two I/O accesses per SMBus transaction.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ drivers/i2c/busses/i2c-viapro.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:14.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:15.000000000 -0700
+@@ -105,7 +105,7 @@
+ static unsigned int vt596_features;
+
+ /* Return -1 on error, 0 on success */
+-static int vt596_transaction(void)
++static int vt596_transaction(u8 size)
+ {
+ int temp;
+ int result = 0;
+@@ -131,7 +131,7 @@
+ }
+
+ /* Start the transaction by setting bit 6 */
+- outb_p(inb(SMBHSTCNT) | 0x40, SMBHSTCNT);
++ outb_p(0x40 | (size & 0x3C), SMBHSTCNT);
+
+ /* We will always wait for a fraction of a second */
+ do {
+@@ -232,9 +232,8 @@
+ }
+
+ outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD);
+- outb_p((size & 0x3C), SMBHSTCNT);
+
+- if (vt596_transaction()) /* Error in transaction */
++ if (vt596_transaction(size)) /* Error in transaction */
+ return -1;
+
+ if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
diff --git a/i2c/i2c-viapro-07.patch b/i2c/i2c-viapro-07.patch
new file mode 100644
index 0000000000000..62ba095e8a277
--- /dev/null
+++ b/i2c/i2c-viapro-07.patch
@@ -0,0 +1,80 @@
+From khali@linux-fr.org Fri Sep 23 00:05:24 2005
+Date: Thu, 22 Sep 2005 22:23:32 +0200
+From: Jean Delvare <khali@linux-fr.org>
+To: Greg KH <greg@kroah.com>
+Subject: [PATCH] (7/7) i2c-viapro: Improve register dump
+Message-Id: <20050922222332.000eaa7f.khali@linux-fr.org>
+
+
+Improve the register dump used to debug the i2c-viapro driver. The
+original dump was missing the HSTSTS register and the block data
+buffer.
+
+Signed-off-by: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ drivers/i2c/busses/i2c-viapro.c | 38 ++++++++++++++++++++++++++++++--------
+ 1 file changed, 30 insertions(+), 8 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:16.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:17.000000000 -0700
+@@ -104,6 +104,30 @@
+ #define FEATURE_I2CBLOCK (1<<0)
+ static unsigned int vt596_features;
+
++#ifdef DEBUG
++static void vt596_dump_regs(const char *msg, u8 size)
++{
++ dev_dbg(&vt596_adapter.dev, "%s: STS=%02x CNT=%02x CMD=%02x ADD=%02x "
++ "DAT=%02x,%02x\n", msg, inb_p(SMBHSTSTS), inb_p(SMBHSTCNT),
++ inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
++ inb_p(SMBHSTDAT1));
++
++ if (size == VT596_BLOCK_DATA
++ || size == VT596_I2C_BLOCK_DATA) {
++ int i;
++
++ dev_dbg(&vt596_adapter.dev, "BLK=");
++ for (i = 0; i < I2C_SMBUS_BLOCK_MAX / 2; i++)
++ printk("%02x,", inb_p(SMBBLKDAT));
++ printk("\n");
++ dev_dbg(&vt596_adapter.dev, " ");
++ for (; i < I2C_SMBUS_BLOCK_MAX - 1; i++)
++ printk("%02x,", inb_p(SMBBLKDAT));
++ printk("%02x\n", inb_p(SMBBLKDAT));
++ }
++}
++#endif
++
+ /* Return -1 on error, 0 on success */
+ static int vt596_transaction(u8 size)
+ {
+@@ -111,10 +135,9 @@
+ int result = 0;
+ int timeout = 0;
+
+- dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
+- "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
+- inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
+- inb_p(SMBHSTDAT1));
++#ifdef DEBUG
++ vt596_dump_regs("Transaction (pre)", size);
++#endif
+
+ /* Make sure the SMBus host is ready to start transmitting */
+ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+@@ -169,10 +192,9 @@
+ if (temp & 0x1F)
+ outb_p(temp, SMBHSTSTS);
+
+- dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
+- "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
+- inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
+- inb_p(SMBHSTDAT1));
++#ifdef DEBUG
++ vt596_dump_regs("Transaction (post)", size);
++#endif
+
+ return result;
+ }
diff --git a/i2c/i2c-viapro-08.patch b/i2c/i2c-viapro-08.patch
new file mode 100644
index 0000000000000..8d0d1606363d5
--- /dev/null
+++ b/i2c/i2c-viapro-08.patch
@@ -0,0 +1,47 @@
+From gregkh@suse.de Fri Sep 23 00:05:24 2005
+Date: Thu, 22 Sep 2005 22:23:32 +0200
+From: Greg KH <greg@kroah.com>
+To: Jean Delvare <khali@linux-fr.org>
+Subject: [PATCH] (7/8) i2c-viapro: Cleanup ifdef usage
+Message-Id: <20050922222332.000eaa7f.khali@linux-fr.org>
+
+It's not nice to put #ifdef in the middle of functions.
+
+CC: Jean Delvare <khali@linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+ drivers/i2c/busses/i2c-viapro.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+--- gregkh-2.6.orig/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:54:19.000000000 -0700
++++ gregkh-2.6/drivers/i2c/busses/i2c-viapro.c 2005-09-28 15:57:36.000000000 -0700
+@@ -126,6 +126,8 @@
+ printk("%02x\n", inb_p(SMBBLKDAT));
+ }
+ }
++#else
++static inline void vt596_dump_regs(const char *msg, u8 size) { }
+ #endif
+
+ /* Return -1 on error, 0 on success */
+@@ -135,9 +137,7 @@
+ int result = 0;
+ int timeout = 0;
+
+-#ifdef DEBUG
+ vt596_dump_regs("Transaction (pre)", size);
+-#endif
+
+ /* Make sure the SMBus host is ready to start transmitting */
+ if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
+@@ -192,9 +192,7 @@
+ if (temp & 0x1F)
+ outb_p(temp, SMBHSTSTS);
+
+-#ifdef DEBUG
+ vt596_dump_regs("Transaction (post)", size);
+-#endif
+
+ return result;
+ }