Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / x86 / cpu / ivybridge / sata.c
index 0f5e19042575fe4117735137ea026be729806c73..025b20be31bd1137854c2565e3a25650b15081e9 100644 (file)
@@ -1,13 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * From Coreboot
  * Copyright (C) 2008-2009 coresystems GmbH
- *
- * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <common.h>
+#include <ahci.h>
 #include <dm.h>
 #include <fdtdec.h>
+#include <log.h>
 #include <asm/io.h>
 #include <asm/pch_common.h>
 #include <asm/pci.h>
@@ -208,6 +209,20 @@ static void bd82x6x_sata_enable(struct udevice *dev)
        dm_pci_write_config16(dev, 0x90, map);
 }
 
+static int bd82x6x_sata_bind(struct udevice *dev)
+{
+       struct udevice *scsi_dev;
+       int ret;
+
+       if (gd->flags & GD_FLG_RELOC) {
+               ret = ahci_bind_scsi(dev, &scsi_dev);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 static int bd82x6x_sata_probe(struct udevice *dev)
 {
        struct udevice *pch;
@@ -219,8 +234,12 @@ static int bd82x6x_sata_probe(struct udevice *dev)
 
        if (!(gd->flags & GD_FLG_RELOC))
                bd82x6x_sata_enable(dev);
-       else
+       else {
                bd82x6x_sata_init(dev, pch);
+               ret = ahci_probe_scsi_pci(dev);
+               if (ret)
+                       return ret;
+       }
 
        return 0;
 }
@@ -234,5 +253,6 @@ U_BOOT_DRIVER(ahci_ivybridge_drv) = {
        .name           = "ahci_ivybridge",
        .id             = UCLASS_AHCI,
        .of_match       = bd82x6x_ahci_ids,
+       .bind           = bd82x6x_sata_bind,
        .probe          = bd82x6x_sata_probe,
 };