1 /*
2  * Copyright (c) 2018, Xilinx, Inc. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /* Xilinx IPI management configuration data and macros */
8 
9 #ifndef IPI_H
10 #define IPI_H
11 
12 #include <stdint.h>
13 
14 /*********************************************************************
15  * IPI mailbox status macros
16  ********************************************************************/
17 #define IPI_MB_STATUS_IDLE		0
18 #define IPI_MB_STATUS_SEND_PENDING	1
19 #define IPI_MB_STATUS_RECV_PENDING	2
20 
21 /*********************************************************************
22  * IPI mailbox call is secure or not macros
23  ********************************************************************/
24 #define IPI_MB_CALL_NOTSECURE	0
25 #define IPI_MB_CALL_SECURE	1
26 
27 /*********************************************************************
28  * IPI secure check
29  ********************************************************************/
30 #define IPI_SECURE_MASK  0x1U
31 #define IPI_IS_SECURE(I) ((ipi_table[(I)].secure_only & \
32 			   IPI_SECURE_MASK) ? 1 : 0)
33 
34 /*********************************************************************
35  * Struct definitions
36  ********************************************************************/
37 
38 /* structure to maintain IPI configuration information */
39 struct ipi_config {
40 	unsigned int ipi_bit_mask;
41 	unsigned int ipi_reg_base;
42 	unsigned char secure_only;
43 };
44 
45 /*********************************************************************
46  * IPI APIs declarations
47  ********************************************************************/
48 
49 /* Initialize IPI configuration table */
50 void ipi_config_table_init(const struct ipi_config *ipi_table,
51 			   uint32_t total_ipi);
52 
53 /* Validate IPI mailbox access */
54 int ipi_mb_validate(uint32_t local, uint32_t remote, unsigned int is_secure);
55 
56 /* Open the IPI mailbox */
57 void ipi_mb_open(uint32_t local, uint32_t remote);
58 
59 /* Release the IPI mailbox */
60 void ipi_mb_release(uint32_t local, uint32_t remote);
61 
62 /* Enquire IPI mailbox status */
63 int ipi_mb_enquire_status(uint32_t local, uint32_t remote);
64 
65 /* Trigger notification on the IPI mailbox */
66 void ipi_mb_notify(uint32_t local, uint32_t remote, uint32_t is_blocking);
67 
68 /* Ack IPI mailbox notification */
69 void ipi_mb_ack(uint32_t local, uint32_t remote);
70 
71 /* Disable IPI mailbox notification interrupt */
72 void ipi_mb_disable_irq(uint32_t local, uint32_t remote);
73 
74 /* Enable IPI mailbox notification interrupt */
75 void ipi_mb_enable_irq(uint32_t local, uint32_t remote);
76 
77 #endif /* IPI_H */
78