]> git.sur5r.net Git - u-boot/commitdiff
mvebu: turris_omnia: Fix PEX vs SATA detection for board topology
authorMarek BehĂșn <marek.behun@nic.cz>
Fri, 4 Aug 2017 13:28:25 +0000 (15:28 +0200)
committerStefan Roese <sr@denx.de>
Tue, 8 Aug 2017 12:20:26 +0000 (14:20 +0200)
The I2C reading in the PEX vs SATA detection code often fails on the
first try. Try three times, as the code for EEPROM reading does.

Signed-off-by: Marek Behun <marek.behun@nic.cz>
Signed-off-by: Stefan Roese <sr@denx.de>
board/CZ.NIC/turris_omnia/turris_omnia.c

index 86926f805036e7f630c8d6d8f7d65020c9c4f9bb..a4275091d21573c42ee7b605d3a33b29a7b609e7 100644 (file)
@@ -90,7 +90,7 @@ static struct serdes_map board_serdes_map_sata[] = {
 static bool omnia_detect_sata(void)
 {
        struct udevice *bus, *dev;
-       int ret;
+       int ret, retry = 3;
        u16 mode;
 
        puts("SERDES0 card detect: ");
@@ -106,8 +106,13 @@ static bool omnia_detect_sata(void)
                return false;
        }
 
-       ret = dm_i2c_read(dev, OMNIA_I2C_MCU_ADDR_STATUS, (uchar *) &mode, 2);
-       if (ret) {
+       for (; retry > 0; --retry) {
+               ret = dm_i2c_read(dev, OMNIA_I2C_MCU_ADDR_STATUS, (uchar *) &mode, 2);
+               if (!ret)
+                       break;
+       }
+
+       if (!retry) {
                puts("I2C read failed! Default PEX\n");
                return false;
        }