Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 3 | |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 4 | #include <Porting.h> |
| 5 | #include <AGESA.h> |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 6 | #include <arch/io.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 7 | #include <cbmem.h> |
Nico Huber | 3e1b3b1 | 2018-10-07 12:45:47 +0200 | [diff] [blame] | 8 | #include <cf9_reset.h> |
Elyes HAOUAS | 20eaef0 | 2019-03-29 17:45:28 +0100 | [diff] [blame] | 9 | #include <console/console.h> |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 10 | #include <device/device.h> |
| 11 | #include <device/pci_def.h> |
Patrick Rudolph | e56189c | 2018-04-18 10:11:59 +0200 | [diff] [blame] | 12 | #include <device/pci_ops.h> |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 13 | #include <smp/node.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 14 | #include <northbridge/amd/agesa/state_machine.h> |
| 15 | #include <northbridge/amd/agesa/agesa_helper.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 16 | #include <sb_cimx.h> |
| 17 | |
| 18 | void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset) |
| 19 | { |
Kyösti Mälkki | 3d5e1e5 | 2019-12-03 14:06:02 +0200 | [diff] [blame] | 20 | if (!boot_cpu()) |
| 21 | return; |
| 22 | |
Kyösti Mälkki | 520717d | 2019-12-15 21:37:48 +0200 | [diff] [blame] | 23 | sb_Poweron_Init(); |
Kyösti Mälkki | 3d5e1e5 | 2019-12-03 14:06:02 +0200 | [diff] [blame] | 24 | |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 25 | /* Reboots with outb(3,0x92), outb(4,0xcf9) or triple-fault all |
| 26 | * would fail later in AmdInitPost(), when DRAM is already configured |
| 27 | * and C6DramLock bit has been set. |
| 28 | * |
| 29 | * As a workaround, do a hard reset to clear C6DramLock bit. |
| 30 | */ |
Kyösti Mälkki | 3d5e1e5 | 2019-12-03 14:06:02 +0200 | [diff] [blame] | 31 | |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 32 | #ifdef __SIMPLE_DEVICE__ |
| 33 | pci_devfn_t dev = PCI_DEV(0, 0x18, 2); |
| 34 | #else |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 35 | struct device *dev = pcidev_on_root(0x18, 2); |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 36 | #endif |
Kyösti Mälkki | 3d5e1e5 | 2019-12-03 14:06:02 +0200 | [diff] [blame] | 37 | u32 mct_cfg_lo = pci_read_config32(dev, 0x118); |
| 38 | if (mct_cfg_lo & (1<<19)) { |
| 39 | printk(BIOS_CRIT, "C6DramLock is set, resetting\n"); |
| 40 | system_reset(); |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 41 | } |
Kyösti Mälkki | 3d5e1e5 | 2019-12-03 14:06:02 +0200 | [diff] [blame] | 42 | |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post) |
| 50 | { |
Mike Banon | e7f176c | 2020-01-19 21:42:09 +0300 | [diff] [blame^] | 51 | Post->MemConfig.BottomIo = (UINT16)(MIN(0xE0000000, |
| 52 | MAX(0x28000000, CONFIG_BOTTOMIO_POSITION)) >> 24) & 0xF8; |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post) |
| 56 | { |
| 57 | backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop); |
| 58 | } |
| 59 | |
| 60 | void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume) |
| 61 | { |
| 62 | OemInitResume(&Resume->S3DataBlock); |
| 63 | } |
| 64 | |
| 65 | void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume) |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env) |
| 70 | { |
| 71 | EmptyHeap(); |
| 72 | } |
| 73 | |
| 74 | void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env) |
| 75 | { |
| 76 | amd_initenv(); |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late) |
| 80 | { |
| 81 | OemS3LateRestore(&S3Late->S3DataBlock); |
| 82 | } |
| 83 | |
| 84 | void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late) |
| 85 | { |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid) |
| 89 | { |
| 90 | sb_After_Pci_Init(); |
| 91 | sb_Mid_Post_Init(); |
| 92 | |
| 93 | amd_initcpuio(); |
| 94 | } |
| 95 | |
Michał Żygowski | 506b9c1 | 2019-12-20 16:57:13 +0100 | [diff] [blame] | 96 | void platform_BeforeInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late) |
| 97 | { |
| 98 | } |
| 99 | |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 100 | void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late) |
| 101 | { |
| 102 | sb_Late_Post(); |
| 103 | } |
| 104 | |
| 105 | void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save) |
| 106 | { |
| 107 | OemS3Save(&S3Save->S3DataBlock); |
| 108 | } |