1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
252eabba5SLogan Gunthorpe /*
352eabba5SLogan Gunthorpe  * Microsemi Switchtec PCIe Driver
452eabba5SLogan Gunthorpe  * Copyright (c) 2017, Microsemi Corporation
552eabba5SLogan Gunthorpe  *
652eabba5SLogan Gunthorpe  * This program is free software; you can redistribute it and/or modify it
752eabba5SLogan Gunthorpe  * under the terms and conditions of the GNU General Public License,
852eabba5SLogan Gunthorpe  * version 2, as published by the Free Software Foundation.
952eabba5SLogan Gunthorpe  *
1052eabba5SLogan Gunthorpe  * This program is distributed in the hope it will be useful, but WITHOUT
1152eabba5SLogan Gunthorpe  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1252eabba5SLogan Gunthorpe  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
1352eabba5SLogan Gunthorpe  * more details.
1452eabba5SLogan Gunthorpe  *
1552eabba5SLogan Gunthorpe  */
1652eabba5SLogan Gunthorpe 
1752eabba5SLogan Gunthorpe #ifndef _UAPI_LINUX_SWITCHTEC_IOCTL_H
1852eabba5SLogan Gunthorpe #define _UAPI_LINUX_SWITCHTEC_IOCTL_H
1952eabba5SLogan Gunthorpe 
2052eabba5SLogan Gunthorpe #include <linux/types.h>
2152eabba5SLogan Gunthorpe 
2252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_CFG0	0
2352eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_CFG1	1
2452eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_IMG0	2
2552eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_IMG1	3
2652eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_NVLOG	4
2752eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR0	5
2852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR1	6
2952eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR2	7
3052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR3	8
3152eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR4	9
3252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR5	10
3352eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR6	11
3452eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_VENDOR7	12
35*fcccd282SLogan Gunthorpe #define SWITCHTEC_NUM_PARTITIONS_GEN3	13
36*fcccd282SLogan Gunthorpe 
37*fcccd282SLogan Gunthorpe /* obsolete: for compatibility with old userspace software */
38*fcccd282SLogan Gunthorpe #define SWITCHTEC_IOCTL_NUM_PARTITIONS	SWITCHTEC_NUM_PARTITIONS_GEN3
3952eabba5SLogan Gunthorpe 
4052eabba5SLogan Gunthorpe struct switchtec_ioctl_flash_info {
4152eabba5SLogan Gunthorpe 	__u64 flash_length;
4252eabba5SLogan Gunthorpe 	__u32 num_partitions;
4352eabba5SLogan Gunthorpe 	__u32 padding;
4452eabba5SLogan Gunthorpe };
4552eabba5SLogan Gunthorpe 
46079e3bc5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_ACTIVE  1
47079e3bc5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PART_RUNNING 2
48079e3bc5SLogan Gunthorpe 
4952eabba5SLogan Gunthorpe struct switchtec_ioctl_flash_part_info {
5052eabba5SLogan Gunthorpe 	__u32 flash_partition;
5152eabba5SLogan Gunthorpe 	__u32 address;
5252eabba5SLogan Gunthorpe 	__u32 length;
5352eabba5SLogan Gunthorpe 	__u32 active;
5452eabba5SLogan Gunthorpe };
5552eabba5SLogan Gunthorpe 
56ba8a3982SWesley Sheng struct switchtec_ioctl_event_summary_legacy {
5752eabba5SLogan Gunthorpe 	__u64 global;
5852eabba5SLogan Gunthorpe 	__u64 part_bitmap;
5952eabba5SLogan Gunthorpe 	__u32 local_part;
6052eabba5SLogan Gunthorpe 	__u32 padding;
6152eabba5SLogan Gunthorpe 	__u32 part[48];
6252eabba5SLogan Gunthorpe 	__u32 pff[48];
6352eabba5SLogan Gunthorpe };
6452eabba5SLogan Gunthorpe 
65ba8a3982SWesley Sheng struct switchtec_ioctl_event_summary {
66ba8a3982SWesley Sheng 	__u64 global;
67ba8a3982SWesley Sheng 	__u64 part_bitmap;
68ba8a3982SWesley Sheng 	__u32 local_part;
69ba8a3982SWesley Sheng 	__u32 padding;
70ba8a3982SWesley Sheng 	__u32 part[48];
71ba8a3982SWesley Sheng 	__u32 pff[255];
72ba8a3982SWesley Sheng };
73ba8a3982SWesley Sheng 
7452eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_STACK_ERROR		0
7552eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_PPU_ERROR			1
7652eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_ISP_ERROR			2
7752eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_SYS_RESET			3
7852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FW_EXC			4
7952eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FW_NMI			5
8052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FW_NON_FATAL		6
8152eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FW_FATAL			7
8252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_TWI_MRPC_COMP		8
8352eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_TWI_MRPC_COMP_ASYNC	9
8452eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP		10
8552eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP_ASYNC	11
8652eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_GPIO_INT			12
8752eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_PART_RESET		13
8852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_MRPC_COMP			14
8952eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_MRPC_COMP_ASYNC		15
9052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_DYN_PART_BIND_COMP	16
9152eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_AER_IN_P2P		17
9252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_AER_IN_VEP		18
9352eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_DPC			19
9452eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_CTS			20
9552eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_HOTPLUG			21
9652eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_IER			22
9752eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_THRESH			23
9852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_POWER_MGMT		24
9952eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_TLP_THROTTLING		25
10052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FORCE_SPEED		26
10152eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT		27
10252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_LINK_STATE		28
103f0edce7aSLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_GFMS			29
104a6b0ef9aSLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_INTERCOMM_REQ_NOTIFY	30
105a6b0ef9aSLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_UEC			31
106a6b0ef9aSLogan Gunthorpe #define SWITCHTEC_IOCTL_MAX_EVENTS			32
10752eabba5SLogan Gunthorpe 
10852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX -1
10952eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_IDX_ALL -2
11052eabba5SLogan Gunthorpe 
11152eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_CLEAR     (1 << 0)
11252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_POLL   (1 << 1)
11352eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_LOG    (1 << 2)
11452eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_CLI    (1 << 3)
11552eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_EN_FATAL  (1 << 4)
11652eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_POLL  (1 << 5)
11752eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_LOG   (1 << 6)
11852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_CLI   (1 << 7)
11952eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_FATAL (1 << 8)
12052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_FLAG_UNUSED    (~0x1ff)
12152eabba5SLogan Gunthorpe 
12252eabba5SLogan Gunthorpe struct switchtec_ioctl_event_ctl {
12352eabba5SLogan Gunthorpe 	__u32 event_id;
12452eabba5SLogan Gunthorpe 	__s32 index;
12552eabba5SLogan Gunthorpe 	__u32 flags;
12652eabba5SLogan Gunthorpe 	__u32 occurred;
12752eabba5SLogan Gunthorpe 	__u32 count;
12852eabba5SLogan Gunthorpe 	__u32 data[5];
12952eabba5SLogan Gunthorpe };
13052eabba5SLogan Gunthorpe 
13152eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PFF_VEP 100
13252eabba5SLogan Gunthorpe struct switchtec_ioctl_pff_port {
13352eabba5SLogan Gunthorpe 	__u32 pff;
13452eabba5SLogan Gunthorpe 	__u32 partition;
13552eabba5SLogan Gunthorpe 	__u32 port;
13652eabba5SLogan Gunthorpe };
13752eabba5SLogan Gunthorpe 
13852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_FLASH_INFO \
13952eabba5SLogan Gunthorpe 	_IOR('W', 0x40, struct switchtec_ioctl_flash_info)
14052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_FLASH_PART_INFO \
14152eabba5SLogan Gunthorpe 	_IOWR('W', 0x41, struct switchtec_ioctl_flash_part_info)
14252eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_SUMMARY \
14352eabba5SLogan Gunthorpe 	_IOR('W', 0x42, struct switchtec_ioctl_event_summary)
144ba8a3982SWesley Sheng #define SWITCHTEC_IOCTL_EVENT_SUMMARY_LEGACY \
145ba8a3982SWesley Sheng 	_IOR('W', 0x42, struct switchtec_ioctl_event_summary_legacy)
14652eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_EVENT_CTL \
14752eabba5SLogan Gunthorpe 	_IOWR('W', 0x43, struct switchtec_ioctl_event_ctl)
14852eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PFF_TO_PORT \
14952eabba5SLogan Gunthorpe 	_IOWR('W', 0x44, struct switchtec_ioctl_pff_port)
15052eabba5SLogan Gunthorpe #define SWITCHTEC_IOCTL_PORT_TO_PFF \
15152eabba5SLogan Gunthorpe 	_IOWR('W', 0x45, struct switchtec_ioctl_pff_port)
15252eabba5SLogan Gunthorpe 
15352eabba5SLogan Gunthorpe #endif
154