Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 2 | |
Furquan Shaikh | 5df9a04 | 2020-04-15 22:52:35 -0700 | [diff] [blame] | 3 | #include <console/console.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <drivers/i2c/designware/dw_i2c.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 7 | #include <soc/acpi.h> |
| 8 | #include <soc/cpu.h> |
Raul E Rangel | 789aefc | 2020-05-11 16:26:35 -0600 | [diff] [blame] | 9 | #include <soc/data_fabric.h> |
Furquan Shaikh | 4663749 | 2020-06-03 16:22:20 -0700 | [diff] [blame] | 10 | #include <soc/iomap.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 11 | #include <soc/pci_devs.h> |
| 12 | #include <soc/southbridge.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 13 | #include "chip.h" |
Marshall Dawson | 00a2208 | 2020-01-20 23:05:31 -0700 | [diff] [blame] | 14 | #include <fsp/api.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 15 | |
| 16 | /* Supplied by i2c.c */ |
Karthikeyan Ramasubramanian | 4f87ae1 | 2021-03-18 23:16:29 -0600 | [diff] [blame] | 17 | extern struct device_operations soc_amd_i2c_mmio_ops; |
Furquan Shaikh | b07e262 | 2020-06-03 16:50:32 -0700 | [diff] [blame] | 18 | /* Supplied by uart.c */ |
| 19 | extern struct device_operations picasso_uart_mmio_ops; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 20 | |
| 21 | struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 22 | .read_resources = noop_read_resources, |
| 23 | .set_resources = noop_set_resources, |
Kyösti Mälkki | 79e12ab | 2020-05-31 09:21:07 +0300 | [diff] [blame] | 24 | .init = mp_cpu_bus_init, |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 25 | .acpi_fill_ssdt = generate_cpu_entries, |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 26 | }; |
| 27 | |
Felix Held | 61e60d1 | 2021-02-16 23:23:00 +0100 | [diff] [blame] | 28 | static const char *soc_acpi_name(const struct device *dev) |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 29 | { |
| 30 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 31 | return "PCI0"; |
| 32 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 33 | if (dev->path.type != DEVICE_PATH_PCI) |
| 34 | return NULL; |
| 35 | |
Furquan Shaikh | 5df9a04 | 2020-04-15 22:52:35 -0700 | [diff] [blame] | 36 | printk(BIOS_WARNING, "Unknown PCI device: dev: %d, fn: %d\n", |
| 37 | PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn)); |
| 38 | return NULL; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 39 | }; |
| 40 | |
Felix Held | 0f058f6 | 2020-12-05 01:29:38 +0100 | [diff] [blame] | 41 | static struct device_operations pci_domain_ops = { |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 42 | .read_resources = pci_domain_read_resources, |
Raul E Rangel | 5cb34e2 | 2020-05-04 16:41:22 -0600 | [diff] [blame] | 43 | .set_resources = pci_domain_set_resources, |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 44 | .scan_bus = pci_domain_scan_bus, |
| 45 | .acpi_name = soc_acpi_name, |
| 46 | }; |
| 47 | |
Furquan Shaikh | 4663749 | 2020-06-03 16:22:20 -0700 | [diff] [blame] | 48 | static void set_mmio_dev_ops(struct device *dev) |
| 49 | { |
| 50 | switch (dev->path.mmio.addr) { |
| 51 | case APU_I2C2_BASE: |
| 52 | case APU_I2C3_BASE: |
| 53 | case APU_I2C4_BASE: |
Karthikeyan Ramasubramanian | 4f87ae1 | 2021-03-18 23:16:29 -0600 | [diff] [blame] | 54 | dev->ops = &soc_amd_i2c_mmio_ops; |
Furquan Shaikh | 4663749 | 2020-06-03 16:22:20 -0700 | [diff] [blame] | 55 | break; |
Furquan Shaikh | b07e262 | 2020-06-03 16:50:32 -0700 | [diff] [blame] | 56 | case APU_UART0_BASE: |
| 57 | case APU_UART1_BASE: |
| 58 | case APU_UART2_BASE: |
| 59 | case APU_UART3_BASE: |
| 60 | dev->ops = &picasso_uart_mmio_ops; |
| 61 | break; |
Furquan Shaikh | 4663749 | 2020-06-03 16:22:20 -0700 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 65 | static void enable_dev(struct device *dev) |
| 66 | { |
| 67 | /* Set the operations if it is a special bus type */ |
Felix Held | cbd5bb9 | 2021-01-26 18:05:21 +0100 | [diff] [blame] | 68 | switch (dev->path.type) { |
| 69 | case DEVICE_PATH_DOMAIN: |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 70 | dev->ops = &pci_domain_ops; |
Felix Held | cbd5bb9 | 2021-01-26 18:05:21 +0100 | [diff] [blame] | 71 | break; |
| 72 | case DEVICE_PATH_CPU_CLUSTER: |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 73 | dev->ops = &cpu_bus_ops; |
Felix Held | cbd5bb9 | 2021-01-26 18:05:21 +0100 | [diff] [blame] | 74 | break; |
| 75 | case DEVICE_PATH_MMIO: |
Furquan Shaikh | 4663749 | 2020-06-03 16:22:20 -0700 | [diff] [blame] | 76 | set_mmio_dev_ops(dev); |
Felix Held | cbd5bb9 | 2021-01-26 18:05:21 +0100 | [diff] [blame] | 77 | break; |
| 78 | default: |
| 79 | break; |
Raul E Rangel | 6de79b9 | 2020-05-19 16:13:06 -0600 | [diff] [blame] | 80 | } |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | static void soc_init(void *chip_info) |
| 84 | { |
Matt Papageorge | a21eae0 | 2019-11-13 17:00:12 -0600 | [diff] [blame] | 85 | default_dev_ops_root.write_acpi_tables = agesa_write_acpi_tables; |
| 86 | |
Kyösti Mälkki | cc93c6e | 2021-01-09 22:53:52 +0200 | [diff] [blame] | 87 | fsp_silicon_init(); |
Marshall Dawson | 00a2208 | 2020-01-20 23:05:31 -0700 | [diff] [blame] | 88 | |
Raul E Rangel | 789aefc | 2020-05-11 16:26:35 -0600 | [diff] [blame] | 89 | data_fabric_set_mmio_np(); |
Felix Held | faaafb4 | 2021-01-28 23:19:40 +0100 | [diff] [blame] | 90 | fch_init(chip_info); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | static void soc_final(void *chip_info) |
| 94 | { |
Felix Held | faaafb4 | 2021-01-28 23:19:40 +0100 | [diff] [blame] | 95 | fch_final(chip_info); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 96 | } |
| 97 | |
Marshall Dawson | bc4c903 | 2019-06-11 12:18:20 -0600 | [diff] [blame] | 98 | struct chip_operations soc_amd_picasso_ops = { |
| 99 | CHIP_NAME("AMD Picasso SOC") |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 100 | .enable_dev = enable_dev, |
| 101 | .init = soc_init, |
| 102 | .final = soc_final |
| 103 | }; |