From c54c35572a30da2fa028c1dc045facac4ee5640a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 26 Mar 2012 21:47:18 +0200 Subject: i2c-gpio: Use linux/gpio.h rather than asm/gpio.h Direct inclusion of asm/gpio.h has been deprecated for a while now due to the cross platform gpiolib. Signed-off-by: Mark Brown Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index a651779d9ff..69fbfaedc03 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -14,8 +14,7 @@ #include #include #include - -#include +#include /* Toggle SDA by changing the direction of the pin */ static void i2c_gpio_setsda_dir(void *data, int state) -- cgit v1.2.3 From b3240e68c05deef2df28db9fc0eea4c277f76494 Mon Sep 17 00:00:00 2001 From: Olivier Sobrie Date: Mon, 26 Mar 2012 21:47:18 +0200 Subject: i2c-isch: Decrease delay in command completion check loop Generally it is not needed to wait for 1 msec, the SMBus get often ready in less than 200 usecs. msleep(1) can wait up to 20 msecs... It has a significant impact when there is a burst of transactions on the bus. Signed-off-by: Olivier Sobrie Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-isch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index 6561d275b8c..f90a6057508 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -47,7 +47,7 @@ #define SMBBLKDAT (0x20 + sch_smba) /* Other settings */ -#define MAX_TIMEOUT 500 +#define MAX_RETRIES 5000 /* I2C constants */ #define SCH_QUICK 0x00 @@ -68,7 +68,7 @@ static int sch_transaction(void) { int temp; int result = 0; - int timeout = 0; + int retries = 0; dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT), @@ -100,12 +100,12 @@ static int sch_transaction(void) outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT); do { - msleep(1); + usleep_range(100, 200); temp = inb(SMBHSTSTS) & 0x0f; - } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT)); + } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); /* If the SMBus is still busy, we give up */ - if (timeout > MAX_TIMEOUT) { + if (retries > MAX_RETRIES) { dev_err(&sch_adapter.dev, "SMBus Timeout!\n"); result = -ETIMEDOUT; } -- cgit v1.2.3 From 062737fb6d90c632439b1f77ad6a4965cfc84a20 Mon Sep 17 00:00:00 2001 From: Seth Heasley Date: Mon, 26 Mar 2012 21:47:19 +0200 Subject: i2c-i801: Add device IDs for Intel Lynx Point Add the SMBus controller device IDs for the Intel Lynx Point PCH. Signed-off-by: Seth Heasley Signed-off-by: Jean Delvare --- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-i801.c | 3 +++ 2 files changed, 4 insertions(+) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 71c1b0a7535..d2c5095deea 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -103,6 +103,7 @@ config I2C_I801 Patsburg (PCH) DH89xxCC (PCH) Panther Point (PCH) + Lynx Point (PCH) This driver can also be built as a module. If so, the module will be called i2c-i801. diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 5d2e2816831..07d0c9565fc 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -51,6 +51,7 @@ Patsburg (PCH) IDF 0x1d72 32 hard yes yes yes DH89xxCC (PCH) 0x2330 32 hard yes yes yes Panther Point (PCH) 0x1e22 32 hard yes yes yes + Lynx Point (PCH) 0x8c22 32 hard yes yes yes Features supported by this driver: Software PEC no @@ -145,6 +146,7 @@ #define PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS 0x1e22 #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 +#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 struct i801_priv { struct i2c_adapter adapter; @@ -633,6 +635,7 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids) = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) }, { 0, } }; -- cgit v1.2.3 From 84c1af4c21d645a02a4780cdf61c7551d8e7bb56 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 26 Mar 2012 21:47:19 +0200 Subject: i2c-i801: Use usleep_range to wait for command completion Use usleep_range instead of msleep when waiting for command completion. Most SMBus commands complete in less than 2 jiffies so this brings a pleasant performance boost. Strongly inspired from a similar change by Olivier Sobrie to the i2c-isch driver. Signed-off-by: Jean Delvare Cc: Olivier Sobrie --- drivers/i2c/busses/i2c-i801.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 07d0c9565fc..ae2945a5e00 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -2,7 +2,7 @@ Copyright (c) 1998 - 2002 Frodo Looijaard , Philip Edelbrock , and Mark D. Studebaker - Copyright (C) 2007, 2008 Jean Delvare + Copyright (C) 2007 - 2012 Jean Delvare Copyright (C) 2010 Intel Corporation, David Woodhouse @@ -106,7 +106,7 @@ #define SMBHSTCNT_KILL 2 /* Other settings */ -#define MAX_TIMEOUT 100 +#define MAX_RETRIES 400 #define ENABLE_INT9 0 /* set to 0x01 to enable - untested */ /* I801 command constants */ @@ -217,7 +217,7 @@ static int i801_check_post(struct i801_priv *priv, int status, int timeout) dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, SMBHSTCNT(priv)); - msleep(1); + usleep_range(1000, 2000); outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), SMBHSTCNT(priv)); @@ -274,11 +274,11 @@ static int i801_transaction(struct i801_priv *priv, int xact) /* We will always wait for a fraction of a second! */ do { - msleep(1); + usleep_range(250, 500); status = inb_p(SMBHSTSTS(priv)); - } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT)); + } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES)); - result = i801_check_post(priv, status, timeout > MAX_TIMEOUT); + result = i801_check_post(priv, status, timeout > MAX_RETRIES); if (result < 0) return result; @@ -293,12 +293,12 @@ static void i801_wait_hwpec(struct i801_priv *priv) int status; do { - msleep(1); + usleep_range(250, 500); status = inb_p(SMBHSTSTS(priv)); } while ((!(status & SMBHSTSTS_INTR)) - && (timeout++ < MAX_TIMEOUT)); + && (timeout++ < MAX_RETRIES)); - if (timeout > MAX_TIMEOUT) + if (timeout > MAX_RETRIES) dev_dbg(&priv->pci_dev->dev, "PEC Timeout!\n"); outb_p(status, SMBHSTSTS(priv)); @@ -382,12 +382,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, /* We will always wait for a fraction of a second! */ timeout = 0; do { - msleep(1); + usleep_range(250, 500); status = inb_p(SMBHSTSTS(priv)); } while ((!(status & SMBHSTSTS_BYTE_DONE)) - && (timeout++ < MAX_TIMEOUT)); + && (timeout++ < MAX_RETRIES)); - result = i801_check_post(priv, status, timeout > MAX_TIMEOUT); + result = i801_check_post(priv, status, timeout > MAX_RETRIES); if (result < 0) return result; -- cgit v1.2.3 From de05497aab22b515ff02988634eab59848410a25 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 26 Mar 2012 21:47:19 +0200 Subject: i2c: Convert drivers/i2c/muxes/* to use module_i2c_driver() This patch converts the drivers in drivers/i2c/muxes/* to use the module_i2c_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin Acked-by: Wolfram Sang Cc: Guenter Roeck Cc: Michael Lawnick Cc: Ben Dooks Signed-off-by: Jean Delvare --- drivers/i2c/muxes/pca9541.c | 13 +------------ drivers/i2c/muxes/pca954x.c | 13 +------------ 2 files changed, 2 insertions(+), 24 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/muxes/pca9541.c b/drivers/i2c/muxes/pca9541.c index ed699c5aa79..e0df9b6c66b 100644 --- a/drivers/i2c/muxes/pca9541.c +++ b/drivers/i2c/muxes/pca9541.c @@ -393,18 +393,7 @@ static struct i2c_driver pca9541_driver = { .id_table = pca9541_id, }; -static int __init pca9541_init(void) -{ - return i2c_add_driver(&pca9541_driver); -} - -static void __exit pca9541_exit(void) -{ - i2c_del_driver(&pca9541_driver); -} - -module_init(pca9541_init); -module_exit(pca9541_exit); +module_i2c_driver(pca9541_driver); MODULE_AUTHOR("Guenter Roeck "); MODULE_DESCRIPTION("PCA9541 I2C master selector driver"); diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c index 6f895366463..0e37ef27aa1 100644 --- a/drivers/i2c/muxes/pca954x.c +++ b/drivers/i2c/muxes/pca954x.c @@ -284,18 +284,7 @@ static struct i2c_driver pca954x_driver = { .id_table = pca954x_id, }; -static int __init pca954x_init(void) -{ - return i2c_add_driver(&pca954x_driver); -} - -static void __exit pca954x_exit(void) -{ - i2c_del_driver(&pca954x_driver); -} - -module_init(pca954x_init); -module_exit(pca954x_exit); +module_i2c_driver(pca954x_driver); MODULE_AUTHOR("Rodolfo Giometti "); MODULE_DESCRIPTION("PCA954x I2C mux/switch driver"); -- cgit v1.2.3 From 5694f8a888f8f69a562e4cf939eed81ca7a5ecf2 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 26 Mar 2012 21:47:19 +0200 Subject: i2c: Update the FSF address Signed-off-by: Jean Delvare --- drivers/i2c/algos/i2c-algo-bit.c | 3 ++- drivers/i2c/algos/i2c-algo-pca.c | 3 ++- drivers/i2c/algos/i2c-algo-pcf.c | 3 ++- drivers/i2c/algos/i2c-algo-pcf.h | 3 ++- drivers/i2c/i2c-boardinfo.c | 3 ++- drivers/i2c/i2c-core.c | 3 ++- drivers/i2c/i2c-core.h | 3 ++- drivers/i2c/i2c-dev.c | 3 ++- drivers/i2c/i2c-smbus.c | 3 ++- 9 files changed, 18 insertions(+), 9 deletions(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index acba1c686c6..69902c8e3b1 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -15,7 +15,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301 USA. * ------------------------------------------------------------------------- */ /* With some changes from Frodo Looijaard , Kyösti Mälkki diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index beb9ffe2564..73133b1063f 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -15,7 +15,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA. */ #include diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 5eebf562ff3..5c2379522aa 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c @@ -16,7 +16,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA. * * With some changes from Kyösti Mälkki and * Frodo Looijaard , and also from Martin Bailey diff --git a/drivers/i2c/algos/i2c-algo-pcf.h b/drivers/i2c/algos/i2c-algo-pcf.h index 5263a9eeb8d..1ec703ee788 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.h +++ b/drivers/i2c/algos/i2c-algo-pcf.h @@ -16,7 +16,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301 USA. */ /* -------------------------------------------------------------------- */ /* With some changes from Frodo Looijaard */ diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c index 10274ffb66d..f24cc64e2e8 100644 --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c @@ -13,7 +13,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA. */ #include diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index e9c18939eda..feb7dc35918 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -14,7 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301 USA. */ /* ------------------------------------------------------------------------- */ /* With some changes from Kyösti Mälkki . diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 9f9c57ff670..18a8fd21d2c 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -13,7 +13,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA. */ #include diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 10e7f1e7658..45048323b75 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -17,7 +17,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301 USA. */ /* Note that this is a complete rewrite of Simon Vogl's i2c-dev module. diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index f61ccc1e5ea..9836d08f7a7 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -16,7 +16,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA. */ #include -- cgit v1.2.3 From 41101a33026c215a09e5d3549aedfcdae9105515 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 26 Mar 2012 21:47:19 +0200 Subject: i2c-algo-bit: Don't resched on clock stretching Clock stretching is not supposed to last long, so asking to be rescheduled while waiting for the clock line to be released by a slave makes little sense. Odds are that the clock line will long have been released when we run again, so we will have lost time and may even get an SMBus timeout because of this. So just busy-wait in that case. This also participates in the effort to make i2c-algo-bit usable in contexts that can't sleep. Signed-off-by: Jean Delvare Cc: Ben Skeggs --- drivers/i2c/algos/i2c-algo-bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/i2c') diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 69902c8e3b1..7f0b8321974 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -112,7 +112,7 @@ static int sclhi(struct i2c_algo_bit_data *adap) break; return -ETIMEDOUT; } - cond_resched(); + cpu_relax(); } #ifdef DEBUG if (jiffies != start && i2c_debug >= 3) -- cgit v1.2.3