+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
- \r\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
- \r\r
-\r
-Module Name:\r
-\r
- LpcIsaAcpi.c\r
-\r
-Abstract: IsaAcpi implementation\r
-\r
-\r
-\r
---*/\r
-\r
-#include "LpcDriver.h"\r
-\r
-//\r
-// PS/2 Keyboard Controller\r
-//\r
-static EFI_ISA_ACPI_RESOURCE mLpcWpce791Ps2KeyboardDeviceResources[] = {\r
- {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},\r
- {EfiIsaAcpiResourceInterrupt, 0, 1, 0},\r
- {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
-};\r
-\r
-//\r
-// PS/2 Mouse Controller\r
-//\r
-static EFI_ISA_ACPI_RESOURCE mLpcWpce791Ps2MouseDeviceResources[] = {\r
- {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},\r
- {EfiIsaAcpiResourceInterrupt, 0, 12, 0},\r
- {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
-};\r
-\r
-//\r
-// COM\r
-//\r
-static EFI_ISA_ACPI_RESOURCE mLpcWpce791ComDeviceResources[] = {\r
- {EfiIsaAcpiResourceIo, 0, 0x3f8, 0x3ff},\r
- {EfiIsaAcpiResourceInterrupt, 0, 4, 0},\r
- {EfiIsaAcpiResourceEndOfList, 0, 0, 0}\r
-};\r
-\r
-//\r
-// Table of ISA Controllers\r
-//\r
-EFI_ISA_ACPI_RESOURCE_LIST mLpcWpce791DeviceList[] = {\r
- {{EISA_PNP_ID(0x303), 0}, mLpcWpce791Ps2KeyboardDeviceResources }, // PS/2 Keyboard Controller\r
- {{EISA_PNP_ID(0xF03), 0}, mLpcWpce791Ps2MouseDeviceResources }, // PS/2 Mouse Controller\r
- {{EISA_PNP_ID(0x501), 0}, mLpcWpce791ComDeviceResources }, // COM\r
- {{0, 0}, NULL } // End\r
-};\r
-\r
-static ICH_DMA_INIT mIchDmaInitTable [] = {\r
-//\r
-//Register OFFSET, Value\r
-//\r
-\r
- 0x0D8, 0x000, // Reset DMA Controller 2\r
- 0x0D0, 0x000, // Enable DMA controller 2\r
- 0x00C, 0x000, // Reset DMA Controller 1\r
- 0x008, 0x000, // Enable DMA controller 1\r
-\r
- //\r
- // Channel 4\r
- //\r
- 0x0D6, 0x0c0, // DMA contr. 2 Cascade mode, addr. increment, disable auto init.\r
- 0x0D2, 0x000, // Clear write request register\r
- 0x0d4, 0x000, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 0\r
- //\r
- 0x00B, 0x040, // DMA contr. 1 single mode, addr. increment, disable auto init.\r
- 0x009, 0x000, // Clear write request register\r
- 0x00A, 0x000, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 1\r
- //\r
- 0x00B, 0x041, // DMA contr. 1 single mode, addr. increment, disable auto init.\r
- 0x009, 0x001, // Clear write request register\r
- 0x00A, 0x001, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 2\r
- //\r
- 0x00B, 0x042, // DMA contr. 1 single mode, addr. increment, disable auto init.\r
- 0x009, 0x002, // Clear write request register\r
- 0x00A, 0x002, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 3\r
- //\r
- 0x00B, 0x043, // DMA contr. 1 single mode, addr. increment, disable auto init.\r
- 0x009, 0x003, // Clear write request register\r
- 0x00A, 0x003, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 5\r
- //\r
- 0x0D6, 0x041, // DMA contr. 2 single mode, addr. increment, disable auto init.\r
- 0x0D2, 0x001, // Clear write request register\r
- 0x0D4, 0x001, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 6\r
- //\r
- 0x0D6, 0x042, // DMA contr. 2 single mode, addr. increment, disable auto init.\r
- 0x0D2, 0x002, // Clear write request register\r
- 0x0D4, 0x002, // Enable DREQs for channel\r
-\r
- //\r
- // Channel 7\r
- //\r
- 0x0D6, 0x043, // DMA contr. 2 single mode, addr. increment, disable auto init.\r
- 0x0D2, 0x003, // Clear write request register\r
- 0x0D4, 0x003 // Enable DREQs for channel\r
-\r
-};\r
-\r
-//\r
-// ISA ACPI Protocol Functions\r
-//\r
-/**\r
-\r
- Enumerate the ISA devices on the ISA bus\r
-\r
-**/\r
-VOID\r
-IsaDeviceLookup (\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
- OUT EFI_ISA_ACPI_RESOURCE_LIST **IsaAcpiDevice,\r
- OUT EFI_ISA_ACPI_RESOURCE_LIST **NextIsaAcpiDevice\r
- )\r
-{\r
- UINTN Index;\r
-\r
- *IsaAcpiDevice = NULL;\r
- if (NextIsaAcpiDevice != NULL) {\r
- *NextIsaAcpiDevice = NULL;\r
- }\r
- if (Device == NULL) {\r
- Index = 0;\r
- } else {\r
- for(Index = 0; mLpcWpce791DeviceList[Index].Device.HID != 0; Index++) {\r
- if (Device->HID == mLpcWpce791DeviceList[Index].Device.HID &&\r
- Device->UID == mLpcWpce791DeviceList[Index].Device.UID ) {\r
- break;\r
- }\r
- }\r
- if (mLpcWpce791DeviceList[Index].Device.HID == 0) {\r
- return;\r
- }\r
- *IsaAcpiDevice = &(mLpcWpce791DeviceList[Index]);\r
- Index++;\r
- }\r
- if (NextIsaAcpiDevice != NULL && mLpcWpce791DeviceList[Index].Device.HID != 0){\r
- *NextIsaAcpiDevice = &(mLpcWpce791DeviceList[Index]);\r
- }\r
-}\r
-\r
-\r
-/**\r
- Enumerate the ISA devices on the ISA bus\r
- It is hard code now and future it will get from ACPI table\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaDeviceEnumerate (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- OUT EFI_ISA_ACPI_DEVICE_ID **Device\r
- )\r
-{\r
- EFI_ISA_ACPI_RESOURCE_LIST *IsaAcpiDevice;\r
- EFI_ISA_ACPI_RESOURCE_LIST *NextIsaAcpiDevice;\r
-\r
- IsaDeviceLookup (*Device, &IsaAcpiDevice, &NextIsaAcpiDevice);\r
- if (NextIsaAcpiDevice == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
- *Device = &(NextIsaAcpiDevice->Device);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Set ISA device power use sio\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaDeviceSetPower (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
- IN BOOLEAN OnOff\r
- )\r
-{\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
- Get current Resource of the specific ISA device\r
- It is hardcode now and future will get from ACPI table\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsaGetCurrentResource (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
- OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList\r
- )\r
-{\r
- IsaDeviceLookup (Device, ResourceList, NULL);\r
- if (*ResourceList == NULL || (*ResourceList)->ResourceItem == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-IsaGetPossibleResource (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
- OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList\r
- )\r
-{\r
- //\r
- // Not supported yet\r
- //\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-IsaSetResource (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
- IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList\r
- )\r
-{\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-IsaEnableDevice (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device,\r
- IN BOOLEAN Enable\r
- )\r
-{\r
-\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-\r
- Clear out Resource List if device is set to disable by platform policy\r
-\r
-**/\r
-VOID\r
-EmptyResourceList (\r
- IN UINT32 DeviceHid\r
- )\r
-{\r
- UINT8 Index;\r
- for (Index = 0; mLpcWpce791DeviceList[Index].Device.HID != 0; Index++) {\r
- if (DeviceHid == mLpcWpce791DeviceList[Index].Device.HID) {\r
- mLpcWpce791DeviceList[Index].ResourceItem = NULL;\r
- }\r
- }\r
- return;\r
-}\r
-\r
-/**\r
-\r
- Clear out Resource List if device is set to disable by platform policy\r
-\r
-**/\r
-VOID\r
-EmptyResourceListHidUid (\r
- IN UINT32 DeviceHid,\r
- IN UINT32 DeviceUid\r
- )\r
-{\r
- UINT8 Index;\r
- for (Index = 0; mLpcWpce791DeviceList[Index].Device.HID != 0; Index++) {\r
- if ((DeviceHid == mLpcWpce791DeviceList[Index].Device.HID) &&\r
- (DeviceUid == mLpcWpce791DeviceList[Index].Device.UID)) {\r
- mLpcWpce791DeviceList[Index].ResourceItem = NULL;\r
- }\r
- }\r
- return;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-IsaInitDevice (\r
- IN EFI_ISA_ACPI_PROTOCOL *This,\r
- IN EFI_ISA_ACPI_DEVICE_ID *Device\r
- )\r
-{\r
- EFI_WPCE791_POLICY_PROTOCOL *LpcWpce791Policy;\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Disable configuration according to platform protocol\r
- //\r
- Status = gBS->LocateProtocol (\r
- &gEfiLpcWpce791PolicyProtocolGuid,\r
- NULL,\r
- (VOID **) &LpcWpce791Policy\r
- );\r
- if (!EFI_ERROR(Status)) {\r
- if (LpcWpce791Policy->DeviceEnables.Ps2Keyboard == EFI_WPCE791_PS2_KEYBOARD_DISABLE) {\r
- EmptyResourceList(EISA_PNP_ID(0x303));\r
- DisableLogicalDevice (SIO_KEYBOARD);\r
- EmptyResourceList(EISA_PNP_ID(0xF03));\r
- DisableLogicalDevice (SIO_KEYBOARD);\r
- }\r
- if (LpcWpce791Policy->DeviceEnables.Ps2Mouse == EFI_WPCE791_PS2_MOUSE_DISABLE) {\r
- EmptyResourceList(EISA_PNP_ID(0xF03));\r
- DisableLogicalDevice (SIO_MOUSE);\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-LpcInterfaceInit (\r
- IN EFI_ISA_ACPI_PROTOCOL *This\r
- )\r
-{\r
- EFI_PCI_IO_PROTOCOL *PciIo;\r
- UINTN Index;\r
-\r
- PciIo = (LPC_ISA_ACPI_FROM_THIS (This))->PciIo;\r
-\r
- //\r
- // DMA controller initialize\r
- //\r
- for (Index=0; Index < (sizeof(mIchDmaInitTable)/sizeof(ICH_DMA_INIT)); Index++) {\r
- PciIo->Io.Write (\r
- PciIo,\r
- EfiPciIoWidthUint8,\r
- EFI_PCI_IO_PASS_THROUGH_BAR,\r
- mIchDmaInitTable[Index].Register,\r
- 1,\r
- &mIchDmaInitTable[Index].Value\r
- );\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r