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