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