blob: ff70ebe974644712cffc7c7f831290af8ec45f12 [file] [log] [blame]
Patrick Delaunay2f6030a2024-01-15 15:05:49 +01001// 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 Chotard539fec32024-01-15 15:05:50 +01007#include <misc.h>
Patrick Delaunay2f6030a2024-01-15 15:05:49 +01008#include <asm/arch/sys_proto.h>
9#include <dm/device.h>
Patrice Chotard539fec32024-01-15 15:05:50 +010010#include <dm/uclass.h>
Patrick Delaunay2f6030a2024-01-15 15:05:49 +010011
12/* used when CONFIG_DISPLAY_CPUINFO is activated */
13int 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 Chotard539fec32024-01-15 15:05:50 +010022
23int 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}