blob: 833512a5b79c1a964f2e79fe4e502985ef55222f [file] [log] [blame]
Stefan Reinauer8e073822012-04-04 00:07:22 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * 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.
Stefan Reinauer8e073822012-04-04 00:07:22 +020015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
Kyösti Mälkkidf128a52019-09-21 18:35:37 +030020#include <device/pci_def.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +020022#include <device/pci_ids.h>
23#include "pch.h"
24
25static void pci_init(struct device *dev)
26{
27 u16 reg16;
28 u8 reg8;
29
30 printk(BIOS_DEBUG, "PCI init.\n");
31 /* Enable Bus Master */
32 reg16 = pci_read_config16(dev, PCI_COMMAND);
33 reg16 |= PCI_COMMAND_MASTER;
34 pci_write_config16(dev, PCI_COMMAND, reg16);
35
36 /* This device has no interrupt */
37 pci_write_config8(dev, INTR, 0xff);
38
39 /* disable parity error response and SERR */
Kyösti Mälkkidf128a52019-09-21 18:35:37 +030040 reg16 = pci_read_config16(dev, PCI_BRIDGE_CONTROL);
41 reg16 &= ~PCI_BRIDGE_CTL_PARITY;
42 reg16 &= ~PCI_BRIDGE_CTL_SERR;
43 pci_write_config16(dev, PCI_BRIDGE_CONTROL, reg16);
Stefan Reinauer8e073822012-04-04 00:07:22 +020044
45 /* Master Latency Count must be set to 0x04! */
46 reg8 = pci_read_config8(dev, SMLT);
47 reg8 &= 0x07;
48 reg8 |= (0x04 << 3);
49 pci_write_config8(dev, SMLT, reg8);
50
Stefan Reinauer8e073822012-04-04 00:07:22 +020051 /* Clear errors in status registers */
52 reg16 = pci_read_config16(dev, PSTS);
53 //reg16 |= 0xf900;
54 pci_write_config16(dev, PSTS, reg16);
55
56 reg16 = pci_read_config16(dev, SECSTS);
57 // reg16 |= 0xf900;
58 pci_write_config16(dev, SECSTS, reg16);
59}
60
Stefan Reinauer8e073822012-04-04 00:07:22 +020061static struct pci_operations pci_ops = {
Kyösti Mälkkidbd31322019-03-20 17:55:27 +020062 .set_subsystem = pci_dev_set_subsystem,
Stefan Reinauer8e073822012-04-04 00:07:22 +020063};
64
65static struct device_operations device_ops = {
66 .read_resources = pci_bus_read_resources,
67 .set_resources = pci_dev_set_resources,
Kyösti Mälkkia84a7342019-09-23 10:01:16 +030068 .enable_resources = pci_bus_enable_resources,
Stefan Reinauer8e073822012-04-04 00:07:22 +020069 .init = pci_init,
70 .scan_bus = pci_scan_bridge,
71 .ops_pci = &pci_ops,
72};
73
74static const struct pci_driver pch_pci __pci_driver = {
75 .ops = &device_ops,
76 .vendor = PCI_VENDOR_ID_INTEL,
77 .device = 0x2448,
78};