blob: e0440f297a5b2e5d6e9afb8f31bf240824070990 [file] [log] [blame]
Frank Vibrans69da1b62011-02-14 19:04:45 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
Mike Loptienc93a75a2014-06-06 15:16:29 -06005 * Copyright (C) 2014 Sage Electronic Engineering, LLC.
Frank Vibrans69da1b62011-02-14 19:04:45 +00006 *
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.
Frank Vibrans69da1b62011-02-14 19:04:45 +000015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <arch/io.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000021#include <cpu/x86/msr.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000022#include <device/pci_def.h>
Stefan Reinauer13e41822015-04-27 14:02:36 -070023#include <southbridge/amd/common/amd_pci_util.h>
Mike Loptienc93a75a2014-06-06 15:16:29 -060024#include <southbridge/amd/cimx/cimx_util.h>
zbaof543c7b2012-04-13 13:42:46 +080025#include <arch/acpi.h>
Kyösti Mälkki26f297e2014-05-26 11:27:54 +030026#include <northbridge/amd/agesa/BiosCallOuts.h>
zbaof543c7b2012-04-13 13:42:46 +080027#include <cpu/amd/agesa/s3_resume.h>
28#include <cpu/amd/mtrr.h>
Dave Frodin73be43a2012-11-16 14:16:33 -070029#include "SBPLATFORM.h"
Mike Loptienc93a75a2014-06-06 15:16:29 -060030#include <southbridge/amd/cimx/sb800/pci_devs.h>
31#include <northbridge/amd/agesa/family14/pci_devs.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000032
efdesign98d7a696d2011-09-15 15:24:26 -060033void set_pcie_reset(void);
34void set_pcie_dereset(void);
Frank Vibrans69da1b62011-02-14 19:04:45 +000035
Mike Loptienc93a75a2014-06-06 15:16:29 -060036/***********************************************************
37 * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
38 * This table is responsible for physically routing the PIC and
39 * IOAPIC IRQs to the different PCI devices on the system. It
40 * is read and written via registers 0xC00/0xC01 as an
41 * Index/Data pair. These values are chipset and mainboard
42 * dependent and should be updated accordingly.
43 *
44 * These values are used by the PCI configuration space,
45 * MP Tables. TODO: Make ACPI use these values too.
46 *
47 * The Persimmon PCI INTA/B/C/D pins are connected to
48 * FCH pins INTE/F/G/H on the schematic so these need
49 * to be routed as well.
50 */
51static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = {
52 /* INTA# - INTH# */
53 [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
54 /* Misc-nil,0,1,2, INT from Serial irq */
55 [0x08] = 0x00,0xF0,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
56 /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon */
57 [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F,
58 /* IMC INT0 - 5 */
59 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
60 /* USB Devs 18/19/20/22 INTA-C */
61 [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
62 /* IDE, SATA */
63 [0x40] = 0x0B,0x0B,
64 /* GPPInt0 - 3 */
65 [0x50] = 0x0A,0x0B,0x0A,0x0B
66};
67
68static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = {
69 /* INTA# - INTH# */
70 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71 /* Misc-nil,0,1,2, INT from Serial irq */
72 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
73 /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon */
74 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F,
75 /* IMC INT0 - 5 */
76 [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
77 /* USB Devs 18/19/22/20 INTA-C */
78 [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12,
79 /* IDE, SATA */
80 [0x40] = 0x11,0x13,
81 /* GPPInt0 - 3 */
82 [0x50] = 0x10,0x11,0x12,0x13
83};
84
85/*
86 * This table defines the index into the picr/intr_data
87 * tables for each device. Any enabled device and slot
88 * that uses hardware interrupts should have an entry
89 * in this table to define its index into the FCH
90 * PCI_INTR register 0xC00/0xC01. This index will define
91 * the interrupt that it should use. Putting PIRQ_A into
92 * the PIN A index for a device will tell that device to
93 * use PIC IRQ 10 if it uses PIN A for its hardware INT.
94 */
95/*
96 * Persimmon has PCI slot INTA/B/C/D connected to PIRQE/F/G/H
97 * but because PCI INT_PIN swizzling isnt implemented to match
98 * the IDSEL (dev 3) of the slot, the table is adjusted for the
99 * swizzle and INTA is connected to PIRQH so PINA/B/C/D on
100 * off-chip devices should get mapped to PIRQH/E/F/G.
101 */
102static const struct pirq_struct mainboard_pirq_data[] = {
Kyösti Mälkkifaaa2532014-06-26 07:11:22 +0300103 /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */
104 {GFX_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
105 {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 04.0 */
106 {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* PCIe bdg: 06.0 */
107 {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */
108 {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */
109 {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */
110 {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */
111 {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */
112 {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */
113 {IDE_DEVFN, {PIRQ_NC, PIRQ_IDE, PIRQ_NC, PIRQ_NC}}, /* IDE: 14.1 */
114 {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */
115 {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCI bdg: 14.4 */
116 {OHCI4_DEVFN, {PIRQ_NC, PIRQ_NC, PIRQ_OHCI4, PIRQ_NC}}, /* OHCI4: 14.5 */
117 {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */
118 {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */
Mike Loptienc93a75a2014-06-06 15:16:29 -0600119};
120
121/* PIRQ Setup */
122static void pirq_setup(void)
123{
124 pirq_data_ptr = mainboard_pirq_data;
125 pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct);
126 intr_data_ptr = mainboard_intr_data;
127 picr_data_ptr = mainboard_picr_data;
128}
129
Frank Vibrans69da1b62011-02-14 19:04:45 +0000130/**
131 * TODO
132 * SB CIMx callback
133 */
134void set_pcie_reset(void)
135{
136}
137
138/**
139 * TODO
140 * mainboard specific SB CIMx callback
141 */
142void set_pcie_dereset(void)
143{
144}
145
Frank Vibrans69da1b62011-02-14 19:04:45 +0000146
Jens Rottmann5e707662013-02-26 15:56:11 +0100147/**********************************************
148 * Enable the dedicated functions of the board.
149 **********************************************/
Paul Menzel528640d2013-02-23 21:31:23 +0100150static void mainboard_enable(device_t dev)
Frank Vibrans69da1b62011-02-14 19:04:45 +0000151{
Scott Duplichan8c462632011-05-15 22:10:15 +0000152 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
153
Dave Frodin73be43a2012-11-16 14:16:33 -0700154 /* enable GPP CLK0 thru CLK1 */
155 /* disable GPP CLK2 thru SLT_GFX_CLK */
156 u8 *misc_mem_clk_cntrl = (u8 *)(ACPI_MMIO_BASE + MISC_BASE);
Felix Held421b47e2015-10-17 13:16:27 +0200157 write8(misc_mem_clk_cntrl + 0, 0xFF);
158 write8(misc_mem_clk_cntrl + 1, 0x00);
159 write8(misc_mem_clk_cntrl + 2, 0x00);
160 write8(misc_mem_clk_cntrl + 3, 0x00);
161 write8(misc_mem_clk_cntrl + 4, 0x00);
Martin Roth45f72ce2013-02-24 12:58:33 -0700162
163 /*
164 * Initialize ASF registers to an arbitrary address because someone
165 * long ago set things up this way inside the SPD read code. The
Paul Menzelb55b74f2013-03-07 22:41:25 +0100166 * SPD read code has been made generic and moved out of the board
Martin Roth45f72ce2013-02-24 12:58:33 -0700167 * directory, so the ASF init is being done here.
168 */
169 pm_iowrite(0x29, 0x80);
170 pm_iowrite(0x28, 0x61);
Mike Loptienc93a75a2014-06-06 15:16:29 -0600171
172 /* Initialize the PIRQ data structures for consumption */
173 pirq_setup();
Frank Vibrans69da1b62011-02-14 19:04:45 +0000174}
175
Frank Vibrans69da1b62011-02-14 19:04:45 +0000176struct chip_operations mainboard_ops = {
Paul Menzel528640d2013-02-23 21:31:23 +0100177 .enable_dev = mainboard_enable,
Frank Vibrans69da1b62011-02-14 19:04:45 +0000178};