[U-Boot-Users] [PATCH] 6/9: i2c_init_board

Robert Schwebel robert at schwebel.de
Thu Mar 6 13:35:27 CET 2003


I2C_INIT_BOARD
==============

- introduced a new i2c_init_board() function, to be implemented by the
  board maintainers for boards that support it.

Robert
-- 
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Braunschweiger Str. 79,  31134 Hildesheim, Germany
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
    Phone: +49-5121-28619-0 |  Fax: +49-5121-28619-4
-------------- next part --------------
diff -urN -x CVS -x ptx-patches -x logfile -x logfile1 u-boot/README u-boot-ptx/README
--- u-boot/README	2003-03-06 08:41:17.000000000 +0100
+++ u-boot-ptx/README	2003-03-06 09:21:57.000000000 +0100
@@ -897,6 +897,16 @@
 		controls the rate of data transfer.  The data rate thus
 		is 1 / (I2C_DELAY * 4).
 
+		CFG_I2C_INIT_BOARD
+
+		When a board is resetted during an i2c bus transfer chips
+		might think that the current transfer is still in progress. 
+		On some boards it is possible to access the i2c SCLK line
+		directly, either by using the processor pin as a GPIO or 
+		by having a second pin connected to the bus. If this option
+		is defined a custom i2c_coldstart() routine in 
+		boards/xxx/board.c is run early in the boot sequence. 
+
 - SPI Support:	CONFIG_SPI
 
 
diff -urN -x CVS -x ptx-patches -x logfile -x logfile1 u-boot/cpu/mpc8260/i2c.c u-boot-ptx/cpu/mpc8260/i2c.c
--- u-boot/cpu/mpc8260/i2c.c	2002-11-03 01:31:58.000000000 +0100
+++ u-boot-ptx/cpu/mpc8260/i2c.c	2003-03-06 10:41:59.000000000 +0100
@@ -221,6 +221,13 @@
 	volatile I2C_BD *rxbd, *txbd;
 	uint dpaddr;
 
+#ifdef CFG_I2C_INIT_BOARD        
+	/* call board specific i2c bus reset routine before accessing the   */
+	/* environment, which might be in a chip on that bus. For details   */
+	/* about this problem see doc/I2C_Edge_Conditions.                  */
+	i2c_init_board();
+#endif
+
 	dpaddr = *((unsigned short*)(&immap->im_dprambase[PROFF_I2C_BASE]));
 	if (dpaddr == 0) {
 	    /* need to allocate dual port ram */
diff -urN -x CVS -x ptx-patches -x logfile -x logfile1 u-boot/cpu/mpc8xx/i2c.c u-boot-ptx/cpu/mpc8xx/i2c.c
--- u-boot/cpu/mpc8xx/i2c.c	2002-10-02 22:40:41.000000000 +0200
+++ u-boot-ptx/cpu/mpc8xx/i2c.c	2003-03-06 10:42:46.000000000 +0100
@@ -215,6 +215,13 @@
 	volatile I2C_BD *rxbd, *txbd;
 	uint dpaddr;
 
+#ifdef CFG_I2C_INIT_BOARD        
+	/* call board specific i2c bus reset routine before accessing the   */
+	/* environment, which might be in a chip on that bus. For details   */
+	/* about this problem see doc/I2C_Edge_Conditions.                  */
+	i2c_init_board();
+#endif
+
 #ifdef CFG_I2C_UCODE_PATCH
 	iip = (iic_t *)&cp->cp_dpmem[iip->iic_rpbase];
 #else
diff -urN -x CVS -x ptx-patches -x logfile -x logfile1 u-boot/cpu/ppc4xx/i2c.c u-boot-ptx/cpu/ppc4xx/i2c.c
--- u-boot/cpu/ppc4xx/i2c.c	2002-11-03 01:32:03.000000000 +0100
+++ u-boot-ptx/cpu/ppc4xx/i2c.c	2003-03-06 10:43:54.000000000 +0100
@@ -85,7 +85,15 @@
 	unsigned long freqOPB;
 	int val, divisor;
 
+#ifdef CFG_I2C_INIT_BOARD        
+	/* call board specific i2c bus reset routine before accessing the   */
+	/* environment, which might be in a chip on that bus. For details   */
+	/* about this problem see doc/I2C_Edge_Conditions.                  */
+	i2c_init_board();
+#endif
+
 	/* Handle possible failed I2C state */
+	/* FIXME: put this into i2c_init_board()? */
 	_i2c_bus_reset ();
 
 	/* clear lo master address */
diff -urN -x CVS -x ptx-patches -x logfile -x logfile1 u-boot/cpu/xscale/i2c.c u-boot-ptx/cpu/xscale/i2c.c
--- u-boot/cpu/xscale/i2c.c	2003-03-06 01:02:09.000000000 +0100
+++ u-boot-ptx/cpu/xscale/i2c.c	2003-03-06 10:44:30.000000000 +0100
@@ -41,6 +41,7 @@
  *	- I2C_PXA_SLAVE_ADDR 
  */
 
+#include <asm/arch/hardware.h>
 #include <asm/arch/pxa-regs.h>
 #include <i2c.h>
 
@@ -244,6 +245,12 @@
 
 void i2c_init(int speed, int slaveaddr)
 {
+#ifdef CFG_I2C_INIT_BOARD        
+	/* call board specific i2c bus reset routine before accessing the   */
+	/* environment, which might be in a chip on that bus. For details   */
+	/* about this problem see doc/I2C_Edge_Conditions.                  */
+	i2c_init_board();
+#endif
 }
 
 


More information about the U-Boot mailing list