Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 2 | |
| 3 | #include <fsp/api.h> |
| 4 | #include <FspmUpd.h> |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 5 | #include <drivers/ipmi/ipmi_if.h> |
Johnny Lin | 3acea5c | 2021-01-08 15:24:25 +0800 | [diff] [blame] | 6 | #include <drivers/ipmi/ocp/ipmi_ocp.h> |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 7 | #include <soc/romstage.h> |
Johnny Lin | 3b9d995 | 2020-03-27 22:06:30 +0800 | [diff] [blame] | 8 | #include <string.h> |
| 9 | #include <gpio.h> |
Tim Chu | 13c4445 | 2022-11-25 10:31:00 +0000 | [diff] [blame^] | 10 | #include <soc/gpio_soc_defs.h> |
Maxim Polyakov | 8fb221d | 2020-04-26 20:56:50 +0300 | [diff] [blame] | 11 | #include <skxsp_tp_iio.h> |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 12 | |
Johnny Lin | dcc2eb9 | 2020-01-14 09:17:18 +0800 | [diff] [blame] | 13 | #include "ipmi.h" |
| 14 | |
Johnny Lin | 3b9d995 | 2020-03-27 22:06:30 +0800 | [diff] [blame] | 15 | static uint8_t iio_table_buf[sizeof(tp_iio_bifur_table)]; |
| 16 | |
| 17 | static void oem_update_iio(FSPM_UPD *mupd) |
| 18 | { |
| 19 | /* Read GPIO to decide IIO bifurcation at run-time. */ |
| 20 | int slot_config0 = gpio_get(GPP_C15); |
| 21 | int slot_config1 = gpio_get(GPP_C16); |
| 22 | |
| 23 | /* It's a single side 3 slots riser card, to tell which AICs are on each slot requires |
| 24 | reading the GPIO expander PCA9555 via SMBUS, and then configure the bifurcation |
| 25 | accordingly is left for future work. */ |
| 26 | if (!slot_config0 && slot_config1) |
| 27 | mupd->FspmConfig.IioBifurcationConfig.IIoBifurcationTable[Skt0_Iou0].Bifurcation |
| 28 | = IIO_BIFURCATE_xxx8xxx8; |
| 29 | } |
| 30 | |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 31 | static void mainboard_config_iio(FSPM_UPD *mupd) |
| 32 | { |
Johnny Lin | 3b9d995 | 2020-03-27 22:06:30 +0800 | [diff] [blame] | 33 | memcpy(iio_table_buf, tp_iio_bifur_table, sizeof(tp_iio_bifur_table)); |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 34 | mupd->FspmConfig.IioBifurcationConfig.IIoBifurcationTable = |
Johnny Lin | 3b9d995 | 2020-03-27 22:06:30 +0800 | [diff] [blame] | 35 | (UPD_IIO_BIFURCATION_DATA_ENTRY *) iio_table_buf; |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 36 | mupd->FspmConfig.IioBifurcationConfig.NumberOfEntries = |
| 37 | ARRAY_SIZE(tp_iio_bifur_table); |
| 38 | |
| 39 | mupd->FspmConfig.IioPciConfig.ConfigurationTable = |
| 40 | (UPD_PCI_PORT_CONFIG *) tp_iio_pci_port_skt0; |
| 41 | mupd->FspmConfig.IioPciConfig.NumberOfEntries = |
| 42 | ARRAY_SIZE(tp_iio_pci_port_skt0); |
| 43 | |
| 44 | mupd->FspmConfig.PchPciConfig.PciPortConfig = |
| 45 | (UPD_PCH_PCIE_PORT *) tp_pch_pci_port_skt0; |
| 46 | mupd->FspmConfig.PchPciConfig.NumberOfEntries = |
| 47 | ARRAY_SIZE(tp_pch_pci_port_skt0); |
| 48 | |
| 49 | mupd->FspmConfig.PchPciConfig.RootPortFunctionSwapping = 0x00; |
| 50 | mupd->FspmConfig.PchPciConfig.PciePllSsc = 0x00; |
Johnny Lin | 3b9d995 | 2020-03-27 22:06:30 +0800 | [diff] [blame] | 51 | oem_update_iio(mupd); |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void mainboard_memory_init_params(FSPM_UPD *mupd) |
| 55 | { |
Johnny Lin | dcc2eb9 | 2020-01-14 09:17:18 +0800 | [diff] [blame] | 56 | /* It's better to run get BMC selftest result first */ |
Sergii Dmytruk | ef7dd5d | 2021-10-22 01:02:32 +0300 | [diff] [blame] | 57 | if (ipmi_premem_init(CONFIG_BMC_KCS_BASE, 0) == CB_SUCCESS) { |
Johnny Lin | 3acea5c | 2021-01-08 15:24:25 +0800 | [diff] [blame] | 58 | ipmi_set_post_start(CONFIG_BMC_KCS_BASE); |
Johnny Lin | dcc2eb9 | 2020-01-14 09:17:18 +0800 | [diff] [blame] | 59 | init_frb2_wdt(); |
Johnny Lin | 3acea5c | 2021-01-08 15:24:25 +0800 | [diff] [blame] | 60 | } |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 61 | mainboard_config_iio(mupd); |
Maxim Polyakov | 89d2aa0 | 2020-04-26 20:56:50 +0300 | [diff] [blame] | 62 | |
| 63 | /* do not configure GPIO controller inside FSP-M */ |
| 64 | mupd->FspmConfig.GpioConfig.GpioTable = NULL; |
| 65 | mupd->FspmConfig.GpioConfig.NumberOfEntries = 0; |
Jonathan Zhang | 75985f1 | 2020-01-16 11:20:09 -0800 | [diff] [blame] | 66 | } |