blob: a32d4a94b0c7899b8e51e6eaf49f73ef3fe6e0ab [file] [log] [blame]
Arthur Heymans7b9c1392017-04-09 20:40:39 +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.
15 */
16
17#include <device/device.h>
18#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.h>
Arthur Heymans7b9c1392017-04-09 20:40:39 +020020#include <device/pci_ids.h>
Arthur Heymans349e0852017-04-09 20:48:37 +020021#include "i82801jx.h"
Arthur Heymans7b9c1392017-04-09 20:40:39 +020022
23static void pci_init(struct device *dev)
24{
25 u16 reg16;
26 u8 reg8;
27
28 /* This device has no interrupt */
29 pci_write_config8(dev, PCI_INTERRUPT_LINE, 0xff);
30
31 /* Master Latency Count must be set to 0x04! */
32 reg8 = pci_read_config8(dev, D30F0_SMLT);
33 reg8 &= 0x07;
34 reg8 |= (0x04 << 3);
35 pci_write_config8(dev, D30F0_SMLT, reg8);
36
37 /* Clear errors in status registers */
38 reg16 = pci_read_config16(dev, PCI_STATUS);
39 //reg16 |= 0xf900;
40 pci_write_config16(dev, PCI_STATUS, reg16);
41
42 reg16 = pci_read_config16(dev, PCI_SEC_STATUS);
43 // reg16 |= 0xf900;
44 pci_write_config16(dev, PCI_SEC_STATUS, reg16);
45}
46
Elyes HAOUAS1a8c1df2018-05-13 13:36:44 +020047static void set_subsystem(struct device *dev, unsigned vendor, unsigned device)
Arthur Heymans7b9c1392017-04-09 20:40:39 +020048{
49 /* NOTE: 0x54 is not the default position! */
50 if (!vendor || !device) {
51 pci_write_config32(dev, 0x54,
52 pci_read_config32(dev, PCI_VENDOR_ID));
53 } else {
54 pci_write_config32(dev, 0x54,
55 ((device & 0xffff) << 16) | (vendor & 0xffff));
56 }
57}
58
59static struct pci_operations pci_ops = {
60 .set_subsystem = set_subsystem,
61};
62
63static struct device_operations device_ops = {
64 .read_resources = pci_bus_read_resources,
65 .set_resources = pci_dev_set_resources,
66 .enable_resources = pci_bus_enable_resources,
67 .init = pci_init,
68 .scan_bus = pci_scan_bridge,
69 .reset_bus = pci_bus_reset,
70 .ops_pci = &pci_ops,
71};
72
73static const unsigned short pci_device_ids[] = {
Arthur Heymans349e0852017-04-09 20:48:37 +020074 0x244e,
Arthur Heymans7b9c1392017-04-09 20:40:39 +020075 0
76};
77
Arthur Heymans349e0852017-04-09 20:48:37 +020078static const struct pci_driver ich10_pci __pci_driver = {
Arthur Heymans7b9c1392017-04-09 20:40:39 +020079 .ops = &device_ops,
80 .vendor = PCI_VENDOR_ID_INTEL,
81 .devices = pci_device_ids,
82};