diff --git a/board/nm/hancock/board.c b/board/nm/hancock/board.c index a52e32a9d3..35416653e2 100644 --- a/board/nm/hancock/board.c +++ b/board/nm/hancock/board.c @@ -844,10 +844,7 @@ int board_late_init(void) if (read_eeprom() < 0) { puts("Could not get board ID.\n"); } - int rc = -1; - int bus; - int ret; - uint8_t val; + get_hw_version(); get_pmic_version(); set_root_partition(); @@ -863,18 +860,11 @@ int board_late_init(void) /* UI configuration and detection */ REQUEST_AND_SET_GPIO(GPIO_RST_UI_N); - - - ret = ui_claim_i2c_bus(&bus); - if (ret == 0) - rc = ui_i2c_get_reg(0x00, &val); - if (rc==0 && ret == 0 ) - printf("UI interface detected\n"); + if ( detect_ui() ) + printf("UI: ready\n"); else - printf("UI interface NOT detected\n"); + printf("UI: n/a\n"); - if (ret == 0) - ui_release_i2c_bus(bus); /* FIXME: Problem switch reset lines of switch and PHY * Clocks for PHY are only present once switch is configured @@ -1054,18 +1044,10 @@ static void ft_hw_version(void *blob) } static void ft_led(void *blob) { - int rc = -1; - int bus; - int ret; - uint8_t val; + int node_offset; - ret = ui_claim_i2c_bus(&bus); - if (ret == 0){ - rc = ui_i2c_get_reg(0x00, &val); - ui_release_i2c_bus(bus); - } - if (rc==0 && ret == 0){ + if ( detect_ui() ){ printf ("ft access to change the led status to okay \n"); node_offset = fdt_path_offset(blob, "/leds/led@4/"); if (node_offset != -1) { diff --git a/board/nm/hancock/ui.c b/board/nm/hancock/ui.c index b45dfea248..fa30be30c9 100644 --- a/board/nm/hancock/ui.c +++ b/board/nm/hancock/ui.c @@ -108,5 +108,25 @@ int ui_i2c_set_reg(uint32_t reg, u8 val) return ret; } +bool detect_ui(void) +{ + int bus; + int claim; + uint8_t val; + static int ui_detected = -1; /* -1: unitialized, 0: UI not available, 1: UI detected */ + + if (ui_detected < 0) { + claim = ui_claim_i2c_bus(&bus); + if (claim == 0) { + if ( 0 == ui_i2c_get_reg(0x00, &val)) + ui_detected = 1; + else + ui_detected = 0; + ui_release_i2c_bus(bus); + } + } + + return (ui_detected == 1); +} diff --git a/board/nm/hancock/ui.h b/board/nm/hancock/ui.h index 2760bc1359..f181b5d43f 100644 --- a/board/nm/hancock/ui.h +++ b/board/nm/hancock/ui.h @@ -24,7 +24,7 @@ extern int ui_release_i2c_bus(int bus); extern int ui_i2c_get_reg(uint32_t reg, u8* val); extern int ui_i2c_set_reg(uint32_t reg, u8 val); - +extern bool detect_ui(void); #endif /* UI_H */ diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index a7f3fb4a79..0a771a9925 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -420,8 +420,8 @@ static int omap24_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr, } if (status == 0 || (status & I2C_STAT_NACK)) { i2c_error = 1; - printf("i2c_read: error waiting for addr ACK (status=0x%x)\n", - status); + /*printf("i2c_read: error waiting for addr ACK (status=0x%x)\n", + status);*/ goto rd_exit; } if (alen) {