xref: /optee_os/core/pta/bcm/bnxt.c (revision 6ccd56ca981b48637d33926e9a2c2a8374a9ffb7)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright 2019 Broadcom.
4  */
5 
6 #include <drivers/bcm/bnxt.h>
7 #include <io.h>
8 #include <kernel/misc.h>
9 #include <kernel/pseudo_ta.h>
10 #include <mm/core_memprot.h>
11 #include <string.h>
12 #include <util.h>
13 
14 #define BNXT_SERVICE_UUID \
15 		{0x6272636D, 0x2019, 0x0716,  \
16 		{0x42, 0x43, 0x4D, 0x5F, 0x53, 0x43, 0x48, 0x49} }
17 
18 enum pta_bnxt_cmd {
19 	PTA_BNXT_FASTBOOT = 0,
20 };
21 
22 #define BNXT_TA_NAME		"pta_bnxt.ta"
23 
24 static TEE_Result create_ta(void)
25 {
26 	DMSG("create entry point for static ta \"%s\"", BNXT_TA_NAME);
27 	return TEE_SUCCESS;
28 }
29 
30 static void destroy_ta(void)
31 {
32 	DMSG("destroy entry point for static ta \"%s\"", BNXT_TA_NAME);
33 }
34 
35 static TEE_Result open_session(uint32_t param_types __unused,
36 			       TEE_Param params[4] __unused,
37 			       void **session_context __unused)
38 {
39 	DMSG("open entry point for static ta \"%s\"", BNXT_TA_NAME);
40 	return TEE_SUCCESS;
41 }
42 
43 static void close_session(void *session_context __unused)
44 {
45 	DMSG("close entry point for static ta \"%s\"", BNXT_TA_NAME);
46 }
47 
48 static TEE_Result invoke_command(void *session_context __unused,
49 				 uint32_t cmd_id,
50 				 uint32_t param_types __unused,
51 				 TEE_Param params[TEE_NUM_PARAMS] __unused)
52 {
53 	TEE_Result res = TEE_SUCCESS;
54 
55 	DMSG("command entry point[%d] for \"%s\"", cmd_id, BNXT_TA_NAME);
56 
57 	switch (cmd_id) {
58 	case PTA_BNXT_FASTBOOT:
59 		DMSG("BNXT FASTBOOT\n");
60 		if (bnxt_load_fw(1) != BNXT_SUCCESS)
61 			return TEE_ERROR_TARGET_DEAD;
62 		break;
63 	default:
64 		DMSG("%d Not supported %s\n", cmd_id, BNXT_TA_NAME);
65 		res = TEE_ERROR_NOT_SUPPORTED;
66 		break;
67 	}
68 
69 	return res;
70 }
71 
72 pseudo_ta_register(.uuid = BNXT_SERVICE_UUID,
73 		   .name = BNXT_TA_NAME,
74 		   .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM,
75 		   .create_entry_point = create_ta,
76 		   .destroy_entry_point = destroy_ta,
77 		   .open_session_entry_point = open_session,
78 		   .close_session_entry_point = close_session,
79 		   .invoke_command_entry_point = invoke_command);
80