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