summaryrefslogtreecommitdiff
path: root/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPostMem/BoardInitMiscs.c
blob: 37dcdf8acb2a7b1f1b21d0f974eb62735c8708db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/** @file
  This file does Multiplatform initialization.

  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#include "BoardInitMiscs.h"

/**
  Configure GPIO group GPE tier.

  @param[in]  PlatformInfo

  @retval     none.

**/
VOID
AuroraGpioGroupTierInit (
  IN EFI_PLATFORM_INFO_HOB  *PlatformInfoHob
  )
{
  DEBUG ((DEBUG_INFO, "AuroraGpioGroupTierInit Start\n"));
  switch (PlatformInfoHob->BoardId) {
    default:
      GpioSetGroupToGpeDwX (GPIO_BXTP_GROUP_7,  // map group 7 to GPE 0 ~ 31
                            GPIO_BXTP_GROUP_0,  // map group 0 to GPE 32 ~ 63 // We don't have SCI pin in Group0 as of now, but still need to assign a unique group to this field.
                            GPIO_BXTP_GROUP_1); // map group 1 to GPE 64 ~ 95 // We don't have SCI pin in Group1 as of now, but still need to assign a unique group to this field.
      break;
  }

  DEBUG ((DEBUG_INFO, "AuroraGpioGroupTierInit End\n"));
}


