mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-27 08:33:10 +01:00 
			
		
		
		
	SATA: do not auto-initialize during boot
Rather than have the board code initialize SATA automatically during boot, make the user manually run "sata init". This brings the SATA subsystem in line with common U-Boot policy. Rather than having a dedicated weak function "is_sata_supported", people can override sata_initialize() to do their weird board stuff. Then they can call the actual __sata_initialize(). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
		
				
					committed by
					
						 Wolfgang Denk
						Wolfgang Denk
					
				
			
			
				
	
			
			
			
						parent
						
							5097083971
						
					
				
				
					commit
					cf7e399fb3
				
			| @@ -582,15 +582,15 @@ get_board_ddr_clk(ulong dummy) | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| int is_sata_supported(void) | int sata_initialize(void) | ||||||
| { | { | ||||||
| 	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); | 	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); | ||||||
| 	uint sdrs2_io_sel = | 	uint sdrs2_io_sel = | ||||||
| 		(gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27; | 		(gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27; | ||||||
| 	if (sdrs2_io_sel & 0x04) | 	if (sdrs2_io_sel & 0x04) | ||||||
| 		return 0; | 		return 1; | ||||||
|  |  | ||||||
| 	return 1; | 	return __sata_initialize(); | ||||||
| } | } | ||||||
|  |  | ||||||
| int board_eth_init(bd_t *bis) | int board_eth_init(bd_t *bis) | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ | |||||||
| int curr_device = -1; | int curr_device = -1; | ||||||
| block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; | block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; | ||||||
|  |  | ||||||
| int sata_initialize(void) | int __sata_initialize(void) | ||||||
| { | { | ||||||
| 	int rc; | 	int rc; | ||||||
| 	int i; | 	int i; | ||||||
| @@ -55,6 +55,7 @@ int sata_initialize(void) | |||||||
| 	curr_device = 0; | 	curr_device = 0; | ||||||
| 	return rc; | 	return rc; | ||||||
| } | } | ||||||
|  | int sata_initialize(void) __attribute__((weak,alias("__sata_initialize"))); | ||||||
|  |  | ||||||
| block_dev_desc_t *sata_get_dev(int dev) | block_dev_desc_t *sata_get_dev(int dev) | ||||||
| { | { | ||||||
| @@ -65,6 +66,14 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |||||||
| { | { | ||||||
| 	int rc = 0; | 	int rc = 0; | ||||||
|  |  | ||||||
|  | 	if (argc == 2 && strcmp(argv[1], "init") == 0) | ||||||
|  | 		return sata_initialize(); | ||||||
|  |  | ||||||
|  | 	/* If the user has not yet run `sata init`, do it now */ | ||||||
|  | 	if (curr_device == -1) | ||||||
|  | 		if (sata_initialize()) | ||||||
|  | 			return 1; | ||||||
|  |  | ||||||
| 	switch (argc) { | 	switch (argc) { | ||||||
| 	case 0: | 	case 0: | ||||||
| 	case 1: | 	case 1: | ||||||
| @@ -186,6 +195,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) | |||||||
| U_BOOT_CMD( | U_BOOT_CMD( | ||||||
| 	sata, 5, 1, do_sata, | 	sata, 5, 1, do_sata, | ||||||
| 	"sata	- SATA sub system\n", | 	"sata	- SATA sub system\n", | ||||||
|  | 	"init - init SATA sub system\n" | ||||||
| 	"sata info - show available SATA devices\n" | 	"sata info - show available SATA devices\n" | ||||||
| 	"sata device [dev] - show or set current device\n" | 	"sata device [dev] - show or set current device\n" | ||||||
| 	"sata part [dev] - print partition table\n" | 	"sata part [dev] - print partition table\n" | ||||||
|   | |||||||
| @@ -7,5 +7,6 @@ ulong sata_read(int dev, ulong blknr, ulong blkcnt, void *buffer); | |||||||
| ulong sata_write(int dev, ulong blknr, ulong blkcnt, const void *buffer); | ulong sata_write(int dev, ulong blknr, ulong blkcnt, const void *buffer); | ||||||
|  |  | ||||||
| int sata_initialize(void); | int sata_initialize(void); | ||||||
|  | int __sata_initialize(void); | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -38,9 +38,6 @@ | |||||||
| #if defined(CONFIG_CMD_IDE) | #if defined(CONFIG_CMD_IDE) | ||||||
| #include <ide.h> | #include <ide.h> | ||||||
| #endif | #endif | ||||||
| #if defined(CONFIG_CMD_SATA) |  | ||||||
| #include <sata.h> |  | ||||||
| #endif |  | ||||||
| #if defined(CONFIG_CMD_SCSI) | #if defined(CONFIG_CMD_SCSI) | ||||||
| #include <scsi.h> | #include <scsi.h> | ||||||
| #endif | #endif | ||||||
| @@ -639,16 +636,6 @@ void board_init_f (ulong bootflag) | |||||||
| 	/* NOTREACHED - relocate_code() does not return */ | 	/* NOTREACHED - relocate_code() does not return */ | ||||||
| } | } | ||||||
|  |  | ||||||
| int __is_sata_supported(void) |  | ||||||
| { |  | ||||||
| 	/* For some boards, when sata disabled by the switch, and the |  | ||||||
| 	 * driver still access the sata registers, the cpu will hangup. |  | ||||||
| 	 * please define platform specific is_sata_supported() if your |  | ||||||
| 	 * board have such issue.*/ |  | ||||||
| 	return 1; |  | ||||||
| } |  | ||||||
| int is_sata_supported(void) __attribute__((weak, alias("__is_sata_supported"))); |  | ||||||
|  |  | ||||||
| /************************************************************************ | /************************************************************************ | ||||||
|  * |  * | ||||||
|  * This is the next part if the initialization sequence: we are now |  * This is the next part if the initialization sequence: we are now | ||||||
| @@ -1152,13 +1139,6 @@ void board_init_r (gd_t *id, ulong dest_addr) | |||||||
| #endif | #endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(CONFIG_CMD_SATA) |  | ||||||
| 	if (is_sata_supported()) { |  | ||||||
| 		puts("SATA:  "); |  | ||||||
| 		sata_initialize(); |  | ||||||
| 	} |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef CONFIG_LAST_STAGE_INIT | #ifdef CONFIG_LAST_STAGE_INIT | ||||||
| 	WATCHDOG_RESET (); | 	WATCHDOG_RESET (); | ||||||
| 	/* | 	/* | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user