blob: 382506b97ad8843a49eee53b63f64b9c65daeb04 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer8e073822012-04-04 00:07:22 +02002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +02007#include <device/pci_ids.h>
8#include "pch.h"
9
10static void pci_init(struct device *dev)
11{
12 u16 reg16;
Stefan Reinauer8e073822012-04-04 00:07:22 +020013
14 printk(BIOS_DEBUG, "PCI init.\n");
15 /* Enable Bus Master */
Angel Ponsc803f652020-06-07 22:09:01 +020016 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Stefan Reinauer8e073822012-04-04 00:07:22 +020017
18 /* This device has no interrupt */
19 pci_write_config8(dev, INTR, 0xff);
20
21 /* disable parity error response and SERR */
Angel Ponsc803f652020-06-07 22:09:01 +020022 pci_and_config16(dev, PCI_BRIDGE_CONTROL,
23 ~(PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR));
Stefan Reinauer8e073822012-04-04 00:07:22 +020024
25 /* Master Latency Count must be set to 0x04! */
Angel Ponsc803f652020-06-07 22:09:01 +020026 pci_update_config8(dev, SMLT, 0x07, (0x04 << 3));
Stefan Reinauer8e073822012-04-04 00:07:22 +020027
Angel Ponsc803f652020-06-07 22:09:01 +020028 /* Clear errors in status registers. FIXME: do we need to do something? */
Stefan Reinauer8e073822012-04-04 00:07:22 +020029 reg16 = pci_read_config16(dev, PSTS);
30 //reg16 |= 0xf900;
31 pci_write_config16(dev, PSTS, reg16);
32
33 reg16 = pci_read_config16(dev, SECSTS);
34 // reg16 |= 0xf900;
35 pci_write_config16(dev, SECSTS, reg16);
36}
37
Stefan Reinauer8e073822012-04-04 00:07:22 +020038static struct device_operations device_ops = {
39 .read_resources = pci_bus_read_resources,
40 .set_resources = pci_dev_set_resources,
Kyösti Mälkkia84a7342019-09-23 10:01:16 +030041 .enable_resources = pci_bus_enable_resources,
Stefan Reinauer8e073822012-04-04 00:07:22 +020042 .init = pci_init,
43 .scan_bus = pci_scan_bridge,
Angel Pons1fc0edd2020-05-31 00:03:28 +020044 .ops_pci = &pci_dev_ops_pci,
Stefan Reinauer8e073822012-04-04 00:07:22 +020045};
46
James Yeb92a4d62020-05-03 23:04:07 +100047static const unsigned short pci_device_ids[] = {
48 0x2448, /* Mobile */
49 0x244e, /* Desktop */
50 0
51};
52
Stefan Reinauer8e073822012-04-04 00:07:22 +020053static const struct pci_driver pch_pci __pci_driver = {
James Yeb92a4d62020-05-03 23:04:07 +100054 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010055 .vendor = PCI_VID_INTEL,
James Yeb92a4d62020-05-03 23:04:07 +100056 .devices = pci_device_ids,
Stefan Reinauer8e073822012-04-04 00:07:22 +020057};