| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpigen.h> |
| 4 |
#include <baseboard/gpio.h> |
| 5 |
#include <baseboard/variants.h> |
| 6 |
#include <device/device.h> |
| 7 |
#include <drivers/wwan/fm/chip.h> |
| 8 |
#include <ec/ec.h> |
| 9 |
#include <fw_config.h> |
| 10 |
#include <soc/gpio.h> |
| 11 |
#include <soc/ramstage.h> |
| 12 |
#include <stdio.h> |
| 13 |
|
| 14 |
static void add_fw_config_oem_string(const struct fw_config *config, void *arg) |
| 15 |
{ |
| 16 |
struct smbios_type11 *t; |
| 17 |
char buffer[64]; |
| 18 |
|
| 19 |
t = (struct smbios_type11 *)arg; |
| 20 |
|
| 21 |
snprintf(buffer, sizeof(buffer), "%s-%s", config->field_name, config->option_name); |
| 22 |
t->count = smbios_add_string(t->eos, buffer); |
| 23 |
} |
| 24 |
|
| 25 |
static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t) |
| 26 |
{ |
| 27 |
fw_config_for_each_found(add_fw_config_oem_string, t); |
| 28 |
} |
| 29 |
|
| 30 |
void mainboard_update_soc_chip_config(struct soc_intel_alderlake_config *config) |
| 31 |
{ |
| 32 |
variant_update_soc_chip_config(config); |
| 33 |
} |
| 34 |
|
| 35 |
void __weak variant_update_soc_chip_config(struct soc_intel_alderlake_config *config) |
| 36 |
{ |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
void __weak variant_init(void) |
| 41 |
{ |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
void __weak fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 46 |
{ |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
void __weak variant_configure_pads(void) |
| 51 |
{ |
| 52 |
const struct pad_config *base_pads; |
| 53 |
const struct pad_config *override_pads; |
| 54 |
size_t base_num, override_num; |
| 55 |
|
| 56 |
base_pads = variant_gpio_table(&base_num); |
| 57 |
override_pads = variant_gpio_override_table(&override_num); |
| 58 |
gpio_configure_pads_with_override(base_pads, base_num, override_pads, override_num); |
| 59 |
} |
| 60 |
|
| 61 |
static void mainboard_init(void *chip_info) |
| 62 |
{ |
| 63 |
variant_configure_pads(); |
| 64 |
variant_init(); |
| 65 |
variant_devtree_update(); |
| 66 |
} |
| 67 |
|
| 68 |
void __weak variant_devtree_update(void) |
| 69 |
{ |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
static void mainboard_dev_init(struct device *dev) |
| 74 |
{ |
| 75 |
mainboard_ec_init(); |
| 76 |
} |
| 77 |
|
| 78 |
static void mainboard_generate_s0ix_hook(void) |
| 79 |
{ |
| 80 |
acpigen_write_if_lequal_op_int(ARG0_OP, 1); |
| 81 |
{ |
| 82 |
if (CONFIG(HAVE_SLP_S0_GATE)) |
| 83 |
acpigen_soc_clear_tx_gpio(GPIO_SLP_S0_GATE); |
| 84 |
variant_generate_s0ix_hook(S0IX_ENTRY); |
| 85 |
} |
| 86 |
acpigen_write_else(); |
| 87 |
{ |
| 88 |
if (CONFIG(HAVE_SLP_S0_GATE)) |
| 89 |
acpigen_soc_set_tx_gpio(GPIO_SLP_S0_GATE); |
| 90 |
variant_generate_s0ix_hook(S0IX_EXIT); |
| 91 |
} |
| 92 |
acpigen_write_if_end(); |
| 93 |
} |
| 94 |
|
| 95 |
static void mainboard_fill_ssdt(const struct device *dev) |
| 96 |
{ |
| 97 |
|
| 98 |
variant_fill_ssdt(dev); |
| 99 |
|
| 100 |
acpigen_write_scope("\\_SB"); |
| 101 |
acpigen_write_method_serialized("MS0X", 1); |
| 102 |
mainboard_generate_s0ix_hook(); |
| 103 |
acpigen_write_method_end(); |
| 104 |
acpigen_write_scope_end(); |
| 105 |
} |
| 106 |
|
| 107 |
void __weak variant_fill_ssdt(const struct device *dev) |
| 108 |
{ |
| 109 |
|
| 110 |
} |
| 111 |
|
| 112 |
void __weak variant_generate_s0ix_hook(enum s0ix_entry entry) |
| 113 |
{ |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
static void mainboard_enable(struct device *dev) |
| 126 |
{ |
| 127 |
dev->ops->init = mainboard_dev_init; |
| 128 |
dev->ops->get_smbios_strings = mainboard_smbios_strings; |
| 129 |
dev->ops->acpi_fill_ssdt = mainboard_fill_ssdt; |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
void __weak variant_finalize(void) |
| 134 |
{ |
| 135 |
} |
| 136 |
|
| 137 |
static void mainboard_final(void *chip_info) |
| 138 |
{ |
| 139 |
variant_finalize(); |
| 140 |
} |
| 141 |
|
| 142 |
struct chip_operations mainboard_ops = { |
| 143 |
.init = mainboard_init, |
| 144 |
.enable_dev = mainboard_enable, |
| 145 |
.final = mainboard_final, |
| 146 |
}; |