Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2016 Kyösti Mälkki |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 16 | #include <Porting.h> |
| 17 | #include <AGESA.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 18 | |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 19 | #include <arch/io.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 20 | #include <cbmem.h> |
Nico Huber | 3e1b3b1 | 2018-10-07 12:45:47 +0200 | [diff] [blame] | 21 | #include <cf9_reset.h> |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 22 | #include <device/device.h> |
| 23 | #include <device/pci_def.h> |
Patrick Rudolph | e56189c | 2018-04-18 10:11:59 +0200 | [diff] [blame] | 24 | #include <device/pci_ops.h> |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 25 | #include <smp/node.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 26 | #include <northbridge/amd/agesa/state_machine.h> |
| 27 | #include <northbridge/amd/agesa/agesa_helper.h> |
| 28 | |
| 29 | #include <sb_cimx.h> |
| 30 | |
| 31 | void platform_BeforeInitReset(struct sysinfo *cb, AMD_RESET_PARAMS *Reset) |
| 32 | { |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 33 | /* Reboots with outb(3,0x92), outb(4,0xcf9) or triple-fault all |
| 34 | * would fail later in AmdInitPost(), when DRAM is already configured |
| 35 | * and C6DramLock bit has been set. |
| 36 | * |
| 37 | * As a workaround, do a hard reset to clear C6DramLock bit. |
| 38 | */ |
| 39 | #ifdef __SIMPLE_DEVICE__ |
| 40 | pci_devfn_t dev = PCI_DEV(0, 0x18, 2); |
| 41 | #else |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 42 | struct device *dev = pcidev_on_root(0x18, 2); |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 43 | #endif |
| 44 | if (boot_cpu()) { |
| 45 | u32 mct_cfg_lo = pci_read_config32(dev, 0x118); |
| 46 | if (mct_cfg_lo & (1<<19)) { |
| 47 | printk(BIOS_CRIT, "C6DramLock is set, resetting\n"); |
Nico Huber | 3e1b3b1 | 2018-10-07 12:45:47 +0200 | [diff] [blame] | 48 | system_reset(); |
Kyösti Mälkki | 64df52e | 2017-09-01 06:13:08 +0300 | [diff] [blame] | 49 | } |
| 50 | } |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void platform_BeforeInitEarly(struct sysinfo *cb, AMD_EARLY_PARAMS *Early) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | void platform_BeforeInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | void platform_AfterInitPost(struct sysinfo *cb, AMD_POST_PARAMS *Post) |
| 62 | { |
| 63 | backup_top_of_low_cacheable(Post->MemConfig.Sub4GCacheTop); |
| 64 | } |
| 65 | |
| 66 | void platform_BeforeInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume) |
| 67 | { |
| 68 | OemInitResume(&Resume->S3DataBlock); |
| 69 | } |
| 70 | |
| 71 | void platform_AfterInitResume(struct sysinfo *cb, AMD_RESUME_PARAMS *Resume) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | void platform_BeforeInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env) |
| 76 | { |
| 77 | EmptyHeap(); |
| 78 | } |
| 79 | |
| 80 | void platform_AfterInitEnv(struct sysinfo *cb, AMD_ENV_PARAMS *Env) |
| 81 | { |
| 82 | amd_initenv(); |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | void platform_BeforeS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late) |
| 86 | { |
| 87 | OemS3LateRestore(&S3Late->S3DataBlock); |
| 88 | } |
| 89 | |
| 90 | void platform_AfterS3LateRestore(struct sysinfo *cb, AMD_S3LATE_PARAMS *S3Late) |
| 91 | { |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | void platform_BeforeInitMid(struct sysinfo *cb, AMD_MID_PARAMS *Mid) |
| 95 | { |
| 96 | sb_After_Pci_Init(); |
| 97 | sb_Mid_Post_Init(); |
| 98 | |
| 99 | amd_initcpuio(); |
| 100 | } |
| 101 | |
| 102 | void platform_AfterInitLate(struct sysinfo *cb, AMD_LATE_PARAMS *Late) |
| 103 | { |
| 104 | sb_Late_Post(); |
| 105 | } |
| 106 | |
| 107 | void platform_AfterS3Save(struct sysinfo *cb, AMD_S3SAVE_PARAMS *S3Save) |
| 108 | { |
| 109 | OemS3Save(&S3Save->S3DataBlock); |
| 110 | } |