Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <baseboard/gpio.h> |
| 4 | #include <baseboard/variants.h> |
Elyes Haouas | 1bd23e3 | 2022-10-31 13:13:37 +0100 | [diff] [blame] | 5 | #include <cpu/cpu.h> |
Bora Guvendik | 6445023 | 2022-05-25 17:39:34 -0700 | [diff] [blame] | 6 | #include <cpu/intel/cpu_ids.h> |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 7 | #include <device/device.h> |
Meera Ravindranath | 8dffc38 | 2020-12-07 20:48:09 +0530 | [diff] [blame] | 8 | #include <drivers/intel/gma/opregion.h> |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 9 | #include <ec/ec.h> |
Elyes Haouas | 1bd23e3 | 2022-10-31 13:13:37 +0100 | [diff] [blame] | 10 | #include <fw_config.h> |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 11 | #include <smbios.h> |
Elyes Haouas | 1bd23e3 | 2022-10-31 13:13:37 +0100 | [diff] [blame] | 12 | #include <soc/gpio.h> |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | #include <string.h> |
Elyes Haouas | 1bd23e3 | 2022-10-31 13:13:37 +0100 | [diff] [blame] | 15 | |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 16 | #include "board_id.h" |
| 17 | |
| 18 | const char *smbios_system_sku(void) |
| 19 | { |
| 20 | static char sku_str[7] = ""; |
| 21 | uint8_t sku_id = get_board_id(); |
| 22 | |
| 23 | snprintf(sku_str, sizeof(sku_str), "sku%u", sku_id); |
| 24 | return sku_str; |
| 25 | } |
| 26 | |
| 27 | static void mainboard_init(void *chip_info) |
| 28 | { |
| 29 | variant_configure_gpio_pads(); |
| 30 | |
| 31 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
| 32 | mainboard_ec_init(); |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 33 | |
| 34 | variant_devtree_update(); |
| 35 | } |
| 36 | |
| 37 | void __weak variant_devtree_update(void) |
| 38 | { |
| 39 | /* Override dev tree settings per board */ |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 40 | } |
| 41 | |
Sean Rhodes | 9c40215 | 2024-02-19 11:45:26 +0000 | [diff] [blame^] | 42 | #if CONFIG(BOARD_INTEL_ADLRVP_N_EXT_EC) |
Anil Kumar | 9b73c2b | 2021-06-09 11:51:10 -0700 | [diff] [blame] | 43 | static void add_fw_config_oem_string(const struct fw_config *config, void *arg) |
| 44 | { |
| 45 | struct smbios_type11 *t; |
| 46 | char buffer[64]; |
| 47 | |
| 48 | t = (struct smbios_type11 *)arg; |
| 49 | |
| 50 | snprintf(buffer, sizeof(buffer), "%s-%s", config->field_name, config->option_name); |
| 51 | t->count = smbios_add_string(t->eos, buffer); |
| 52 | } |
| 53 | |
| 54 | static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t) |
| 55 | { |
| 56 | fw_config_for_each_found(add_fw_config_oem_string, t); |
| 57 | } |
| 58 | #endif |
| 59 | |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 60 | static void mainboard_enable(struct device *dev) |
| 61 | { |
Sean Rhodes | 9c40215 | 2024-02-19 11:45:26 +0000 | [diff] [blame^] | 62 | #if CONFIG(BOARD_INTEL_ADLRVP_N_EXT_EC) |
Anil Kumar | 9b73c2b | 2021-06-09 11:51:10 -0700 | [diff] [blame] | 63 | dev->ops->get_smbios_strings = mainboard_smbios_strings; |
| 64 | #endif |
Subrata Banik | 9b4f221 | 2020-10-10 15:53:33 +0530 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | struct chip_operations mainboard_ops = { |
| 68 | .init = mainboard_init, |
| 69 | .enable_dev = mainboard_enable, |
| 70 | }; |
Meera Ravindranath | 8dffc38 | 2020-12-07 20:48:09 +0530 | [diff] [blame] | 71 | |
| 72 | const char *mainboard_vbt_filename(void) |
| 73 | { |
Lean Sheng Tan | 8ad51a8 | 2022-02-01 10:07:12 +0100 | [diff] [blame] | 74 | if (!CONFIG(CHROMEOS)) |
| 75 | return "vbt.bin"; |
| 76 | |
Bora Guvendik | 6445023 | 2022-05-25 17:39:34 -0700 | [diff] [blame] | 77 | uint32_t cpu_id = cpu_get_cpuid(); |
Meera Ravindranath | 8dffc38 | 2020-12-07 20:48:09 +0530 | [diff] [blame] | 78 | uint8_t sku_id = get_board_id(); |
| 79 | switch (sku_id) { |
| 80 | case ADL_P_LP5_1: |
| 81 | case ADL_P_LP5_2: |
Michał Żygowski | d54a5b29 | 2023-07-03 17:17:32 +0200 | [diff] [blame] | 82 | if (cpu_id == CPUID_RAPTORLAKE_J0) |
Bora Guvendik | 6445023 | 2022-05-25 17:39:34 -0700 | [diff] [blame] | 83 | return "vbt_adlrvp_rpl_lp5.bin"; |
Tim Wawrzynczak | a10cc8a | 2021-04-01 15:41:16 -0600 | [diff] [blame] | 84 | return "vbt_adlrvp_lp5.bin"; |
Deepti Deshatty | 193203f | 2021-04-29 21:32:58 +0530 | [diff] [blame] | 85 | case ADL_P_DDR5_1: |
| 86 | case ADL_P_DDR5_2: |
Tim Wawrzynczak | a10cc8a | 2021-04-01 15:41:16 -0600 | [diff] [blame] | 87 | return "vbt_adlrvp_ddr5.bin"; |
Meera Ravindranath | 8dffc38 | 2020-12-07 20:48:09 +0530 | [diff] [blame] | 88 | default: |
| 89 | return "vbt.bin"; |
| 90 | } |
| 91 | } |