blob: 57f658c8bdac1e48b39e874558b3e5d0da45da3b [file] [log] [blame]
Mathew King2e2fc7a2020-12-08 11:33:58 -07001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
Mathew King00b490d2021-03-12 15:48:32 -07003#include <amdblocks/amd_pci_util.h>
Mathew King10dd7752021-01-26 16:08:14 -07004#include <baseboard/variants.h>
Mathew King2e2fc7a2020-12-08 11:33:58 -07005#include <device/device.h>
Mathew King00b490d2021-03-12 15:48:32 -07006#include <soc/acpi.h>
Mathew Kingad830232021-02-23 13:08:15 -07007#include <variant/ec.h>
Mathew King5d478872021-02-16 14:05:15 -07008#include <vendorcode/google/chromeos/chromeos.h>
Mathew King2e2fc7a2020-12-08 11:33:58 -07009
Mathew King00b490d2021-03-12 15:48:32 -070010/*
11 * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01.
12 * This table is responsible for physically routing the PIC and
13 * IOAPIC IRQs to the different PCI devices on the system. It
14 * is read and written via registers 0xC00/0xC01 as an
15 * Index/Data pair. These values are chipset and mainboard
16 * dependent and should be updated accordingly.
17 */
18static uint8_t fch_pic_routing[0x80];
19static uint8_t fch_apic_routing[0x80];
20
21_Static_assert(sizeof(fch_pic_routing) == sizeof(fch_apic_routing),
22 "PIC and APIC FCH interrupt tables must be the same size");
23
24/*
25 * This controls the device -> IRQ routing.
26 *
27 * Hardcoded IRQs:
28 * 0: timer < soc/amd/common/acpi/lpc.asl
29 * 1: i8042 - Keyboard
30 * 2: cascade
31 * 8: rtc0 <- soc/amd/common/acpi/lpc.asl
32 * 9: acpi <- soc/amd/common/acpi/lpc.asl
33 */
34static const struct fch_irq_routing {
35 uint8_t intr_index;
36 uint8_t pic_irq_num;
37 uint8_t apic_irq_num;
38} guybrush_fch[] = {
39 { PIRQ_A, PIRQ_NC, PIRQ_NC },
40 { PIRQ_B, PIRQ_NC, PIRQ_NC },
41 { PIRQ_C, PIRQ_NC, PIRQ_NC },
42 { PIRQ_D, PIRQ_NC, PIRQ_NC },
43 { PIRQ_E, PIRQ_NC, PIRQ_NC },
44 { PIRQ_F, PIRQ_NC, PIRQ_NC },
45 { PIRQ_G, PIRQ_NC, PIRQ_NC },
46 { PIRQ_H, PIRQ_NC, PIRQ_NC },
47
48 { PIRQ_SCI, ACPI_SCI_IRQ, ACPI_SCI_IRQ },
49 { PIRQ_SD, PIRQ_NC, PIRQ_NC },
50 { PIRQ_SDIO, PIRQ_NC, PIRQ_NC },
51 { PIRQ_SATA, PIRQ_NC, PIRQ_NC },
52 { PIRQ_EMMC, PIRQ_NC, PIRQ_NC },
Raul E Rangelcce7d822021-03-30 15:50:43 -060053 { PIRQ_GPIO, 11, 11 },
54 { PIRQ_I2C0, 10, 10 },
55 { PIRQ_I2C1, 7, 7 },
56 { PIRQ_I2C2, 6, 6 },
57 { PIRQ_I2C3, 5, 5 },
Mathew King00b490d2021-03-12 15:48:32 -070058 { PIRQ_UART0, 4, 4 },
59 { PIRQ_UART1, 3, 3 },
60
61 /* The MISC registers are not interrupt numbers */
62 { PIRQ_MISC, 0xfa, 0x00 },
63 { PIRQ_MISC0, 0x91, 0x00 },
64 { PIRQ_HPET_L, 0x00, 0x00 },
65 { PIRQ_HPET_H, 0x00, 0x00 },
66};
67
68static void init_tables(void)
69{
70 const struct fch_irq_routing *entry;
71 int i;
72
73 memset(fch_pic_routing, PIRQ_NC, sizeof(fch_pic_routing));
74 memset(fch_apic_routing, PIRQ_NC, sizeof(fch_apic_routing));
75
76 for (i = 0; i < ARRAY_SIZE(guybrush_fch); i++) {
77 entry = guybrush_fch + i;
78 fch_pic_routing[entry->intr_index] = entry->pic_irq_num;
79 fch_apic_routing[entry->intr_index] = entry->apic_irq_num;
80 }
81}
82
83static void pirq_setup(void)
84{
85 intr_data_ptr = fch_apic_routing;
86 picr_data_ptr = fch_pic_routing;
87}
88
Mathew King10dd7752021-01-26 16:08:14 -070089static void mainboard_configure_gpios(void)
90{
91 size_t base_num_gpios, override_num_gpios;
92 const struct soc_amd_gpio *base_gpios, *override_gpios;
93
94 base_gpios = variant_base_gpio_table(&base_num_gpios);
95 override_gpios = variant_override_gpio_table(&override_num_gpios);
96
97 gpio_configure_pads_with_override(base_gpios, base_num_gpios, override_gpios,
98 override_num_gpios);
99}
100
Mathew King2e2fc7a2020-12-08 11:33:58 -0700101static void mainboard_init(void *chip_info)
102{
Mathew King10dd7752021-01-26 16:08:14 -0700103 mainboard_configure_gpios();
Mathew Kingad830232021-02-23 13:08:15 -0700104 mainboard_ec_init();
Mathew King2e2fc7a2020-12-08 11:33:58 -0700105}
106
107static void mainboard_enable(struct device *dev)
108{
Mathew King5d478872021-02-16 14:05:15 -0700109 printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n");
110
111 dev->ops->acpi_inject_dsdt = chromeos_dsdt_generator;
Mathew King00b490d2021-03-12 15:48:32 -0700112
113 init_tables();
114 /* Initialize the PIRQ data structures for consumption */
115 pirq_setup();
Mathew King2e2fc7a2020-12-08 11:33:58 -0700116}
117
118struct chip_operations mainboard_ops = {
119 .init = mainboard_init,
120 .enable_dev = mainboard_enable,
121};