28 #include <linux/module.h>
29 #include <linux/sched.h>
30 #include <linux/errno.h>
31 #include <linux/kernel.h>
33 #include <linux/string.h>
40 #include <asm/delay.h>
50 static const char i2c_name[] =
"i2c";
52 #define CLOCK_LOW_TIME 8
53 #define CLOCK_HIGH_TIME 8
54 #define START_CONDITION_HOLD_TIME 8
55 #define STOP_CONDITION_HOLD_TIME 8
56 #define ENABLE_OUTPUT 0x01
57 #define ENABLE_INPUT 0x00
58 #define I2C_CLOCK_HIGH 1
59 #define I2C_CLOCK_LOW 0
60 #define I2C_DATA_HIGH 1
61 #define I2C_DATA_LOW 0
68 #define i2c_dir_out() crisv32_io_set_dir(&cris_i2c_data, crisv32_io_dir_out)
69 #define i2c_dir_in() crisv32_io_set_dir(&cris_i2c_data, crisv32_io_dir_in)
73 #define i2c_clk(x) crisv32_io_set(&cris_i2c_clk, x)
74 #define i2c_data(x) crisv32_io_set(&cris_i2c_data, x)
78 #define i2c_getbit() crisv32_io_rd(&cris_i2c_data)
80 #define i2c_delay(usecs) udelay(usecs)
153 for (i = 0; i < 8; i++) {
181 unsigned char aBitByte = 0;
196 for (i = 1; i < 8; i++) {
394 unsigned char bytes_wrote = 0;
416 for (bytes_wrote = 0; bytes_wrote <
nbytes; bytes_wrote++) {
417 memcpy(&value, data + bytes_wrote,
sizeof value);
430 }
while (error && cntr--);
434 spin_unlock_irqrestore(&i2c_lock, flags);
450 unsigned char bytes_read = 0;
475 for (bytes_read = 0; bytes_read <
nbytes; bytes_read++) {
477 memcpy(data + bytes_read, &b,
sizeof b);
479 if (bytes_read < (nbytes - 1))
491 }
while (error && cntr--);
493 spin_unlock_irqrestore(&i2c_lock, flags);
507 unsigned char theValue)
550 }
while(error && cntr--);
554 spin_unlock_irqrestore(&i2c_lock, flags);
629 }
while(error && cntr--);
631 spin_unlock_irqrestore(&i2c_lock, flags);
697 .unlocked_ioctl = i2c_ioctl,
699 .release = i2c_release,
706 static int first = 1;
716 CONFIG_ETRAX_V32_I2C_DATA_PORT);
727 static int __init i2c_register(
void)
737 res = register_chrdev(
I2C_MAJOR, i2c_name, &i2c_fops);
744 "I2C driver v2.2, (c) 1999-2007 Axis Communications AB\n");