1 /* 2 * Copyright (c) 2021-2022 HPMicro 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 9 #ifndef HPM_MBX_H 10 #define HPM_MBX_H 11 12 typedef struct { 13 __RW uint32_t CR; /* 0x0: Command Registers */ 14 __RW uint32_t SR; /* 0x4: Status Registers */ 15 __W uint32_t TXREG; /* 0x8: Transmit word message to other core. */ 16 __R uint32_t RXREG; /* 0xC: Receive word message from other core. */ 17 __W uint32_t TXWRD[1]; /* 0x10: TXFIFO for sending message to other core */ 18 __R uint8_t RESERVED0[12]; /* 0x14 - 0x1F: Reserved */ 19 __R uint32_t RXWRD[1]; /* 0x20: RXFIFO for receiving message from other core */ 20 } MBX_Type; 21 22 23 /* Bitfield definition for register: CR */ 24 /* 25 * TXRESET (RW) 26 * 27 * Reset TX Fifo and word. 28 */ 29 #define MBX_CR_TXRESET_MASK (0x80000000UL) 30 #define MBX_CR_TXRESET_SHIFT (31U) 31 #define MBX_CR_TXRESET_SET(x) (((uint32_t)(x) << MBX_CR_TXRESET_SHIFT) & MBX_CR_TXRESET_MASK) 32 #define MBX_CR_TXRESET_GET(x) (((uint32_t)(x) & MBX_CR_TXRESET_MASK) >> MBX_CR_TXRESET_SHIFT) 33 34 /* 35 * BARCTL (RW) 36 * 37 * Bus Acccess Response Control, when bit 15:14= 38 * 00: no bus error will be generated, no wait for fifo write when fifo full and no wait for word/fifo read when word message invalid or fifo empty; or when write to word/fifo message will be ignored. 39 * 01: bus error will be generated when: 1, access invalid address; 2, write to ready only addr; 3, write to fulled fifo or valid message; 4, read from a emptied fifo/word message. 40 * 10: no error will be generated, but bus will wait when 1, write to fulled fifo/reg message; 2, read from a emptied fifo/reg message; write to word message will overwrite the existing reg value enven word message are still valid; read from invalid word message will read out last read out message data.happen. 41 * 11: reserved. 42 */ 43 #define MBX_CR_BARCTL_MASK (0xC000U) 44 #define MBX_CR_BARCTL_SHIFT (14U) 45 #define MBX_CR_BARCTL_SET(x) (((uint32_t)(x) << MBX_CR_BARCTL_SHIFT) & MBX_CR_BARCTL_MASK) 46 #define MBX_CR_BARCTL_GET(x) (((uint32_t)(x) & MBX_CR_BARCTL_MASK) >> MBX_CR_BARCTL_SHIFT) 47 48 /* 49 * BEIE (RW) 50 * 51 * Bus Error Interrupt Enable, will enable the interrupt for any bus error as described in the SR bit 13 to bit 8. 52 * 1, enable the bus access error interrupt. 53 * 0, disable the bus access error interrupt. 54 */ 55 #define MBX_CR_BEIE_MASK (0x100U) 56 #define MBX_CR_BEIE_SHIFT (8U) 57 #define MBX_CR_BEIE_SET(x) (((uint32_t)(x) << MBX_CR_BEIE_SHIFT) & MBX_CR_BEIE_MASK) 58 #define MBX_CR_BEIE_GET(x) (((uint32_t)(x) & MBX_CR_BEIE_MASK) >> MBX_CR_BEIE_SHIFT) 59 60 /* 61 * TFMAIE (RW) 62 * 63 * TX FIFO message available interrupt enable. 64 * 1, enable the TX FIFO massage available interrupt. 65 * 0, disable the TX FIFO message available interrupt. 66 */ 67 #define MBX_CR_TFMAIE_MASK (0x80U) 68 #define MBX_CR_TFMAIE_SHIFT (7U) 69 #define MBX_CR_TFMAIE_SET(x) (((uint32_t)(x) << MBX_CR_TFMAIE_SHIFT) & MBX_CR_TFMAIE_MASK) 70 #define MBX_CR_TFMAIE_GET(x) (((uint32_t)(x) & MBX_CR_TFMAIE_MASK) >> MBX_CR_TFMAIE_SHIFT) 71 72 /* 73 * TFMEIE (RW) 74 * 75 * TX FIFO message empty interrupt enable. 76 * 1, enable the TX FIFO massage empty interrupt. 77 * 0, disable the TX FIFO message empty interrupt. 78 */ 79 #define MBX_CR_TFMEIE_MASK (0x40U) 80 #define MBX_CR_TFMEIE_SHIFT (6U) 81 #define MBX_CR_TFMEIE_SET(x) (((uint32_t)(x) << MBX_CR_TFMEIE_SHIFT) & MBX_CR_TFMEIE_MASK) 82 #define MBX_CR_TFMEIE_GET(x) (((uint32_t)(x) & MBX_CR_TFMEIE_MASK) >> MBX_CR_TFMEIE_SHIFT) 83 84 /* 85 * RFMAIE (RW) 86 * 87 * RX FIFO message available interrupt enable. 88 * 1, enable the RX FIFO massage available interrupt. 89 * 0, disable the RX FIFO message available interrupt. 90 */ 91 #define MBX_CR_RFMAIE_MASK (0x20U) 92 #define MBX_CR_RFMAIE_SHIFT (5U) 93 #define MBX_CR_RFMAIE_SET(x) (((uint32_t)(x) << MBX_CR_RFMAIE_SHIFT) & MBX_CR_RFMAIE_MASK) 94 #define MBX_CR_RFMAIE_GET(x) (((uint32_t)(x) & MBX_CR_RFMAIE_MASK) >> MBX_CR_RFMAIE_SHIFT) 95 96 /* 97 * RFMFIE (RW) 98 * 99 * RX fifo message full interrupt enable. 100 * 1, enable the RX fifo message full interrupt. 101 * 0, disable the RX fifo message full interrupt. 102 */ 103 #define MBX_CR_RFMFIE_MASK (0x10U) 104 #define MBX_CR_RFMFIE_SHIFT (4U) 105 #define MBX_CR_RFMFIE_SET(x) (((uint32_t)(x) << MBX_CR_RFMFIE_SHIFT) & MBX_CR_RFMFIE_MASK) 106 #define MBX_CR_RFMFIE_GET(x) (((uint32_t)(x) & MBX_CR_RFMFIE_MASK) >> MBX_CR_RFMFIE_SHIFT) 107 108 /* 109 * TWMEIE (RW) 110 * 111 * TX word message empty interrupt enable. 112 * 1, enable the TX word massage empty interrupt. 113 * 0, disable the TX word message empty interrupt. 114 */ 115 #define MBX_CR_TWMEIE_MASK (0x2U) 116 #define MBX_CR_TWMEIE_SHIFT (1U) 117 #define MBX_CR_TWMEIE_SET(x) (((uint32_t)(x) << MBX_CR_TWMEIE_SHIFT) & MBX_CR_TWMEIE_MASK) 118 #define MBX_CR_TWMEIE_GET(x) (((uint32_t)(x) & MBX_CR_TWMEIE_MASK) >> MBX_CR_TWMEIE_SHIFT) 119 120 /* 121 * RWMVIE (RW) 122 * 123 * RX word message valid interrupt enable. 124 * 1, enable the RX word massage valid interrupt. 125 * 0, disable the RX word message valid interrupt. 126 */ 127 #define MBX_CR_RWMVIE_MASK (0x1U) 128 #define MBX_CR_RWMVIE_SHIFT (0U) 129 #define MBX_CR_RWMVIE_SET(x) (((uint32_t)(x) << MBX_CR_RWMVIE_SHIFT) & MBX_CR_RWMVIE_MASK) 130 #define MBX_CR_RWMVIE_GET(x) (((uint32_t)(x) & MBX_CR_RWMVIE_MASK) >> MBX_CR_RWMVIE_SHIFT) 131 132 /* Bitfield definition for register: SR */ 133 /* 134 * RFVC (RO) 135 * 136 * RX FIFO valid message count 137 */ 138 #define MBX_SR_RFVC_MASK (0xF00000UL) 139 #define MBX_SR_RFVC_SHIFT (20U) 140 #define MBX_SR_RFVC_GET(x) (((uint32_t)(x) & MBX_SR_RFVC_MASK) >> MBX_SR_RFVC_SHIFT) 141 142 /* 143 * TFEC (RO) 144 * 145 * TX FIFO empty message word count 146 */ 147 #define MBX_SR_TFEC_MASK (0xF0000UL) 148 #define MBX_SR_TFEC_SHIFT (16U) 149 #define MBX_SR_TFEC_GET(x) (((uint32_t)(x) & MBX_SR_TFEC_MASK) >> MBX_SR_TFEC_SHIFT) 150 151 /* 152 * ERRRE (W1C) 153 * 154 * bus Error for read when rx word message are still invalid, this bit is W1C bit. 155 * 1, read from word message when the word message are still invalid will cause this error bit set. 156 * 0, nothis kind of bus error; write this bit to 1 will clear this bit when this kind of error happen. 157 */ 158 #define MBX_SR_ERRRE_MASK (0x2000U) 159 #define MBX_SR_ERRRE_SHIFT (13U) 160 #define MBX_SR_ERRRE_SET(x) (((uint32_t)(x) << MBX_SR_ERRRE_SHIFT) & MBX_SR_ERRRE_MASK) 161 #define MBX_SR_ERRRE_GET(x) (((uint32_t)(x) & MBX_SR_ERRRE_MASK) >> MBX_SR_ERRRE_SHIFT) 162 163 /* 164 * EWTRF (W1C) 165 * 166 * bus Error for write when tx word message are still valid, this bit is W1C bit. 167 * 1, write to word message when the word message are still valid will cause this error bit set. 168 * 0, nothis kind of bus error; write this bit to 1 will clear this bit when this kind of error happen. 169 */ 170 #define MBX_SR_EWTRF_MASK (0x1000U) 171 #define MBX_SR_EWTRF_SHIFT (12U) 172 #define MBX_SR_EWTRF_SET(x) (((uint32_t)(x) << MBX_SR_EWTRF_SHIFT) & MBX_SR_EWTRF_MASK) 173 #define MBX_SR_EWTRF_GET(x) (((uint32_t)(x) & MBX_SR_EWTRF_MASK) >> MBX_SR_EWTRF_SHIFT) 174 175 /* 176 * ERRFE (W1C) 177 * 178 * bus Error for read when rx fifo empty, this bit is W1C bit. 179 * 1, read from a empty rx fifo will cause this error bit set. 180 * 0, nothis kind of bus error; write this bit to 1 will clear this bit when this kind of error happen. 181 */ 182 #define MBX_SR_ERRFE_MASK (0x800U) 183 #define MBX_SR_ERRFE_SHIFT (11U) 184 #define MBX_SR_ERRFE_SET(x) (((uint32_t)(x) << MBX_SR_ERRFE_SHIFT) & MBX_SR_ERRFE_MASK) 185 #define MBX_SR_ERRFE_GET(x) (((uint32_t)(x) & MBX_SR_ERRFE_MASK) >> MBX_SR_ERRFE_SHIFT) 186 187 /* 188 * EWTFF (W1C) 189 * 190 * bus Error for write when tx fifo full, this bit is W1C bit. 191 * 1, write to a fulled tx fifo will cause this error bit set. 192 * 0, nothis kind of bus error; write this bit to 1 will clear this bit when this kind of error happen. 193 */ 194 #define MBX_SR_EWTFF_MASK (0x400U) 195 #define MBX_SR_EWTFF_SHIFT (10U) 196 #define MBX_SR_EWTFF_SET(x) (((uint32_t)(x) << MBX_SR_EWTFF_SHIFT) & MBX_SR_EWTFF_MASK) 197 #define MBX_SR_EWTFF_GET(x) (((uint32_t)(x) & MBX_SR_EWTFF_MASK) >> MBX_SR_EWTFF_SHIFT) 198 199 /* 200 * EAIVA (W1C) 201 * 202 * bus Error for Accessing Invalid Address; this bit is W1C bit. 203 * 1, read and write to invalid address in the bus of this block, will set this bit. 204 * 0, nothis kind of bus error; write this bit to 1 will clear this bit when this kind of error happen. 205 */ 206 #define MBX_SR_EAIVA_MASK (0x200U) 207 #define MBX_SR_EAIVA_SHIFT (9U) 208 #define MBX_SR_EAIVA_SET(x) (((uint32_t)(x) << MBX_SR_EAIVA_SHIFT) & MBX_SR_EAIVA_MASK) 209 #define MBX_SR_EAIVA_GET(x) (((uint32_t)(x) & MBX_SR_EAIVA_MASK) >> MBX_SR_EAIVA_SHIFT) 210 211 /* 212 * EW2RO (W1C) 213 * 214 * bus Error for Write to Read Only address; this bit is W1C bit. 215 * 1, write to read only address happened in the bus of this block. 216 * 0, nothis kind of bus error; write this bit to 1 will clear this bit when this kind of error happen. 217 */ 218 #define MBX_SR_EW2RO_MASK (0x100U) 219 #define MBX_SR_EW2RO_SHIFT (8U) 220 #define MBX_SR_EW2RO_SET(x) (((uint32_t)(x) << MBX_SR_EW2RO_SHIFT) & MBX_SR_EW2RO_MASK) 221 #define MBX_SR_EW2RO_GET(x) (((uint32_t)(x) & MBX_SR_EW2RO_MASK) >> MBX_SR_EW2RO_SHIFT) 222 223 /* 224 * TFMA (RW) 225 * 226 * TX FIFO Message slot available, the 4x32 TX FIFO message buffer to the other core full, will not trigger any interrupt. 227 * 1, TXFIFO message buffer has slot available 228 * 0, no slot available (fifo full) 229 */ 230 #define MBX_SR_TFMA_MASK (0x80U) 231 #define MBX_SR_TFMA_SHIFT (7U) 232 #define MBX_SR_TFMA_SET(x) (((uint32_t)(x) << MBX_SR_TFMA_SHIFT) & MBX_SR_TFMA_MASK) 233 #define MBX_SR_TFMA_GET(x) (((uint32_t)(x) & MBX_SR_TFMA_MASK) >> MBX_SR_TFMA_SHIFT) 234 235 /* 236 * TFME (RW) 237 * 238 * TX FIFO Message Empty, no any data in the message FIFO buffer from other core, will not trigger any interrupt.message from other core. 239 * 1, no any message data in TXFIFO from other core. 240 * 0, there are some data in the 4x32 TX FIFO from other core yet. 241 */ 242 #define MBX_SR_TFME_MASK (0x40U) 243 #define MBX_SR_TFME_SHIFT (6U) 244 #define MBX_SR_TFME_SET(x) (((uint32_t)(x) << MBX_SR_TFME_SHIFT) & MBX_SR_TFME_MASK) 245 #define MBX_SR_TFME_GET(x) (((uint32_t)(x) & MBX_SR_TFME_MASK) >> MBX_SR_TFME_SHIFT) 246 247 /* 248 * RFMA (RO) 249 * 250 * RX FIFO Message Available, available data in the 4x32 TX FIFO message buffer to the other core, will trigger interrupt if the related interrupt enable bit set in the control (CR) registrer. 251 * 1, no any data in the 4x32 TXFIFO message buffer. 252 * 0, there are some data in the the 4x32 TXFIFO message buffer already. 253 */ 254 #define MBX_SR_RFMA_MASK (0x20U) 255 #define MBX_SR_RFMA_SHIFT (5U) 256 #define MBX_SR_RFMA_GET(x) (((uint32_t)(x) & MBX_SR_RFMA_MASK) >> MBX_SR_RFMA_SHIFT) 257 258 /* 259 * RFMF (RO) 260 * 261 * RX FIFO Message Full, message from other core; will trigger interrupt if the related interrupt enable bit set in the control (CR) registrer. 262 * 1, the other core had written 4x32 message in the RXFIFO. 263 * 0, no 4x32 RX FIFO message from other core yet. 264 */ 265 #define MBX_SR_RFMF_MASK (0x10U) 266 #define MBX_SR_RFMF_SHIFT (4U) 267 #define MBX_SR_RFMF_GET(x) (((uint32_t)(x) & MBX_SR_RFMF_MASK) >> MBX_SR_RFMF_SHIFT) 268 269 /* 270 * TWME (RO) 271 * 272 * TX word message empty, will trigger interrupt if the related interrupt enable bit set in the control (CR) registrer. 273 * 1, means this core had write word message to TXREG. 274 * 0, means no valid word message in the TXREG yet. 275 */ 276 #define MBX_SR_TWME_MASK (0x2U) 277 #define MBX_SR_TWME_SHIFT (1U) 278 #define MBX_SR_TWME_GET(x) (((uint32_t)(x) & MBX_SR_TWME_MASK) >> MBX_SR_TWME_SHIFT) 279 280 /* 281 * RWMV (RO) 282 * 283 * RX word message valid, will trigger interrupt if the related interrupt enable bit set in the control (CR) registrer. 284 * 1, the other core had written word message in the RXREG. 285 * 0, no valid word message yet in the RXREG. 286 */ 287 #define MBX_SR_RWMV_MASK (0x1U) 288 #define MBX_SR_RWMV_SHIFT (0U) 289 #define MBX_SR_RWMV_GET(x) (((uint32_t)(x) & MBX_SR_RWMV_MASK) >> MBX_SR_RWMV_SHIFT) 290 291 /* Bitfield definition for register: TXREG */ 292 /* 293 * TXREG (WO) 294 * 295 * Transmit word message to other core. 296 */ 297 #define MBX_TXREG_TXREG_MASK (0xFFFFFFFFUL) 298 #define MBX_TXREG_TXREG_SHIFT (0U) 299 #define MBX_TXREG_TXREG_SET(x) (((uint32_t)(x) << MBX_TXREG_TXREG_SHIFT) & MBX_TXREG_TXREG_MASK) 300 #define MBX_TXREG_TXREG_GET(x) (((uint32_t)(x) & MBX_TXREG_TXREG_MASK) >> MBX_TXREG_TXREG_SHIFT) 301 302 /* Bitfield definition for register: RXREG */ 303 /* 304 * RXREG (RO) 305 * 306 * Receive word message from other core. 307 */ 308 #define MBX_RXREG_RXREG_MASK (0xFFFFFFFFUL) 309 #define MBX_RXREG_RXREG_SHIFT (0U) 310 #define MBX_RXREG_RXREG_GET(x) (((uint32_t)(x) & MBX_RXREG_RXREG_MASK) >> MBX_RXREG_RXREG_SHIFT) 311 312 /* Bitfield definition for register array: TXWRD */ 313 /* 314 * TXFIFO (WO) 315 * 316 * TXFIFO for sending message to other core, FIFO size, 4x32 317 * can write one of the word address to push data to the FIFO; 318 * can also use 4x32 burst write from 0x010 to push 4 words to the FIFO. 319 */ 320 #define MBX_TXWRD_TXFIFO_MASK (0xFFFFFFFFUL) 321 #define MBX_TXWRD_TXFIFO_SHIFT (0U) 322 #define MBX_TXWRD_TXFIFO_SET(x) (((uint32_t)(x) << MBX_TXWRD_TXFIFO_SHIFT) & MBX_TXWRD_TXFIFO_MASK) 323 #define MBX_TXWRD_TXFIFO_GET(x) (((uint32_t)(x) & MBX_TXWRD_TXFIFO_MASK) >> MBX_TXWRD_TXFIFO_SHIFT) 324 325 /* Bitfield definition for register array: RXWRD */ 326 /* 327 * RXFIFO (RO) 328 * 329 * RXFIFO for receiving message from other core, FIFO size, 4x32 330 * can read one of the word address to pop data to the FIFO; 331 * can also use 4x32 burst read from 0x020 to read 4 words from the FIFO. 332 */ 333 #define MBX_RXWRD_RXFIFO_MASK (0xFFFFFFFFUL) 334 #define MBX_RXWRD_RXFIFO_SHIFT (0U) 335 #define MBX_RXWRD_RXFIFO_GET(x) (((uint32_t)(x) & MBX_RXWRD_RXFIFO_MASK) >> MBX_RXWRD_RXFIFO_SHIFT) 336 337 338 339 /* TXWRD register group index macro definition */ 340 #define MBX_TXWRD_TXFIFO0 (0UL) 341 342 /* RXWRD register group index macro definition */ 343 #define MBX_RXWRD_RXFIFO0 (0UL) 344 345 346 #endif /* HPM_MBX_H */