]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/block/ahci.c
x86: ahci: Make sure interface is not busy after enabling the port
[karo-tx-uboot.git] / drivers / block / ahci.c
index 37d2d2a28eef53bbd2477b7bb06b37f415e68735..c908fab4506e5c6400dc91150cbc23234c0ed9e3 100644 (file)
@@ -513,6 +513,20 @@ static void ahci_set_feature(u8 port)
 }
 #endif
 
+static int wait_spinup(volatile u8 *port_mmio)
+{
+       ulong start;
+       u32 tf_data;
+
+       start = get_timer(0);
+       do {
+               tf_data = readl(port_mmio + PORT_TFDATA);
+               if (!(tf_data & ATA_BUSY))
+                       return 0;
+       } while (get_timer(start) < WAIT_MS_SPINUP);
+
+       return -ETIMEDOUT;
+}
 
 static int ahci_port_start(u8 port)
 {
@@ -579,7 +593,11 @@ static int ahci_port_start(u8 port)
 
        debug("Exit start port %d\n", port);
 
-       return 0;
+       /*
+        * Make sure interface is not busy based on error and status
+        * information from task file data register before proceeding
+        */
+       return wait_spinup(port_mmio);
 }