coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/acpimmio.h>
4 #include <device/device.h>
5 #include <device/mmio.h>
10 
11 /***********************************************************
12  * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
13  * This table is responsible for physically routing the PIC and
14  * IOAPIC IRQs to the different PCI devices on the system. It
15  * is read and written via registers 0xC00/0xC01 as an
16  * Index/Data pair. These values are chipset and mainboard
17  * dependent and should be updated accordingly.
18  *
19  * These values are used by the PCI configuration space,
20  * MP Tables. TODO: Make ACPI use these values too.
21  *
22  * The Persimmon PCI INTA/B/C/D pins are connected to
23  * FCH pins INTE/F/G/H on the schematic so these need
24  * to be routed as well.
25  */
27  /* INTA# - INTH# */
28  [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
29  /* Misc-nil,0,1,2, INT from Serial irq */
30  [0x08] = 0x00,0xF0,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
31  /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon */
32  [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F,
33  /* IMC INT0 - 5 */
34  [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
35  /* USB Devs 18/19/20/22 INTA-C */
36  [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
37  /* IDE, SATA */
38  [0x40] = 0x0B,0x0B,
39  /* GPPInt0 - 3 */
40  [0x50] = 0x0A,0x0B,0x0A,0x0B
41 };
42 
44  /* INTA# - INTH# */
45  [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
46  /* Misc-nil,0,1,2, INT from Serial irq */
47  [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,
48  /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon */
49  [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F,
50  /* IMC INT0 - 5 */
51  [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
52  /* USB Devs 18/19/22/20 INTA-C */
53  [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12,
54  /* IDE, SATA */
55  [0x40] = 0x11,0x13,
56  /* GPPInt0 - 3 */
57  [0x50] = 0x10,0x11,0x12,0x13
58 };
59 
60 /*
61  * This table defines the index into the picr/intr_data
62  * tables for each device. Any enabled device and slot
63  * that uses hardware interrupts should have an entry
64  * in this table to define its index into the FCH
65  * PCI_INTR register 0xC00/0xC01. This index will define
66  * the interrupt that it should use. Putting PIRQ_A into
67  * the PIN A index for a device will tell that device to
68  * use PIC IRQ 10 if it uses PIN A for its hardware INT.
69  */
70 /*
71  * Persimmon has PCI slot INTA/B/C/D connected to PIRQE/F/G/H
72  * but because PCI INT_PIN swizzling isn't implemented to match
73  * the IDSEL (dev 3) of the slot, the table is adjusted for the
74  * swizzle and INTA is connected to PIRQH so PINA/B/C/D on
75  * off-chip devices should get mapped to PIRQH/E/F/G.
76  */
77 static const struct pirq_struct mainboard_pirq_data[] = {
78  /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */
79  {GFX_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */
80  {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 04.0 */
81  {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* PCIe bdg: 06.0 */
82  {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */
83  {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */
84  {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */
85  {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */
86  {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */
87  {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */
88  {IDE_DEVFN, {PIRQ_NC, PIRQ_IDE, PIRQ_NC, PIRQ_NC}}, /* IDE: 14.1 */
89  {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */
90  {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCI bdg: 14.4 */
91  {OHCI4_DEVFN, {PIRQ_NC, PIRQ_NC, PIRQ_OHCI4, PIRQ_NC}}, /* OHCI4: 14.5 */
92  {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */
93  {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */
94 };
95 
96 /* PIRQ Setup */
97 static void pirq_setup(void)
98 {
103 }
104 
105 /**********************************************
106  * Enable the dedicated functions of the board.
107  **********************************************/
108 static void mainboard_enable(struct device *dev)
109 {
110  /* enable GPP CLK0 thru CLK1 */
111  /* disable GPP CLK2 thru SLT_GFX_CLK */
112  misc_write8(0, 0xff);
113  misc_write8(1, 0);
114  misc_write8(2, 0);
115  misc_write8(3, 0);
116  misc_write8(4, 0);
117 
118  /*
119  * Initialize ASF registers to an arbitrary address because someone
120  * long ago set things up this way inside the SPD read code. The
121  * SPD read code has been made generic and moved out of the board
122  * directory, so the ASF init is being done here.
123  */
124  pm_write8(0x29, 0x80);
125  pm_write8(0x28, 0x61);
126 
127  /* Initialize the PIRQ data structures for consumption */
128  pirq_setup();
129 }
130 
133 };
struct chip_operations mainboard_ops
Definition: mainboard.c:19
@ PIRQ_A
Definition: acpi_pirq_gen.h:22
@ PIRQ_C
Definition: acpi_pirq_gen.h:24
@ PIRQ_G
Definition: acpi_pirq_gen.h:28
@ PIRQ_H
Definition: acpi_pirq_gen.h:29
@ PIRQ_E
Definition: acpi_pirq_gen.h:26
@ PIRQ_D
Definition: acpi_pirq_gen.h:25
@ PIRQ_F
Definition: acpi_pirq_gen.h:27
@ PIRQ_B
Definition: acpi_pirq_gen.h:23
static void pm_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:181
static void misc_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:271
static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE]
Definition: mainboard.c:26
static const struct pirq_struct mainboard_pirq_data[]
Definition: mainboard.c:77
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:108
static void pirq_setup(void)
Definition: mainboard.c:97
static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE]
Definition: mainboard.c:43
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define NB_PCIE_PORT3_DEVFN
Definition: pci_devs.h:35
#define NB_PCIE_PORT1_DEVFN
Definition: pci_devs.h:33
#define GFX_DEVFN
Definition: pci_devs.h:13
#define PIRQ_SATA
#define PIRQ_SMBUS
#define PIRQ_NC
#define SMBUS_DEVFN
Definition: pci_devs.h:117
u32 pirq_data_size
Definition: amd_pci_util.c:12
const u8 * intr_data_ptr
Definition: amd_pci_util.c:13
const u8 * picr_data_ptr
Definition: amd_pci_util.c:14
const struct pirq_struct * pirq_data_ptr
Definition: amd_pci_util.c:11
#define SATA_DEVFN
Definition: pci_devs.h:83
#define PIRQ_HDA
#define EHCI1_DEVFN
Definition: pci_devs.h:170
#define PIRQ_OHCI2
#define PIRQ_OHCI1
#define PIRQ_EHCI3
#define PIRQ_IDE
#define PIRQ_OHCI4
#define PIRQ_OHCI3
#define PIRQ_EHCI2
#define PIRQ_EHCI1
#define HDA_DEVFN
Definition: pci_devs.h:69
#define OHCI4_DEVFN
Definition: pci_devs.h:37
#define OHCI1_DEVFN
Definition: pci_devs.h:34
#define EHCI3_DEVFN
Definition: pci_devs.h:49
#define SB_PCI_PORT_DEVFN
Definition: pci_devs.h:82
#define OHCI3_DEVFN
Definition: pci_devs.h:36
#define EHCI2_DEVFN
Definition: pci_devs.h:48
#define OHCI2_DEVFN
Definition: pci_devs.h:35
#define FCH_INT_TABLE_SIZE
#define IDE_DEVFN
Definition: pci_devs.h:56
uint8_t u8
Definition: stdint.h:45
void(* enable_dev)(struct device *dev)
Definition: device.h:24
Definition: device.h:107