]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkPlatformPkg/Pci/Dxe/PciHostBridge/PciHostBridgeSupport.c
QuarkPlatformPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkPlatformPkg / Pci / Dxe / PciHostBridge / PciHostBridgeSupport.c
CommitLineData
b303605e
MK
1/** @file\r
2Do platform initialization for PCI bridge.\r
3\r
4Copyright (c) 2013-2015 Intel Corporation.\r
5\r
0eb3de2e 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
b303605e
MK
7\r
8\r
9**/\r
10\r
11#include "PciHostBridge.h"\r
12\r
13EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo;\r
14\r
15EFI_STATUS\r
16ChipsetPreprocessController (\r
17 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
18 IN EFI_HANDLE RootBridgeHandle,\r
19 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,\r
20 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase\r
21 )\r
22/*++\r
23\r
24Routine Description:\r
25 This function is called for all the PCI controllers that the PCI\r
26 bus driver finds. Can be used to Preprogram the controller.\r
27\r
28Arguments:\r
29 This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
30 RootBridgeHandle -- The PCI Root Bridge handle\r
31 PciBusAddress -- Address of the controller on the PCI bus\r
32 Phase -- The Phase during resource allocation\r
33\r
34Returns:\r
35 EFI_SUCCESS\r
36\r
37--*/\r
38\r
39// GC_TODO: PciAddress - add argument and description to function comment\r
40//\r
41// GC_TODO: PciAddress - add argument and description to function comment\r
42//\r
43// GC_TODO: PciAddress - add argument and description to function comment\r
44//\r
45// GC_TODO: PciAddress - add argument and description to function comment\r
46//\r
47{\r
48\r
49 EFI_STATUS Status;\r
50 UINT8 Latency;\r
51 UINT8 CacheLineSize;\r
52\r
53 if (mPciRootBridgeIo == NULL) {\r
54 //\r
55 // Get root bridge in the system.\r
56 //\r
57 Status = gBS->HandleProtocol (RootBridgeHandle, &gEfiPciRootBridgeIoProtocolGuid, (VOID **) &mPciRootBridgeIo);\r
58 ASSERT_EFI_ERROR (Status);\r
59 }\r
60\r
61 if (Phase == EfiPciBeforeResourceCollection) {\r
62 //\r
63 // Program the latency register, CLS register\r
64 //\r
65 PciAddress.Register = PCI_LATENCY_TIMER_OFFSET;\r
66 mPciRootBridgeIo->Pci.Read (\r
67 mPciRootBridgeIo,\r
68 EfiPciWidthUint8,\r
69 *((UINT64 *) &PciAddress),\r
70 1,\r
71 &Latency\r
72 );\r
73\r
74 //\r
75 // PCI-x cards come up with a default latency of 0x40. Don't touch them.\r
76 //\r
77 if (Latency == 0) {\r
78 Latency = DEFAULT_PCI_LATENCY;\r
79 mPciRootBridgeIo->Pci.Write (\r
80 mPciRootBridgeIo,\r
81 EfiPciWidthUint8,\r
82 *((UINT64 *) &PciAddress),\r
83 1,\r
84 &Latency\r
85 );\r
86 }\r
87 //\r
88 // Program Cache Line Size as 64bytes\r
89 // 16 of DWORDs = 64bytes (0x10)\r
90 //\r
91 PciAddress.Register = PCI_CACHELINE_SIZE_OFFSET;\r
92 CacheLineSize = 0x10;\r
93 mPciRootBridgeIo->Pci.Write (\r
94 mPciRootBridgeIo,\r
95 EfiPciWidthUint8,\r
96 *((UINT64 *) &PciAddress),\r
97 1,\r
98 &CacheLineSize\r
99 );\r
100\r
101 }\r
102\r
103 return EFI_SUCCESS;\r
104}\r
105\r
106UINT64\r
107GetAllocAttributes (\r
108 IN UINTN RootBridgeIndex\r
109 )\r
110/*++\r
111\r
112Routine Description:\r
113\r
114 Returns the Allocation attributes for the BNB Root Bridge.\r
115\r
116Arguments:\r
117\r
118 RootBridgeIndex - The root bridge number. 0 based.\r
119\r
120Returns:\r
121\r
122 EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | EFI_PCI_HOST_BRIDGE_MEM64_DECODE\r
123\r
124--*/\r
125{\r
126 //\r
127 // Cannot have more than one Root bridge\r
128 //\r
129 //ASSERT (RootBridgeIndex == 0);\r
130\r
131 //\r
132 // PCI Root Bridge does not support separate windows for Non-prefetchable\r
133 // and Prefetchable memory. A PCI bus driver needs to include requests for\r
134 // Prefetchable memory in the Non-prefetchable memory pool.\r
135 // Further TNB does not support 64 bit memory apertures for PCI. BNB\r
136 // can only have system memory above 4 GB,\r
137 //\r
138\r
139 return EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | EFI_PCI_HOST_BRIDGE_MEM64_DECODE;\r
140}\r