xref: /linux/include/uapi/linux/switchtec_ioctl.h (revision 8dd06ef34b6e2f41b29fbf5fc1663780f2524285)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Microsemi Switchtec PCIe Driver
4  * Copyright (c) 2017, Microsemi Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  */
16 
17 #ifndef _UAPI_LINUX_SWITCHTEC_IOCTL_H
18 #define _UAPI_LINUX_SWITCHTEC_IOCTL_H
19 
20 #include <linux/types.h>
21 
22 #define SWITCHTEC_IOCTL_PART_CFG0	0
23 #define SWITCHTEC_IOCTL_PART_CFG1	1
24 #define SWITCHTEC_IOCTL_PART_IMG0	2
25 #define SWITCHTEC_IOCTL_PART_IMG1	3
26 #define SWITCHTEC_IOCTL_PART_NVLOG	4
27 #define SWITCHTEC_IOCTL_PART_VENDOR0	5
28 #define SWITCHTEC_IOCTL_PART_VENDOR1	6
29 #define SWITCHTEC_IOCTL_PART_VENDOR2	7
30 #define SWITCHTEC_IOCTL_PART_VENDOR3	8
31 #define SWITCHTEC_IOCTL_PART_VENDOR4	9
32 #define SWITCHTEC_IOCTL_PART_VENDOR5	10
33 #define SWITCHTEC_IOCTL_PART_VENDOR6	11
34 #define SWITCHTEC_IOCTL_PART_VENDOR7	12
35 #define SWITCHTEC_IOCTL_PART_BL2_0	13
36 #define SWITCHTEC_IOCTL_PART_BL2_1	14
37 #define SWITCHTEC_IOCTL_PART_MAP_0	15
38 #define SWITCHTEC_IOCTL_PART_MAP_1	16
39 #define SWITCHTEC_IOCTL_PART_KEY_0	17
40 #define SWITCHTEC_IOCTL_PART_KEY_1	18
41 
42 #define SWITCHTEC_NUM_PARTITIONS_GEN3	13
43 #define SWITCHTEC_NUM_PARTITIONS_GEN4	19
44 
45 /* obsolete: for compatibility with old userspace software */
46 #define SWITCHTEC_IOCTL_NUM_PARTITIONS	SWITCHTEC_NUM_PARTITIONS_GEN3
47 
48 struct switchtec_ioctl_flash_info {
49 	__u64 flash_length;
50 	__u32 num_partitions;
51 	__u32 padding;
52 };
53 
54 #define SWITCHTEC_IOCTL_PART_ACTIVE  1
55 #define SWITCHTEC_IOCTL_PART_RUNNING 2
56 
57 struct switchtec_ioctl_flash_part_info {
58 	__u32 flash_partition;
59 	__u32 address;
60 	__u32 length;
61 	__u32 active;
62 };
63 
64 struct switchtec_ioctl_event_summary_legacy {
65 	__u64 global;
66 	__u64 part_bitmap;
67 	__u32 local_part;
68 	__u32 padding;
69 	__u32 part[48];
70 	__u32 pff[48];
71 };
72 
73 struct switchtec_ioctl_event_summary {
74 	__u64 global;
75 	__u64 part_bitmap;
76 	__u32 local_part;
77 	__u32 padding;
78 	__u32 part[48];
79 	__u32 pff[255];
80 };
81 
82 #define SWITCHTEC_IOCTL_EVENT_STACK_ERROR		0
83 #define SWITCHTEC_IOCTL_EVENT_PPU_ERROR			1
84 #define SWITCHTEC_IOCTL_EVENT_ISP_ERROR			2
85 #define SWITCHTEC_IOCTL_EVENT_SYS_RESET			3
86 #define SWITCHTEC_IOCTL_EVENT_FW_EXC			4
87 #define SWITCHTEC_IOCTL_EVENT_FW_NMI			5
88 #define SWITCHTEC_IOCTL_EVENT_FW_NON_FATAL		6
89 #define SWITCHTEC_IOCTL_EVENT_FW_FATAL			7
90 #define SWITCHTEC_IOCTL_EVENT_TWI_MRPC_COMP		8
91 #define SWITCHTEC_IOCTL_EVENT_TWI_MRPC_COMP_ASYNC	9
92 #define SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP		10
93 #define SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP_ASYNC	11
94 #define SWITCHTEC_IOCTL_EVENT_GPIO_INT			12
95 #define SWITCHTEC_IOCTL_EVENT_PART_RESET		13
96 #define SWITCHTEC_IOCTL_EVENT_MRPC_COMP			14
97 #define SWITCHTEC_IOCTL_EVENT_MRPC_COMP_ASYNC		15
98 #define SWITCHTEC_IOCTL_EVENT_DYN_PART_BIND_COMP	16
99 #define SWITCHTEC_IOCTL_EVENT_AER_IN_P2P		17
100 #define SWITCHTEC_IOCTL_EVENT_AER_IN_VEP		18
101 #define SWITCHTEC_IOCTL_EVENT_DPC			19
102 #define SWITCHTEC_IOCTL_EVENT_CTS			20
103 #define SWITCHTEC_IOCTL_EVENT_HOTPLUG			21
104 #define SWITCHTEC_IOCTL_EVENT_IER			22
105 #define SWITCHTEC_IOCTL_EVENT_THRESH			23
106 #define SWITCHTEC_IOCTL_EVENT_POWER_MGMT		24
107 #define SWITCHTEC_IOCTL_EVENT_TLP_THROTTLING		25
108 #define SWITCHTEC_IOCTL_EVENT_FORCE_SPEED		26
109 #define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT		27
110 #define SWITCHTEC_IOCTL_EVENT_LINK_STATE		28
111 #define SWITCHTEC_IOCTL_EVENT_GFMS			29
112 #define SWITCHTEC_IOCTL_EVENT_INTERCOMM_REQ_NOTIFY	30
113 #define SWITCHTEC_IOCTL_EVENT_UEC			31
114 #define SWITCHTEC_IOCTL_MAX_EVENTS			32
115 
116 #define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX -1
117 #define SWITCHTEC_IOCTL_EVENT_IDX_ALL -2
118 
119 #define SWITCHTEC_IOCTL_EVENT_FLAG_CLEAR     (1 << 0)
120 #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_POLL   (1 << 1)
121 #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_LOG    (1 << 2)
122 #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_CLI    (1 << 3)
123 #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_FATAL  (1 << 4)
124 #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_POLL  (1 << 5)
125 #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_LOG   (1 << 6)
126 #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_CLI   (1 << 7)
127 #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_FATAL (1 << 8)
128 #define SWITCHTEC_IOCTL_EVENT_FLAG_UNUSED    (~0x1ff)
129 
130 struct switchtec_ioctl_event_ctl {
131 	__u32 event_id;
132 	__s32 index;
133 	__u32 flags;
134 	__u32 occurred;
135 	__u32 count;
136 	__u32 data[5];
137 };
138 
139 #define SWITCHTEC_IOCTL_PFF_VEP 100
140 struct switchtec_ioctl_pff_port {
141 	__u32 pff;
142 	__u32 partition;
143 	__u32 port;
144 };
145 
146 #define SWITCHTEC_IOCTL_FLASH_INFO \
147 	_IOR('W', 0x40, struct switchtec_ioctl_flash_info)
148 #define SWITCHTEC_IOCTL_FLASH_PART_INFO \
149 	_IOWR('W', 0x41, struct switchtec_ioctl_flash_part_info)
150 #define SWITCHTEC_IOCTL_EVENT_SUMMARY \
151 	_IOR('W', 0x42, struct switchtec_ioctl_event_summary)
152 #define SWITCHTEC_IOCTL_EVENT_SUMMARY_LEGACY \
153 	_IOR('W', 0x42, struct switchtec_ioctl_event_summary_legacy)
154 #define SWITCHTEC_IOCTL_EVENT_CTL \
155 	_IOWR('W', 0x43, struct switchtec_ioctl_event_ctl)
156 #define SWITCHTEC_IOCTL_PFF_TO_PORT \
157 	_IOWR('W', 0x44, struct switchtec_ioctl_pff_port)
158 #define SWITCHTEC_IOCTL_PORT_TO_PFF \
159 	_IOWR('W', 0x45, struct switchtec_ioctl_pff_port)
160 
161 #endif
162