* [U-Boot] [PATCH] i2c, mpc5xxx: add multibus support
@ 2010-11-15 7:34 Heiko Schocher
2010-11-18 18:44 ` Heiko Schocher
0 siblings, 1 reply; 2+ messages in thread
From: Heiko Schocher @ 2010-11-15 7:34 UTC (permalink / raw)
To: u-boot
Tested on upcoming hydra (mpc5200 based) board.
Signed-off-by: Heiko Schocher <hs@denx.de>
---
arch/powerpc/cpu/mpc5xxx/i2c.c | 43 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/cpu/mpc5xxx/i2c.c b/arch/powerpc/cpu/mpc5xxx/i2c.c
index 4f7f716..9fb330f 100644
--- a/arch/powerpc/cpu/mpc5xxx/i2c.c
+++ b/arch/powerpc/cpu/mpc5xxx/i2c.c
@@ -30,6 +30,7 @@ DECLARE_GLOBAL_DATA_PTR;
#include <mpc5xxx.h>
#include <i2c.h>
+#if !defined(CONFIG_I2C_MULTI_BUS)
#if (CONFIG_SYS_I2C_MODULE == 2)
#define I2C_BASE MPC5XXX_I2C2
#elif (CONFIG_SYS_I2C_MODULE == 1)
@@ -37,6 +38,19 @@ DECLARE_GLOBAL_DATA_PTR;
#else
#error CONFIG_SYS_I2C_MODULE is not properly configured
#endif
+#else
+static unsigned int i2c_bus_num __attribute__ ((section (".data"))) =
+ CONFIG_SYS_SPD_BUS_NUM;
+static unsigned int i2c_bus_speed[2] = {CONFIG_SYS_I2C_SPEED,
+ CONFIG_SYS_I2C_SPEED};
+
+static const unsigned long i2c_dev[2] = {
+ MPC5XXX_I2C1,
+ MPC5XXX_I2C2,
+};
+
+#define I2C_BASE ((struct mpc5xxx_i2c *)i2c_dev[i2c_bus_num])
+#endif
#define I2C_TIMEOUT 6667
#define I2C_RETRIES 3
@@ -439,4 +453,33 @@ Done:
return ret;
}
+#if defined(CONFIG_I2C_MULTI_BUS)
+int i2c_set_bus_num(unsigned int bus)
+{
+ if (bus > 1)
+ return -1;
+
+ i2c_bus_num = bus;
+ i2c_init(i2c_bus_speed[bus], CONFIG_SYS_I2C_SLAVE);
+ return 0;
+}
+
+int i2c_set_bus_speed(unsigned int speed)
+{
+ i2c_init(speed, CONFIG_SYS_I2C_SLAVE);
+ return 0;
+}
+
+unsigned int i2c_get_bus_num(void)
+{
+ return i2c_bus_num;
+}
+
+unsigned int i2c_get_bus_speed(void)
+{
+ return i2c_bus_speed[i2c_bus_num];
+}
+#endif
+
+
#endif /* CONFIG_HARD_I2C */
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* [U-Boot] [PATCH] i2c, mpc5xxx: add multibus support
2010-11-15 7:34 [U-Boot] [PATCH] i2c, mpc5xxx: add multibus support Heiko Schocher
@ 2010-11-18 18:44 ` Heiko Schocher
0 siblings, 0 replies; 2+ messages in thread
From: Heiko Schocher @ 2010-11-18 18:44 UTC (permalink / raw)
To: u-boot
Hello Heiko,
Heiko Schocher wrote:
> Tested on upcoming hydra (mpc5200 based) board.
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
> arch/powerpc/cpu/mpc5xxx/i2c.c | 43 ++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 43 insertions(+), 0 deletions(-)
Applied to u-boot-iwc.git.
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] 2+ messages in thread
end of thread, other threads:[~2010-11-18 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 7:34 [U-Boot] [PATCH] i2c, mpc5xxx: add multibus support Heiko Schocher
2010-11-18 18:44 ` Heiko Schocher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox