From nobody Sat Apr 4 01:33:30 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12EE43803E8; Sun, 22 Mar 2026 12:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774182951; cv=none; b=LamEyz+cZ+UfjieFqrT5Tkpt4PaVle0W+n0ddQJCdyp0c6lza0MUXuw9bqnE0LhLRfUr7rKWRcJ1c53h56+bX93UUsPkgJ3fEegbj8zl8bBCmzXv2XLiazU6xqWUQct7BDCEyM0ju0xQl4M+yTzI1SCqqiwuTddO6z26qs5ImFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774182951; c=relaxed/simple; bh=hvgnFd6i8bH5mUG8809MkRlOdbcEZRveaBCGMvPKUaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HPg3aVFbt6qSqGxsbFj7GkBml0iqZfRk3uXdwk2YDf97mnBNO13DAtuyw3bCI8ji3Y+wMFoghV0LvwXydn+SgxQvQgSeFx3oGz2xFDqBxtcC+5l6SaNTR+oFeERF3Myv2pfUVt+3xJFC6JOCJJpxfQbc+f9Px1NOLax6/tgjC/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=kbkEGLdw; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="kbkEGLdw" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id ADD8F26E75; Sun, 22 Mar 2026 13:35:43 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id XISDc5WuRObm; Sun, 22 Mar 2026 13:35:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1774182943; bh=hvgnFd6i8bH5mUG8809MkRlOdbcEZRveaBCGMvPKUaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kbkEGLdwUhJqYlJei5Rt6QD9pKs5uH1HslMv8NSO+SBQ2zrE4adHobx9+JQIeccR/ hIVrgMZP/4P4raE2fEaPfUzE8izbuYLZSjmhDnKT8ZrI+XdOXUsPnqxNG0z/7VHW5A PiP5kV+BaJqLFe00bUywQlwgATj25Qmxnq5D2i3rJ4ZfStOzbztlhZUjaFYSCRF7LA 9Xcqt7T856WbQbcaYf/0Igyq7mFmjdVhtwYNPQ6xIsJK59UmpVptrxBFk8r6E725pR WoHKORDABnKxSZkKkL0jFhzO3Z04W2b+voz1+S8VnFDjXTNL6vNCnvfRkqTiFYW5R9 XXWK+KGLJ4yKw== From: Rustam Adilov To: Chris Packham , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rustam Adilov Subject: [PATCH v3 5/8] i2c: rtl9300: introduce clk struct for upcoming rtl9607 support Date: Sun, 22 Mar 2026 17:34:08 +0500 Message-ID: <20260322123411.32102-6-adilov@disroot.org> In-Reply-To: <20260322123411.32102-1-adilov@disroot.org> References: <20260322123411.32102-1-adilov@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In RTL9607C i2c controller, there is 10 bit CLK_DIV field for setting the clock of i2c interface which depends on the rate of i2c clk (which seems be fixed to 62.5MHz according to Realtek SDK). Introduce the clk struct and the respective F_CLK_DIV and clk_div which are going to be used in the upcoming patch for rtl9607c i2c controller support addition. devm_clk_get_optional_enabled() function was used for cleaner code as it automatically returns NULL if the clk is not present, which is going to be the case for RTL9300 and RTL9310 i2c controllers. Reviewed-by: Chris Packham Signed-off-by: Rustam Adilov --- drivers/i2c/busses/i2c-rtl9300.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index ffbc6c52861b..16af49ccd1dd 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only =20 #include +#include #include #include #include @@ -28,6 +29,7 @@ struct rtl9300_i2c_chan { struct rtl9300_i2c *i2c; enum rtl9300_bus_freq bus_freq; u8 sda_num; + u32 clk_div; }; =20 enum rtl9300_i2c_reg_scope { @@ -54,6 +56,7 @@ enum rtl9300_i2c_reg_fields { F_SDA_OUT_SEL, F_SDA_SEL, F_BUSY, + F_CLK_DIV, =20 /* keep last */ F_NUM_FIELDS @@ -85,6 +88,7 @@ struct rtl9300_i2c { u8 scl_num; u8 sda_num; struct mutex lock; + struct clk *clk; }; =20 DEFINE_GUARD(rtl9300_i2c, struct rtl9300_i2c *, mutex_lock(&_T->lock), mut= ex_unlock(&_T->lock)) @@ -432,6 +436,10 @@ static int rtl9300_i2c_probe(struct platform_device *p= dev) if (ret) return ret; =20 + i2c->clk =3D devm_clk_get_optional_enabled(dev, NULL); + if (IS_ERR(i2c->clk)) + return dev_err_probe(dev, PTR_ERR(i2c->clk), "Failed to enable i2c clock= \n"); + i =3D 0; for_each_child_of_node_scoped(dev->of_node, child) { struct rtl9300_i2c_chan *chan =3D &i2c->chans[i]; --=20 2.53.0