blob: 63b9c8561360488593efde1ec8c058ff1509a7de [file] [log] [blame]
Lijian Zhaoa3cbbf72017-10-26 11:59:14 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2016 Google 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 <arch/io.h>
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21#include <rules.h>
22#include <soc/iomap.h>
23#include <soc/pci_devs.h>
24#include <intelblocks/p2sb.h>
25
26#define P2SB_E0 0xe0
27#define HIDE_BIT (1 << 0)
28
29static void p2sb_set_hide_bit(int hide)
30{
31 struct device *dev;
32 const uint16_t reg = P2SB_E0 + 1;
33 const uint8_t mask = HIDE_BIT;
34 uint8_t val;
35
36 dev = PCH_DEV_P2SB;
37
38 val = pci_read_config8(dev, reg);
39 val &= ~mask;
40 if (hide)
41 val |= mask;
42 pci_write_config8(dev, reg, val);
43}
44
45void p2sb_unhide(void)
46{
47 p2sb_set_hide_bit(0);
48}
49
50void p2sb_hide(void)
51{
52 p2sb_set_hide_bit(1);
53}
54
55static void read_resources(struct device *dev)
56{
57 /*
58 * There's only one resource on the P2SB device. It's also already
59 * manually set to a fixed address in earlier boot stages.
60 */
61 mmio_resource(dev, PCI_BASE_ADDRESS_0, P2SB_BAR / KiB, P2SB_SIZE / KiB);
62}
63
64static const struct device_operations device_ops = {
65 .read_resources = read_resources,
66 .set_resources = DEVICE_NOOP,
67};
68
69static const unsigned short pci_device_ids[] = {
70 PCI_DEVICE_ID_INTEL_APL_P2SB,
71 PCI_DEVICE_ID_INTEL_GLK_P2SB,
72 PCI_DEVICE_ID_INTEL_CNL_P2SB,
73 0,
74};
75
76static const struct pci_driver pmc __pci_driver = {
77 .ops = &device_ops,
78 .vendor = PCI_VENDOR_ID_INTEL,
79 .devices = pci_device_ids,
80};