blob: 895135bdd2610624c3a5d3e56e040895861cb8e0 [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älkkidf128a52019-09-21 18:35:37 +03006#include <device/pci_def.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02007#include <device/pci_ops.h>
Stefan Reinauer8e073822012-04-04 00:07:22 +02008#include <device/pci_ids.h>
9#include "pch.h"
10
11static void pci_init(struct device *dev)
12{
13 u16 reg16;
Stefan Reinauer8e073822012-04-04 00:07:22 +020014
15 printk(BIOS_DEBUG, "PCI init.\n");
16 /* Enable Bus Master */
Angel Ponsc803f652020-06-07 22:09:01 +020017 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Stefan Reinauer8e073822012-04-04 00:07:22 +020018
19 /* This device has no interrupt */
20 pci_write_config8(dev, INTR, 0xff);
21
22 /* disable parity error response and SERR */
Angel Ponsc803f652020-06-07 22:09:01 +020023 pci_and_config16(dev, PCI_BRIDGE_CONTROL,
24 ~(PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR));
Stefan Reinauer8e073822012-04-04 00:07:22 +020025
26 /* Master Latency Count must be set to 0x04! */
Angel Ponsc803f652020-06-07 22:09:01 +020027 pci_update_config8(dev, SMLT, 0x07, (0x04 << 3));
Stefan Reinauer8e073822012-04-04 00:07:22 +020028
Angel Ponsc803f652020-06-07 22:09:01 +020029 /* Clear errors in status registers. FIXME: do we need to do something? */
Stefan Reinauer8e073822012-04-04 00:07:22 +020030 reg16 = pci_read_config16(dev, PSTS);
31 //reg16 |= 0xf900;
32 pci_write_config16(dev, PSTS, reg16);
33
34 reg16 = pci_read_config16(dev, SECSTS);
35 // reg16 |= 0xf900;
36 pci_write_config16(dev, SECSTS, reg16);
37}
38
Stefan Reinauer8e073822012-04-04 00:07:22 +020039static struct device_operations device_ops = {
40 .read_resources = pci_bus_read_resources,
41 .set_resources = pci_dev_set_resources,
Kyösti Mälkkia84a7342019-09-23 10:01:16 +030042 .enable_resources = pci_bus_enable_resources,
Stefan Reinauer8e073822012-04-04 00:07:22 +020043 .init = pci_init,
44 .scan_bus = pci_scan_bridge,
Angel Pons1fc0edd2020-05-31 00:03:28 +020045 .ops_pci = &pci_dev_ops_pci,
Stefan Reinauer8e073822012-04-04 00:07:22 +020046};
47
48static const struct pci_driver pch_pci __pci_driver = {
49 .ops = &device_ops,
50 .vendor = PCI_VENDOR_ID_INTEL,
51 .device = 0x2448,
52};