All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands
@ 2009-04-24 20:34 Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 1/5] i2c.h: Provide a default CONFIG_SYS_I2C_SLAVE value Peter Tyser
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Peter Tyser @ 2009-04-24 20:34 UTC (permalink / raw)
  To: u-boot

Hi Heiko,
These 5 patches should clean up the compile issues that you noticed
after application of the "[PATCH v2 0/7] Remove individual I2C commands
and cleanup" series.

I only have a build environment for powerpc boards so it'd be much
appreciated if other architectures could do some basic compile
testing after the "Remove individual I2C commands and cleanup"
series is applied to the i2c repository.

Assuming these patches are accepted, the original "v2 Remove individual
I2C commands and cleanup" series should then be applied.

Thanks,
Peter

Peter Tyser (5):
  i2c.h: Provide a default CONFIG_SYS_I2C_SLAVE value
  cpci750: i2c cleanup
  Marvell: i2c cleanup
  mpc7448hpc2: Add CONFIG_SYS_I2C_SPEED define
  tsi108_i2c: Add i2c_init() stub function

 board/Marvell/common/i2c.c    |   19 ++++++++++++-------
 board/esd/cpci750/i2c.c       |   16 ++++++++++------
 common/cmd_eeprom.c           |    4 ----
 cpu/mpc8260/i2c.c             |    3 ---
 cpu/ppc4xx/40x_spd_sdram.c    |    4 ----
 cpu/ppc4xx/44x_spd_ddr.c      |    4 ----
 drivers/i2c/tsi108_i2c.c      |    9 +++++++++
 include/configs/mpc7448hpc2.h |    1 +
 include/i2c.h                 |   12 +++++++++---
 9 files changed, 41 insertions(+), 31 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/5] i2c.h: Provide a default CONFIG_SYS_I2C_SLAVE value
  2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
@ 2009-04-24 20:34 ` Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 2/5] cpci750: i2c cleanup Peter Tyser
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Tyser @ 2009-04-24 20:34 UTC (permalink / raw)
  To: u-boot

Many boards/controllers/drivers don't support an I2C slave interface,
however CONFIG_SYS_I2C_SLAVE is used in common code so provide a
default

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 common/cmd_eeprom.c        |    4 ----
 cpu/mpc8260/i2c.c          |    3 ---
 cpu/ppc4xx/40x_spd_sdram.c |    4 ----
 cpu/ppc4xx/44x_spd_ddr.c   |    4 ----
 include/i2c.h              |   12 +++++++++---
 5 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index e598bf1..f749087 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -401,10 +401,6 @@ eeprom_probe (unsigned dev_addr, unsigned offset)
 #define	CONFIG_SYS_I2C_SPEED	50000
 #endif
 
-#ifndef	CONFIG_SYS_I2C_SLAVE
-#define	CONFIG_SYS_I2C_SLAVE	0xFE
-#endif
-
 void eeprom_init  (void)
 {
 #if defined(CONFIG_SPI)
diff --git a/cpu/mpc8260/i2c.c b/cpu/mpc8260/i2c.c
index 35cf8f1..2b954b4 100644
--- a/cpu/mpc8260/i2c.c
+++ b/cpu/mpc8260/i2c.c
@@ -58,9 +58,6 @@ static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
 #define	CONFIG_SYS_I2C_SPEED	50000
 #endif
 
-#ifndef	CONFIG_SYS_I2C_SLAVE
-#define	CONFIG_SYS_I2C_SLAVE	0xFE
-#endif
 /*-----------------------------------------------------------------------
  */
 
diff --git a/cpu/ppc4xx/40x_spd_sdram.c b/cpu/ppc4xx/40x_spd_sdram.c
index 57861b3..75bd70d 100644
--- a/cpu/ppc4xx/40x_spd_sdram.c
+++ b/cpu/ppc4xx/40x_spd_sdram.c
@@ -56,10 +56,6 @@
 #define CONFIG_SYS_I2C_SPEED	50000
 #endif
 
-#ifndef CONFIG_SYS_I2C_SLAVE
-#define CONFIG_SYS_I2C_SLAVE	0xFE
-#endif
-
 #define ONE_BILLION	1000000000
 
 #define	 SDRAM0_CFG_DCE		0x80000000
diff --git a/cpu/ppc4xx/44x_spd_ddr.c b/cpu/ppc4xx/44x_spd_ddr.c
index 153391e..f26fcda 100644
--- a/cpu/ppc4xx/44x_spd_ddr.c
+++ b/cpu/ppc4xx/44x_spd_ddr.c
@@ -66,10 +66,6 @@
 #define CONFIG_SYS_I2C_SPEED	50000
 #endif
 
-#ifndef CONFIG_SYS_I2C_SLAVE
-#define CONFIG_SYS_I2C_SLAVE	0xFE
-#endif
-
 #define ONE_BILLION	1000000000
 
 /*
diff --git a/include/i2c.h b/include/i2c.h
index f8a59a6..668e754 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -78,16 +78,22 @@
 #endif
 
 #ifdef CONFIG_8xx
-/* Set default values for the I2C bus speed and slave address on 8xx. In the
+/* Set default value for the I2C bus speed on 8xx. In the
  * future, we'll define these in all 8xx board config files.
  */
 #ifndef	CONFIG_SYS_I2C_SPEED
 #define	CONFIG_SYS_I2C_SPEED	50000
 #endif
+#endif
 
+/*
+ * Many boards/controllers/drivers don't support an I2C slave interface so
+ * provide a default slave address for them for use in common code.  A real
+ * value for CONFIG_SYS_I2C_SLAVE should be defined for any board which does
+ * support a slave interface.
+ */
 #ifndef	CONFIG_SYS_I2C_SLAVE
-#define	CONFIG_SYS_I2C_SLAVE	0xFE
-#endif
+#define	CONFIG_SYS_I2C_SLAVE	0xfe
 #endif
 
 /*
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/5] cpci750: i2c cleanup
  2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 1/5] i2c.h: Provide a default CONFIG_SYS_I2C_SLAVE value Peter Tyser
@ 2009-04-24 20:34 ` Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 3/5] Marvell: " Peter Tyser
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Tyser @ 2009-04-24 20:34 UTC (permalink / raw)
  To: u-boot

