1 // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
3 * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
6 #define LOG_CATEGORY LOGC_ARCH
12 #include <asm/arch/stm32.h>
13 #include <asm/arch/sys_proto.h>
16 #define SYSCFG_IDC_OFFSET 0x380
17 #define SYSCFG_IDC_DEV_ID_MASK GENMASK(11, 0)
18 #define SYSCFG_IDC_DEV_ID_SHIFT 0
19 #define SYSCFG_IDC_REV_ID_MASK GENMASK(31, 16)
20 #define SYSCFG_IDC_REV_ID_SHIFT 16
22 /* Device Part Number (RPN) = OTP_DATA1 lower 11 bits */
24 #define RPN_MASK GENMASK(11, 0)
26 static u32 read_idc(void)
28 void *syscfg = syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
30 return readl(syscfg + SYSCFG_IDC_OFFSET);
35 return (read_idc() & SYSCFG_IDC_DEV_ID_MASK) >> SYSCFG_IDC_DEV_ID_SHIFT;
40 return (read_idc() & SYSCFG_IDC_REV_ID_MASK) >> SYSCFG_IDC_REV_ID_SHIFT;
43 /* Get Device Part Number (RPN) from OTP */
44 static u32 get_cpu_rpn(void)
46 return get_otp(BSEC_OTP_RPN, RPN_SHIFT, RPN_MASK);
49 u32 get_cpu_type(void)
51 return (get_cpu_dev() << 16) | get_cpu_rpn();
58 switch (get_cpu_type()) {
59 case CPU_STM32MP131Dxx:
61 case CPU_STM32MP131Cxx:
63 case CPU_STM32MP131Axx:
74 void get_soc_name(char name[SOC_NAME_SIZE])
78 /* MPUs Part Numbers */
79 switch (get_cpu_type()) {
80 case CPU_STM32MP135Fxx:
83 case CPU_STM32MP135Dxx:
86 case CPU_STM32MP135Cxx:
89 case CPU_STM32MP135Axx:
92 case CPU_STM32MP133Fxx:
95 case CPU_STM32MP133Dxx:
98 case CPU_STM32MP133Cxx:
101 case CPU_STM32MP133Axx:
104 case CPU_STM32MP131Fxx:
107 case CPU_STM32MP131Dxx:
110 case CPU_STM32MP131Cxx:
113 case CPU_STM32MP131Axx:
122 switch (get_cpu_rev()) {
137 snprintf(name, SOC_NAME_SIZE, "STM32MP%s Rev.%s", cpu_s, cpu_r);