soc/amd/cezanne/fsp_m_params: fix modification of constant

mcfg->usb_phy is a pointer to a struct usb_phy_config. The config is
constant. Changing a constant is undefined behavior, so create a local
static instance of usb_phy_config that can be modified safely.

Change-Id: If9b76b869a5b0581f979432ce57cc40f1c253880
Signed-off-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64133
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Fred Reitberger 2022-05-06 15:59:15 -04:00 committed by Felix Held
parent ab660f533f
commit 727bebb095
1 changed files with 4 additions and 1 deletions

View File

@ -150,7 +150,10 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
mcfg->sata_enable = is_dev_enabled(DEV_PTR(sata_0)) || is_dev_enabled(DEV_PTR(sata_1));
if (config->usb_phy_custom) {
mcfg->usb_phy = (struct usb_phy_config *)&config->usb_phy;
/* devicetree config is const, use local copy */
static struct usb_phy_config lcl_usb_phy;
lcl_usb_phy = config->usb_phy;
mcfg->usb_phy = &lcl_usb_phy;
mcfg->usb_phy->Version_Major = FSP_USB_STRUCT_MAJOR_VERSION;
mcfg->usb_phy->Version_Minor = FSP_USB_STRUCT_MINOR_VERSION;
mcfg->usb_phy->TableLength = sizeof(struct usb_phy_config);