Subversion Repositories Kolibri OS

Rev

Rev 4104 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4104 Rev 5271
Line 10... Line 10...
10
 
10
 
11
    This program is distributed in the hope that it will be useful,
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
-
 
15
 
-
 
16
    You should have received a copy of the GNU General Public License
-
 
17
    along with this program; if not, write to the Free Software
-
 
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-
 
19
    MA 02110-1301 USA.
14
    GNU General Public License for more details.
Line 20... Line 15...
20
 * ------------------------------------------------------------------------- */
15
 * ------------------------------------------------------------------------- */
21
 
16
 
Line 22... Line -...
22
/* With some changes from Frodo Looijaard , Kyösti Mälkki
-
 
23
    and Jean Delvare  */
-
 
24
 
17
/* With some changes from Frodo Looijaard , Kyösti Mälkki
25
#include 
18
    and Jean Delvare  */
26
#include 
19
 
27
#include 
20
#include 
28
#include 
21
#include 
29
#include 
22
#include 
30
#include 
23
#include 
-
 
24
#include 
Line 31... Line 25...
31
#include 
25
#include 
Line 32... Line 26...
32
#include 
26
#include 
Line 47... Line 41...
47
	do {} while (0)
41
	do {} while (0)
48
#endif /* DEBUG */
42
#endif /* DEBUG */
Line 49... Line 43...
49
 
43
 
Line 50... Line 44...
50
/* ----- global variables ---------------------------------------------	*/
44
/* ----- global variables ---------------------------------------------	*/
-
 
45
 
Line 51... Line 46...
51
 
46
static int bit_test;	/* see if the line-setting functions work	*/
52
static int bit_test = 0;   /* see if the line-setting functions work   */
47
MODULE_PARM_DESC(bit_test, "lines testing - 0 off; 1 report; 2 fail if stuck");
53
 
-
 
54
#ifdef DEBUG
48
 
55
static int i2c_debug = 1;
49
#ifdef DEBUG
56
module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
50
static int i2c_debug = 1;
Line 57... Line 51...
57
MODULE_PARM_DESC(i2c_debug,
51
MODULE_PARM_DESC(i2c_debug,
Line 95... Line 89...
95
 
89
 
96
	/* Not all adapters have scl sense line... */
90
	/* Not all adapters have scl sense line... */
97
	if (!adap->getscl)
91
	if (!adap->getscl)
Line 98... Line 92...
98
		goto done;
92
		goto done;
99
 
93
 
100
    start = GetTimerTicks();
94
	start = jiffies;
101
	while (!getscl(adap)) {
95
	while (!getscl(adap)) {
102
		/* This hw knows how to read the clock line, so we wait
96
		/* This hw knows how to read the clock line, so we wait
103
		 * until it actually gets high.  This is safer as some
97
		 * until it actually gets high.  This is safer as some
104
		 * chips may hold it low ("clock stretching") while they
98
		 * chips may hold it low ("clock stretching") while they
105
		 * are processing data internally.
99
		 * are processing data internally.
106
		 */
100
		 */
107
		if (time_after(GetTimerTicks(), start + adap->timeout)) {
101
		if (time_after(jiffies, start + adap->timeout)) {
108
			/* Test one last time, as we may have been preempted
102
			/* Test one last time, as we may have been preempted
109
			 * between last check and timeout test.
103
			 * between last check and timeout test.
110
			 */
104
			 */
111
			if (getscl(adap))
105
			if (getscl(adap))
112
				break;
106
				break;
113
           return -ETIMEDOUT;
107
           return -ETIMEDOUT;
114
		}
108
		}
-
 
109
		cpu_relax();
-
 
110
    }
-
 
111
#ifdef DEBUG
-
 
112
	if (jiffies != start && i2c_debug >= 3)
-
 
113
		pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go "
-
 
114
			 "high\n", jiffies - start);
115
		asm volatile("rep; nop" ::: "memory");
115
#endif
116
    }
116
 
117
done:
117
done:
118
	udelay(adap->udelay);
118
	udelay(adap->udelay);
Line 648... Line 648...
648
{
648
{
649
	return __i2c_bit_add_bus(adap, NULL);
649
	return __i2c_bit_add_bus(adap, NULL);
650
}
650
}
Line -... Line 651...
-
 
651
 
-
 
652
 
-
 
653
MODULE_AUTHOR("Simon G. Vogl ");