blob: 076b30cf6eec0f879ec7150d568b094f2bb6d3b2 [file] [log] [blame]
Sergej Ivanovd777c782015-04-03 18:10:27 +03001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
5 * Copyright (C) 2014 Sage Electronic Engineering, LLC
6 * Copyright (C) 2015 Sergej Ivanov <getinaks@gmail.com>
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Sergej Ivanovd777c782015-04-03 18:10:27 +030017 */
18
19#include <console/console.h>
20#include <device/device.h>
21#include <device/pci.h>
22#include <arch/io.h>
23#include <cpu/x86/msr.h>
24#include <cpu/amd/mtrr.h>
25#include <device/pci_def.h>
26#include <arch/acpi.h>
27#include <northbridge/amd/agesa/BiosCallOuts.h>
Sergej Ivanovd777c782015-04-03 18:10:27 +030028#include <northbridge/amd/agesa/agesawrapper.h>
29#include <southbridge/amd/agesa/hudson/pci_devs.h>
30#include <southbridge/amd/agesa/hudson/amd_pci_int_defs.h>
Stefan Reinauer13e41822015-04-27 14:02:36 -070031#include <southbridge/amd/common/amd_pci_util.h>
Sergej Ivanovd777c782015-04-03 18:10:27 +030032#include <northbridge/amd/agesa/family16kb/pci_devs.h>
33
34const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = {
35 /* INTA# - INTH# */
36 [0x00] = 0x03,0x04,0x05,0x07,0x0B,0x0A,0x1F,0x1F,
37 /* Misc-nil,0,1,2, INT from Serial irq */
38 [0x08] = 0x5A,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
39 /* SCI, SMBUS0, ASF, HDA, FC, RSVD, PerMon, SD */
40 [0x10] = 0x1F,0x1F,0x1F,0x03,0x1F,0x1F,0x1F,0x1F, // HDA was 1F - now 03
41 /* IMC INT0 - 5 */
42 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
43 /* USB Devs 18/19/22 INTA-C */
44 [0x30] = 0x05,0x04,0x05,0x04,0x04,0x05,0x04,0x05,
45 /* SATA & MISSING IDE */
46 [0x40] = 0x04, 0x04
47};
48
49const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = {
50 /* INTA# - INTH# */
51 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
52 /* Misc-nil,0,1,2, INT from Serial irq */
53 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
54 /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */
55 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x10,0x1F,0x10,0x1F,0x1F,
56 /* IMC INT0 - 5 */
57 [0x20] = 0x05,0x1F,0x1F,0x1F,0x1F,0x1F,
58 /* USB Devs 18/19/20/22 INTA-C */
59 [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12,
60 /* SATA & MISSING IDE*/
61 [0x40] = 0x11, 0x11
62};
63
64/*
65 * This table defines the index into the picr/intr_data
66 * tables for each device. Any enabled device and slot
67 * that uses hardware interrupts should have an entry
68 * in this table to define its index into the FCH
69 * PCI_INTR register 0xC00/0xC01. This index will define
70 * the interrupt that it should use. Putting PIRQ_A into
71 * the PIN A index for a device will tell that device to
72 * use PIC IRQ 10 if it uses PIN A for its hardware INT.
73 */
74static const struct pirq_struct mainboard_pirq_data[] = {
75 /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */
76 {GFX_DEVFN, {PIRQ_A, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
77 {ACTL_DEVFN,{PIRQ_NC, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* Audio: 01.1 */
78 {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* x4 PCIe: 02.1 */
79 {NB_PCIE_PORT2_DEVFN, {PIRQ_B, PIRQ_C, PIRQ_D, PIRQ_A}}, /* mPCIe: 02.2 */
80 {NB_PCIE_PORT3_DEVFN, {PIRQ_C, PIRQ_D, PIRQ_A, PIRQ_B}}, /* NIC: 02.3 */
81 {NB_PCIE_PORT4_DEVFN, {PIRQ_D, PIRQ_A, PIRQ_B, PIRQ_C}}, /* Edge: 02.4 */
82 {NB_PCIE_PORT5_DEVFN, {PIRQ_E, PIRQ_F, PIRQ_G, PIRQ_H}}, /* Edge: 02.5 */
83 {XHCI_DEVFN, {PIRQ_C, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* XHCI: 10.0 */
84 {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */
85 {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */
86 {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */
87 {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */
88 {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */
89 {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */
90 {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */
91 {LPC_DEVFN, {PIRQ_C, PIRQ_NC, PIRQ_NC, PIRQ_NC }}, /* LPC: 14.3 */
92 {SD_DEVFN, {PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SD: 14.7 */
93};
94
95const u8 *picr_data = mainboard_picr_data;
96const u8 *intr_data = mainboard_intr_data;
97
98/* PIRQ Setup */
99static void pirq_setup(void)
100{
101 pirq_data_ptr = mainboard_pirq_data;
102 pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct);
103 intr_data_ptr = mainboard_intr_data;
104 picr_data_ptr = mainboard_picr_data;
105}
106
107/**********************************************
108 * enable the dedicated function in mainboard.
109 **********************************************/
110static void mainboard_enable(device_t dev)
111{
112 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
113
114 if (acpi_is_wakeup_s3())
115 agesawrapper_fchs3earlyrestore();
116
117 /* Initialize the PIRQ data structures for consumption */
118 pirq_setup();
119}
120
121struct chip_operations mainboard_ops = {
122 .enable_dev = mainboard_enable,
123};