]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: rtl93xx: replace pending I2C patches with upstreamed patches 20273/head
authorJonas Jelonek <jelonek.jonas@gmail.com>
Fri, 12 Sep 2025 19:33:18 +0000 (19:33 +0000)
committerRobert Marko <robimarko@gmail.com>
Thu, 2 Oct 2025 11:52:24 +0000 (13:52 +0200)
Replace the pending I2C backport patches for RTL93XX added in
44655c97bb with the upstreamed variants. The patches have been accepted
upstream in the meantime and are included in v6.17 or v6.18.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/20273
Signed-off-by: Robert Marko <robimarko@gmail.com>
20 files changed:
target/linux/realtek/patches-6.12/005-01-v6.17-i2c-rtl9300-Fix-out-of-bounds-bug-in-rtl9300_i2c_smb.patch [moved from target/linux/realtek/patches-6.12/100-01-i2c-rtl9300-Fix-out-of-bounds-bug-in-rtl9300_i2c_smb.patch with 62% similarity]
target/linux/realtek/patches-6.12/005-02-v6.17-i2c-rtl9300-Fix-multi-byte-I2C-write.patch [moved from target/linux/realtek/patches-6.12/100-02-i2c-rtl9300-Fix-multi-byte-I2C-write.patch with 81% similarity]
target/linux/realtek/patches-6.12/005-03-v6.17-i2c-rtl9300-Increase-timeout-for-transfer-polling.patch [moved from target/linux/realtek/patches-6.12/100-03-i2c-rtl9300-Increase-timeout-for-transfer-polling.patch with 70% similarity]
target/linux/realtek/patches-6.12/005-04-v6.17-i2c-rtl9300-Add-missing-count-byte-for-SMBus-Block-O.patch [moved from target/linux/realtek/patches-6.12/100-04-i2c-rtl9300-Add-missing-count-byte-for-SMBus-Block-O.patch with 73% similarity]
target/linux/realtek/patches-6.12/006-01-v6.17-i2c-rtl9300-fix-channel-number-bound-check.patch [new file with mode: 0644]
target/linux/realtek/patches-6.12/006-02-v6.17-i2c-rtl9300-ensure-data-length-is-within-supported-r.patch [new file with mode: 0644]
target/linux/realtek/patches-6.12/006-03-v6.17-i2c-rtl9300-remove-broken-SMBus-Quick-operation-supp.patch [moved from target/linux/realtek/patches-6.12/101-06-i2c-rtl9300-remove-SMBus-Quick-operation-support.patch with 57% similarity]
target/linux/realtek/patches-6.12/007-01-v6.17-i2c-rtl9300-Drop-unsupported-I2C_FUNC_SMBUS_I2C_BLOC.patch [new file with mode: 0644]
target/linux/realtek/patches-6.12/007-02-v6.18-i2c-rtl9300-Implement-I2C-block-read-and-write.patch [moved from target/linux/realtek/patches-6.12/100-05-i2c-rtl9300-Implement-I2C-block-read-and-write.patch with 75% similarity]
target/linux/realtek/patches-6.12/008-01-v6.18-i2c-rtl9300-use-regmap-fields-and-API-for-registers.patch [moved from target/linux/realtek/patches-6.12/101-01-i2c-rtl9300-use-regmap-fields-and-API-for-registe.patch with 89% similarity]
target/linux/realtek/patches-6.12/008-02-v6.18-dt-bindings-i2c-realtek-rtl9301-i2c-fix-wording-and-.patch [moved from target/linux/realtek/patches-6.12/101-03-dt-bindings-i2c-realtek-rtl9301-i2c-fix-wording-a.patch with 65% similarity]
target/linux/realtek/patches-6.12/008-03-v6.18-i2c-rtl9300-rename-internal-sda_pin-to-sda_num.patch [moved from target/linux/realtek/patches-6.12/101-04-i2c-rtl9300-rename-internal-sda_pin-to-sda_num.patch with 70% similarity]
target/linux/realtek/patches-6.12/008-04-v6.18-i2c-rtl9300-move-setting-SCL-frequency-to-config_io.patch [moved from target/linux/realtek/patches-6.12/101-07-i2c-rtl9300-move-setting-SCL-frequency-to-config_.patch with 63% similarity]
target/linux/realtek/patches-6.12/008-05-v6.18-i2c-rtl9300-do-not-set-read-mode-on-every-transfer.patch [moved from target/linux/realtek/patches-6.12/101-08-i2c-rtl9300-do-not-set-read-mode-on-every-transfe.patch with 56% similarity]
target/linux/realtek/patches-6.12/008-06-v6.18-i2c-rtl9300-separate-xfer-configuration-and-executio.patch [moved from target/linux/realtek/patches-6.12/101-09-i2c-rtl9300-separate-xfer-configuration-and-execu.patch with 90% similarity]
target/linux/realtek/patches-6.12/008-07-v6.18-i2c-rtl9300-use-scoped-guard-instead-of-explicit-loc.patch [new file with mode: 0644]
target/linux/realtek/patches-6.12/008-08-v6.18-dt-bindings-i2c-realtek-rtl9301-i2c-extend-for-RTL93.patch [moved from target/linux/realtek/patches-6.12/101-10-dt-bindings-i2c-realtek-rtl9301-i2c-extend-for-RT.patch with 69% similarity]
target/linux/realtek/patches-6.12/008-09-v6.18-i2c-rtl9300-add-support-for-RTL9310-I2C-controller.patch [moved from target/linux/realtek/patches-6.12/101-11-i2c-rtl9300-add-support-for-RTL9310-I2C-controlle.patch with 71% similarity]
target/linux/realtek/patches-6.12/101-02-i2c-rtl9300-fix-channel-number-bound-check.patch [deleted file]
target/linux/realtek/patches-6.12/101-05-i2c-rtl9300-check-if-xfer-length-is-valid.patch [deleted file]

similarity index 62%
rename from target/linux/realtek/patches-6.12/100-01-i2c-rtl9300-Fix-out-of-bounds-bug-in-rtl9300_i2c_smb.patch
rename to target/linux/realtek/patches-6.12/005-01-v6.17-i2c-rtl9300-Fix-out-of-bounds-bug-in-rtl9300_i2c_smb.patch
index 3caecdf9ab261410b9d8a26def4f3e846c7f9d68..98196db1206e344b6dfd0ab01bbb8c9eab78cf0c 100644 (file)
@@ -1,8 +1,7 @@
-From c8e44fae5b05528d4d672a935c8ace21eed8b8e7 Mon Sep 17 00:00:00 2001
+From 57f312b955938fc4663f430cb57a71f2414f601b Mon Sep 17 00:00:00 2001
 From: Alex Guo <alexguo1023@gmail.com>
-Date: Sat, 9 Aug 2025 08:40:54 +0200
-Subject: [PATCH 1/5] i2c: rtl9300: Fix out-of-bounds bug in
- rtl9300_i2c_smbus_xfer
+Date: Sun, 10 Aug 2025 20:05:13 +0200
+Subject: [PATCH] i2c: rtl9300: Fix out-of-bounds bug in rtl9300_i2c_smbus_xfer
 
 The data->block[0] variable comes from user. Without proper check,
 the variable may be very large to cause an out-of-bounds bug.
@@ -14,17 +13,21 @@ Fix this bug by checking the value of data->block[0] first.
 2. commit 92fbb6d1296f ("i2c: xgene-slimpro: Fix out-of-bounds bug in
    xgene_slimpro_i2c_xfer()")
 
-Cc: <stable@vger.kernel.org>
 Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
 Signed-off-by: Alex Guo <alexguo1023@gmail.com>
+Cc: <stable@vger.kernel.org> # v6.13+
 Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
 Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
 Signed-off-by: Sven Eckelmann <sven@narfation.org>
-Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-1-d71dd5eb6121@narfation.org/
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250810-i2c-rtl9300-multi-byte-v5-1-cd9dca0db722@narfation.org
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index e064e8a4a1f0..568495720810 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -281,6 +281,10 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -281,6 +281,10 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
                ret = rtl9300_i2c_reg_addr_set(i2c, command, 1);
                if (ret)
                        goto out_unlock;
@@ -35,3 +38,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-1-d71
                ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0]);
                if (ret)
                        goto out_unlock;
