blob: 09cede3ddb345dca3794104aac2311411c169120 [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 Jones24484842017-05-04 21:17:45 -06005#include <device/device.h>
6#include <device/pci.h>
Justin TerAvest13101a72018-01-24 14:23:12 -07007#include <drivers/i2c/designware/dw_i2c.h>
Duncan Laurie32bdffa2018-05-07 15:37:28 -07008#include <soc/acpi.h>
Marshall Dawsona7bfbbe2017-09-13 17:24:53 -06009#include <soc/cpu.h>
Marc Jones1587dc82017-05-15 18:55:11 -060010#include <soc/northbridge.h>
Justin TerAvest949d6662018-01-24 14:20:03 -070011#include <soc/pci_devs.h>
Marshall Dawsona7bfbbe2017-09-13 17:24:53 -060012#include <soc/southbridge.h>
Marshall Dawsonf5e057c2017-10-12 16:10:14 -060013#include <amdblocks/psp.h>
Richard Spiegel0ad74ac2017-12-08 16:53:29 -070014#include <amdblocks/agesawrapper.h>
15#include <amdblocks/agesawrapper_call.h>
Karthikeyan Ramasubramanian4f87ae12021-03-18 23:16:29 -060016#include <amdblocks/i2c.h>
Martin Roth81804272022-11-20 20:30:18 -070017#include <amdblocks/post_codes.h>
Marc Jones24484842017-05-04 21:17:45 -060018
Elyes HAOUASc3385072019-03-21 15:38:06 +010019#include "chip.h"
20
Duncan Laurie32bdffa2018-05-07 15:37:28 -070021const char *soc_acpi_name(const struct device *dev)
Justin TerAvest949d6662018-01-24 14:20:03 -070022{
23 if (dev->path.type == DEVICE_PATH_DOMAIN)
24 return "PCI0";
Duncan Laurie32bdffa2018-05-07 15:37:28 -070025
26 if (dev->path.type == DEVICE_PATH_USB) {
27 switch (dev->path.usb.port_type) {
28 case 0:
29 /* Root Hub */
30 return "RHUB";
31 case 2:
32 /* USB2 ports */
33 switch (dev->path.usb.port_id) {
34 case 0: return "HS01";
35 case 1: return "HS02";
36 case 2: return "HS03";
37 case 3: return "HS04";
38 case 4: return "HS05";
39 case 5: return "HS06";
40 case 6: return "HS07";
41 case 7: return "HS08";
42 }
43 break;
44 case 3:
45 /* USB3 ports */
46 switch (dev->path.usb.port_id) {
47 case 0: return "SS01";
48 case 1: return "SS02";
49 case 2: return "SS03";
50 }
51 break;
52 }
53 return NULL;
54 }
55
Justin TerAvest949d6662018-01-24 14:20:03 -070056 if (dev->path.type != DEVICE_PATH_PCI)
57 return NULL;
58
59 switch (dev->path.pci.devfn) {
Marc Jones6dcb6c22018-07-26 17:07:13 -060060 case GFX_DEVFN:
61 return "IGFX";
Marc Jones9022b9d2018-05-25 20:53:44 -060062 case PCIE0_DEVFN:
63 return "PBR4";
64 case PCIE1_DEVFN:
65 return "PBR5";
66 case PCIE2_DEVFN:
67 return "PBR6";
68 case PCIE3_DEVFN:
69 return "PBR7";
70 case PCIE4_DEVFN:
71 return "PBR8";
Justin TerAvest949d6662018-01-24 14:20:03 -070072 case EHCI1_DEVFN:
73 return "EHC0";
Justin TerAvest949d6662018-01-24 14:20:03 -070074 case SD_DEVFN:
75 return "SDCN";
Justin TerAvest949d6662018-01-24 14:20:03 -070076 case XHCI_DEVFN:
77 return "XHC0";
78 default:
79 return NULL;
80 }
81};
82
Felix Helda11b4722022-10-13 16:32:23 +020083struct device_operations stoneyridge_pci_domain_ops = {
Furquan Shaikhfc752b62020-05-13 12:14:11 -070084 .read_resources = domain_read_resources,
85 .set_resources = pci_domain_set_resources,
Marc Jones1587dc82017-05-15 18:55:11 -060086 .enable_resources = domain_enable_resources,
Arthur Heymans0b0113f2023-08-31 17:09:28 +020087 .scan_bus = pci_host_bridge_scan_bus,
Justin TerAvest949d6662018-01-24 14:20:03 -070088 .acpi_name = soc_acpi_name,
Marc Jones24484842017-05-04 21:17:45 -060089};
90
Marc Jones24484842017-05-04 21:17:45 -060091static void soc_init(void *chip_info)
92{
Felix Helda21690b2021-01-29 16:01:10 +010093 fch_init(chip_info);
Marc Jones24484842017-05-04 21:17:45 -060094}
95
96static void soc_final(void *chip_info)
97{
Felix Helda21690b2021-01-29 16:01:10 +010098 fch_final(chip_info);
Marc Jones1587dc82017-05-15 18:55:11 -060099 fam15_finalize(chip_info);
Marc Jones24484842017-05-04 21:17:45 -0600100}
101
102struct chip_operations soc_amd_stoneyridge_ops = {
103 CHIP_NAME("AMD StoneyRidge SOC")
Elyes HAOUAS1d191272018-11-27 12:23:48 +0100104 .init = soc_init,
105 .final = soc_final
Marc Jones24484842017-05-04 21:17:45 -0600106};
Marshall Dawson9db8a442017-09-20 10:24:28 -0600107
Marshall Dawsonf5e057c2017-10-12 16:10:14 -0600108static void earliest_ramstage(void *unused)
Marshall Dawson9db8a442017-09-20 10:24:28 -0600109{
Kyösti Mälkki9e591c42021-01-09 12:37:25 +0200110 if (!acpi_is_wakeup_s3()) {
Yuchen He1e67adb2023-07-25 21:28:36 +0200111 post_code(POSTCODE_PSP_LOAD_SMU);
Julius Wernercd49cce2019-03-05 16:53:33 -0800112 if (CONFIG(SOC_AMD_PSP_SELECTABLE_SMU_FW))
Marshall Dawson737e56a2020-01-19 16:32:08 -0700113 psp_load_named_blob(BLOB_SMU_FW2, "smu_fw2");
Marshall Dawsonf5e057c2017-10-12 16:10:14 -0600114
Yuchen He1e67adb2023-07-25 21:28:36 +0200115 post_code(POSTCODE_AGESA_AMDINITENV);
Kyösti Mälkki6e512c42018-06-14 06:57:05 +0300116 do_agesawrapper(AMD_INIT_ENV, "amdinitenv");
Marshall Dawson8f2a7e02017-11-01 11:44:48 -0600117 } else {
118 /* Complete the initial system restoration */
Yuchen He1e67adb2023-07-25 21:28:36 +0200119 post_code(POSTCODE_AGESA_AMDS3LATERESTORE);
Kyösti Mälkki6e512c42018-06-14 06:57:05 +0300120 do_agesawrapper(AMD_S3LATE_RESTORE, "amds3laterestore");
Marshall Dawson8f2a7e02017-11-01 11:44:48 -0600121 }
Marshall Dawson9db8a442017-09-20 10:24:28 -0600122}
123
Marshall Dawsonf5e057c2017-10-12 16:10:14 -0600124BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, earliest_ramstage, NULL);