| 1 |
|
| 2 |
|
| 3 |
#include <device/device.h> |
| 4 |
#include <device/pci_def.h> |
| 5 |
#include <amdblocks/BiosCallOuts.h> |
| 6 |
#include <console/console.h> |
| 7 |
#include <soc/southbridge.h> |
| 8 |
#include <soc/pci_devs.h> |
| 9 |
#include <static.h> |
| 10 |
#include <amdblocks/agesawrapper.h> |
| 11 |
#include <amdblocks/dimm_spd.h> |
| 12 |
#include <amdblocks/car.h> |
| 13 |
|
| 14 |
#include "chip.h" |
| 15 |
|
| 16 |
void __weak platform_FchParams_reset(FCH_RESET_DATA_BLOCK *FchParams_reset) {} |
| 17 |
|
| 18 |
AGESA_STATUS agesa_fch_initreset(uint32_t Func, uintptr_t FchData, |
| 19 |
void *ConfigPtr) |
| 20 |
{ |
| 21 |
AMD_CONFIG_PARAMS *StdHeader = ConfigPtr; |
| 22 |
|
| 23 |
if (StdHeader->Func == AMD_INIT_RESET) { |
| 24 |
FCH_RESET_DATA_BLOCK *FchParams_reset; |
| 25 |
FchParams_reset = (FCH_RESET_DATA_BLOCK *)FchData; |
| 26 |
printk(BIOS_DEBUG, "Fch OEM config in INIT RESET "); |
| 27 |
|
| 28 |
|
| 29 |
platform_FchParams_reset(FchParams_reset); |
| 30 |
|
| 31 |
printk(BIOS_DEBUG, "Done\n"); |
| 32 |
} |
| 33 |
|
| 34 |
return AGESA_SUCCESS; |
| 35 |
} |
| 36 |
|
| 37 |
AGESA_STATUS agesa_fch_initenv(uint32_t Func, uintptr_t FchData, |
| 38 |
void *ConfigPtr) |
| 39 |
{ |
| 40 |
AMD_CONFIG_PARAMS *StdHeader = ConfigPtr; |
| 41 |
|
| 42 |
if (StdHeader->Func == AMD_INIT_ENV) { |
| 43 |
FCH_DATA_BLOCK *FchParams_env = (FCH_DATA_BLOCK *)FchData; |
| 44 |
printk(BIOS_DEBUG, "Fch OEM config in INIT ENV "); |
| 45 |
|
| 46 |
|
| 47 |
if (CONFIG(STONEYRIDGE_XHCI_ENABLE)) |
| 48 |
FchParams_env->Usb.Xhci0Enable = TRUE; |
| 49 |
else |
| 50 |
FchParams_env->Usb.Xhci0Enable = FALSE; |
| 51 |
FchParams_env->Usb.Xhci1Enable = FALSE; |
| 52 |
|
| 53 |
|
| 54 |
FchParams_env->Sata.SataClass = CONFIG_STONEYRIDGE_SATA_MODE; |
| 55 |
if (is_dev_enabled(DEV_PTR(sata))) { |
| 56 |
switch ((SATA_CLASS)CONFIG_STONEYRIDGE_SATA_MODE) { |
| 57 |
case SataRaid: |
| 58 |
case SataAhci: |
| 59 |
case SataAhci7804: |
| 60 |
case SataLegacyIde: |
| 61 |
FchParams_env->Sata.SataIdeMode = FALSE; |
| 62 |
break; |
| 63 |
case SataIde2Ahci: |
| 64 |
case SataIde2Ahci7804: |
| 65 |
default: |
| 66 |
FchParams_env->Sata.SataIdeMode = TRUE; |
| 67 |
break; |
| 68 |
} |
| 69 |
} else { |
| 70 |
FchParams_env->Sata.SataIdeMode = FALSE; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
platform_FchParams_env(FchParams_env); |
| 75 |
|
| 76 |
printk(BIOS_DEBUG, "Done\n"); |
| 77 |
} |
| 78 |
|
| 79 |
return AGESA_SUCCESS; |
| 80 |
} |
| 81 |
|
| 82 |
AGESA_STATUS agesa_ReadSpd(uint32_t Func, uintptr_t Data, void *ConfigPtr) |
| 83 |
{ |
| 84 |
uint8_t spd_address; |
| 85 |
int err; |
| 86 |
DEVTREE_CONST struct device *dev; |
| 87 |
DEVTREE_CONST struct soc_amd_stoneyridge_config *conf; |
| 88 |
AGESA_READ_SPD_PARAMS *info = ConfigPtr; |
| 89 |
|
| 90 |
if (!ENV_RAMINIT) |
| 91 |
return AGESA_UNSUPPORTED; |
| 92 |
|
| 93 |
dev = pcidev_path_on_root(DCT_DEVFN); |
| 94 |
if (dev == NULL) |
| 95 |
return AGESA_ERROR; |
| 96 |
|
| 97 |
conf = dev->chip_info; |
| 98 |
if (conf == NULL) |
| 99 |
return AGESA_ERROR; |
| 100 |
|
| 101 |
if (info->SocketId >= ARRAY_SIZE(conf->spd_addr_lookup)) |
| 102 |
return AGESA_ERROR; |
| 103 |
if (info->MemChannelId >= ARRAY_SIZE(conf->spd_addr_lookup[0])) |
| 104 |
return AGESA_ERROR; |
| 105 |
if (info->DimmId >= ARRAY_SIZE(conf->spd_addr_lookup[0][0])) |
| 106 |
return AGESA_ERROR; |
| 107 |
|
| 108 |
spd_address = conf->spd_addr_lookup |
| 109 |
[info->SocketId][info->MemChannelId][info->DimmId]; |
| 110 |
if (spd_address == 0) |
| 111 |
return AGESA_ERROR; |
| 112 |
|
| 113 |
err = mainboard_read_spd(spd_address, (void *)info->Buffer, |
| 114 |
CONFIG_DIMM_SPD_SIZE); |
| 115 |
|
| 116 |
|
| 117 |
if (err || (*info->Buffer == 0)) |
| 118 |
err = sb_read_spd(spd_address, (void *)info->Buffer, |
| 119 |
CONFIG_DIMM_SPD_SIZE); |
| 120 |
|
| 121 |
if (err) |
| 122 |
return AGESA_ERROR; |
| 123 |
|
| 124 |
return AGESA_SUCCESS; |
| 125 |
} |
| 126 |
|
| 127 |
AGESA_STATUS agesa_HaltThisAp(uint32_t Func, uintptr_t Data, void *ConfigPtr) |
| 128 |
{ |
| 129 |
AGESA_HALT_THIS_AP_PARAMS *info = ConfigPtr; |
| 130 |
uint32_t flags = 0; |
| 131 |
|
| 132 |
if (info->PrimaryCore == TRUE) |
| 133 |
return AGESA_UNSUPPORTED; |
| 134 |
if (info->ExecWbinvd == TRUE) |
| 135 |
flags |= 1; |
| 136 |
if (info->CacheEn == TRUE) |
| 137 |
flags |= 2; |
| 138 |
|
| 139 |
ap_teardown_car(flags); |
| 140 |
|
| 141 |
|
| 142 |
return AGESA_UNSUPPORTED; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
__weak int mainboard_read_spd(uint8_t spdAddress, char *buf, |
| 147 |
size_t len) |
| 148 |
{ |
| 149 |
printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 150 |
return -1; |
| 151 |
} |