From: Andrew Davis <afd@ti.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
<u-boot@lists.denx.de>
Cc: Andrew Davis <afd@ti.com>
Subject: [PATCH 1/4] arm: mach-k3: Add support for device type detection
Date: Fri, 15 Jul 2022 11:34:32 -0500 [thread overview]
Message-ID: <20220715163435.1725-1-afd@ti.com> (raw)
K3 SoCs are available in a number of device types such as
GP, HS-FS, EMU, etc. Like OMAP SoCs we can detect this at runtime
and should print this out as part of the SoC information line.
We add this as part of the common.c file as it will be used
to also modify our security state early in the device boot.
Signed-off-by: Andrew Davis <afd@ti.com>
---
arch/arm/mach-k3/common.c | 51 +++++++++++++++++++++++-
arch/arm/mach-k3/common.h | 10 +++++
arch/arm/mach-k3/include/mach/hardware.h | 10 +++++
3 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 70f6444e79..ac14975694 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -396,7 +396,54 @@ void reset_cpu(void)
}
#endif
+enum k3_device_type get_device_type(void)
+{
+ u32 sys_status = readl(K3_SEC_MGR_SYS_STATUS);
+
+ u32 sys_dev_type = (sys_status & SYS_STATUS_DEV_TYPE_MASK) >>
+ SYS_STATUS_DEV_TYPE_SHIFT;
+
+ u32 sys_sub_type = (sys_status & SYS_STATUS_SUB_TYPE_MASK) >>
+ SYS_STATUS_SUB_TYPE_SHIFT;
+
+ switch (sys_dev_type) {
+ case SYS_STATUS_DEV_TYPE_GP:
+ return K3_DEVICE_TYPE_GP;
+ case SYS_STATUS_DEV_TYPE_TEST:
+ return K3_DEVICE_TYPE_TEST;
+ case SYS_STATUS_DEV_TYPE_EMU:
+ return K3_DEVICE_TYPE_EMU;
+ case SYS_STATUS_DEV_TYPE_HS:
+ if (sys_sub_type == SYS_STATUS_SUB_TYPE_VAL_FS)
+ return K3_DEVICE_TYPE_HS_FS;
+ else
+ return K3_DEVICE_TYPE_HS_SE;
+ default:
+ return K3_DEVICE_TYPE_BAD;
+ }
+}
+
#if defined(CONFIG_DISPLAY_CPUINFO)
+static const char *get_device_type_name(void)
+{
+ enum k3_device_type type = get_device_type();
+
+ switch (type) {
+ case K3_DEVICE_TYPE_GP:
+ return "GP";
+ case K3_DEVICE_TYPE_TEST:
+ return "TEST";
+ case K3_DEVICE_TYPE_EMU:
+ return "EMU";
+ case K3_DEVICE_TYPE_HS_FS:
+ return "HS-FS";
+ case K3_DEVICE_TYPE_HS_SE:
+ return "HS-SE";
+ default:
+ return "BAD";
+ }
+}
+
int print_cpuinfo(void)
{
struct udevice *soc;
@@ -418,9 +465,11 @@ int print_cpuinfo(void)
ret = soc_get_revision(soc, name, 64);
if (!ret) {
- printf("%s\n", name);
+ printf("%s ", name);
}
+ printf("%s\n", get_device_type_name());
+
return 0;
}
#endif
diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h
index e81b70d7c3..8f38fcef7f 100644
--- a/arch/arm/mach-k3/common.h
+++ b/arch/arm/mach-k3/common.h
@@ -18,6 +18,15 @@ struct fwl_data {
u16 regions;
};
+enum k3_device_type {
+ K3_DEVICE_TYPE_BAD,
+ K3_DEVICE_TYPE_GP,
+ K3_DEVICE_TYPE_TEST,
+ K3_DEVICE_TYPE_EMU,
+ K3_DEVICE_TYPE_HS_FS,
+ K3_DEVICE_TYPE_HS_SE,
+};
+
void setup_k3_mpu_regions(void);
int early_console_init(void);
void disable_linefill_optimization(void);
@@ -27,4 +36,5 @@ void k3_sysfw_print_ver(void);
void spl_enable_dcache(void);
void mmr_unlock(phys_addr_t base, u32 partition);
bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data);
+enum k3_device_type get_device_type(void);
void ti_secure_image_post_process(void **p_image, size_t *p_size);
diff --git a/arch/arm/mach-k3/include/mach/hardware.h b/arch/arm/mach-k3/include/mach/hardware.h
index 7c6928d5da..73dc2d2d98 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -32,6 +32,16 @@
#define JTAG_ID_VARIANT_MASK (0xf << 28)
#define JTAG_ID_PARTNO_SHIFT 12
#define JTAG_ID_PARTNO_MASK (0xffff << 12)
+#define K3_SEC_MGR_SYS_STATUS 0x44234100
+#define SYS_STATUS_DEV_TYPE_SHIFT 0
+#define SYS_STATUS_DEV_TYPE_MASK (0xf)
+#define SYS_STATUS_DEV_TYPE_GP 0x3
+#define SYS_STATUS_DEV_TYPE_TEST 0x5
+#define SYS_STATUS_DEV_TYPE_EMU 0x9
+#define SYS_STATUS_DEV_TYPE_HS 0xa
+#define SYS_STATUS_SUB_TYPE_SHIFT 8
+#define SYS_STATUS_SUB_TYPE_MASK (0xf << 8)
+#define SYS_STATUS_SUB_TYPE_VAL_FS 0xa
#define K3_ROM_BOOT_HEADER_MAGIC "EXTBOOT"
--
2.36.1
next reply other threads:[~2022-07-15 16:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 16:34 Andrew Davis [this message]
2022-07-15 16:34 ` [PATCH 2/4] arm: mach-k3: security: Allow signing bypass if type is HS-FS Andrew Davis
2022-08-04 20:52 ` Tom Rini
2022-07-15 16:34 ` [PATCH 3/4] arm: mach-k3: security: Bypass image signing at runtime for GP devices Andrew Davis
2022-08-04 20:52 ` Tom Rini
2022-07-15 16:34 ` [PATCH 4/4] arm: mach-k3: security: Remove certificate if detected on GP device Andrew Davis
2022-07-18 12:08 ` Tom Rini
2022-08-04 20:52 ` Tom Rini
2022-07-18 12:08 ` [PATCH 1/4] arm: mach-k3: Add support for device type detection Tom Rini
2022-07-25 16:57 ` Tom Rini
2022-07-26 1:29 ` Andrew Davis
2022-08-04 20:51 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220715163435.1725-1-afd@ti.com \
--to=afd@ti.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox