Blame view

common/spl/spl_sata.c 1.23 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
fff40a7e0   Dan Murphy   common: spl: Add ...
2
3
4
5
6
7
  /*
   * (C) Copyright 2013
   * Texas Instruments, <www.ti.com>
   *
   * Dan Murphy <dmurphy@ti.com>
   *
fff40a7e0   Dan Murphy   common: spl: Add ...
8
9
10
11
12
13
14
   * Derived work from spl_usb.c
   */
  
  #include <common.h>
  #include <spl.h>
  #include <asm/u-boot.h>
  #include <sata.h>
fc89b2e47   Tom Rini   spl_sata.c: Add <...
15
  #include <scsi.h>
36afd4513   Nikita Kiryanov   spl: change retur...
16
  #include <errno.h>
fff40a7e0   Dan Murphy   common: spl: Add ...
17
  #include <fat.h>
fff40a7e0   Dan Murphy   common: spl: Add ...
18
  #include <image.h>
2a2ee2ac3   Simon Glass   spl: Pass spl_ima...
19
20
  static int spl_sata_load_image(struct spl_image_info *spl_image,
  			       struct spl_boot_device *bootdev)
fff40a7e0   Dan Murphy   common: spl: Add ...
21
22
  {
  	int err;
4101f6879   Simon Glass   dm: Drop the bloc...
23
  	struct blk_desc *stor_dev;
fff40a7e0   Dan Murphy   common: spl: Add ...
24
25
26
27
28
29
30
  
  	err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE);
  	if (err) {
  #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
  		printf("spl: sata init failed: err - %d
  ", err);
  #endif
36afd4513   Nikita Kiryanov   spl: change retur...
31
  		return err;
fff40a7e0   Dan Murphy   common: spl: Add ...
32
33
  	} else {
  		/* try to recognize storage devices immediately */
8eab1a58d   Simon Glass   dm: scsi: Documen...
34
  		scsi_scan(false);
edd82ab35   Simon Glass   dm: scsi: Drop th...
35
  		stor_dev = blk_get_devnum_by_type(IF_TYPE_SCSI, 0);
36afd4513   Nikita Kiryanov   spl: change retur...
36
37
  		if (!stor_dev)
  			return -ENODEV;
fff40a7e0   Dan Murphy   common: spl: Add ...
38
39
40
  	}
  
  #ifdef CONFIG_SPL_OS_BOOT
710e9ca57   Simon Glass   spl: Update fat f...
41
42
43
  	if (spl_start_uboot() ||
  	    spl_load_image_fat_os(spl_image, stor_dev,
  				  CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
fff40a7e0   Dan Murphy   common: spl: Add ...
44
  #endif
710e9ca57   Simon Glass   spl: Update fat f...
45
46
47
  	{
  		err = spl_load_image_fat(spl_image, stor_dev,
  					CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
205b4f33c   Guillaume GARDET   Rename some defin...
48
  				CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
710e9ca57   Simon Glass   spl: Update fat f...
49
  	}
fff40a7e0   Dan Murphy   common: spl: Add ...
50
51
52
  	if (err) {
  		puts("Error loading sata device
  ");
36afd4513   Nikita Kiryanov   spl: change retur...
53
  		return err;
fff40a7e0   Dan Murphy   common: spl: Add ...
54
  	}
36afd4513   Nikita Kiryanov   spl: change retur...
55
56
  
  	return 0;
fff40a7e0   Dan Murphy   common: spl: Add ...
57
  }
ebc4ef61d   Simon Glass   spl: Add a name t...
58
  SPL_LOAD_IMAGE_METHOD("SATA", 0, BOOT_DEVICE_SATA, spl_sata_load_image);