blob: f4d5be964d61ead38c9d39635fd5b6f9ce7c2d9b [file] [log] [blame]
Angel Pons5c596802020-04-03 01:21:01 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Richard Spiegel31d04e62019-07-02 17:13:19 -07002
Felix Held00792002024-01-26 14:41:14 +01003#include <amdblocks/acpi.h>
Richard Spiegel31d04e62019-07-02 17:13:19 -07004#include <device/device.h>
Richard Spiegel31d04e62019-07-02 17:13:19 -07005#include <amdblocks/agesawrapper.h>
6#include <amdblocks/amd_pci_util.h>
Elyes Haouas9aebc192023-01-30 20:02:03 +01007#include <gpio.h>
Felix Heldb6b5af12023-02-27 21:15:16 +01008#include <soc/acpi.h>
Richard Spiegel31d04e62019-07-02 17:13:19 -07009#include <soc/pci_devs.h>
10#include <soc/southbridge.h>
11
12#include "gpio.h"
13
Felix Heldcf92ecf2022-10-26 00:59:13 +020014/* The IRQ mapping in fch_irq_map ends up getting written to the indirect address space that is
15 accessed via I/O ports 0xc00/0xc01. */
Felix Held9a1da4b2022-10-25 22:45:58 +020016static const struct fch_irq_routing fch_irq_map[] = {
17 { PIRQ_A, 3, 16 },
18 { PIRQ_B, 4, 17 },
19 { PIRQ_C, 5, 18 },
20 { PIRQ_D, 7, 19 },
21 { PIRQ_E, 11, 20 },
22 { PIRQ_F, 10, 21 },
23 { PIRQ_G, PIRQ_NC, 22 },
24 { PIRQ_H, PIRQ_NC, 23 },
Felix Heldb6b5af12023-02-27 21:15:16 +010025 { PIRQ_SCI, ACPI_SCI_IRQ, ACPI_SCI_IRQ },
Felix Held9a1da4b2022-10-25 22:45:58 +020026 { PIRQ_SMBUS, PIRQ_NC, PIRQ_NC },
27 { PIRQ_HDA, 3, 16 },
28 { PIRQ_SD, PIRQ_NC, 16 },
29 { PIRQ_SDIO, PIRQ_NC, PIRQ_NC },
30 { PIRQ_EHCI, 5, 18 },
31 { PIRQ_XHCI, 4, 18 },
32 { PIRQ_SATA, PIRQ_NC, 19 },
33 { PIRQ_GPIO, 7, 7 },
34 { PIRQ_I2C0, 3, 3 },
35 { PIRQ_I2C1, 15, 15 },
36 { PIRQ_I2C2, 6, 6 },
37 { PIRQ_I2C3, 14, 14 },
38 { PIRQ_UART0, 10, 10 },
39 { PIRQ_UART1, 11, 11 },
40
41 /* The MISC registers are not interrupt numbers */
42 { PIRQ_MISC, 0xfa, 0x00 },
43 { PIRQ_MISC0, 0xf1, 0x00 },
44 { PIRQ_MISC1, 0x00, 0x00 },
45 { PIRQ_MISC2, 0x00, 0x00 },
Richard Spiegel31d04e62019-07-02 17:13:19 -070046};
47
Felix Heldcf92ecf2022-10-26 00:59:13 +020048const struct fch_irq_routing *mb_get_fch_irq_mapping(size_t *length)
Felix Held9a1da4b2022-10-25 22:45:58 +020049{
50 *length = ARRAY_SIZE(fch_irq_map);
51 return fch_irq_map;
52}
53
Richard Spiegel31d04e62019-07-02 17:13:19 -070054/*
55 * This table defines the index into the picr/intr_data tables for each
56 * device. Any enabled device and slot that uses hardware interrupts should
57 * have an entry in this table to define its index into the FCH PCI_INTR
58 * register 0xC00/0xC01. This index will define the interrupt that it should
59 * use. Putting PIRQ_A into the PIN A index for a device will tell that
60 * device to use PIC IRQ 10 if it uses PIN A for its hardware INT.
61 */
62static const struct pirq_struct mainboard_pirq_data[] = {
63 { GFX_DEVFN, { PIRQ_A, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
64 { HDA0_DEVFN, { PIRQ_NC, PIRQ_HDA, PIRQ_NC, PIRQ_NC } },
65 { PCIE0_DEVFN, { PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D } },
66 { PCIE1_DEVFN, { PIRQ_B, PIRQ_C, PIRQ_D, PIRQ_A } },
67 { PCIE2_DEVFN, { PIRQ_C, PIRQ_D, PIRQ_A, PIRQ_B } },
68 { PCIE3_DEVFN, { PIRQ_D, PIRQ_A, PIRQ_B, PIRQ_C } },
69 { PCIE4_DEVFN, { PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D } },
70 { PSP_DEVFN, { PIRQ_A, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
71 { HDA1_DEVFN, { PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
72 { SD_DEVFN, { PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
73 { SMBUS_DEVFN, { PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
74 { SATA_DEVFN, { PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
75 { EHCI1_DEVFN, { PIRQ_EHCI, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
76 { XHCI_DEVFN, { PIRQ_XHCI, PIRQ_NC, PIRQ_NC, PIRQ_NC } },
77};
78
79/* PIRQ Setup */
80static void pirq_setup(void)
81{
82 pirq_data_ptr = mainboard_pirq_data;
83 pirq_data_size = ARRAY_SIZE(mainboard_pirq_data);
Richard Spiegel31d04e62019-07-02 17:13:19 -070084}
85
86static void mainboard_init(void *chip_info)
87{
88 size_t num_gpios;
89 const struct soc_amd_gpio *gpios;
90 gpios = gpio_table(&num_gpios);
Felix Held7011fa12021-09-22 16:36:12 +020091 gpio_configure_pads(gpios, num_gpios);
Richard Spiegel31d04e62019-07-02 17:13:19 -070092}
93
94/*************************************************
Felix Heldf0d62ce2022-10-14 17:48:22 +020095 * enable the dedicated function in pademelon board.
Richard Spiegel31d04e62019-07-02 17:13:19 -070096 *************************************************/
Kyösti Mälkki813b2f02021-02-22 06:03:08 +020097static void mainboard_enable(struct device *dev)
Richard Spiegel31d04e62019-07-02 17:13:19 -070098{
Richard Spiegel31d04e62019-07-02 17:13:19 -070099 /* Initialize the PIRQ data structures for consumption */
100 pirq_setup();
101}
102
103struct chip_operations mainboard_ops = {
104 .init = mainboard_init,
Kyösti Mälkki813b2f02021-02-22 06:03:08 +0200105 .enable_dev = mainboard_enable,
Richard Spiegel31d04e62019-07-02 17:13:19 -0700106};