Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marc Jones | 1587dc8 | 2017-05-15 18:55:11 -0600 | [diff] [blame] | 2 | |
Marshall Dawson | 9db8a44 | 2017-09-20 10:24:28 -0600 | [diff] [blame] | 3 | #include <bootstate.h> |
| 4 | #include <console/console.h> |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
Justin TerAvest | 13101a7 | 2018-01-24 14:23:12 -0700 | [diff] [blame] | 7 | #include <drivers/i2c/designware/dw_i2c.h> |
Duncan Laurie | 32bdffa | 2018-05-07 15:37:28 -0700 | [diff] [blame] | 8 | #include <soc/acpi.h> |
Marshall Dawson | a7bfbbe | 2017-09-13 17:24:53 -0600 | [diff] [blame] | 9 | #include <soc/cpu.h> |
Marc Jones | 1587dc8 | 2017-05-15 18:55:11 -0600 | [diff] [blame] | 10 | #include <soc/northbridge.h> |
Justin TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 11 | #include <soc/pci_devs.h> |
Marshall Dawson | a7bfbbe | 2017-09-13 17:24:53 -0600 | [diff] [blame] | 12 | #include <soc/southbridge.h> |
Marshall Dawson | f5e057c | 2017-10-12 16:10:14 -0600 | [diff] [blame] | 13 | #include <amdblocks/psp.h> |
Richard Spiegel | 0ad74ac | 2017-12-08 16:53:29 -0700 | [diff] [blame] | 14 | #include <amdblocks/agesawrapper.h> |
| 15 | #include <amdblocks/agesawrapper_call.h> |
Karthikeyan Ramasubramanian | 4f87ae1 | 2021-03-18 23:16:29 -0600 | [diff] [blame] | 16 | #include <amdblocks/i2c.h> |
Martin Roth | 8180427 | 2022-11-20 20:30:18 -0700 | [diff] [blame] | 17 | #include <amdblocks/post_codes.h> |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 18 | |
Elyes HAOUAS | c338507 | 2019-03-21 15:38:06 +0100 | [diff] [blame] | 19 | #include "chip.h" |
| 20 | |
Duncan Laurie | 32bdffa | 2018-05-07 15:37:28 -0700 | [diff] [blame] | 21 | const char *soc_acpi_name(const struct device *dev) |
Justin TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 22 | { |
| 23 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 24 | return "PCI0"; |
Duncan Laurie | 32bdffa | 2018-05-07 15:37:28 -0700 | [diff] [blame] | 25 | |
| 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 TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 56 | if (dev->path.type != DEVICE_PATH_PCI) |
| 57 | return NULL; |
| 58 | |
| 59 | switch (dev->path.pci.devfn) { |
Marc Jones | 6dcb6c2 | 2018-07-26 17:07:13 -0600 | [diff] [blame] | 60 | case GFX_DEVFN: |
| 61 | return "IGFX"; |
Marc Jones | 9022b9d | 2018-05-25 20:53:44 -0600 | [diff] [blame] | 62 | 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 TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 72 | case EHCI1_DEVFN: |
| 73 | return "EHC0"; |
Justin TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 74 | case SD_DEVFN: |
| 75 | return "SDCN"; |
Justin TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 76 | case XHCI_DEVFN: |
| 77 | return "XHC0"; |
| 78 | default: |
| 79 | return NULL; |
| 80 | } |
| 81 | }; |
| 82 | |
Felix Held | a11b472 | 2022-10-13 16:32:23 +0200 | [diff] [blame] | 83 | struct device_operations stoneyridge_pci_domain_ops = { |
Furquan Shaikh | fc752b6 | 2020-05-13 12:14:11 -0700 | [diff] [blame] | 84 | .read_resources = domain_read_resources, |
| 85 | .set_resources = pci_domain_set_resources, |
Marc Jones | 1587dc8 | 2017-05-15 18:55:11 -0600 | [diff] [blame] | 86 | .enable_resources = domain_enable_resources, |
Marc Jones | 1587dc8 | 2017-05-15 18:55:11 -0600 | [diff] [blame] | 87 | .scan_bus = pci_domain_scan_bus, |
Justin TerAvest | 949d666 | 2018-01-24 14:20:03 -0700 | [diff] [blame] | 88 | .acpi_name = soc_acpi_name, |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 89 | }; |
| 90 | |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 91 | static void soc_init(void *chip_info) |
| 92 | { |
Felix Held | a21690b | 2021-01-29 16:01:10 +0100 | [diff] [blame] | 93 | fch_init(chip_info); |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static void soc_final(void *chip_info) |
| 97 | { |
Felix Held | a21690b | 2021-01-29 16:01:10 +0100 | [diff] [blame] | 98 | fch_final(chip_info); |
Marc Jones | 1587dc8 | 2017-05-15 18:55:11 -0600 | [diff] [blame] | 99 | fam15_finalize(chip_info); |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | struct chip_operations soc_amd_stoneyridge_ops = { |
| 103 | CHIP_NAME("AMD StoneyRidge SOC") |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 104 | .init = soc_init, |
| 105 | .final = soc_final |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 106 | }; |
Marshall Dawson | 9db8a44 | 2017-09-20 10:24:28 -0600 | [diff] [blame] | 107 | |
Marshall Dawson | f5e057c | 2017-10-12 16:10:14 -0600 | [diff] [blame] | 108 | static void earliest_ramstage(void *unused) |
Marshall Dawson | 9db8a44 | 2017-09-20 10:24:28 -0600 | [diff] [blame] | 109 | { |
Kyösti Mälkki | 9e591c4 | 2021-01-09 12:37:25 +0200 | [diff] [blame] | 110 | if (!acpi_is_wakeup_s3()) { |
Martin Roth | 8180427 | 2022-11-20 20:30:18 -0700 | [diff] [blame] | 111 | post_code(POST_PSP_LOAD_SMU); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 112 | if (CONFIG(SOC_AMD_PSP_SELECTABLE_SMU_FW)) |
Marshall Dawson | 737e56a | 2020-01-19 16:32:08 -0700 | [diff] [blame] | 113 | psp_load_named_blob(BLOB_SMU_FW2, "smu_fw2"); |
Marshall Dawson | f5e057c | 2017-10-12 16:10:14 -0600 | [diff] [blame] | 114 | |
Martin Roth | 8180427 | 2022-11-20 20:30:18 -0700 | [diff] [blame] | 115 | post_code(POST_AGESA_AMDINITENV); |
Kyösti Mälkki | 6e512c4 | 2018-06-14 06:57:05 +0300 | [diff] [blame] | 116 | do_agesawrapper(AMD_INIT_ENV, "amdinitenv"); |
Marshall Dawson | 8f2a7e0 | 2017-11-01 11:44:48 -0600 | [diff] [blame] | 117 | } else { |
| 118 | /* Complete the initial system restoration */ |
Martin Roth | 8180427 | 2022-11-20 20:30:18 -0700 | [diff] [blame] | 119 | post_code(POST_AGESA_AMDS3LATERESTORE); |
Kyösti Mälkki | 6e512c4 | 2018-06-14 06:57:05 +0300 | [diff] [blame] | 120 | do_agesawrapper(AMD_S3LATE_RESTORE, "amds3laterestore"); |
Marshall Dawson | 8f2a7e0 | 2017-11-01 11:44:48 -0600 | [diff] [blame] | 121 | } |
Marshall Dawson | 9db8a44 | 2017-09-20 10:24:28 -0600 | [diff] [blame] | 122 | } |
| 123 | |
Marshall Dawson | f5e057c | 2017-10-12 16:10:14 -0600 | [diff] [blame] | 124 | BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, earliest_ramstage, NULL); |