xref: /rk3399_rockchip-uboot/include/spl.h (revision 52f2acc5e065b52499ee4a8e6baf886b8f5fa6da)
147f7bcaeSTom Rini /*
247f7bcaeSTom Rini  * (C) Copyright 2012
347f7bcaeSTom Rini  * Texas Instruments, <www.ti.com>
447f7bcaeSTom Rini  *
51a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
647f7bcaeSTom Rini  */
747f7bcaeSTom Rini #ifndef	_SPL_H_
847f7bcaeSTom Rini #define	_SPL_H_
947f7bcaeSTom Rini 
1047f7bcaeSTom Rini /* Platform-specific defines */
116507f133STom Rini #include <linux/compiler.h>
1247f7bcaeSTom Rini #include <asm/spl.h>
1347f7bcaeSTom Rini 
1432ba8952SSimon Glass /* Value in r0 indicates we booted from U-Boot */
1532ba8952SSimon Glass #define UBOOT_NOT_LOADED_FROM_SPL	0x13578642
16773b5940SDan Murphy 
1747f7bcaeSTom Rini /* Boot type */
1847f7bcaeSTom Rini #define MMCSD_MODE_UNDEFINED	0
1947f7bcaeSTom Rini #define MMCSD_MODE_RAW		1
20205b4f33SGuillaume GARDET #define MMCSD_MODE_FS		2
217dbe63bcSTom Rini #define MMCSD_MODE_EMMCBOOT	3
2247f7bcaeSTom Rini 
2347f7bcaeSTom Rini struct spl_image_info {
2447f7bcaeSTom Rini 	const char *name;
2547f7bcaeSTom Rini 	u8 os;
2647f7bcaeSTom Rini 	u32 load_addr;
2747f7bcaeSTom Rini 	u32 entry_point;
2847f7bcaeSTom Rini 	u32 size;
29022b4975SStefan Roese 	u32 flags;
3047f7bcaeSTom Rini };
3147f7bcaeSTom Rini 
32f1dcee59SSimon Glass /*
33f1dcee59SSimon Glass  * Information required to load data from a device
34f1dcee59SSimon Glass  *
35f1dcee59SSimon Glass  * @dev: Pointer to the device, e.g. struct mmc *
36f1dcee59SSimon Glass  * @priv: Private data for the device
37f1dcee59SSimon Glass  * @bl_len: Block length for reading in bytes
38eafd5410SLokesh Vutla  * @filename: Name of the fit image file.
39f1dcee59SSimon Glass  * @read: Function to call to read from the device
40f1dcee59SSimon Glass  */
41f1dcee59SSimon Glass struct spl_load_info {
42f1dcee59SSimon Glass 	void *dev;
43f1dcee59SSimon Glass 	void *priv;
44f1dcee59SSimon Glass 	int bl_len;
45eafd5410SLokesh Vutla 	const char *filename;
46f1dcee59SSimon Glass 	ulong (*read)(struct spl_load_info *load, ulong sector, ulong count,
47f1dcee59SSimon Glass 		      void *buf);
48f1dcee59SSimon Glass };
49f1dcee59SSimon Glass 
50eafd5410SLokesh Vutla /**
51eafd5410SLokesh Vutla  * spl_load_simple_fit() - Loads a fit image from a device.
52eafd5410SLokesh Vutla  * @info:	Structure containing the information required to load data.
53eafd5410SLokesh Vutla  * @sector:	Sector number where FIT image is located in the device
54eafd5410SLokesh Vutla  * @fdt:	Pointer to the copied FIT header.
55eafd5410SLokesh Vutla  *
56eafd5410SLokesh Vutla  * Reads the FIT image @sector in the device. Loads u-boot image to
57eafd5410SLokesh Vutla  * specified load address and copies the dtb to end of u-boot image.
58eafd5410SLokesh Vutla  * Returns 0 on success.
59eafd5410SLokesh Vutla  */
60f1dcee59SSimon Glass int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fdt);
61f1dcee59SSimon Glass 
62022b4975SStefan Roese #define SPL_COPY_PAYLOAD_ONLY	1
63022b4975SStefan Roese 
6447f7bcaeSTom Rini extern struct spl_image_info spl_image;
6547f7bcaeSTom Rini 
6647f7bcaeSTom Rini /* SPL common functions */
6747f7bcaeSTom Rini void preloader_console_init(void);
6847f7bcaeSTom Rini u32 spl_boot_device(void);
692b1cdafaSMarek Vasut u32 spl_boot_mode(const u32 boot_device);
700c3117b1SHeiko Schocher void spl_set_header_raw_uboot(void);
717e0f2267SMarek Vasut int spl_parse_image_header(const struct image_header *header);
7247f7bcaeSTom Rini void spl_board_prepare_for_linux(void);
733a3b9147SMichal Simek void spl_board_prepare_for_boot(void);
74bf55cd4fSLadislav Michl int spl_board_ubi_load_image(u32 boot_device);
756507f133STom Rini void __noreturn jump_to_image_linux(void *arg);
7647f7bcaeSTom Rini int spl_start_uboot(void);
7747f7bcaeSTom Rini void spl_display_print(void);
7847f7bcaeSTom Rini 
7947f7bcaeSTom Rini /* NAND SPL functions */
8036afd451SNikita Kiryanov int spl_nand_load_image(void);
8147f7bcaeSTom Rini 
826000992eSEnric Balletbo i Serra /* OneNAND SPL functions */
8336afd451SNikita Kiryanov int spl_onenand_load_image(void);
846000992eSEnric Balletbo i Serra 
8533d34646SStefan Roese /* NOR SPL functions */
8636afd451SNikita Kiryanov int spl_nor_load_image(void);
8733d34646SStefan Roese 
88bf55cd4fSLadislav Michl /* UBI SPL functions */
89bf55cd4fSLadislav Michl int spl_ubi_load_image(u32 boot_device);
90bf55cd4fSLadislav Michl 
9147f7bcaeSTom Rini /* MMC SPL functions */
92a1e56cf6SNikita Kiryanov int spl_mmc_load_image(u32 boot_device);
9347f7bcaeSTom Rini 
9447f7bcaeSTom Rini /* YMODEM SPL functions */
9536afd451SNikita Kiryanov int spl_ymodem_load_image(void);
9647f7bcaeSTom Rini 
9747f7bcaeSTom Rini /* SPI SPL functions */
9836afd451SNikita Kiryanov int spl_spi_load_image(void);
9947f7bcaeSTom Rini 
1007ac2fe2dSIlya Yanok /* Ethernet SPL functions */
10136afd451SNikita Kiryanov int spl_net_load_image(const char *device);
1027ac2fe2dSIlya Yanok 
1038cffe5bdSDan Murphy /* USB SPL functions */
10436afd451SNikita Kiryanov int spl_usb_load_image(void);
1058cffe5bdSDan Murphy 
106fff40a7eSDan Murphy /* SATA SPL functions */
10736afd451SNikita Kiryanov int spl_sata_load_image(void);
108fff40a7eSDan Murphy 
109773b5940SDan Murphy /* SPL FAT image functions */
1104101f687SSimon Glass int spl_load_image_fat(struct blk_desc *block_dev, int partition,
1114101f687SSimon Glass 		       const char *filename);
1124101f687SSimon Glass int spl_load_image_fat_os(struct blk_desc *block_dev, int partition);
113773b5940SDan Murphy 
114ce048224SJeroen Hofstee void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
115ce048224SJeroen Hofstee 
116592f9222SGuillaume GARDET /* SPL EXT image functions */
1174101f687SSimon Glass int spl_load_image_ext(struct blk_desc *block_dev, int partition,
1184101f687SSimon Glass 		       const char *filename);
1194101f687SSimon Glass int spl_load_image_ext_os(struct blk_desc *block_dev, int partition);
120592f9222SGuillaume GARDET 
121070d00b8SSimon Glass /**
122070d00b8SSimon Glass  * spl_init() - Set up device tree and driver model in SPL if enabled
123070d00b8SSimon Glass  *
124070d00b8SSimon Glass  * Call this function in board_init_f() if you want to use device tree and
125070d00b8SSimon Glass  * driver model early, before board_init_r() is called. This function will
126070d00b8SSimon Glass  * be called from board_init_r() if not called earlier.
127070d00b8SSimon Glass  *
128070d00b8SSimon Glass  * If this is not called, then driver model will be inactive in SPL's
129070d00b8SSimon Glass  * board_init_f(), and no device tree will be available.
130070d00b8SSimon Glass  */
131070d00b8SSimon Glass int spl_init(void);
132070d00b8SSimon Glass 
13347f7bcaeSTom Rini #ifdef CONFIG_SPL_BOARD_INIT
13447f7bcaeSTom Rini void spl_board_init(void);
13547f7bcaeSTom Rini #endif
13632ba8952SSimon Glass 
13732ba8952SSimon Glass /**
13832ba8952SSimon Glass  * spl_was_boot_source() - check if U-Boot booted from SPL
13932ba8952SSimon Glass  *
14032ba8952SSimon Glass  * This will normally be true, but if U-Boot jumps to second U-Boot, it will
14132ba8952SSimon Glass  * be false. This should be implemented by board-specific code.
14232ba8952SSimon Glass  *
14332ba8952SSimon Glass  * @return true if U-Boot booted from SPL, else false
14432ba8952SSimon Glass  */
14532ba8952SSimon Glass bool spl_was_boot_source(void);
14632ba8952SSimon Glass 
147*52f2acc5SB, Ravi /**
148*52f2acc5SB, Ravi  * spl_dfu_cmd- run dfu command with chosen mmc device interface
149*52f2acc5SB, Ravi  * @param usb_index - usb controller number
150*52f2acc5SB, Ravi  * @param mmc_dev -  mmc device nubmer
151*52f2acc5SB, Ravi  *
152*52f2acc5SB, Ravi  * @return 0 on success, otherwise error code
153*52f2acc5SB, Ravi  */
154*52f2acc5SB, Ravi int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr);
15547f7bcaeSTom Rini #endif
156