From nobody Tue Apr 7 10:39:52 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 27E0F1DF970; Sat, 14 Mar 2026 08:27:32 +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=1773476854; cv=none; b=IZcFltCNNlGfiSgBFnfgApSH+/0Oj4YKIcZWj0LahysiOKt9PqaOl5En9mZtjHlCEJ0KWHDHrgUy5XcMTg9/P88tsCK8XVbSUD0sH6J9bD9VMhKfN+mtm0q2iGKtdYlbGriRCUr5cN4sA+QqlN3h4q34Apk4cBcHjpSZ7O1azKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476854; c=relaxed/simple; bh=7OS17cQYSjPlq4e1ZxX5TDNoZL/icU6dIWn2AUy/f18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EapEkBvnjzTTII3dLrAQkv/tdJIiX8GZWT+Jm3sabjDXyX1yOz+9E11Qx2PV3u1usZcsp2kMOz3CLVhgP1fgFIHnAEwHOXDgbE+YHX4TVYJwhPZnfQ3VHUG3roDwuUfud3Xw1ZrKLvYkS7hLrpRw9/nGtNXRmuLkHzOS6xnk72g= 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=Z7uXcGUx; 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="Z7uXcGUx" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id D024A26849; Sat, 14 Mar 2026 09:27:31 +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 uv0-WXNJKOit; Sat, 14 Mar 2026 09:27:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476851; bh=7OS17cQYSjPlq4e1ZxX5TDNoZL/icU6dIWn2AUy/f18=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z7uXcGUxuVqoN1tUcy8VKep3AR1vCVWh6xFz+X2MbwabvwigckzCiKNscz5PkMm2y xLSXHsKyN+9hgwuPL6XKTV6c7ZSc0CgV67CnIASUQdWRpuwCFhmjuOFX07uZqd8Wkr XVYnchnwS4g7EbSHFGy0bJInlfh7/fYqXK/J+60nsi0i2ffM49f84gvMKNFRt7NlQw TQybsmpCKWeFLw5Dm4ajrMAVWRoHaPH0MIfaw9WJSwcwkglsaXOmiyoU719g7KctOn /rgTTxPSb57SYOPJ1EYTHA4Dx2iSNZvRwxJRPg8I6TC7/evbjCs3+Q2mK31q64vl6s lZFbdDSHrSEDA== 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 5/8] i2c: rtl9300: introduce clk struct for upcoming rtl9607 support Date: Sat, 14 Mar 2026 13:26:25 +0500 Message-ID: <20260314082628.25206-6-adilov@disroot.org> In-Reply-To: <20260314082628.25206-1-adilov@disroot.org> References: <20260314082628.25206-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. 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 86a82f2c3ce0..4953223ec97c 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 @@ -22,6 +23,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 { @@ -48,6 +50,7 @@ enum rtl9300_i2c_reg_fields { F_SDA_OUT_SEL, F_SDA_SEL, F_BUSY, + F_CLK_DIV, =20 /* keep last */ F_NUM_FIELDS @@ -79,6 +82,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)) @@ -426,6 +430,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