]> git.sur5r.net Git - u-boot/commitdiff
common: spl: Add spl sata boot support
authorDan Murphy <dmurphy@ti.com>
Mon, 3 Feb 2014 12:59:01 +0000 (06:59 -0600)
committerTom Rini <trini@ti.com>
Wed, 19 Feb 2014 15:47:43 +0000 (10:47 -0500)
Add spl_sata to read a fat partition from a bootable SATA
drive.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
common/Makefile
common/cmd_scsi.c
common/spl/Makefile
common/spl/spl.c
common/spl/spl_sata.c [new file with mode: 0644]
include/spl.h
spl/Makefile

index a83246ee27b293944819fc01be0ce90b22f82c87..2fe14ccc41b95704025ad22f466091388885ae2a 100644 (file)
@@ -202,6 +202,9 @@ ifdef CONFIG_SPL_USB_HOST_SUPPORT
 obj-$(CONFIG_SPL_USB_SUPPORT) += usb.o usb_hub.o
 obj-$(CONFIG_USB_STORAGE) += usb_storage.o
 endif
+ifdef CONFIG_SPL_SATA_SUPPORT
+obj-$(CONFIG_CMD_SCSI) += cmd_scsi.o
+endif
 ifneq ($(CONFIG_SPL_NET_SUPPORT),y)
 obj-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
 obj-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o
index 7b97dc9332b4d275ee05eb97690102a1a95a4e3f..b3f7687aee6a2c87bd802539d7cdb96d9a4c0847 100644 (file)
@@ -168,7 +168,9 @@ removable:
                scsi_curr_dev = -1;
 
        printf("Found %d device(s).\n", scsi_max_devs);
+#ifndef CONFIG_SPL_BUILD
        setenv_ulong("scsidevs", scsi_max_devs);
+#endif
 }
 
 int scsi_get_disk_count(void)
index 65a1484fc4e48fc6016e57c385778837599add63..64569c2cc6d563732a259c237db0ac7d52060bc9 100644 (file)
@@ -18,4 +18,5 @@ obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
 obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
 obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
 obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o
+obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
 endif
index 0645cee789ff8640f12ab69de458b1cd91013eef..774fdad2523b7ff0e4f5a48371756053fda0e7a6 100644 (file)
@@ -209,6 +209,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
        case BOOT_DEVICE_USB:
                spl_usb_load_image();
                break;
+#endif
+#ifdef CONFIG_SPL_SATA_SUPPORT
+       case BOOT_DEVICE_SATA:
+               spl_sata_load_image();
+               break;
 #endif
        default:
                debug("SPL: Un-supported Boot Device\n");
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
new file mode 100644 (file)
index 0000000..2e7adca
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * (C) Copyright 2013
+ * Texas Instruments, <www.ti.com>
+ *
+ * Dan Murphy <dmurphy@ti.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ *
+ * Derived work from spl_usb.c
+ */
+
+#include <common.h>
+#include <spl.h>
+#include <asm/u-boot.h>
+#include <sata.h>
+#include <fat.h>
+#include <version.h>
+#include <image.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void spl_sata_load_image(void)
+{
+       int err;
+       block_dev_desc_t *stor_dev;
+
+       err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE);
+       if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+               printf("spl: sata init failed: err - %d\n", err);
+#endif
+               hang();
+       } else {
+               /* try to recognize storage devices immediately */
+               stor_dev = scsi_get_dev(0);
+       }
+
+#ifdef CONFIG_SPL_OS_BOOT
+       if (spl_start_uboot() || spl_load_image_fat_os(stor_dev,
+                                                                       CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
+#endif
+       err = spl_load_image_fat(stor_dev,
+                               CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
+                               CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME);
+       if (err) {
+               puts("Error loading sata device\n");
+               hang();
+       }
+}
index dad00c0075d9b6904d1db8248c8464e6cd7e2e03..a7e41da7fd4980ef2362816a63d8680cc26ef1b9 100644 (file)
@@ -65,6 +65,9 @@ void spl_net_load_image(const char *device);
 /* USB SPL functions */
 void spl_usb_load_image(void);
 
+/* SATA SPL functions */
+void spl_sata_load_image(void);
+
 /* SPL FAT image functions */
 int spl_load_image_fat(block_dev_desc_t *block_dev, int partition, const char *filename);
 int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition);
index 4143e3810cd4340eae32b155307cbe24975e77f1..28fcfdd48626101d1619a6bc6ef7d215472d3d3f 100644 (file)
@@ -85,6 +85,7 @@ LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
 LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
 LIBS-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
 LIBS-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
+LIBS-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
 
 ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
 LIBS-y += arch/$(ARCH)/imx-common/