blob: 78a4e33d7699751a8b971e147f55aa8e22a95d76 [file] [log] [blame]
Felix Helddc2d3562020-12-02 14:38:53 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <device/device.h>
Felix Held86c24a22021-01-28 23:07:48 +01004#include <fsp/api.h>
Felix Heldea32c522021-02-13 01:42:44 +01005#include <soc/data_fabric.h>
Felix Held230dbd62021-01-28 23:40:52 +01006#include <soc/southbridge.h>
Felix Held86c24a22021-01-28 23:07:48 +01007#include <types.h>
Felix Heldc8272782020-12-05 01:39:28 +01008#include "chip.h"
Felix Helddc2d3562020-12-02 14:38:53 +01009
Felix Heldc3ce09c2021-02-10 16:25:53 +010010/* Supplied by uart.c */
11extern struct device_operations cezanne_uart_mmio_ops;
12
Felix Heldfd056012021-02-09 16:55:47 +010013struct device_operations cpu_bus_ops = {
Felix Heldb2d8a5c2021-02-10 16:17:13 +010014 .read_resources = noop_read_resources,
15 .set_resources = noop_set_resources,
16 .init = mp_cpu_bus_init,
Felix Heldfd056012021-02-09 16:55:47 +010017};
18
Felix Held5a7e4a52021-02-05 21:46:53 +010019static struct device_operations pci_domain_ops = {
20 .read_resources = pci_domain_read_resources,
21 .set_resources = pci_domain_set_resources,
22 .scan_bus = pci_domain_scan_bus,
23};
24
Felix Heldc8a0faa2021-02-09 16:56:04 +010025static void set_mmio_dev_ops(struct device *dev)
26{
Felix Heldc3ce09c2021-02-10 16:25:53 +010027 switch (dev->path.mmio.addr) {
28 case APU_UART0_BASE:
29 case APU_UART1_BASE:
30 dev->ops = &cezanne_uart_mmio_ops;
31 break;
32 }
Felix Heldc8a0faa2021-02-09 16:56:04 +010033}
34
Felix Held613f9fc2021-01-26 18:09:46 +010035static void enable_dev(struct device *dev)
36{
Felix Held5a7e4a52021-02-05 21:46:53 +010037 /* Set the operations if it is a special bus type */
38 switch (dev->path.type) {
39 case DEVICE_PATH_DOMAIN:
40 dev->ops = &pci_domain_ops;
41 break;
Felix Heldfd056012021-02-09 16:55:47 +010042 case DEVICE_PATH_CPU_CLUSTER:
43 dev->ops = &cpu_bus_ops;
44 break;
Felix Heldc8a0faa2021-02-09 16:56:04 +010045 case DEVICE_PATH_MMIO:
46 set_mmio_dev_ops(dev);
47 break;
Felix Held5a7e4a52021-02-05 21:46:53 +010048 default:
49 break;
50 }
Felix Held613f9fc2021-01-26 18:09:46 +010051}
52
53static void soc_init(void *chip_info)
54{
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +020055 fsp_silicon_init();
Felix Held230dbd62021-01-28 23:40:52 +010056
Felix Heldea32c522021-02-13 01:42:44 +010057 data_fabric_set_mmio_np();
58
Felix Held230dbd62021-01-28 23:40:52 +010059 fch_init(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010060}
61
62static void soc_final(void *chip_info)
63{
Felix Held230dbd62021-01-28 23:40:52 +010064 fch_final(chip_info);
Felix Held613f9fc2021-01-26 18:09:46 +010065}
66
67struct chip_operations soc_amd_cezanne_ops = {
68 CHIP_NAME("AMD Cezanne SoC")
69 .enable_dev = enable_dev,
70 .init = soc_init,
71 .final = soc_final
72};