Felix Held | dc2d356 | 2020-12-02 14:38:53 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <device/device.h> |
Felix Held | 86c24a2 | 2021-01-28 23:07:48 +0100 | [diff] [blame] | 4 | #include <fsp/api.h> |
Felix Held | ea32c52 | 2021-02-13 01:42:44 +0100 | [diff] [blame^] | 5 | #include <soc/data_fabric.h> |
Felix Held | 230dbd6 | 2021-01-28 23:40:52 +0100 | [diff] [blame] | 6 | #include <soc/southbridge.h> |
Felix Held | 86c24a2 | 2021-01-28 23:07:48 +0100 | [diff] [blame] | 7 | #include <types.h> |
Felix Held | c827278 | 2020-12-05 01:39:28 +0100 | [diff] [blame] | 8 | #include "chip.h" |
Felix Held | dc2d356 | 2020-12-02 14:38:53 +0100 | [diff] [blame] | 9 | |
Felix Held | c3ce09c | 2021-02-10 16:25:53 +0100 | [diff] [blame] | 10 | /* Supplied by uart.c */ |
| 11 | extern struct device_operations cezanne_uart_mmio_ops; |
| 12 | |
Felix Held | fd05601 | 2021-02-09 16:55:47 +0100 | [diff] [blame] | 13 | struct device_operations cpu_bus_ops = { |
Felix Held | b2d8a5c | 2021-02-10 16:17:13 +0100 | [diff] [blame] | 14 | .read_resources = noop_read_resources, |
| 15 | .set_resources = noop_set_resources, |
| 16 | .init = mp_cpu_bus_init, |
Felix Held | fd05601 | 2021-02-09 16:55:47 +0100 | [diff] [blame] | 17 | }; |
| 18 | |
Felix Held | 5a7e4a5 | 2021-02-05 21:46:53 +0100 | [diff] [blame] | 19 | static 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 Held | c8a0faa | 2021-02-09 16:56:04 +0100 | [diff] [blame] | 25 | static void set_mmio_dev_ops(struct device *dev) |
| 26 | { |
Felix Held | c3ce09c | 2021-02-10 16:25:53 +0100 | [diff] [blame] | 27 | 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 Held | c8a0faa | 2021-02-09 16:56:04 +0100 | [diff] [blame] | 33 | } |
| 34 | |
Felix Held | 613f9fc | 2021-01-26 18:09:46 +0100 | [diff] [blame] | 35 | static void enable_dev(struct device *dev) |
| 36 | { |
Felix Held | 5a7e4a5 | 2021-02-05 21:46:53 +0100 | [diff] [blame] | 37 | /* 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 Held | fd05601 | 2021-02-09 16:55:47 +0100 | [diff] [blame] | 42 | case DEVICE_PATH_CPU_CLUSTER: |
| 43 | dev->ops = &cpu_bus_ops; |
| 44 | break; |
Felix Held | c8a0faa | 2021-02-09 16:56:04 +0100 | [diff] [blame] | 45 | case DEVICE_PATH_MMIO: |
| 46 | set_mmio_dev_ops(dev); |
| 47 | break; |
Felix Held | 5a7e4a5 | 2021-02-05 21:46:53 +0100 | [diff] [blame] | 48 | default: |
| 49 | break; |
| 50 | } |
Felix Held | 613f9fc | 2021-01-26 18:09:46 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | static void soc_init(void *chip_info) |
| 54 | { |
Kyösti Mälkki | cc93c6e | 2021-01-09 22:53:52 +0200 | [diff] [blame] | 55 | fsp_silicon_init(); |
Felix Held | 230dbd6 | 2021-01-28 23:40:52 +0100 | [diff] [blame] | 56 | |
Felix Held | ea32c52 | 2021-02-13 01:42:44 +0100 | [diff] [blame^] | 57 | data_fabric_set_mmio_np(); |
| 58 | |
Felix Held | 230dbd6 | 2021-01-28 23:40:52 +0100 | [diff] [blame] | 59 | fch_init(chip_info); |
Felix Held | 613f9fc | 2021-01-26 18:09:46 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static void soc_final(void *chip_info) |
| 63 | { |
Felix Held | 230dbd6 | 2021-01-28 23:40:52 +0100 | [diff] [blame] | 64 | fch_final(chip_info); |
Felix Held | 613f9fc | 2021-01-26 18:09:46 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | struct 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 | }; |