EFI_STATUS
EFIAPI
AuroraMultiPlatformInfoInit (
  IN CONST EFI_PEI_SERVICES     **PeiServices,
  IN OUT EFI_PLATFORM_INFO_HOB  *PlatformInfoHob
  )
{
  UINT8                  Data8;
  EFI_STATUS             Status;

#if (ENBDT_PF_ENABLE == 1)
   DEBUG ((EFI_D_INFO, "Platform BoardId:%x FabId%x\n", PlatformInfoHob->BoardId, PlatformInfoHob->FABID));
#endif

  //
  // Device ID
  //
  PlatformInfoHob->IohSku = MmPci16 (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN, PCI_DEVICE_ID_OFFSET);

  PlatformInfoHob->IohRevision = MmPci8 (0, SA_MC_BUS, SA_MC_DEV, SA_MC_FUN, PCI_REVISION_ID_OFFSET);

  //
  // Don't support BASE above 4GB currently
  //
  PlatformInfoHob->PciData.PciExpressSize     = 0x04000000;
  PlatformInfoHob->PciData.PciExpressBase     = (UINTN) PcdGet64 (PcdPciExpressBaseAddress);

  PlatformInfoHob->PciData.PciResourceMem32Base  = (UINT32) (PlatformInfoHob->PciData.PciExpressBase - RES_MEM32_MIN_LEN);
  PlatformInfoHob->PciData.PciResourceMem32Limit = (UINT32) (PlatformInfoHob->PciData.PciExpressBase -1);

  PlatformInfoHob->PciData.PciResourceMem64Base   = RES_MEM64_36_BASE;
  PlatformInfoHob->PciData.PciResourceMem64Limit  = RES_MEM64_36_LIMIT;
  PlatformInfoHob->CpuData.CpuAddressWidth        = 36;

  PlatformInfoHob->MemData.MemMir0 = PlatformInfoHob->PciData.PciResourceMem64Base;
  PlatformInfoHob->MemData.MemMir1 = PlatformInfoHob->PciData.PciResourceMem64Limit + 1;

  PlatformInfoHob->PciData.PciResourceMinSecBus  = 1;  //can be changed by SystemConfiguration->PciMinSecondaryBus;

  //
  // Set MemMaxTolm to the lowest address between PCIe Base and PCI32 Base
  //
  if (PlatformInfoHob->PciData.PciExpressBase > PlatformInfoHob->PciData.PciResourceMem32Base ) {
    PlatformInfoHob->MemData.MemMaxTolm = (UINT32) PlatformInfoHob->PciData.PciResourceMem32Base;
  } else {
    PlatformInfoHob->MemData.MemMaxTolm = (UINT32) PlatformInfoHob->PciData.PciExpressBase;
  }
  PlatformInfoHob->MemData.MemTolm = PlatformInfoHob->MemData.MemMaxTolm;

  //
  // Platform PCI MMIO Size in unit of 1MB
  //
  PlatformInfoHob->MemData.MmioSize = 0x1000 - (UINT16) (PlatformInfoHob->MemData.MemMaxTolm >> 20);

  //
  // Enable ICH IOAPIC
  //
  PlatformInfoHob->SysData.SysIoApicEnable  = ICH_IOAPIC;

  DEBUG ((EFI_D_INFO,  "PlatformFlavor is %x (%x=tablet,%x=mobile,%x=desktop)\n", PlatformInfoHob->PlatformFlavor, FlavorTablet, FlavorMobile, FlavorDesktop));

  //
  // Get Platform Info and fill the Hob
  //
  PlatformInfoHob->RevisonId = PLATFORM_INFO_HOB_REVISION;

  //
  // Get GPIO table
  //
  Status = AuroraMultiPlatformGpioTableInit (PeiServices, PlatformInfoHob);
  ASSERT_EFI_ERROR (Status);

  //
  // Program GPIO
  //
  Status = AuroraMultiPlatformGpioProgram (PeiServices, PlatformInfoHob);

  if (GetBxtSeries () == BxtP) {
    AuroraGpioGroupTierInit (PlatformInfoHob);
  }

  //
  // Update OemId
  //
  Status = AuroraInitializeBoardOemId (PeiServices, PlatformInfoHob);
  Status = AuroraInitializeBoardSsidSvid (PeiServices, PlatformInfoHob);

  //
  // TypeC MUX AUX mode
  //

  //
  // Set P0-P4 to input mode
  //
  Data8  = 0x1F;
  Status = ByteWriteI2C (0x05, 0x38, 0x03, 1, &Data8);
  DEBUG ((DEBUG_INFO, "%a(#%d) - Setting button MUX into GPI mode returned %r\n", __FUNCTION__, __LINE__, Status));

  //
  // Set P0-P4 to inverted mode
  //
  Data8  = 0x1F;
  Status = ByteWriteI2C (0x05, 0x38, 0x02, 1, &Data8);
  DEBUG ((DEBUG_INFO, "%a(#%d) - Setting button MUX into inverted mode returned %r\n", __FUNCTION__, __LINE__, Status));

  //
  // Dump switch state
  //
  Data8  = 0x00;
  Status = ByteReadI2C (0x05, 0x38, 0x00, 1, &Data8);
  DEBUG ((DEBUG_INFO, "%a(#%d) - ByteReadI2C[0] returned %r\n", __FUNCTION__, __LINE__, Status));
  if (!EFI_ERROR (Status)) {
    DEBUG ((DEBUG_INFO, "%a(#%d) - Input register         = %02x\n", __FUNCTION__, __LINE__, Data8));
    DEBUG ((DEBUG_INFO, "%a(#%d) -               Volume + = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT0) ? "Pressed" : "Not pressed"));
    DEBUG ((DEBUG_INFO, "%a(#%d) -               Volume - = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT1) ? "Pressed" : "Not pressed"));
    DEBUG ((DEBUG_INFO, "%a(#%d) -                BT Pair = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT2) ? "Pressed" : "Not pressed"));
    DEBUG ((DEBUG_INFO, "%a(#%d) -               Mic Mute = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT3) ? "Pressed" : "Not pressed"));
    DEBUG ((DEBUG_INFO, "%a(#%d) -           Speaker Mute = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT4) ? "Pressed" : "Not pressed"));
  }

  return EFI_SUCCESS;
}


EFI_STATUS
AuroraInitializeBoardOemId (
  IN CONST EFI_PEI_SERVICES       **PeiServices,
  IN EFI_PLATFORM_INFO_HOB        *PlatformInfoHob
  )
{
  UINT64  OemId;
  UINT64  OemTableId;

  //
  // Set OEM ID according to Board ID.
  //
  switch (PlatformInfoHob->BoardId) {
    default:
      OemId = EFI_ACPI_OEM_ID_DEFAULT;
      OemTableId = EFI_ACPI_OEM_TABLE_ID_DEFAULT;
      break;
  }

  PlatformInfoHob->AcpiOemId      = OemId;
  PlatformInfoHob->AcpiOemTableId = OemTableId;

  return  EFI_SUCCESS;
}

EFI_STATUS
AuroraInitializeBoardSsidSvid (
  IN CONST EFI_PEI_SERVICES       **PeiServices,
  IN EFI_PLATFORM_INFO_HOB        *PlatformInfoHob
  )
{
  UINT32  SsidSvidValue = 0;

  //
  // Set OEM ID according to Board ID.
  //
  switch (PlatformInfoHob->BoardId) {
    default:
      SsidSvidValue = SUBSYSTEM_SVID_SSID; //SUBSYSTEM_SVID_SSID_DEFAULT;
      break;
  }
  PlatformInfoHob->SsidSvid = SsidSvidValue;

  return  EFI_SUCCESS;
}