1*e1c4c8ddSCristian Marussi /* 2*e1c4c8ddSCristian Marussi * Virtio SCMI Device 3*e1c4c8ddSCristian Marussi * 4*e1c4c8ddSCristian Marussi * Copyright (c) 2023 Arm Ltd 5*e1c4c8ddSCristian Marussi * 6*e1c4c8ddSCristian Marussi * This header is BSD licensed so anyone can use the definitions 7*e1c4c8ddSCristian Marussi * to implement compatible drivers/servers: 8*e1c4c8ddSCristian Marussi * 9*e1c4c8ddSCristian Marussi * Redistribution and use in source and binary forms, with or without 10*e1c4c8ddSCristian Marussi * modification, are permitted provided that the following conditions 11*e1c4c8ddSCristian Marussi * are met: 12*e1c4c8ddSCristian Marussi * 1. Redistributions of source code must retain the above copyright 13*e1c4c8ddSCristian Marussi * notice, this list of conditions and the following disclaimer. 14*e1c4c8ddSCristian Marussi * 2. Redistributions in binary form must reproduce the above copyright 15*e1c4c8ddSCristian Marussi * notice, this list of conditions and the following disclaimer in the 16*e1c4c8ddSCristian Marussi * documentation and/or other materials provided with the distribution. 17*e1c4c8ddSCristian Marussi * 3. Neither the name of IBM nor the names of its contributors 18*e1c4c8ddSCristian Marussi * may be used to endorse or promote products derived from this software 19*e1c4c8ddSCristian Marussi * without specific prior written permission. 20*e1c4c8ddSCristian Marussi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21*e1c4c8ddSCristian Marussi * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*e1c4c8ddSCristian Marussi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*e1c4c8ddSCristian Marussi * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR 24*e1c4c8ddSCristian Marussi * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25*e1c4c8ddSCristian Marussi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26*e1c4c8ddSCristian Marussi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 27*e1c4c8ddSCristian Marussi * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28*e1c4c8ddSCristian Marussi * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*e1c4c8ddSCristian Marussi * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 30*e1c4c8ddSCristian Marussi * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*e1c4c8ddSCristian Marussi * SUCH DAMAGE. 32*e1c4c8ddSCristian Marussi */ 33*e1c4c8ddSCristian Marussi 34*e1c4c8ddSCristian Marussi #ifndef VIRTIO_SCMI_H 35*e1c4c8ddSCristian Marussi #define VIRTIO_SCMI_H 36*e1c4c8ddSCristian Marussi 37*e1c4c8ddSCristian Marussi #include <dev/virtio/virtqueue.h> 38*e1c4c8ddSCristian Marussi 39*e1c4c8ddSCristian Marussi /* Features bits */ 40*e1c4c8ddSCristian Marussi /* Device implements some SCMI notifications, or delayed responses */ 41*e1c4c8ddSCristian Marussi #define VIRTIO_SCMI_F_P2A_CHANNELS (1 << 0) 42*e1c4c8ddSCristian Marussi /* Device implements any SCMI statistics region */ 43*e1c4c8ddSCristian Marussi #define VIRTIO_SCMI_F_SHARED_MEMORY (1 << 1) 44*e1c4c8ddSCristian Marussi 45*e1c4c8ddSCristian Marussi #define VIRTIO_SCMI_FEATURES \ 46*e1c4c8ddSCristian Marussi (VIRTIO_SCMI_F_P2A_CHANNELS | VIRTIO_SCMI_F_SHARED_MEMORY) 47*e1c4c8ddSCristian Marussi 48*e1c4c8ddSCristian Marussi /* Virtqueues */ 49*e1c4c8ddSCristian Marussi enum vtscmi_chan { 50*e1c4c8ddSCristian Marussi VIRTIO_SCMI_CHAN_A2P, 51*e1c4c8ddSCristian Marussi VIRTIO_SCMI_CHAN_P2A, 52*e1c4c8ddSCristian Marussi VIRTIO_SCMI_CHAN_MAX 53*e1c4c8ddSCristian Marussi }; 54*e1c4c8ddSCristian Marussi 55*e1c4c8ddSCristian Marussi typedef void virtio_scmi_rx_callback_t(void *msg, unsigned int len, void *priv); 56*e1c4c8ddSCristian Marussi 57*e1c4c8ddSCristian Marussi device_t virtio_scmi_transport_get(void); 58*e1c4c8ddSCristian Marussi int virtio_scmi_channel_size_get(device_t dev, enum vtscmi_chan chan); 59*e1c4c8ddSCristian Marussi int virtio_scmi_channel_callback_set(device_t dev, enum vtscmi_chan chan, 60*e1c4c8ddSCristian Marussi virtio_scmi_rx_callback_t *cb, void *priv); 61*e1c4c8ddSCristian Marussi int virtio_scmi_message_enqueue(device_t dev, enum vtscmi_chan chan, 62*e1c4c8ddSCristian Marussi void *buf, unsigned int tx_len, 63*e1c4c8ddSCristian Marussi unsigned int rx_len); 64*e1c4c8ddSCristian Marussi void *virtio_scmi_message_poll(device_t dev, uint32_t *rx_len); 65*e1c4c8ddSCristian Marussi 66*e1c4c8ddSCristian Marussi #endif 67