Program SD Cards into 4-bit mode (support for this is required in the spec). This...
[mirror_edk2.git] / PcAtChipsetPkg / IsaAcpiDxe / IsaAcpi.c
CommitLineData
18c97f53 1/** @file\r
2 ISA ACPI Protocol Implementation\r
c69dd9df 3\r
95d48e82 4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
18c97f53 5This program and the accompanying materials \r
c69dd9df 6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
18c97f53 12**/\r
c69dd9df 13\r
14#include "PcatIsaAcpi.h"\r
15\r
16//\r
17// Platform specific data for the ISA devices that are present.in the platform\r
18//\r
19\r
20//\r
21// COM 1 UART Controller\r
22//\r
e56dd2ce 23EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom1DeviceResources[] = {\r
c69dd9df 24 {EfiIsaAcpiResourceIo, 0, 0x3f8, 0x3ff},\r
25 {EfiIsaAcpiResourceInterrupt, 0, 4, 0},\r
26 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
27};\r
28\r
29//\r
30// COM 2 UART Controller\r
31//\r
e56dd2ce 32EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom2DeviceResources[] = {\r
c69dd9df 33 {EfiIsaAcpiResourceIo, 0, 0x2f8, 0x2ff},\r
34 {EfiIsaAcpiResourceInterrupt, 0, 3, 0},\r
35 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
36};\r
37\r
38//\r
39// PS/2 Keyboard Controller\r
40//\r
e56dd2ce 41EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2KeyboardDeviceResources[] = {\r
c69dd9df 42 {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},\r
43 {EfiIsaAcpiResourceInterrupt, 0, 1, 0},\r
44 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
45};\r
46\r
47//\r
48// PS/2 Mouse Controller\r
49//\r
e56dd2ce 50EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2MouseDeviceResources[] = {\r
c69dd9df 51 {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},\r
52 {EfiIsaAcpiResourceInterrupt, 0, 12, 0},\r
53 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
54};\r
55\r
56//\r
57// Floppy Disk Controller\r
58//\r
e56dd2ce 59EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiFloppyResources[] = {\r
c69dd9df 60 {EfiIsaAcpiResourceIo, 0, 0x3f0, 0x3f7},\r
61 {EfiIsaAcpiResourceInterrupt, 0, 6, 0},\r
62 {EfiIsaAcpiResourceDma, EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE | EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8 | EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE, 2, 0},\r
63 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
64};\r
65\r
66//\r
67// Table of ISA Controllers\r
68//\r
69EFI_ISA_ACPI_RESOURCE_LIST gPcatIsaAcpiDeviceList[] = {\r
70 {{EISA_PNP_ID(0x501), 0}, mPcatIsaAcpiCom1DeviceResources }, // COM 1 UART Controller\r
71 {{EISA_PNP_ID(0x501), 1}, mPcatIsaAcpiCom2DeviceResources }, // COM 2 UART Controller\r
72 {{EISA_PNP_ID(0x303), 0}, mPcatIsaAcpiPs2KeyboardDeviceResources }, // PS/2 Keyboard Controller\r
73 {{EISA_PNP_ID(0x303), 1}, mPcatIsaAcpiPs2MouseDeviceResources }, // PS/2 Mouse Controller\r
74 {{EISA_PNP_ID(0x604), 0}, mPcatIsaAcpiFloppyResources }, // Floppy Disk Controller A:\r
75 {{EISA_PNP_ID(0x604), 1}, mPcatIsaAcpiFloppyResources }, // Floppy Disk Controller B:\r
76 {{0, 0}, NULL } // End if ISA Controllers\r
77};\r
78\r
79//\r
80// ISA ACPI Protocol Functions\r
81//\r
18c97f53 82/**\r
83 Enumerate the ISA devices on the ISA bus.\r
84\r
85 @param Device Point to device ID instance \r
86 @param IsaAcpiDevice On return, point to resource data for Isa device\r
87 @param NextIsaAcpiDevice On return, point to resource data for next Isa device\r
88**/\r
c69dd9df 89VOID\r
90IsaDeviceLookup (\r
91 IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
92 OUT EFI_ISA_ACPI_RESOURCE_LIST **IsaAcpiDevice,\r
93 OUT EFI_ISA_ACPI_RESOURCE_LIST **NextIsaAcpiDevice\r
94 )\r
c69dd9df 95{\r
96 UINTN Index;\r
97\r
98 *IsaAcpiDevice = NULL;\r
99 if (NextIsaAcpiDevice != NULL) {\r
100 *NextIsaAcpiDevice = NULL;\r
101 }\r
102 if (Device == NULL) {\r
103 Index = 0;\r
104 } else {\r
105 for(Index = 0; gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL; Index++) {\r
106 if (Device->HID == gPcatIsaAcpiDeviceList[Index].Device.HID && \r
107 Device->UID == gPcatIsaAcpiDeviceList[Index].Device.UID ) {\r
108 break;\r
109 }\r
110 }\r
111 if (gPcatIsaAcpiDeviceList[Index].ResourceItem == NULL) {\r
112 return;\r
113 }\r
114 *IsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);\r
115 Index++;\r
116 }\r
117 if (gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL && NextIsaAcpiDevice != NULL) {\r
118 *NextIsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);\r
119 }\r
120}\r
121\r
18c97f53 122/**\r
123 Enumerate the ISA devices on the ISA bus\r
124\r
125\r
126 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
127 @param Device Point to device ID instance \r
128\r
129 @retval EFI_NOT_FOUND Can not found the next Isa device.\r
130 @retval EFI_SUCESS Success retrieve the next Isa device for enumration.\r
131\r
132**/\r
c69dd9df 133EFI_STATUS\r
134EFIAPI\r
135IsaDeviceEnumerate (\r
136 IN EFI_ISA_ACPI_PROTOCOL *This,\r
137 OUT EFI_ISA_ACPI_DEVICE_ID **Device\r
138 )\r
c69dd9df 139{\r
140 EFI_ISA_ACPI_RESOURCE_LIST *IsaAcpiDevice;\r
141 EFI_ISA_ACPI_RESOURCE_LIST *NextIsaAcpiDevice;\r
142\r
143 IsaDeviceLookup (*Device, &IsaAcpiDevice, &NextIsaAcpiDevice);\r
144 if (NextIsaAcpiDevice == NULL) {\r
145 return EFI_NOT_FOUND;\r
146 }\r
147 *Device = &(NextIsaAcpiDevice->Device);\r
148 return EFI_SUCCESS;\r
149}\r
150\r
18c97f53 151/**\r
152 Set ISA device power\r
153\r
154\r
155 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
156 @param Device Point to device ID instance \r
157 @param OnOff TRUE for setting isa device power on,\r
158 FALSE for setting isa device power off\r
159\r
160 @return EFI_SUCCESS Sucess to change power status for isa device.\r
161**/\r
c69dd9df 162EFI_STATUS\r
163EFIAPI\r
164IsaDeviceSetPower (\r
165 IN EFI_ISA_ACPI_PROTOCOL *This,\r
166 IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
167 IN BOOLEAN OnOff\r
168 )\r
c69dd9df 169{\r
170 return EFI_SUCCESS;\r
171} \r
172\r
18c97f53 173/**\r
174 Get current resource for the specific ISA device.\r
175\r
176 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
177 @param Device Point to device ID instance \r
178 @param ResourceList On return, point to resources instances for given isa device\r
179\r
180 @retval EFI_NOT_FOUND Can not found the resource instance for given isa device\r
181 @retval EFI_SUCCESS Success to get resource instance for given isa device.\r
182**/\r
c69dd9df 183EFI_STATUS\r
184EFIAPI\r
185IsaGetCurrentResource (\r
186 IN EFI_ISA_ACPI_PROTOCOL *This,\r
187 IN EFI_ISA_ACPI_DEVICE_ID *Device, \r
188 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList\r
189 )\r
c69dd9df 190{\r
191 IsaDeviceLookup (Device, ResourceList, NULL);\r
192 if (*ResourceList == NULL) {\r
193 return EFI_NOT_FOUND;\r
194 }\r
195 return EFI_SUCCESS;\r
196}\r
197\r
18c97f53 198/**\r
199 Get possible resource for the specific ISA device.\r
200 \r
201 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
202 @param Device Point to device ID instance \r
203 @param ResourceList On return, point to resources instances for given isa device\r
204\r
205 @retval EFI_SUCCESS Success to get resource instance for given isa device.\r
206**/\r
c69dd9df 207EFI_STATUS\r
208EFIAPI\r
209IsaGetPossibleResource (\r
210 IN EFI_ISA_ACPI_PROTOCOL *This,\r
211 IN EFI_ISA_ACPI_DEVICE_ID *Device, \r
212 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList\r
213 )\r
c69dd9df 214{\r
215 return EFI_SUCCESS;\r
216}\r
217\r
18c97f53 218/**\r
219 Set resource for the specific ISA device.\r
220\r
221 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
222 @param Device Point to device ID instance \r
223 @param ResourceList Point to resources instances for given isa device\r
224\r
225 @return EFI_SUCESS Success to set resource.\r
226\r
227**/\r
c69dd9df 228EFI_STATUS\r
229EFIAPI\r
230IsaSetResource (\r
231 IN EFI_ISA_ACPI_PROTOCOL *This,\r
232 IN EFI_ISA_ACPI_DEVICE_ID *Device, \r
233 IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList\r
234 )\r
c69dd9df 235{\r
236 return EFI_SUCCESS;\r
237}\r
238 \r
18c97f53 239/**\r
240 Enable/Disable the specific ISA device.\r
241\r
242 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
243 @param Device Point to device ID instance \r
244 @param Enable Enable/Disable\r
245\r
246 @return EFI_SUCESS Success to enable/disable.\r
247\r
248**/\r
c69dd9df 249EFI_STATUS\r
250EFIAPI\r
251IsaEnableDevice (\r
252 IN EFI_ISA_ACPI_PROTOCOL *This,\r
253 IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
254 IN BOOLEAN Enable\r
255 )\r
c69dd9df 256{\r
257 return EFI_SUCCESS; \r
258}\r
259\r
18c97f53 260/**\r
261 Initialize the specific ISA device.\r
262\r
263 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
264 @param Device Point to device ID instance \r
265\r
266 @return EFI_SUCESS Success to initialize.\r
267\r
268**/\r
c69dd9df 269EFI_STATUS\r
270EFIAPI\r
271IsaInitDevice (\r
272 IN EFI_ISA_ACPI_PROTOCOL *This,\r
273 IN EFI_ISA_ACPI_DEVICE_ID *Device\r
274 )\r
c69dd9df 275{\r
276 return EFI_SUCCESS;\r
277}\r
278\r
279\r
18c97f53 280/**\r
281 Initialize the ISA interface.\r
282\r
283 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL\r
284\r
285 @return EFI_SUCESS Success to initialize ISA interface.\r
286\r
287**/\r
c69dd9df 288EFI_STATUS\r
289EFIAPI\r
290IsaInterfaceInit (\r
291 IN EFI_ISA_ACPI_PROTOCOL *This\r
292) \r
c69dd9df 293{\r
294 return EFI_SUCCESS;\r
295} \r