1 /*!
2 * Copyright 2021-2025 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include "fsl_common.h"
8 #include "fsl_adapter_rpmsg.h"
9 #include "fwk_platform.h"
10 #include "fwk_platform_ics.h"
11 #include "fwk_platform_ot.h"
12
13 /* Check if __st is negative, if true, apply 4 bits shit and add new __error_code,
14 assert in debug and break
15 Shall be called in a do while(0) bracket */
16 #define CHECK_AND_RAISE_ERROR(__st, __error_code) \
17 { \
18 if ((__st) < 0) \
19 { \
20 assert(0); \
21 (__st) = -(int)((uint32_t)(((uint32_t)(-(__st)) << 4) | (uint32_t)(-(__error_code)))); \
22 break; \
23 } \
24 }
25
26 /* Raise error with status update , shift previous status by 4 bits and OR with new error code.
27 * the returned status will be negative */
28 #define RAISE_ERROR(__st, __error_code) -(int)((uint32_t)(((uint32_t)(__st) << 4) | (uint32_t)(__error_code)));
29
PLATFORM_InitOT(void)30 int PLATFORM_InitOT(void)
31 {
32 int status = 0;
33
34 do
35 {
36 #if USE_NBU
37 /* Init NBU domain and configure RFMC module
38 * CM3 is still in reset and will be released by MCMGR_StartCore during RPMSG init */
39 status = PLATFORM_InitNbu();
40 CHECK_AND_RAISE_ERROR(status, -2);
41
42 /* Init of the multicore*/
43 status = PLATFORM_InitMulticore();
44 CHECK_AND_RAISE_ERROR(status, -3);
45
46 /* Initialize PLatform Service intercore channel
47 * Used to retrieve NBU version information but not retricted to this sole use.
48 */
49 status = PLATFORM_FwkSrvInit();
50 CHECK_AND_RAISE_ERROR(status, -5);
51 #endif
52
53 #if USE_NBU
54 /* Send chip revision (A0 or A1) to NBU */
55 status = PLATFORM_SendChipRevision();
56 CHECK_AND_RAISE_ERROR(status, -6);
57 #endif
58
59 } while (false);
60
61 return status;
62 }
63