xref: /OK3568_Linux_fs/kernel/include/uapi/linux/aspeed-p2a-ctrl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright 2019 Google Inc
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or
6*4882a593Smuzhiyun  * modify it under the terms of the GNU General Public License
7*4882a593Smuzhiyun  * as published by the Free Software Foundation; either version
8*4882a593Smuzhiyun  * 2 of the License, or (at your option) any later version.
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Provides a simple driver to control the ASPEED P2A interface which allows
11*4882a593Smuzhiyun  * the host to read and write to various regions of the BMC's memory.
12*4882a593Smuzhiyun  */
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #ifndef _UAPI_LINUX_ASPEED_P2A_CTRL_H
15*4882a593Smuzhiyun #define _UAPI_LINUX_ASPEED_P2A_CTRL_H
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include <linux/ioctl.h>
18*4882a593Smuzhiyun #include <linux/types.h>
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #define ASPEED_P2A_CTRL_READ_ONLY 0
21*4882a593Smuzhiyun #define ASPEED_P2A_CTRL_READWRITE 1
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /*
24*4882a593Smuzhiyun  * This driver provides a mechanism for enabling or disabling the read-write
25*4882a593Smuzhiyun  * property of specific windows into the ASPEED BMC's memory.
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * A user can map a region of the BMC's memory as read-only or read-write, with
28*4882a593Smuzhiyun  * the caveat that once any region is mapped, all regions are unlocked for
29*4882a593Smuzhiyun  * reading.
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /*
33*4882a593Smuzhiyun  * Unlock a region of BMC physical memory for access from the host.
34*4882a593Smuzhiyun  *
35*4882a593Smuzhiyun  * Also used to read back the optional memory-region configuration for the
36*4882a593Smuzhiyun  * driver.
37*4882a593Smuzhiyun  */
38*4882a593Smuzhiyun struct aspeed_p2a_ctrl_mapping {
39*4882a593Smuzhiyun 	__u64 addr;
40*4882a593Smuzhiyun 	__u32 length;
41*4882a593Smuzhiyun 	__u32 flags;
42*4882a593Smuzhiyun };
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun #define __ASPEED_P2A_CTRL_IOCTL_MAGIC 0xb3
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /*
47*4882a593Smuzhiyun  * This IOCTL is meant to configure a region or regions of memory given a
48*4882a593Smuzhiyun  * starting address and length to be readable by the host, or
49*4882a593Smuzhiyun  * readable-writeable.
50*4882a593Smuzhiyun  */
51*4882a593Smuzhiyun #define ASPEED_P2A_CTRL_IOCTL_SET_WINDOW _IOW(__ASPEED_P2A_CTRL_IOCTL_MAGIC, \
52*4882a593Smuzhiyun 		0x00, struct aspeed_p2a_ctrl_mapping)
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun /*
55*4882a593Smuzhiyun  * This IOCTL is meant to read back to the user the base address and length of
56*4882a593Smuzhiyun  * the memory-region specified to the driver for use with mmap.
57*4882a593Smuzhiyun  */
58*4882a593Smuzhiyun #define ASPEED_P2A_CTRL_IOCTL_GET_MEMORY_CONFIG \
59*4882a593Smuzhiyun 	_IOWR(__ASPEED_P2A_CTRL_IOCTL_MAGIC, \
60*4882a593Smuzhiyun 		0x01, struct aspeed_p2a_ctrl_mapping)
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun #endif /* _UAPI_LINUX_ASPEED_P2A_CTRL_H */
63