blob: 8625bd75f15d9f63b4c16b74281d727b83a02ad5 [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>
Jason Glenesk79542fa2021-03-10 03:50:57 -08007#include <soc/cpu.h>
Felix Heldea32c522021-02-13 01:42:44 +01008#include <soc/data_fabric.h>
Felix Held51c4d682021-02-16 23:14:42 +01009#include <soc/pci_devs.h>
Felix Held230dbd62021-01-28 23:40:52 +010010#include <soc/southbridge.h>
Felix Held86c24a22021-01-28 23:07:48 +010011#include <types.h>
Felix Heldc8272782020-12-05 01:39:28 +010012#include "chip.h"
Felix Helddc2d3562020-12-02 14:38:53 +010013
Raul E Rangel32fc4e32021-03-30 15:56:46 -060014/* Supplied by i2c.c */
15extern struct device_operations soc_amd_i2c_mmio_ops;
Felix Heldc3ce09c2021-02-10 16:25:53 +010016/* Supplied by uart.c */
17extern struct device_operations cezanne_uart_mmio_ops;
18
Felix Heldfd056012021-02-09 16:55:47 +010019struct device_operations cpu_bus_ops = {
Felix Heldb2d8a5c2021-02-10 16:17:13 +010020 .read_resources = noop_read_resources,
21 .set_resources = noop_set_resources,
22 .init = mp_cpu_bus_init,
Jason Glenesk79542fa2021-03-10 03:50:57 -080023 .acpi_fill_ssdt = generate_cpu_entries,
Felix Heldfd056012021-02-09 16:55:47 +010024};
25
Felix Held51c4d682021-02-16 23:14:42 +010026static const char *soc_acpi_name(const struct device *dev)
27{
28 if (dev->path.type == DEVICE_PATH_DOMAIN)
29 return "PCI0";
30
31 if (dev->path.type != DEVICE_PATH_PCI)
32 return NULL;
33
34 printk(BIOS_WARNING, "Unknown PCI device: dev: %d, fn: %d\n",
35 PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
36 return NULL;
37};
38
Felix Held5a7e4a52021-02-05 21:46:53 +010039static struct device_operations pci_domain_ops = {
40 .read_resources = pci_domain_read_resources,
41 .set_resources = pci_domain_set_resources,
42 .scan_bus = pci_domain_scan_bus,
Felix Held51c4d682021-02-16 23:14:42 +010043 .acpi_name = soc_acpi_name,
Felix Held5a7e4a52021-02-05 21:46:53 +010044};
45
Felix Heldc8a0faa2021-02-09 16:56:04 +010046static void set_mmio_dev_ops(struct device *dev)
47{
Felix Heldc3ce09c2021-02-10 16:25:53 +010048 switch (dev->path.mmio.addr) {
Raul E Rangel32fc4e32021-03-30 15:56:46 -060049 case APU_I2C0_BASE:
50 case APU_I2C1_BASE:
51 case APU_I2C2_BASE:
52 case APU_I2C3_BASE:
53 dev->ops = &soc_amd_i2c_mmio_ops;
54 break;
Felix Heldc3ce09c2021-02-10 16:25:53 +010055 case APU_UART0_BASE:
56 case APU_UART1_BASE:
57 dev->ops = &cezanne_uart_mmio_ops;
58 break;
59 }
Felix Heldc8a0faa2021-02-09 16:56:04 +010060}
61
Felix Held613f9fc2021-01-26 18:09:46 +010062static void enable_dev(struct device *dev)
63{
Felix Held5a7e4a52021-02-05 21:46:53 +010064 /* Set the operations if it is a special bus type */
65 switch (dev->path.type) {
66 case DEVICE_PATH_DOMAIN:
67 dev->ops = &pci_domain_ops;
68 break;
Felix Heldfd056012021-02-09 16:55:47 +010069 case DEVICE_PATH_CPU_CLUSTER:
70 dev->ops = &cpu_bus_ops;
71 break;
Felix Heldc8a0faa2021-02-09 16:56:04 +010072 case DEVICE_PATH_MMIO:
73 set_mmio_dev_ops(dev);
74 break;
Felix Held5a7e4a52021-02-05 21:46:53 +010075 default:
76 break;
77 }
Felix Held613f9fc2021-01-26 18:09:46 +010078}
79
80static void soc_init(void *chip_info)
81{
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +020082 fsp_silicon_init();
Felix Held230dbd62021-01-28 23:40:52 +010083
Felix Heldea32c522021-02-13 01:42:44 +010084 data_fabric_set_mmio_np();
85
Felix Held230dbd62021-01-28 23:40:52 +010086 fch_init(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010087}
88
89static void soc_final(void *chip_info)
90{
Felix Held230dbd62021-01-28 23:40:52 +010091 fch_final(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010092}
93
94struct chip_operations soc_amd_cezanne_ops = {
95 CHIP_NAME("AMD Cezanne SoC")
96 .enable_dev = enable_dev,
97 .init = soc_init,
98 .final = soc_final
99};