MdePkg: Add SIO related protocol/PPI definitions.
[mirror_edk2.git] / Include / Ppi / SuperIo.h
1 /** @file
2 This PPI provides the super I/O register access functionality.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 @par Revision Reference:
14 This PPI is from PI Version 1.2.1.
15
16 **/
17
18 #ifndef __EFI_SUPER_IO_PPI_H__
19 #define __EFI_SUPER_IO_PPI_H__
20
21 #include <Protocol/SuperIo.h>
22
23 #define EFI_SIO_PPI_GUID \
24 { \
25 0x23a464ad, 0xcb83, 0x48b8, {0x94, 0xab, 0x1a, 0x6f, 0xef, 0xcf, 0xe5, 0x22} \
26 }
27
28 typedef struct _EFI_SIO_PPI EFI_SIO_PPI;
29 typedef struct _EFI_SIO_PPI *PEFI_SIO_PPI;
30
31 typedef UINT16 EFI_SIO_REGISTER;
32 #define EFI_SIO_REG(ldn,reg) (EFI_SIO_REGISTER) (((ldn) << 8) | reg)
33 #define EFI_SIO_LDN_GLOBAL 0xFF
34
35 /**
36 Read a Super I/O register.
37
38 The register is specified as an 8-bit logical device number and an 8-bit
39 register value. The logical device numbers for specific SIO devices can be
40 determined using the Info member of the PPI structure.
41
42 @param This A pointer to this instance of the EFI_SIO_PPI.
43 @param ExitCfgMode A boolean specifying whether the driver should turn on
44 configuration mode (FALSE) or turn off configuration mode
45 (TRUE) after completing the read operation. The driver must
46 track the current state of the configuration mode (if any)
47 and turn on configuration mode (if necessary) prior to
48 register access.
49 @param Register A value specifying the logical device number (bits 15:8)
50 and the register to read (bits 7:0). The logical device
51 number of EFI_SIO_LDN_GLOBAL indicates that global
52 registers will be used.
53 @param IoData A pointer to the returned register value.
54
55 @retval EFI_SUCCESS Success.
56 @regval EFI_TIMEOUT The register could not be read in the a reasonable
57 amount of time. The exact time is device-specific.
58 @retval EFI_INVALID_PARAMETERS Register was out of range for this device.
59 @retval EFI_INVALID_PARAMETERS IoData was NULL
60 @retval EFI_DEVICE_ERROR There was a device fault or the device was not present.
61 **/
62 typedef
63 EFI_STATUS
64 (EFIAPI *EFI_PEI_SIO_REGISTER_READ)(
65 IN CONST EFI_SIO_PPI *This,
66 IN BOOLEAN ExitCfgMode,
67 IN EFI_SIO_REGISTER Register,
68 OUT UINT8 *IoData
69 );
70
71 /**
72 Write a Super I/O register.
73
74 The register is specified as an 8-bit logical device number and an 8-bit register
75 value. The logical device numbers for specific SIO devices can be determined
76 using the Info member of the PPI structure.
77
78 @param This A pointer to this instance of the EFI_SIO_PPI.
79 @param ExitCfgMode A boolean specifying whether the driver should turn on
80 configuration mode (FALSE) or turn off configuration mode
81 (TRUE) after completing the read operation. The driver must
82 track the current state of the configuration mode (if any)
83 and turn on configuration mode (if necessary) prior to
84 register access.
85 @param Register A value specifying the logical device number (bits 15:8)
86 and the register to read (bits 7:0). The logical device
87 number of EFI_SIO_LDN_GLOBAL indicates that global
88 registers will be used.
89 @param IoData A pointer to the returned register value.
90
91 @retval EFI_SUCCESS Success.
92 @regval EFI_TIMEOUT The register could not be read in the a reasonable
93 amount of time. The exact time is device-specific.
94 @retval EFI_INVALID_PARAMETERS Register was out of range for this device.
95 @retval EFI_INVALID_PARAMETERS IoData was NULL
96 @retval EFI_DEVICE_ERROR There was a device fault or the device was not present.
97 **/
98 typedef
99 EFI_STATUS
100 (EFIAPI *EFI_PEI_SIO_REGISTER_WRITE)(
101 IN CONST EFI_SIO_PPI *This,
102 IN BOOLEAN ExitCfgMode,
103 IN EFI_SIO_REGISTER Register,
104 IN UINT8 IoData
105 );
106
107 /**
108 Provides an interface for a table based programming of the Super I/O registers.
109
110 The Modify() function provides an interface for table based programming of the
111 Super I/O registers. This function can be used to perform programming of
112 multiple Super I/O registers with a single function call. For each table entry,
113 the Register is read, its content is bitwise ANDed with AndMask, and then ORed
114 with OrMask before being written back to the Register. The Super I/O driver
115 must track the current state of the Super I/O and enable the configuration mode
116 of Super I/O if necessary prior to table processing. Once the table is processed,
117 the Super I/O device must be returned to the original state.
118
119 @param This A pointer to this instance of the EFI_SIO_PPI.
120 @param Command A pointer to an array of NumberOfCommands EFI_SIO_REGISTER_MODIFY
121 structures. Each structure specifies a single Super I/O register
122 modify operation.
123 @param NumberOfCommands The number of elements in the Command array.
124
125 @retval EFI_SUCCESS The operation completed successfully.
126 @retval EFI_INVALID_PARAMETERS Command is NULL.
127 **/
128 typedef
129 EFI_STATUS
130 (EFIAPI *EFI_PEI_SIO_REGISTER_MODIFY)(
131 IN CONST EFI_SIO_PPI *This,
132 IN CONST EFI_SIO_REGISTER_MODIFY *Command,
133 IN UINTN NumberOfCommands
134 );
135
136 ///
137 /// Specifies the end of the information list.
138 ///
139 #define EFI_ACPI_PNP_HID_END 0
140
141 typedef UINT32 EFI_ACPI_HID;
142 typedef UINT32 EFI_ACPI_UID;
143 #pragma pack(1)
144 typedef struct _EFI_SIO_INFO {
145 EFI_ACPI_HID Hid;
146 EFI_ACPI_UID Uid;
147 UINT8 Ldn;
148 } EFI_SIO_INFO, *PEFI_SIO_INFO;
149 #pragma pack()
150
151 ///
152 /// This PPI provides low-level access to Super I/O registers using Read() and
153 /// Write(). It also uniquely identifies this Super I/O controller using a GUID
154 /// and provides mappings between ACPI style PNP IDs and the logical device numbers.
155 /// There is one instance of this PPI per Super I/O device.
156 ///
157 struct _EFI_SIO_PPI {
158 ///
159 /// This function reads a register's value from the Super I/O controller.
160 ///
161 EFI_PEI_SIO_REGISTER_READ Read;
162 ///
163 /// This function writes a value to a register in the Super I/O controller.
164 ///
165 EFI_PEI_SIO_REGISTER_WRITE Write;
166 ///
167 /// This function modifies zero or more registers in the Super I/O controller
168 /// using a table.
169 ///
170 EFI_PEI_SIO_REGISTER_MODIFY Modify;
171 ///
172 /// This GUID uniquely identifies the Super I/O controller.
173 ///
174 EFI_GUID SioGuid;
175 ///
176 /// This pointer is to an array which maps EISA identifiers to logical devices numbers.
177 ///
178 PEFI_SIO_INFO Info;
179 };
180
181 extern EFI_GUID gEfiSioPpiGuid;
182
183 #endif