Skip to contentSkip to conversation

1/12 Multiadapter/multibus I2C, common part 1

PATCH New ksi at koi8.net 4 participants 9 messages Feb 12, 2009 – Feb 17, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

---

common/cmd_date.c +9 -0
diff -purN u-boot-i2c.orig/common/cmd_date.c u-boot-i2c/common/cmd_date.c
@@ -46,8 +46,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_NEW_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM);
+#endif
 
 	switch (argc) {
 	case 2:			/* set date & time */
@@ -94,7 +99,11 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	}
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_NEW_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return rcode;
 }
common/cmd_dtt.c +9 -0
diff -purN u-boot-i2c.orig/common/cmd_dtt.c u-boot-i2c/common/cmd_dtt.c
@@ -35,8 +35,13 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag,
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_NEW_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
+#endif
 
 	/*
 	 * Loop through sensors, read
@@ -46,7 +51,11 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag,
 		printf ("DTT%d: %i C\n", i + 1, dtt_get_temp (sensors[i]));
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_NEW_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return 0;
 }	/* do_dtt() */
common/cmd_i2c.c +69 -271

425 lines not on this page · raw message

common/devices.c +11 -1
diff -purN u-boot-i2c.orig/common/devices.c u-boot-i2c/common/devices.c
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Sergey Kubushyn <[email protected]>
+ *
+ * Changes for multibus/multiadapter I2C support.
+ *
  * (C) Copyright 2000
  * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio at tin.it
  *
@@ -30,7 +34,7 @@
 #ifdef CONFIG_LOGBUFFER
 #include <logbuff.h>
 #endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) || defined(CONFIG_SYS_I2C_ADAPTERS)
 #include <i2c.h>
 #endif
 
@@ -215,9 +219,15 @@ int devices_init (void)
 	/* Initialize the list */
 	INIT_LIST_HEAD(&(devs.list));
 
+#ifdef CONFIG_NEW_I2C
+#ifdef CONFIG_SYS_I2C_ADAPTERS
+	i2c_init_all();
+#endif
+#else
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
+#endif
 #ifdef CONFIG_LCD
 	drv_lcd_init ();
 #endif
drivers/hwmon/adm1021.c +4 -0
diff -purN u-boot-i2c.orig/drivers/hwmon/adm1021.c u-boot-i2c/drivers/hwmon/adm1021.c
@@ -174,7 +174,11 @@ dtt_init (void)
 	const char *const header = "DTT:   ";
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_NEW_I2C
+	i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
+#else
 	I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
+#endif
 
 	for (i = 0; i < sizeof(sensors); i++) {
 		if (_dtt_init(sensors[i]) != 0)
drivers/hwmon/lm75.c +9 -0
diff -purN u-boot-i2c.orig/drivers/hwmon/lm75.c u-boot-i2c/drivers/hwmon/lm75.c
@@ -156,8 +156,13 @@ int dtt_init (void)
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_NEW_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_DTT_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_DTT_BUS_NUM);
+#endif
 
 	for (i = 0; i < sizeof(sensors); i++) {
 	if (_dtt_init(sensors[i]) != 0)
@@ -167,7 +172,11 @@ int dtt_init (void)
 		dtt_get_temp(sensors[i]));
 	}
 	/* switch back to original I2C bus */
+#ifdef CONFIG_NEW_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif
 
 	return (0);
 } /* dtt_init() */
drivers/i2c/i2c_core.c +337 -0

337 lines not on this page · raw message

drivers/i2c/Makefile +5 -4
diff -purN u-boot-i2c.orig/drivers/i2c/Makefile u-boot-i2c/drivers/i2c/Makefile
@@ -27,12 +27,13 @@ LIB	:= $(obj)libi2c.a
 
 COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
-COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
-COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
-COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
-COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
+COBJS-$(CONFIG_MXC_I2C) += mxc_i2c.o
+COBJS-$(CONFIG_OMAP1510_I2C) += omap1510_i2c.o
+COBJS-$(CONFIG_OMAP24XX_I2C) += omap24xx_i2c.o
 COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
 COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
+COBJS-$(CONFIG_SM502_I2C) += sm502_i2c.o
+COBJS-$(CONFIG_NEW_I2C) += i2c_core.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
include/i2c.h +124 -112

296 lines not on this page · raw message

#1 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

Hello ksi,

Quoted 2 lines · ksi at koi8.net wrote:

Patch aplies with warnings:

Applying: 1/12 Multiadapter/multibus I2C, common part 1 /home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:630: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:688: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:765: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:808: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:1017: trailing whitespace.

        char            *name;

warning: 5 lines add whitespace errors.

please fix

bye
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
#2 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

Quoted 15 lines · Heiko Schocher

Hello ksi,

Quoted 2 lines · ksi at koi8.net wrote:

Patch aplies with warnings:

Applying: 1/12 Multiadapter/multibus I2C, common part 1 /home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:630: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:688: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:765: trailing whitespace.

Quoted 7 lines

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:808: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:1017: trailing whitespace.

        char            *name;

warning: 5 lines add whitespace errors.

please fix

Just do this instead always:

    git am -3 --whitespace=fix path/to.patch

jdl

#3 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

Hello Jon,

Quoted 21 lines · Jon Loeliger
Quoted 20 lines · Heiko Schocher

Hello ksi,

Quoted 2 lines · ksi at koi8.net wrote:

Patch aplies with warnings:

Applying: 1/12 Multiadapter/multibus I2C, common part 1 /home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:630: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:688: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:765: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:808: trailing whitespace.

/home/hs/i2c/u-boot-i2c/.git/rebase-apply/patch:1017: trailing whitespace.

        char            *name;

