]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: fix SMBus Rollball access 23049/head
authorJan Hoffmann <jan@3e8.eu>
Wed, 22 Apr 2026 15:48:20 +0000 (17:48 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 26 Apr 2026 07:51:09 +0000 (09:51 +0200)
The Rollball command byte needs to be written last. Otherwise the
controller might access the wrong register or write the wrong value.

Fixes: 1fc19bc06edc ("realtek: rtl93xx: mdio-smbus support for clause 45 and Rollball SFPs")
Signed-off-by: Jan Hoffmann <jan@3e8.eu>
Link: https://github.com/openwrt/openwrt/pull/23049
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/patches-6.18/712-net-phy-add-an-MDIO-SMBus-library.patch

index 0b471be1ec7680fde9e22aff54155dd9df0098f8..6f79964db90bc3f6cae06ddf5aa03dae7b85597b 100644 (file)
@@ -260,8 +260,8 @@ Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
 +      buf[2] = reg >> 8;
 +      buf[3] = reg & 0xff;
 +
-+      /* send address */
-+      for (i = 0; i < 4; i++) {
++      /* send address, making sure to send the command byte last */
++      for (i = 3; i >= 0; i--) {
 +              data.byte = buf[i];
 +              ret = __i2c_smbus_xfer(i2c, bus_addr, 0, I2C_SMBUS_WRITE, ROLLBALL_CMD_ADDR + i, I2C_SMBUS_BYTE_DATA, &data);
 +              if (ret < 0)
@@ -311,8 +311,8 @@ Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
 +      buf[4] = val >> 8;
 +      buf[5] = val & 0xff;
 +
-+      /* send address and value */
-+      for (i = 0; i < 6; i++) {
++      /* send address and value, making sure to send the command byte last */
++      for (i = 5; i >= 0; i--) {
 +              data.byte = buf[i];
 +              ret = __i2c_smbus_xfer(i2c, bus_addr, 0, I2C_SMBUS_WRITE, ROLLBALL_CMD_ADDR + i, I2C_SMBUS_BYTE_DATA, &data);
 +              if (ret < 0)