The following changes were made, primarily to bring the cpci750 i2c
driver in line with U-Boot's current I2C API:
- Made i2c_init() globally accessible
- Made i2c_read() and i2c_write() return an integer
- Updated i2c_init() calls to pass in CONFIG_SYS_I2C_SLAVE in the
  offhand chance someone adds slave support in the future

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 board/esd/cpci750/i2c.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/board/esd/cpci750/i2c.c b/board/esd/cpci750/i2c.c
index d95567f..b752903 100644
--- a/board/esd/cpci750/i2c.c
+++ b/board/esd/cpci750/i2c.c
@@ -27,6 +27,7 @@
 #include <common.h>
 #include <mpc8xx.h>
 #include <malloc.h>
+#include <i2c.h>
 #include "../../Marvell/include/mv_gen_reg.h"
 #include "../../Marvell/include/core.h"
 
@@ -41,7 +42,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;
@@ -375,7 +376,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)
 {
@@ -384,7 +385,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_set_dev_offset (dev_addr, offset, 0, alen);	/* send the slave address + offset */
 	if (status) {
@@ -423,7 +425,7 @@ void i2c_stop (void)
 }
 
 
-uchar
+int
 i2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data,
 	   int len)
 {
@@ -432,7 +434,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_set_dev_offset (dev_addr, offset, 0, alen);	/* send the slave address + offset */
 	if (status) {
@@ -468,7 +471,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_set_dev_offset (chip, 0, 0, 0);	/* send the slave address + no offset */
 	if (status) {
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 3/5] Marvell: i2c cleanup
  2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 1/5] i2c.h: Provide a default CONFIG_SYS_I2C_SLAVE value Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 2/5] cpci750: i2c cleanup Peter Tyser
@ 2009-04-24 20:34 ` Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 4/5] mpc7448hpc2: Add CONFIG_SYS_I2C_SPEED define Peter Tyser
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Tyser @ 2009-04-24 20:34 UTC (permalink / raw)
  To: u-boot

The following changes were made, primarily to bring the Marvell i2c
driver in line with U-Boot's current I2C API:
- Made i2c_init() globally accessible
- Made i2c_read() and i2c_write() return an integer
- Updated i2c_init() calls to pass in CONFIG_SYS_I2C_SLAVE in the
  offhand chance someone adds slave support in the future

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 board/Marvell/common/i2c.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/board/Marvell/common/i2c.c b/board/Marvell/common/i2c.c
index d426044..8d87b2d 100644
--- a/board/Marvell/common/i2c.c
+++ b/board/Marvell/common/i2c.c
@@ -26,6 +26,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 +43,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 +368,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 +377,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 +398,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) {
@@ -442,7 +445,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 +454,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 +508,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 */
 
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 4/5] mpc7448hpc2: Add CONFIG_SYS_I2C_SPEED define
  2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
                   ` (2 preceding siblings ...)
  2009-04-24 20:34 ` [U-Boot] [PATCH 3/5] Marvell: " Peter Tyser
@ 2009-04-24 20:34 ` Peter Tyser
  2009-04-24 20:34 ` [U-Boot] [PATCH 5/5] tsi108_i2c: Add i2c_init() stub function Peter Tyser
  2009-04-27  7:22 ` [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Heiko Schocher
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Tyser @ 2009-04-24 20:34 UTC (permalink / raw)
  To: u-boot

Add standard CONFIG_SYS_I2C_SPEED define for the mpc7448hpc2 so that
it can use the common 'i2c speed' command.  Note that the I2C controller
utilized by the mpc7448hpc2 has a fixed speed and cannot be changed
dynamically.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 include/configs/mpc7448hpc2.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/configs/mpc7448hpc2.h b/include/configs/mpc7448hpc2.h
index a1783b2..7d42155 100644
--- a/include/configs/mpc7448hpc2.h
+++ b/include/configs/mpc7448hpc2.h
@@ -179,6 +179,7 @@
  */
 #define CONFIG_VERSION_VARIABLE		1
 #define CONFIG_TSI108_I2C
+#define CONFIG_SYS_I2C_SPEED		100000	/* I2C speed */
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x50	/* I2C EEPROM page 1 */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1	/* Bytes of address */
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 5/5] tsi108_i2c: Add i2c_init() stub function
  2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
                   ` (3 preceding siblings ...)
  2009-04-24 20:34 ` [U-Boot] [PATCH 4/5] mpc7448hpc2: Add CONFIG_SYS_I2C_SPEED define Peter Tyser
