blob: df4edc0f1e94b3c5ea8fea3a5192735d7b1ee73d [file] [log] [blame]
Martin Roth58562402015-10-11 10:36:26 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
6 * Copyright (C) 2013 Sage Electronic Engineering, LLC.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; version 2 of
11 * the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Martin Roth58562402015-10-11 10:36:26 +020017 */
18
19#include <console/console.h>
20#include <delay.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include "soc.h"
24
25static int soc_revision_id = -1;
26static int soc_type = -1;
27
28int soc_silicon_revision(void)
29{
30 if (soc_revision_id < 0)
31 soc_revision_id = pci_read_config8(
32 dev_find_slot(0, PCI_DEVFN(0x1f, 0)),
33 PCI_REVISION_ID);
34 return soc_revision_id;
35}
36
37int soc_silicon_type(void)
38{
39 if (soc_type < 0)
40 soc_type = pci_read_config8(
41 dev_find_slot(0, PCI_DEVFN(0x1f, 0)),
42 PCI_DEVICE_ID + 1);
43 return soc_type;
44}
45
46int soc_silicon_supported(int type, int rev)
47{
48 int cur_type = soc_silicon_type();
49 int cur_rev = soc_silicon_revision();
50
51 switch (type) {
52 case SOC_TYPE_RANGELEY:
53 if (cur_type == SOC_TYPE_RANGELEY && cur_rev >= rev)
54 return 1;
55 }
56
57 return 0;
58}
59
60/* Set bit in Function Disable register to hide this device */
61static void soc_hide_devfn(unsigned devfn)
62{
63/* TODO Function Disable. */
64}
65
66
67
68
69void soc_enable(device_t dev)
70{
71 u32 reg32;
72
73 if (!dev->enabled) {
74 printk(BIOS_DEBUG, "%s: Disabling device\n", dev_path(dev));
75
76 /* Ensure memory, IO, and bus master are all disabled */
77 reg32 = pci_read_config32(dev, PCI_COMMAND);
78 reg32 &= ~(PCI_COMMAND_MASTER |
79 PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
80 pci_write_config32(dev, PCI_COMMAND, reg32);
81
82 /* Hide this device if possible */
83 soc_hide_devfn(dev->path.pci.devfn);
84 } else {
85 /* Enable SERR */
86 reg32 = pci_read_config32(dev, PCI_COMMAND);
87 reg32 |= PCI_COMMAND_SERR;
88 pci_write_config32(dev, PCI_COMMAND, reg32);
89 }
90}
91
92struct chip_operations southbridge_intel_fsp_rangeley_ops = {
93 CHIP_NAME("Intel Rangeley Southbridge")
94 .enable_dev = soc_enable,
95};