public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Rustam Adilov <adilov@disroot.org>
To: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Cc: Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/8] i2c: rtl9300: introduce a property for 8 bit width reg address
Date: Mon, 16 Mar 2026 16:28:52 +0000	[thread overview]
Message-ID: <c03ba2a5b0fa3ee0714d9e6cf475a1c6@disroot.org> (raw)
In-Reply-To: <d91f5897-c565-4574-81e4-5b0624da2766@alliedtelesis.co.nz>

Hello,
On 2026-03-15 21:31, Chris Packham wrote:
> Hi Rustam,
> 
> (sorry I might have prematurely hit send on an earlier reply)
> 
> On 14/03/2026 21:26, Rustam Adilov wrote:
>> 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 <adilov@disroot.org>
>> ---
>>   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-rtl9300.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;
>>   };
>>   
>>   #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
>>   
>>   #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 *adap, u16 addr, unsigned s
>>   				  union i2c_smbus_data *data)
>>   {
>>   	struct rtl9300_i2c_chan *chan = i2c_get_adapdata(adap);
>> +	const struct rtl9300_i2c_drv_data *drv_data;
>>   	struct rtl9300_i2c *i2c = chan->i2c;
>>   	struct rtl9300_i2c_xfer xfer = {0};
>>   	int ret;
>> @@ -308,6 +311,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
>>   
>>   	guard(rtl9300_i2c)(i2c);
>>   
>> +	drv_data = device_get_match_data(i2c->dev);
>>   	ret = rtl9300_i2c_config_chan(i2c, chan);
>>   	if (ret)
>>   		return ret;
>> @@ -315,7 +319,7 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
>>   	xfer.dev_addr = addr & 0x7f;
>>   	xfer.write = (read_write == I2C_SMBUS_WRITE);
>>   	xfer.reg_addr = command;
>> -	xfer.reg_addr_len = 1;
>> +	xfer.reg_addr_len = drv_data->reg_addr_8bit_len;
> 
> For this one I wonder if we could come up with something that involves a 
> subtraction for the rtl9607? len = 1 just makes sense to me so maybe 
> RTL_9300_ADDR_LEN(1) which expands to 1 - 0 on the rtl9300 and 1 - 1 on 
> the rtl9607 would be easier to follow.

I am not entirely sure i understand this approach. Is RTL_9300_ADDR_LEN(1)
gonna be a "#define"? Would like to know before i proceed with possible
changes for v2.

And wouldn't something like this work just as well:

xfer.reg_addr_len = 1 - drv_data->subtract_len;

But then, i honestly think "drv_data->reg_addr_8bit_len" would be a bit less
cluttery?

> Not a deal breaker just thought I'd mention it.
> 
>>   
>>   	switch (size) {
>>   	case I2C_SMBUS_BYTE:
>> @@ -501,6 +505,7 @@ static const struct rtl9300_i2c_drv_data rtl9300_i2c_drv_data = {
>>   	.wd_reg = RTL9300_I2C_MST_DATA_WORD0,
>>   	.max_nchan = RTL9300_I2C_MUX_NCHAN,
>>   	.max_data_len = RTL9300_I2C_MAX_DATA_LEN,
>> +	.reg_addr_8bit_len = RTL9300_REG_ADDR_8BIT_LEN,
>>   };
>>   
>>   static const struct rtl9300_i2c_drv_data rtl9310_i2c_drv_data = {
>> @@ -524,6 +529,7 @@ static const struct rtl9300_i2c_drv_data rtl9310_i2c_drv_data = {
>>   	.wd_reg = RTL9310_I2C_MST_DATA_CTRL,
>>   	.max_nchan = RTL9310_I2C_MUX_NCHAN,
>>   	.max_data_len = RTL9300_I2C_MAX_DATA_LEN,
>> +	.reg_addr_8bit_len = RTL9300_REG_ADDR_8BIT_LEN,
>>   };
>>   
>>   static const struct of_device_id i2c_rtl9300_dt_ids[] = {

  reply	other threads:[~2026-03-16 16:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-14  8:26 [PATCH 0/8] i2c: rtl9300: support for RTL9607C I2C controller Rustam Adilov
2026-03-14  8:26 ` [PATCH 1/8] i2c: rtl9300: split data_reg into read and write reg Rustam Adilov
2026-03-14  8:26 ` [PATCH 2/8] i2c: rtl9300: introduce max length property to driver data Rustam Adilov
2026-03-14  8:26 ` [PATCH 3/8] i2c: rtl9300: introduce F_BUSY to the reg_fields struct Rustam Adilov
2026-03-14  8:26 ` [PATCH 4/8] i2c: rtl9300: introduce a property for 8 bit width reg address Rustam Adilov
2026-03-15 21:26   ` Chris Packham
2026-03-15 21:31   ` Chris Packham
2026-03-16 16:28     ` Rustam Adilov [this message]
2026-03-16 20:24       ` Chris Packham
2026-03-14  8:26 ` [PATCH 5/8] i2c: rtl9300: introduce clk struct for upcoming rtl9607 support Rustam Adilov
2026-03-14  8:26 ` [PATCH 6/8] i2c: rtl9300: intoduce new function properties to driver data Rustam Adilov
2026-03-15 21:36   ` Chris Packham
2026-03-16 16:42     ` Rustam Adilov
2026-03-14  8:26 ` [PATCH 7/8] dt-bindings: i2c: realtek,rtl9301-i2c: extend for RTL9607C support Rustam Adilov
2026-03-15  8:56   ` Krzysztof Kozlowski
2026-03-15 10:10     ` Rustam Adilov
2026-03-15 10:15       ` Krzysztof Kozlowski
2026-03-15 16:18         ` Rustam Adilov
2026-03-14  8:26 ` [PATCH 8/8] i2c: rtl9300: add RTL9607C i2c controller support Rustam Adilov
2026-03-15 21:45 ` [PATCH 0/8] i2c: rtl9300: support for RTL9607C I2C controller Chris Packham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c03ba2a5b0fa3ee0714d9e6cf475a1c6@disroot.org \
    --to=adilov@disroot.org \
    --cc=Chris.Packham@alliedtelesis.co.nz \
    --cc=andi.shyti@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox