Felix Held | 80434a6 | 2023-12-13 23:11:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/acpi.h> |
| 4 | #include <amdblocks/acpimmio.h> |
| 5 | #include <amdblocks/amd_pci_util.h> |
| 6 | #include <amdblocks/gpio.h> |
| 7 | #include <amdblocks/smi.h> |
| 8 | #include <bootstate.h> |
| 9 | #include <cpu/x86/smm.h> |
| 10 | #include <soc/acpi.h> |
| 11 | #include <soc/amd_pci_int_defs.h> |
| 12 | #include <soc/smi.h> |
| 13 | #include <soc/southbridge.h> |
| 14 | |
| 15 | /* |
| 16 | * Table of APIC register index and associated IRQ name. Using IDX_XXX_NAME |
| 17 | * provides a visible association with the index, therefore helping |
| 18 | * maintainability of table. If a new index/name is defined in |
| 19 | * amd_pci_int_defs.h, just add the pair at the end of this table. |
| 20 | * Order is not important. |
| 21 | */ |
| 22 | static const struct irq_idx_name irq_association[] = { |
| 23 | { PIRQ_A, "INTA#" }, |
| 24 | { PIRQ_B, "INTB#" }, |
| 25 | { PIRQ_C, "INTC#" }, |
| 26 | { PIRQ_D, "INTD#" }, |
| 27 | { PIRQ_E, "INTE#" }, |
| 28 | { PIRQ_F, "INTF#/GENINT2" }, |
| 29 | { PIRQ_G, "INTG#" }, |
| 30 | { PIRQ_H, "INTH#" }, |
| 31 | { PIRQ_MISC, "Misc" }, |
| 32 | { PIRQ_MISC0, "Misc0" }, |
| 33 | { PIRQ_HPET_L, "HPET_L" }, |
| 34 | { PIRQ_HPET_H, "HPET_H" }, |
| 35 | { PIRQ_SIRQA, "Ser IRQ INTA" }, |
| 36 | { PIRQ_SIRQB, "Ser IRQ INTB" }, |
| 37 | { PIRQ_SIRQC, "Ser IRQ INTC" }, |
| 38 | { PIRQ_SIRQD, "Ser IRQ INTD" }, |
| 39 | { PIRQ_SCI, "SCI" }, |
| 40 | { PIRQ_SMBUS, "SMBUS" }, |
| 41 | { PIRQ_ASF, "ASF" }, |
| 42 | { PIRQ_PMON, "PerMon" }, |
| 43 | { PIRQ_SDIO, "SDIO" }, |
| 44 | { PIRQ_GPP0, "GPP0" }, |
| 45 | { PIRQ_GPP1, "GPP1" }, |
| 46 | { PIRQ_GPP2, "GPP2" }, |
| 47 | { PIRQ_GPP3, "GPP3" }, |
| 48 | { PIRQ_GSCI, "GEvent SCI" }, |
| 49 | { PIRQ_GSMI, "GEvent SMI" }, |
| 50 | { PIRQ_GPIO, "GPIO" }, |
| 51 | { PIRQ_I2C0, "I2C0" }, |
| 52 | { PIRQ_I2C1, "I2C1" }, |
| 53 | { PIRQ_I2C2, "I2C2" }, |
| 54 | { PIRQ_I2C3, "I2C3" }, |
| 55 | { PIRQ_UART0, "UART0" }, |
| 56 | { PIRQ_UART1, "UART1" }, |
| 57 | { PIRQ_I2C4, "I2C4" }, |
| 58 | { PIRQ_I2C5, "I2C5" }, |
| 59 | { PIRQ_UART2, "UART2" }, |
| 60 | { PIRQ_UART3, "UART3" }, |
| 61 | }; |
| 62 | |
| 63 | const struct irq_idx_name *sb_get_apic_reg_association(size_t *size) |
| 64 | { |
| 65 | *size = ARRAY_SIZE(irq_association); |
| 66 | return irq_association; |
| 67 | } |
| 68 | |
| 69 | static void set_pci_irqs(void) |
| 70 | { |
| 71 | /* Write PCI_INTR regs 0xC00/0xC01 */ |
| 72 | write_pci_int_table(); |
| 73 | |
| 74 | /* TODO: PIRQ configuration */ |
| 75 | } |
| 76 | |
Felix Held | f0c6712 | 2023-12-14 18:52:40 +0100 | [diff] [blame] | 77 | static void fch_init_acpi_ports(void) |
| 78 | { |
| 79 | /* Configure and enable APMC SMI Command Port */ |
| 80 | pm_write16(PM_ACPI_SMI_CMD, APM_CNT); |
| 81 | configure_smi(SMITYPE_SMI_CMD_PORT, SMI_MODE_SMI); |
| 82 | } |
| 83 | |
Felix Held | 80434a6 | 2023-12-13 23:11:45 +0100 | [diff] [blame] | 84 | static void fch_init(void *unused) |
| 85 | { |
| 86 | set_pci_irqs(); |
Felix Held | f0c6712 | 2023-12-14 18:52:40 +0100 | [diff] [blame] | 87 | fch_init_acpi_ports(); |
Felix Held | 80434a6 | 2023-12-13 23:11:45 +0100 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /* |
| 91 | * Hook this function into the PCI state machine on entry into BS_DEV_ENABLE. |
| 92 | * TODO: can this be done without using BOOT_STATE_INIT_ENTRY? |
| 93 | */ |
| 94 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fch_init, NULL); |