summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sparmann <theseven@rockbox.org>2009-10-10 16:36:55 +0000
committerMichael Sparmann <theseven@rockbox.org>2009-10-10 16:36:55 +0000
commit6be1d8b8a8d966d3c4669ce6ba0b535a9b3e6a1c (patch)
treeb287a88ff9bfb93eb746d76cc1069c59b4a9c7c7
parent72271af7df5158d516305ea647789b543b805078 (diff)
downloadrockbox-6be1d8b8a8d966d3c4669ce6ba0b535a9b3e6a1c.zip
rockbox-6be1d8b8a8d966d3c4669ce6ba0b535a9b3e6a1c.tar.gz
rockbox-6be1d8b8a8d966d3c4669ce6ba0b535a9b3e6a1c.tar.bz2
rockbox-6be1d8b8a8d966d3c4669ce6ba0b535a9b3e6a1c.tar.xz
Revert the S5L870X I2C driver to busy waiting because of some issues with interrupts, and increase the bus speed from 24kHz to 390kHz.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23074 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/s5l8700/i2c-s5l8700.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/firmware/target/arm/s5l8700/i2c-s5l8700.c b/firmware/target/arm/s5l8700/i2c-s5l8700.c
index 5b55334..8b0879b 100644
--- a/firmware/target/arm/s5l8700/i2c-s5l8700.c
+++ b/firmware/target/arm/s5l8700/i2c-s5l8700.c
@@ -40,20 +40,10 @@
*/
static struct mutex i2c_mtx;
-static struct wakeup i2c_wakeup;
-
-void INT_IIC(void)
-{
- /* disable interrupt (but don't clear it yet) */
- IICCON &= ~((1 << 4) | (1 << 5));
-
- wakeup_signal(&i2c_wakeup);
-}
void i2c_init(void)
{
mutex_init(&i2c_mtx);
- wakeup_init(&i2c_wakeup);
/* enable I2C pins */
PCON10 = (2 << 2) |
@@ -65,10 +55,10 @@ void i2c_init(void)
/* initial config */
IICADD = 0;
IICCON = (1 << 7) | /* ACK_GEN */
- (1 << 6) | /* CLKSEL = PCLK/512 */
+ (0 << 6) | /* CLKSEL = PCLK/16 */
(1 << 5) | /* INT_EN */
(1 << 4) | /* IRQ clear */
- (3 << 0); /* CK_REG */
+ (7 << 0); /* CK_REG */
/* serial output on */
IICSTAT = (1 << 4);
@@ -84,26 +74,26 @@ int i2c_write(unsigned char slave, int address, int len, const unsigned char *da
/* START */
IICDS = slave & ~1;
IICSTAT = 0xF0;
- IICCON = 0xF3;
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = 0xB7;
+ while ((IICCON & 0x10) == 0);
if (address >= 0) {
/* write address */
IICDS = address;
- IICCON = 0xF3;
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = 0xB7;
+ while ((IICCON & 0x10) == 0);
}
/* write data */
while (len--) {
IICDS = *data++;
- IICCON = 0xF3;
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = 0xB7;
+ while ((IICCON & 0x10) == 0);
}
/* STOP */
IICSTAT = 0xD0;
- IICCON = 0xF3;
+ IICCON = 0xB7;
while ((IICSTAT & (1 << 5)) != 0);
mutex_unlock(&i2c_mtx);
@@ -118,30 +108,30 @@ int i2c_read(unsigned char slave, int address, int len, unsigned char *data)
/* START */
IICDS = slave & ~1;
IICSTAT = 0xF0;
- IICCON = 0xF3;
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = 0xB7;
+ while ((IICCON & 0x10) == 0);
/* write address */
IICDS = address;
- IICCON = 0xF3;
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = 0xB7;
+ while ((IICCON & 0x10) == 0);
}
/* (repeated) START */
IICDS = slave | 1;
IICSTAT = 0xB0;
- IICCON = 0xF3;
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = 0xB7;
+ while ((IICCON & 0x10) == 0);
while (len--) {
- IICCON = (len == 0) ? 0x73 : 0xF3; /* NACK or ACK */
- while ((IICCON & 0x10) == 0) wakeup_wait(&i2c_wakeup, 1);
+ IICCON = (len == 0) ? 0x37 : 0xB7; /* NACK or ACK */
+ while ((IICCON & 0x10) == 0);
*data++ = IICDS;
}
/* STOP */
IICSTAT = 0x90;
- IICCON = 0xF3;
+ IICCON = 0xB7;
while ((IICSTAT & (1 << 5)) != 0);
mutex_unlock(&i2c_mtx);