spl: eMMC/SD: Provide one __weak spl_boot_mode() function
The goal of this patch is to clean up the code related to choosing SPL MMC boot mode. The spl_boot_mode() now is called only in spl_mmc_load_image() function, which is only compiled in if CONFIG_SPL_MMC_SUPPORT is enabled. To achieve the goal, all per mach/arch implementations eligible for unification has been replaced with one __weak implementation. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Stefano Babic <sbabic@denx.de> Acked-by: Michal Simek <michal.simek@xilinx.com> (For ZynqMP) Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
This commit is contained in:
		
							parent
							
								
									492322992b
								
							
						
					
					
						commit
						d695d66278
					
				|  | @ -524,24 +524,3 @@ u32 spl_boot_device(void) | ||||||
| 
 | 
 | ||||||
| 	return BOOT_DEVICE_NONE; | 	return BOOT_DEVICE_NONE; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| #ifdef CONFIG_SPL_BUILD |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	switch (spl_boot_device()) { |  | ||||||
| 	case BOOT_DEVICE_MMC1: |  | ||||||
| #ifdef CONFIG_SPL_FAT_SUPPORT |  | ||||||
| 		return MMCSD_MODE_FS; |  | ||||||
| #else |  | ||||||
| 		return MMCSD_MODE_RAW; |  | ||||||
| #endif |  | ||||||
| 		break; |  | ||||||
| 	case BOOT_DEVICE_NAND: |  | ||||||
| 		return 0; |  | ||||||
| 		break; |  | ||||||
| 	default: |  | ||||||
| 		puts("spl: ERROR:  unsupported device\n"); |  | ||||||
| 		hang(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|  | @ -14,20 +14,3 @@ u32 spl_boot_device(void) | ||||||
| #endif | #endif | ||||||
| 	return BOOT_DEVICE_NAND; | 	return BOOT_DEVICE_NAND; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	switch (spl_boot_device()) { |  | ||||||
| 	case BOOT_DEVICE_MMC1: |  | ||||||
| #ifdef CONFIG_SPL_FAT_SUPPORT |  | ||||||
| 		return MMCSD_MODE_FS; |  | ||||||
| #else |  | ||||||
| 		return MMCSD_MODE_RAW; |  | ||||||
| #endif |  | ||||||
| 	case BOOT_DEVICE_NAND: |  | ||||||
| 		return 0; |  | ||||||
| 	default: |  | ||||||
| 		puts("spl: error: unsupported device\n"); |  | ||||||
| 		hang(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -26,23 +26,6 @@ u32 spl_boot_device(void) | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	switch (spl_boot_device()) { |  | ||||||
| 	case BOOT_DEVICE_MMC1: |  | ||||||
| #ifdef CONFIG_SPL_FAT_SUPPORT |  | ||||||
| 		return MMCSD_MODE_FS; |  | ||||||
| #else |  | ||||||
| 		return MMCSD_MODE_RAW; |  | ||||||
| #endif |  | ||||||
| 	case BOOT_DEVICE_NAND: |  | ||||||
| 		return 0; |  | ||||||
| 	default: |  | ||||||
| 		puts("spl: error: unsupported device\n"); |  | ||||||
| 		hang(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #ifdef CONFIG_SPL_BUILD | #ifdef CONFIG_SPL_BUILD | ||||||
| 
 | 
 | ||||||
| void spl_board_init(void) | void spl_board_init(void) | ||||||
|  |  | ||||||
|  | @ -115,20 +115,6 @@ u32 spl_boot_device(void) | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	switch (boot_device) { |  | ||||||
| 	case BOOT_DEVICE_RAM: |  | ||||||
| 		return 0; |  | ||||||
| 	case BOOT_DEVICE_MMC1: |  | ||||||
| 	case BOOT_DEVICE_MMC2: |  | ||||||
| 		return MMCSD_MODE_FS; |  | ||||||
| 	default: |  | ||||||
| 		puts("spl: error: unsupported device\n"); |  | ||||||
| 		hang(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #ifdef CONFIG_SPL_OS_BOOT | #ifdef CONFIG_SPL_OS_BOOT | ||||||
| int spl_start_uboot(void) | int spl_start_uboot(void) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -87,18 +87,3 @@ u32 spl_boot_device(void) | ||||||
| 	return BOOT_DEVICE_NONE; | 	return BOOT_DEVICE_NONE; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	switch (boot_device) { |  | ||||||
| #if defined(CONFIG_SYS_USE_MMC) || defined(CONFIG_SD_BOOT) |  | ||||||
| 	case BOOT_DEVICE_MMC1: |  | ||||||
| 	case BOOT_DEVICE_MMC2: |  | ||||||
| 		return MMCSD_MODE_FS; |  | ||||||
| 		break; |  | ||||||
| #endif |  | ||||||
| 	case BOOT_DEVICE_NONE: |  | ||||||
| 	default: |  | ||||||
| 		hang(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -45,11 +45,6 @@ void spl_board_init(void) | ||||||
| 	preloader_console_init(); | 	preloader_console_init(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| u32 spl_boot_device(void) | u32 spl_boot_device(void) | ||||||
| { | { | ||||||
| 	switch (davinci_syscfg_regs->bootcfg) { | 	switch (davinci_syscfg_regs->bootcfg) { | ||||||
|  |  | ||||||
|  | @ -132,29 +132,6 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if defined(CONFIG_SPL_MMC_SUPPORT) |  | ||||||
| /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	switch (spl_boot_device()) { |  | ||||||
| 	/* for MMC return either RAW or FAT mode */ |  | ||||||
| 	case BOOT_DEVICE_MMC1: |  | ||||||
| 	case BOOT_DEVICE_MMC2: |  | ||||||
| #if defined(CONFIG_SPL_FAT_SUPPORT) |  | ||||||
| 		return MMCSD_MODE_FS; |  | ||||||
| #elif defined(CONFIG_SUPPORT_EMMC_BOOT) |  | ||||||
| 		return MMCSD_MODE_EMMCBOOT; |  | ||||||
| #else |  | ||||||
| 		return MMCSD_MODE_RAW; |  | ||||||
| #endif |  | ||||||
| 		break; |  | ||||||
| 	default: |  | ||||||
| 		puts("spl: ERROR:  unsupported device\n"); |  | ||||||
| 		hang(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #if defined(CONFIG_SECURE_BOOT) | #if defined(CONFIG_SECURE_BOOT) | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  |  | ||||||
|  | @ -70,13 +70,6 @@ u32 spl_boot_device(void) | ||||||
| 	return get_boot_device(); | 	return get_boot_device(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_SPL_MMC_SUPPORT |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| void board_init_f(ulong dummy) | void board_init_f(ulong dummy) | ||||||
| { | { | ||||||
| 	int ret; | 	int ret; | ||||||
|  |  | ||||||
|  | @ -72,11 +72,6 @@ fallback: | ||||||
| 	return BOOT_DEVICE_MMC1; | 	return BOOT_DEVICE_MMC1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static int setup_arm_clock(void) | static int setup_arm_clock(void) | ||||||
| { | { | ||||||
| 	struct udevice *dev; | 	struct udevice *dev; | ||||||
|  |  | ||||||
|  | @ -78,11 +78,6 @@ fallback: | ||||||
| 	return BOOT_DEVICE_MMC1; | 	return BOOT_DEVICE_MMC1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #ifdef CONFIG_SPL_MMC_SUPPORT | #ifdef CONFIG_SPL_MMC_SUPPORT | ||||||
| static int configure_emmc(struct udevice *pinctrl) | static int configure_emmc(struct udevice *pinctrl) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -57,11 +57,6 @@ void board_init_f(ulong dummy) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| u32 spl_boot_device(void) | u32 spl_boot_device(void) | ||||||
| { | { | ||||||
| 	return BOOT_DEVICE_MMC1; | 	return BOOT_DEVICE_MMC1; | ||||||
|  |  | ||||||
|  | @ -60,11 +60,6 @@ u32 spl_boot_device(void) | ||||||
| 	return boot_device; | 	return boot_device; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #define TIMER_CHN10_BASE	0xff8680a0 | #define TIMER_CHN10_BASE	0xff8680a0 | ||||||
| #define TIMER_END_COUNT_L	0x00 | #define TIMER_END_COUNT_L	0x00 | ||||||
| #define TIMER_END_COUNT_H	0x04 | #define TIMER_END_COUNT_H	0x04 | ||||||
|  |  | ||||||
|  | @ -66,17 +66,6 @@ u32 spl_boot_device(void) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_SPL_MMC_SUPPORT |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) |  | ||||||
| 	return MMCSD_MODE_FS; |  | ||||||
| #else |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| #endif |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #if defined(CONFIG_TARGET_SOCFPGA_GEN5) | #if defined(CONFIG_TARGET_SOCFPGA_GEN5) | ||||||
| static void socfpga_nic301_slave_ns(void) | static void socfpga_nic301_slave_ns(void) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -260,12 +260,6 @@ u32 spl_boot_device(void) | ||||||
| 	return sunxi_get_boot_device(); | 	return sunxi_get_boot_device(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* No confirmation data available in SPL yet. Hardcode bootmode */ |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_RAW; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void board_init_f(ulong dummy) | void board_init_f(ulong dummy) | ||||||
| { | { | ||||||
| 	spl_init(); | 	spl_init(); | ||||||
|  |  | ||||||
|  | @ -69,13 +69,6 @@ u32 spl_boot_device(void) | ||||||
| 	return mode; | 	return mode; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_SPL_MMC_SUPPORT |  | ||||||
| u32 spl_boot_mode(const u32 boot_device) |  | ||||||
| { |  | ||||||
| 	return MMCSD_MODE_FS; |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifdef CONFIG_SPL_OS_BOOT | #ifdef CONFIG_SPL_OS_BOOT | ||||||
| int spl_start_uboot(void) | int spl_start_uboot(void) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -281,6 +281,17 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc) | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | u32 __weak spl_boot_mode(const u32 boot_device) | ||||||
|  | { | ||||||
|  | #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) | ||||||
|  | 	return MMCSD_MODE_FS; | ||||||
|  | #elif defined(CONFIG_SUPPORT_EMMC_BOOT) | ||||||
|  | 	return MMCSD_MODE_EMMCBOOT; | ||||||
|  | #else | ||||||
|  | 	return MMCSD_MODE_RAW; | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int spl_mmc_load_image(struct spl_image_info *spl_image, | int spl_mmc_load_image(struct spl_image_info *spl_image, | ||||||
| 		       struct spl_boot_device *bootdev) | 		       struct spl_boot_device *bootdev) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue