From 0bdaf5c804f852fe21f6172e436524157c9f6919 Mon Sep 17 00:00:00 2001 From: Manorit Chawdhry Date: Wed, 17 Jan 2024 15:06:58 +0530 Subject: [PATCH 1/3] fix(k3): increment while reading trail bytes The trail bytes from the secure proxy driver were being overwritten, increase the count each time to not overwrite the existing data and not get the end data corrupted from secure proxy. Fixes: d76fdd33e011 ("ti: k3: drivers: Add Secure Proxy driver") Change-Id: I8e23f8b6959da886d6ab43049746f78765ae1766 Signed-off-by: Manorit Chawdhry --- plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c b/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c index 1bed229b7..fb27336e0 100644 --- a/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c +++ b/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c @@ -320,7 +320,7 @@ int k3_sec_proxy_recv(enum k3_sec_proxy_chan_id id, struct k3_sec_proxy_msg *msg i = msg->len - trail_bytes; while (trail_bytes--) { - msg->buf[i] = data_trail & 0xff; + msg->buf[i++] = data_trail & 0xff; data_trail >>= 8; } } From 73d772d87f6c5c344b326b2cc29c8f9e2648a4eb Mon Sep 17 00:00:00 2001 From: Manorit Chawdhry Date: Mon, 29 Jan 2024 12:40:54 +0530 Subject: [PATCH 2/3] refactor(ti): remove ti_sci_init function ti_sci_get_revision handles getting the firmware version and ti_sci_init is just a wrapper around it with no added benefit. Refactor the ti_sci_get_revision to give the version information and remove ti_sci_init wrapper. Change-Id: I39184af5b00bedc8b9220533f1ddac3b6672d2f1 Signed-off-by: Manorit Chawdhry --- plat/ti/k3/common/drivers/ti_sci/ti_sci.c | 41 ++++++++------------- plat/ti/k3/common/drivers/ti_sci/ti_sci.h | 44 ++++++++++++++++++----- plat/ti/k3/common/k3_bl31_setup.c | 17 +++++++-- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/plat/ti/k3/common/drivers/ti_sci/ti_sci.c b/plat/ti/k3/common/drivers/ti_sci/ti_sci.c index d04d80596..8b77050da 100644 --- a/plat/ti/k3/common/drivers/ti_sci/ti_sci.c +++ b/plat/ti/k3/common/drivers/ti_sci/ti_sci.c @@ -2,7 +2,7 @@ * Texas Instruments System Control Interface Driver * Based on Linux and U-Boot implementation * - * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ + * Copyright (C) 2018-2024 Texas Instruments Incorporated - https://www.ti.com/ * * SPDX-License-Identifier: BSD-3-Clause */ @@ -185,17 +185,20 @@ unlock: * * Updates the SCI information in the internal data structure. * + * @version: Structure containing the version info + * * Return: 0 if all goes well, else appropriate error message */ -int ti_sci_get_revision(struct ti_sci_msg_resp_version *rev_info) +int ti_sci_get_revision(struct ti_sci_msg_version *version) { + struct ti_sci_msg_resp_version rev_info; struct ti_sci_msg_hdr hdr; struct ti_sci_xfer xfer; int ret; ret = ti_sci_setup_one_xfer(TI_SCI_MSG_VERSION, 0x0, &hdr, sizeof(hdr), - rev_info, sizeof(*rev_info), + &rev_info, sizeof(rev_info), &xfer); if (ret) { ERROR("Message alloc failed (%d)\n", ret); @@ -208,6 +211,14 @@ int ti_sci_get_revision(struct ti_sci_msg_resp_version *rev_info) return ret; } + memcpy(version->firmware_description, rev_info.firmware_description, + sizeof(rev_info.firmware_description)); + version->abi_major = rev_info.abi_major; + version->abi_minor = rev_info.abi_minor; + version->firmware_revision = rev_info.firmware_revision; + version->sub_version = rev_info.sub_version; + version->patch_version = rev_info.patch_version; + return 0; } @@ -1729,27 +1740,3 @@ int ti_sci_enter_sleep(uint8_t proc_id, return 0; } - -/** - * ti_sci_init() - Basic initialization - * - * Return: 0 if all goes well, else appropriate error message - */ -int ti_sci_init(void) -{ - struct ti_sci_msg_resp_version rev_info; - int ret; - - ret = ti_sci_get_revision(&rev_info); - if (ret) { - ERROR("Unable to communicate with control firmware (%d)\n", ret); - return ret; - } - - INFO("SYSFW ABI: %d.%d (firmware rev 0x%04x '%s')\n", - rev_info.abi_major, rev_info.abi_minor, - rev_info.firmware_revision, - rev_info.firmware_description); - - return 0; -} diff --git a/plat/ti/k3/common/drivers/ti_sci/ti_sci.h b/plat/ti/k3/common/drivers/ti_sci/ti_sci.h index c702a711f..acaca4d04 100644 --- a/plat/ti/k3/common/drivers/ti_sci/ti_sci.h +++ b/plat/ti/k3/common/drivers/ti_sci/ti_sci.h @@ -2,7 +2,7 @@ * Texas Instruments System Control Interface API * Based on Linux and U-Boot implementation * - * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ + * Copyright (C) 2018-2024 Texas Instruments Incorporated - https://www.ti.com/ * * SPDX-License-Identifier: BSD-3-Clause */ @@ -13,6 +13,41 @@ #include #include +/** + * User exported structures. + * + * The structures in ti_sci_protocol.h are used by the internal drivers. + * These are the structures that are exported for outside use and populated + * by the internal drivers. + * + * struct ti_sci_msg_version - Structure containing version info + * + * @firmware_description: String describing the firmware + * @firmware_revision: Firmware revision + * @abi_major: Major version of the ABI that firmware supports + * @abi_minor: Minor version of the ABI that firmware supports + * @sub_version: Sub-version number of the firmware + * @patch_version: Patch-version number of the firmware. + */ +struct ti_sci_msg_version { +#define FIRMWARE_DESCRIPTION_LENGTH 32 + char firmware_description[FIRMWARE_DESCRIPTION_LENGTH]; + uint16_t firmware_revision; + uint8_t abi_major; + uint8_t abi_minor; + uint8_t sub_version; + uint8_t patch_version; +}; + +/** + * General Message + * + * ti_sci_get_revision - Get the revision of the SCI entity + * @version: Structure containing the version info + * + **/ +int ti_sci_get_revision(struct ti_sci_msg_version *version); + /** * Device control operations * @@ -225,11 +260,4 @@ int ti_sci_enter_sleep(uint8_t proc_id, uint8_t mode, uint64_t core_resume_addr); -/** - * ti_sci_init() - Basic initialization - * - * Return: 0 if all goes good, else appropriate error message. - */ -int ti_sci_init(void); - #endif /* TI_SCI_H */ diff --git a/plat/ti/k3/common/k3_bl31_setup.c b/plat/ti/k3/common/k3_bl31_setup.c index c5f60feea..97a416f01 100644 --- a/plat/ti/k3/common/k3_bl31_setup.c +++ b/plat/ti/k3/common/k3_bl31_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -119,10 +119,23 @@ void bl31_plat_arch_setup(void) void bl31_platform_setup(void) { + struct ti_sci_msg_version version; + int ret; + k3_gic_driver_init(K3_GIC_BASE); k3_gic_init(); - ti_sci_init(); + ret = ti_sci_get_revision(&version); + if (ret) { + ERROR("Unable to communicate with the control firmware (%d)\n", ret); + return; + } + + INFO("SYSFW ABI: %d.%d (firmware rev 0x%04x '%s')\n", + version.abi_major, version.abi_minor, + version.firmware_revision, + version.firmware_description); + } void platform_mem_init(void) From a53d137753e900a27f387dd940dbe9ea791eb6e7 Mon Sep 17 00:00:00 2001 From: Manorit Chawdhry Date: Mon, 29 Jan 2024 17:36:49 +0530 Subject: [PATCH 3/3] Revert "fix(ti): do not take system power reference in bl31_platform_setup()" The workaround that we required to get over the timing issue with our Device Manager is fixed in [0], revert the workaround as it is no longer required. [0]: https://git.ti.com/cgit/processor-firmware/ti-linux-firmware/commit?id=9ad862b528112f7bc26d80668fbb9b38521cddf9 This reverts commit 9977948112d732935362a3fe8518e3b2e4b7f6b7. It also adds a check to make this backward compatible. Change-Id: Icf10f9df9558de1ae7ba6f5f586485111aac4f8d Signed-off-by: Manorit Chawdhry --- plat/ti/k3/common/k3_bl31_setup.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plat/ti/k3/common/k3_bl31_setup.c b/plat/ti/k3/common/k3_bl31_setup.c index 97a416f01..63fe02065 100644 --- a/plat/ti/k3/common/k3_bl31_setup.c +++ b/plat/ti/k3/common/k3_bl31_setup.c @@ -136,6 +136,27 @@ void bl31_platform_setup(void) version.firmware_revision, version.firmware_description); + /* + * Older firmware have a timing issue with DM that crashes few TF-A + * lite devices while trying to make calls to DM. Since there is no way + * to detect what current DM version we are running - we rely on the + * corresponding TIFS versioning to handle this check and ensure that + * the platform boots up + * + * Upgrading to TIFS version 9.1.7 along with the corresponding DM from + * ti-linux-firmware will enable this functionality. + */ + if (version.firmware_revision > 9 || + (version.firmware_revision == 9 && version.sub_version > 1) || + (version.firmware_revision == 9 && version.sub_version == 1 && + version.patch_version >= 7) + ) { + if (ti_sci_device_get(PLAT_BOARD_DEVICE_ID)) { + WARN("Unable to take system power reference\n"); + } + } else { + NOTICE("Upgrade Firmwares for Power off functionality\n"); + } } void platform_mem_init(void)