Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 3 | |
| 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
Kyösti Mälkki | df128a5 | 2019-09-21 18:35:37 +0300 | [diff] [blame] | 7 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 8 | #include <device/pci_ops.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 9 | #include <device/pci_ids.h> |
| 10 | #include "pch.h" |
| 11 | |
| 12 | static 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älkki | df128a5 | 2019-09-21 18:35:37 +0300 | [diff] [blame] | 27 | 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 Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 31 | |
| 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 Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 38 | /* 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 Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 48 | static struct pci_operations pci_ops = { |
Kyösti Mälkki | dbd3132 | 2019-03-20 17:55:27 +0200 | [diff] [blame] | 49 | .set_subsystem = pci_dev_set_subsystem, |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static struct device_operations device_ops = { |
| 53 | .read_resources = pci_bus_read_resources, |
| 54 | .set_resources = pci_dev_set_resources, |
Kyösti Mälkki | a84a734 | 2019-09-23 10:01:16 +0300 | [diff] [blame] | 55 | .enable_resources = pci_bus_enable_resources, |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 56 | .init = pci_init, |
| 57 | .scan_bus = pci_scan_bridge, |
| 58 | .ops_pci = &pci_ops, |
| 59 | }; |
| 60 | |
| 61 | static const struct pci_driver pch_pci __pci_driver = { |
| 62 | .ops = &device_ops, |
| 63 | .vendor = PCI_VENDOR_ID_INTEL, |
| 64 | .device = 0x2448, |
| 65 | }; |