xref: /openbmc/linux/include/uapi/linux/misc/bcm_vk.h (revision ee7da21a)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Copyright 2018-2020 Broadcom.
4  */
5 
6 #ifndef __UAPI_LINUX_MISC_BCM_VK_H
7 #define __UAPI_LINUX_MISC_BCM_VK_H
8 
9 #include <linux/ioctl.h>
10 #include <linux/types.h>
11 
12 #define BCM_VK_MAX_FILENAME 64
13 
14 struct vk_image {
15 	__u32 type; /* Type of image */
16 #define VK_IMAGE_TYPE_BOOT1 1 /* 1st stage (load to SRAM) */
17 #define VK_IMAGE_TYPE_BOOT2 2 /* 2nd stage (load to DDR) */
18 	__u8 filename[BCM_VK_MAX_FILENAME]; /* Filename of image */
19 };
20 
21 struct vk_reset {
22 	__u32 arg1;
23 	__u32 arg2;
24 };
25 
26 #define VK_MAGIC		0x5e
27 
28 /* Load image to Valkyrie */
29 #define VK_IOCTL_LOAD_IMAGE	_IOW(VK_MAGIC, 0x2, struct vk_image)
30 
31 /* Send Reset to Valkyrie */
32 #define VK_IOCTL_RESET		_IOW(VK_MAGIC, 0x4, struct vk_reset)
33 
34 /*
35  * Firmware Status accessed directly via BAR space
36  */
37 #define VK_BAR_FWSTS			0x41c
38 #define VK_BAR_COP_FWSTS		0x428
39 /* VK_FWSTS definitions */
40 #define VK_FWSTS_RELOCATION_ENTRY	(1UL << 0)
41 #define VK_FWSTS_RELOCATION_EXIT	(1UL << 1)
42 #define VK_FWSTS_INIT_START		(1UL << 2)
43 #define VK_FWSTS_ARCH_INIT_DONE		(1UL << 3)
44 #define VK_FWSTS_PRE_KNL1_INIT_DONE	(1UL << 4)
45 #define VK_FWSTS_PRE_KNL2_INIT_DONE	(1UL << 5)
46 #define VK_FWSTS_POST_KNL_INIT_DONE	(1UL << 6)
47 #define VK_FWSTS_INIT_DONE		(1UL << 7)
48 #define VK_FWSTS_APP_INIT_START		(1UL << 8)
49 #define VK_FWSTS_APP_INIT_DONE		(1UL << 9)
50 #define VK_FWSTS_MASK			0xffffffff
51 #define VK_FWSTS_READY			(VK_FWSTS_INIT_START | \
52 					 VK_FWSTS_ARCH_INIT_DONE | \
53 					 VK_FWSTS_PRE_KNL1_INIT_DONE | \
54 					 VK_FWSTS_PRE_KNL2_INIT_DONE | \
55 					 VK_FWSTS_POST_KNL_INIT_DONE | \
56 					 VK_FWSTS_INIT_DONE | \
57 					 VK_FWSTS_APP_INIT_START | \
58 					 VK_FWSTS_APP_INIT_DONE)
59 /* Deinit */
60 #define VK_FWSTS_APP_DEINIT_START	(1UL << 23)
61 #define VK_FWSTS_APP_DEINIT_DONE	(1UL << 24)
62 #define VK_FWSTS_DRV_DEINIT_START	(1UL << 25)
63 #define VK_FWSTS_DRV_DEINIT_DONE	(1UL << 26)
64 #define VK_FWSTS_RESET_DONE		(1UL << 27)
65 #define VK_FWSTS_DEINIT_TRIGGERED	(VK_FWSTS_APP_DEINIT_START | \
66 					 VK_FWSTS_APP_DEINIT_DONE  | \
67 					 VK_FWSTS_DRV_DEINIT_START | \
68 					 VK_FWSTS_DRV_DEINIT_DONE)
69 /* Last nibble for reboot reason */
70 #define VK_FWSTS_RESET_REASON_SHIFT	28
71 #define VK_FWSTS_RESET_REASON_MASK	(0xf << VK_FWSTS_RESET_REASON_SHIFT)
72 #define VK_FWSTS_RESET_SYS_PWRUP	(0x0 << VK_FWSTS_RESET_REASON_SHIFT)
73 #define VK_FWSTS_RESET_MBOX_DB		(0x1 << VK_FWSTS_RESET_REASON_SHIFT)
74 #define VK_FWSTS_RESET_M7_WDOG		(0x2 << VK_FWSTS_RESET_REASON_SHIFT)
75 #define VK_FWSTS_RESET_TEMP		(0x3 << VK_FWSTS_RESET_REASON_SHIFT)
76 #define VK_FWSTS_RESET_PCI_FLR		(0x4 << VK_FWSTS_RESET_REASON_SHIFT)
77 #define VK_FWSTS_RESET_PCI_HOT		(0x5 << VK_FWSTS_RESET_REASON_SHIFT)
78 #define VK_FWSTS_RESET_PCI_WARM		(0x6 << VK_FWSTS_RESET_REASON_SHIFT)
79 #define VK_FWSTS_RESET_PCI_COLD		(0x7 << VK_FWSTS_RESET_REASON_SHIFT)
80 #define VK_FWSTS_RESET_L1		(0x8 << VK_FWSTS_RESET_REASON_SHIFT)
81 #define VK_FWSTS_RESET_L0		(0x9 << VK_FWSTS_RESET_REASON_SHIFT)
82 #define VK_FWSTS_RESET_UNKNOWN		(0xf << VK_FWSTS_RESET_REASON_SHIFT)
83 
84 #endif /* __UAPI_LINUX_MISC_BCM_VK_H */
85