warning: 5 lines add whitespace errors.

Quoted 6 lines
Quoted 1 line

please fix

Just do this instead always:

    git am -3 --whitespace=fix path/to.patch

Ah, ok, thanks. Didn;t know this

bye
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#4 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

In reply to Jon Loeliger

Dear Jon,

Quoted 8 lines · In message <1234547485.25686.14.camel@ld0161-tx32> you wrote:
Quoted 4 lines

warning: 5 lines add whitespace errors.

please fix

Just do this instead always:

    git am -3 --whitespace=fix path/to.patch

Unfortunately this only works until onelater patche refers to one of the cleaned up lines.

Heikos request to the original poster to stick to the coding style requirements was perfectly reasonable.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The POP3 server service depends on the SMTP  server  service,  which
failed to start because of the following error: The operation comple-
ted successfully."                         -- Windows NT Server v3.51
#5 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

In reply to ksi at koi8.net

Dear ksi at koi8.net,

Quoted 20 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/common/cmd_date.c u-boot-i2c/common/cmd_date.c

common/cmd_date.c +5 -0
@@ -46,8 +46,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_NEW_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM);
+#endif
 
 	switch (argc) {
 	case 2:			/* set date & time */

common/cmd_date.c int do_date (cmd_tbl_t *cmdtp, int flag, · line 106

Quoted 8 lines
common/cmd_date.c +4 -0
@@ -94,7 +99,11 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	}
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_NEW_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif

Just a global note:

This makes no sense to me. If we assume that the new code works, then it will replace the old code. These #ifdef's make no sense.

We will probably hold this code in some testing branch (for a longer period of time to allow for extensive testing), but I don;t see the need to support both the old and the new code at the same time. This makes the code and your patches only more difficult to read.

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The manager will be continually amazed that policies he took for com-
mon knowledge are totally unknown by some member of his  team.  Since
his fundamental job is to keep everybody going in the same direction,
his chief daily task will be communication, not decision-making.
                              - Fred Brooks, "The Mythical Man Month"
#6 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

Quoted 34 lines · Wolfgang Denk

Dear ksi at koi8.net,

Quoted 20 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/common/cmd_date.c u-boot-i2c/common/cmd_date.c

common/cmd_date.c +5 -0
@@ -46,8 +46,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	int old_bus;
 
 	/* switch to correct I2C bus */
+#ifdef CONFIG_NEW_I2C
+	old_bus = i2c_get_bus_num();
+	i2c_set_bus_num(CONFIG_SYS_RTC_BUS_NUM);
+#else
 	old_bus = I2C_GET_BUS();
 	I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM);
+#endif
 
 	switch (argc) {
 	case 2:			/* set date & time */

common/cmd_date.c int do_date (cmd_tbl_t *cmdtp, int flag, · line 106

Quoted 8 lines
common/cmd_date.c +4 -0
@@ -94,7 +99,11 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	}
 
 	/* switch back to original I2C bus */
+#ifdef CONFIG_NEW_I2C
+	i2c_set_bus_num(old_bus);
+#else
 	I2C_SET_BUS(old_bus);
+#endif

Just a global note:

Quoted 7 lines

This makes no sense to me. If we assume that the new code works, then it will replace the old code. These #ifdef's make no sense.

We will probably hold this code in some testing branch (for a longer period of time to allow for extensive testing), but I don;t see the need to support both the old and the new code at the same time. This makes the code and your patches only more difficult to read.

I totally agree with you. That was done before a separate branch has been created so I tried to make something working in the main tree. The idea was make everything with that CONFIG_NEW_I2C first, one thing at a time and then, when everything was converted to the new format, remove all those stubs with a single patch.

You are totally right, it is not needed any more. I will rebase those patches and get rid of all old (legacy) code.

Ok, it's getting late here in Vegas so I will reply the rest of postings tomorrow when I'm back in the office.

I'm glad that there is interest in getting that I2C thing done...

---
******************************************************************
* KSI at home KOI8 Net < > The impossible we do immediately. *
* Las Vegas NV, USA < > Miracles require 24-hour notice. *
******************************************************************

#7 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

In reply to ksi at koi8.net

Dear ksi at koi8.net,

common/cmd_date.c int do_date (cmd_tbl_t *cmdtp, int flag, · line 46

Quoted 7 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/common/cmd_date.c u-boot-i2c/common/cmd_date.c

common/cmd_date.c +0 -0
@@ -46,8 +46,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	int old_bus;

One more global comment: can you please use git and especially git-format-patch to prepare your patches? For example, it is really helpful to see at a glance which files are affected by a patch.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I've seen it. It's rubbish."          - Marvin the Paranoid Android
#8 lore raw

PATCH 1/1 1/12 Multiadapter/multibus I2C, common part 1

Quoted 14 lines · Wolfgang Denk

Dear ksi at koi8.net,

common/cmd_date.c int do_date (cmd_tbl_t *cmdtp, int flag, · line 46

Quoted 7 lines · In message <[email protected]> you wrote:

---
diff -purN u-boot-i2c.orig/common/cmd_date.c u-boot-i2c/common/cmd_date.c

common/cmd_date.c +0 -0
@@ -46,8 +46,13 @@ int do_date (cmd_tbl_t *cmdtp, int flag,
 	int old_bus;

One more global comment: can you please use git and especially git-format-patch to prepare your patches? For example, it is really helpful to see at a glance which files are affected by a patch.

OK, I will.

---
******************************************************************
* KSI at home KOI8 Net < > The impossible we do immediately. *
* Las Vegas NV, USA < > Miracles require 24-hour notice. *
******************************************************************