]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/esd/cpci750/i2c.c
imported Freescale specific U-Boot additions for i.MX28,... release L2.6.31_10.08.01
[karo-tx-uboot.git] / board / esd / cpci750 / i2c.c
index 5b1bc01c21ebe0e037877a4af03712e859996323..b752903a146045b241b418b5403b60f1954652d5 100755 (executable)
@@ -27,6 +27,7 @@
 #include <common.h>
 #include <mpc8xx.h>
 #include <malloc.h>
+#include <i2c.h>
 #include "../../Marvell/include/mv_gen_reg.h"
 #include "../../Marvell/include/core.h"
 
 
 /* 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 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"));
@@ -375,16 +376,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_set_dev_offset (dev_addr, offset, 0, alen);        /* send the slave address + offset */
        if (status) {
@@ -423,16 +425,17 @@ void i2c_stop (void)
 }
 
 
-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_set_dev_offset (dev_addr, offset, 0, alen);        /* send the slave address + offset */
        if (status) {
@@ -464,11 +467,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_set_dev_offset (chip, 0, 0, 0);    /* send the slave address + no offset */
        if (status) {