From fce489e9e5c306f78819535faf0df3f696aa2d2e Mon Sep 17 00:00:00 2001 From: Cliff Huang Date: Fri, 17 Oct 2025 11:03:54 -0700 Subject: [PATCH] drivers/intel/touch: Check SoC I2C speed function exists before calling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds a null pointer check to ensure that the SoC-specific function to retrieve I2C bus speed is properly mapped before attempting to call it. Without this check, systems may crash during boot when the function pointer is not initialized. The issue occurs when the touchscreen or touchpad is configured to use THC-I2C via CBI fw_config, but the underlying SoC doesn't provide the required I2C speed function implementation. BUG=none TEST=Boot Fatcat board to OS with CBI fw_config selecting touchscreen or touchpad using THC-I2C. Verify no crash occurs during boot and touch devices function properly. Change-Id: Ib982f4435aa506f2b9203f81140366addc6559f3 Signed-off-by: Cliff Huang Reviewed-on: https://review.coreboot.org/c/coreboot/+/89628 Tested-by: build bot (Jenkins) Reviewed-by: Bora Guvendik Reviewed-by: Jamie Ryu Reviewed-by: Jérémy Compostella --- src/drivers/intel/touch/touch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/drivers/intel/touch/touch.c b/src/drivers/intel/touch/touch.c index 2310773dd3..7697ffb149 100644 --- a/src/drivers/intel/touch/touch.c +++ b/src/drivers/intel/touch/touch.c @@ -268,8 +268,13 @@ static void touch_generate_acpi_i2cdev_dsd(const struct device *dev) acpigen_write_create_buffer_qword_field("ISUB", 0x88, "HMSL"); acpigen_write_store_int_to_namestr(touch_get(dev, dev_hidi2c.intf.hidi2c.addr), "DADR"); - connection_speed_val = _soc_hidi2c_info->get_soc_i2c_bus_speed_val_func( - touch_dev_soc_get(dev, hidi2c, connection_speed)); + + if (_soc_hidi2c_info->get_soc_i2c_bus_speed_val_func) { + connection_speed_val = _soc_hidi2c_info->get_soc_i2c_bus_speed_val_func( + touch_dev_soc_get(dev, hidi2c, connection_speed)); + } else { + die("Missing SoC function to map I2C speed to its register value!\n"); + } acpigen_write_store_int_to_namestr(connection_speed_val, "DSPD"); acpigen_write_store_int_to_namestr(touch_soc_get(dev, hidi2c, addr_mode), "DADM"); acpigen_write_store_int_to_namestr(touch_soc_get(dev, hidi2c, sm_scl_high_period), "SMHX");