summaryrefslogtreecommitdiff
path: root/src/soc/amd/picasso/fsp_params.c
blob: 9decbbf57b7b9f9ce967fb4168ccc0ba8b0392f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* SPDX-License-Identifier: GPL-2.0-only */

#include <device/pci.h>
#include <soc/pci_devs.h>
#include <soc/platform_descriptors.h>
#include <fsp/api.h>
#include "chip.h"

static void fsps_update_emmc_config(FSP_S_CONFIG *scfg,
				const struct soc_amd_picasso_config *cfg)
{
	int val = SD_DISABLE;

	switch (cfg->sd_emmc_config) {
	case SD_EMMC_DISABLE:
		val = SD_DISABLE;
		break;
	case SD_EMMC_SD_LOW_SPEED:
		val = SD_LOW_SPEED;
		break;
	case SD_EMMC_SD_HIGH_SPEED:
		val = SD_HIGH_SPEED;
		break;
	case SD_EMMC_SD_UHS_I_SDR_50:
		val = SD_UHS_I_SDR_50;
		break;
	case SD_EMMC_SD_UHS_I_DDR_50:
		val = SD_UHS_I_DDR_50;
		break;
	case SD_EMMC_SD_UHS_I_SDR_104:
		val = SD_UHS_I_SDR_104;
		break;
	case SD_EMMC_EMMC_SDR_26:
		val = EMMC_SDR_26;
		break;
	case SD_EMMC_EMMC_SDR_52:
		val = EMMC_SDR_52;
		break;
	case SD_EMMC_EMMC_DDR_52:
		val = EMMC_DDR_52;
		break;
	case SD_EMMC_EMMC_HS200:
		val = EMMC_HS200;
		break;
	case SD_EMMC_EMMC_HS400:
		val = EMMC_HS400;
		break;
	case SD_EMMC_EMMC_HS300:
		val = EMMC_HS300;
		break;
	default:
		break;
	}

	scfg->emmc0_mode = val;
}

static void fill_pcie_descriptors(FSP_S_CONFIG *scfg,
			const fsp_pcie_descriptor *descs, size_t num)
{
	size_t i;
	fsp_pcie_descriptor *fsp_pcie;

	/* FIXME: this violates C rules. */
	fsp_pcie = (fsp_pcie_descriptor *)(scfg->dxio_descriptor0);

	for (i = 0; i < num; i++) {
		fsp_pcie[i] = descs[i];
	}
}

static void fill_ddi_descriptors(FSP_S_CONFIG *scfg,
			const fsp_ddi_descriptor *descs, size_t num)
{
	size_t i;
	fsp_ddi_descriptor *fsp_ddi;

	/* FIXME: this violates C rules. */
	fsp_ddi = (fsp_ddi_descriptor *)&(scfg->ddi_descriptor0);

	for (i = 0; i < num; i++) {
		fsp_ddi[i] = descs[i];
	}
}
static void fsp_fill_pcie_ddi_descriptors(FSP_S_CONFIG *scfg)
{
	const fsp_pcie_descriptor *fsp_pcie;
	const fsp_ddi_descriptor *fsp_ddi;
	size_t num_pcie;
	size_t num_ddi;

	mainboard_get_pcie_ddi_descriptors(&fsp_pcie, &num_pcie,
						&fsp_ddi, &num_ddi);
	fill_pcie_descriptors(scfg, fsp_pcie, num_pcie);
	fill_ddi_descriptors(scfg, fsp_ddi, num_ddi);
}

static void fsp_usb_oem_customization(FSP_S_CONFIG *scfg,
			const struct soc_amd_picasso_config *cfg)
{
	scfg->xhci0_force_gen1 = cfg->xhci0_force_gen1;
}

void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
{
	const struct soc_amd_picasso_config *cfg;
	FSP_S_CONFIG *scfg = &supd->FspsConfig;

	cfg = config_of_soc();
	fsps_update_emmc_config(scfg, cfg);
	fsp_fill_pcie_ddi_descriptors(scfg);
	fsp_usb_oem_customization(scfg, cfg);
}