blob: ab1bb8b8292ba775c47974743e35207d9f6f18e1 [file] [log] [blame]
Kyösti Mälkki595ef3d2015-05-27 12:44:16 +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 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc.
20 */
21
22#include <console/console.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <arch/io.h>
26#include <cpu/x86/msr.h>
27#include <cpu/amd/mtrr.h>
28#include <device/pci_def.h>
29#include <arch/acpi.h>
30#include <southbridge/amd/agesa/hudson/pci_devs.h>
31#include <southbridge/amd/agesa/hudson/amd_pci_int_defs.h>
32#include <southbridge/amd/common/amd_pci_util.h>
33#include <northbridge/amd/agesa/family16kb/pci_devs.h>
34#include <northbridge/amd/agesa/BiosCallOuts.h>
35#include <cpu/amd/agesa/s3_resume.h>
36#include <northbridge/amd/agesa/agesawrapper.h>
37
38/***********************************************************
39 * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
40 * This table is responsible for physically routing the PIC and
41 * IOAPIC IRQs to the different PCI devices on the system. It
42 * is read and written via registers 0xC00/0xC01 as an
43 * Index/Data pair. These values are chipset and mainboard
44 * dependent and should be updated accordingly.
45 *
46 * These values are used by the PCI configuration space,
47 * MP Tables. TODO: Make ACPI use these values too.
48 */
49const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = {
50 /* INTA# - INTH# */
51 [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
52 /* Misc-nil,0,1,2, INT from Serial irq */
53 [0x08] = 0xFA,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
54 /* SCI, SMBUS0, ASF, HDA, FC, RSVD, PerMon, SD */
55 [0x10] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
56 /* IMC INT0 - 5 */
57 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
58 /* USB Devs 18/19/22 INTA-C */
59 [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
60 /* SATA */
61 [0x41] = 0x0F,
62};
63
64const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = {
65 /* INTA# - INTH# */
66 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
67 /* Misc-nil,0,1,2, INT from Serial irq */
68 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
69 /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */
70 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x10,0x1F,0x10,0x1F,
71 /* IMC INT0 - 5 */
72 [0x20] = 0x05,0x1F,0x1F,0x1F,0x1F,0x1F,
73 /* USB Devs 18/19/20/22 INTA-C */
74 [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12,
75 /* SATA */
76 [0x41] = 0x13
77};
78
79/*
80 * This table defines the index into the picr/intr_data
81 * tables for each device. Any enabled device and slot
82 * that uses hardware interrupts should have an entry
83 * in this table to define its index into the FCH
84 * PCI_INTR register 0xC00/0xC01. This index will define
85 * the interrupt that it should use. Putting PIRQ_A into
86 * the PIN A index for a device will tell that device to
87 * use PIC IRQ 10 if it uses PIN A for its hardware INT.
88 */
89static const struct pirq_struct mainboard_pirq_data[] = {
90 /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */
91 {GFX_DEVFN, {PIRQ_A, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
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_NC}}, /* SD: 14.7 */
107};
108
109const u8 *picr_data = mainboard_picr_data;
110const u8 *intr_data = mainboard_intr_data;
111
112/* PIRQ Setup */
113static void pirq_setup(void)
114{
115 pirq_data_ptr = mainboard_pirq_data;
116 pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct);
117 intr_data_ptr = mainboard_intr_data;
118 picr_data_ptr = mainboard_picr_data;
119}
120
121/**********************************************
122 * enable the dedicated function in mainboard.
123 **********************************************/
124static void mainboard_enable(device_t dev)
125{
126 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
127
128 if (acpi_is_wakeup_s3())
129 agesawrapper_fchs3earlyrestore();
130
131 /* Initialize the PIRQ data structures for consumption */
132 pirq_setup();
133}
134
135struct chip_operations mainboard_ops = {
136 .enable_dev = mainboard_enable,
137};