[PATCH 2/2] rockchip: rk3588: Implement checkboard() to print SoC variant
Jonas Karlman
jonas at kwiboo.se
Fri Oct 18 18:34:18 CEST 2024
Implement checkboard() to print current SoC model, e.g. one of:
SoC: RK3582 v1
SoC: RK3588 v0
SoC: RK3588 v1
SoC: RK3588S v0
SoC: RK3588S v1
SoC: RK3588S2 v1
when U-Boot proper is started.
Information about what SoC model, variant and version is read from OTP.
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
arch/arm/dts/rk3588s-u-boot.dtsi | 4 ++
arch/arm/mach-rockchip/rk3588/rk3588.c | 56 ++++++++++++++++++++++++++
configs/generic-rk3588_defconfig | 2 +-
3 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/rk3588s-u-boot.dtsi b/arch/arm/dts/rk3588s-u-boot.dtsi
index 09d8b311cec5..8880d162b11c 100644
--- a/arch/arm/dts/rk3588s-u-boot.dtsi
+++ b/arch/arm/dts/rk3588s-u-boot.dtsi
@@ -69,6 +69,10 @@
bootph-all;
};
+&otp {
+ bootph-some-ram;
+};
+
&pcfg_pull_down {
bootph-all;
};
diff --git a/arch/arm/mach-rockchip/rk3588/rk3588.c b/arch/arm/mach-rockchip/rk3588/rk3588.c
index e2dac2a5b806..6317fabd5de3 100644
--- a/arch/arm/mach-rockchip/rk3588/rk3588.c
+++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
@@ -4,6 +4,8 @@
* Copyright (c) 2022 Edgeble AI Technologies Pvt. Ltd.
*/
+#include <dm.h>
+#include <misc.h>
#include <spl.h>
#include <asm/armv8/mmu.h>
#include <asm/arch-rockchip/bootrom.h>
@@ -178,3 +180,57 @@ int arch_cpu_init(void)
return 0;
}
#endif
+
+#define RK3588_OTP_CPU_CODE_OFFSET 0x02
+#define RK3588_OTP_SPECIFICATION_OFFSET 0x06
+#define RK3588_OTP_CPU_VERSION_OFFSET 0x1c
+
+int checkboard(void)
+{
+ u8 cpu_code[2], specification, package, cpu_version;
+ struct udevice *dev;
+ char suffix[3];
+ int ret;
+
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_DRIVER_GET(rockchip_otp), &dev);
+ if (ret) {
+ debug("%s: could not find otp device, ret=%d\n", __func__, ret);
+ return 0;
+ }
+
+ /* cpu-code: SoC model, 0x35 0x82 or 0x35 0x88 */
+ ret = misc_read(dev, RK3588_OTP_CPU_CODE_OFFSET, cpu_code, 2);
+ if (ret < 0) {
+ debug("%s: could not read cpu-code, ret=%d\n", __func__, ret);
+ return 0;
+ }
+
+ /* specification: SoC variant, 0x2 for RK3588S and RK3588S2 */
+ ret = misc_read(dev, RK3588_OTP_SPECIFICATION_OFFSET, &specification, 1);
+ if (ret < 0) {
+ debug("%s: could not read specification, ret=%d\n", __func__, ret);
+ return 0;
+ }
+ /* package: likely SoC variant revision, 0x2 for RK3588S2 */
+ package = specification >> 5;
+ specification &= 0x1f;
+
+ /* cpu-version: chip version, e.g. second letter of lot number */
+ ret = misc_read(dev, RK3588_OTP_CPU_VERSION_OFFSET, &cpu_version, 1);
+ if (ret < 0) {
+ debug("%s: could not read cpu-version, ret=%d\n", __func__, ret);
+ return 0;
+ }
+ cpu_version >>= 3;
+ cpu_version &= 0x7;
+
+ suffix[0] = specification > 1 ? '@' + specification : 0;
+ suffix[1] = package > 1 ? '0' + package : 0;
+ suffix[2] = 0;
+
+ printf("SoC: RK%02x%02x%s v%u\n",
+ cpu_code[0], cpu_code[1], suffix, cpu_version);
+
+ return 0;
+}
diff --git a/configs/generic-rk3588_defconfig b/configs/generic-rk3588_defconfig
index ebe883ed5972..51e31dce3a96 100644
--- a/configs/generic-rk3588_defconfig
+++ b/configs/generic-rk3588_defconfig
@@ -18,13 +18,13 @@ CONFIG_SPL_LOAD_FIT=y
CONFIG_LEGACY_IMAGE_FORMAT=y
CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-generic.dtb"
# CONFIG_DISPLAY_CPUINFO is not set
-CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_SPL_MAX_SIZE=0x40000
CONFIG_SPL_PAD_TO=0x7f8000
# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
CONFIG_SPL_ATF=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_GPT=y
+CONFIG_CMD_MISC=y
CONFIG_CMD_MMC=y
CONFIG_CMD_ROCKUSB=y
CONFIG_CMD_USB_MASS_STORAGE=y
--
2.46.2
More information about the U-Boot
mailing list