README.scrapyard: update commit IDs
[platform/kernel/u-boot.git] / board / Marvell / common / i2c.c
index d426044..abdde86 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  *
  * Hacked for the DB64360 board by Ingo.Assmus@keymile.com
  * extra improvments by Brain Waite
@@ -26,6 +10,7 @@
 #include <common.h>
 #include <mpc8xx.h>
 #include <malloc.h>
+#include <i2c.h>
 #include "../include/mv_gen_reg.h"
 #include "../include/core.h"
 
@@ -42,7 +27,7 @@
 
 /* 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;
@@ -367,7 +352,7 @@ 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)
 {
@@ -376,7 +361,8 @@ i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data,
 
        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 +382,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) {
@@ -417,7 +404,7 @@ i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data,
        status = i2c_get_data (data, len);
        if (status) {
 #ifdef DEBUG_I2C
-               printf ("Data not recieved: 0x%02x\n", status);
+               printf ("Data not received: 0x%02x\n", status);
 #endif
                return status;
        }
@@ -442,7 +429,7 @@ 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)
 {
@@ -451,7 +438,8 @@ i2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data,
 
        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 */
 
@@ -504,7 +492,8 @@ int i2c_probe (uchar chip)
 
        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 */