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