blob: 261224326ee8a95b06539b35309e6d7db0637d29 [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 Heldea32c522021-02-13 01:42:44 +01007#include <soc/data_fabric.h>
Felix Held51c4d682021-02-16 23:14:42 +01008#include <soc/pci_devs.h>
Felix Held230dbd62021-01-28 23:40:52 +01009#include <soc/southbridge.h>
Felix Held86c24a22021-01-28 23:07:48 +010010#include <types.h>
Felix Heldc8272782020-12-05 01:39:28 +010011#include "chip.h"
Felix Helddc2d3562020-12-02 14:38:53 +010012
Felix Heldc3ce09c2021-02-10 16:25:53 +010013/* Supplied by uart.c */
14extern struct device_operations cezanne_uart_mmio_ops;
15
Felix Heldfd056012021-02-09 16:55:47 +010016struct device_operations cpu_bus_ops = {
Felix Heldb2d8a5c2021-02-10 16:17:13 +010017 .read_resources = noop_read_resources,
18 .set_resources = noop_set_resources,
19 .init = mp_cpu_bus_init,
Felix Heldfd056012021-02-09 16:55:47 +010020};
21
Felix Held51c4d682021-02-16 23:14:42 +010022static const char *soc_acpi_name(const struct device *dev)
23{
24 if (dev->path.type == DEVICE_PATH_DOMAIN)
25 return "PCI0";
26
27 if (dev->path.type != DEVICE_PATH_PCI)
28 return NULL;
29
30 printk(BIOS_WARNING, "Unknown PCI device: dev: %d, fn: %d\n",
31 PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
32 return NULL;
33};
34
Felix Held5a7e4a52021-02-05 21:46:53 +010035static struct device_operations pci_domain_ops = {
36 .read_resources = pci_domain_read_resources,
37 .set_resources = pci_domain_set_resources,
38 .scan_bus = pci_domain_scan_bus,
Felix Held51c4d682021-02-16 23:14:42 +010039 .acpi_name = soc_acpi_name,
Felix Held5a7e4a52021-02-05 21:46:53 +010040};
41
Felix Heldc8a0faa2021-02-09 16:56:04 +010042static void set_mmio_dev_ops(struct device *dev)
43{
Felix Heldc3ce09c2021-02-10 16:25:53 +010044 switch (dev->path.mmio.addr) {
45 case APU_UART0_BASE:
46 case APU_UART1_BASE:
47 dev->ops = &cezanne_uart_mmio_ops;
48 break;
49 }
Felix Heldc8a0faa2021-02-09 16:56:04 +010050}
51
Felix Held613f9fc2021-01-26 18:09:46 +010052static void enable_dev(struct device *dev)
53{
Felix Held5a7e4a52021-02-05 21:46:53 +010054 /* Set the operations if it is a special bus type */
55 switch (dev->path.type) {
56 case DEVICE_PATH_DOMAIN:
57 dev->ops = &pci_domain_ops;
58 break;
Felix Heldfd056012021-02-09 16:55:47 +010059 case DEVICE_PATH_CPU_CLUSTER:
60 dev->ops = &cpu_bus_ops;
61 break;
Felix Heldc8a0faa2021-02-09 16:56:04 +010062 case DEVICE_PATH_MMIO:
63 set_mmio_dev_ops(dev);
64 break;
Felix Held5a7e4a52021-02-05 21:46:53 +010065 default:
66 break;
67 }
Felix Held613f9fc2021-01-26 18:09:46 +010068}
69
70static void soc_init(void *chip_info)
71{
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +020072 fsp_silicon_init();
Felix Held230dbd62021-01-28 23:40:52 +010073
Felix Heldea32c522021-02-13 01:42:44 +010074 data_fabric_set_mmio_np();
75
Felix Held230dbd62021-01-28 23:40:52 +010076 fch_init(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010077}
78
79static void soc_final(void *chip_info)
80{
Felix Held230dbd62021-01-28 23:40:52 +010081 fch_final(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010082}
83
84struct chip_operations soc_amd_cezanne_ops = {
85 CHIP_NAME("AMD Cezanne SoC")
86 .enable_dev = enable_dev,
87 .init = soc_init,
88 .final = soc_final
89};