Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
| 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 | |
| 16 | #include <stdint.h> |
| 17 | #include <string.h> |
| 18 | #include <device/pci_def.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <arch/acpi.h> |
| 21 | #include <arch/io.h> |
| 22 | #include <arch/stages.h> |
| 23 | #include <device/pnp_def.h> |
| 24 | #include <arch/cpu.h> |
| 25 | #include <cpu/x86/lapic.h> |
| 26 | #include <console/console.h> |
| 27 | #include <commonlib/loglevel.h> |
| 28 | #include <cpu/amd/car.h> |
| 29 | #include <northbridge/amd/pi/agesawrapper.h> |
| 30 | #include <northbridge/amd/pi/agesawrapper_call.h> |
| 31 | #include <cpu/x86/bist.h> |
| 32 | #include <cpu/x86/lapic.h> |
| 33 | #include <southbridge/amd/pi/hudson/hudson.h> |
| 34 | #include <cpu/amd/pi/s3_resume.h> |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 35 | #include <superio/fintek/common/fintek.h> |
| 36 | #include <superio/fintek/f81866d/f81866d.h> |
| 37 | |
| 38 | #define SERIAL_DEV1 PNP_DEV(0x4e, F81866D_SP1) |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 39 | |
| 40 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 41 | { |
| 42 | u32 val; |
| 43 | |
| 44 | /* |
| 45 | * In Hudson RRG, PMIOxD2[5:4] is "Drive strength control for |
| 46 | * LpcClk[1:0]". This following register setting has been |
| 47 | * replicated in every reference design since Parmer, so it is |
| 48 | * believed to be required even though it is not documented in |
| 49 | * the SoC BKDGs. Without this setting, there is no serial |
| 50 | * output. |
| 51 | */ |
| 52 | outb(0xD2, 0xcd6); |
| 53 | outb(0x00, 0xcd7); |
| 54 | |
| 55 | amd_initmmio(); |
| 56 | |
| 57 | hudson_lpc_port80(); |
| 58 | |
| 59 | if (!cpu_init_detectedx && boot_cpu()) { |
| 60 | post_code(0x30); |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 61 | fintek_enable_serial(SERIAL_DEV1, CONFIG_TTYS0_BASE); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 62 | post_code(0x31); |
| 63 | console_init(); |
| 64 | } |
| 65 | |
| 66 | /* Halt if there was a built in self test failure */ |
| 67 | post_code(0x34); |
| 68 | report_bist_failure(bist); |
| 69 | |
| 70 | /* Load MPB */ |
| 71 | val = cpuid_eax(1); |
Elyes HAOUAS | e53e488c | 2016-08-21 12:19:25 +0200 | [diff] [blame^] | 72 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 73 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 74 | |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 75 | post_code(0x37); |
| 76 | AGESAWRAPPER(amdinitreset); |
| 77 | |
| 78 | post_code(0x38); |
| 79 | printk(BIOS_DEBUG, "Got past avalon_early_setup\n"); |
| 80 | |
| 81 | post_code(0x39); |
| 82 | AGESAWRAPPER(amdinitearly); |
| 83 | int s3resume = acpi_is_wakeup_s3(); |
| 84 | if (!s3resume) { |
| 85 | post_code(0x40); |
| 86 | AGESAWRAPPER(amdinitpost); |
| 87 | |
| 88 | //PspMboxBiosCmdDramInfo(); |
| 89 | post_code(0x41); |
| 90 | AGESAWRAPPER(amdinitenv); |
| 91 | /* |
| 92 | If code hangs here, please check cahaltasm.S |
| 93 | */ |
| 94 | disable_cache_as_ram(); |
| 95 | } else { /* S3 detect */ |
| 96 | printk(BIOS_INFO, "S3 detected\n"); |
| 97 | |
| 98 | post_code(0x60); |
| 99 | AGESAWRAPPER(amdinitresume); |
| 100 | |
| 101 | AGESAWRAPPER(amds3laterestore); |
| 102 | |
| 103 | post_code(0x61); |
| 104 | prepare_for_resume(); |
| 105 | } |
| 106 | |
| 107 | outb(0xEA, 0xCD6); |
| 108 | outb(0x1, 0xcd7); |
| 109 | |
| 110 | post_code(0x50); |
| 111 | copy_and_run(); |
| 112 | |
| 113 | post_code(0x54); /* Should never see this post code. */ |
| 114 | } |