[U-Boot-Users] [PATCH] fix combination of CONFIG_I2C_CMD_TREE and CONFIG_SOFT_I2C

Andrew Dyer amdyer at gmail.com
Sun Feb 25 02:32:13 CET 2007


If CONFIG_I2C_CMD_TREE and CONFIG_SOFT_I2C are both enabled (and
CFG_CMD_I2C) compilation will fail with not being able to find
i2c_get_bus_speed().

This patch changes the code to return CFG_I2C_SPEED on an 'i2c speed'
command and an error message on setting the speed.

Signed-off-by: Andrew Dyer <amdyer at gmail.com>

-- 
Hardware, n.:
        The parts of a computer system that can be kicked.
-------------- next part --------------
Index: common/cmd_i2c.c
===================================================================
RCS file: /home/cvsroot/Projects/u-boot/common/cmd_i2c.c,v
retrieving revision 1.1.1.4
diff -p -u -r1.1.1.4 cmd_i2c.c
--- common/cmd_i2c.c	11 Dec 2006 17:17:33 -0000	1.1.1.4
+++ common/cmd_i2c.c	25 Feb 2007 01:04:55 -0000
@@ -901,13 +901,23 @@ int do_i2c_bus_speed(cmd_tbl_t * cmdtp, 
 {
 	int speed, ret=0;
 
-	if (argc == 1)
+	if (argc == 1) {
 		/* querying current speed */
-		printf("Current bus speed=%d\n", i2c_get_bus_speed());
-	else {
+#ifdef CONFIG_SOFT_I2C
+		speed = CFG_I2C_SPEED;
+#else
+		speed = i2c_get_bus_speed();
+#endif
+		printf("Current bus speed=%d\n", speed);
+	} else {
+#ifdef CONFIG_SOFT_I2C
+		printf("Setting bus speed is not supported for soft i2c\n");
+		ret = 1;
+#else
 		speed = simple_strtoul(argv[1], NULL, 10);
 		printf("Setting bus speed to %d Hz\n", speed);
 		ret = i2c_set_bus_speed(speed);
+#endif
 		if (ret)
 			printf("Failure changing bus speed (%d)\n", ret);
 	}


More information about the U-Boot mailing list