diff -u2 -r cvs/lm_sensors2/kernel/busses/i2c-i810.c patched/lm_sensors2/kernel/busses/i2c-i810.c --- cvs/lm_sensors2/kernel/busses/i2c-i810.c Sun Jul 7 17:45:14 2002 +++ patched/lm_sensors2/kernel/busses/i2c-i810.c Mon Jul 29 14:03:00 2002 @@ -112,4 +112,7 @@ static int __initdata i810i2c_initialized; static unsigned char *mem; +static unsigned short device; + +#define IS_I810E (device==0x7125) static inline void outlong(unsigned int dat, int off) @@ -135,7 +138,17 @@ static void bit_i810i2c_setsda(void *data, int val) { - outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK, - I810_GPIOB); - readlong(I810_GPIOB); /* flush posted write */ + if ( IS_I810E ) { + if (val) { + // Set output to 1 by config. the pin as input (assuming external pull up) + outlong(SDA_DIR_MASK,I810_GPIOB); + } else { + // Set output to 0 + outlong(SDA_DIR|SDA_DIR_MASK|SDA_VAL_MASK,I810_GPIOB); + } + } else { + outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK, + I810_GPIOB); + } + readlong(I810_GPIOB); /* flush posted write */ } @@ -148,7 +161,10 @@ i2c_algo_bit bit_test=1 to pass. */ +/* The method described above does not work with an i810e (at least not + * in my computer with a chrontel 7007 connected to the i2c bus). */ static int bit_i810i2c_getscl(void *data) { - outlong(0, I810_GPIOB); + if ( ! IS_I810E ) + outlong(0, I810_GPIOB); return (0 != (readlong(I810_GPIOB) & SCL_VAL_IN)); } @@ -156,5 +172,6 @@ static int bit_i810i2c_getsda(void *data) { - outlong(0, I810_GPIOB); + if (! IS_I810E ) + outlong(0, I810_GPIOB); return (0 != (readlong(I810_GPIOB) & SDA_VAL_IN)); } @@ -169,6 +186,16 @@ static void bit_i810ddc_setsda(void *data, int val) { - outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK, - I810_GPIOA); + if ( IS_I810E ) { + if (val) { + // Set output to 1 by config. the pin as input (assuming external pull up) + outlong(SDA_DIR_MASK,I810_GPIOA); + } else { + // Set output to 0 + outlong(SDA_DIR|SDA_DIR_MASK|SDA_VAL_MASK,I810_GPIOA); + } + } else { + outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK, + I810_GPIOA); + } readlong(I810_GPIOA); /* flush posted write */ } @@ -176,5 +203,6 @@ static int bit_i810ddc_getscl(void *data) { - outlong(0, I810_GPIOA); + if (! IS_I810E ) + outlong(0, I810_GPIOA); return (0 != (readlong(I810_GPIOA) & SCL_VAL_IN)); } @@ -182,5 +210,6 @@ static int bit_i810ddc_getsda(void *data) { - outlong(0, I810_GPIOA); + if (! IS_I810E ) + outlong(0, I810_GPIOA); return (0 != (readlong(I810_GPIOA) & SDA_VAL_IN)); } @@ -247,4 +276,5 @@ bit_i810ddc_setsda(NULL, 1); } + device=dev->device; } @@ -286,4 +316,5 @@ printk("i2c-i810.o version %s (%s)\n", LM_VERSION, LM_DATE); + device=0; i810i2c_initialized = 0; if ((res = i810i2c_setup())) {