aboutsummaryrefslogtreecommitdiff
path: root/include/linux/virtio_spmi.h
blob: d3224983fa93595c8f6f79bbbc4bbea02af4de0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _LINUX_VIRTIO_SPMI_H
#define _LINUX_VIRTIO_SPMI_H

#include <linux/types.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_config.h>
#include <linux/virtio_types.h>

/* Feature bits */
#define VIRTIO_SPMI_F_INT	1	/* Support interrupt */

#define VM_MAX_PERIPHS 512

/* Configuration layout */
struct virtio_spmi_config {
	__u16 ppid_allowed[VM_MAX_PERIPHS];
} __packed;

struct payload_cmd {
	__virtio32 data[2];
};

struct payload_irq {
	__virtio32 ppid;
	__virtio32 val;
};

union payload_data {
	struct payload_cmd cmdd;
	struct payload_irq irqd;
};

struct virtio_spmi_msg {
	__virtio32 type;
	__virtio32 len;
	__virtio32 res;
	union {
		__virtio32 cmd;
		__virtio32 cnt;
	} u;
	union payload_data payload[];
};

/* Virtio SPMI message type */
enum vio_spmi_msg_type {
	VIO_SPMI_BUS_WRITE = 0,
	VIO_SPMI_BUS_READ = 1,
	VIO_ACC_ENABLE_WR = 2,
	VIO_ACC_ENABLE_RD = 3,
	VIO_IRQ_CLEAR = 4,
	VIO_IRQ_STATUS = 5,
};

/* Virtio SPMI message type */
enum vio_spmi_msg_res {
	VIO_SPMI_DONE = 0,
	VIO_SPMI_ERR = 1,
};

/* payload fix size and one payload_data size */
#define MSG_FIX_SZ (sizeof(struct virtio_spmi_msg))
#define PER_PLD_SZ (sizeof(union payload_data))
#define MSG_SZ(x)  (MSG_FIX_SZ + ((PER_PLD_SZ) * (x)))

#endif /* _LINUX_VIRTIO_SPMI_H */