summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorBaruch Siach <baruch@tkos.co.il>2019-07-14 17:54:21 +0300
committerTom Rini <trini@konsulko.com>2019-07-24 14:15:36 -0400
commit60ca969a7a1cbab6e43c5f97ffe99a9630257d08 (patch)
treef6900687696cd0bbb85f0fec554c1c65fbb86f57 /common/spl
parent146ce6474d0355a45fbd289981ecc8d2d15ff993 (diff)
downloadu-boot-60ca969a7a1cbab6e43c5f97ffe99a9630257d08.tar.gz
u-boot-60ca969a7a1cbab6e43c5f97ffe99a9630257d08.tar.bz2
u-boot-60ca969a7a1cbab6e43c5f97ffe99a9630257d08.zip
spl: sata: support U-Boot load from raw sata disk
Support load of the U-Boot image from raw SATA disk sector. This is equivalent to load from MMC raw sector. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/Kconfig14
-rw-r--r--common/spl/spl_sata.c34
2 files changed, 48 insertions, 0 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 5978fb2934..5d6da5db89 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -918,6 +918,20 @@ config SPL_SATA_SUPPORT
expense and power consumption. This enables loading from SATA
using a configured device.
+config SPL_SATA_RAW_U_BOOT_USE_SECTOR
+ bool "SATA raw mode: by sector"
+ depends on SPL_SATA_SUPPORT
+ help
+ Use sector number for specifying U-Boot location on SATA disk in
+ raw mode.
+
+config SPL_SATA_RAW_U_BOOT_SECTOR
+ hex "Sector on the SATA disk to load U-Boot from"
+ depends on SPL_SATA_RAW_U_BOOT_USE_SECTOR
+ help
+ Sector on the SATA disk to load U-Boot from, when the SATA disk is being
+ used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes).
+
config SPL_SERIAL_SUPPORT
bool "Support serial"
select SPL_PRINTF
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index f0af9f38d1..e108af0576 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -25,6 +25,37 @@
#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img"
#endif
+#ifndef CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR
+/* Dummy value to make the compiler happy */
+#define CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR 0x100
+#endif
+
+static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
+ struct blk_desc *stor_dev, unsigned long sector)
+{
+ struct image_header *header;
+ unsigned long count;
+ u32 image_size_sectors;
+ int ret;
+
+ header = spl_get_load_buffer(-sizeof(*header), stor_dev->blksz);
+ count = blk_dread(stor_dev, sector, 1, header);
+ if (count == 0)
+ return -EIO;
+
+ ret = spl_parse_image_header(spl_image, header);
+ if (ret)
+ return ret;
+
+ image_size_sectors = DIV_ROUND_UP(spl_image->size, stor_dev->blksz);
+ count = blk_dread(stor_dev, sector, image_size_sectors,
+ (void *)spl_image->load_addr);
+ if (count != image_size_sectors)
+ return -EIO;
+
+ return 0;
+}
+
static int spl_sata_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
@@ -59,6 +90,9 @@ static int spl_sata_load_image(struct spl_image_info *spl_image,
err = spl_load_image_fat(spl_image, stor_dev,
CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+ } else if (IS_ENABLED(CONFIG_SPL_SATA_RAW_U_BOOT_USE_SECTOR)) {
+ err = spl_sata_load_image_raw(spl_image, stor_dev,
+ CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR);
}
}
if (err) {