Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
Kyösti Mälkki | df128a5 | 2019-09-21 18:35:37 +0300 | [diff] [blame] | 6 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 8 | #include <device/pci_ids.h> |
| 9 | #include "pch.h" |
| 10 | |
| 11 | static void pci_init(struct device *dev) |
| 12 | { |
| 13 | u16 reg16; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 14 | |
| 15 | printk(BIOS_DEBUG, "PCI init.\n"); |
| 16 | /* Enable Bus Master */ |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 17 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 18 | |
| 19 | /* This device has no interrupt */ |
| 20 | pci_write_config8(dev, INTR, 0xff); |
| 21 | |
| 22 | /* disable parity error response and SERR */ |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 23 | pci_and_config16(dev, PCI_BRIDGE_CONTROL, |
| 24 | ~(PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR)); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 25 | |
| 26 | /* Master Latency Count must be set to 0x04! */ |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 27 | pci_update_config8(dev, SMLT, 0x07, (0x04 << 3)); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 28 | |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 29 | /* Clear errors in status registers. FIXME: do we need to do something? */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 30 | 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 Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 39 | static struct device_operations device_ops = { |
| 40 | .read_resources = pci_bus_read_resources, |
| 41 | .set_resources = pci_dev_set_resources, |
Kyösti Mälkki | a84a734 | 2019-09-23 10:01:16 +0300 | [diff] [blame] | 42 | .enable_resources = pci_bus_enable_resources, |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 43 | .init = pci_init, |
| 44 | .scan_bus = pci_scan_bridge, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 45 | .ops_pci = &pci_dev_ops_pci, |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | static const struct pci_driver pch_pci __pci_driver = { |
| 49 | .ops = &device_ops, |
| 50 | .vendor = PCI_VENDOR_ID_INTEL, |
| 51 | .device = 0x2448, |
| 52 | }; |