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