blob: 1633ecddae7be51d541545d5e451acc8d9ca4770 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marc Jones1587dc82017-05-15 18:55:11 -06002
Marshall Dawson9db8a442017-09-20 10:24:28 -06003#include <bootstate.h>
4#include <console/console.h>
Marc Jones1587dc82017-05-15 18:55:11 -06005#include <cpu/amd/mtrr.h>
Marc Jones24484842017-05-04 21:17:45 -06006#include <device/device.h>
7#include <device/pci.h>
Justin TerAvest13101a72018-01-24 14:23:12 -07008#include <drivers/i2c/designware/dw_i2c.h>
Duncan Laurie32bdffa2018-05-07 15:37:28 -07009#include <soc/acpi.h>
Marshall Dawsona7bfbbe2017-09-13 17:24:53 -060010#include <soc/cpu.h>
Marc Jones1587dc82017-05-15 18:55:11 -060011#include <soc/northbridge.h>
Justin TerAvest949d6662018-01-24 14:20:03 -070012#include <soc/pci_devs.h>
Marshall Dawsona7bfbbe2017-09-13 17:24:53 -060013#include <soc/southbridge.h>
Marshall Dawsonf5e057c2017-10-12 16:10:14 -060014#include <amdblocks/psp.h>
Richard Spiegel0ad74ac2017-12-08 16:53:29 -070015#include <amdblocks/agesawrapper.h>
16#include <amdblocks/agesawrapper_call.h>
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060017#include <amdblocks/i2c.h>
Marc Jones24484842017-05-04 21:17:45 -060018
Elyes HAOUASc3385072019-03-21 15:38:06 +010019#include "chip.h"
20
Felix Helda11b4722022-10-13 16:32:23 +020021struct device_operations stoneyridge_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,
Marc Jones24484842017-05-04 21:17:45 -060026};
27
Duncan Laurie32bdffa2018-05-07 15:37:28 -070028const char *soc_acpi_name(const struct device *dev)
Justin TerAvest949d6662018-01-24 14:20:03 -070029{
30 if (dev->path.type == DEVICE_PATH_DOMAIN)
31 return "PCI0";
Duncan Laurie32bdffa2018-05-07 15:37:28 -070032
33 if (dev->path.type == DEVICE_PATH_USB) {
34 switch (dev->path.usb.port_type) {
35 case 0:
36 /* Root Hub */
37 return "RHUB";
38 case 2:
39 /* USB2 ports */
40 switch (dev->path.usb.port_id) {
41 case 0: return "HS01";
42 case 1: return "HS02";
43 case 2: return "HS03";
44 case 3: return "HS04";
45 case 4: return "HS05";
46 case 5: return "HS06";
47 case 6: return "HS07";
48 case 7: return "HS08";
49 }
50 break;
51 case 3:
52 /* USB3 ports */
53 switch (dev->path.usb.port_id) {
54 case 0: return "SS01";
55 case 1: return "SS02";
56 case 2: return "SS03";
57 }
58 break;
59 }
60 return NULL;
61 }
62
Justin TerAvest949d6662018-01-24 14:20:03 -070063 if (dev->path.type != DEVICE_PATH_PCI)
64 return NULL;
65
66 switch (dev->path.pci.devfn) {
Marc Jones6dcb6c22018-07-26 17:07:13 -060067 case GFX_DEVFN:
68 return "IGFX";
Marc Jones9022b9d2018-05-25 20:53:44 -060069 case PCIE0_DEVFN:
70 return "PBR4";
71 case PCIE1_DEVFN:
72 return "PBR5";
73 case PCIE2_DEVFN:
74 return "PBR6";
75 case PCIE3_DEVFN:
76 return "PBR7";
77 case PCIE4_DEVFN:
78 return "PBR8";
Justin TerAvest949d6662018-01-24 14:20:03 -070079 case EHCI1_DEVFN:
80 return "EHC0";
Justin TerAvest949d6662018-01-24 14:20:03 -070081 case SD_DEVFN:
82 return "SDCN";
Justin TerAvest949d6662018-01-24 14:20:03 -070083 case XHCI_DEVFN:
84 return "XHC0";
85 default:
86 return NULL;
87 }
88};
89
Felix Helda11b4722022-10-13 16:32:23 +020090struct device_operations stoneyridge_pci_domain_ops = {
Furquan Shaikhfc752b62020-05-13 12:14:11 -070091 .read_resources = domain_read_resources,
92 .set_resources = pci_domain_set_resources,
Marc Jones1587dc82017-05-15 18:55:11 -060093 .enable_resources = domain_enable_resources,
Marc Jones1587dc82017-05-15 18:55:11 -060094 .scan_bus = pci_domain_scan_bus,
Justin TerAvest949d6662018-01-24 14:20:03 -070095 .acpi_name = soc_acpi_name,
Marc Jones24484842017-05-04 21:17:45 -060096};
97
Marc Jones24484842017-05-04 21:17:45 -060098static void soc_init(void *chip_info)
99{
Felix Helda21690b2021-01-29 16:01:10 +0100100 fch_init(chip_info);
Marc Jones24484842017-05-04 21:17:45 -0600101}
102
103static void soc_final(void *chip_info)
104{
Felix Helda21690b2021-01-29 16:01:10 +0100105 fch_final(chip_info);
Marc Jones1587dc82017-05-15 18:55:11 -0600106 fam15_finalize(chip_info);
Marc Jones24484842017-05-04 21:17:45 -0600107}
108
109struct chip_operations soc_amd_stoneyridge_ops = {
110 CHIP_NAME("AMD StoneyRidge SOC")
Elyes HAOUAS1d191272018-11-27 12:23:48 +0100111 .init = soc_init,
112 .final = soc_final
Marc Jones24484842017-05-04 21:17:45 -0600113};
Marshall Dawson9db8a442017-09-20 10:24:28 -0600114
Marshall Dawsonf5e057c2017-10-12 16:10:14 -0600115static void earliest_ramstage(void *unused)
Marshall Dawson9db8a442017-09-20 10:24:28 -0600116{
Kyösti Mälkki9e591c42021-01-09 12:37:25 +0200117 if (!acpi_is_wakeup_s3()) {
Marshall Dawson8f2a7e02017-11-01 11:44:48 -0600118 post_code(0x46);
Julius Wernercd49cce2019-03-05 16:53:33 -0800119 if (CONFIG(SOC_AMD_PSP_SELECTABLE_SMU_FW))
Marshall Dawson737e56a2020-01-19 16:32:08 -0700120 psp_load_named_blob(BLOB_SMU_FW2, "smu_fw2");
Marshall Dawsonf5e057c2017-10-12 16:10:14 -0600121
Marshall Dawson8f2a7e02017-11-01 11:44:48 -0600122 post_code(0x47);
Kyösti Mälkki6e512c42018-06-14 06:57:05 +0300123 do_agesawrapper(AMD_INIT_ENV, "amdinitenv");
Marshall Dawson8f2a7e02017-11-01 11:44:48 -0600124 } else {
125 /* Complete the initial system restoration */
126 post_code(0x46);
Kyösti Mälkki6e512c42018-06-14 06:57:05 +0300127 do_agesawrapper(AMD_S3LATE_RESTORE, "amds3laterestore");
Marshall Dawson8f2a7e02017-11-01 11:44:48 -0600128 }
Marshall Dawson9db8a442017-09-20 10:24:28 -0600129}
130
Marshall Dawsonf5e057c2017-10-12 16:10:14 -0600131BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, earliest_ramstage, NULL);