3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
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.
18 Abstract: IsaAcpi implementation
24 #include "LpcDriver.h"
27 // PS/2 Keyboard Controller
29 static EFI_ISA_ACPI_RESOURCE mLpcWpce791Ps2KeyboardDeviceResources
[] = {
30 {EfiIsaAcpiResourceIo
, 0, 0x60, 0x64},
31 {EfiIsaAcpiResourceInterrupt
, 0, 1, 0},
32 {EfiIsaAcpiResourceEndOfList
, 0, 0, 0}
36 // PS/2 Mouse Controller
38 static EFI_ISA_ACPI_RESOURCE mLpcWpce791Ps2MouseDeviceResources
[] = {
39 {EfiIsaAcpiResourceIo
, 0, 0x60, 0x64},
40 {EfiIsaAcpiResourceInterrupt
, 0, 12, 0},
41 {EfiIsaAcpiResourceEndOfList
, 0, 0, 0}
47 static EFI_ISA_ACPI_RESOURCE mLpcWpce791ComDeviceResources
[] = {
48 {EfiIsaAcpiResourceIo
, 0, 0x3f8, 0x3ff},
49 {EfiIsaAcpiResourceInterrupt
, 0, 4, 0},
50 {EfiIsaAcpiResourceEndOfList
, 0, 0, 0}
54 // Table of ISA Controllers
56 EFI_ISA_ACPI_RESOURCE_LIST mLpcWpce791DeviceList
[] = {
57 {{EISA_PNP_ID(0x303), 0}, mLpcWpce791Ps2KeyboardDeviceResources
}, // PS/2 Keyboard Controller
58 {{EISA_PNP_ID(0xF03), 0}, mLpcWpce791Ps2MouseDeviceResources
}, // PS/2 Mouse Controller
59 {{EISA_PNP_ID(0x501), 0}, mLpcWpce791ComDeviceResources
}, // COM
60 {{0, 0}, NULL
} // End
63 static ICH_DMA_INIT mIchDmaInitTable
[] = {
65 //Register OFFSET, Value
68 0x0D8, 0x000, // Reset DMA Controller 2
69 0x0D0, 0x000, // Enable DMA controller 2
70 0x00C, 0x000, // Reset DMA Controller 1
71 0x008, 0x000, // Enable DMA controller 1
76 0x0D6, 0x0c0, // DMA contr. 2 Cascade mode, addr. increment, disable auto init.
77 0x0D2, 0x000, // Clear write request register
78 0x0d4, 0x000, // Enable DREQs for channel
83 0x00B, 0x040, // DMA contr. 1 single mode, addr. increment, disable auto init.
84 0x009, 0x000, // Clear write request register
85 0x00A, 0x000, // Enable DREQs for channel
90 0x00B, 0x041, // DMA contr. 1 single mode, addr. increment, disable auto init.
91 0x009, 0x001, // Clear write request register
92 0x00A, 0x001, // Enable DREQs for channel
97 0x00B, 0x042, // DMA contr. 1 single mode, addr. increment, disable auto init.
98 0x009, 0x002, // Clear write request register
99 0x00A, 0x002, // Enable DREQs for channel
104 0x00B, 0x043, // DMA contr. 1 single mode, addr. increment, disable auto init.
105 0x009, 0x003, // Clear write request register
106 0x00A, 0x003, // Enable DREQs for channel
111 0x0D6, 0x041, // DMA contr. 2 single mode, addr. increment, disable auto init.
112 0x0D2, 0x001, // Clear write request register
113 0x0D4, 0x001, // Enable DREQs for channel
118 0x0D6, 0x042, // DMA contr. 2 single mode, addr. increment, disable auto init.
119 0x0D2, 0x002, // Clear write request register
120 0x0D4, 0x002, // Enable DREQs for channel
125 0x0D6, 0x043, // DMA contr. 2 single mode, addr. increment, disable auto init.
126 0x0D2, 0x003, // Clear write request register
127 0x0D4, 0x003 // Enable DREQs for channel
132 // ISA ACPI Protocol Functions
136 Enumerate the ISA devices on the ISA bus
141 IN EFI_ISA_ACPI_DEVICE_ID
*Device
,
142 OUT EFI_ISA_ACPI_RESOURCE_LIST
**IsaAcpiDevice
,
143 OUT EFI_ISA_ACPI_RESOURCE_LIST
**NextIsaAcpiDevice
148 *IsaAcpiDevice
= NULL
;
149 if (NextIsaAcpiDevice
!= NULL
) {
150 *NextIsaAcpiDevice
= NULL
;
152 if (Device
== NULL
) {
155 for(Index
= 0; mLpcWpce791DeviceList
[Index
].Device
.HID
!= 0; Index
++) {
156 if (Device
->HID
== mLpcWpce791DeviceList
[Index
].Device
.HID
&&
157 Device
->UID
== mLpcWpce791DeviceList
[Index
].Device
.UID
) {
161 if (mLpcWpce791DeviceList
[Index
].Device
.HID
== 0) {
164 *IsaAcpiDevice
= &(mLpcWpce791DeviceList
[Index
]);
167 if (NextIsaAcpiDevice
!= NULL
&& mLpcWpce791DeviceList
[Index
].Device
.HID
!= 0){
168 *NextIsaAcpiDevice
= &(mLpcWpce791DeviceList
[Index
]);
174 Enumerate the ISA devices on the ISA bus
175 It is hard code now and future it will get from ACPI table
181 IN EFI_ISA_ACPI_PROTOCOL
*This
,
182 OUT EFI_ISA_ACPI_DEVICE_ID
**Device
185 EFI_ISA_ACPI_RESOURCE_LIST
*IsaAcpiDevice
;
186 EFI_ISA_ACPI_RESOURCE_LIST
*NextIsaAcpiDevice
;
188 IsaDeviceLookup (*Device
, &IsaAcpiDevice
, &NextIsaAcpiDevice
);
189 if (NextIsaAcpiDevice
== NULL
) {
190 return EFI_NOT_FOUND
;
192 *Device
= &(NextIsaAcpiDevice
->Device
);
197 Set ISA device power use sio
203 IN EFI_ISA_ACPI_PROTOCOL
*This
,
204 IN EFI_ISA_ACPI_DEVICE_ID
*Device
,
208 return EFI_UNSUPPORTED
;
213 Get current Resource of the specific ISA device
214 It is hardcode now and future will get from ACPI table
219 IsaGetCurrentResource (
220 IN EFI_ISA_ACPI_PROTOCOL
*This
,
221 IN EFI_ISA_ACPI_DEVICE_ID
*Device
,
222 OUT EFI_ISA_ACPI_RESOURCE_LIST
**ResourceList
225 IsaDeviceLookup (Device
, ResourceList
, NULL
);
226 if (*ResourceList
== NULL
|| (*ResourceList
)->ResourceItem
== NULL
) {
227 return EFI_NOT_FOUND
;
234 IsaGetPossibleResource (
235 IN EFI_ISA_ACPI_PROTOCOL
*This
,
236 IN EFI_ISA_ACPI_DEVICE_ID
*Device
,
237 OUT EFI_ISA_ACPI_RESOURCE_LIST
**ResourceList
243 return EFI_UNSUPPORTED
;
250 IN EFI_ISA_ACPI_PROTOCOL
*This
,
251 IN EFI_ISA_ACPI_DEVICE_ID
*Device
,
252 IN EFI_ISA_ACPI_RESOURCE_LIST
*ResourceList
255 return EFI_UNSUPPORTED
;
261 IN EFI_ISA_ACPI_PROTOCOL
*This
,
262 IN EFI_ISA_ACPI_DEVICE_ID
*Device
,
267 return EFI_UNSUPPORTED
;
272 Clear out Resource List if device is set to disable by platform policy
281 for (Index
= 0; mLpcWpce791DeviceList
[Index
].Device
.HID
!= 0; Index
++) {
282 if (DeviceHid
== mLpcWpce791DeviceList
[Index
].Device
.HID
) {
283 mLpcWpce791DeviceList
[Index
].ResourceItem
= NULL
;
291 Clear out Resource List if device is set to disable by platform policy
295 EmptyResourceListHidUid (
301 for (Index
= 0; mLpcWpce791DeviceList
[Index
].Device
.HID
!= 0; Index
++) {
302 if ((DeviceHid
== mLpcWpce791DeviceList
[Index
].Device
.HID
) &&
303 (DeviceUid
== mLpcWpce791DeviceList
[Index
].Device
.UID
)) {
304 mLpcWpce791DeviceList
[Index
].ResourceItem
= NULL
;
313 IN EFI_ISA_ACPI_PROTOCOL
*This
,
314 IN EFI_ISA_ACPI_DEVICE_ID
*Device
317 EFI_WPCE791_POLICY_PROTOCOL
*LpcWpce791Policy
;
321 // Disable configuration according to platform protocol
323 Status
= gBS
->LocateProtocol (
324 &gEfiLpcWpce791PolicyProtocolGuid
,
326 (VOID
**) &LpcWpce791Policy
328 if (!EFI_ERROR(Status
)) {
329 if (LpcWpce791Policy
->DeviceEnables
.Ps2Keyboard
== EFI_WPCE791_PS2_KEYBOARD_DISABLE
) {
330 EmptyResourceList(EISA_PNP_ID(0x303));
331 DisableLogicalDevice (SIO_KEYBOARD
);
332 EmptyResourceList(EISA_PNP_ID(0xF03));
333 DisableLogicalDevice (SIO_KEYBOARD
);
335 if (LpcWpce791Policy
->DeviceEnables
.Ps2Mouse
== EFI_WPCE791_PS2_MOUSE_DISABLE
) {
336 EmptyResourceList(EISA_PNP_ID(0xF03));
337 DisableLogicalDevice (SIO_MOUSE
);
347 IN EFI_ISA_ACPI_PROTOCOL
*This
350 EFI_PCI_IO_PROTOCOL
*PciIo
;
353 PciIo
= (LPC_ISA_ACPI_FROM_THIS (This
))->PciIo
;
356 // DMA controller initialize
358 for (Index
=0; Index
< (sizeof(mIchDmaInitTable
)/sizeof(ICH_DMA_INIT
)); Index
++) {
362 EFI_PCI_IO_PASS_THROUGH_BAR
,
363 mIchDmaInitTable
[Index
].Register
,
365 &mIchDmaInitTable
[Index
].Value