Patrick Delaunay | 2f6030a | 2024-01-15 15:05:49 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (C) 2024, STMicroelectronics - All Rights Reserved |
| 4 | */ |
| 5 | |
| 6 | #include <env.h> |
Patrice Chotard | 539fec3 | 2024-01-15 15:05:50 +0100 | [diff] [blame^] | 7 | #include <misc.h> |
Patrick Delaunay | 2f6030a | 2024-01-15 15:05:49 +0100 | [diff] [blame] | 8 | #include <asm/arch/sys_proto.h> |
| 9 | #include <dm/device.h> |
Patrice Chotard | 539fec3 | 2024-01-15 15:05:50 +0100 | [diff] [blame^] | 10 | #include <dm/uclass.h> |
Patrick Delaunay | 2f6030a | 2024-01-15 15:05:49 +0100 | [diff] [blame] | 11 | |
| 12 | /* used when CONFIG_DISPLAY_CPUINFO is activated */ |
| 13 | int print_cpuinfo(void) |
| 14 | { |
| 15 | char name[SOC_NAME_SIZE]; |
| 16 | |
| 17 | get_soc_name(name); |
| 18 | printf("CPU: %s\n", name); |
| 19 | |
| 20 | return 0; |
| 21 | } |
Patrice Chotard | 539fec3 | 2024-01-15 15:05:50 +0100 | [diff] [blame^] | 22 | |
| 23 | int setup_serial_number(void) |
| 24 | { |
| 25 | char serial_string[25]; |
| 26 | u32 otp[3] = {0, 0, 0 }; |
| 27 | struct udevice *dev; |
| 28 | int ret; |
| 29 | |
| 30 | if (env_get("serial#")) |
| 31 | return 0; |
| 32 | |
| 33 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
| 34 | DM_DRIVER_GET(stm32mp_bsec), |
| 35 | &dev); |
| 36 | if (ret) |
| 37 | return ret; |
| 38 | |
| 39 | ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL), |
| 40 | otp, sizeof(otp)); |
| 41 | if (ret < 0) |
| 42 | return ret; |
| 43 | |
| 44 | sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]); |
| 45 | env_set("serial#", serial_string); |
| 46 | |
| 47 | return 0; |
| 48 | } |