mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 18:35:42 +01:00 
			
		
		
		
	rockchip: board: Add board_rng_seed() for all Rockchip devices
Allow all rockchip devices to use the hardware RNG to seed Linux RNG. Signed-off-by: Chris Morgan <macromorgan@hotmail.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
		| @@ -320,3 +320,35 @@ __weak int misc_init_r(void) | |||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #if IS_ENABLED(CONFIG_BOARD_RNG_SEED) && IS_ENABLED(CONFIG_RNG_ROCKCHIP) | ||||||
|  | #include <rng.h> | ||||||
|  |  | ||||||
|  | /* Use hardware rng to seed Linux random. */ | ||||||
|  | __weak int board_rng_seed(struct abuf *buf) | ||||||
|  | { | ||||||
|  | 	struct udevice *dev; | ||||||
|  | 	size_t len = 0x8; | ||||||
|  | 	u64 *data; | ||||||
|  |  | ||||||
|  | 	data = malloc(len); | ||||||
|  | 	if (!data) { | ||||||
|  | 		printf("Out of memory\n"); | ||||||
|  | 		return -ENOMEM; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) { | ||||||
|  | 		printf("No RNG device\n"); | ||||||
|  | 		return -ENODEV; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if (dm_rng_read(dev, data, len)) { | ||||||
|  | 		printf("Reading RNG failed\n"); | ||||||
|  | 		return -EIO; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	abuf_init_set(buf, data, len); | ||||||
|  |  | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  | #endif | ||||||
|   | |||||||
| @@ -16,7 +16,6 @@ | |||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
| #include <panel.h> | #include <panel.h> | ||||||
| #include <pwm.h> | #include <pwm.h> | ||||||
| #include <rng.h> |  | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <video_bridge.h> | #include <video_bridge.h> | ||||||
|  |  | ||||||
| @@ -133,34 +132,6 @@ void spl_board_init(void) | |||||||
| 	       (GPIO0_BASE + GPIO_SWPORT_DR_H)); | 	       (GPIO0_BASE + GPIO_SWPORT_DR_H)); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Use hardware rng to seed Linux random. */ |  | ||||||
| int board_rng_seed(struct abuf *buf) |  | ||||||
| { |  | ||||||
| 	struct udevice *dev; |  | ||||||
| 	size_t len = 0x8; |  | ||||||
| 	u64 *data; |  | ||||||
|  |  | ||||||
| 	data = malloc(len); |  | ||||||
| 	if (!data) { |  | ||||||
| 		printf("Out of memory\n"); |  | ||||||
| 		return -ENOMEM; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) { |  | ||||||
| 		printf("No RNG device\n"); |  | ||||||
| 		return -ENODEV; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if (dm_rng_read(dev, data, len)) { |  | ||||||
| 		printf("Reading RNG failed\n"); |  | ||||||
| 		return -EIO; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	abuf_init_set(buf, data, len); |  | ||||||
|  |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Buzz the buzzer so the user knows something is going on. Make it |  * Buzz the buzzer so the user knows something is going on. Make it | ||||||
|  * optional in case PWM is disabled. |  * optional in case PWM is disabled. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user