All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: "Théo Lebrun" <theo.lebrun@bootlin.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Andi Shyti" <andi.shyti@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
	"Grégory Clement" <gregory.clement@bootlin.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>
Subject: Re: [PATCH 2/4] i2c: nomadik: support Mobileye EyeQ6H I2C controller
Date: Tue, 8 Oct 2024 18:03:36 +0200	[thread overview]
Message-ID: <fc17ef3d-7895-4ee8-bfa0-d31dd45f2f2c@kernel.org> (raw)
In-Reply-To: <D4QI63B6YQU5.3UPKA7G75J445@bootlin.com>

On 08/10/2024 16:43, Théo Lebrun wrote:
> Hello Krzysztof,
> 
> On Tue Oct 8, 2024 at 3:39 PM CEST, Krzysztof Kozlowski wrote:
>> On Tue, Oct 08, 2024 at 12:29:41PM +0200, Théo Lebrun wrote:
>>> Add EyeQ6H support to the nmk-i2c AMBA driver. It shares the same quirk
>>> as EyeQ5: the memory bus only supports 32-bit accesses. Avoid writeb()
>>> and readb() by reusing the same `priv->has_32b_bus` flag.
>>>
>>> It does NOT need to write speed-mode specific value into a register;
>>> therefore it does not depend on the mobileye,olb DT property.
>>>
>>> Refactoring is done using is_eyeq5 and is_eyeq6h boolean local
>>> variables. Sort variables in reverse christmas tree to try and
>>> introduce some logic into the ordering.
>>>
>>> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
>>> ---
>>>  drivers/i2c/busses/i2c-nomadik.c | 22 +++++++++++-----------
>>>  1 file changed, 11 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
>>> index ad0f02acdb1215a1c04729f97bb14a4d93f88456..ea511d3a58073eaedb63850026e05b59427a69c6 100644
>>> --- a/drivers/i2c/busses/i2c-nomadik.c
>>> +++ b/drivers/i2c/busses/i2c-nomadik.c
>>> @@ -6,10 +6,10 @@
>>>   * I2C master mode controller driver, used in Nomadik 8815
>>>   * and Ux500 platforms.
>>>   *
>>> - * The Mobileye EyeQ5 platform is also supported; it uses
>>> + * The Mobileye EyeQ5 and EyeQ6H platforms are also supported; they use
>>>   * the same Ux500/DB8500 IP block with two quirks:
>>>   *  - The memory bus only supports 32-bit accesses.
>>> - *  - A register must be configured for the I2C speed mode;
>>> + *  - (only EyeQ5) A register must be configured for the I2C speed mode;
>>>   *    it is located in a shared register region called OLB.
>>>   *
>>>   * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
>>> @@ -1046,8 +1046,6 @@ static int nmk_i2c_eyeq5_probe(struct nmk_i2c_dev *priv)
>>>  	struct regmap *olb;
>>>  	unsigned int id;
>>>  
>>> -	priv->has_32b_bus = true;
>>> -
>>>  	olb = syscon_regmap_lookup_by_phandle_args(np, "mobileye,olb", 1, &id);
>>>  	if (IS_ERR(olb))
>>>  		return PTR_ERR(olb);
>>> @@ -1070,13 +1068,15 @@ static int nmk_i2c_eyeq5_probe(struct nmk_i2c_dev *priv)
>>>  
>>>  static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
>>>  {
>>> -	int ret = 0;
>>> -	struct nmk_i2c_dev *priv;
>>> -	struct device_node *np = adev->dev.of_node;
>>> -	struct device *dev = &adev->dev;
>>> -	struct i2c_adapter *adap;
>>>  	struct i2c_vendor_data *vendor = id->data;
>>> +	struct device_node *np = adev->dev.of_node;
>>> +	bool is_eyeq6h = of_device_is_compatible(np, "mobileye,eyeq6h-i2c");
>>> +	bool is_eyeq5 = of_device_is_compatible(np, "mobileye,eyeq5-i2c");
>>
>> You should use match data, not add compatibles in the middle of code.
>> That's preferred, scallable pattern. What you added here last time does
>> not scale and above change is a proof for that.
> 
> I would have used match data if the driver struct had a .of_match_table
> field. `struct amba_driver` does not. Are you recommending the approach
> below?
> 
> I don't see how it brings much to the driver but I do get the scaling
> issue as the number of support compatibles increases. This is a fear
> based on what *could* happen in the future though.

You still have adev->dev.of_node, which you can use for matching in
probe. See for example of_match_device() (and add a note so people will
not convert it to device_get_match_data() blindly).

Best regards,
Krzysztof


  reply	other threads:[~2024-10-08 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 10:29 [PATCH 0/4] i2c: nomadik: support >=1MHz & Mobileye EyeQ6H platform Théo Lebrun
2024-10-08 10:29 ` [PATCH 1/4] dt-bindings: i2c: nomadik: add mobileye,eyeq6h-i2c bindings Théo Lebrun
2024-10-08 13:38   ` Krzysztof Kozlowski
2024-10-08 10:29 ` [PATCH 2/4] i2c: nomadik: support Mobileye EyeQ6H I2C controller Théo Lebrun
2024-10-08 13:39   ` Krzysztof Kozlowski
2024-10-08 14:43     ` Théo Lebrun
2024-10-08 16:03       ` Krzysztof Kozlowski [this message]
2024-10-09 10:27         ` Théo Lebrun
2024-10-08 10:29 ` [PATCH 3/4] i2c: nomadik: fix BRCR computation Théo Lebrun
2024-10-08 10:29 ` [PATCH 4/4] i2c: nomadik: support >=1MHz speed modes Théo Lebrun

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=fc17ef3d-7895-4ee8-bfa0-d31dd45f2f2c@kernel.org \
    --to=krzk@kernel.org \
    --cc=andi.shyti@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=tawfik.bayouk@mobileye.com \
    --cc=theo.lebrun@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vladimir.kondratiev@mobileye.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.