i2c: Enable i2c and perform bus clear procedure
Help the boot loader and perform a bus clear. U-Boot will try to read the MAC from the EEPROM and barebox has the complex boot state stored in it. In the past we have seen U-boot failing to read from the EEPROM and let's have one place to initialize it.master
parent
77aac3693b
commit
910bd284c3
2
board.h
2
board.h
|
@ -39,7 +39,7 @@
|
|||
|
||||
#if defined(board_sysmobts_v2)
|
||||
# define PINMUX0_DEFAULT 0x0000000F
|
||||
# define PINMUX1_DEFAULT PINMUX1_UART0 | PINMUX1_UART1
|
||||
# define PINMUX1_DEFAULT PINMUX1_UART0 | PINMUX1_UART1 | PINMUX1_I2C
|
||||
# define NAND_nWP_GPIO 33
|
||||
#endif
|
||||
|
||||
|
|
39
davinci.c
39
davinci.c
|
@ -217,6 +217,39 @@ lpsc_tansition(uint8_t module, uint8_t domain, uint8_t state)
|
|||
;
|
||||
}
|
||||
|
||||
static void
|
||||
i2c_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Perform a bus clear. That is the best we can do to
|
||||
// unlock I2C devices that do not have reset signal
|
||||
SYSTEM->PINMUX[1] &= ~PINMUX1_I2C;
|
||||
|
||||
gpio_direction_in(43); // SCL High
|
||||
waitloop(450);
|
||||
gpio_direction_in(44); // SDA High
|
||||
waitloop(450);
|
||||
|
||||
gpio_direction_out(43, 0); // SCL Low
|
||||
waitloop(450);
|
||||
gpio_direction_out(44, 0); // SDA Low
|
||||
waitloop(450);
|
||||
|
||||
for (i=0; i<9; i++) {
|
||||
gpio_direction_in(43); // SCL High
|
||||
waitloop(450);
|
||||
gpio_direction_out(43, 0); // SCL Low
|
||||
waitloop(450);
|
||||
}
|
||||
|
||||
gpio_direction_in(43); // SCL High
|
||||
waitloop(450);
|
||||
gpio_direction_in(44); // SDA High
|
||||
|
||||
SYSTEM->PINMUX[1] |= PINMUX1_I2C;
|
||||
}
|
||||
|
||||
static void
|
||||
ivt_init(void)
|
||||
{
|
||||
|
@ -716,6 +749,12 @@ davinci_platform_init(char *version, int *nwp_nand)
|
|||
gpio_direction_out(HDD_ENA, 1);
|
||||
#endif
|
||||
|
||||
/* Init/Reset I2C */
|
||||
#ifdef PINMUX1_DEFAULT
|
||||
if ((PINMUX1_DEFAULT) & PINMUX1_I2C)
|
||||
i2c_init();
|
||||
#endif
|
||||
|
||||
/* IRQ Vector Table Setup */
|
||||
ivt_init();
|
||||
|
||||
|
|
Loading…
Reference in New Issue