/* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { char *spd_file; size_t spd_file_len; int spd_index, sku_id; gpio_t spd_gpios[] = { GPIO_MEM_CONFIG_0, GPIO_MEM_CONFIG_1, GPIO_MEM_CONFIG_2, GPIO_MEM_CONFIG_3, }; spd_index = gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios)); /* * XXX: This is incorrect usage.The Board ID should be the revision ID * and not SKU ID but on SCRD it indicates SKU. */ sku_id = board_id(); printk(BIOS_INFO, "SPD index %d\n", spd_index); printk(BIOS_INFO, "Board ID %d\n", sku_id); /* Load SPD data from CBFS */ spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, &spd_file_len); if (!spd_file) die("SPD data not found."); /* make sure we have at least one SPD in the file. */ if (spd_file_len < SPD_LEN) die("Missing SPD data."); /* Make sure we did not overrun the buffer */ if (spd_file_len < ((spd_index + 1) * SPD_LEN)) { printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n"); spd_index = 0; } /* Assume same memory in both channels */ spd_index *= SPD_LEN; memcpy(pei_data->spd_data[0][0], spd_file + spd_index, SPD_LEN); /* * XXX: This is incorrect usage. mem_cfg should be used here instead of * SKU ID. The current implementation of mem_config does not * support channel population. */ if (sku_id != SCRD_SKU1) memcpy(pei_data->spd_data[1][0], spd_file + spd_index, SPD_LEN); /* Make sure a valid SPD was found */ if (pei_data->spd_data[0][0][0] == 0) die("Invalid SPD data."); mainboard_print_spd_info(pei_data->spd_data[0][0]); }
int mainboard_get_spd_index(void) { gpio_t spd_gpios[] = { GPIO_MEM_CONFIG_0, GPIO_MEM_CONFIG_1, GPIO_MEM_CONFIG_2, GPIO_MEM_CONFIG_3, }; return gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios)); }
uint32_t sku_id(void) { const gpio_t pins[] = {[1] = GPIO(113), [0] = GPIO(79)}; static uint32_t id = UNDEFINED_STRAPPING_ID; if (id == UNDEFINED_STRAPPING_ID) id = gpio_base2_value(pins, ARRAY_SIZE(pins)); return id; }
uint32_t ram_code(void) { const gpio_t pins[] = {[1] = GPIO(147), [0] = GPIO(146)}; static uint32_t id = UNDEFINED_STRAPPING_ID; if (id == UNDEFINED_STRAPPING_ID) id = gpio_base2_value(pins, ARRAY_SIZE(pins)); return id; }
uint32_t board_id(void) { const gpio_t pins[] = {[2] = GPIO(51), [1] = GPIO(62), [0] = GPIO(38)}; static uint32_t id = UNDEFINED_STRAPPING_ID; if (id == UNDEFINED_STRAPPING_ID) id = gpio_base2_value(pins, ARRAY_SIZE(pins)); return id; }
uint32_t ram_code(void) { uint32_t code; static gpio_t pins[] = {[3] = GPIO(8, A, 3), [2] = GPIO(8, A, 2), [1] = GPIO(8, A, 1), [0] = GPIO(8, A, 0)}; /* GPIO8_A0 is LSB */ code = gpio_base2_value(pins, ARRAY_SIZE(pins)); printk(BIOS_SPEW, "RAM Config: %u.\n", code); return code; }
__weak uint8_t get_ramid(void) { gpio_t spd_gpios[] = { GP_SW_80, /* SATA_GP3, RAMID0 */ GP_SW_67, /* I2C3_SCL, RAMID1 */ GP_SE_02, /* MF_PLT_CLK1, RAMID2 */ GP_SW_64, /* I2C3_SDA, RAMID3 */ }; return gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios)); }
uint8_t board_id(void) { static int id = -1; static gpio_t pins[] = {[3] = GPIO(2, A, 7), [2] = GPIO(2, A, 2), [1] = GPIO(2, A, 1), [0] = GPIO(2, A, 0)}; /* GPIO2_A0 is LSB */ if (id < 0) { id = gpio_base2_value(pins, ARRAY_SIZE(pins)); printk(BIOS_SPEW, "Board ID: %d.\n", id); } return id; }
uint32_t ram_code(void) { uint32_t code; gpio_t pins[] = {[3] = GPIO(8, A, 3), [2] = GPIO(8, A, 2), [1] = GPIO(8, A, 1), [0] = GPIO(8, A, 0)}; /* GPIO8_A0 is LSB */ if (IS_ENABLED(CONFIG_VEYRON_FORCE_BINARY_RAM_CODE)) code = gpio_base2_value(pins, ARRAY_SIZE(pins)); else code = gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins)); printk(BIOS_SPEW, "RAM Config: %u.\n", code); return code; }
/* Copy SPD data for on-board memory */ void mainboard_fill_spd_data(struct pei_data *pei_data) { char *spd_file; size_t spd_file_len; int spd_index; gpio_t spd_gpios[] = { GPIO_MEM_CONFIG_0, GPIO_MEM_CONFIG_1, GPIO_MEM_CONFIG_2, GPIO_MEM_CONFIG_3, }; spd_index = gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios)); printk(BIOS_INFO, "SPD index %d\n", spd_index); /* Load SPD data from CBFS */ spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, &spd_file_len); if (!spd_file) die("SPD data not found."); /* make sure we have at least one SPD in the file. */ if (spd_file_len < SPD_LEN) die("Missing SPD data."); /* Make sure we did not overrun the buffer */ if (spd_file_len < ((spd_index + 1) * SPD_LEN)) { printk(BIOS_ERR, "SPD index override to 1 - old hardware?\n"); spd_index = 1; } /* Assume same memory in both channels */ spd_index *= SPD_LEN; memcpy(pei_data->spd_data[0][0], spd_file + spd_index, SPD_LEN); memcpy(pei_data->spd_data[1][0], spd_file + spd_index, SPD_LEN); /* Make sure a valid SPD was found */ if (pei_data->spd_data[0][0][0] == 0) die("Invalid SPD data."); mainboard_print_spd_info(pei_data->spd_data[0][0]); }
void mainboard_romstage_entry(struct romstage_params *params) { #ifdef EC_ENABLE_KEYBOARD_BACKLIGHT /* Turn on keyboard backlight to indicate we are booting */ if (params->power_state->prev_sleep_state != ACPI_S3) google_chromeec_kbbacklight(25); #endif /* Get SPD index */ gpio_t spd_gpios[] = { GPIO_MEM_CONFIG_0, GPIO_MEM_CONFIG_1, GPIO_MEM_CONFIG_2, GPIO_MEM_CONFIG_3, }; params->pei_data->mem_cfg_id = gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios)); /* Fill out PEI DATA */ mainboard_fill_pei_data(params->pei_data); mainboard_fill_spd_data(params->pei_data); /* Initialize memory */ romstage_common(params); }
void mainboard_romstage_entry(struct romstage_params *params) { /* PCH_MEM_CFG[3:0] */ gpio_t spd_gpios[] = { GPIO_MEM_CONFIG_0, GPIO_MEM_CONFIG_1, GPIO_MEM_CONFIG_2, GPIO_MEM_CONFIG_3, }; /* Ensure the EC and PD are in the right mode for recovery */ google_chromeec_early_init(); early_config_gpio(); params->pei_data->mem_cfg_id = gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios)); /* Fill out PEI DATA */ mainboard_fill_pei_data(params->pei_data); mainboard_fill_spd_data(params->pei_data); /* Initliaze memory */ romstage_common(params); }
#include <boardid.h> #include <gpio.h> #include <console/console.h> #include <stdlib.h> #include "gpio.h" static int board_id_value = -1; static uint8_t get_board_id(void) { uint8_t bid = 0; static gpio_t pins[] = {[2] = BOARD_ID_2, [1] = BOARD_ID_1, [0] = BOARD_ID_0}; bid = gpio_base2_value(pins, ARRAY_SIZE(pins)); printk(BIOS_INFO, "Board ID %d\n", bid); return bid; } uint32_t board_id(void) { if (board_id_value < 0) board_id_value = get_board_id(); return board_id_value; } uint32_t ram_code(void)