drivers/intel/touch: Change I2C speed type to i2c_speed enum
Change the I2C connection speed type from uint32_t to the i2c_speed enum type for better type safety and code consistency. While the i2c_speed enum values correspond to actual speed values in Hz, using the enum provides clearer intent and prevents invalid speed values. Additionally, add logic to use standard I2C speed (100 kHz) when no recommended or required speed is specified in the device tree, SoC configuration, or device settings. BUG=none TEST=Boot Fatcat board to OS and verify correct I2C speed assignments in 'DSPD' Name object under THC device from SSDT. Confirm touch devices operate at expected speeds. Signed-off-by: Cliff Huang <cliff.huang@intel.com> Change-Id: Ie01693544bebf9f748d16606fc13f39fe4069b03 Reviewed-on: https://review.coreboot.org/c/coreboot/+/89649 Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Kyoung Il Kim <kyoung.il.kim@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Pranava Y N <pranavayn@google.com> Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
This commit is contained in:
parent
84a348f4bf
commit
1af54d9784
3 changed files with 13 additions and 6 deletions
|
|
@ -62,10 +62,10 @@ struct intel_thc_hidi2c_info {
|
|||
/* Device connection speed in Hz */
|
||||
enum i2c_speed connection_speed;
|
||||
/*
|
||||
* This maps SoC specific function for converting speed in Hz to the actual
|
||||
* This maps SoC specific function for converting speed enum to the actual
|
||||
* value for the configuration register.
|
||||
*/
|
||||
uint64_t (*get_soc_i2c_bus_speed_val_func)(uint32_t speed);
|
||||
uint64_t (*get_soc_i2c_bus_speed_val_func)(enum i2c_speed speed);
|
||||
/* Device address mode */
|
||||
uint64_t addr_mode;
|
||||
/* Standard Mode (100 kbit/s) Serial Clock Line HIGH Period */
|
||||
|
|
|
|||
|
|
@ -270,8 +270,17 @@ static void touch_generate_acpi_i2cdev_dsd(const struct device *dev)
|
|||
acpigen_write_store_int_to_namestr(touch_get(dev, dev_hidi2c.intf.hidi2c.addr), "DADR");
|
||||
|
||||
if (_soc_hidi2c_info->get_soc_i2c_bus_speed_val_func) {
|
||||
enum i2c_speed connection_speed;
|
||||
|
||||
connection_speed = touch_dev_soc_get(dev, hidi2c, connection_speed);
|
||||
/*
|
||||
* If the recommended speed is not specified in the device tree, SoC, and device,
|
||||
* standard speed is used.
|
||||
*/
|
||||
if (!connection_speed)
|
||||
connection_speed = I2C_SPEED_STANDARD;
|
||||
connection_speed_val = _soc_hidi2c_info->get_soc_i2c_bus_speed_val_func(
|
||||
touch_dev_soc_get(dev, hidi2c, connection_speed));
|
||||
connection_speed);
|
||||
} else {
|
||||
die("Missing SoC function to map I2C speed to its register value!\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <soc/touch.h>
|
||||
|
||||
/* Convert I2C speed into value for the register in SoC */
|
||||
static uint64_t get_soc_thc_i2c_bus_freq_val(uint32_t speed)
|
||||
static uint64_t get_soc_thc_i2c_bus_freq_val(enum i2c_speed speed)
|
||||
{
|
||||
switch (speed) {
|
||||
case I2C_SPEED_FAST_PLUS:
|
||||
|
|
@ -13,8 +13,6 @@ static uint64_t get_soc_thc_i2c_bus_freq_val(uint32_t speed)
|
|||
return SOC_PTL_THC_I2C_CONNECTION_SPEED_FM;
|
||||
case I2C_SPEED_STANDARD:
|
||||
return SOC_PTL_THC_I2C_CONNECTION_SPEED_SM;
|
||||
case 0: /* If not specified in the device tree, SoC, and device, standard speed is used */
|
||||
return SOC_PTL_THC_I2C_CONNECTION_SPEED_SM;
|
||||
default:
|
||||
die("Fail to map %d Hz to proper I2C speed.\n", speed);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue