diff options
Diffstat (limited to 'arch/cris/arch-v10/drivers/i2c.c')
-rw-r--r-- | arch/cris/arch-v10/drivers/i2c.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c index a8737a8eb229..77a941813819 100644 --- a/arch/cris/arch-v10/drivers/i2c.c +++ b/arch/cris/arch-v10/drivers/i2c.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/smp_lock.h> | ||
18 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/fs.h> | 19 | #include <linux/fs.h> |
@@ -60,8 +59,8 @@ static const char i2c_name[] = "i2c"; | |||
60 | 59 | ||
61 | #define SDABIT CONFIG_ETRAX_I2C_DATA_PORT | 60 | #define SDABIT CONFIG_ETRAX_I2C_DATA_PORT |
62 | #define SCLBIT CONFIG_ETRAX_I2C_CLK_PORT | 61 | #define SCLBIT CONFIG_ETRAX_I2C_CLK_PORT |
63 | #define i2c_enable() | 62 | #define i2c_enable() |
64 | #define i2c_disable() | 63 | #define i2c_disable() |
65 | 64 | ||
66 | /* enable or disable output-enable, to select output or input on the i2c bus */ | 65 | /* enable or disable output-enable, to select output or input on the i2c bus */ |
67 | 66 | ||
@@ -91,7 +90,7 @@ static const char i2c_name[] = "i2c"; | |||
91 | 90 | ||
92 | #define i2c_dir_out() \ | 91 | #define i2c_dir_out() \ |
93 | *R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ | 92 | *R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ |
94 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1); | 93 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1); |
95 | #define i2c_dir_in() \ | 94 | #define i2c_dir_in() \ |
96 | *R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ | 95 | *R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ |
97 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 0); | 96 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 0); |
@@ -189,7 +188,7 @@ i2c_outbyte(unsigned char x) | |||
189 | } else { | 188 | } else { |
190 | i2c_data(I2C_DATA_LOW); | 189 | i2c_data(I2C_DATA_LOW); |
191 | } | 190 | } |
192 | 191 | ||
193 | i2c_delay(CLOCK_LOW_TIME/2); | 192 | i2c_delay(CLOCK_LOW_TIME/2); |
194 | i2c_clk(I2C_CLOCK_HIGH); | 193 | i2c_clk(I2C_CLOCK_HIGH); |
195 | i2c_delay(CLOCK_HIGH_TIME); | 194 | i2c_delay(CLOCK_HIGH_TIME); |
@@ -416,7 +415,7 @@ i2c_sendnack(void) | |||
416 | *# | 415 | *# |
417 | *#--------------------------------------------------------------------------*/ | 416 | *#--------------------------------------------------------------------------*/ |
418 | int | 417 | int |
419 | i2c_writereg(unsigned char theSlave, unsigned char theReg, | 418 | i2c_writereg(unsigned char theSlave, unsigned char theReg, |
420 | unsigned char theValue) | 419 | unsigned char theValue) |
421 | { | 420 | { |
422 | int error, cntr = 3; | 421 | int error, cntr = 3; |
@@ -468,7 +467,7 @@ i2c_writereg(unsigned char theSlave, unsigned char theReg, | |||
468 | * enable interrupt again | 467 | * enable interrupt again |
469 | */ | 468 | */ |
470 | local_irq_restore(flags); | 469 | local_irq_restore(flags); |
471 | 470 | ||
472 | } while(error && cntr--); | 471 | } while(error && cntr--); |
473 | 472 | ||
474 | i2c_delay(CLOCK_LOW_TIME); | 473 | i2c_delay(CLOCK_LOW_TIME); |
@@ -504,7 +503,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
504 | * generate start condition | 503 | * generate start condition |
505 | */ | 504 | */ |
506 | i2c_start(); | 505 | i2c_start(); |
507 | 506 | ||
508 | /* | 507 | /* |
509 | * send slave address | 508 | * send slave address |
510 | */ | 509 | */ |
@@ -555,7 +554,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
555 | * enable interrupt again | 554 | * enable interrupt again |
556 | */ | 555 | */ |
557 | local_irq_restore(flags); | 556 | local_irq_restore(flags); |
558 | 557 | ||
559 | } while(error && cntr--); | 558 | } while(error && cntr--); |
560 | 559 | ||
561 | spin_unlock(&i2c_lock); | 560 | spin_unlock(&i2c_lock); |
@@ -566,7 +565,6 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
566 | static int | 565 | static int |
567 | i2c_open(struct inode *inode, struct file *filp) | 566 | i2c_open(struct inode *inode, struct file *filp) |
568 | { | 567 | { |
569 | cycle_kernel_lock(); | ||
570 | return 0; | 568 | return 0; |
571 | } | 569 | } |
572 | 570 | ||
@@ -579,9 +577,7 @@ i2c_release(struct inode *inode, struct file *filp) | |||
579 | /* Main device API. ioctl's to write or read to/from i2c registers. | 577 | /* Main device API. ioctl's to write or read to/from i2c registers. |
580 | */ | 578 | */ |
581 | 579 | ||
582 | static int | 580 | static long i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
583 | i2c_ioctl(struct inode *inode, struct file *file, | ||
584 | unsigned int cmd, unsigned long arg) | ||
585 | { | 581 | { |
586 | if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { | 582 | if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { |
587 | return -EINVAL; | 583 | return -EINVAL; |
@@ -590,7 +586,7 @@ i2c_ioctl(struct inode *inode, struct file *file, | |||
590 | switch (_IOC_NR(cmd)) { | 586 | switch (_IOC_NR(cmd)) { |
591 | case I2C_WRITEREG: | 587 | case I2C_WRITEREG: |
592 | /* write to an i2c slave */ | 588 | /* write to an i2c slave */ |
593 | D(printk("i2cw %d %d %d\n", | 589 | D(printk(KERN_DEBUG "i2cw %d %d %d\n", |
594 | I2C_ARGSLAVE(arg), | 590 | I2C_ARGSLAVE(arg), |
595 | I2C_ARGREG(arg), | 591 | I2C_ARGREG(arg), |
596 | I2C_ARGVALUE(arg))); | 592 | I2C_ARGVALUE(arg))); |
@@ -602,26 +598,25 @@ i2c_ioctl(struct inode *inode, struct file *file, | |||
602 | { | 598 | { |
603 | unsigned char val; | 599 | unsigned char val; |
604 | /* read from an i2c slave */ | 600 | /* read from an i2c slave */ |
605 | D(printk("i2cr %d %d ", | 601 | D(printk(KERN_DEBUG "i2cr %d %d ", |
606 | I2C_ARGSLAVE(arg), | 602 | I2C_ARGSLAVE(arg), |
607 | I2C_ARGREG(arg))); | 603 | I2C_ARGREG(arg))); |
608 | val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); | 604 | val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); |
609 | D(printk("= %d\n", val)); | 605 | D(printk(KERN_DEBUG "= %d\n", val)); |
610 | return val; | 606 | return val; |
611 | } | 607 | } |
612 | default: | 608 | default: |
613 | return -EINVAL; | 609 | return -EINVAL; |
614 | 610 | ||
615 | } | 611 | } |
616 | |||
617 | return 0; | 612 | return 0; |
618 | } | 613 | } |
619 | 614 | ||
620 | static const struct file_operations i2c_fops = { | 615 | static const struct file_operations i2c_fops = { |
621 | .owner = THIS_MODULE, | 616 | .owner = THIS_MODULE, |
622 | .ioctl = i2c_ioctl, | 617 | .unlocked_ioctl = i2c_ioctl, |
623 | .open = i2c_open, | 618 | .open = i2c_open, |
624 | .release = i2c_release, | 619 | .release = i2c_release, |
625 | }; | 620 | }; |
626 | 621 | ||
627 | int __init | 622 | int __init |