master
h 72 lines 1.72 KB
Raw
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2
3 #ifndef _LINUX_VIRTIO_GPIO_H
4 #define _LINUX_VIRTIO_GPIO_H
5
6 #include "standard-headers/linux/types.h"
7
8 /* Virtio GPIO Feature bits */
9 #define VIRTIO_GPIO_F_IRQ 0
10
11 /* Virtio GPIO request types */
12 #define VIRTIO_GPIO_MSG_GET_NAMES 0x0001
13 #define VIRTIO_GPIO_MSG_GET_DIRECTION 0x0002
14 #define VIRTIO_GPIO_MSG_SET_DIRECTION 0x0003
15 #define VIRTIO_GPIO_MSG_GET_VALUE 0x0004
16 #define VIRTIO_GPIO_MSG_SET_VALUE 0x0005
17 #define VIRTIO_GPIO_MSG_IRQ_TYPE 0x0006
18
19 /* Possible values of the status field */
20 #define VIRTIO_GPIO_STATUS_OK 0x0
21 #define VIRTIO_GPIO_STATUS_ERR 0x1
22
23 /* Direction types */
24 #define VIRTIO_GPIO_DIRECTION_NONE 0x00
25 #define VIRTIO_GPIO_DIRECTION_OUT 0x01
26 #define VIRTIO_GPIO_DIRECTION_IN 0x02
27
28 /* Virtio GPIO IRQ types */
29 #define VIRTIO_GPIO_IRQ_TYPE_NONE 0x00
30 #define VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING 0x01
31 #define VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
32 #define VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
33 #define VIRTIO_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
34 #define VIRTIO_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
35
36 struct virtio_gpio_config {
37 uint16_t ngpio;
38 uint8_t padding[2];
39 uint32_t gpio_names_size;
40 };
41
42 /* Virtio GPIO Request / Response */
43 struct virtio_gpio_request {
44 uint16_t type;
45 uint16_t gpio;
46 uint32_t value;
47 };
48
49 struct virtio_gpio_response {
50 uint8_t status;
51 uint8_t value;
52 };
53
54 struct virtio_gpio_response_get_names {
55 uint8_t status;
56 uint8_t value[];
57 };
58
59 /* Virtio GPIO IRQ Request / Response */
60 struct virtio_gpio_irq_request {
61 uint16_t gpio;
62 };
63
64 struct virtio_gpio_irq_response {
65 uint8_t status;
66 };
67
68 /* Possible values of the interrupt status field */
69 #define VIRTIO_GPIO_IRQ_STATUS_INVALID 0x0
70 #define VIRTIO_GPIO_IRQ_STATUS_VALID 0x1
71
72 #endif /* _LINUX_VIRTIO_GPIO_H */