blob: 742c28d6306e657e63c42780840d3f4e8a7d3469 [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
24void set_pcie_reset(void);
25void set_pcie_dereset(void);
26
27/***********************************************************
28 * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
29 * This table is responsible for physically routing the PIC and
30 * IOAPIC IRQs to the different PCI devices on the system. It
31 * is read and written via registers 0xC00/0xC01 as an
32 * Index/Data pair. These values are chipset and mainboard
33 * dependent and should be updated accordingly.
34 *
35 * These values are used by the PCI configuration space,
36 * MP Tables. TODO: Make ACPI use these values too.
37 */
38static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = {
39 [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, /* INTA# - INTH# */
40 [0x08] = 0x00,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */
41 [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F,0x0A, /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon, SD */
42 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, /* IMC INT0 - 5 */
43 [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, /* USB Devs 18/19/20/22 INTA-C */
44 [0x40] = 0x0B,0x0B, /* IDE, SATA */
45};
46
47static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = {
48 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, /* INTA# - INTH# */
49 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */
50 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F,0x10, /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */
51 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, /* IMC INT0 - 5 */
52 [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12, /* USB Devs 18/19/22/20 INTA-C */
53 [0x40] = 0x11,0x13, /* IDE, SATA */
54};
55
56/*
57 * This table defines the index into the picr/intr_data
58 * tables for each device. Any enabled device and slot
59 * that uses hardware interrupts should have an entry
60 * in this table to define its index into the FCH
61 * PCI_INTR register 0xC00/0xC01. This index will define
62 * the interrupt that it should use. Putting PIRQ_A into
63 * the PIN A index for a device will tell that device to
64 * use PIC IRQ 10 if it uses PIN A for its hardware INT.
65 */
66static const struct pirq_struct mainboard_pirq_data[] = {
67 /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */
68 {GFX_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
69 {NB_PCIE_PORT2_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.2 */
70 {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.3 */
71 {NB_PCIE_PORT4_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.4 */
72 {NB_PCIE_PORT5_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.5 */
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 {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCIB: 14.4 */
81 {SD_DEVFN, {PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SD: 14.7 */
82 {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */
83 {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */
84};
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/* TODO: mainboard specific SB AGESA callback */
96void set_pcie_reset(void)
97{
98}
99
100/* TODO: mainboard specific SB AGESA callback */
101void set_pcie_dereset(void)
102{
103}
Kyösti Mälkkie75deb62014-06-26 09:12:54 +0300104
105/**********************************************
Dave Frodin83405a12014-06-05 11:49:04 -0600106 * Enable the dedicated functions of the board.
Kyösti Mälkkie75deb62014-06-26 09:12:54 +0300107 **********************************************/
108static void mainboard_enable(device_t dev)
109{
110 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
111
Dave Frodin83405a12014-06-05 11:49:04 -0600112 /* Initialize the PIRQ data structures for consumption */
113 pirq_setup();
Kyösti Mälkkie75deb62014-06-26 09:12:54 +0300114}
115
116struct chip_operations mainboard_ops = {
117 .enable_dev = mainboard_enable,
118};