Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Felix Held | 0079200 | 2024-01-26 14:41:14 +0100 | [diff] [blame^] | 3 | #include <amdblocks/acpi.h> |
Jon Murphy | 3f62507 | 2022-04-18 13:19:23 -0600 | [diff] [blame] | 4 | #include <amdblocks/acpimmio.h> |
Jon Murphy | 4f4f32b | 2022-02-17 20:33:49 -0700 | [diff] [blame] | 5 | #include <amdblocks/amd_pci_util.h> |
Mark Hasemeyer | 7d8f7fb | 2022-11-18 20:25:44 -0700 | [diff] [blame] | 6 | #include <amdblocks/psp.h> |
Robert Zieba | 6f8f482 | 2022-10-04 12:06:38 -0600 | [diff] [blame] | 7 | #include <amdblocks/xhci.h> |
Jon Murphy | 9042427 | 2022-02-16 06:34:39 -0700 | [diff] [blame] | 8 | #include <baseboard/variants.h> |
Jon Murphy | 9e00571 | 2022-02-17 14:48:55 -0700 | [diff] [blame] | 9 | #include <console/console.h> |
Robert Zieba | 6f8f482 | 2022-10-04 12:06:38 -0600 | [diff] [blame] | 10 | #include <cpu/x86/smm.h> |
Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 11 | #include <device/device.h> |
Mark Hasemeyer | 7d8f7fb | 2022-11-18 20:25:44 -0700 | [diff] [blame] | 12 | #include <drivers/i2c/tpm/chip.h> |
Jon Murphy | cbf0f98 | 2022-02-16 06:47:46 -0700 | [diff] [blame] | 13 | #include <variant/ec.h> |
Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 14 | |
Felix Held | cf92ecf | 2022-10-26 00:59:13 +0200 | [diff] [blame] | 15 | /* The IRQ mapping in fch_irq_map ends up getting written to the indirect address space that is |
| 16 | accessed via I/O ports 0xc00/0xc01. */ |
Jon Murphy | 4f4f32b | 2022-02-17 20:33:49 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * This controls the device -> IRQ routing. |
| 20 | * |
| 21 | * Hardcoded IRQs: |
| 22 | * 0: timer < soc/amd/common/acpi/lpc.asl |
| 23 | * 1: i8042 - Keyboard |
| 24 | * 2: cascade |
| 25 | * 8: rtc0 <- soc/amd/common/acpi/lpc.asl |
| 26 | * 9: acpi <- soc/amd/common/acpi/lpc.asl |
| 27 | */ |
| 28 | |
Felix Held | 067f703 | 2022-10-25 23:30:43 +0200 | [diff] [blame] | 29 | static const struct fch_irq_routing fch_irq_map[] = { |
Jon Murphy | 4f4f32b | 2022-02-17 20:33:49 -0700 | [diff] [blame] | 30 | { PIRQ_A, 12, PIRQ_NC }, |
| 31 | { PIRQ_B, 14, PIRQ_NC }, |
| 32 | { PIRQ_C, 15, PIRQ_NC }, |
| 33 | { PIRQ_D, 12, PIRQ_NC }, |
| 34 | { PIRQ_E, 14, PIRQ_NC }, |
| 35 | { PIRQ_F, 15, PIRQ_NC }, |
| 36 | { PIRQ_G, 12, PIRQ_NC }, |
| 37 | { PIRQ_H, 14, PIRQ_NC }, |
| 38 | |
| 39 | { PIRQ_SCI, ACPI_SCI_IRQ, ACPI_SCI_IRQ }, |
| 40 | { PIRQ_SD, PIRQ_NC, PIRQ_NC }, |
| 41 | { PIRQ_SDIO, PIRQ_NC, PIRQ_NC }, |
Jon Murphy | 4f4f32b | 2022-02-17 20:33:49 -0700 | [diff] [blame] | 42 | { PIRQ_GPIO, 11, 11 }, |
| 43 | { PIRQ_I2C0, 10, 10 }, |
| 44 | { PIRQ_I2C1, 7, 7 }, |
| 45 | { PIRQ_I2C2, 6, 6 }, |
| 46 | { PIRQ_I2C3, 5, 5 }, |
| 47 | { PIRQ_UART0, 4, 4 }, |
| 48 | { PIRQ_UART1, 3, 3 }, |
| 49 | |
| 50 | /* The MISC registers are not interrupt numbers */ |
| 51 | { PIRQ_MISC, 0xfa, 0x00 }, |
| 52 | { PIRQ_MISC0, 0x91, 0x00 }, |
| 53 | { PIRQ_HPET_L, 0x00, 0x00 }, |
| 54 | { PIRQ_HPET_H, 0x00, 0x00 }, |
| 55 | }; |
| 56 | |
Felix Held | cf92ecf | 2022-10-26 00:59:13 +0200 | [diff] [blame] | 57 | const struct fch_irq_routing *mb_get_fch_irq_mapping(size_t *length) |
Felix Held | df14a02 | 2022-10-25 23:42:15 +0200 | [diff] [blame] | 58 | { |
| 59 | *length = ARRAY_SIZE(fch_irq_map); |
| 60 | return fch_irq_map; |
| 61 | } |
| 62 | |
Jon Murphy | 9042427 | 2022-02-16 06:34:39 -0700 | [diff] [blame] | 63 | static void mainboard_configure_gpios(void) |
| 64 | { |
| 65 | size_t base_num_gpios, override_num_gpios; |
| 66 | const struct soc_amd_gpio *base_gpios, *override_gpios; |
| 67 | |
Matt DeVillier | 4236e2a | 2022-09-23 13:33:00 -0500 | [diff] [blame] | 68 | baseboard_gpio_table(&base_gpios, &base_num_gpios); |
Jon Murphy | 9042427 | 2022-02-16 06:34:39 -0700 | [diff] [blame] | 69 | variant_override_gpio_table(&override_gpios, &override_num_gpios); |
| 70 | |
| 71 | gpio_configure_pads_with_override(base_gpios, base_num_gpios, |
| 72 | override_gpios, override_num_gpios); |
| 73 | } |
| 74 | |
Mark Hasemeyer | 7d8f7fb | 2022-11-18 20:25:44 -0700 | [diff] [blame] | 75 | static void configure_psp_tpm_gpio(void) |
| 76 | { |
| 77 | const struct device *ti50_dev = DEV_PTR(ti50); |
| 78 | struct drivers_i2c_tpm_config *cfg = config_of(ti50_dev); |
| 79 | |
| 80 | psp_set_tpm_irq_gpio(cfg->irq_gpio.pins[0]); |
| 81 | } |
| 82 | |
Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 83 | static void mainboard_init(void *chip_info) |
| 84 | { |
Jon Murphy | 9042427 | 2022-02-16 06:34:39 -0700 | [diff] [blame] | 85 | mainboard_configure_gpios(); |
Jon Murphy | cbf0f98 | 2022-02-16 06:47:46 -0700 | [diff] [blame] | 86 | mainboard_ec_init(); |
Mark Hasemeyer | 7d8f7fb | 2022-11-18 20:25:44 -0700 | [diff] [blame] | 87 | configure_psp_tpm_gpio(); |
Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | static void mainboard_enable(struct device *dev) |
| 91 | { |
Jon Murphy | 3f62507 | 2022-04-18 13:19:23 -0600 | [diff] [blame] | 92 | /* TODO: b/184678786 - Move into espi_config */ |
| 93 | /* Unmask eSPI IRQ 1 (Keyboard) */ |
| 94 | pm_write32(PM_ESPI_INTR_CTRL, PM_ESPI_DEV_INTR_MASK & ~(BIT(1))); |
Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Robert Zieba | 6f8f482 | 2022-10-04 12:06:38 -0600 | [diff] [blame] | 97 | void smm_mainboard_pci_resource_store_init(struct smm_pci_resource_info *slots, size_t size) |
| 98 | { |
| 99 | soc_xhci_store_resources(slots, size); |
| 100 | } |
| 101 | |
Karthikeyan Ramasubramanian | a84d4f23 | 2022-02-02 10:10:03 -0700 | [diff] [blame] | 102 | struct chip_operations mainboard_ops = { |
| 103 | .init = mainboard_init, |
| 104 | .enable_dev = mainboard_enable, |
| 105 | }; |