blob: 229442121f571ef8f44e1d1b59aaad5e1132361c [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
Felix Held898757f2023-11-18 17:49:48 +010038struct device_operations bd82x6x_pci_bridge_ops = {
Stefan Reinauer8e073822012-04-04 00:07:22 +020039 .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};