blob: aaa899b55da1819665693d0015b34f18bf20263e [file] [log] [blame]
Kyösti Mälkkie75deb62014-06-26 09:12:54 +03001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
Dave Frodin83405a12014-06-05 11:49:04 -06005 * Copyright (C) 2014 Sage Electronic Engineering, LLC
Kyösti Mälkkie75deb62014-06-26 09:12:54 +03006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Kyösti Mälkkie75deb62014-06-26 09:12:54 +030015 */
16
17#include <console/console.h>
18#include <device/device.h>
Kyösti Mälkkif7ca6722017-09-10 06:30:54 +030019
Stefan Reinauer13e41822015-04-27 14:02:36 -070020#include <southbridge/amd/common/amd_pci_util.h>
Dave Frodin83405a12014-06-05 11:49:04 -060021#include <southbridge/amd/agesa/hudson/pci_devs.h>
22#include <northbridge/amd/agesa/family16kb/pci_devs.h>
23
Dave Frodin83405a12014-06-05 11:49:04 -060024/***********************************************************
25 * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
26 * This table is responsible for physically routing the PIC and
27 * IOAPIC IRQs to the different PCI devices on the system. It
28 * is read and written via registers 0xC00/0xC01 as an
29 * Index/Data pair. These values are chipset and mainboard
30 * dependent and should be updated accordingly.
31 *
32 * These values are used by the PCI configuration space,
33 * MP Tables. TODO: Make ACPI use these values too.
34 */
35static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = {
36 [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, /* INTA# - INTH# */
37 [0x08] = 0x00,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */
38 [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F,0x0A, /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon, SD */
39 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, /* IMC INT0 - 5 */
40 [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, /* USB Devs 18/19/20/22 INTA-C */
41 [0x40] = 0x0B,0x0B, /* IDE, SATA */
42};
43
44static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = {
45 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, /* INTA# - INTH# */
46 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */
47 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F,0x10, /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */
48 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, /* IMC INT0 - 5 */
49 [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12, /* USB Devs 18/19/22/20 INTA-C */
50 [0x40] = 0x11,0x13, /* IDE, SATA */
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_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
66 {NB_PCIE_PORT2_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.2 */
67 {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.3 */
68 {NB_PCIE_PORT4_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.4 */
69 {NB_PCIE_PORT5_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.5 */
70 {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */
71 {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */
72 {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */
73 {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */
74 {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */
75 {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */
76 {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */
77 {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCIB: 14.4 */
78 {SD_DEVFN, {PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SD: 14.7 */
79 {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */
80 {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */
81};
82
83/* PIRQ Setup */
84static void pirq_setup(void)
85{
86 pirq_data_ptr = mainboard_pirq_data;
87 pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct);
88 intr_data_ptr = mainboard_intr_data;
89 picr_data_ptr = mainboard_picr_data;
90}
91
Kyösti Mälkkie75deb62014-06-26 09:12:54 +030092/**********************************************
Dave Frodin83405a12014-06-05 11:49:04 -060093 * Enable the dedicated functions of the board.
Kyösti Mälkkie75deb62014-06-26 09:12:54 +030094 **********************************************/
Elyes HAOUAS56f172d2018-05-04 20:41:40 +020095static void mainboard_enable(struct device *dev)
Kyösti Mälkkie75deb62014-06-26 09:12:54 +030096{
97 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
98
Dave Frodin83405a12014-06-05 11:49:04 -060099 /* Initialize the PIRQ data structures for consumption */
100 pirq_setup();
Kyösti Mälkkie75deb62014-06-26 09:12:54 +0300101}
102
103struct chip_operations mainboard_ops = {
104 .enable_dev = mainboard_enable,
105};