1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2022 Rockchip Electronics Co., Ltd. 4 */ 5 #ifndef ROCKCHIP_RPMSG_H 6 #define ROCKCHIP_RPMSG_H 7 8 /* rpmsg flag bit definition 9 * bit 0: Set 1 to indicate remote processor is ready 10 * bit 1: Set 1 to use reserved memory region as shared DMA pool 11 * bit 2: Set 1 to use cached share memory as vring buffer 12 */ 13 #define RPMSG_REMOTE_IS_READY BIT(0) 14 #define RPMSG_SHARED_DMA_POOL BIT(1) 15 #define RPMSG_CACHED_VRING BIT(2) 16 17 #define RPMSG_VIRTIO_RPMSG_F_NS BIT(0) 18 19 #define RPMSG_BUF_PAYLOAD_SIZE (496UL) 20 /* rpmsg buffer size is formed by payload size and struct rpmsg_hdr */ 21 #define RPMSG_BUF_SIZE (RPMSG_BUF_PAYLOAD_SIZE + 16UL) 22 /* rpmsg buffer count for each direction */ 23 #define RPMSG_BUF_COUNT (64UL) 24 /* rpmsg endpoint size is equal to rpmsg buffer size */ 25 #define RPMSG_EPT_SIZE RPMSG_BUF_SIZE 26 27 #define RPMSG_MAX_INSTANCE_NUM (12U) 28 #define RPMSG_MAX_LINK_ID (0xFFU) 29 30 #define RPMSG_MBOX_MAGIC (0x524D5347U) 31 32 /* Linux requires the ALIGN to 0x1000(4KB) */ 33 #define RPMSG_VRING_ALIGN (0x1000UL) 34 /* contains pool of descriptors and two circular buffers */ 35 #define RPMSG_VRING_SIZE (0x8000UL) 36 /* size of 2 * RPMSG_VRING_SIZE */ 37 #define RPMSG_VRING_OVERHEAD (2UL * RPMSG_VRING_SIZE) 38 39 /* link_id: 4 bit master cpu_id and 4 bit remote_id */ 40 #define RPMSG_GET_M_CPU_ID(link_id) (((link_id) & 0xF0U) >> 4U) 41 #define RPMSG_GET_R_CPU_ID(link_id) ((link_id) & 0xFU) 42 43 #endif /* ROCKCHIP_RPMSG_H */ 44