blob: 625f46ce8eeee6999532f3daa58a6567973c068d [file] [log] [blame]
Felix Helddc2d3562020-12-02 14:38:53 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Felix Held51c4d682021-02-16 23:14:42 +01003#include <console/console.h>
Felix Helddc2d3562020-12-02 14:38:53 +01004#include <device/device.h>
Felix Held51c4d682021-02-16 23:14:42 +01005#include <device/pci.h>
Felix Held86c24a22021-01-28 23:07:48 +01006#include <fsp/api.h>
Felix Held144c7aa2021-05-04 21:06:04 +02007#include <soc/acpi.h>
Jason Glenesk79542fa2021-03-10 03:50:57 -08008#include <soc/cpu.h>
Felix Heldea32c522021-02-13 01:42:44 +01009#include <soc/data_fabric.h>
Felix Held51c4d682021-02-16 23:14:42 +010010#include <soc/pci_devs.h>
Felix Held230dbd62021-01-28 23:40:52 +010011#include <soc/southbridge.h>
Felix Held86c24a22021-01-28 23:07:48 +010012#include <types.h>
Felix Heldc8272782020-12-05 01:39:28 +010013#include "chip.h"
Felix Helddc2d3562020-12-02 14:38:53 +010014
Raul E Rangel32fc4e32021-03-30 15:56:46 -060015/* Supplied by i2c.c */
16extern struct device_operations soc_amd_i2c_mmio_ops;
Felix Heldc3ce09c2021-02-10 16:25:53 +010017/* Supplied by uart.c */
18extern struct device_operations cezanne_uart_mmio_ops;
19
Felix Heldfd056012021-02-09 16:55:47 +010020struct device_operations cpu_bus_ops = {
Felix Heldb2d8a5c2021-02-10 16:17:13 +010021 .read_resources = noop_read_resources,
22 .set_resources = noop_set_resources,
23 .init = mp_cpu_bus_init,
Jason Glenesk79542fa2021-03-10 03:50:57 -080024 .acpi_fill_ssdt = generate_cpu_entries,
Felix Heldfd056012021-02-09 16:55:47 +010025};
26
Felix Held51c4d682021-02-16 23:14:42 +010027static const char *soc_acpi_name(const struct device *dev)
28{
29 if (dev->path.type == DEVICE_PATH_DOMAIN)
30 return "PCI0";
31
32 if (dev->path.type != DEVICE_PATH_PCI)
33 return NULL;
34
35 printk(BIOS_WARNING, "Unknown PCI device: dev: %d, fn: %d\n",
36 PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
37 return NULL;
38};
39
Felix Held5a7e4a52021-02-05 21:46:53 +010040static struct device_operations pci_domain_ops = {
41 .read_resources = pci_domain_read_resources,
42 .set_resources = pci_domain_set_resources,
43 .scan_bus = pci_domain_scan_bus,
Felix Held51c4d682021-02-16 23:14:42 +010044 .acpi_name = soc_acpi_name,
Felix Held5a7e4a52021-02-05 21:46:53 +010045};
46
Felix Heldc8a0faa2021-02-09 16:56:04 +010047static void set_mmio_dev_ops(struct device *dev)
48{
Felix Heldc3ce09c2021-02-10 16:25:53 +010049 switch (dev->path.mmio.addr) {
Raul E Rangel32fc4e32021-03-30 15:56:46 -060050 case APU_I2C0_BASE:
51 case APU_I2C1_BASE:
52 case APU_I2C2_BASE:
53 case APU_I2C3_BASE:
54 dev->ops = &soc_amd_i2c_mmio_ops;
55 break;
Felix Heldc3ce09c2021-02-10 16:25:53 +010056 case APU_UART0_BASE:
57 case APU_UART1_BASE:
58 dev->ops = &cezanne_uart_mmio_ops;
59 break;
60 }
Felix Heldc8a0faa2021-02-09 16:56:04 +010061}
62
Felix Held613f9fc2021-01-26 18:09:46 +010063static void enable_dev(struct device *dev)
64{
Felix Held5a7e4a52021-02-05 21:46:53 +010065 /* Set the operations if it is a special bus type */
66 switch (dev->path.type) {
67 case DEVICE_PATH_DOMAIN:
68 dev->ops = &pci_domain_ops;
69 break;
Felix Heldfd056012021-02-09 16:55:47 +010070 case DEVICE_PATH_CPU_CLUSTER:
71 dev->ops = &cpu_bus_ops;
72 break;
Felix Heldc8a0faa2021-02-09 16:56:04 +010073 case DEVICE_PATH_MMIO:
74 set_mmio_dev_ops(dev);
75 break;
Felix Held5a7e4a52021-02-05 21:46:53 +010076 default:
77 break;
78 }
Felix Held613f9fc2021-01-26 18:09:46 +010079}
80
81static void soc_init(void *chip_info)
82{
Felix Held144c7aa2021-05-04 21:06:04 +020083 default_dev_ops_root.write_acpi_tables = agesa_write_acpi_tables;
84
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +020085 fsp_silicon_init();
Felix Held230dbd62021-01-28 23:40:52 +010086
Felix Heldea32c522021-02-13 01:42:44 +010087 data_fabric_set_mmio_np();
88
Felix Held230dbd62021-01-28 23:40:52 +010089 fch_init(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010090}
91
92static void soc_final(void *chip_info)
93{
Felix Held230dbd62021-01-28 23:40:52 +010094 fch_final(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010095}
96
97struct chip_operations soc_amd_cezanne_ops = {
98 CHIP_NAME("AMD Cezanne SoC")
99 .enable_dev = enable_dev,
100 .init = soc_init,
101 .final = soc_final
102};