3cc90210f27ce890105ee8f5db3cb0e33d19cc7f
[openwrt/openwrt.git] /
1 From 0cb24186d0ebd7dd12c070fed9d782bf7c6dfb1e Mon Sep 17 00:00:00 2001
2 From: Jonas Jelonek <jelonek.jonas@gmail.com>
3 Date: Sat, 27 Sep 2025 10:19:27 +0000
4 Subject: [PATCH] i2c: rtl9300: do not set read mode on every transfer
5
6 Move the operation to set the read mode from config_xfer to probe.
7
8 The I2C controller of RTL9300 and RTL9310 support a legacy message mode
9 for READs with 'Read Address Data' instead of the standard format 'Write
10 Address ; Read Data'. There is no way to pass that via smbus_xfer, thus
11 there is no point in supported this in the driver and moreover no point
12 in setting this on every transaction. Setting this once in the probe
13 call is sufficient.
14
15 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
16 Tested-by: Sven Eckelmann <sven@narfation.org>
17 Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
18 Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # On RTL9302C based board
19 Tested-by: Markus Stockhausen <markus.stockhausen@gmx.de>
20 Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
21 Link: https://lore.kernel.org/r/20250927101931.71575-6-jelonek.jonas@gmail.com
22
23 diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
24 index 4177cfb77094..9e3517b09b3d 100644
25 --- a/drivers/i2c/busses/i2c-rtl9300.c
26 +++ b/drivers/i2c/busses/i2c-rtl9300.c
27 @@ -130,11 +130,7 @@ static int rtl9300_i2c_config_xfer(struct rtl9300_i2c *i2c, struct rtl9300_i2c_c
28 if (ret)
29 return ret;
30
31 - ret = regmap_field_write(i2c->fields[F_DATA_WIDTH], (len - 1) & 0xf);
32 - if (ret)
33 - return ret;
34 -
35 - return regmap_field_write(i2c->fields[F_RD_MODE], 0);
36 + return regmap_field_write(i2c->fields[F_DATA_WIDTH], (len - 1) & 0xf);
37 }
38
39 static int rtl9300_i2c_read(struct rtl9300_i2c *i2c, u8 *buf, int len)
40 @@ -455,6 +451,11 @@ static int rtl9300_i2c_probe(struct platform_device *pdev)
41 }
42 i2c->sda_num = 0xff;
43
44 + /* only use standard read format */
45 + ret = regmap_field_write(i2c->fields[F_RD_MODE], 0);
46 + if (ret)
47 + return ret;
48 +
49 return 0;
50 }
51
52 --
53 2.48.1
54