blob: 420c249686ae4db45308da8d77d1750f8fc07cc1 [file] [log] [blame]
Angel Pons0fcb1b82020-04-03 01:21:20 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +03003
4#include <console/console.h>
5#include <device/device.h>
Kyösti Mälkkif7ca6722017-09-10 06:30:54 +03006
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +03007#include <southbridge/amd/agesa/hudson/pci_devs.h>
8#include <southbridge/amd/agesa/hudson/amd_pci_int_defs.h>
9#include <southbridge/amd/common/amd_pci_util.h>
10#include <northbridge/amd/agesa/family16kb/pci_devs.h>
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +030011
12/***********************************************************
13 * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
14 * This table is responsible for physically routing the PIC and
15 * IOAPIC IRQs to the different PCI devices on the system. It
16 * is read and written via registers 0xC00/0xC01 as an
17 * Index/Data pair. These values are chipset and mainboard
18 * dependent and should be updated accordingly.
19 *
20 * These values are used by the PCI configuration space,
21 * MP Tables. TODO: Make ACPI use these values too.
22 */
Kyösti Mälkkie1e32892019-12-22 09:49:56 +020023static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = {
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +030024 /* INTA# - INTH# */
25 [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
26 /* Misc-nil,0,1,2, INT from Serial irq */
27 [0x08] = 0xFA,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
28 /* SCI, SMBUS0, ASF, HDA, FC, RSVD, PerMon, SD */
29 [0x10] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
30 /* IMC INT0 - 5 */
31 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
32 /* USB Devs 18/19/22 INTA-C */
33 [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
34 /* SATA */
35 [0x41] = 0x0F,
36};
37
Kyösti Mälkkie1e32892019-12-22 09:49:56 +020038static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = {
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +030039 /* INTA# - INTH# */
40 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
41 /* Misc-nil,0,1,2, INT from Serial irq */
42 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
43 /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */
44 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x10,0x1F,0x10,0x1F,
45 /* IMC INT0 - 5 */
46 [0x20] = 0x05,0x1F,0x1F,0x1F,0x1F,0x1F,
47 /* USB Devs 18/19/20/22 INTA-C */
48 [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12,
49 /* SATA */
50 [0x41] = 0x13
51};
52
53/*
54 * This table defines the index into the picr/intr_data
55 * tables for each device. Any enabled device and slot
56 * that uses hardware interrupts should have an entry
57 * in this table to define its index into the FCH
58 * PCI_INTR register 0xC00/0xC01. This index will define
59 * the interrupt that it should use. Putting PIRQ_A into
60 * the PIN A index for a device will tell that device to
61 * use PIC IRQ 10 if it uses PIN A for its hardware INT.
62 */
63static const struct pirq_struct mainboard_pirq_data[] = {
64 /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */
65 {GFX_DEVFN, {PIRQ_A, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
66 {ACTL_DEVFN,{PIRQ_NC, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* Audio: 01.1 */
67 {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* x4 PCIe: 02.1 */
68 {NB_PCIE_PORT2_DEVFN, {PIRQ_B, PIRQ_C, PIRQ_D, PIRQ_A}}, /* mPCIe: 02.2 */
69 {NB_PCIE_PORT3_DEVFN, {PIRQ_C, PIRQ_D, PIRQ_A, PIRQ_B}}, /* NIC: 02.3 */
70 {NB_PCIE_PORT4_DEVFN, {PIRQ_D, PIRQ_A, PIRQ_B, PIRQ_C}}, /* Edge: 02.4 */
71 {NB_PCIE_PORT5_DEVFN, {PIRQ_E, PIRQ_F, PIRQ_G, PIRQ_H}}, /* Edge: 02.5 */
72 {XHCI_DEVFN, {PIRQ_C, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* XHCI: 10.0 */
73 {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */
74 {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */
75 {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */
76 {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */
77 {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */
78 {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */
79 {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */
80 {SD_DEVFN, {PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SD: 14.7 */
81};
82
83const u8 *picr_data = mainboard_picr_data;
84const u8 *intr_data = mainboard_intr_data;
85
86/* PIRQ Setup */
87static void pirq_setup(void)
88{
89 pirq_data_ptr = mainboard_pirq_data;
90 pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct);
91 intr_data_ptr = mainboard_intr_data;
92 picr_data_ptr = mainboard_picr_data;
93}
94
95/**********************************************
96 * enable the dedicated function in mainboard.
97 **********************************************/
Elyes HAOUAS5a0757c2018-05-04 20:05:33 +020098static void mainboard_enable(struct device *dev)
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +030099{
100 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
101
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +0300102 /* Initialize the PIRQ data structures for consumption */
103 pirq_setup();
104}
105
106struct chip_operations mainboard_ops = {
107 .enable_dev = mainboard_enable,
108};