blob: 0df3e30f563e9dbd911ed39968dc2130a1b0626e [file] [log] [blame]
Marshall Dawsona7bfbbe2017-09-13 17:24:53 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015-2016 Intel Corp.
5 * Copyright (C) 2017 Advanced Micro Devices, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <cpu/x86/mp.h>
18#include <cpu/x86/mtrr.h>
19#include <device/device.h>
20#include <soc/pci_devs.h>
21#include <soc/cpu.h>
22#include <soc/northbridge.h>
23#include <console/console.h>
24
25/*
26 * Do essential initialization tasks before APs can be fired up -
27 *
28 * 1. Prevent race condition in MTRR solution. Enable MTRRs on the BSP. This
29 * creates the MTRR solution that the APs will use. Otherwise APs will try to
30 * apply the incomplete solution as the BSP is calculating it.
31 */
32static void pre_mp_init(void)
33{
34 x86_setup_mtrrs_with_detect();
35 x86_mtrr_check();
36}
37
38static int get_cpu_count(void)
39{
40 device_t nb = dev_find_slot(0, HT_DEVFN);
41 return (pci_read_config16(nb, D18F0_CPU_CNT) & CPU_CNT_MASK) + 1;
42}
43
44static const struct mp_ops mp_ops = {
45 .pre_mp_init = pre_mp_init,
46 .get_cpu_count = get_cpu_count,
47};
48
49void stoney_init_cpus(struct device *dev)
50{
51 /* Clear for take-off */
52 if (mp_init_with_smm(dev->link_list, &mp_ops) < 0)
53 printk(BIOS_ERR, "MP initialization failure.\n");
54}