forked from len0rd/rockbox
Renamed the ipod_i2c functions to the more appropriate pp_i2c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11361 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2c1eec5533
commit
77c915ad61
7 changed files with 41 additions and 41 deletions
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
#define POLL_TIMEOUT (HZ)
|
#define POLL_TIMEOUT (HZ)
|
||||||
|
|
||||||
static int ipod_i2c_wait_not_busy(void)
|
static int pp_i2c_wait_not_busy(void)
|
||||||
{
|
{
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
timeout = current_tick + POLL_TIMEOUT;
|
timeout = current_tick + POLL_TIMEOUT;
|
||||||
|
@ -66,9 +66,9 @@ static int ipod_i2c_wait_not_busy(void)
|
||||||
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
|
|
||||||
int ipod_i2c_read_byte(unsigned int addr, unsigned int *data)
|
int pp_i2c_read_byte(unsigned int addr, unsigned int *data)
|
||||||
{
|
{
|
||||||
if (ipod_i2c_wait_not_busy() < 0)
|
if (pp_i2c_wait_not_busy() < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ int ipod_i2c_read_byte(unsigned int addr, unsigned int *data)
|
||||||
|
|
||||||
outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
|
outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
|
||||||
|
|
||||||
if (ipod_i2c_wait_not_busy() < 0)
|
if (pp_i2c_wait_not_busy() < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ int ipod_i2c_read_byte(unsigned int addr, unsigned int *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipod_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data)
|
int pp_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data)
|
||||||
{
|
{
|
||||||
int data_addr;
|
int data_addr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -103,7 +103,7 @@ int ipod_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipod_i2c_wait_not_busy() < 0)
|
if (pp_i2c_wait_not_busy() < 0)
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -127,21 +127,21 @@ int ipod_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipod_i2c_send_byte(unsigned int addr, int data0)
|
int pp_i2c_send_byte(unsigned int addr, int data0)
|
||||||
{
|
{
|
||||||
unsigned char data[1];
|
unsigned char data[1];
|
||||||
|
|
||||||
data[0] = data0;
|
data[0] = data0;
|
||||||
|
|
||||||
return ipod_i2c_send_bytes(addr, 1, data);
|
return pp_i2c_send_bytes(addr, 1, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data) {
|
int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data) {
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
int i;
|
int i;
|
||||||
ipod_i2c_send_byte(dev_addr, addr);
|
pp_i2c_send_byte(dev_addr, addr);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ipod_i2c_read_byte(dev_addr, &temp);
|
pp_i2c_read_byte(dev_addr, &temp);
|
||||||
data[i] = temp;
|
data[i] = temp;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -151,20 +151,20 @@ int i2c_readbyte(unsigned int dev_addr, int addr)
|
||||||
{
|
{
|
||||||
int data;
|
int data;
|
||||||
|
|
||||||
ipod_i2c_send_byte(dev_addr, addr);
|
pp_i2c_send_byte(dev_addr, addr);
|
||||||
ipod_i2c_read_byte(dev_addr, &data);
|
pp_i2c_read_byte(dev_addr, &data);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipod_i2c_send(unsigned int addr, int data0, int data1)
|
int pp_i2c_send(unsigned int addr, int data0, int data1)
|
||||||
{
|
{
|
||||||
unsigned char data[2];
|
unsigned char data[2];
|
||||||
|
|
||||||
data[0] = data0;
|
data[0] = data0;
|
||||||
data[1] = data1;
|
data[1] = data1;
|
||||||
|
|
||||||
return ipod_i2c_send_bytes(addr, 2, data);
|
return pp_i2c_send_bytes(addr, 2, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2c_init(void)
|
void i2c_init(void)
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
#define POLL_TIMEOUT (HZ)
|
#define POLL_TIMEOUT (HZ)
|
||||||
|
|
||||||
static int ipod_i2c_wait_not_busy(void)
|
static int pp_i2c_wait_not_busy(void)
|
||||||
{
|
{
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
timeout = current_tick + POLL_TIMEOUT;
|
timeout = current_tick + POLL_TIMEOUT;
|
||||||
|
@ -63,9 +63,9 @@ static int ipod_i2c_wait_not_busy(void)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipod_i2c_read_byte(unsigned int addr, unsigned int *data)
|
static int pp_i2c_read_byte(unsigned int addr, unsigned int *data)
|
||||||
{
|
{
|
||||||
if (ipod_i2c_wait_not_busy() < 0)
|
if (pp_i2c_wait_not_busy() < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ static int ipod_i2c_read_byte(unsigned int addr, unsigned int *data)
|
||||||
outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
|
outb(inb(IPOD_I2C_CTRL) | IPOD_I2C_SEND, IPOD_I2C_CTRL);
|
||||||
|
|
||||||
set_irq_level(old_irq_level);
|
set_irq_level(old_irq_level);
|
||||||
if (ipod_i2c_wait_not_busy() < 0)
|
if (pp_i2c_wait_not_busy() < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ static int ipod_i2c_read_byte(unsigned int addr, unsigned int *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipod_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data)
|
static int pp_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned char *data)
|
||||||
{
|
{
|
||||||
int data_addr;
|
int data_addr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -109,7 +109,7 @@ static int ipod_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned cha
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipod_i2c_wait_not_busy() < 0)
|
if (pp_i2c_wait_not_busy() < 0)
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -139,13 +139,13 @@ static int ipod_i2c_send_bytes(unsigned int addr, unsigned int len, unsigned cha
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipod_i2c_send_byte(unsigned int addr, int data0)
|
static int pp_i2c_send_byte(unsigned int addr, int data0)
|
||||||
{
|
{
|
||||||
unsigned char data[1];
|
unsigned char data[1];
|
||||||
|
|
||||||
data[0] = data0;
|
data[0] = data0;
|
||||||
|
|
||||||
return ipod_i2c_send_bytes(addr, 1, data);
|
return pp_i2c_send_bytes(addr, 1, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
|
@ -155,9 +155,9 @@ int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data)
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
int i;
|
int i;
|
||||||
mutex_lock(&i2c_mutex);
|
mutex_lock(&i2c_mutex);
|
||||||
ipod_i2c_send_byte(dev_addr, addr);
|
pp_i2c_send_byte(dev_addr, addr);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ipod_i2c_read_byte(dev_addr, &temp);
|
pp_i2c_read_byte(dev_addr, &temp);
|
||||||
data[i] = temp;
|
data[i] = temp;
|
||||||
}
|
}
|
||||||
mutex_unlock(&i2c_mutex);
|
mutex_unlock(&i2c_mutex);
|
||||||
|
@ -169,14 +169,14 @@ int i2c_readbyte(unsigned int dev_addr, int addr)
|
||||||
int data;
|
int data;
|
||||||
|
|
||||||
mutex_lock(&i2c_mutex);
|
mutex_lock(&i2c_mutex);
|
||||||
ipod_i2c_send_byte(dev_addr, addr);
|
pp_i2c_send_byte(dev_addr, addr);
|
||||||
ipod_i2c_read_byte(dev_addr, &data);
|
pp_i2c_read_byte(dev_addr, &data);
|
||||||
mutex_unlock(&i2c_mutex);
|
mutex_unlock(&i2c_mutex);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipod_i2c_send(unsigned int addr, int data0, int data1)
|
int pp_i2c_send(unsigned int addr, int data0, int data1)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
unsigned char data[2];
|
unsigned char data[2];
|
||||||
|
@ -185,7 +185,7 @@ int ipod_i2c_send(unsigned int addr, int data0, int data1)
|
||||||
data[1] = data1;
|
data[1] = data1;
|
||||||
|
|
||||||
mutex_lock(&i2c_mutex);
|
mutex_lock(&i2c_mutex);
|
||||||
retval = ipod_i2c_send_bytes(addr, 2, data);
|
retval = pp_i2c_send_bytes(addr, 2, data);
|
||||||
mutex_unlock(&i2c_mutex);
|
mutex_unlock(&i2c_mutex);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -85,7 +85,7 @@ int pcf50605_read_multiple(int address, unsigned char* buf, int count)
|
||||||
|
|
||||||
int pcf50605_write(int address, unsigned char val)
|
int pcf50605_write(int address, unsigned char val)
|
||||||
{
|
{
|
||||||
ipod_i2c_send(0x8, address, val);
|
pp_i2c_send(0x8, address, val);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ int rtc_write_datetime(unsigned char* buf)
|
||||||
buf[4]=tmp;
|
buf[4]=tmp;
|
||||||
|
|
||||||
for (i=0;i<7;i++){
|
for (i=0;i<7;i++){
|
||||||
ipod_i2c_send(0x51, 0x02+i,buf[i]);
|
pp_i2c_send(0x51, 0x02+i,buf[i]);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
void i2c_init(void);
|
void i2c_init(void);
|
||||||
int i2c_readbyte(unsigned int dev_addr, int addr);
|
int i2c_readbyte(unsigned int dev_addr, int addr);
|
||||||
int ipod_i2c_send(unsigned int addr, int data0, int data1);
|
int pp_i2c_send(unsigned int addr, int data0, int data1);
|
||||||
int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data);
|
int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
void i2c_init(void);
|
void i2c_init(void);
|
||||||
int i2c_readbyte(unsigned int dev_addr, int addr);
|
int i2c_readbyte(unsigned int dev_addr, int addr);
|
||||||
int ipod_i2c_send(unsigned int addr, int data0, int data1);
|
int pp_i2c_send(unsigned int addr, int data0, int data1);
|
||||||
int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data);
|
int i2c_readbytes(unsigned int dev_addr, int addr, int len, unsigned char *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,6 +43,14 @@
|
||||||
#include "i2c-pp5002.h"
|
#include "i2c-pp5002.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
|
||||||
|
/* The H10's audio codec uses an I2C address of 0x1b */
|
||||||
|
#define I2C_AUDIO_ADDRESS 0x1b
|
||||||
|
#else
|
||||||
|
/* The iPod's audio codecs use an I2C address of 0x1a */
|
||||||
|
#define I2C_AUDIO_ADDRESS 0x1a
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
|
* Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
|
||||||
*/
|
*/
|
||||||
|
@ -144,13 +152,5 @@ int wmcodec_init(void) {
|
||||||
|
|
||||||
void wmcodec_write(int reg, int data)
|
void wmcodec_write(int reg, int data)
|
||||||
{
|
{
|
||||||
/* Todo: Since the ipod_i2c_* functions also work on H10 and possibly other PP
|
pp_i2c_send(I2C_AUDIO_ADDRESS, (reg<<1) | ((data&0x100)>>8),data&0xff);
|
||||||
targets, these functions should probably be renamed */
|
|
||||||
#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
|
|
||||||
/* The H10's audio codec uses an I2C address of 0x1b */
|
|
||||||
ipod_i2c_send(0x1b, (reg<<1) | ((data&0x100)>>8),data&0xff);
|
|
||||||
#else
|
|
||||||
/* The iPod's audio codecs use an I2C address of 0x1a */
|
|
||||||
ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue