summarylogtreecommitdiffstats
path: root/epiphany_uapi.h
blob: 7666e735190ac0482d981d5113a4a761c546e2b4 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright (C) 2015 Adapteva Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called COPYING.
 */

#ifndef _UAPI_MISC_EPIPHANY_H
#define _UAPI_MISC_EPIPHANY_H

#include <linux/types.h>
#include <linux/ioctl.h>

#define E_MESH_MAX_ARRAYS	128
#define E_LINK_MAX_MEM_MAPPINGS	256

enum e_link_side {
	E_SIDE_N = 0,
	E_SIDE_E,
	E_SIDE_S,
	E_SIDE_W,
	E_SIDE_MAX
};

enum e_connection_type {
	E_CONN_DISCONNECTED = 0,
	E_CONN_ELINK,
	E_CONN_ARRAY,
	E_CONN_MAX
};

enum e_chip_type {
	E_CHIP_UNKNOWN = 0,
	E_CHIP_E16G301,
	E_CHIP_E64G401,
	E_CHIP_MAX
};

struct e_mappings_info {
	__u64 nmappings;
	struct {
		__u64 emesh_addr;
		__u64 size;
	} mappings[E_LINK_MAX_MEM_MAPPINGS];
} __attribute__((packed));

struct e_array_info {
	__u64 id;
	__u64 chip_type;
	__u64 chip_rows;
	__u64 chip_cols;
	__u64 parent_side;
	__u64 mesh_dev;
	struct {
		__u64 type;
		union {
			__u64 dev;
			__u64 id;
		};
	} connections[E_SIDE_MAX];
} __attribute__((packed));

struct e_elink_info {
	__u64 dev;
	__u32 version;
	__u32 _pad;
	__u64 connection_type;
	union {
		struct e_array_info array;
		__u64 remote_elink_id;
	};
} __attribute__((packed));

struct e_mesh_info {
	__u64 dev;
	__u64 chip_type;
	__u64 narrays;
#if 1
	struct e_array_info arrays[E_MESH_MAX_ARRAYS];
#endif
} __attribute__((packed));

struct e_mailbox_msg {
	__u32		from;
	__u32		data;
} __attribute__((packed));


#define E_IOCTL_MAGIC  'E'
#define E_IO(nr)		_IO(E_IOCTL_MAGIC, nr)
#define E_IOR(nr, type)		_IOR(E_IOCTL_MAGIC, nr, type)
#define E_IOW(nr, type)		_IOW(E_IOCTL_MAGIC, nr, type)
#define E_IOWR(nr, type)	_IOWR(E_IOCTL_MAGIC, nr, type)

/**
 * If you add an IOC command, please update the
 * EPIPHANY_IOC_MAXNR macro
 */

#define E_IOCTL_RESET			E_IO(0x00)
#define E_IOCTL_ELINK_PROBE		E_IOR(0x01, struct e_elink_info)
#define E_IOCTL_MESH_PROBE		E_IOR(0x02, struct e_mesh_info)
#define E_IOCTL_GET_MAPPINGS		E_IOR(0x03, struct e_mappings_info)
#define E_IOCTL_MAILBOX_READ		E_IOWR(0x04, struct e_mailbox_msg)
#define E_IOCTL_MAILBOX_COUNT		E_IO(0x05)
#define E_IOCTL_THERMAL_DISALLOW	E_IO(0x06)
#define E_IOCTL_THERMAL_ALLOW		E_IO(0x07)

#define E_IOCTL_MAXNR			0x07

#endif /* _UAPI_MISC_EPIPHANY_H */