+-- 
+2.48.1
+
similarity index 81%
rename from target/linux/realtek/patches-6.12/100-02-i2c-rtl9300-Fix-multi-byte-I2C-write.patch
rename to target/linux/realtek/patches-6.12/005-02-v6.17-i2c-rtl9300-Fix-multi-byte-I2C-write.patch
index 4a8cdacdee35207a2b15f1b514d2701f46a487ba..7e60da6012ece2dd4e817fc3851c59f24e702576 100644 (file)
@@ -1,7 +1,7 @@
-From 0190fed3eed28be78717a0b45d7038c855e83b18 Mon Sep 17 00:00:00 2001
+From d67b740b9edfa46310355e2b68050f79ebf05a4c Mon Sep 17 00:00:00 2001
 From: Harshal Gohel <hg@simonwunderlich.de>
-Date: Sat, 9 Aug 2025 08:40:55 +0200
-Subject: [PATCH 2/5] i2c: rtl9300: Fix multi-byte I2C write
+Date: Sun, 10 Aug 2025 20:05:14 +0200
+Subject: [PATCH] i2c: rtl9300: Fix multi-byte I2C write
 
 The RTL93xx I2C controller has 4 32 bit registers to store the bytes for
 the upcoming I2C transmission. The first byte is stored in the
@@ -46,18 +46,21 @@ The second initialization (to 0) of vals was also be dropped because this
 array is initialized to 0 on the stack by using `= {};`. This makes the
 fix a lot more readable.
 
-Cc: <stable@vger.kernel.org>
 Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
 Signed-off-by: Harshal Gohel <hg@simonwunderlich.de>
+Cc: <stable@vger.kernel.org> # v6.13+
 Co-developed-by: Sven Eckelmann <sven@narfation.org>
 Signed-off-by: Sven Eckelmann <sven@narfation.org>
 Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
 Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
-Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-2-d71dd5eb6121@narfation.org/
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250810-i2c-rtl9300-multi-byte-v5-2-cd9dca0db722@narfation.org
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 568495720810..4a538b266080 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -143,10 +143,10 @@ static int rtl9300_i2c_write(struct rtl9
+@@ -143,10 +143,10 @@ static int rtl9300_i2c_write(struct rtl9300_i2c *i2c, u8 *buf, int len)
                return -EIO;
  
        for (i = 0; i < len; i++) {
@@ -72,3 +75,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-2-d71
        }
  
        return regmap_bulk_write(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_DATA_WORD0,
+-- 
+2.48.1
+
similarity index 70%
rename from target/linux/realtek/patches-6.12/100-03-i2c-rtl9300-Increase-timeout-for-transfer-polling.patch
rename to target/linux/realtek/patches-6.12/005-03-v6.17-i2c-rtl9300-Increase-timeout-for-transfer-polling.patch
index 7f0c440fd9fa62e74c34a72a3baf3fcdbf1c3e96..5bf9c8c22820916ec584a4837ae9b345ed5e4685 100644 (file)
@@ -1,7 +1,7 @@
-From 1757cce14242192be41819db4bc7b6b707d20b87 Mon Sep 17 00:00:00 2001
+From ceee7776c010c5f09d30985c9e5223b363a6172a Mon Sep 17 00:00:00 2001
 From: Sven Eckelmann <sven@narfation.org>
-Date: Sat, 9 Aug 2025 08:40:56 +0200
-Subject: [PATCH 3/5] i2c: rtl9300: Increase timeout for transfer polling
+Date: Sun, 10 Aug 2025 20:05:15 +0200
+Subject: [PATCH] i2c: rtl9300: Increase timeout for transfer polling
 
 The timeout for transfers was only set to 2ms. Because of this relatively
 low limit, 12-byte read operations to the frontend MCU of a RTL8239 POE PSE
@@ -16,16 +16,19 @@ management solution is possible.
 
 [1] https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/realtek/files-6.12/drivers/i2c/busses/i2c-rtl9300.c;h=c4d973195ef39dc56d6207e665d279745525fcac#l202
 
-Cc: <stable@vger.kernel.org>
 Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
 Signed-off-by: Sven Eckelmann <sven@narfation.org>
+Cc: <stable@vger.kernel.org> # v6.13+
 Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
 Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
-Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-3-d71dd5eb6121@narfation.org/
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250810-i2c-rtl9300-multi-byte-v5-3-cd9dca0db722@narfation.org
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 4a538b266080..4a282d57e2c1 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -175,7 +175,7 @@ static int rtl9300_i2c_execute_xfer(stru
+@@ -175,7 +175,7 @@ static int rtl9300_i2c_execute_xfer(struct rtl9300_i2c *i2c, char read_write,
                return ret;
  
        ret = regmap_read_poll_timeout(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_CTRL1,
@@ -34,3 +37,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-3-d71
        if (ret)
                return ret;
  
+-- 
+2.48.1
+
similarity index 73%
rename from target/linux/realtek/patches-6.12/100-04-i2c-rtl9300-Add-missing-count-byte-for-SMBus-Block-O.patch
rename to target/linux/realtek/patches-6.12/005-04-v6.17-i2c-rtl9300-Add-missing-count-byte-for-SMBus-Block-O.patch
index 31869ce854e5b1e11ae663986de79b67ec15acf4..c56fbb93c538557abbde6dc80f4696597e78a7a9 100644 (file)
@@ -1,7 +1,7 @@
-From ebc6d39a075f89ab3a7bb3cf011c5fbd555ab82b Mon Sep 17 00:00:00 2001
+From 82b350dd8185ce790e61555c436f90b6501af23c Mon Sep 17 00:00:00 2001
 From: Sven Eckelmann <sven@narfation.org>
-Date: Sat, 9 Aug 2025 08:40:57 +0200
-Subject: [PATCH 4/5] i2c: rtl9300: Add missing count byte for SMBus Block Ops
+Date: Sun, 10 Aug 2025 20:05:16 +0200
+Subject: [PATCH] i2c: rtl9300: Add missing count byte for SMBus Block Ops
 
 The expected on-wire format of an SMBus Block Write is
 
@@ -22,16 +22,19 @@ I2C controller is enough to fix the transmission.
 This also affects read because the I2C controller must receive the count
 byte + $count * data bytes.
 
-Cc: <stable@vger.kernel.org>
 Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
 Signed-off-by: Sven Eckelmann <sven@narfation.org>
+Cc: <stable@vger.kernel.org> # v6.13+
 Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
 Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
-Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-4-d71dd5eb6121@narfation.org/
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250810-i2c-rtl9300-multi-byte-v5-4-cd9dca0db722@narfation.org
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 4a282d57e2c1..cfafe089102a 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -285,15 +285,15 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -285,15 +285,15 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
                        ret = -EINVAL;
                        goto out_unlock;
                }
@@ -50,3 +53,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-4-d71
                break;
  
        default:
+-- 
+2.48.1
+
diff --git a/target/linux/realtek/patches-6.12/006-01-v6.17-i2c-rtl9300-fix-channel-number-bound-check.patch b/target/linux/realtek/patches-6.12/006-01-v6.17-i2c-rtl9300-fix-channel-number-bound-check.patch
new file mode 100644 (file)
index 0000000..662af6c
--- /dev/null
@@ -0,0 +1,45 @@
+From cd6c956fbc13156bcbcca084b46a8380caebc2a8 Mon Sep 17 00:00:00 2001
+From: Jonas Jelonek <jelonek.jonas@gmail.com>
+Date: Sun, 31 Aug 2025 10:04:46 +0000
+Subject: [PATCH] i2c: rtl9300: fix channel number bound check
+
+Fix the current check for number of channels (child nodes in the device
+tree). Before, this was:
+
+if (device_get_child_node_count(dev) >= RTL9300_I2C_MUX_NCHAN)
+
+RTL9300_I2C_MUX_NCHAN gives the maximum number of channels so checking
+with '>=' isn't correct because it doesn't allow the last channel
+number. Thus, fix it to:
+
+if (device_get_child_node_count(dev) > RTL9300_I2C_MUX_NCHAN)
+
+Issue occured on a TP-Link TL-ST1008F v2.0 device (8 SFP+ ports) and fix
+is tested there.
+
+Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
+Cc: stable@vger.kernel.org # v6.13+
+Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250831100457.3114-2-jelonek.jonas@gmail.com
+
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index cfafe089102a..1a63790f1957 100644
+--- a/drivers/i2c/busses/i2c-rtl9300.c
++++ b/drivers/i2c/busses/i2c-rtl9300.c
+@@ -353,7 +353,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
+       platform_set_drvdata(pdev, i2c);
+-      if (device_get_child_node_count(dev) >= RTL9300_I2C_MUX_NCHAN)
++      if (device_get_child_node_count(dev) > RTL9300_I2C_MUX_NCHAN)
+               return dev_err_probe(dev, -EINVAL, "Too many channels\n");
+       device_for_each_child_node(dev, child) {
+-- 
+2.48.1
+
diff --git a/target/linux/realtek/patches-6.12/006-02-v6.17-i2c-rtl9300-ensure-data-length-is-within-supported-r.patch b/target/linux/realtek/patches-6.12/006-02-v6.17-i2c-rtl9300-ensure-data-length-is-within-supported-r.patch
new file mode 100644 (file)
index 0000000..f83f5de
--- /dev/null
@@ -0,0 +1,66 @@
+From 06418cb5a1a542a003fdb4ad8e76ea542d57cfba Mon Sep 17 00:00:00 2001
+From: Jonas Jelonek <jelonek.jonas@gmail.com>
+Date: Sun, 31 Aug 2025 10:04:47 +0000
+Subject: [PATCH] i2c: rtl9300: ensure data length is within supported range
+
+Add an explicit check for the xfer length to 'rtl9300_i2c_config_xfer'
+to ensure the data length isn't within the supported range. In
+particular a data length of 0 is not supported by the hardware and
+causes unintended or destructive behaviour.
+
+This limitation becomes obvious when looking at the register
+documentation [1]. 4 bits are reserved for DATA_WIDTH and the value
+of these 4 bits is used as N + 1, allowing a data length range of
+1 <= len <= 16.
+
+Affected by this is the SMBus Quick Operation which works with a data
+length of 0. Passing 0 as the length causes an underflow of the value
+due to:
+
+(len - 1) & 0xf
+
+and effectively specifying a transfer length of 16 via the registers.
+This causes a 16-byte write operation instead of a Quick Write. For
+example, on SFP modules without write-protected EEPROM this soft-bricks
+them by overwriting some initial bytes.
+
+For completeness, also add a quirk for the zero length.
+
+[1] https://svanheule.net/realtek/longan/register/i2c_mst1_ctrl2
+
+Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
+Cc: stable@vger.kernel.org # v6.13+
+Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250831100457.3114-3-jelonek.jonas@gmail.com
+
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 1a63790f1957..2b3e80aa1bdf 100644
+--- a/drivers/i2c/busses/i2c-rtl9300.c
++++ b/drivers/i2c/busses/i2c-rtl9300.c
+@@ -99,6 +99,9 @@ static int rtl9300_i2c_config_xfer(struct rtl9300_i2c *i2c, struct rtl9300_i2c_c
+ {
+       u32 val, mask;
++      if (len < 1 || len > 16)
++              return -EINVAL;
++
+       val = chan->bus_freq << RTL9300_I2C_MST_CTRL2_SCL_FREQ_OFS;
+       mask = RTL9300_I2C_MST_CTRL2_SCL_FREQ_MASK;
+@@ -323,7 +326,7 @@ static const struct i2c_algorithm rtl9300_i2c_algo = {
+ };
+ static struct i2c_adapter_quirks rtl9300_i2c_quirks = {
+-      .flags          = I2C_AQ_NO_CLK_STRETCH,
++      .flags          = I2C_AQ_NO_CLK_STRETCH | I2C_AQ_NO_ZERO_LEN,
+       .max_read_len   = 16,
+       .max_write_len  = 16,
+ };
+-- 
+2.48.1
+
similarity index 57%
rename from target/linux/realtek/patches-6.12/101-06-i2c-rtl9300-remove-SMBus-Quick-operation-support.patch
rename to target/linux/realtek/patches-6.12/006-03-v6.17-i2c-rtl9300-remove-broken-SMBus-Quick-operation-supp.patch
index 718dcfa51a3e054fc5ef560374a01332e703c72c..dc5360e63d0b830642b3590faca7e77a3e4ced5a 100644 (file)
@@ -1,7 +1,7 @@
-From cee289c080977752b485dc41a5fbc53c5af93aa9 Mon Sep 17 00:00:00 2001
+From ede965fd555ac2536cf651893a998dbfd8e57b86 Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Tue, 5 Aug 2025 09:14:51 +0000
-Subject: [PATCH v5 06/11] i2c: rtl9300: remove SMBus Quick operation support
+Date: Sun, 31 Aug 2025 10:04:48 +0000
+Subject: [PATCH] i2c: rtl9300: remove broken SMBus Quick operation support
 
 Remove the SMBus Quick operation from this driver because it is not
 natively supported by the hardware and is wrongly implemented in the
@@ -20,30 +20,35 @@ The current implementation of SMBus Quick operation passes a length of
 commit, this led to a read operation of 16 bytes from any register (the
 one of a former transaction or any other value.
 
-Although there are currently no reports of actual issues this caused.
-However, as an example, i2cdetect by default uses Quick Write operation
-to probe the bus and this may already write anything to some register
-of a device, causing unintended behaviour. This could be the cause of a
-recent brick of one of my DAC cables where there was a checksum mismatch
-of the EEPROM after having run 'i2cdetect -l' before.
+This caused issues like soft-bricked SFP modules after a simple probe
+with i2cdetect which uses Quick by default. Running this with SFP
+modules whose EEPROM isn't write-protected, some of the initial bytes
+are overwritten because a 16-byte write operation is executed instead of
+a Quick Write. (This temporarily soft-bricked one of my DAC cables.)
 
 Because SMBus Quick operation is obviously not supported on these
 controllers (because a length of 0 cannot be set, even when no register
 address is set), remove that instead of claiming there is support. There
 also shouldn't be any kind of emulated 'Quick' which just does another
-kind of operation in the background. Otherwise, specific issues may
-occur in case of a 'Quick' Write which writes unknown data to an unknown
-register.
+kind of operation in the background. Otherwise, specific issues occur
+in case of a 'Quick' Write which actually writes unknown data to an
+unknown register.
 
+Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
+Cc: stable@vger.kernel.org # v6.13+
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-7-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 16 +++-------------
- 1 file changed, 3 insertions(+), 13 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250831100457.3114-4-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 2b3e80aa1bdf..9e1f71fed0fe 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -251,15 +251,6 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -225,15 +225,6 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
        }
  
        switch (size) {
@@ -59,17 +64,19 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-7-jelonek.jonas@g
        case I2C_SMBUS_BYTE:
                if (read_write == I2C_SMBUS_WRITE) {
                        ret = rtl9300_i2c_config_xfer(i2c, chan, addr, 0);
-@@ -360,10 +351,9 @@ out_unlock:
+@@ -315,9 +306,9 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
  
  static u32 rtl9300_i2c_func(struct i2c_adapter *a)
  {
 -      return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
 -             I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
--             I2C_FUNC_SMBUS_READ_I2C_BLOCK | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
 -             I2C_FUNC_SMBUS_BLOCK_DATA;
 +      return I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
-+             I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_READ_I2C_BLOCK |
-+             I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | I2C_FUNC_SMBUS_BLOCK_DATA;
++             I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA |
++             I2C_FUNC_SMBUS_I2C_BLOCK;
  }
  
  static const struct i2c_algorithm rtl9300_i2c_algo = {
+-- 
+2.48.1
+
diff --git a/target/linux/realtek/patches-6.12/007-01-v6.17-i2c-rtl9300-Drop-unsupported-I2C_FUNC_SMBUS_I2C_BLOC.patch b/target/linux/realtek/patches-6.12/007-01-v6.17-i2c-rtl9300-Drop-unsupported-I2C_FUNC_SMBUS_I2C_BLOC.patch
new file mode 100644 (file)
index 0000000..5c70430
--- /dev/null
@@ -0,0 +1,31 @@
+From 095530512152e6811278de9c30f170f0ac9705eb Mon Sep 17 00:00:00 2001
+From: Sven Eckelmann <sven@narfation.org>
+Date: Sat, 27 Sep 2025 11:52:16 +0200
+Subject: [PATCH] i2c: rtl9300: Drop unsupported I2C_FUNC_SMBUS_I2C_BLOCK
+
+While applying the patch for commit ede965fd555a ("i2c: rtl9300: remove
+broken SMBus Quick operation support"), a conflict was incorrectly solved
+by adding the I2C_FUNC_SMBUS_I2C_BLOCK feature flag. But the code to handle
+I2C_SMBUS_I2C_BLOCK_DATA requests will be added by a separate commit.
+
+Fixes: ede965fd555a ("i2c: rtl9300: remove broken SMBus Quick operation support")
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
+
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 9e1f71fed0fe..af991b28e4f8 100644
+--- a/drivers/i2c/busses/i2c-rtl9300.c
++++ b/drivers/i2c/busses/i2c-rtl9300.c
+@@ -307,8 +307,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
+ static u32 rtl9300_i2c_func(struct i2c_adapter *a)
+ {
+       return I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
+-             I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA |
+-             I2C_FUNC_SMBUS_I2C_BLOCK;
++             I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA;
+ }
+ static const struct i2c_algorithm rtl9300_i2c_algo = {
+-- 
+2.48.1
+
similarity index 75%
rename from target/linux/realtek/patches-6.12/100-05-i2c-rtl9300-Implement-I2C-block-read-and-write.patch
rename to target/linux/realtek/patches-6.12/007-02-v6.18-i2c-rtl9300-Implement-I2C-block-read-and-write.patch
index c2e6b333ea18560bdbcc13d8dadcc6ed93f6f3e0..490f5df795ce5b7fe923f1c78155c9795ed5cf63 100644 (file)
@@ -1,7 +1,7 @@
-From 1bd7526db1cf9d5c6a700c37b8bf915f8ff72c44 Mon Sep 17 00:00:00 2001
+From 415216ae3196e67bdb9515519f219d553bd38d3a Mon Sep 17 00:00:00 2001
 From: Harshal Gohel <hg@simonwunderlich.de>
-Date: Sat, 9 Aug 2025 08:40:58 +0200
-Subject: [PATCH 5/5] i2c: rtl9300: Implement I2C block read and write
+Date: Sat, 27 Sep 2025 11:52:17 +0200
+Subject: [PATCH] i2c: rtl9300: Implement I2C block read and write
 
 It was noticed that the original implementation of SMBus Block Write in the
 driver was actually an I2C Block Write. Both differ only in the Count byte
@@ -40,11 +40,14 @@ Co-developed-by: Sven Eckelmann <sven@narfation.org>
 Signed-off-by: Sven Eckelmann <sven@narfation.org>
 Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
 Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
-Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-5-d71dd5eb6121@narfation.org/
+Reviewed-by: Jonas Jelonek <jelonek.jonas@gmail.com>
+Tested-by: Jonas Jelonek <jelonek.jonas@gmail.com>
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index af991b28e4f8..9e6232075137 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -183,22 +183,32 @@ static int rtl9300_i2c_execute_xfer(stru
+@@ -186,22 +186,32 @@ static int rtl9300_i2c_execute_xfer(struct rtl9300_i2c *i2c, char read_write,
                return -EIO;
  
        if (read_write == I2C_SMBUS_READ) {
@@ -80,7 +83,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-5-d71
                }
        }
  
-@@ -296,6 +306,25 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -290,6 +300,25 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
                len = data->block[0] + 1;
                break;
  
@@ -106,11 +109,16 @@ Link: https://lore.kernel.org/linux-i2c/20250809-i2c-rtl9300-multi-byte-v4-5-d71
        default:
                dev_err(&adap->dev, "Unsupported transaction %d\n", size);
                ret = -EOPNOTSUPP;
-@@ -314,6 +343,7 @@ static u32 rtl9300_i2c_func(struct i2c_a
+@@ -307,7 +336,8 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
+ static u32 rtl9300_i2c_func(struct i2c_adapter *a)
  {
-       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
-              I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
-+             I2C_FUNC_SMBUS_READ_I2C_BLOCK | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
-              I2C_FUNC_SMBUS_BLOCK_DATA;
+       return I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
+-             I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA;
++             I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA |
++             I2C_FUNC_SMBUS_I2C_BLOCK;
  }
  
+ static const struct i2c_algorithm rtl9300_i2c_algo = {
+-- 
+2.48.1
+
similarity index 89%
rename from target/linux/realtek/patches-6.12/101-01-i2c-rtl9300-use-regmap-fields-and-API-for-registe.patch
rename to target/linux/realtek/patches-6.12/008-01-v6.18-i2c-rtl9300-use-regmap-fields-and-API-for-registers.patch
index 629279348314052d83c9b34382980e16d6ede244..92292d7d63f0f530aeca53625ea7f83be002ded8 100644 (file)
@@ -1,8 +1,7 @@
-From 055c2659011812c1abbd879ce80b2342e4d93576 Mon Sep 17 00:00:00 2001
+From 5a6ecb27435ef7a67d7bec4543f0c6303f34e8a6 Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Mon, 30 Jun 2025 15:37:06 +0000
-Subject: [PATCH v5 01/11] i2c: rtl9300: use regmap fields and API for
- registers
+Date: Sat, 27 Sep 2025 10:19:23 +0000
+Subject: [PATCH] i2c: rtl9300: use regmap fields and API for registers
 
 Adapt the RTL9300 I2C controller driver to use more of the regmap
 API, especially make use of reg_field and regmap_field instead of macros
@@ -19,17 +18,19 @@ differences between specific revisions within a series. Just by
 defining a separate driver data structure with the corresponding
 register field definitions and linking it to a new compatible.
 
-Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
-Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302c
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 192 ++++++++++++++++++++-----------
- 1 file changed, 124 insertions(+), 68 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-2-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 9e6232075137..8483bab72146 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -23,94 +23,114 @@ struct rtl9300_i2c_chan {
+@@ -23,97 +23,117 @@ struct rtl9300_i2c_chan {
        u8 sda_pin;
  };
  
@@ -159,11 +160,14 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
                                   u16 addr, u16 len)
  {
 -      u32 val, mask;
--
--      val = chan->bus_freq << RTL9300_I2C_MST_CTRL2_SCL_FREQ_OFS;
--      mask = RTL9300_I2C_MST_CTRL2_SCL_FREQ_MASK;
 +      int ret;
  
+       if (len < 1 || len > 16)
+               return -EINVAL;
+-      val = chan->bus_freq << RTL9300_I2C_MST_CTRL2_SCL_FREQ_OFS;
+-      mask = RTL9300_I2C_MST_CTRL2_SCL_FREQ_MASK;
+-
 -      val |= addr << RTL9300_I2C_MST_CTRL2_DEV_ADDR_OFS;
 -      mask |= RTL9300_I2C_MST_CTRL2_DEV_ADDR_MASK;
 +      ret = regmap_field_write(i2c->fields[F_SCL_FREQ], chan->bus_freq);
@@ -186,7 +190,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
  }
  
  static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, int len)
-@@ -121,8 +141,7 @@ static int rtl9300_i2c_read(struct rtl93
+@@ -124,8 +144,7 @@ static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, int len)
        if (len > 16)
                return -EIO;
  
@@ -196,7 +200,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
        if (ret)
                return ret;
  
-@@ -149,52 +168,49 @@ static int rtl9300_i2c_write(struct rtl9
+@@ -152,52 +171,49 @@ static int rtl9300_i2c_write(struct rtl9300_i2c *i2c, u8 *buf, int len)
                vals[reg] |= buf[i] << shift;
        }
  
@@ -263,7 +267,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
                        if (ret)
                                return ret;
                        data->word = val & 0xffff;
-@@ -362,9 +378,11 @@ static int rtl9300_i2c_probe(struct plat
+@@ -355,9 +371,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
  {
        struct device *dev = &pdev->dev;
        struct rtl9300_i2c *i2c;
@@ -276,13 +280,13 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
  
        i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
        if (!i2c)
-@@ -383,9 +401,22 @@ static int rtl9300_i2c_probe(struct plat
+@@ -376,9 +394,22 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
  
        platform_set_drvdata(pdev, i2c);
  
--      if (device_get_child_node_count(dev) >= RTL9300_I2C_MUX_NCHAN)
+-      if (device_get_child_node_count(dev) > RTL9300_I2C_MUX_NCHAN)
 +      drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev);
-+      if (device_get_child_node_count(dev) >= drv_data->max_nchan)
++      if (device_get_child_node_count(dev) > drv_data->max_nchan)
                return dev_err_probe(dev, -EINVAL, "Too many channels\n");
  
 +      i2c->data_reg = i2c->reg_base + drv_data->data_reg;
@@ -300,7 +304,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
        device_for_each_child_node(dev, child) {
                struct rtl9300_i2c_chan *chan = &i2c->chans[i];
                struct i2c_adapter *adap = &chan->adap;
-@@ -402,7 +433,6 @@ static int rtl9300_i2c_probe(struct plat
+@@ -395,7 +426,6 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
                case I2C_MAX_STANDARD_MODE_FREQ:
                        chan->bus_freq = RTL9300_I2C_STD_FREQ;
                        break;
@@ -308,7 +312,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
                case I2C_MAX_FAST_MODE_FREQ:
                        chan->bus_freq = RTL9300_I2C_FAST_FREQ;
                        break;
-@@ -434,11 +464,37 @@ static int rtl9300_i2c_probe(struct plat
+@@ -427,11 +457,37 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
        return 0;
  }
  
@@ -350,3 +354,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-2-jelonek.jonas@g
        {}
  };
  MODULE_DEVICE_TABLE(of, i2c_rtl9300_dt_ids);
+-- 
+2.48.1
+
similarity index 65%
rename from target/linux/realtek/patches-6.12/101-03-dt-bindings-i2c-realtek-rtl9301-i2c-fix-wording-a.patch
rename to target/linux/realtek/patches-6.12/008-02-v6.18-dt-bindings-i2c-realtek-rtl9301-i2c-fix-wording-and-.patch
index d4b58bc0e19bc7dc8035fbd7b65f864824e480b7..a94c02e3efb7da3e834ca8698a175525c376270d 100644 (file)
@@ -1,8 +1,7 @@
-From 7bb38428b718a281e09b35bc26478600b53300fc Mon Sep 17 00:00:00 2001
+From 80f3e37d5e734bbfe891592bb669ceb5e8b314dc Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Mon, 4 Aug 2025 10:26:35 +0000
-Subject: [PATCH v5 03/11] dt-bindings: i2c: realtek,rtl9301-i2c: fix wording
- and typos
+Date: Sat, 27 Sep 2025 10:19:24 +0000
+Subject: [PATCH] dt-bindings: i2c: realtek,rtl9301-i2c: fix wording and typos
 
 Fix wording of binding description to use plural because there is not
 only a single RTL9300 SoC. RTL9300 describes a whole family of Realtek
@@ -14,11 +13,15 @@ Change 'SDA pin' to 'SDA line number' because the property must contain
 the SDA (channel) number ranging from 0-7 instead of a real pin number.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-4-jelonek.jonas@gmail.com/
----
- .../devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml        | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
+Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-3-jelonek.jonas@gmail.com
 
+diff --git a/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml b/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml
+index 69ac5db8b914..274e2ab8b612 100644
 --- a/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml
 +++ b/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml
 @@ -10,7 +10,7 @@ maintainers:
@@ -48,3 +51,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-4-jelonek.jonas@g
          maxItems: 1
  
      required:
+-- 
+2.48.1
+
similarity index 70%
rename from target/linux/realtek/patches-6.12/101-04-i2c-rtl9300-rename-internal-sda_pin-to-sda_num.patch
rename to target/linux/realtek/patches-6.12/008-03-v6.18-i2c-rtl9300-rename-internal-sda_pin-to-sda_num.patch
index efc3ecb16baeb7ddb37247aff82c6c84964b9982..0983b358b20f25951224ab8c8bbe689c2ec43d8b 100644 (file)
@@ -1,7 +1,7 @@
-From bccfb0e2a337529d07134e52ca3e2ec1c156bd7d Mon Sep 17 00:00:00 2001
+From 8ff3819d7edcd56e4c533b9391a156cd607048fa Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Mon, 4 Aug 2025 11:27:57 +0000
-Subject: [PATCH v5 04/11] i2c: rtl9300: rename internal sda_pin to sda_num
+Date: Sat, 27 Sep 2025 10:19:25 +0000
+Subject: [PATCH] i2c: rtl9300: rename internal sda_pin to sda_num
 
 Rename the internally used 'sda_pin' to 'sda_num' to make it clear that
 this is NOT the actual pin number of the GPIO pin but rather the logical
@@ -12,11 +12,15 @@ confusion or misconfiguration by giving the variable the correct name.
 This follows the description change in the devicetree bindings.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 24 ++++++++++++------------
- 1 file changed, 12 insertions(+), 12 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-4-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 8483bab72146..f9b5ac7670c2 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
 @@ -20,7 +20,7 @@ struct rtl9300_i2c_chan {
@@ -37,7 +41,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
        struct mutex lock;
  };
  
-@@ -102,11 +102,11 @@ static int rtl9300_i2c_config_io(struct
+@@ -102,11 +102,11 @@ static int rtl9300_i2c_config_io(struct rtl9300_i2c *i2c, u8 sda_pin)
  
        drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev);
  
@@ -51,7 +55,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
        if (ret)
                return ret;
  
-@@ -240,11 +240,11 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -243,11 +243,11 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
        int len = 0, ret;
  
        mutex_lock(&i2c->lock);
@@ -65,7 +69,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
        }
  
        switch (size) {
-@@ -381,7 +381,7 @@ static int rtl9300_i2c_probe(struct plat
+@@ -374,7 +374,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
        struct fwnode_handle *child;
        struct rtl9300_i2c_drv_data *drv_data;
        struct reg_field fields[F_NUM_FIELDS];
@@ -74,7 +78,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
        int ret, i = 0;
  
        i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
-@@ -421,7 +421,7 @@ static int rtl9300_i2c_probe(struct plat
+@@ -414,7 +414,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
                struct rtl9300_i2c_chan *chan = &i2c->chans[i];
                struct i2c_adapter *adap = &chan->adap;
  
@@ -83,7 +87,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
                if (ret)
                        return ret;
  
-@@ -438,11 +438,11 @@ static int rtl9300_i2c_probe(struct plat
+@@ -431,11 +431,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
                        break;
                default:
                        dev_warn(i2c->dev, "SDA%d clock-frequency %d not supported using default\n",
@@ -97,7 +101,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
                chan->i2c = i2c;
                adap = &i2c->chans[i].adap;
                adap->owner = THIS_MODULE;
-@@ -452,14 +452,14 @@ static int rtl9300_i2c_probe(struct plat
+@@ -445,14 +445,14 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
                adap->dev.parent = dev;
                i2c_set_adapdata(adap, chan);
                adap->dev.of_node = to_of_node(child);
@@ -114,3 +118,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-5-jelonek.jonas@g
  
        return 0;
  }
+-- 
+2.48.1
+
similarity index 63%
rename from target/linux/realtek/patches-6.12/101-07-i2c-rtl9300-move-setting-SCL-frequency-to-config_.patch
rename to target/linux/realtek/patches-6.12/008-04-v6.18-i2c-rtl9300-move-setting-SCL-frequency-to-config_io.patch
index feb9949c09c07fed1f7b588e022ec18a22c416ef..4403d99d9f32b27bab9d7282fa3d395e7722d9d9 100644 (file)
@@ -1,8 +1,7 @@
-From c64be5e5ee6326ca7ec38dbcc8892254f1da3cf8 Mon Sep 17 00:00:00 2001
+From 6b0549abc8582a81425f89a436def8e28d8d7dce Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Fri, 1 Aug 2025 21:18:56 +0000
-Subject: [PATCH v5 07/11] i2c: rtl9300: move setting SCL frequency to
- config_io
+Date: Sat, 27 Sep 2025 10:19:26 +0000
+Subject: [PATCH] i2c: rtl9300: move setting SCL frequency to config_io
 
 Move the register operation to set the SCL frequency to the
 rtl9300_i2c_config_io function instead of the rtl9300_i2c_config_xfer
@@ -10,14 +9,18 @@ function. This rather belongs there next to selecting the current SDA
 output line.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-8-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 17 +++++++++--------
- 1 file changed, 9 insertions(+), 8 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-5-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index f9b5ac7670c2..4177cfb77094 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -95,18 +95,23 @@ static int rtl9300_i2c_select_scl(struct
+@@ -95,18 +95,23 @@ static int rtl9300_i2c_select_scl(struct rtl9300_i2c *i2c, u8 scl)
        return regmap_field_write(i2c->fields[F_SCL_SEL], 1);
  }
  
@@ -44,7 +47,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-8-jelonek.jonas@g
        if (ret)
                return ret;
  
-@@ -121,10 +126,6 @@ static int rtl9300_i2c_config_xfer(struc
+@@ -121,10 +126,6 @@ static int rtl9300_i2c_config_xfer(struct rtl9300_i2c *i2c, struct rtl9300_i2c_c
        if (len < 1 || len > 16)
                return -EINVAL;
  
@@ -55,7 +58,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-8-jelonek.jonas@g
        ret = regmap_field_write(i2c->fields[F_DEV_ADDR], addr);
        if (ret)
                return ret;
-@@ -244,7 +245,7 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -244,7 +245,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
  
        mutex_lock(&i2c->lock);
        if (chan->sda_num != i2c->sda_num) {
@@ -64,3 +67,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-8-jelonek.jonas@g
                if (ret)
                        goto out_unlock;
                i2c->sda_num = chan->sda_num;
+-- 
+2.48.1
+
similarity index 56%
rename from target/linux/realtek/patches-6.12/101-08-i2c-rtl9300-do-not-set-read-mode-on-every-transfe.patch
rename to target/linux/realtek/patches-6.12/008-05-v6.18-i2c-rtl9300-do-not-set-read-mode-on-every-transfer.patch
index b06719608daa87dd676f1c10c4ba76756537f8df..3cc90210f27ce890105ee8f5db3cb0e33d19cc7f 100644 (file)
@@ -1,7 +1,7 @@
-From bd70c2680786f3b1def31285ad5114f17e381b3a Mon Sep 17 00:00:00 2001
+From 0cb24186d0ebd7dd12c070fed9d782bf7c6dfb1e Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Fri, 1 Aug 2025 21:31:09 +0000
-Subject: [PATCH v5 08/11] i2c: rtl9300: do not set read mode on every transfer
+Date: Sat, 27 Sep 2025 10:19:27 +0000
+Subject: [PATCH] i2c: rtl9300: do not set read mode on every transfer
 
 Move the operation to set the read mode from config_xfer to probe.
 
@@ -13,14 +13,18 @@ in setting this on every transaction. Setting this once in the probe
 call is sufficient.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-9-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 11 ++++++-----
- 1 file changed, 6 insertions(+), 5 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-6-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 4177cfb77094..9e3517b09b3d 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -130,11 +130,7 @@ static int rtl9300_i2c_config_xfer(struc
+@@ -130,11 +130,7 @@ static int rtl9300_i2c_config_xfer(struct rtl9300_i2c *i2c, struct rtl9300_i2c_c
        if (ret)
                return ret;
  
@@ -33,7 +37,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-9-jelonek.jonas@g
  }
  
  static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, int len)
-@@ -455,6 +451,11 @@ static int rtl9300_i2c_probe(struct plat
+@@ -455,6 +451,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
        }
        i2c->sda_num = 0xff;
  
@@ -45,3 +49,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-9-jelonek.jonas@g
        return 0;
  }
  
+-- 
+2.48.1
+
similarity index 90%
rename from target/linux/realtek/patches-6.12/101-09-i2c-rtl9300-separate-xfer-configuration-and-execu.patch
rename to target/linux/realtek/patches-6.12/008-06-v6.18-i2c-rtl9300-separate-xfer-configuration-and-executio.patch
index 6eee13f0b574e119fd3e328febf3f127eec258a5..c7b4ea58dcb94ffc0fba23aa22b4b1cfb447ff56 100644 (file)
@@ -1,8 +1,7 @@
-From 9665c6a9812d9e2fa2b86be1fa1fc2b381e6f34e Mon Sep 17 00:00:00 2001
+From 447dd46f95014eb4ea94f6164963bf23ce05b927 Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Mon, 4 Aug 2025 11:31:11 +0000
-Subject: [PATCH v5 09/11] i2c: rtl9300: separate xfer configuration and
- execution
+Date: Sat, 27 Sep 2025 10:19:28 +0000
+Subject: [PATCH] i2c: rtl9300: separate xfer configuration and execution
 
 So far, the rtl9300_i2c_smbus_xfer code is quite a mess with function
 calls distributed over the whole function setting different values in
@@ -35,11 +34,15 @@ xfer to the corresponding register, and 'rtl9300_i2c_do_xfer' which
 actually executes the xfer and does post-processing if needed.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 234 +++++++++++++++----------------
- 1 file changed, 114 insertions(+), 120 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-7-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index 9e3517b09b3d..fb3ebbd46a18 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
 @@ -8,6 +8,7 @@
@@ -73,7 +76,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
  #define RTL9300_I2C_MST_CTRL1                         0x0
  #define RTL9300_I2C_MST_CTRL2                         0x4
  #define RTL9300_I2C_MST_DATA_WORD0                    0x8
-@@ -95,45 +112,37 @@ static int rtl9300_i2c_select_scl(struct
+@@ -95,45 +112,37 @@ static int rtl9300_i2c_select_scl(struct rtl9300_i2c *i2c, u8 scl)
        return regmap_field_write(i2c->fields[F_SCL_SEL], 1);
  }
  
@@ -131,7 +134,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
  {
        u32 vals[4] = {};
        int i, ret;
-@@ -153,7 +162,7 @@ static int rtl9300_i2c_read(struct rtl93
+@@ -153,7 +162,7 @@ static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, int len)
        return 0;
  }
  
@@ -140,7 +143,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
  {
        u32 vals[4] = {};
        int i;
-@@ -176,16 +185,51 @@ static int rtl9300_i2c_writel(struct rtl
+@@ -176,16 +185,51 @@ static int rtl9300_i2c_writel(struct rtl9300_i2c *i2c, u32 data)
        return regmap_write(i2c->regmap, i2c->data_reg, data);
  }
  
@@ -156,21 +159,21 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
 +              return -EINVAL;
 +
 +      ret = regmap_field_write(i2c->fields[F_DEV_ADDR], xfer->dev_addr);
-       if (ret)
-               return ret;
-+      ret = rtl9300_i2c_reg_addr_set(i2c, xfer->reg_addr, xfer->reg_addr_len);
 +      if (ret)
 +              return ret;
 +
-+      ret = regmap_field_write(i2c->fields[F_RWOP], xfer->write);
++      ret = rtl9300_i2c_reg_addr_set(i2c, xfer->reg_addr, xfer->reg_addr_len);
 +      if (ret)
 +              return ret;
 +
-+      ret = regmap_field_write(i2c->fields[F_DATA_WIDTH], (xfer->data_len - 1) & 0xf);
++      ret = regmap_field_write(i2c->fields[F_RWOP], xfer->write);
 +      if (ret)
 +              return ret;
 +
++      ret = regmap_field_write(i2c->fields[F_DATA_WIDTH], (xfer->data_len - 1) & 0xf);
+       if (ret)
+               return ret;
 +      if (xfer->write) {
 +              switch (xfer->type) {
 +              case RTL9300_I2C_XFER_BYTE:
@@ -196,7 +199,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
        ret = regmap_field_write(i2c->fields[F_I2C_TRIG], 1);
        if (ret)
                return ret;
-@@ -200,28 +244,24 @@ static int rtl9300_i2c_execute_xfer(stru
+@@ -200,28 +244,24 @@ static int rtl9300_i2c_execute_xfer(struct rtl9300_i2c *i2c, char read_write,
        if (val)
                return -EIO;
  
@@ -234,7 +237,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
                        if (ret)
                                return ret;
                        break;
-@@ -237,108 +277,62 @@ static int rtl9300_i2c_smbus_xfer(struct
+@@ -237,108 +277,62 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
  {
        struct rtl9300_i2c_chan *chan = i2c_get_adapdata(adap);
        struct rtl9300_i2c *i2c = chan->i2c;
@@ -379,3 +382,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-10-jelonek.jonas@
  
  out_unlock:
        mutex_unlock(&i2c->lock);
+-- 
+2.48.1
+
diff --git a/target/linux/realtek/patches-6.12/008-07-v6.18-i2c-rtl9300-use-scoped-guard-instead-of-explicit-loc.patch b/target/linux/realtek/patches-6.12/008-07-v6.18-i2c-rtl9300-use-scoped-guard-instead-of-explicit-loc.patch
new file mode 100644 (file)
index 0000000..fddf24c
--- /dev/null
@@ -0,0 +1,73 @@
+From bcd5f0da57e6c47a884dcad94ad6b0e32cce8705 Mon Sep 17 00:00:00 2001
+From: Jonas Jelonek <jelonek.jonas@gmail.com>
+Date: Sat, 27 Sep 2025 10:19:29 +0000
+Subject: [PATCH] i2c: rtl9300: use scoped guard instead of explicit
+ lock/unlock
+
+Use the scoped guard infrastructure which unlocks a mutex automatically
+when the guard goes out of scope, instead of explicit lock and unlock.
+This simplifies the code and control flow in rtl9300_i2c_smbus_xfer and
+removes the need of using goto in error cases to unlock before
+returning.
+
+Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-8-jelonek.jonas@gmail.com
+
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index fb3ebbd46a18..c67463228604 100644
+--- a/drivers/i2c/busses/i2c-rtl9300.c
++++ b/drivers/i2c/busses/i2c-rtl9300.c
+@@ -72,6 +72,8 @@ struct rtl9300_i2c {
+       struct mutex lock;
+ };
++DEFINE_GUARD(rtl9300_i2c, struct rtl9300_i2c *, mutex_lock(&_T->lock), mutex_unlock(&_T->lock))
++
+ enum rtl9300_i2c_xfer_type {
+       RTL9300_I2C_XFER_BYTE,
+       RTL9300_I2C_XFER_WORD,
+@@ -283,11 +285,11 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
+       if (addr > 0x7f)
+               return -EINVAL;
+-      mutex_lock(&i2c->lock);
++      guard(rtl9300_i2c)(i2c);
+       ret = rtl9300_i2c_config_chan(i2c, chan);
+       if (ret)
+-              goto out_unlock;
++              return ret;
+       xfer.dev_addr = addr & 0x7f;
+       xfer.write = (read_write == I2C_SMBUS_WRITE);
+@@ -324,20 +326,14 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
+               break;
+       default:
+               dev_err(&adap->dev, "Unsupported transaction %d\n", size);
+-              ret = -EOPNOTSUPP;
+-              goto out_unlock;
++              return -EOPNOTSUPP;
+       }
+       ret = rtl9300_i2c_prepare_xfer(i2c, &xfer);
+       if (ret)
+-              goto out_unlock;
+-
+-      ret = rtl9300_i2c_do_xfer(i2c, &xfer);
+-
+-out_unlock:
+-      mutex_unlock(&i2c->lock);
++              return ret;
+-      return ret;
++      return rtl9300_i2c_do_xfer(i2c, &xfer);
+ }
+ static u32 rtl9300_i2c_func(struct i2c_adapter *a)
+-- 
+2.48.1
+
similarity index 69%
rename from target/linux/realtek/patches-6.12/101-10-dt-bindings-i2c-realtek-rtl9301-i2c-extend-for-RT.patch
rename to target/linux/realtek/patches-6.12/008-08-v6.18-dt-bindings-i2c-realtek-rtl9301-i2c-extend-for-RTL93.patch
index 03dea2c0886de044ab2e5018ed26530120c8d433..7035005efc7cb58d74b6fd6f7479e6bb7f8496d5 100644 (file)
@@ -1,26 +1,29 @@
-From f891af341e32c8a2f2d2d25dd3c424ff47147a31 Mon Sep 17 00:00:00 2001
+From 17689aafb793599a862617a127429dd3d6f675c9 Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Mon, 4 Aug 2025 10:39:39 +0000
-Subject: [PATCH v5 10/11] dt-bindings: i2c: realtek,rtl9301-i2c: extend for
RTL9310 support
+Date: Sat, 27 Sep 2025 10:19:30 +0000
+Subject: [PATCH] dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9310
+ support
 
 Adjust the regex for child-node address to account for the fact that
 RTL9310 supports 12 instead of only 8 SDA lines. Also, narrow this per
 variant.
 
-Add a vendor-specific property to explicitly specify the
-Realtek-internal ID of the defined I2C controller/master. This is
-required, in particular for RTL9310, to describe the correct I2C
-master. Require this property for RTL9310.
+Add a vendor-specific property to explicitly specify the SCL line number
+of the defined I2C controller/master. This is required, in particular
+for RTL9310, to operate on the correct SCL for each controller. Require
+this property to be specified for RTL9310.
 
 Add compatibles for known SoC variants RTL9311, RTL9312 and RTL9313.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-11-jelonek.jonas@gmail.com/
----
- .../bindings/i2c/realtek,rtl9301-i2c.yaml     | 39 ++++++++++++++++++-
- 1 file changed, 37 insertions(+), 2 deletions(-)
+Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-9-jelonek.jonas@gmail.com
 
+diff --git a/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml b/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml
+index 274e2ab8b612..17ce39c19ab1 100644
 --- a/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml
 +++ b/Documentation/devicetree/bindings/i2c/realtek,rtl9301-i2c.yaml
 @@ -13,6 +13,8 @@ description:
@@ -91,3 +94,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-11-jelonek.jonas@
  required:
    - compatible
    - reg
+-- 
+2.48.1
+
similarity index 71%
rename from target/linux/realtek/patches-6.12/101-11-i2c-rtl9300-add-support-for-RTL9310-I2C-controlle.patch
rename to target/linux/realtek/patches-6.12/008-09-v6.18-i2c-rtl9300-add-support-for-RTL9310-I2C-controller.patch
index bf170fad85997355f42dee8ab0745fec8f54f89a..9a3a32e8c712819211ecae11cc01bb2e26419331 100644 (file)
@@ -1,7 +1,7 @@
-From ceddd84c5f73b17a1d8b9a760d9d5b5b7f0f0519 Mon Sep 17 00:00:00 2001
+From 8d43287120ce6437e7a77e735d99137f3fdb3ae9 Mon Sep 17 00:00:00 2001
 From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Mon, 30 Jun 2025 17:02:32 +0000
-Subject: [PATCH v5 11/11] i2c: rtl9300: add support for RTL9310 I2C controller
+Date: Sat, 27 Sep 2025 10:19:31 +0000
+Subject: [PATCH] i2c: rtl9300: add support for RTL9310 I2C controller
 
 Add support for the internal I2C controllers of RTL9310 series based
 SoCs to the driver for RTL9300. Add register definitions, chip-specific
@@ -15,11 +15,14 @@ which has SCL selection in a global register instead of a
 master-specific one.
 
 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-12-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 44 ++++++++++++++++++++++++++++++--
- 1 file changed, 42 insertions(+), 2 deletions(-)
+Tested-by: Sven Eckelmann <sven@narfation.org>
+Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Link: https://lore.kernel.org/r/20250927101931.71575-10-jelonek.jonas@gmail.com
 
+diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
+index c67463228604..4723e48cfe18 100644
 --- a/drivers/i2c/busses/i2c-rtl9300.c
 +++ b/drivers/i2c/busses/i2c-rtl9300.c
 @@ -60,14 +60,16 @@ struct rtl9300_i2c_drv_data {
@@ -40,20 +43,20 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-12-jelonek.jonas@
        u8 sda_num;
        struct mutex lock;
  };
-@@ -96,6 +98,12 @@ struct rtl9300_i2c_xfer {
+@@ -98,6 +100,12 @@ struct rtl9300_i2c_xfer {
  #define RTL9300_I2C_MST_DATA_WORD3                    0x14
  #define RTL9300_I2C_MST_GLB_CTRL                      0x384
  
 +#define RTL9310_I2C_MST_IF_CTRL                               0x1004
-+#define       RTL9310_I2C_MST_IF_SEL                          0x1008
-+#define       RTL9310_I2C_MST_CTRL                            0x0
-+#define       RTL9310_I2C_MST_MEMADDR_CTRL                    0x4
++#define RTL9310_I2C_MST_IF_SEL                                0x1008
++#define RTL9310_I2C_MST_CTRL                          0x0
++#define RTL9310_I2C_MST_MEMADDR_CTRL                  0x4
 +#define RTL9310_I2C_MST_DATA_CTRL                     0x8
 +
  static int rtl9300_i2c_reg_addr_set(struct rtl9300_i2c *i2c, u32 reg, u16 len)
  {
        int ret;
-@@ -112,6 +120,11 @@ static int rtl9300_i2c_select_scl(struct
+@@ -114,6 +122,11 @@ static int rtl9300_i2c_select_scl(struct rtl9300_i2c *i2c, u8 scl)
        return regmap_field_write(i2c->fields[F_SCL_SEL], 1);
  }
  
@@ -65,7 +68,7 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-12-jelonek.jonas@
  static int rtl9300_i2c_config_chan(struct rtl9300_i2c *i2c, struct rtl9300_i2c_chan *chan)
  {
        struct rtl9300_i2c_drv_data *drv_data;
-@@ -125,7 +138,7 @@ static int rtl9300_i2c_config_chan(struc
+@@ -127,7 +140,7 @@ static int rtl9300_i2c_config_chan(struct rtl9300_i2c *i2c, struct rtl9300_i2c_c
                return ret;
  
        drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev);
@@ -74,18 +77,28 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-12-jelonek.jonas@
        if (ret)
                return ret;
  
-@@ -383,6 +396,10 @@ static int rtl9300_i2c_probe(struct plat
+@@ -361,7 +374,7 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
+       struct fwnode_handle *child;
+       struct rtl9300_i2c_drv_data *drv_data;
+       struct reg_field fields[F_NUM_FIELDS];
+-      u32 clock_freq, sda_num;
++      u32 clock_freq, scl_num, sda_num;
+       int ret, i = 0;
+       i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
+@@ -379,6 +392,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
        if (ret)
                return ret;
  
-+      ret = device_property_read_u8(dev, "realtek,scl", &i2c->scl_num);
-+      if (ret || i2c->scl_num != 1)
-+              i2c->scl_num = 0;
++      ret = device_property_read_u32(dev, "realtek,scl", &scl_num);
++      if (ret || scl_num != 1)
++              scl_num = 0;
++      i2c->scl_num = (u8)scl_num;
 +
        platform_set_drvdata(pdev, i2c);
  
        drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev);
-@@ -478,12 +495,35 @@ static const struct rtl9300_i2c_drv_data
+@@ -474,12 +492,35 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_drv_data = {
        .max_nchan = RTL9300_I2C_MUX_NCHAN,
  };
  
@@ -121,3 +134,6 @@ Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-12-jelonek.jonas@
        {}
  };
  MODULE_DEVICE_TABLE(of, i2c_rtl9300_dt_ids);
+-- 
+2.48.1
+
diff --git a/target/linux/realtek/patches-6.12/101-02-i2c-rtl9300-fix-channel-number-bound-check.patch b/target/linux/realtek/patches-6.12/101-02-i2c-rtl9300-fix-channel-number-bound-check.patch
deleted file mode 100644 (file)
index a00bf32..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-From 571dd5203fcd1b9f78bc3d913492c0e13ad1bb00 Mon Sep 17 00:00:00 2001
-From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Sat, 9 Aug 2025 19:58:43 +0000
-Subject: [PATCH v5 02/11] i2c: rtl9300: fix channel number bound check
-
-Fix the current check for number of channels (child nodes in the device
-tree). Before, this was:
-
-if (device_get_child_node_count(dev) >= drv_data->max_nchan)
-
-drv_data->max_nchan gives the maximum number of channels so checking
-with '>=' isn't correct because it doesn't allow the last channel
-number. Thus, fix it to:
-
-if (device_get_child_node_count(dev) > drv_data->max_nchan)
-
-Issue occured on a TP-Link TL-ST1008F v2.0 device (8 SFP+ ports) and fix
-is tested there.
-
-Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-3-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/i2c/busses/i2c-rtl9300.c
-+++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -402,7 +402,7 @@ static int rtl9300_i2c_probe(struct plat
-       platform_set_drvdata(pdev, i2c);
-       drv_data = (struct rtl9300_i2c_drv_data *)device_get_match_data(i2c->dev);
--      if (device_get_child_node_count(dev) >= drv_data->max_nchan)
-+      if (device_get_child_node_count(dev) > drv_data->max_nchan)
-               return dev_err_probe(dev, -EINVAL, "Too many channels\n");
-       i2c->data_reg = i2c->reg_base + drv_data->data_reg;
diff --git a/target/linux/realtek/patches-6.12/101-05-i2c-rtl9300-check-if-xfer-length-is-valid.patch b/target/linux/realtek/patches-6.12/101-05-i2c-rtl9300-check-if-xfer-length-is-valid.patch
deleted file mode 100644 (file)
index 75ac386..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-From 47c2f21b934bda1d4031db8d54e08d52b180d9df Mon Sep 17 00:00:00 2001
-From: Jonas Jelonek <jelonek.jonas@gmail.com>
-Date: Tue, 5 Aug 2025 09:06:44 +0000
-Subject: [PATCH v5 05/11] i2c: rtl9300: check if xfer length is valid
-
-Add an explicit check for the xfer length to 'rtl9300_i2c_config_xfer'
-to make sure a length < 1 or > 16 isn't accepted. While there shouldn't
-be a length > 16 because this is specified in the i2c_adapter_quirks, a
-length of 0 may be passed. This is problematic, because the code adopts
-this value with
-
-(len - 1) & 0xf
-
-because the corresponding register documentation states that the value
-in the register is always used + 1 ([1]). Obvious reason for this is to
-fit allow xfer length of 16 to be specified in this 4-bit wide register
-field.
-
-Another consequence of this is also, that an xfer length of 0 cannot be
-set. Thus, an explicit check should avoid this. Before, this actually
-led to writing 0xf into the register, probably causing unintended
-behaviour.
-
-Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
-Link: https://lore.kernel.org/linux-i2c/20250809220713.1038947-6-jelonek.jonas@gmail.com/
----
- drivers/i2c/busses/i2c-rtl9300.c | 3 +++
- 1 file changed, 3 insertions(+)
-
---- a/drivers/i2c/busses/i2c-rtl9300.c
-+++ b/drivers/i2c/busses/i2c-rtl9300.c
-@@ -118,6 +118,9 @@ static int rtl9300_i2c_config_xfer(struc
- {
-       int ret;
-+      if (len < 1 || len > 16)
-+              return -EINVAL;
-+
-       ret = regmap_field_write(i2c->fields[F_SCL_FREQ], chan->bus_freq);
-       if (ret)
-               return ret;