1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022 Ruslan Bukin <br@bsdpad.com> 5 * Copyright (c) 2023 Arm Ltd 6 * 7 * This work was supported by Innovate UK project 105694, "Digital Security 8 * by Design (DSbD) Technology Platform Prototype". 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 #ifndef _ARM64_SCMI_SCMI_SHMEM_H_ 33 #define _ARM64_SCMI_SCMI_SHMEM_H_ 34 35 /* Shared Memory Transfer. */ 36 struct scmi_smt_header { 37 uint32_t reserved; 38 uint32_t channel_status; 39 #define SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR (1 << 1) 40 #define SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE (1 << 0) 41 uint32_t reserved1[2]; 42 uint32_t flags; 43 #define SCMI_SHMEM_FLAG_INTR_ENABLED (1 << 0) 44 uint32_t length; 45 uint32_t msg_header; 46 uint8_t msg_payload[0]; 47 }; 48 49 #define SMT_SIZE_HEADER sizeof(struct scmi_smt_header) 50 51 #define SMT_OFFSET_CHAN_STATUS \ 52 __offsetof(struct scmi_smt_header, channel_status) 53 #define SMT_SIZE_CHAN_STATUS sizeof(uint32_t) 54 55 #define SMT_OFFSET_LENGTH \ 56 __offsetof(struct scmi_smt_header, length) 57 #define SMT_SIZE_LENGTH sizeof(uint32_t) 58 59 #define SMT_OFFSET_MSG_HEADER \ 60 __offsetof(struct scmi_smt_header, msg_header) 61 #define SMT_SIZE_MSG_HEADER sizeof(uint32_t) 62 63 device_t scmi_shmem_get(device_t sdev, phandle_t node, int index); 64 int scmi_shmem_prepare_msg(device_t dev, uint8_t *msg, uint32_t tx_len, 65 bool polling); 66 bool scmi_shmem_poll_msg(device_t dev, uint32_t *msg_header); 67 int scmi_shmem_read_msg_header(device_t dev, uint32_t *msg_header); 68 int scmi_shmem_read_msg_payload(device_t dev, uint8_t *buf, uint32_t buf_len); 69 void scmi_shmem_tx_complete(device_t); 70 void scmi_shmem_clear_channel(device_t); 71 72 #endif /* !_ARM64_SCMI_SCMI_SHMEM_H_ */ 73