coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
chip.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootstate.h>
4 #include <console/console.h>
5 #include <cpu/amd/mtrr.h>
6 #include <device/device.h>
7 #include <device/pci.h>
9 #include <soc/acpi.h>
10 #include <soc/cpu.h>
11 #include <soc/northbridge.h>
12 #include <soc/pci_devs.h>
13 #include <soc/southbridge.h>
14 #include <amdblocks/psp.h>
15 #include <amdblocks/agesawrapper.h>
17 #include <amdblocks/i2c.h>
18 
19 #include "chip.h"
20 
21 /* Supplied by i2c.c */
23 
26  .set_resources = noop_set_resources,
27  .init = mp_cpu_bus_init,
28  .acpi_fill_ssdt = generate_cpu_entries,
29 };
30 
31 const char *soc_acpi_name(const struct device *dev)
32 {
33  if (dev->path.type == DEVICE_PATH_DOMAIN)
34  return "PCI0";
35 
36  if (dev->path.type == DEVICE_PATH_USB) {
37  switch (dev->path.usb.port_type) {
38  case 0:
39  /* Root Hub */
40  return "RHUB";
41  case 2:
42  /* USB2 ports */
43  switch (dev->path.usb.port_id) {
44  case 0: return "HS01";
45  case 1: return "HS02";
46  case 2: return "HS03";
47  case 3: return "HS04";
48  case 4: return "HS05";
49  case 5: return "HS06";
50  case 6: return "HS07";
51  case 7: return "HS08";
52  }
53  break;
54  case 3:
55  /* USB3 ports */
56  switch (dev->path.usb.port_id) {
57  case 0: return "SS01";
58  case 1: return "SS02";
59  case 2: return "SS03";
60  }
61  break;
62  }
63  return NULL;
64  }
65 
66  if (dev->path.type != DEVICE_PATH_PCI)
67  return NULL;
68 
69  switch (dev->path.pci.devfn) {
70  case GFX_DEVFN:
71  return "IGFX";
72  case PCIE0_DEVFN:
73  return "PBR4";
74  case PCIE1_DEVFN:
75  return "PBR5";
76  case PCIE2_DEVFN:
77  return "PBR6";
78  case PCIE3_DEVFN:
79  return "PBR7";
80  case PCIE4_DEVFN:
81  return "PBR8";
82  case EHCI1_DEVFN:
83  return "EHC0";
84  case SD_DEVFN:
85  return "SDCN";
86  case XHCI_DEVFN:
87  return "XHC0";
88  default:
89  return NULL;
90  }
91 };
92 
93 static struct device_operations pci_domain_ops = {
95  .set_resources = pci_domain_set_resources,
96  .enable_resources = domain_enable_resources,
97  .scan_bus = pci_domain_scan_bus,
98  .acpi_name = soc_acpi_name,
99 };
100 
101 static void set_mmio_dev_ops(struct device *dev)
102 {
103  switch (dev->path.mmio.addr) {
104  case APU_I2C0_BASE:
105  case APU_I2C1_BASE:
106  case APU_I2C2_BASE:
107  case APU_I2C3_BASE:
108  dev->ops = &soc_amd_i2c_mmio_ops;
109  break;
110  }
111 }
112 
113 static void enable_dev(struct device *dev)
114 {
115  /* Set the operations if it is a special bus type */
116  switch (dev->path.type) {
117  case DEVICE_PATH_DOMAIN:
118  dev->ops = &pci_domain_ops;
119  break;
121  dev->ops = &cpu_bus_ops;
122  break;
123  case DEVICE_PATH_MMIO:
124  set_mmio_dev_ops(dev);
125  break;
126  default:
127  break;
128  }
129 }
130 
131 static void soc_init(void *chip_info)
132 {
133  fch_init(chip_info);
134 }
135 
136 static void soc_final(void *chip_info)
137 {
138  fch_final(chip_info);
139  fam15_finalize(chip_info);
140 }
141 
143  CHIP_NAME("AMD StoneyRidge SOC")
144  .enable_dev = enable_dev,
145  .init = soc_init,
146  .final = soc_final
147 };
148 
149 static void earliest_ramstage(void *unused)
150 {
151  if (!acpi_is_wakeup_s3()) {
152  post_code(0x46);
153  if (CONFIG(SOC_AMD_PSP_SELECTABLE_SMU_FW))
154  psp_load_named_blob(BLOB_SMU_FW2, "smu_fw2");
155 
156  post_code(0x47);
157  do_agesawrapper(AMD_INIT_ENV, "amdinitenv");
158  } else {
159  /* Complete the initial system restoration */
160  post_code(0x46);
161  do_agesawrapper(AMD_S3LATE_RESTORE, "amds3laterestore");
162  }
163 }
164 
static u32 do_agesawrapper(AGESA_STRUCT_NAME func, const char *name)
#define APU_I2C0_BASE
Definition: iomap.h:14
#define APU_I2C3_BASE
Definition: iomap.h:17
#define APU_I2C2_BASE
Definition: iomap.h:16
#define APU_I2C1_BASE
Definition: iomap.h:15
static int acpi_is_wakeup_s3(void)
Definition: acpi.h:9
@ BS_PRE_DEVICE
Definition: bootstate.h:78
@ BS_ON_ENTRY
Definition: bootstate.h:95
void fch_init(void *chip_info)
Definition: fch.c:290
void fch_final(void *chip_info)
Definition: fch.c:304
void generate_cpu_entries(const struct device *device)
Definition: acpi.c:334
@ CONFIG
Definition: dsi_common.h:201
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, wilco_ec_post_complete, NULL)
#define SD_DEVFN
Definition: variants.h:11
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
static void mp_cpu_bus_init(struct device *dev)
Definition: device.h:240
static void domain_read_resources(struct device *dev)
Definition: northbridge.c:460
#define GFX_DEVFN
Definition: pci_devs.h:13
void domain_enable_resources(struct device *dev)
Definition: northbridge.c:379
void fam15_finalize(void *chip_info)
Definition: northbridge.c:365
@ DEVICE_PATH_PCI
Definition: path.h:9
@ DEVICE_PATH_CPU_CLUSTER
Definition: path.h:14
@ DEVICE_PATH_DOMAIN
Definition: path.h:13
@ DEVICE_PATH_USB
Definition: path.h:20
@ DEVICE_PATH_MMIO
Definition: path.h:21
void pci_domain_set_resources(struct device *dev)
Definition: pci_device.c:564
void pci_domain_scan_bus(struct device *dev)
Scan a PCI domain.
Definition: pci_device.c:1610
#define post_code(value)
Definition: post_code.h:12
@ BLOB_SMU_FW2
Definition: psp.h:67
int psp_load_named_blob(enum psp_blob_type type, const char *name)
Definition: psp_gen1.c:153
struct device_operations cpu_bus_ops
Definition: chip.c:22
struct device_operations soc_amd_i2c_mmio_ops
Definition: i2c.c:123
static struct device_operations pci_domain_ops
Definition: chip.c:93
static void enable_dev(struct device *dev)
Definition: chip.c:113
static void soc_init(void *chip_info)
Definition: chip.c:131
const char * soc_acpi_name(const struct device *dev)
Definition: chip.c:31
struct chip_operations soc_amd_stoneyridge_ops
Definition: chip.c:142
static void set_mmio_dev_ops(struct device *dev)
Definition: chip.c:101
static void soc_final(void *chip_info)
Definition: chip.c:136
static void earliest_ramstage(void *unused)
Definition: chip.c:149
#define EHCI1_DEVFN
Definition: pci_devs.h:170
#define PCIE3_DEVFN
Definition: pci_devs.h:69
#define PCIE4_DEVFN
Definition: pci_devs.h:75
#define PCIE2_DEVFN
Definition: pci_devs.h:63
#define PCIE1_DEVFN
Definition: pci_devs.h:57
#define PCIE0_DEVFN
Definition: pci_devs.h:51
#define XHCI_DEVFN
Definition: pci_devs.h:153
#define NULL
Definition: stddef.h:19
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct usb_path usb
Definition: path.h:127
struct mmio_path mmio
Definition: path.h:128
struct pci_path pci
Definition: path.h:116
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143
uintptr_t addr
Definition: path.h:106
unsigned int devfn
Definition: path.h:54
unsigned int port_type
Definition: path.h:101
unsigned int port_id
Definition: path.h:102