Blame view

common/spl/spl_sata.c 1.25 KB
fff40a7e0   Dan Murphy   common: spl: Add ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /*
   * (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>
fc89b2e47   Tom Rini   spl_sata.c: Add <...
16
  #include <scsi.h>
36afd4513   Nikita Kiryanov   spl: change retur...
17
  #include <errno.h>
fff40a7e0   Dan Murphy   common: spl: Add ...
18
  #include <fat.h>
fff40a7e0   Dan Murphy   common: spl: Add ...
19
20
21
  #include <image.h>
  
  DECLARE_GLOBAL_DATA_PTR;
2a2ee2ac3   Simon Glass   spl: Pass spl_ima...
22
23
  static int spl_sata_load_image(struct spl_image_info *spl_image,
  			       struct spl_boot_device *bootdev)
fff40a7e0   Dan Murphy   common: spl: Add ...
24
25
  {
  	int err;
4101f6879   Simon Glass   dm: Drop the bloc...
26
  	struct blk_desc *stor_dev;
fff40a7e0   Dan Murphy   common: spl: Add ...
27
28
29
30
31
32
33
  
  	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...
34
  		return err;
fff40a7e0   Dan Murphy   common: spl: Add ...
35
36
  	} else {
  		/* try to recognize storage devices immediately */
8eab1a58d   Simon Glass   dm: scsi: Documen...
37
  		scsi_scan(false);
edd82ab35   Simon Glass   dm: scsi: Drop th...
38
  		stor_dev = blk_get_devnum_by_type(IF_TYPE_SCSI, 0);
36afd4513   Nikita Kiryanov   spl: change retur...
39
40
  		if (!stor_dev)
  			return -ENODEV;
fff40a7e0   Dan Murphy   common: spl: Add ...
41
42
43
  	}
  
  #ifdef CONFIG_SPL_OS_BOOT
710e9ca57   Simon Glass   spl: Update fat f...
44
45
46
  	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 ...
47
  #endif
710e9ca57   Simon Glass   spl: Update fat f...
48
49
50
  	{
  		err = spl_load_image_fat(spl_image, stor_dev,
  					CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
205b4f33c   Guillaume GARDET   Rename some defin...
51
  				CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
710e9ca57   Simon Glass   spl: Update fat f...
52
  	}
fff40a7e0   Dan Murphy   common: spl: Add ...
53
54
55
  	if (err) {
  		puts("Error loading sata device
  ");
36afd4513   Nikita Kiryanov   spl: change retur...
56
  		return err;
fff40a7e0   Dan Murphy   common: spl: Add ...
57
  	}
36afd4513   Nikita Kiryanov   spl: change retur...
58
59
  
  	return 0;
fff40a7e0   Dan Murphy   common: spl: Add ...
60
  }
ebc4ef61d   Simon Glass   spl: Add a name t...
61
  SPL_LOAD_IMAGE_METHOD("SATA", 0, BOOT_DEVICE_SATA, spl_sata_load_image);