mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-30 08:07:59 +00:00
soft_i2c: Add CFG_I2C_INIT_BOARD option
This patch adds the option for a boardspecific I2C deblocking mechanism for the soft i2c driver. Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
e5e4edd9f1
commit
4ca107effe
1 changed files with 11 additions and 0 deletions
|
@ -75,13 +75,16 @@ static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = 0;
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
* Local functions
|
* Local functions
|
||||||
*/
|
*/
|
||||||
|
#if !defined(CFG_I2C_INIT_BOARD)
|
||||||
static void send_reset (void);
|
static void send_reset (void);
|
||||||
|
#endif
|
||||||
static void send_start (void);
|
static void send_start (void);
|
||||||
static void send_stop (void);
|
static void send_stop (void);
|
||||||
static void send_ack (int);
|
static void send_ack (int);
|
||||||
static int write_byte (uchar byte);
|
static int write_byte (uchar byte);
|
||||||
static uchar read_byte (int);
|
static uchar read_byte (int);
|
||||||
|
|
||||||
|
#if !defined(CFG_I2C_INIT_BOARD)
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
* Send a reset sequence consisting of 9 clocks with the data signal high
|
* Send a reset sequence consisting of 9 clocks with the data signal high
|
||||||
* to clock any confused device back into an idle state. Also send a
|
* to clock any confused device back into an idle state. Also send a
|
||||||
|
@ -109,6 +112,7 @@ static void send_reset(void)
|
||||||
send_stop();
|
send_stop();
|
||||||
I2C_TRISTATE;
|
I2C_TRISTATE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
* START: High -> Low on SDA while SCL is High
|
* START: High -> Low on SDA while SCL is High
|
||||||
|
@ -280,6 +284,12 @@ static uchar read_byte(int ack)
|
||||||
*/
|
*/
|
||||||
void i2c_init (int speed, int slaveaddr)
|
void i2c_init (int speed, int slaveaddr)
|
||||||
{
|
{
|
||||||
|
#if defined(CFG_I2C_INIT_BOARD)
|
||||||
|
/* call board specific i2c bus reset routine before accessing the */
|
||||||
|
/* environment, which might be in a chip on that bus. For details */
|
||||||
|
/* about this problem see doc/I2C_Edge_Conditions. */
|
||||||
|
i2c_init_board();
|
||||||
|
#else
|
||||||
/*
|
/*
|
||||||
* WARNING: Do NOT save speed in a static variable: if the
|
* WARNING: Do NOT save speed in a static variable: if the
|
||||||
* I2C routines are called before RAM is initialized (to read
|
* I2C routines are called before RAM is initialized (to read
|
||||||
|
@ -287,6 +297,7 @@ void i2c_init (int speed, int slaveaddr)
|
||||||
* system will crash.
|
* system will crash.
|
||||||
*/
|
*/
|
||||||
send_reset ();
|
send_reset ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Reference in a new issue