summaryrefslogtreecommitdiff
path: root/arch/arm/mach-imx/imx9/misc.c
blob: 3cad67aed43718fa7bd0c4aa807ae9a5af570fa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2023-2026 NXP
 *
 */

#include <command.h>
#include <cpu_func.h>
#include <init.h>
#include <log.h>
#include <asm/io.h>
#include <errno.h>
#include <linux/bitops.h>
#include <asm/arch-imx/cpu.h>
#include <asm/mach-imx/ele_api.h>
#include <asm/arch/sys_proto.h>
#include <linux/delay.h>
#include <linux/sizes.h>
#include <display_options.h>

static int do_v2x_status(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
	int ret;
	u32 resp = 0;
	struct v2x_get_state state;

	if (is_imx91() || is_imx93()) {
		printf("No V2X supported\n");
		return CMD_RET_FAILURE;
	}

	ret = ele_v2x_get_state(&state, &resp);
	if (ret) {
		printf("get v2x state failed, resp 0x%x, ret %d\n", resp, ret);
		return CMD_RET_FAILURE;
	}

	printf("V2X state: 0x%x\n", state.v2x_state);
	printf("V2X power state: 0x%x\n", state.v2x_power_state);
	printf("V2X err code: 0x%x\n", state.v2x_err_code);

	return CMD_RET_SUCCESS;
}

static int do_ele_info(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
	int ret;
	u32 res = 0, length;
	struct ele_get_info_data *info;

	/* ELE can't access full DDR */
	info = (struct ele_get_info_data *)(CONFIG_TEXT_BASE + SZ_2M -
		sizeof(struct ele_get_info_data));
	flush_dcache_range((ulong)info, (ulong)info + sizeof(struct ele_get_info_data));

	ret = ele_get_info(info, &res);
	if (ret) {
		printf("Get ELE info failed, resp 0x%x, ret %d\n", res, ret);
		return CMD_RET_FAILURE;
	}

	invalidate_dcache_range((ulong)info, (ulong)info + sizeof(struct ele_get_info_data));

	printf("SOC: 0x%x\n", info->soc);
	printf("LC: 0x%x\n", info->lc);

	printf("\nUID:\n");
	print_buffer(0, &info->uid, 4, 4, 0);

	printf("\nSHA256 ROM PATCH:\n");
	print_buffer(0, &info->sha256_rom_patch, 4, 8, 0);

	printf("\nSHA FW:\n");
	print_buffer(0, &info->sha_fw, 4, 8, 0);

	printf("\nOEM SRKH:\n");
	print_buffer(0, &info->oem_srkh, 4, 16, 0);

	printf("\nSTATE: 0x%x\n", info->state);

	length = (info->hdr >> 16) & 0xffff;
	if (length == sizeof(struct ele_get_info_data)) {
		printf("\nOEM PQC SRKH:\n");
		print_buffer(0, &info->oem_pqc_srkh, 4, 16, 0);
	}

	return CMD_RET_SUCCESS;
}

U_BOOT_CMD(v2x_status, CONFIG_SYS_MAXARGS, 1, do_v2x_status,
	   "display v2x status",
	   ""
);

U_BOOT_CMD(ele_info, CONFIG_SYS_MAXARGS, 1, do_ele_info,
	   "display ELE information",
	   ""
);