@ 2009-04-24 20:34 ` Peter Tyser
  2009-04-27  7:22 ` [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Heiko Schocher
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Tyser @ 2009-04-24 20:34 UTC (permalink / raw)
  To: u-boot

Add the i2c_init() function so that the tsi108_i2c.c driver fits
U-Boot's standard I2C API which is utilized by cmd_i2c.c

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 drivers/i2c/tsi108_i2c.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/tsi108_i2c.c b/drivers/i2c/tsi108_i2c.c
index fda822c..3829ef9 100644
--- a/drivers/i2c/tsi108_i2c.c
+++ b/drivers/i2c/tsi108_i2c.c
@@ -41,6 +41,15 @@
 /* All functions assume that Tsi108 I2C block is the only master on the bus */
 /* I2C read helper function */
 
+void i2c_init(int speed, int slaveaddr)
+{
+	/*
+	 * The TSI108 has a fixed I2C clock rate and doesn't support slave
+	 * operation.  This function only exists as a stub to fit into the
+	 * U-Boot I2C API.
+	 */
+}
+
 static int i2c_read_byte (
 		uint i2c_chan,	/* I2C channel number: 0 - main, 1 - SDC SPD */
 		uchar chip_addr,/* I2C device address on the bus */
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands
  2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
                   ` (4 preceding siblings ...)
  2009-04-24 20:34 ` [U-Boot] [PATCH 5/5] tsi108_i2c: Add i2c_init() stub function Peter Tyser
@ 2009-04-27  7:22 ` Heiko Schocher
  5 siblings, 0 replies; 7+ messages in thread
From: Heiko Schocher @ 2009-04-27  7:22 UTC (permalink / raw)
  To: u-boot

Hello Peter,

Peter Tyser wrote:
> Hi Heiko,
> These 5 patches should clean up the compile issues that you noticed
> after application of the "[PATCH v2 0/7] Remove individual I2C commands
> and cleanup" series.

Thanks.

> I only have a build environment for powerpc boards so it'd be much
> appreciated if other architectures could do some basic compile
> testing after the "Remove individual I2C commands and cleanup"
> series is applied to the i2c repository.

I did a "powerpc" and an "arm" MAKEALL ... Hmm.. maybe we should
add somewhere in the tree a documentation, where toolchains can be found?

> Assuming these patches are accepted, the original "v2 Remove individual
> I2C commands and cleanup" series should then be applied.

Applied to u-boot-i2c next branch, also the "v2 Remove individual I2C
commands and cleanup" series, see:

http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/next

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-04-27  7:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-24 20:34 [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Peter Tyser
2009-04-24 20:34 ` [U-Boot] [PATCH 1/5] i2c.h: Provide a default CONFIG_SYS_I2C_SLAVE value Peter Tyser
2009-04-24 20:34 ` [U-Boot] [PATCH 2/5] cpci750: i2c cleanup Peter Tyser
2009-04-24 20:34 ` [U-Boot] [PATCH 3/5] Marvell: " Peter Tyser
2009-04-24 20:34 ` [U-Boot] [PATCH 4/5] mpc7448hpc2: Add CONFIG_SYS_I2C_SPEED define Peter Tyser
2009-04-24 20:34 ` [U-Boot] [PATCH 5/5] tsi108_i2c: Add i2c_init() stub function Peter Tyser
2009-04-27  7:22 ` [U-Boot] [PATCH 0/5] I2C cleanup before removal of deprecated commands Heiko Schocher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.