From nobody Tue Apr 7 09:06:50 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 DBE762DCC05; Sat, 14 Mar 2026 08:27:19 +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=1773476841; cv=none; b=f6yL7CaM6gWM4DTdH7zIcOztAUL0mwavtj2TaNQ/wdtuiPkoR0AmT5jilRmt6qTYwFwu33qXcChHsdxMXBQMTmQLpfh5oFitPGyHHn2cZW28mc2n8p8G3wCMx/aNovpOeVhRyoEHM7rHbokhbDPGlwgV/9/6UD1bY1QEqsfkoqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476841; c=relaxed/simple; bh=mqj4cJpd6qLwJ/bpExmiNn7phn7P9JaoseG1YDfjN/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fWZwwc9xJwbLtkzNrbwvDOygMeNU05yVM8/bwFrtdwS2mi06oCBDFXdn5Exg2+b1YVx0MbMLoiDPwoGzCCT0SJSrScg4CWQkbfUrsfcvN7GbcdJKEwoiNztP2Hyql0j/ztVyxGsI/1YaNKw2RHPPhOppHOS+r9urkpE/Vq7Vc6E= 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=JTWsbB2H; 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="JTWsbB2H" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A3BAF26849; Sat, 14 Mar 2026 09:27:18 +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 Wzomg2mFgRHj; Sat, 14 Mar 2026 09:27:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476838; bh=mqj4cJpd6qLwJ/bpExmiNn7phn7P9JaoseG1YDfjN/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JTWsbB2HZ85LabopbvSFmpDzJGDYuBKqSnL4BnbeHVGi+671Xi8Szl68GSWl8hj4b 5K4cG4/DnlbZbI//r2HIny0+s3qA0Q2JEnr0WWfjVjK4YWOPPtJFBpuJmGRKXY/8Ku doY/0CL3tDujTWBCPpG9FNQenrU4xTR19H+yeH7OXHFPeIG1rSj1MYIZyGMGeHcDX6 NEM2HB+3yk2n0/3XO/rlvkIAQdFAS9UQwBoodrizJFcRdPaUOhvs/iRnuTT8wrVLMr WTVz+1OuLM7gLiSECYTvgjxXA10tFUsEgqU4LZ8e3LlM9rYVdhT1jS7egVAZScVJw+ WOFV9GwDc0SqQ== 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 1/8] i2c: rtl9300: split data_reg into read and write reg Date: Sat, 14 Mar 2026 13:26:21 +0500 Message-ID: <20260314082628.25206-2-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 are 2 separate registers for reads and writes as opposed the combined 1 on rtl9300 and rtl9310. In preparation for RTL9607C support, split it up into rd_reg and wd_reg properties and change the i2c read and write functions accordingly. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- drivers/i2c/busses/i2c-rtl9300.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index 672cb978066d..66390420bd6a 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -55,7 +55,8 @@ enum rtl9300_i2c_reg_fields { struct rtl9300_i2c_drv_data { struct rtl9300_i2c_reg_field field_desc[F_NUM_FIELDS]; int (*select_scl)(struct rtl9300_i2c *i2c, u8 scl); - u32 data_reg; + u32 rd_reg; + u32 wd_reg; u8 max_nchan; }; =20 @@ -68,7 +69,8 @@ struct rtl9300_i2c { struct rtl9300_i2c_chan chans[RTL9310_I2C_MUX_NCHAN]; struct regmap_field *fields[F_NUM_FIELDS]; u32 reg_base; - u32 data_reg; + u32 rd_reg; + u32 wd_reg; u8 scl_num; u8 sda_num; struct mutex lock; @@ -165,7 +167,7 @@ static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8= *buf, u8 len) if (len > 16) return -EIO; =20 - ret =3D regmap_bulk_read(i2c->regmap, i2c->data_reg, vals, ARRAY_SIZE(val= s)); + ret =3D regmap_bulk_read(i2c->regmap, i2c->rd_reg, vals, ARRAY_SIZE(vals)= ); if (ret) return ret; =20 @@ -192,12 +194,12 @@ static int rtl9300_i2c_write(struct rtl9300_i2c *i2c,= u8 *buf, u8 len) vals[reg] |=3D buf[i] << shift; } =20 - return regmap_bulk_write(i2c->regmap, i2c->data_reg, vals, ARRAY_SIZE(val= s)); + return regmap_bulk_write(i2c->regmap, i2c->wd_reg, vals, ARRAY_SIZE(vals)= ); } =20 static int rtl9300_i2c_writel(struct rtl9300_i2c *i2c, u32 data) { - return regmap_write(i2c->regmap, i2c->data_reg, data); + return regmap_write(i2c->regmap, i2c->wd_reg, data); } =20 static int rtl9300_i2c_prepare_xfer(struct rtl9300_i2c *i2c, struct rtl930= 0_i2c_xfer *xfer) @@ -262,14 +264,14 @@ static int rtl9300_i2c_do_xfer(struct rtl9300_i2c *i2= c, struct rtl9300_i2c_xfer if (!xfer->write) { switch (xfer->type) { case RTL9300_I2C_XFER_BYTE: - ret =3D regmap_read(i2c->regmap, i2c->data_reg, &val); + ret =3D regmap_read(i2c->regmap, i2c->rd_reg, &val); if (ret) return ret; =20 *xfer->data =3D val & 0xff; break; case RTL9300_I2C_XFER_WORD: - ret =3D regmap_read(i2c->regmap, i2c->data_reg, &val); + ret =3D regmap_read(i2c->regmap, i2c->rd_reg, &val); if (ret) return ret; =20 @@ -402,7 +404,8 @@ static int rtl9300_i2c_probe(struct platform_device *pd= ev) if (device_get_child_node_count(dev) > drv_data->max_nchan) return dev_err_probe(dev, -EINVAL, "Too many channels\n"); =20 - i2c->data_reg =3D i2c->reg_base + drv_data->data_reg; + i2c->rd_reg =3D i2c->reg_base + drv_data->rd_reg; + i2c->wd_reg =3D i2c->reg_base + drv_data->wd_reg; for (i =3D 0; i < F_NUM_FIELDS; i++) { fields[i] =3D drv_data->field_desc[i].field; if (drv_data->field_desc[i].scope =3D=3D REG_SCOPE_MASTER) @@ -487,7 +490,8 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_dr= v_data =3D { [F_SDA_SEL] =3D GLB_REG_FIELD(RTL9300_I2C_MST_GLB_CTRL, 0, 7), }, .select_scl =3D rtl9300_i2c_select_scl, - .data_reg =3D RTL9300_I2C_MST_DATA_WORD0, + .rd_reg =3D RTL9300_I2C_MST_DATA_WORD0, + .wd_reg =3D RTL9300_I2C_MST_DATA_WORD0, .max_nchan =3D RTL9300_I2C_MUX_NCHAN, }; =20 @@ -507,7 +511,8 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_dr= v_data =3D { [F_MEM_ADDR] =3D MST_REG_FIELD(RTL9310_I2C_MST_MEMADDR_CTRL, 0, 23), }, .select_scl =3D rtl9310_i2c_select_scl, - .data_reg =3D RTL9310_I2C_MST_DATA_CTRL, + .rd_reg =3D RTL9310_I2C_MST_DATA_CTRL, + .wd_reg =3D RTL9310_I2C_MST_DATA_CTRL, .max_nchan =3D RTL9310_I2C_MUX_NCHAN, }; =20 --=20 2.53.0 From nobody Tue Apr 7 09:06:50 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 293AE32D0D8; Sat, 14 Mar 2026 08:27:23 +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=1773476845; cv=none; b=PH9waFPi/qygtuzlm4iyumsdHRBqX9QKpBOtbA0cGT3SOBM4gBbPbMGCY9B5kgpvjxjkgTDmpfjuIEoo2NdGRfaQqh/PmtXn157cyjZzEpbRfm4zr+TtcxMDZeHFha5y9iOUBvP3ihLTNFVbkJRuiRLSl4oYMhvP3DcCo/RocGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476845; c=relaxed/simple; bh=XZ1w1KvIa3CV+ZPgZfcPDWPjjJWpcjh6BeKa5wN95YU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ct+p0NviMSak0GtaUHArtrw0fQuHbzU/unzkn0+sqi3d5BeaFndo0QD7zFAcn95Dv5H86qV13EfVJ30Dc23rnSYiop6oJdEPF2aHoODEyeHJ1nvz8O4LLCTqRbmMEqnTvhGRT5ycaRqvdxhApqKbVad7tvj/RTvWZklXd24cm2w= 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=aE2CtOEQ; 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="aE2CtOEQ" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id DF2A22676F; Sat, 14 Mar 2026 09:27:22 +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 ebb908eLS7qx; Sat, 14 Mar 2026 09:27:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476842; bh=XZ1w1KvIa3CV+ZPgZfcPDWPjjJWpcjh6BeKa5wN95YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aE2CtOEQ9Lp9dgGsIz5vWwRDRf8jByZdDLXqvUfRnuYPZsUNeU+LitBKrW5yDsJ3M QpKxXbeUlzm3OCsYQuYgzmtu/r1Z9yKAWdbqngtOy3SRc5+JLkokqeP9IUVD28jiLW HWyOL4j5Zqem07rbHqyujgRPH8JcRJV9Wqj9iyee4j0dExDqSTQqrruZlTaBsZQxHD 0/WTkGAMViLYnqMrv3GGk9Asqu2eiuiTsXxHRQFC7zVfa0oOhUcCfhxiJLgAljDhrZ bittLHBzauKX36d/4ynToZtDkFuUXlEC68A92ZXdRQIHHejyPNUmtonHveUVdQTpOt 8a1KoGXP1Yefw== 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 2/8] i2c: rtl9300: introduce max length property to driver data Date: Sat, 14 Mar 2026 13:26:22 +0500 Message-ID: <20260314082628.25206-3-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, theoretical maximum the data length can be is 4 bytes as opposed to 16 bytes on rtl9300 and rtl9310. Introduce a new property to the driver data struct for that. Adjust if statement in prepare_xfer function to follow that new property instead of the hardcoded value. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- drivers/i2c/busses/i2c-rtl9300.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index 66390420bd6a..1354c8a7a369 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -58,11 +58,14 @@ struct rtl9300_i2c_drv_data { u32 rd_reg; u32 wd_reg; u8 max_nchan; + u8 max_data_len; }; =20 #define RTL9300_I2C_MUX_NCHAN 8 #define RTL9310_I2C_MUX_NCHAN 12 =20 +#define RTL9300_I2C_MAX_DATA_LEN 16 + struct rtl9300_i2c { struct regmap *regmap; struct device *dev; @@ -204,9 +207,11 @@ static int rtl9300_i2c_writel(struct rtl9300_i2c *i2c,= u32 data) =20 static int rtl9300_i2c_prepare_xfer(struct rtl9300_i2c *i2c, struct rtl930= 0_i2c_xfer *xfer) { + const struct rtl9300_i2c_drv_data *drv_data; int ret; =20 - if (xfer->data_len < 1 || xfer->data_len > 16) + drv_data =3D device_get_match_data(i2c->dev); + if (xfer->data_len < 1 || xfer->data_len > drv_data->max_data_len) return -EINVAL; =20 ret =3D regmap_field_write(i2c->fields[F_DEV_ADDR], xfer->dev_addr); @@ -493,6 +498,7 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_dr= v_data =3D { .rd_reg =3D RTL9300_I2C_MST_DATA_WORD0, .wd_reg =3D RTL9300_I2C_MST_DATA_WORD0, .max_nchan =3D RTL9300_I2C_MUX_NCHAN, + .max_data_len =3D RTL9300_I2C_MAX_DATA_LEN, }; =20 static const struct rtl9300_i2c_drv_data rtl9310_i2c_drv_data =3D { @@ -514,6 +520,7 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_dr= v_data =3D { .rd_reg =3D RTL9310_I2C_MST_DATA_CTRL, .wd_reg =3D RTL9310_I2C_MST_DATA_CTRL, .max_nchan =3D RTL9310_I2C_MUX_NCHAN, + .max_data_len =3D RTL9300_I2C_MAX_DATA_LEN, }; =20 static const struct of_device_id i2c_rtl9300_dt_ids[] =3D { --=20 2.53.0 From nobody Tue Apr 7 09:06:50 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 5FE7E29D29F; Sat, 14 Mar 2026 08:27:27 +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=1773476848; cv=none; b=pz+QwP9OE9HbBs+IOJRYuB+LdX38LVszfg8sZV9bsIKJb/q2sBkIS1bGXHuJ09X7DnVoMO/r/tZShAM4IZQ1IueNoweB6J6+W5ek2PCZGgOBLOa8UVWTyTn/AFM86HPl/KlUm91KVXk91Y+e812glsOZSHvTsbyQDjea2Xl8gZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476848; c=relaxed/simple; bh=wObEu7e3pzx2P5ILQgZadH8cxnOg7AQelSJPu3msjb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OiTC0vPiIKSgMeUVu89nqZGrmALuNdv+Weai+MEYP4dKG3Cw4zs4GCYEBo2VqauwnMPWBUfghEcxuviqWKcuW4b9aw732BFPtbTJrm/z02SqOg4XAqf3k0KjOknMUBZPgyUK92qLn+s17VtJnQZNdnnWZpv7Lsg/xN39gxoiNvs= 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=Xg8Uweo2; 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="Xg8Uweo2" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 1708C27011; Sat, 14 Mar 2026 09:27:26 +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 bgeJMl2NZ993; Sat, 14 Mar 2026 09:27:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476845; bh=wObEu7e3pzx2P5ILQgZadH8cxnOg7AQelSJPu3msjb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xg8Uweo2eMltt7MRalvWBx/ry+rm/OphA2rULKGmT/RKbq2c9yd4DBQ+FJtqQI2v7 0c51eBrYoWUMlERYYG5dzpd4jV4fhGQMAnnJJ3EydxDbR/Wevt/wp6ioLquacPES/R sHuXMZIm5p+XHGFY2OBzr0v/7rWhw96z/G6ZjgrGjrq+bbCFOIknKXcGApNUNWTJW9 Blg7nxzl4knOPLunvGrpykYHW5CCpr6lH3mXpNj/twB6z1cUcYDx/d8+bJPjNNcUVx meDQ6rjh13Mw3Z/B+IVoPdDl5b49arNPFPaVWI7lulNy+bvSnb7eV5ABJ2dW8yo/sC R5d9wXdxWMfrw== 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 3/8] i2c: rtl9300: introduce F_BUSY to the reg_fields struct Date: Sat, 14 Mar 2026 13:26:23 +0500 Message-ID: <20260314082628.25206-4-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 the busy check operation is done on the separate bit of the command register as opposed to self clearing command trigger bit on the rtl9300 and rtl9310 i2c controllers. Introduce a new F_BUSY field to the reg_fields struct for that and change the regmap read poll function to use F_BUSY instead of I2C_TRIG. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- drivers/i2c/busses/i2c-rtl9300.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index 1354c8a7a369..2525b57a9d03 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -47,6 +47,7 @@ enum rtl9300_i2c_reg_fields { F_SCL_SEL, F_SDA_OUT_SEL, F_SDA_SEL, + F_BUSY, =20 /* keep last */ F_NUM_FIELDS @@ -256,7 +257,7 @@ static int rtl9300_i2c_do_xfer(struct rtl9300_i2c *i2c,= struct rtl9300_i2c_xfer if (ret) return ret; =20 - ret =3D regmap_field_read_poll_timeout(i2c->fields[F_I2C_TRIG], val, !val= , 100, 100000); + ret =3D regmap_field_read_poll_timeout(i2c->fields[F_BUSY], val, !val, 10= 0, 100000); if (ret) return ret; =20 @@ -493,6 +494,7 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_dr= v_data =3D { [F_MEM_ADDR_WIDTH] =3D MST_REG_FIELD(RTL9300_I2C_MST_CTRL2, 2, 3), [F_SCL_FREQ] =3D MST_REG_FIELD(RTL9300_I2C_MST_CTRL2, 0, 1), [F_SDA_SEL] =3D GLB_REG_FIELD(RTL9300_I2C_MST_GLB_CTRL, 0, 7), + [F_BUSY] =3D MST_REG_FIELD(RTL9300_I2C_MST_CTRL1, 0, 0), }, .select_scl =3D rtl9300_i2c_select_scl, .rd_reg =3D RTL9300_I2C_MST_DATA_WORD0, @@ -515,6 +517,7 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_dr= v_data =3D { [F_I2C_FAIL] =3D MST_REG_FIELD(RTL9310_I2C_MST_CTRL, 1, 1), [F_I2C_TRIG] =3D MST_REG_FIELD(RTL9310_I2C_MST_CTRL, 0, 0), [F_MEM_ADDR] =3D MST_REG_FIELD(RTL9310_I2C_MST_MEMADDR_CTRL, 0, 23), + [F_BUSY] =3D MST_REG_FIELD(RTL9310_I2C_MST_CTRL, 0, 0), }, .select_scl =3D rtl9310_i2c_select_scl, .rd_reg =3D RTL9310_I2C_MST_DATA_CTRL, --=20 2.53.0 From nobody Tue Apr 7 09:06:50 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 8570B3254B0; Sat, 14 Mar 2026 08:27:30 +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=1773476851; cv=none; b=afqQHI62B0+nkuGMOH6SRN/NgGZhHrexs4Gz9X1sYdxbg3mrsDvRGCoTnasrkDV7uo6CULNE8FekZtzQrpzTTO4odHLNm4Mf0o85jldCK0J676tu65ooh25u/GNMS2B97Qef6fMbTyv2Cw9N3Yj9GRQMm/z9vUCqNogAbt0AvHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476851; c=relaxed/simple; bh=ISobzOLBDX8Y/KPEvI4OJJUSbvCZl/pbZ6X4cIlFcOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tBoG8aVwjA6vVwzpQnB11xfq/9tmvqUw2gg4gr+yedp/vLyu/yF27C/JGJ0U+Fa93G26JUFTAuEsTsgssApzDUY1aD1E7SgOf1ZXhIgY8B6fhQGkyPQsp6HtWIOfjU3bVvErCCZ13c0AaaCe3mO6OMTFjXwBwajAFkfX5ofolh8= 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=gQuY6TwS; 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="gQuY6TwS" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3E5B6266BE; Sat, 14 Mar 2026 09:27:29 +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 tDO2-N1fd5dB; Sat, 14 Mar 2026 09:27:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476848; bh=ISobzOLBDX8Y/KPEvI4OJJUSbvCZl/pbZ6X4cIlFcOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gQuY6TwSO8SPkzlCz4X3H+GCCkz4AxTWYo07DtHOhppvo6rT6xt/31BPsvDAtHabj tUlCckxQ2LIUICevgT3bQMoYI7KbuasYSspU+g2hQgnVnvM78DdtM3Xf9HpvicJRdJ woKUJKGDTKXw0sKCQ+gj/mjfV6qRDEYT3mQBJIvYQMvbIwGxMc1FIKdY+lCGx7/KY7 UhG4vkrpJF86bDQ+yfjQUTlqkbaMEtnrVjYW7IzCPkKbtlFpae+osbiCbthckmgDUA zgTmtJrWkUZ7n8D1b/kI0H3ulz7Onl8f/Tj5BHmPrJeD47is0JZ6aPBAoTXUN91Fcy 8RWsnB7euXQGA== 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 4/8] i2c: rtl9300: introduce a property for 8 bit width reg address Date: Sat, 14 Mar 2026 13:26:24 +0500 Message-ID: <20260314082628.25206-5-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, in order to indicate that the width of memory address is 8 bits, 0 is written to MEM_ADDR_WIDTH field as opposed to 1 for RTL9300 and RTL9310. Introduce a new property to a driver data to indicate what value need to written to MEM_ADDR_WIDTH field for this case. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- drivers/i2c/busses/i2c-rtl9300.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index 2525b57a9d03..86a82f2c3ce0 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -60,6 +60,7 @@ struct rtl9300_i2c_drv_data { u32 wd_reg; u8 max_nchan; u8 max_data_len; + u8 reg_addr_8bit_len; }; =20 #define RTL9300_I2C_MUX_NCHAN 8 @@ -105,6 +106,7 @@ struct rtl9300_i2c_xfer { #define RTL9300_I2C_MST_DATA_WORD2 0x10 #define RTL9300_I2C_MST_DATA_WORD3 0x14 #define RTL9300_I2C_MST_GLB_CTRL 0x384 +#define RTL9300_REG_ADDR_8BIT_LEN 1 =20 #define RTL9310_I2C_MST_IF_CTRL 0x1004 #define RTL9310_I2C_MST_IF_SEL 0x1008 @@ -299,6 +301,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *a= dap, u16 addr, unsigned s union i2c_smbus_data *data) { struct rtl9300_i2c_chan *chan =3D i2c_get_adapdata(adap); + const struct rtl9300_i2c_drv_data *drv_data; struct rtl9300_i2c *i2c =3D chan->i2c; struct rtl9300_i2c_xfer xfer =3D {0}; int ret; @@ -308,6 +311,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *a= dap, u16 addr, unsigned s =20 guard(rtl9300_i2c)(i2c); =20 + drv_data =3D device_get_match_data(i2c->dev); ret =3D rtl9300_i2c_config_chan(i2c, chan); if (ret) return ret; @@ -315,7 +319,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *a= dap, u16 addr, unsigned s xfer.dev_addr =3D addr & 0x7f; xfer.write =3D (read_write =3D=3D I2C_SMBUS_WRITE); xfer.reg_addr =3D command; - xfer.reg_addr_len =3D 1; + xfer.reg_addr_len =3D drv_data->reg_addr_8bit_len; =20 switch (size) { case I2C_SMBUS_BYTE: @@ -501,6 +505,7 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_dr= v_data =3D { .wd_reg =3D RTL9300_I2C_MST_DATA_WORD0, .max_nchan =3D RTL9300_I2C_MUX_NCHAN, .max_data_len =3D RTL9300_I2C_MAX_DATA_LEN, + .reg_addr_8bit_len =3D RTL9300_REG_ADDR_8BIT_LEN, }; =20 static const struct rtl9300_i2c_drv_data rtl9310_i2c_drv_data =3D { @@ -524,6 +529,7 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_dr= v_data =3D { .wd_reg =3D RTL9310_I2C_MST_DATA_CTRL, .max_nchan =3D RTL9310_I2C_MUX_NCHAN, .max_data_len =3D RTL9300_I2C_MAX_DATA_LEN, + .reg_addr_8bit_len =3D RTL9300_REG_ADDR_8BIT_LEN, }; =20 static const struct of_device_id i2c_rtl9300_dt_ids[] =3D { --=20 2.53.0 From nobody Tue Apr 7 09:06:50 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 Reviewed-by: Chris Packham --- 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 From nobody Tue Apr 7 09:06:50 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 CB703328B58; Sat, 14 Mar 2026 08:27:35 +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=1773476857; cv=none; b=jQo5R09+E9lSQZECF2bRJobQbRUN4RdtsHJCOKBKPa70a0KmhExJPXHm5TDEzGtVD5HVYwSB2palzOGQvjKP8d8b3+Wa/quXp07sIToQoSreWek7VmoXAF8NQAvieYR0xqgrE8DLpYMZzxHUp3hRj0EngJGQ/KbEmEJFqquzUYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476857; c=relaxed/simple; bh=lCOQ/5uwRXCYRhEDsme1T7XbRj45JLsOUfdRHU+EZf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SAiikno5BX10m7MQh0d/6cMyimXahIHxUmEcdBdUPGb2NFw7IFWX/+SYqbuqzanWEamdmOHtXAHqVI4C6J8WWc/OcMJ3hNhgsHXIkiDNnhcMzIBXw2CSddGTkD8NZIWaThpe8QwtRJOM7zIAYegUzjPkoQ38Bjy4n5lHEVr7UEQ= 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=dOIfvNSp; 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="dOIfvNSp" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 9188D2676F; Sat, 14 Mar 2026 09:27:34 +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 lh7CBpE578WI; Sat, 14 Mar 2026 09:27:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476853; bh=lCOQ/5uwRXCYRhEDsme1T7XbRj45JLsOUfdRHU+EZf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dOIfvNSpxGYGGHe26NQ4cDeNUCfxs5dX+NGXCS5t0BUG0NolPx4QOYbiLqbqf1g/7 4KYwwHrU5Tt8aGG3fGoqjZh0/4G/iabfCCJ+x++21YuOvgwUXQSxFCpGOGtxIQbOjP GSwtr/j1/31koI1EHsc52M9Jl/hfyBOCb53WhWFmmipziNasTuhkFJpFWahrxFGvx1 QHAaDsNdc0E3hS3o5f6bbJh+mviAgimMl+a/NYpO8xrUX6mMTAbyVmgpITBWO9eNBe icnO1Lqlf7it2xsTS6NHbPghNB4gUpSFeICb2qsZPihUAsuyHNJ6mvazJyjXxKo0tT QQff+BR3tshsA== 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 6/8] i2c: rtl9300: intoduce new function properties to driver data Date: Sat, 14 Mar 2026 13:26:26 +0500 Message-ID: <20260314082628.25206-7-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" Due to the very nature of differences between RTL9607C i2c controller and RTL9300 / RTL9310 that are incompatible with each other in some areas of this driver, for example in clock configuration, channel configuration and initialization at the end of the probe, introduce new function properties to the driver data struct to handle those differences. With these new properties, create configuration functions for RTL9300 and RTL9310 and assign them to their respective driver data structs. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- drivers/i2c/busses/i2c-rtl9300.c | 54 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index 4953223ec97c..7930f47a37b2 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -59,6 +59,9 @@ enum rtl9300_i2c_reg_fields { struct rtl9300_i2c_drv_data { struct rtl9300_i2c_reg_field field_desc[F_NUM_FIELDS]; int (*select_scl)(struct rtl9300_i2c *i2c, u8 scl); + int (*config_chan)(struct rtl9300_i2c *i2c, struct rtl9300_i2c_chan *chan= ); + void (*config_clock)(u32 clock_freq, struct rtl9300_i2c_chan *chan); + int (*misc_init)(struct rtl9300_i2c *i2c); u32 rd_reg; u32 wd_reg; u8 max_nchan; @@ -169,6 +172,24 @@ static int rtl9300_i2c_config_chan(struct rtl9300_i2c = *i2c, struct rtl9300_i2c_c return 0; } =20 +static void rtl9300_i2c_config_clock(u32 clock_freq, struct rtl9300_i2c_ch= an *chan) +{ + struct rtl9300_i2c *i2c =3D chan->i2c; + + switch (clock_freq) { + case I2C_MAX_STANDARD_MODE_FREQ: + chan->bus_freq =3D RTL9300_I2C_STD_FREQ; + break; + case I2C_MAX_FAST_MODE_FREQ: + chan->bus_freq =3D RTL9300_I2C_FAST_FREQ; + break; + default: + dev_warn(i2c->dev, "SDA%d clock-frequency %d not supported using default= \n", + chan->sda_num, clock_freq); + break; + } +} + static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, u8 len) { u32 vals[4] =3D {}; @@ -316,7 +337,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *a= dap, u16 addr, unsigned s guard(rtl9300_i2c)(i2c); =20 drv_data =3D device_get_match_data(i2c->dev); - ret =3D rtl9300_i2c_config_chan(i2c, chan); + ret =3D drv_data->config_chan(i2c, chan); if (ret) return ret; =20 @@ -383,6 +404,12 @@ static struct i2c_adapter_quirks rtl9300_i2c_quirks = =3D { .max_write_len =3D 16, }; =20 +static int rtl9300_i2c_init(struct rtl9300_i2c *i2c) +{ + /* only use standard read format */ + return regmap_field_write(i2c->fields[F_RD_MODE], 0); +} + static int rtl9300_i2c_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -447,21 +474,11 @@ static int rtl9300_i2c_probe(struct platform_device *= pdev) if (ret) clock_freq =3D I2C_MAX_STANDARD_MODE_FREQ; =20 - switch (clock_freq) { - case I2C_MAX_STANDARD_MODE_FREQ: - chan->bus_freq =3D RTL9300_I2C_STD_FREQ; - break; - case I2C_MAX_FAST_MODE_FREQ: - chan->bus_freq =3D RTL9300_I2C_FAST_FREQ; - break; - default: - dev_warn(i2c->dev, "SDA%d clock-frequency %d not supported using defaul= t\n", - sda_num, clock_freq); - break; - } - chan->sda_num =3D sda_num; chan->i2c =3D i2c; + + drv_data->config_clock(clock_freq, chan); + adap =3D &i2c->chans[i].adap; adap->owner =3D THIS_MODULE; adap->algo =3D &rtl9300_i2c_algo; @@ -479,8 +496,7 @@ static int rtl9300_i2c_probe(struct platform_device *pd= ev) } i2c->sda_num =3D 0xff; =20 - /* only use standard read format */ - ret =3D regmap_field_write(i2c->fields[F_RD_MODE], 0); + ret =3D drv_data->misc_init(i2c); if (ret) return ret; =20 @@ -509,6 +525,9 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_dr= v_data =3D { [F_BUSY] =3D MST_REG_FIELD(RTL9300_I2C_MST_CTRL1, 0, 0), }, .select_scl =3D rtl9300_i2c_select_scl, + .config_chan =3D rtl9300_i2c_config_chan, + .config_clock =3D rtl9300_i2c_config_clock, + .misc_init =3D rtl9300_i2c_init, .rd_reg =3D RTL9300_I2C_MST_DATA_WORD0, .wd_reg =3D RTL9300_I2C_MST_DATA_WORD0, .max_nchan =3D RTL9300_I2C_MUX_NCHAN, @@ -533,6 +552,9 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_dr= v_data =3D { [F_BUSY] =3D MST_REG_FIELD(RTL9310_I2C_MST_CTRL, 0, 0), }, .select_scl =3D rtl9310_i2c_select_scl, + .config_chan =3D rtl9300_i2c_config_chan, + .config_clock =3D rtl9300_i2c_config_clock, + .misc_init =3D rtl9300_i2c_init, .rd_reg =3D RTL9310_I2C_MST_DATA_CTRL, .wd_reg =3D RTL9310_I2C_MST_DATA_CTRL, .max_nchan =3D RTL9310_I2C_MUX_NCHAN, --=20 2.53.0 From nobody Tue Apr 7 09:06:50 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 A0B4A3264EC; Sat, 14 Mar 2026 08:27:40 +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=1773476862; cv=none; b=dBClpxvhky1pztEtJXFlVBgZohA2V8pvMZo0IPFDFYrjSCLC3WtDeF+YKwuvcz6dr1OnlqLpJqYvsKoMyc2r7FL7dqJQULnvy5ioJeZ9DZd14fdZrwj16qucKlHbiWwqoHC2KNTcEye4lNsg/hSmDup4FUk5SlUa0l2iRSNuC/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476862; c=relaxed/simple; bh=oVRN2qK1k/0ayPkgo8ZxD9p66Q+kAPL1IgzI1uUl28A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qXDFqLmX5m9VQcFJ2/ck3bMPz9/9Q/y8vrBZAXRMkkUABkkbAloAZCLCm0BsCGe9GqUZox9lzEmZxzCIlR+nvwpGGRhJG9WkpB3R+POTeJ/YireUJ1TK14yKGafmmveDkq0jNM+RIJz+C3D4Z7ZhFoH05Z/7GvI1ZcK5s9aZy7Q= 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=SfhMHzNg; 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="SfhMHzNg" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 8839626F71; Sat, 14 Mar 2026 09:27:37 +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 PlNJVR06-Gx2; Sat, 14 Mar 2026 09:27:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476856; bh=oVRN2qK1k/0ayPkgo8ZxD9p66Q+kAPL1IgzI1uUl28A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SfhMHzNg6UzdKS3WRtJt7gNJIpdwPmOX3YKz5aWO8DnrPXQx1drveHitpWm8Lmv1G ID5dUE8Ekqp86zvZ2CF0mf5CywypMefxznqVMAHP/JRbt8UlJxw8FNa9kEAt/zdisC R205WCzXW0sZGfRTFqcctmzRQoD8n9cAZ5zO2LOTGAeYPxgNroU01gjHV/R7AIR1N5 8pKFnLIkkA9OGc+X5YPv3S4MAnDmDG47w7sycM/emnNG/QGtZUIp6MOpG4a+Cfwonb sTR8IxVKhuGz975kH7q+vzINltc3EET3J8qnGK7i6DRd/IwBzUnUb9lPmsBEQPwCEB o5vwnndgv4tJg== 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 7/8] dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9607C support Date: Sat, 14 Mar 2026 13:26:27 +0500 Message-ID: <20260314082628.25206-8-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" Add the "realtek,rtl9607-i2c" compatible for i2c controller on the RTL9607C SoC series. Add a clocks property to the properties since RTL9607C requires it along with the realtek,scl. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- .../bindings/i2c/realtek,rtl9301-i2c.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml= b/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml index f9a449fee2b0..5873cfdc5b3e 100644 --- a/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml +++ b/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml @@ -15,6 +15,8 @@ description: assigned to either I2C controller. RTL9310 SoCs have equal capabilities but support 12 common SDA lines whi= ch can be assigned to either I2C controller. + RTL9607C SoCs have equal capabilities but each controller only supports 1 + SCL/SDA line. =20 properties: compatible: @@ -34,6 +36,7 @@ properties: - enum: - realtek,rtl9301-i2c - realtek,rtl9310-i2c + - realtek,rtl9607-i2c =20 reg: items: @@ -51,6 +54,9 @@ properties: The SCL line number of this I2C controller. enum: [ 0, 1 ] =20 + clocks: + maxItems: 1 + patternProperties: '^i2c@[0-9ab]$': $ref: /schemas/i2c/i2c-controller.yaml @@ -81,6 +87,15 @@ allOf: then: patternProperties: '^i2c@[89ab]$': false + - if: + properties: + compatible: + contains: + const: realtek,rtl9607-i2c + then: + required: + - realtek,scl + - clocks =20 required: - compatible --=20 2.53.0 From nobody Tue Apr 7 09:06:50 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 573522DCC05; Sat, 14 Mar 2026 08:27:41 +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=1773476862; cv=none; b=Qvn+bPjWh67M/hLHBcm3i3hxG1lQyz1OQ7E5Q0ZTYgyR4r8OP2aQ4YbBTgRPix8P+BBvHTMxbZBp8+n9qASbePYcwlx01SRBnH5GooyqC02XnTysufOCu+UXgBq5E1XlZBMO1hNUQdhGOpEiuGpzg1qpQZP5VJyIrbUo6lOKmfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773476862; c=relaxed/simple; bh=KLpVO8hnVsxasYM9RKBW/SYpFjxwis+040wASje/CLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g5Qvy2/PcBLSBi0+G7UzxceADqkKP90W+WQGmZ5Szm2J1mPSqqjyVafhhZyzHrNfcK4lexbfdiI5DenJqg8lRdmMp7pr2ULPTXZ5S6MaSdAN3FqM8+pJYonjU1sdgRWxY5k4TsMJuZo7TW2Z7oKh1FH9pRrniNnjKZ7JPsyPopg= 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=JfgqtbQ3; 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="JfgqtbQ3" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 14EFC26F8F; Sat, 14 Mar 2026 09:27:40 +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 11275bj0QC-i; Sat, 14 Mar 2026 09:27:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1773476859; bh=KLpVO8hnVsxasYM9RKBW/SYpFjxwis+040wASje/CLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JfgqtbQ36632WyfYwN2yn/3HIDspHgjH6mrsFMyvN5ygLqocqcpjo2QzbV6H2cm2J o17vvYE+eH7mksdL/2c2HgCpNsg3+6A33pnGAExbJfOH572XvP/auVvXHGyZFN3rBg Iel9WdlTubNXUf4TyG1ePDS9HVSgTkxWecLtxgbsASvyi5xTbd5IxkfJgaYlUhLhGK ElSekQd6HmlmNdV0c/jScjzEkU4W/wNqsjGZdA0gBsH0yesz7V5nZb7RZ9VE9IoGA7 jkPl9eZ1CMwByHRexz8V81aHnSxdiS+4QYQSTJW0guB22u5725gzFq9UASX0WfY5g2 rwOW2gRWZ3Tkw== 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 8/8] i2c: rtl9300: add RTL9607C i2c controller support Date: Sat, 14 Mar 2026 13:26:28 +0500 Message-ID: <20260314082628.25206-9-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" Add support for the internal I2C controllers of RTL9607C series based SoCs. Add register definitions, chip-specific functions and macros too. Make use of the clk introduced from the previous patch to get the clk_div value and use it during the rtl9607c channel configuration. Introduce a new EXT_SCK_5MS field to the reg fields struct which is going to be initialized by rtl9607c init function at the end of the probe. This patch depends on all the previous patches in this patch series. Signed-off-by: Rustam Adilov Reviewed-by: Chris Packham --- drivers/i2c/busses/i2c-rtl9300.c | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9= 300.c index 7930f47a37b2..4ea9e0bade19 100644 --- a/drivers/i2c/busses/i2c-rtl9300.c +++ b/drivers/i2c/busses/i2c-rtl9300.c @@ -51,6 +51,7 @@ enum rtl9300_i2c_reg_fields { F_SDA_SEL, F_BUSY, F_CLK_DIV, + F_EXT_SCK_5MS, =20 /* keep last */ F_NUM_FIELDS @@ -71,8 +72,10 @@ struct rtl9300_i2c_drv_data { =20 #define RTL9300_I2C_MUX_NCHAN 8 #define RTL9310_I2C_MUX_NCHAN 12 +#define RTL9607_I2C_MUX_NCHAN 1 =20 #define RTL9300_I2C_MAX_DATA_LEN 16 +#define RTL9607_I2C_MAX_DATA_LEN 4 =20 struct rtl9300_i2c { struct regmap *regmap; @@ -121,6 +124,14 @@ struct rtl9300_i2c_xfer { #define RTL9310_I2C_MST_MEMADDR_CTRL 0x4 #define RTL9310_I2C_MST_DATA_CTRL 0x8 =20 +#define RTL9607_I2C_CONFIG 0x22f50 +#define RTL9607_IO_MODE_EN 0x23014 +#define RTL9607_I2C_IND_WD 0x0 +#define RTL9607_I2C_IND_ADR 0x8 +#define RTL9607_I2C_IND_CMD 0x10 +#define RTL9607_I2C_IND_RD 0x18 +#define RTL9607_REG_ADDR_8BIT_LEN 0 + static int rtl9300_i2c_reg_addr_set(struct rtl9300_i2c *i2c, u32 reg, u16 = len) { int ret; @@ -172,6 +183,27 @@ static int rtl9300_i2c_config_chan(struct rtl9300_i2c = *i2c, struct rtl9300_i2c_c return 0; } =20 +static int rtl9607_i2c_config_chan(struct rtl9300_i2c *i2c, struct rtl9300= _i2c_chan *chan) +{ + const struct rtl9300_i2c_drv_data *drv_data; + int ret; + + if (i2c->sda_num =3D=3D chan->sda_num) + return 0; + + ret =3D regmap_field_write(i2c->fields[F_CLK_DIV], chan->clk_div); + if (ret) + return ret; + + drv_data =3D device_get_match_data(i2c->dev); + ret =3D drv_data->select_scl(i2c, i2c->scl_num); + if (ret) + return ret; + + i2c->sda_num =3D chan->sda_num; + return 0; +} + static void rtl9300_i2c_config_clock(u32 clock_freq, struct rtl9300_i2c_ch= an *chan) { struct rtl9300_i2c *i2c =3D chan->i2c; @@ -190,6 +222,13 @@ static void rtl9300_i2c_config_clock(u32 clock_freq, s= truct rtl9300_i2c_chan *ch } } =20 +static void rtl9607_i2c_config_clock(u32 clock_freq, struct rtl9300_i2c_ch= an *chan) +{ + struct rtl9300_i2c *i2c =3D chan->i2c; + + chan->clk_div =3D clk_get_rate(i2c->clk) / clock_freq - 1; +} + static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, u8 len) { u32 vals[4] =3D {}; @@ -410,6 +449,11 @@ static int rtl9300_i2c_init(struct rtl9300_i2c *i2c) return regmap_field_write(i2c->fields[F_RD_MODE], 0); } =20 +static int rtl9607_i2c_init(struct rtl9300_i2c *i2c) +{ + return regmap_field_write(i2c->fields[F_EXT_SCK_5MS], 1); +} + static int rtl9300_i2c_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -562,6 +606,31 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_d= rv_data =3D { .reg_addr_8bit_len =3D RTL9300_REG_ADDR_8BIT_LEN, }; =20 +static const struct rtl9300_i2c_drv_data rtl9607_i2c_drv_data =3D { + .field_desc =3D { + [F_SCL_SEL] =3D GLB_REG_FIELD(RTL9607_IO_MODE_EN, 13, 14), + [F_EXT_SCK_5MS] =3D MST_REG_FIELD(RTL9607_I2C_CONFIG, 26, 26), + [F_DEV_ADDR] =3D MST_REG_FIELD(RTL9607_I2C_CONFIG, 14, 20), + [F_MEM_ADDR_WIDTH] =3D MST_REG_FIELD(RTL9607_I2C_CONFIG, 12, 13), + [F_DATA_WIDTH] =3D MST_REG_FIELD(RTL9607_I2C_CONFIG, 10, 11), + [F_CLK_DIV] =3D MST_REG_FIELD(RTL9607_I2C_CONFIG, 0, 9), + [F_I2C_FAIL] =3D MST_REG_FIELD(RTL9607_I2C_IND_CMD, 3, 3), + [F_BUSY] =3D MST_REG_FIELD(RTL9607_I2C_IND_CMD, 2, 2), + [F_RWOP] =3D MST_REG_FIELD(RTL9607_I2C_IND_CMD, 1, 1), + [F_I2C_TRIG] =3D MST_REG_FIELD(RTL9607_I2C_IND_CMD, 0, 0), + [F_MEM_ADDR] =3D MST_REG_FIELD(RTL9607_I2C_IND_ADR, 0, 31), + }, + .select_scl =3D rtl9310_i2c_select_scl, + .config_chan =3D rtl9607_i2c_config_chan, + .config_clock =3D rtl9607_i2c_config_clock, + .misc_init =3D rtl9607_i2c_init, + .rd_reg =3D RTL9607_I2C_IND_RD, + .wd_reg =3D RTL9607_I2C_IND_WD, + .max_nchan =3D RTL9607_I2C_MUX_NCHAN, + .max_data_len =3D RTL9607_I2C_MAX_DATA_LEN, + .reg_addr_8bit_len =3D RTL9607_REG_ADDR_8BIT_LEN, +}; + static const struct of_device_id i2c_rtl9300_dt_ids[] =3D { { .compatible =3D "realtek,rtl9301-i2c", .data =3D (void *) &rtl9300_i2c_= drv_data }, { .compatible =3D "realtek,rtl9302b-i2c", .data =3D (void *) &rtl9300_i2c= _drv_data }, @@ -571,6 +640,7 @@ static const struct of_device_id i2c_rtl9300_dt_ids[] = =3D { { .compatible =3D "realtek,rtl9311-i2c", .data =3D (void *) &rtl9310_i2c_= drv_data }, { .compatible =3D "realtek,rtl9312-i2c", .data =3D (void *) &rtl9310_i2c_= drv_data }, { .compatible =3D "realtek,rtl9313-i2c", .data =3D (void *) &rtl9310_i2c_= drv_data }, + { .compatible =3D "realtek,rtl9607-i2c", .data =3D (void *) &rtl9607_i2c_= drv_data }, {} }; MODULE_DEVICE_TABLE(of, i2c_rtl9300_dt_ids); --=20 2.53.0