blob: 459ed4648d91541b8a2dafc48f7a0b2a4ad4e478 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Stefan Reinauer8e073822012-04-04 00:07:22 +02003
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
Kyösti Mälkkidf128a52019-09-21 18:35:37 +03007#include <device/pci_def.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02008#include <device/pci_ops.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +02009#include <device/pci_ids.h>
10#include "pch.h"
11
12static void pci_init(struct device *dev)
13{
14 u16 reg16;
15 u8 reg8;
16
17 printk(BIOS_DEBUG, "PCI init.\n");
18 /* Enable Bus Master */
19 reg16 = pci_read_config16(dev, PCI_COMMAND);
20 reg16 |= PCI_COMMAND_MASTER;
21 pci_write_config16(dev, PCI_COMMAND, reg16);
22
23 /* This device has no interrupt */
24 pci_write_config8(dev, INTR, 0xff);
25
26 /* disable parity error response and SERR */
Kyösti Mälkkidf128a52019-09-21 18:35:37 +030027 reg16 = pci_read_config16(dev, PCI_BRIDGE_CONTROL);
28 reg16 &= ~PCI_BRIDGE_CTL_PARITY;
29 reg16 &= ~PCI_BRIDGE_CTL_SERR;
30 pci_write_config16(dev, PCI_BRIDGE_CONTROL, reg16);
Stefan Reinauer8e073822012-04-04 00:07:22 +020031
32 /* Master Latency Count must be set to 0x04! */
33 reg8 = pci_read_config8(dev, SMLT);
34 reg8 &= 0x07;
35 reg8 |= (0x04 << 3);
36 pci_write_config8(dev, SMLT, reg8);
37
Stefan Reinauer8e073822012-04-04 00:07:22 +020038 /* Clear errors in status registers */
39 reg16 = pci_read_config16(dev, PSTS);
40 //reg16 |= 0xf900;
41 pci_write_config16(dev, PSTS, reg16);
42
43 reg16 = pci_read_config16(dev, SECSTS);
44 // reg16 |= 0xf900;
45 pci_write_config16(dev, SECSTS, reg16);
46}
47
Stefan Reinauer8e073822012-04-04 00:07:22 +020048static struct pci_operations pci_ops = {
Kyösti Mälkkidbd31322019-03-20 17:55:27 +020049 .set_subsystem = pci_dev_set_subsystem,
Stefan Reinauer8e073822012-04-04 00:07:22 +020050};
51
52static struct device_operations device_ops = {
53 .read_resources = pci_bus_read_resources,
54 .set_resources = pci_dev_set_resources,
Kyösti Mälkkia84a7342019-09-23 10:01:16 +030055 .enable_resources = pci_bus_enable_resources,
Stefan Reinauer8e073822012-04-04 00:07:22 +020056 .init = pci_init,
57 .scan_bus = pci_scan_bridge,
58 .ops_pci = &pci_ops,
59};
60
61static const struct pci_driver pch_pci __pci_driver = {
62 .ops = &device_ops,
63 .vendor = PCI_VENDOR_ID_INTEL,
64 .device = 0x2448,
65};