xref: /rk3399_ARM-atf/plat/ti/k3/common/k3_bl31_setup.c (revision 52e486f6a6192bd18d36cdcbc35c59092eefc810)
1 /*
2  * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.
3  * Copyright (C) 2025 Texas Instruments Incorporated - https://www.ti.com/
4  * K3 SOC specific bl31_setup
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include <common/debug.h>
10 #include <ti_sci.h>
11 #include <ti_sci_transport.h>
12 
13 #include <plat_private.h>
14 
15 /* Table of regions to map using the MMU */
16 const mmap_region_t plat_k3_mmap[] = {
17 	K3_MAP_REGION_FLAT(K3_USART_BASE,       K3_USART_SIZE,       MT_DEVICE | MT_RW | MT_SECURE),
18 	K3_MAP_REGION_FLAT(K3_GIC_BASE,         K3_GIC_SIZE,         MT_DEVICE | MT_RW | MT_SECURE),
19 	K3_MAP_REGION_FLAT(K3_GTC_BASE,         K3_GTC_SIZE,         MT_DEVICE | MT_RW | MT_SECURE),
20 	K3_MAP_REGION_FLAT(SEC_PROXY_RT_BASE,   SEC_PROXY_RT_SIZE,   MT_DEVICE | MT_RW | MT_SECURE),
21 	K3_MAP_REGION_FLAT(SEC_PROXY_SCFG_BASE, SEC_PROXY_SCFG_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
22 	K3_MAP_REGION_FLAT(SEC_PROXY_DATA_BASE, SEC_PROXY_DATA_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
23 	{ /* sentinel */ }
24 };
25 
26 int ti_soc_init(void)
27 {
28 	struct ti_sci_msg_version version;
29 	int ret;
30 
31 	ret = ti_sci_get_revision(&version);
32 	if (ret) {
33 		ERROR("Unable to communicate with the control firmware (%d)\n", ret);
34 		return ret;
35 	}
36 
37 	INFO("SYSFW ABI: %d.%d (firmware rev 0x%04x '%s')\n",
38 	     version.abi_major, version.abi_minor,
39 	     version.firmware_revision,
40 	     version.firmware_description);
41 
42 	/*
43 	 * Older firmware have a timing issue with DM that crashes few TF-A
44 	 * lite devices while trying to make calls to DM. Since there is no way
45 	 * to detect what current DM version we are running - we rely on the
46 	 * corresponding TIFS versioning to handle this check and ensure that
47 	 * the platform boots up
48 	 *
49 	 * Upgrading to TIFS version 9.1.7 along with the corresponding DM from
50 	 * ti-linux-firmware will enable this functionality.
51 	 */
52 	if (version.firmware_revision > 9 ||
53 	    (version.firmware_revision == 9 && version.sub_version > 1) ||
54 	    (version.firmware_revision == 9 && version.sub_version == 1 &&
55 		 version.patch_version >= 7)
56 	) {
57 		if (ti_sci_device_get(PLAT_BOARD_DEVICE_ID)) {
58 			WARN("Unable to take system power reference\n");
59 		}
60 	} else {
61 		NOTICE("Upgrade Firmwares for Power off functionality\n");
62 	}
63 	return 0;
64 }
65