Skip to content
Snippets Groups Projects
Commit 00913379 authored by Heiko Schocher's avatar Heiko Schocher
Browse files

i2c, mpc5xxx: add multibus support


Tested on upcoming hydra (mpc5200 based) board.

Signed-off-by: default avatarHeiko Schocher <hs@denx.de>
parent 8ad25bf8
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ DECLARE_GLOBAL_DATA_PTR; ...@@ -30,6 +30,7 @@ DECLARE_GLOBAL_DATA_PTR;
#include <mpc5xxx.h> #include <mpc5xxx.h>
#include <i2c.h> #include <i2c.h>
#if !defined(CONFIG_I2C_MULTI_BUS)
#if (CONFIG_SYS_I2C_MODULE == 2) #if (CONFIG_SYS_I2C_MODULE == 2)
#define I2C_BASE MPC5XXX_I2C2 #define I2C_BASE MPC5XXX_I2C2
#elif (CONFIG_SYS_I2C_MODULE == 1) #elif (CONFIG_SYS_I2C_MODULE == 1)
...@@ -37,6 +38,19 @@ DECLARE_GLOBAL_DATA_PTR; ...@@ -37,6 +38,19 @@ DECLARE_GLOBAL_DATA_PTR;
#else #else
#error CONFIG_SYS_I2C_MODULE is not properly configured #error CONFIG_SYS_I2C_MODULE is not properly configured
#endif #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_TIMEOUT 6667
#define I2C_RETRIES 3 #define I2C_RETRIES 3
...@@ -439,4 +453,33 @@ Done: ...@@ -439,4 +453,33 @@ Done:
return ret; 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 */ #endif /* CONFIG_HARD_I2C */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment