Compare

fcbc48dc650d2f58bfe19c4486830de0e9cad62e..8cb5c17be3a2fadc41075d04ce1c24c831546aaf

i2c: qcom-geni: Restore the source-clock selection policy

Currently, the source clock lookup prefers 32 MHz whenever that rate is
available, regardless of the rate configured by the platform. Before the
switch to looking up the clock index, the driver used the 32 MHz timing
table only if the current source clock rate was 32 MHz, and the 19.2 MHz
table otherwise.

On X1E80100 CRD, this results in switching the source clock from 19.2 MHz
to 32 MHz, which causes intermittent failures when probing the I2C HID
keyboard. These range from corrupted HID descriptors to failed resets
and transfer timeouts, which also affect the touchpad on the same bus.

Restore the original selection policy: use 32 MHz if already selected,
otherwise request 19.2 MHz. Look up the index for the selected rate and
keep the check that rejects higher-frequency multiples. This retains
the dynamic clock index lookup without preferring 32 MHz on platforms
that previously used 19.2 MHz. Report the requested rate if the lookup
fails.

Fixes: cb97bf3d4f91 ("i2c: qcom-geni: Fix hardcoded clock index in SE_GENI_CLK_SEL")
Assisted-by: LLM
Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
Tested-by: Hasty Heat <hastyheat@gmail.com>
Tested-by: Mitchell Augustin <mitchell.augustin@canonical.com>
Reviewed-by: Mitchell Augustin <mitchell.augustin@canonical.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20260928-b4-i2c-qcom-geni-preserve-source-clock-v1-1-9aded7552a76@oss.qualcomm.com

Abel Vesa <abel.vesa@oss.qualcomm.com> · 2026-09-28 13:58 UTC · committed by Andi Shyti

Browse files
3 files changed, +22 −19
modified drivers/gpio/gpio-nct6694.c
@@ -444,7 +444,7 @@ static int nct6694_gpio_probe(struct platform_device *pdev)
444 444 data->gpio.set_config = nct6694_set_config;
445 445 data->gpio.init_valid_mask = nct6694_init_valid_mask;
446 446 data->gpio.base = -1;
447 - data->gpio.can_sleep = true;
447 + data->gpio.can_sleep = false;
448 448 data->gpio.owner = THIS_MODULE;
449 449 data->gpio.ngpio = NCT6694_NR_GPIO;
450 450
modified drivers/i2c/busses/i2c-qcom-geni.c
@@ -201,28 +201,31 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
201 201 static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
202 202 {
203 203 const struct geni_i2c_clk_fld *itr;
204 - unsigned long res_freq;
204 + unsigned long req_freq, res_freq;
205 + int ret;
205 206
206 207 /*
207 - * Frequency counter tables are calibrated for a specific source
208 - * clock frequency and are not valid for any multiple of it
209 - * (e.g. 64 MHz, 128 MHz).
210 - * Use exact=true and verify res_freq matches req_freq literally
211 - * to reject harmonics: a 64 MHz clock that divides evenly to
212 - * 32 MHz would pass exact matching but produce double the intended
213 - * I2C frequency with these counter values.
208 + * Use 32 MHz only if already selected, otherwise use 19.2 MHz.
209 + * Preferring 32 MHz merely because DFS supports it breaks I2C
210 + * transfers on X1E80100 CRD.
214 211 */
215 - if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_32MHZ,
216 - &gi2c->clk_idx, &res_freq, true) &&
217 - res_freq == GENI_SE_CLK_32MHZ) {
212 + if (clk_get_rate(gi2c->se.clk) == GENI_SE_CLK_32MHZ) {
213 + req_freq = GENI_SE_CLK_32MHZ;
218 214 itr = geni_i2c_clk_map_32mhz;
219 - } else if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_19P2MHZ,
220 - &gi2c->clk_idx, &res_freq, true) &&
221 - res_freq == GENI_SE_CLK_19P2MHZ) {
222 - itr = geni_i2c_clk_map_19p2mhz;
223 215 } else {
224 - dev_err(gi2c->se.dev,
225 - "Unsupported SE source clock: must be exactly 32 MHz or 19.2 MHz\n");
216 + req_freq = GENI_SE_CLK_19P2MHZ;
217 + itr = geni_i2c_clk_map_19p2mhz;
218 + }
219 +
220 + ret = geni_se_clk_freq_match(&gi2c->se, req_freq, &gi2c->clk_idx,
221 + &res_freq, true);
222 + if (ret)
223 + return dev_err_probe(gi2c->se.dev, ret,
224 + "Failed to find SE source clock %lu Hz\n",
225 + req_freq);
226 + if (res_freq != req_freq) {
227 + dev_err(gi2c->se.dev, "Unsupported SE source clock %lu Hz\n",
228 + res_freq);
226 229 return -EINVAL;
227 230 }
228 231
modified drivers/i2c/busses/i2c-viai2c-wmt.c
@@ -116,7 +116,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
116 116 if (err)
117 117 return err;
118 118
119 - i2c->clk = of_clk_get(np, 0);
119 + i2c->clk = devm_clk_get(&pdev->dev, NULL);
120 120 if (IS_ERR(i2c->clk))
121 121 return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
122 122 "unable to request clock\n");