[U-Boot] [PATCH] 3/12 Multiadapter/multibus I2C, boards

ksi at koi8.net ksi at koi8.net
Thu Feb 12 23:15:26 CET 2009


Signed-off-by: Sergey Kubushyn <ksi at koi8.net>
---
diff -purN u-boot-i2c.orig/board/keymile/common/common.c u-boot-i2c/board/keymile/common/common.c
--- u-boot-i2c.orig/board/keymile/common/common.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/keymile/common/common.c	2009-02-12 10:46:00.000000000 -0800
@@ -35,11 +35,9 @@
 #include <libfdt.h>
 #endif
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 
-extern int i2c_soft_read_pin (void);
-
 int ivm_calc_crc (unsigned char *buf, int len)
 {
 	const unsigned short crc_tab[16] = {
@@ -295,32 +293,36 @@ int ivm_analyze_eeprom (unsigned char *b
 
 int ivm_read_eeprom (void)
 {
-	I2C_MUX_DEVICE *dev = NULL;
 	uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
+	uint	tmp = 0xffff;
+#if !defined(CONFIG_SYS_IVM_EEPROM_BUS_NUM) || !defined(CONFIG_SYS_IVM_EEPROM_ADR)
 	uchar	*buf;
-	unsigned dev_addr = CONFIG_SYS_IVM_EEPROM_ADR;
+#endif
 
 	/* First init the Bus, select the Bus */
-#if defined(CONFIG_SYS_I2C_IVM_BUS)
-	dev = i2c_mux_ident_muxstring ((uchar *)CONFIG_SYS_I2C_IVM_BUS);
+#if defined(CONFIG_SYS_IVM_EEPROM_BUS_NUM)
+	tmp = CONFIG_SYS_IVM_EEPROM_BUS_NUM;
 #else
-	buf = (unsigned char *) getenv ("EEprom_ivm");
+	buf = (unsigned char *) getenv ("EEprom_ivm_bus");
 	if (buf != NULL)
-		dev = i2c_mux_ident_muxstring (buf);
+		tmp = (uint)simple_strtoul((char *)buf, NULL, 16);
 #endif
-	if (dev == NULL) {
-		printf ("Error couldnt add Bus for IVM\n");
-		return -1;
+	if (i2c_set_bus_num(tmp)) {
+		printf ("Error couldnt set Bus (%x) for IVM\n", tmp);
+		return(-1);
 	}
-	i2c_set_bus_num (dev->busid);
 
-	buf = (unsigned char *) getenv ("EEprom_ivm_addr");
-	if (buf != NULL)
-		dev_addr = simple_strtoul ((char *)buf, NULL, 16);
+#if defined(CONFIG_SYS_IVM_EEPROM_ADR)
+		tmp = CONFIG_SYS_IVM_EEPROM_ADR;
+#else
+		buf = (unsigned char *) getenv ("EEprom_ivm_addr");
+		if (buf != NULL)
+			tmp = (uint)simple_strtoul((char *)buf, NULL, 16);
+#endif
 
-	if (eeprom_read (dev_addr, 0, i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN) != 0) {
-		printf ("Error reading EEprom\n");
-		return -2;
+	if (eeprom_read (tmp, 0, i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN) != 0) {
+		printf("Error reading EEprom\n");
+		return(-2);
 	}
 
 	return ivm_analyze_eeprom (i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
diff -purN u-boot-i2c.orig/board/keymile/mgcoge/mgcoge.c u-boot-i2c/board/keymile/mgcoge/mgcoge.c
--- u-boot-i2c.orig/board/keymile/mgcoge/mgcoge.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/keymile/mgcoge/mgcoge.c	2009-02-12 10:46:00.000000000 -0800
@@ -32,10 +32,6 @@
 #include <libfdt.h>
 #endif
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
-#include <i2c.h>
-#endif
-
 #include "../common/common.h"
 
 /*
diff -purN u-boot-i2c.orig/board/keymile/mgsuvd/mgsuvd.c u-boot-i2c/board/keymile/mgsuvd/mgsuvd.c
--- u-boot-i2c.orig/board/keymile/mgsuvd/mgsuvd.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/keymile/mgsuvd/mgsuvd.c	2009-02-12 10:46:00.000000000 -0800
@@ -195,14 +195,3 @@ void ft_board_setup(void *blob, bd_t *bd
 	ft_blob_update (blob, bd);
 }
 #endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
-
-int i2c_soft_read_pin (void)
-{
-	int val;
-
-	*(unsigned short *)(I2C_BASE_DIR) &=  ~SDA_CONF;
-	udelay(1);
-	val = *(unsigned char *)(I2C_BASE_PORT);
-
-	return ((val & SDA_BIT) == SDA_BIT);
-}
diff -purN u-boot-i2c.orig/board/lwmon/lwmon.c u-boot-i2c/board/lwmon/lwmon.c
--- u-boot-i2c.orig/board/lwmon/lwmon.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/lwmon/lwmon.c	2009-02-12 10:46:00.000000000 -0800
@@ -481,7 +481,7 @@ static void kbd_init (void)
 	uchar val, errcd;
 	int i;
 
-	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_init_all();
 
 	gd->kbd_status = 0;
 
diff -purN u-boot-i2c.orig/board/lwmon/pcmcia.c u-boot-i2c/board/lwmon/pcmcia.c
--- u-boot-i2c.orig/board/lwmon/pcmcia.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/lwmon/pcmcia.c	2009-02-12 10:46:00.000000000 -0800
@@ -108,7 +108,7 @@ int pcmcia_hardware_enable(int slot)
 
 	/*  switch VCC on */
 	val |= MAX1604_OP_SUS | MAX1604_VCCBON;
-	i2c_init  (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_init_all();
 	i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
 
 	udelay(500000);
@@ -199,7 +199,7 @@ int pcmcia_voltage_set(int slot, int vcc
 	 */
 	debug ("PCMCIA power OFF\n");
 	val  = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
-	i2c_init  (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	i2c_init_all();
 	i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
 
 	val = 0;
diff -purN u-boot-i2c.orig/board/omap2420h4/omap2420h4.c u-boot-i2c/board/omap2420h4/omap2420h4.c
--- u-boot-i2c.orig/board/omap2420h4/omap2420h4.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/omap2420h4/omap2420h4.c	2009-02-12 10:46:00.000000000 -0800
@@ -201,7 +201,11 @@ int dram_init (void)
 	u8 vmode_on = 0x8C;
 	#define NOT_EARLY 0
 
+#if defined(CONFIG_NEW_I2C)
+	i2c_init_all();
+#else
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); /* need this a bit early */
+#endif
 
 	btype = get_board_type();
 	mtype = get_mem_type();
diff -purN u-boot-i2c.orig/board/omap3/common/power.c u-boot-i2c/board/omap3/common/power.c
--- u-boot-i2c.orig/board/omap3/common/power.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/omap3/common/power.c	2009-02-12 10:46:00.000000000 -0800
@@ -41,8 +41,8 @@ void power_init_r(void)
 {
 	unsigned char byte;
 
-#ifdef CONFIG_DRIVER_OMAP34XX_I2C
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#ifdef CONFIG_OMAP24XX_I2C
+	i2c_init_all();
 #endif
 
 	/*
diff -purN u-boot-i2c.orig/board/omap3/evm/evm.c u-boot-i2c/board/omap3/evm/evm.c
--- u-boot-i2c.orig/board/omap3/evm/evm.c	2009-02-12 10:43:41.000000000 -0800
+++ u-boot-i2c/board/omap3/evm/evm.c	2009-02-12 10:46:00.000000000 -0800
@@ -60,8 +60,8 @@ int board_init(void)
 int misc_init_r(void)
 {
 
-#ifdef CONFIG_DRIVER_OMAP34XX_I2C
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#ifdef CONFIG_OMAP24XX_I2C
+	i2c_init_all();
 #endif
 
 #if defined(CONFIG_CMD_NET)


More information about the U-Boot mailing list