blob: 6a6c49e28ff82b3969c8e6e3d28a7ace559f9637 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5c354b92019-04-22 14:55:16 -06002
Furquan Shaikh5df9a042020-04-15 22:52:35 -07003#include <console/console.h>
Martin Roth5c354b92019-04-22 14:55:16 -06004#include <device/device.h>
5#include <device/pci.h>
6#include <drivers/i2c/designware/dw_i2c.h>
Martin Roth5c354b92019-04-22 14:55:16 -06007#include <soc/acpi.h>
8#include <soc/cpu.h>
Raul E Rangel789aefc2020-05-11 16:26:35 -06009#include <soc/data_fabric.h>
Furquan Shaikh46637492020-06-03 16:22:20 -070010#include <soc/iomap.h>
Martin Roth5c354b92019-04-22 14:55:16 -060011#include <soc/pci_devs.h>
12#include <soc/southbridge.h>
Martin Roth5c354b92019-04-22 14:55:16 -060013#include "chip.h"
Marshall Dawson00a22082020-01-20 23:05:31 -070014#include <fsp/api.h>
Martin Roth5c354b92019-04-22 14:55:16 -060015
16/* Supplied by i2c.c */
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060017extern struct device_operations soc_amd_i2c_mmio_ops;
Furquan Shaikhb07e2622020-06-03 16:50:32 -070018/* Supplied by uart.c */
19extern struct device_operations picasso_uart_mmio_ops;
Martin Roth5c354b92019-04-22 14:55:16 -060020
21struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020022 .read_resources = noop_read_resources,
23 .set_resources = noop_set_resources,
Kyösti Mälkki79e12ab2020-05-31 09:21:07 +030024 .init = mp_cpu_bus_init,
Nico Huber68680dd2020-03-31 17:34:52 +020025 .acpi_fill_ssdt = generate_cpu_entries,
Martin Roth5c354b92019-04-22 14:55:16 -060026};
27
Felix Held61e60d12021-02-16 23:23:00 +010028static const char *soc_acpi_name(const struct device *dev)
Martin Roth5c354b92019-04-22 14:55:16 -060029{
30 if (dev->path.type == DEVICE_PATH_DOMAIN)
31 return "PCI0";
32
Martin Roth5c354b92019-04-22 14:55:16 -060033 if (dev->path.type != DEVICE_PATH_PCI)
34 return NULL;
35
Furquan Shaikh5df9a042020-04-15 22:52:35 -070036 printk(BIOS_WARNING, "Unknown PCI device: dev: %d, fn: %d\n",
37 PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
38 return NULL;
Martin Roth5c354b92019-04-22 14:55:16 -060039};
40
Felix Held0f058f62020-12-05 01:29:38 +010041static struct device_operations pci_domain_ops = {
Martin Roth5c354b92019-04-22 14:55:16 -060042 .read_resources = pci_domain_read_resources,
Raul E Rangel5cb34e22020-05-04 16:41:22 -060043 .set_resources = pci_domain_set_resources,
Martin Roth5c354b92019-04-22 14:55:16 -060044 .scan_bus = pci_domain_scan_bus,
45 .acpi_name = soc_acpi_name,
46};
47
Furquan Shaikh46637492020-06-03 16:22:20 -070048static void set_mmio_dev_ops(struct device *dev)
49{
50 switch (dev->path.mmio.addr) {
51 case APU_I2C2_BASE:
52 case APU_I2C3_BASE:
53 case APU_I2C4_BASE:
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060054 dev->ops = &soc_amd_i2c_mmio_ops;
Furquan Shaikh46637492020-06-03 16:22:20 -070055 break;
Furquan Shaikhb07e2622020-06-03 16:50:32 -070056 case APU_UART0_BASE:
57 case APU_UART1_BASE:
58 case APU_UART2_BASE:
59 case APU_UART3_BASE:
60 dev->ops = &picasso_uart_mmio_ops;
61 break;
Furquan Shaikh46637492020-06-03 16:22:20 -070062 }
63}
64
Martin Roth5c354b92019-04-22 14:55:16 -060065static void enable_dev(struct device *dev)
66{
67 /* Set the operations if it is a special bus type */
Felix Heldcbd5bb92021-01-26 18:05:21 +010068 switch (dev->path.type) {
69 case DEVICE_PATH_DOMAIN:
Martin Roth5c354b92019-04-22 14:55:16 -060070 dev->ops = &pci_domain_ops;
Felix Heldcbd5bb92021-01-26 18:05:21 +010071 break;
72 case DEVICE_PATH_CPU_CLUSTER:
Martin Roth5c354b92019-04-22 14:55:16 -060073 dev->ops = &cpu_bus_ops;
Felix Heldcbd5bb92021-01-26 18:05:21 +010074 break;
75 case DEVICE_PATH_MMIO:
Furquan Shaikh46637492020-06-03 16:22:20 -070076 set_mmio_dev_ops(dev);
Felix Heldcbd5bb92021-01-26 18:05:21 +010077 break;
78 default:
79 break;
Raul E Rangel6de79b92020-05-19 16:13:06 -060080 }
Martin Roth5c354b92019-04-22 14:55:16 -060081}
82
83static void soc_init(void *chip_info)
84{
Matt Papageorgea21eae02019-11-13 17:00:12 -060085 default_dev_ops_root.write_acpi_tables = agesa_write_acpi_tables;
86
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +020087 fsp_silicon_init();
Marshall Dawson00a22082020-01-20 23:05:31 -070088
Raul E Rangel789aefc2020-05-11 16:26:35 -060089 data_fabric_set_mmio_np();
Felix Heldfaaafb42021-01-28 23:19:40 +010090 fch_init(chip_info);
Martin Roth5c354b92019-04-22 14:55:16 -060091}
92
93static void soc_final(void *chip_info)
94{
Felix Heldfaaafb42021-01-28 23:19:40 +010095 fch_final(chip_info);
Martin Roth5c354b92019-04-22 14:55:16 -060096}
97
Marshall Dawsonbc4c9032019-06-11 12:18:20 -060098struct chip_operations soc_amd_picasso_ops = {
99 CHIP_NAME("AMD Picasso SOC")
Martin Roth5c354b92019-04-22 14:55:16 -0600100 .enable_dev = enable_dev,
101 .init = soc_init,
102 .final = soc_final
103};