X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=board%2FMarvell%2Fcommon%2Fi2c.c;h=8d87b2dd9a763d088e6b95d1c555f69c6347a01b;hb=40b161f6aea54104d0a5e477ff6a22338e8a7b4b;hp=32b2b30a4a23af30d0bec002502bbf9632e66cfc;hpb=8ad96012cd9e46b355ec63eb5a0155c92d8ca52c;p=karo-tx-uboot.git diff --git a/board/Marvell/common/i2c.c b/board/Marvell/common/i2c.c index 32b2b30a4a..8d87b2dd9a 100755 --- a/board/Marvell/common/i2c.c +++ b/board/Marvell/common/i2c.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "../include/mv_gen_reg.h" #include "../include/core.h" @@ -42,13 +43,13 @@ /* Assuming that there is only one master on the bus (us) */ -static void i2c_init (int speed, int slaveaddr) +void i2c_init (int speed, int slaveaddr) { unsigned int n, m, freq, margin, power; unsigned int actualN = 0, actualM = 0; unsigned int control, status; unsigned int minMargin = 0xffffffff; - unsigned int tclk = CFG_TCLK; + unsigned int tclk = CONFIG_SYS_TCLK; unsigned int i2cFreq = speed; /* 100000 max. Fast mode not supported */ DP (puts ("i2c_init\n")); @@ -367,16 +368,17 @@ i2c_set_dev_offset (uchar dev_addr, unsigned int offset, int ten_bit, return 0; /* sucessful completion */ } -uchar +int i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data, int len) { uchar status = 0; - unsigned int i2cFreq = CFG_I2C_SPEED; + unsigned int i2cFreq = CONFIG_SYS_I2C_SPEED; DP (puts ("i2c_read\n")); - i2c_init (i2cFreq, 0); /* set the i2c frequency */ + /* set the i2c frequency */ + i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE); status = i2c_start (); @@ -396,7 +398,8 @@ i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data, return status; } - i2c_init (i2cFreq, 0); /* set the i2c frequency again */ + /* set the i2c frequency again */ + i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE); status = i2c_start (); if (status) { @@ -442,16 +445,17 @@ void i2c_stop (void) /* */ /* returns 0 = succesful */ /* anything but zero is failure */ -uchar +int i2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data, int len) { uchar status = 0; - unsigned int i2cFreq = CFG_I2C_SPEED; + unsigned int i2cFreq = CONFIG_SYS_I2C_SPEED; DP (puts ("i2c_write\n")); - i2c_init (i2cFreq, 0); /* set the i2c frequency */ + /* set the i2c frequency */ + i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE); status = i2c_start (); /* send a start bit */ @@ -500,11 +504,12 @@ int i2c_probe (uchar chip) unsigned int i2c_status; #endif uchar status = 0; - unsigned int i2cFreq = CFG_I2C_SPEED; + unsigned int i2cFreq = CONFIG_SYS_I2C_SPEED; DP (puts ("i2c_probe\n")); - i2c_init (i2cFreq, 0); /* set the i2c frequency */ + /* set the i2c frequency */ + i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE); status = i2c_start (); /* send a start bit */