summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2007-01-27 15:20:30 +0000
committerBarry Wardell <rockbox@barrywardell.net>2007-01-27 15:20:30 +0000
commitadc349891e03c6288f1434351b2cd640356580e3 (patch)
treebedba03165e88e40156a7f2a089fc12dc0ece8d1 /firmware
parent5e765b2ea2962b86c460a67968d4977f3aa55ca3 (diff)
downloadrockbox-adc349891e03c6288f1434351b2cd640356580e3.tar.gz
rockbox-adc349891e03c6288f1434351b2cd640356580e3.tar.bz2
rockbox-adc349891e03c6288f1434351b2cd640356580e3.zip
Clean up PP5002 I2C code (no functional changes):
Move into target tree. Use #defines instead of inb/outb. Also restore comments in PP5020 I2C code. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12124 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/export/i2c-pp5002.h11
-rw-r--r--firmware/export/pp5002.h3
-rw-r--r--firmware/target/arm/i2c-pp5002.c (renamed from firmware/drivers/i2c-pp5002.c)47
-rw-r--r--firmware/target/arm/i2c-pp5020.c6
5 files changed, 31 insertions, 38 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index e393dc1678..00fbc74b67 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -257,7 +257,7 @@ target/arm/memset16-arm.S
#if CONFIG_I2C == I2C_PP5020
target/arm/i2c-pp5020.c
#elif CONFIG_I2C == I2C_PP5002
-drivers/i2c-pp5002.c
+target/arm/i2c-pp5002.c
#elif CONFIG_I2C == I2C_PNX0101
drivers/i2c-pnx0101.c
#elif CONFIG_I2C == I2C_S3C2440
diff --git a/firmware/export/i2c-pp5002.h b/firmware/export/i2c-pp5002.h
index 68c0dda8f7..58324035a5 100644
--- a/firmware/export/i2c-pp5002.h
+++ b/firmware/export/i2c-pp5002.h
@@ -25,6 +25,17 @@
#ifndef _I2C_PP5002_H
#define _I2C_PP5002_H
+#define I2C_CTRL (*(volatile unsigned char*)(I2C_BASE+0x00))
+#define I2C_ADDR (*(volatile unsigned char*)(I2C_BASE+0x04))
+#define I2C_DATA(X) (*(volatile unsigned char*)(I2C_BASE+0xc+(4*X)))
+#define I2C_STATUS (*(volatile unsigned char*)(I2C_BASE+0x1c))
+
+/* I2C_CTRL bit definitions */
+#define I2C_SEND 0x80
+
+/* I2C_STATUS bit definitions */
+#define I2C_BUSY (1<<6)
+
/* TODO: Fully implement i2c driver */
void i2c_init(void);
diff --git a/firmware/export/pp5002.h b/firmware/export/pp5002.h
index b1bc6f4d01..41e8f4cce2 100644
--- a/firmware/export/pp5002.h
+++ b/firmware/export/pp5002.h
@@ -59,6 +59,7 @@
#define DEV_RS (*(volatile unsigned long *)( 0xcf005030))
#define DEV_EN (*(volatile unsigned long *)( 0xcf005000))
+#define DEV_I2C (1<<8)
#define DEV_USB 0x400000
#define DEV_INIT (*(volatile unsigned long *)(0x70000020))
@@ -78,6 +79,8 @@
#define IISFIFO_WR (*(volatile unsigned long*)(0xc0002540))
#define IISFIFO_RD (*(volatile unsigned long*)(0xc0002580))
+#define I2C_BASE 0xc0008000
+
#define TIMER1_CFG (*(volatile unsigned long *)(0xcf001100))
#define TIMER1_VAL (*(volatile unsigned long *)(0xcf001104))
#define TIMER2_CFG (*(volatile unsigned long *)(0xcf001108))
diff --git a/firmware/drivers/i2c-pp5002.c b/firmware/target/arm/i2c-pp5002.c
index 7cb37f6090..ad6d50721d 100644
--- a/firmware/drivers/i2c-pp5002.c
+++ b/firmware/target/arm/i2c-pp5002.c
@@ -32,21 +32,6 @@
/* Local functions definitions */
-#define IPOD_I2C_BASE 0xc0008000
-#define IPOD_I2C_CTRL (IPOD_I2C_BASE+0x00)
-#define IPOD_I2C_ADDR (IPOD_I2C_BASE+0x04)
-#define IPOD_I2C_DATA0 (IPOD_I2C_BASE+0x0c)
-#define IPOD_I2C_DATA1 (IPOD_I2C_BASE+0x10)
-#define IPOD_I2C_DATA2 (IPOD_I2C_BASE+0x14)
-#define IPOD_I2C_DATA3 (IPOD_I2C_BASE+0x18)
-#define IPOD_I2C_STATUS (IPOD_I2C_BASE+0x1c)
-
-/* IPOD_I2C_CTRL bit definitions */
-#define IPOD_I2C_SEND 0x80
-
-/* IPOD_I2C_STATUS bit definitions */
-#define IPOD_I2C_BUSY (1<<6)
-
#define POLL_TIMEOUT (HZ)
static int pp_i2c_wait_not_busy(void)
@@ -54,7 +39,7 @@ static int pp_i2c_wait_not_busy(void)
unsigned long timeout;
timeout = current_tick + POLL_TIMEOUT;
while (TIME_BEFORE(current_tick, timeout)) {
- if (!(inb(IPOD_I2C_STATUS) & IPOD_I2C_BUSY)) {
+ if (!(I2C_STATUS & I2C_BUSY)) {
return 0;
}
yield();
@@ -74,11 +59,11 @@ int pp_i2c_read_byte(unsigned int addr, unsigned int *data)
}
/* clear top 15 bits, left shift 1, or in 0x1 for a read */
- outb(((addr << 17) >> 16) | 0x1, IPOD_I2C_ADDR);
+ I2C_ADDR = ((addr << 17) >> 16) | 0x1 ;
- outb(inb(IPOD_I2C_CTRL) | 0x20, IPOD_I2C_CTRL);
+ I2C_CTRL |= 0x20;
- outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
+ I2C_CTRL |= I2C_SEND;
if (pp_i2c_wait_not_busy() < 0)
{
@@ -87,7 +72,7 @@ int pp_i2c_read_byte(unsigned int addr, unsigned int *data)
if (data)
{
- *data = inb(IPOD_I2C_DATA0);
+ *data = I2C_DATA(0);
}
return 0;
@@ -95,7 +80,6 @@ int pp_i2c_read_byte(unsigned int addr, unsigned int *data)
int pp_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data)
{
- int data_addr;
unsigned int i;
if (len < 1 || len > 4)
@@ -109,20 +93,18 @@ int pp_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data)
}
/* clear top 15 bits, left shift 1 */
- outb((addr << 17) >> 16, IPOD_I2C_ADDR);
+ I2C_ADDR = (addr << 17) >> 16;
- outb(inb(IPOD_I2C_CTRL) & ~0x20, IPOD_I2C_CTRL);
+ I2C_CTRL &= ~0x20;
- data_addr = IPOD_I2C_DATA0;
for ( i = 0; i < len; i++ )
{
- outb(*data++, data_addr);
- data_addr += 4;
+ I2C_DATA(i) = *data++;
}
- outb((inb(IPOD_I2C_CTRL) & ~0x26) | ((len-1) << 1), IPOD_I2C_CTRL);
+ I2C_CTRL = (I2C_CTRL & ~0x26) | ((len-1) << 1);
- outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
+ I2C_CTRL |= I2C_SEND;
return 0x0;
}
@@ -169,10 +151,7 @@ int pp_i2c_send(unsigned int addr, int data0, int data1)
void i2c_init(void)
{
- /* From ipodlinux */
-
- outl(inl(0xcf005000) | 0x2, 0xcf005000);
-
- outl(inl(0xcf005030) | (1<<8), 0xcf005030);
- outl(inl(0xcf005030) & ~(1<<8), 0xcf005030);
+ DEV_EN |= 0x2; /* Enable I2C-should this be DEV_I2C rather than 0x2? */
+ DEV_RS |= DEV_I2C; /* Start I2C Reset */
+ DEV_RS &=~DEV_I2C; /* End I2C Reset */
}
diff --git a/firmware/target/arm/i2c-pp5020.c b/firmware/target/arm/i2c-pp5020.c
index 95a677ea01..ebd0318f0b 100644
--- a/firmware/target/arm/i2c-pp5020.c
+++ b/firmware/target/arm/i2c-pp5020.c
@@ -185,9 +185,9 @@ void i2c_init(void)
GPIOC_ENABLE &= ~0x20;
#endif
- DEV_EN |= DEV_I2C;
- DEV_RS |= DEV_I2C;
- DEV_RS &=~DEV_I2C;
+ DEV_EN |= DEV_I2C; /* Enable I2C */
+ DEV_RS |= DEV_I2C; /* Start I2C Reset */
+ DEV_RS &=~DEV_I2C; /* End I2C Reset */
outl(0x0, 0x600060a4);
outl(0x80 | (0 << 8), 0x600060a4);