board: stm32mp1: stboard: lock the OTP after programming
Lock the OTP used for board identification for the ST boards after programming. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Acked-by: Patrice Chotard <patrice.chotard@st.com>
This commit is contained in:
		
							parent
							
								
									7ae22d7278
								
							
						
					
					
						commit
						658fde8a36
					
				|  | @ -42,7 +42,7 @@ static int do_stboard(cmd_tbl_t *cmdtp, int flag, int argc, | ||||||
| 		      char * const argv[]) | 		      char * const argv[]) | ||||||
| { | { | ||||||
| 	int ret; | 	int ret; | ||||||
| 	u32 otp; | 	u32 otp, lock; | ||||||
| 	u8 revision; | 	u8 revision; | ||||||
| 	unsigned long board, variant, bom; | 	unsigned long board, variant, bom; | ||||||
| 	struct udevice *dev; | 	struct udevice *dev; | ||||||
|  | @ -66,11 +66,20 @@ static int do_stboard(cmd_tbl_t *cmdtp, int flag, int argc, | ||||||
| 		return CMD_RET_FAILURE; | 		return CMD_RET_FAILURE; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	ret = misc_read(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), | ||||||
|  | 			&lock, sizeof(lock)); | ||||||
|  | 	if (ret < 0) { | ||||||
|  | 		puts("LOCK read error"); | ||||||
|  | 		return CMD_RET_FAILURE; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if (argc == 0) { | 	if (argc == 0) { | ||||||
| 		if (!otp) | 		if (!otp) | ||||||
| 			puts("Board : OTP board FREE\n"); | 			puts("Board : OTP board FREE\n"); | ||||||
| 		else | 		else | ||||||
| 			display_stboard(otp); | 			display_stboard(otp); | ||||||
|  | 		printf("      OTP %d %s locked !\n", BSEC_OTP_BOARD, | ||||||
|  | 		       lock == 1 ? "" : "NOT"); | ||||||
| 		return CMD_RET_SUCCESS; | 		return CMD_RET_SUCCESS; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -129,6 +138,16 @@ static int do_stboard(cmd_tbl_t *cmdtp, int flag, int argc, | ||||||
| 		puts("BOARD programming error\n"); | 		puts("BOARD programming error\n"); | ||||||
| 		return CMD_RET_FAILURE; | 		return CMD_RET_FAILURE; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	/* write persistent lock */ | ||||||
|  | 	otp = 1; | ||||||
|  | 	ret = misc_write(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), | ||||||
|  | 			 &otp, sizeof(otp)); | ||||||
|  | 	if (ret < 0) { | ||||||
|  | 		puts("BOARD lock error\n"); | ||||||
|  | 		return CMD_RET_FAILURE; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	puts("BOARD programming done\n"); | 	puts("BOARD programming done\n"); | ||||||
| 
 | 
 | ||||||
| 	return CMD_RET_SUCCESS; | 	return CMD_RET_SUCCESS; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue