xref: /rk3399_ARM-atf/include/drivers/rpi3/mailbox/rpi3_mbox.h (revision 5318255f12f88c91846b7261ce12254fb8395557)
1c0031189SAndre Przywara /*
2*7a9cdf58SMario Bălănică  * Copyright (c) 2019-2024, Arm Limited and Contributors. All rights reserved.
3c0031189SAndre Przywara  *
4c0031189SAndre Przywara  * SPDX-License-Identifier: BSD-3-Clause
5c0031189SAndre Przywara  */
6c0031189SAndre Przywara 
7c0031189SAndre Przywara #ifndef RPI3_MBOX_H
8c0031189SAndre Przywara #define RPI3_MBOX_H
9c0031189SAndre Przywara 
10c0031189SAndre Przywara #include <stdint.h>
11c0031189SAndre Przywara 
12c0031189SAndre Przywara /* This struct must be aligned to 16 bytes */
13c0031189SAndre Przywara typedef struct __packed __aligned(16) rpi3_mbox_request {
14c0031189SAndre Przywara 	uint32_t	size; /* Buffer size in bytes */
15c0031189SAndre Przywara 	uint32_t	code; /* Request/response code */
16c0031189SAndre Przywara 	uint32_t	tags[0];
17c0031189SAndre Przywara } rpi3_mbox_request_t;
18c0031189SAndre Przywara 
19*7a9cdf58SMario Bălănică /* VideoCore -> ARM */
20*7a9cdf58SMario Bălănică #define RPI3_MBOX0_READ_OFFSET		ULL(0x00000000)
21*7a9cdf58SMario Bălănică #define RPI3_MBOX0_PEEK_OFFSET		ULL(0x00000010)
22*7a9cdf58SMario Bălănică #define RPI3_MBOX0_SENDER_OFFSET	ULL(0x00000014)
23*7a9cdf58SMario Bălănică #define RPI3_MBOX0_STATUS_OFFSET	ULL(0x00000018)
24*7a9cdf58SMario Bălănică #define RPI3_MBOX0_CONFIG_OFFSET	ULL(0x0000001C)
25*7a9cdf58SMario Bălănică /* ARM -> VideoCore */
26*7a9cdf58SMario Bălănică #define RPI3_MBOX1_WRITE_OFFSET		ULL(0x00000020)
27*7a9cdf58SMario Bălănică #define RPI3_MBOX1_PEEK_OFFSET		ULL(0x00000030)
28*7a9cdf58SMario Bălănică #define RPI3_MBOX1_SENDER_OFFSET	ULL(0x00000034)
29*7a9cdf58SMario Bălănică #define RPI3_MBOX1_STATUS_OFFSET	ULL(0x00000038)
30*7a9cdf58SMario Bălănică #define RPI3_MBOX1_CONFIG_OFFSET	ULL(0x0000003C)
31*7a9cdf58SMario Bălănică /* Mailbox status constants */
32*7a9cdf58SMario Bălănică #define RPI3_MBOX_STATUS_FULL_MASK	U(0x80000000) /* Set if full */
33*7a9cdf58SMario Bălănică #define RPI3_MBOX_STATUS_EMPTY_MASK	U(0x40000000) /* Set if empty */
34*7a9cdf58SMario Bălănică 
35c0031189SAndre Przywara #define RPI3_MBOX_BUFFER_SIZE		U(256)
36c0031189SAndre Przywara 
37c0031189SAndre Przywara /* Constants to perform a request/check the status of a request. */
38c0031189SAndre Przywara #define RPI3_MBOX_PROCESS_REQUEST	U(0x00000000)
39c0031189SAndre Przywara #define RPI3_MBOX_REQUEST_SUCCESSFUL	U(0x80000000)
40c0031189SAndre Przywara #define RPI3_MBOX_REQUEST_ERROR		U(0x80000001)
41c0031189SAndre Przywara 
42c0031189SAndre Przywara /* Command constants */
43c0031189SAndre Przywara #define RPI3_TAG_HARDWARE_GET_BOARD_REVISION	U(0x00010002)
44c0031189SAndre Przywara #define RPI3_TAG_END				U(0x00000000)
45c0031189SAndre Przywara 
46c0031189SAndre Przywara #define RPI3_TAG_REQUEST		U(0x00000000)
47c0031189SAndre Przywara #define RPI3_TAG_IS_RESPONSE		U(0x80000000) /* Set if response */
48c0031189SAndre Przywara #define RPI3_TAG_RESPONSE_LENGTH_MASK	U(0x7FFFFFFF)
49c0031189SAndre Przywara 
50c0031189SAndre Przywara #define RPI3_CHANNEL_ARM_TO_VC		U(0x8)
51c0031189SAndre Przywara #define RPI3_CHANNEL_MASK		U(0xF)
52c0031189SAndre Przywara 
53c0031189SAndre Przywara void rpi3_vc_mailbox_request_send(rpi3_mbox_request_t *req, int req_size);
54c0031189SAndre Przywara 
55c0031189SAndre Przywara #endif
56