drivers/intel/touch: Check SoC I2C speed function exists before calling

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 <cliff.huang@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89628
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Bora Guvendik <bora.guvendik@intel.com>
Reviewed-by: Jamie Ryu <jamie.m.ryu@intel.com>
Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
This commit is contained in:
Cliff Huang 2025-10-17 11:03:54 -07:00 committed by Matt DeVillier
commit fce489e9e5

View file

@ -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");