1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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>
10 #include <fw_config.h>
11 #include <soc/ramstage.h>
14 #include <vendorcode/google/chromeos/chromeos.h>
16 WEAK_DEV_PTR(rp6_wwan
);
18 void __weak
fw_config_gpio_padbased_override(struct pad_config
*padbased_table
)
20 /* default implementation does nothing */
23 void mainboard_update_soc_chip_config(struct soc_intel_meteorlake_config
*config
)
25 variant_update_soc_chip_config(config
);
28 __weak
void variant_update_soc_chip_config(struct soc_intel_meteorlake_config
*config
)
30 /* default implementation does nothing */
33 static void mainboard_init(void *chip_info
)
35 struct pad_config
*padbased_table
;
36 const struct pad_config
*base_pads
;
39 padbased_table
= new_padbased_table();
40 base_pads
= variant_gpio_table(&base_num
);
41 gpio_padbased_override(padbased_table
, base_pads
, base_num
);
42 fw_config_gpio_padbased_override(padbased_table
);
43 gpio_configure_pads_with_padbased(padbased_table
);
45 baseboard_devtree_update();
48 void __weak
baseboard_devtree_update(void)
50 /* Override dev tree settings per baseboard */
53 void __weak
variant_generate_s0ix_hook(enum s0ix_entry entry
)
55 /* Add board-specific MS0X entries */
57 if (s0ix_entry == S0IX_ENTRY) {
58 implement variant operations here
60 if (s0ix_entry == S0IX_EXIT) {
61 implement variant operations here
66 static void mainboard_generate_s0ix_hook(void)
68 acpigen_write_if_lequal_op_int(ARG0_OP
, 1);
70 if (CONFIG(HAVE_SLP_S0_GATE
))
71 acpigen_soc_clear_tx_gpio(GPIO_SLP_S0_GATE
);
72 variant_generate_s0ix_hook(S0IX_ENTRY
);
76 if (CONFIG(HAVE_SLP_S0_GATE
))
77 acpigen_soc_set_tx_gpio(GPIO_SLP_S0_GATE
);
78 variant_generate_s0ix_hook(S0IX_EXIT
);
80 acpigen_write_if_end();
83 static void mainboard_generate_wwan_shutdown(const struct device
*dev
)
85 const struct drivers_wwan_fm_config
*config
= config_of(dev
);
86 const struct device
*parent
= dev
->upstream
->dev
;
90 if (config
->rtd3dev
) {
91 acpigen_write_store();
92 acpigen_emit_namestring(acpi_device_path_join(parent
, "RTD3._STA"));
93 acpigen_emit_byte(LOCAL0_OP
);
94 acpigen_write_if_lequal_op_int(LOCAL0_OP
, ONE_OP
);
96 acpigen_emit_namestring(acpi_device_path_join(dev
, "DPTS"));
97 acpigen_emit_byte(ARG0_OP
);
99 acpigen_write_if_end();
103 static void mainboard_fill_ssdt(const struct device
*dev
)
105 const struct device
*wwan
= DEV_PTR(rp6_wwan
);
107 if (is_dev_enabled(wwan
)) {
108 acpigen_write_scope("\\_SB");
109 acpigen_write_method_serialized("MPTS", 1);
110 mainboard_generate_wwan_shutdown(wwan
);
111 acpigen_write_method_end(); /* Method */
112 acpigen_write_scope_end(); /* Scope */
115 acpigen_write_scope("\\_SB");
116 acpigen_write_method_serialized("MS0X", 1);
117 mainboard_generate_s0ix_hook();
118 acpigen_write_method_end(); /* Method */
119 acpigen_write_scope_end(); /* Scope */
122 static void add_fw_config_oem_string(const struct fw_config
*config
, void *arg
)
124 struct smbios_type11
*t
;
127 t
= (struct smbios_type11
*)arg
;
129 snprintf(buffer
, sizeof(buffer
), "%s-%s", config
->field_name
, config
->option_name
);
130 t
->count
= smbios_add_string(t
->eos
, buffer
);
133 static void mainboard_smbios_strings(struct device
*dev
, struct smbios_type11
*t
)
135 fw_config_for_each_found(add_fw_config_oem_string
, t
);
138 static void mainboard_dev_init(struct device
*dev
)
143 static void mainboard_enable(struct device
*dev
)
145 dev
->ops
->init
= mainboard_dev_init
;
146 dev
->ops
->get_smbios_strings
= mainboard_smbios_strings
;
147 dev
->ops
->acpi_fill_ssdt
= mainboard_fill_ssdt
;
150 struct chip_operations mainboard_ops
= {
151 .init
= mainboard_init
,
152 .enable_dev
= mainboard_enable
,