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