blob: 1091ef4f2e6672c67c81a4643b9d88af824aa060 [file] [log] [blame]
Timothy Pearson730a0432015-10-16 13:51:51 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
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 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20/* Configure various power control registers, including processor
21 * boost support.
22 */
23
24#include <console/console.h>
25#include <device/device.h>
26#include <device/pci.h>
27#include <device/pci_ids.h>
28#include <device/pci_ops.h>
29#include <pc80/mc146818rtc.h>
30#include <lib.h>
31#include <cpu/amd/model_10xxx_rev.h>
32
33#include "amdfam10.h"
34
35static inline uint8_t is_fam15h(void)
36{
37 uint8_t fam15h = 0;
38 uint32_t family;
39
40 family = cpuid_eax(0x80000001);
41 family = ((family & 0xf00000) >> 16) | ((family & 0xf00) >> 8);
42
43 if (family >= 0x6f)
44 /* Family 15h or later */
45 fam15h = 1;
46
47 return fam15h;
48}
49
50static void nb_control_init(struct device *dev)
51{
52 uint32_t dword;
53
54 printk(BIOS_DEBUG, "NB: Function 4 Link Control.. ");
55
56 if (is_fam15h()) {
57 /* Enable APM */
58 dword = pci_read_config32(dev, 0x15c);
59 dword |= (0x1 << 7); /* ApmMasterEn = 1 */
60 pci_write_config32(dev, 0x15c, dword);
61 }
62
63 printk(BIOS_DEBUG, "done.\n");
64}
65
66
67static struct device_operations mcf4_ops = {
68 .read_resources = pci_dev_read_resources,
69 .set_resources = pci_dev_set_resources,
70 .enable_resources = pci_dev_enable_resources,
71 .init = nb_control_init,
72 .scan_bus = 0,
73 .ops_pci = 0,
74};
75
76static const struct pci_driver mcf4_driver_fam10 __pci_driver = {
77 .ops = &mcf4_ops,
78 .vendor = PCI_VENDOR_ID_AMD,
79 .device = 0x1204,
80};
81
82static const struct pci_driver mcf4_driver_fam15 __pci_driver = {
83 .ops = &mcf4_ops,
84 .vendor = PCI_VENDOR_ID_AMD,
85 .device = 0x1604,
86};