1 /*
2  * Copyright (c) 2019, Nordic Semiconductor
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <nrfx_ipc.h>
8 
9 #define NRFX_IPC_ID_MAX_VALUE	 IPC_CONF_NUM
10 
11 /*
12  * Group IPC signals, events and channels into message channels.
13  * Message channels are one-way connections between cores.
14  *
15  * For example Message Channel 0 is configured as TX on core 0
16  * and as RX on core 1:
17  *
18  * [C0]			    [C1]
19  * SIGNAL0 -> CHANNEL0 -> EVENT0
20  *
21  * Message Channel 1 is configured as RX on core 0 and as TX
22  * on core 1:
23  * [C0]			    [C1]
24  * EVENT1 <- CHANNEL1 <- SIGNAL1
25  */
26 
27 #define IPC_EVENT_BIT(idx) \
28 	((IS_ENABLED(CONFIG_IPM_MSG_CH_##idx##_RX)) << idx)
29 
30 #define IPC_EVENT_BITS		\
31 	(			\
32 	 IPC_EVENT_BIT(0)  |	\
33 	 IPC_EVENT_BIT(1)  |	\
34 	 IPC_EVENT_BIT(2)  |	\
35 	 IPC_EVENT_BIT(3)  |	\
36 	 IPC_EVENT_BIT(4)  |	\
37 	 IPC_EVENT_BIT(5)  |	\
38 	 IPC_EVENT_BIT(6)  |	\
39 	 IPC_EVENT_BIT(7)  |	\
40 	 IPC_EVENT_BIT(8)  |	\
41 	 IPC_EVENT_BIT(9)  |	\
42 	 IPC_EVENT_BIT(10) |	\
43 	 IPC_EVENT_BIT(11) |	\
44 	 IPC_EVENT_BIT(12) |	\
45 	 IPC_EVENT_BIT(13) |	\
46 	 IPC_EVENT_BIT(14) |	\
47 	 IPC_EVENT_BIT(15)	\
48 	)
49 
50 static const nrfx_ipc_config_t ipc_cfg = {
51 	.send_task_config = {
52 		[0] = BIT(0),
53 		[1] = BIT(1),
54 		[2] = BIT(2),
55 		[3] = BIT(3),
56 		[4] = BIT(4),
57 		[5] = BIT(5),
58 		[6] = BIT(6),
59 		[7] = BIT(7),
60 		[8] = BIT(8),
61 		[9] = BIT(9),
62 		[10] = BIT(10),
63 		[11] = BIT(11),
64 		[12] = BIT(12),
65 		[13] = BIT(13),
66 		[14] = BIT(14),
67 		[15] = BIT(15),
68 	},
69 	.receive_event_config = {
70 		[0] = BIT(0),
71 		[1] = BIT(1),
72 		[2] = BIT(2),
73 		[3] = BIT(3),
74 		[4] = BIT(4),
75 		[5] = BIT(5),
76 		[6] = BIT(6),
77 		[7] = BIT(7),
78 		[8] = BIT(8),
79 		[9] = BIT(9),
80 		[10] = BIT(10),
81 		[11] = BIT(11),
82 		[12] = BIT(12),
83 		[13] = BIT(13),
84 		[14] = BIT(14),
85 		[15] = BIT(15),
86 	},
87 	.receive_events_enabled = IPC_EVENT_BITS,
88 };
89