| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <baseboard/variants.h> |
| 5 |
#include <device/device.h> |
| 6 |
#include <drivers/tpm/cr50.h> |
| 7 |
#include <ec/ec.h> |
| 8 |
#include <fw_config.h> |
| 9 |
#include <gpio.h> |
| 10 |
#include <intelblocks/gpio.h> |
| 11 |
#include <security/tpm/tss.h> |
| 12 |
#include <intelblocks/tcss.h> |
| 13 |
#include <soc/pci_devs.h> |
| 14 |
#include <soc/ramstage.h> |
| 15 |
#include <static.h> |
| 16 |
#include <stdio.h> |
| 17 |
#include <variant/gpio.h> |
| 18 |
#include <vb2_api.h> |
| 19 |
|
| 20 |
#include "drivers/intel/pmc_mux/conn/chip.h" |
| 21 |
|
| 22 |
WEAK_DEV_PTR(conn1); |
| 23 |
|
| 24 |
static void typec_orientation_fixup(void) |
| 25 |
{ |
| 26 |
const struct device *conn = DEV_PTR(conn1); |
| 27 |
|
| 28 |
if (!is_dev_enabled(conn)) |
| 29 |
return; |
| 30 |
|
| 31 |
if (fw_config_probe(FW_CONFIG(DB_USB, USB4_GEN2)) |
| 32 |
|| fw_config_probe(FW_CONFIG(DB_USB, USB3_ACTIVE)) |
| 33 |
|| fw_config_probe(FW_CONFIG(DB_USB, USB4_GEN3)) |
| 34 |
|| fw_config_probe(FW_CONFIG(DB_USB, USB3_NO_A))) { |
| 35 |
struct drivers_intel_pmc_mux_conn_config *config = conn->chip_info; |
| 36 |
|
| 37 |
if (config) { |
| 38 |
printk(BIOS_INFO, |
| 39 |
"Configure Right Type-C port orientation for retimer\n"); |
| 40 |
config->sbu_orientation = TYPEC_ORIENTATION_NORMAL; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
static void mainboard_init(struct device *dev) |
| 46 |
{ |
| 47 |
mainboard_ec_init(); |
| 48 |
typec_orientation_fixup(); |
| 49 |
variant_devtree_update(); |
| 50 |
} |
| 51 |
|
| 52 |
void __weak variant_devtree_update(void) |
| 53 |
{ |
| 54 |
} |
| 55 |
|
| 56 |
void __weak variant_ramstage_init(void) |
| 57 |
{ |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
static void add_fw_config_oem_string(const struct fw_config *config, void *arg) |
| 62 |
{ |
| 63 |
struct smbios_type11 *t; |
| 64 |
char buffer[64]; |
| 65 |
|
| 66 |
t = (struct smbios_type11 *)arg; |
| 67 |
|
| 68 |
snprintf(buffer, sizeof(buffer), "%s-%s", config->field_name, config->option_name); |
| 69 |
t->count = smbios_add_string(t->eos, buffer); |
| 70 |
} |
| 71 |
|
| 72 |
static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t) |
| 73 |
{ |
| 74 |
fw_config_for_each_found(add_fw_config_oem_string, t); |
| 75 |
} |
| 76 |
|
| 77 |
static void mainboard_enable(struct device *dev) |
| 78 |
{ |
| 79 |
dev->ops->init = mainboard_init; |
| 80 |
dev->ops->get_smbios_strings = mainboard_smbios_strings; |
| 81 |
|
| 82 |
variant_ramstage_init(); |
| 83 |
} |
| 84 |
|
| 85 |
void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *cfg) |
| 86 |
{ |
| 87 |
tpm_result_t rc; |
| 88 |
if (!CONFIG(TPM_GOOGLE_CR50) || !CONFIG(SPI_TPM)) { |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
return; |
| 96 |
} |
| 97 |
|
| 98 |
rc = tlcl_lib_init(); |
| 99 |
if (rc != TPM_SUCCESS) { |
| 100 |
printk(BIOS_ERR, "tlcl_lib_init() failed: %#x\n", rc); |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
if (cr50_is_long_interrupt_pulse_enabled()) { |
| 105 |
printk(BIOS_INFO, "Enabling S0i3.4\n"); |
| 106 |
} else { |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
printk(BIOS_INFO, "Not enabling S0i3.4\n"); |
| 112 |
cfg->LpmStateDisableMask |= LPM_S0i3_4; |
| 113 |
cfg->gpio_override_pm = 1; |
| 114 |
memset(cfg->gpio_pm, 0, sizeof(cfg->gpio_pm)); |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
static void mainboard_chip_init(void *chip_info) |
| 119 |
{ |
| 120 |
const struct pad_config *base_pads; |
| 121 |
const struct pad_config *override_pads; |
| 122 |
size_t base_num, override_num; |
| 123 |
|
| 124 |
base_pads = baseboard_gpio_table(&base_num); |
| 125 |
override_pads = variant_override_gpio_table(&override_num); |
| 126 |
|
| 127 |
gpio_configure_pads_with_override(base_pads, base_num, override_pads, override_num); |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
if (gpio_get(GPP_A12)) { |
| 135 |
const struct pad_config gpio_pedet_nvme[] = { |
| 136 |
PAD_CFG_NF_IOSSTATE(GPP_A12, NONE, DEEP, NF1, HIZCRx1), |
| 137 |
}; |
| 138 |
gpio_configure_pads(gpio_pedet_nvme, ARRAY_SIZE(gpio_pedet_nvme)); |
| 139 |
printk(BIOS_INFO, "SATAXPCIE1 indicates PCIe NVMe is present\n"); |
| 140 |
} else { |
| 141 |
const struct pad_config gpio_pedet_sata[] = { |
| 142 |
PAD_CFG_NF_IOSSTATE(GPP_A12, NONE, DEEP, NF1, HIZCRx0), |
| 143 |
}; |
| 144 |
gpio_configure_pads(gpio_pedet_sata, ARRAY_SIZE(gpio_pedet_sata)); |
| 145 |
printk(BIOS_INFO, "SATAXPCIE1 indicates SATA SSD is present\n"); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
struct chip_operations mainboard_ops = { |
| 150 |
.init = mainboard_chip_init, |
| 151 |
.enable_dev = mainboard_enable, |
| 152 |
}; |