From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5EF956329B; Wed, 30 Sep 2026 17:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790422; cv=none; b=mDVNq4WT6xt/RuOkpGc6BNQRXV8TdXrDij443cX5OjrY44TGIelAqeOgC6OySYqvhQnAWl4mU+cVQjZQrzkppn/xjYzo1tS5eCFbys6LSufekg9rx4+1VoD58tX6Dz96ujrrMxEsLD4BVgJK6bXxi3M9XFb+CaGNRL3Z9YeGTcc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790422; c=relaxed/simple; bh=TJ9zYuFJOrLKDHv4HnYv+D7urMPIIgviPFAFMGDtVaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KoMg1uJOltwGde8Byv9/LoRIIBPxszte3X32t/JA1kurFFD6pYPT+5OUlEqoo7X5jUwdXqAco1Ou9NzecfPnfeCdnNV/5Zlw+GM76jURmISQS9kXD2BDN53Zw/lFC5QVb1/kJLr6TMIko1xyfShwy4Rxbo/x+EaNZx6DttMk53k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ef3TaLSB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ef3TaLSB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 108001F000FF; Wed, 30 Sep 2026 17:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790790420; bh=nQ4bOp2PmdNCHLISNTw7v1QbmGnbFcuLinMgiSI6xEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ef3TaLSBkWvbF8hUOlZ3hJRr2X780liWdLCvci22joCVMDhOMNe8y5A3Td2/UMLNp mtkKFtQnlAJ4gqCiRRRKnjFuVvg1bQ2loZfy6NqQr46xdsAI266wsLUAWejlbXDdcV AChWXu4MrDkBF3dNesDCLy+4rrFrHUWHl7MTtWBo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Viken Dadhaniya , Mukesh Kumar Savaliya , Andi Shyti , Sasha Levin Subject: [PATCH 6.12 821/877] i2c: qcom-geni: Fix hardcoded clock index in SE_GENI_CLK_SEL Date: Wed, 30 Sep 2026 17:28:52 +0200 Message-ID: <20260930152432.444233111@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152414.738996857@linuxfoundation.org> References: <20260930152414.738996857@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Viken Dadhaniya [ Upstream commit cb97bf3d4f91453b881acaf8e9f0cc47bb40b604 ] qcom_geni_i2c_conf() writes a hardcoded 0 to SE_GENI_CLK_SEL, which selects an index from the hardware clock performance table. This always picks the first table entry regardless of the actual source clock configuration. On platforms where the matching entry is not at index 0, the wrong source clock divider is active and the I2C bus runs at an incorrect frequency. Use geni_se_clk_freq_match() in geni_i2c_clk_map_idx() to find the performance table index for the source clock (32 MHz or 19.2 MHz). Store the resolved index in a new clk_idx field in geni_i2c_dev and write it to SE_GENI_CLK_SEL instead of the hardcoded 0. Fixes: 37692de5d523 ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller") Signed-off-by: Viken Dadhaniya Cc: # v4.19+ Reviewed-by: Mukesh Kumar Savaliya Signed-off-by: Andi Shyti Link: https://patch.msgid.link/20260921-i2c-fix-se-clk-conf-v2-1-8b5537ceff2d@oss.qualcomm.com [ adapted clock initialization to the older driver’s 19.2 MHz-only table and existing probe path. ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-qcom-geni.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -77,6 +77,8 @@ enum geni_i2c_err_code { #define XFER_TIMEOUT HZ #define RST_TIMEOUT HZ +#define GENI_SE_CLK_19P2MHZ 19200000UL + struct geni_i2c_dev { struct geni_se se; u32 tx_wm; @@ -91,6 +93,7 @@ struct geni_i2c_dev { struct clk *core_clk; u32 clk_freq_out; const struct geni_i2c_clk_fld *clk_fld; + u32 clk_idx; int suspended; void *dma_buf; size_t xfer_len; @@ -157,13 +160,36 @@ static int geni_i2c_clk_map_idx(struct g { int i; const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map; + unsigned long res_freq; + + /* + * Frequency counters are calibrated for a 19.2 MHz source clock + * and are not valid for any multiple of it (e.g. 38.4 MHz). + * Use exact=true and verify res_freq matches req_freq literally + * to reject harmonics that would produce an incorrect I2C frequency. + * ACPI systems have firmware-managed clocks and retain the default index. + */ + if (!has_acpi_companion(gi2c->se.dev) && + (geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_19P2MHZ, + &gi2c->clk_idx, &res_freq, true) || + res_freq != GENI_SE_CLK_19P2MHZ)) { + dev_err(gi2c->se.dev, + "Unsupported SE source clock: must be exactly 19.2 MHz\n"); + return -EINVAL; + } for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) { if (itr->clk_freq_out == gi2c->clk_freq_out) { gi2c->clk_fld = itr; + dev_dbg(gi2c->se.dev, + "I2C clk selected: freq: %u Hz, clk_idx: %u\n", + gi2c->clk_freq_out, gi2c->clk_idx); return 0; } } + + dev_err(gi2c->se.dev, "Unsupported I2C output frequency %u Hz\n", gi2c->clk_freq_out); + return -EINVAL; } @@ -172,7 +198,7 @@ static void qcom_geni_i2c_conf(struct ge const struct geni_i2c_clk_fld *itr = gi2c->clk_fld; u32 val; - writel_relaxed(0, gi2c->se.base + SE_GENI_CLK_SEL); + writel_relaxed(gi2c->clk_idx, gi2c->se.base + SE_GENI_CLK_SEL); val = (itr->clk_div << CLK_DIV_SHFT) | SER_CLK_EN; writel_relaxed(val, gi2c->se.base + GENI_SER_M_CLK_CFG); @@ -809,11 +835,8 @@ static int geni_i2c_probe(struct platfor return gi2c->irq; ret = geni_i2c_clk_map_idx(gi2c); - if (ret) { - dev_err(dev, "Invalid clk frequency %d Hz: %d\n", - gi2c->clk_freq_out, ret); + if (ret) return ret; - } gi2c->adap.algo = &geni_i2c_algo; init_completion(&gi2c->done);