From ec53bfa1fe4ed8bcfd423fab66bda0022f84471f Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sat, 2 Dec 2000 22:39:21 +0000 Subject: [PATCH] (mds) Add "dummy writes" before bit reads as recommended in 815 programmers' reference guide. This ensures that the input value is latched in the 815 register. We assume this also applies to the 810 or at least does no harm. Ticket 419. Alan Chen reports that this fixes the bug where i2c-algo-bit bit_test=1 fails the test. We don't have any data that shows there was any problem in normal operation (non bit_test) or that this fixes anything else. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@941 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + kernel/busses/i2c-i810.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 8071b113..0972c474 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,7 @@ ask CVS about it: Module ddcmon: allow force and force_ddcmon parameters Module ds1621: new Module i2c-ali1535: Enhance error checking and recovery; add mutex + Module i2c-i810: Add "dummy write" before reads per Intel prog. ref. Module lm87: update voltage calculations Module mtp008: new Module pcf8574: change update time to 5 seconds diff --git a/kernel/busses/i2c-i810.c b/kernel/busses/i2c-i810.c index e9ff8645..bf6b3c1d 100644 --- a/kernel/busses/i2c-i810.c +++ b/kernel/busses/i2c-i810.c @@ -133,15 +133,21 @@ static void bit_i810i2c_setsda(void *data, int val) /* The GPIO pins are open drain, so the pins always remain outputs. We rely on the i2c-algo-bit routines to set the pins high before - reading the input from other chips. */ + reading the input from other chips. Following guidance in the 815 + prog. ref. guide, we do a "dummy write" of 0 to the register before + reading which forces the input value to be latched. We presume this + applies to the 810 as well. This is necessary to get + i2c_algo_bit bit_test=1 to pass. */ static int bit_i810i2c_getscl(void *data) { + outlong(0, I810_GPIOB); return (0 != (readlong(I810_GPIOB) & SCL_VAL_IN)); } static int bit_i810i2c_getsda(void *data) { + outlong(0, I810_GPIOB); return (0 != (readlong(I810_GPIOB) & SDA_VAL_IN)); } @@ -159,11 +165,13 @@ static void bit_i810ddc_setsda(void *data, int val) static int bit_i810ddc_getscl(void *data) { + outlong(0, I810_GPIOA); return (0 != (readlong(I810_GPIOA) & SCL_VAL_IN)); } static int bit_i810ddc_getsda(void *data) { + outlong(0, I810_GPIOA); return (0 != (readlong(I810_GPIOA) & SDA_VAL_IN)); }