devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Nishanth Menon <nm@ti.com>, Conor Dooley <conor+dt@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Rob Herring <robh@kernel.org>, David Airlie <airlied@gmail.com>,
	Maxime Ripard <mripard@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Neil Armstrong <neil.armstrong@linaro.org>
Cc: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<dri-devel@lists.freedesktop.org>,
	Robert Nelson <robertcnelson@gmail.com>,
	Jason Kridner <jkridner@beagleboard.org>,
	<tomi.valkeinen@ideasonboard.com>, <devarsht@ti.com>,
	<dmitry.baryshkov@oss.qualcomm.com>
Subject: Re: [PATCH V4 4/5] drm/bridge: it66121: Use vid/pid to detect the type of chip
Date: Tue, 19 Aug 2025 09:44:48 -0500	[thread overview]
Message-ID: <b8ed887a-1ffd-4ed4-98b0-6e71f8213f6b@ti.com> (raw)
In-Reply-To: <20250819130807.3322536-5-nm@ti.com>

On 8/19/25 8:08 AM, Nishanth Menon wrote:
> The driver knows exactly which version of the chip is present since
> the vid/pid is used to enforce a compatibility. Given that some
> devices like IT66121 has potentially been replaced with IT66122 mid
> production for many platforms, it makes no sense to use the vid/pid
> as an enforcement for compatibility. Instead, detect the ID of the
> actual chip in use by matching the corresponding vid/pid and drop the
> compatible specific lookup table.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> Changes in V4:
> * Dropped the formatting change
> * Dropped the data lookup from match.
> * Have not picked Andrew's review since the patch was modified
> 
> V3: https://lore.kernel.org/all/20250815034105.1276548-4-nm@ti.com/
> V2: https://lore.kernel.org/all/20250813204106.580141-3-nm@ti.com/
> 
>   drivers/gpu/drm/bridge/ite-it66121.c | 56 ++++++++++++++--------------
>   1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
> index cd74f3966560..a1b0f8a8f3e8 100644
> --- a/drivers/gpu/drm/bridge/ite-it66121.c
> +++ b/drivers/gpu/drm/bridge/ite-it66121.c
> @@ -312,7 +312,7 @@ struct it66121_ctx {
>   		u8 swl;
>   		bool auto_cts;
>   	} audio;
> -	const struct it66121_chip_info *info;
> +	enum chip_id id;
>   };
>   
>   static const struct regmap_range_cfg it66121_regmap_banks[] = {
> @@ -402,7 +402,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
>   		if (ret)
>   			return ret;
>   
> -		if (ctx->info->id == ID_IT66121) {
> +		if (ctx->id == ID_IT66121) {
>   			ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
>   						IT66121_AFE_IP_EC1, 0);
>   			if (ret)
> @@ -428,7 +428,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
>   		if (ret)
>   			return ret;
>   
> -		if (ctx->info->id == ID_IT66121) {
> +		if (ctx->id == ID_IT66121) {
>   			ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
>   						IT66121_AFE_IP_EC1,
>   						IT66121_AFE_IP_EC1);
> @@ -449,7 +449,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
>   	if (ret)
>   		return ret;
>   
> -	if (ctx->info->id == ID_IT6610) {
> +	if (ctx->id == ID_IT6610) {
>   		ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG,
>   					IT6610_AFE_XP_BYPASS,
>   					IT6610_AFE_XP_BYPASS);
> @@ -599,7 +599,7 @@ static int it66121_bridge_attach(struct drm_bridge *bridge,
>   	if (ret)
>   		return ret;
>   
> -	if (ctx->info->id == ID_IT66121) {
> +	if (ctx->id == ID_IT66121) {
>   		ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>   					IT66121_CLK_BANK_PWROFF_RCLK, 0);
>   		if (ret)
> @@ -748,7 +748,7 @@ static int it66121_bridge_check(struct drm_bridge *bridge,
>   {
>   	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
>   
> -	if (ctx->info->id == ID_IT6610) {
> +	if (ctx->id == ID_IT6610) {
>   		/* The IT6610 only supports these settings */
>   		bridge_state->input_bus_cfg.flags |= DRM_BUS_FLAG_DE_HIGH |
>   			DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE;
> @@ -802,7 +802,7 @@ void it66121_bridge_mode_set(struct drm_bridge *bridge,
>   	if (regmap_write(ctx->regmap, IT66121_HDMI_MODE_REG, IT66121_HDMI_MODE_HDMI))
>   		goto unlock;
>   
> -	if (ctx->info->id == ID_IT66121 &&
> +	if (ctx->id == ID_IT66121 &&
>   	    regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>   			      IT66121_CLK_BANK_PWROFF_TXCLK,
>   			      IT66121_CLK_BANK_PWROFF_TXCLK)) {
> @@ -815,7 +815,7 @@ void it66121_bridge_mode_set(struct drm_bridge *bridge,
>   	if (it66121_configure_afe(ctx, adjusted_mode))
>   		goto unlock;
>   
> -	if (ctx->info->id == ID_IT66121 &&
> +	if (ctx->id == ID_IT66121 &&
>   	    regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>   			      IT66121_CLK_BANK_PWROFF_TXCLK, 0)) {
>   		goto unlock;
> @@ -1498,6 +1498,12 @@ static const char * const it66121_supplies[] = {
>   	"vcn33", "vcn18", "vrf12"
>   };
>   
> +static const struct it66121_chip_info it66xx_chip_info[] = {
> +	{.id = ID_IT6610, .vid = 0xca00, .pid = 0x0611 },
> +	{.id = ID_IT66121, .vid = 0x4954, .pid = 0x0612 },
> +	{ }
> +};
> +
>   static int it66121_probe(struct i2c_client *client)
>   {
>   	u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 };
> @@ -1505,6 +1511,7 @@ static int it66121_probe(struct i2c_client *client)
>   	int ret;
>   	struct it66121_ctx *ctx;
>   	struct device *dev = &client->dev;
> +	const struct it66121_chip_info *chip_info;
>   
>   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
>   		dev_err(dev, "I2C check functionality failed.\n");
> @@ -1522,7 +1529,6 @@ static int it66121_probe(struct i2c_client *client)
>   
>   	ctx->dev = dev;
>   	ctx->client = client;
> -	ctx->info = i2c_get_match_data(client);
>   
>   	of_property_read_u32(ep, "bus-width", &ctx->bus_width);
>   	of_node_put(ep);
> @@ -1568,11 +1574,17 @@ static int it66121_probe(struct i2c_client *client)
>   	revision_id = FIELD_GET(IT66121_REVISION_MASK, device_ids[1]);
>   	device_ids[1] &= IT66121_DEVICE_ID1_MASK;
>   
> -	if ((vendor_ids[1] << 8 | vendor_ids[0]) != ctx->info->vid ||
> -	    (device_ids[1] << 8 | device_ids[0]) != ctx->info->pid) {
> -		return -ENODEV;
> +	for (chip_info = it66xx_chip_info; chip_info->vid; chip_info++) {

Relying on a null entry bugs me, here you could just use
the length of the table and remove the null entry:

for (i = 0; i < ARRAY_SIZE(it66xx_chip_info); i++) {
	chip_info = &it66xx_chip_info[i];
	...

Either way,

Reviewed-by: Andrew Davis <afd@ti.com>

> +		if ((vendor_ids[1] << 8 | vendor_ids[0]) == chip_info->vid &&
> +		    (device_ids[1] << 8 | device_ids[0]) == chip_info->pid) {
> +			ctx->id = chip_info->id;
> +			break;
> +		}
>   	}
>   
> +	if (!chip_info->vid)
> +		return -ENODEV;
> +
>   	ctx->bridge.of_node = dev->of_node;
>   	ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
>   	ctx->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
> @@ -1606,28 +1618,16 @@ static void it66121_remove(struct i2c_client *client)
>   	mutex_destroy(&ctx->lock);
>   }
>   
> -static const struct it66121_chip_info it66121_chip_info = {
> -	.id = ID_IT66121,
> -	.vid = 0x4954,
> -	.pid = 0x0612,
> -};
> -
> -static const struct it66121_chip_info it6610_chip_info = {
> -	.id = ID_IT6610,
> -	.vid = 0xca00,
> -	.pid = 0x0611,
> -};
> -
>   static const struct of_device_id it66121_dt_match[] = {
> -	{ .compatible = "ite,it6610", &it6610_chip_info },
> -	{ .compatible = "ite,it66121", &it66121_chip_info },
> +	{ .compatible = "ite,it6610" },
> +	{ .compatible = "ite,it66121" },
>   	{ }
>   };
>   MODULE_DEVICE_TABLE(of, it66121_dt_match);
>   
>   static const struct i2c_device_id it66121_id[] = {
> -	{ "it6610", (kernel_ulong_t)&it6610_chip_info },
> -	{ "it66121", (kernel_ulong_t)&it66121_chip_info },
> +	{ .name = "it6610" },
> +	{ .name = "it66121" },
>   	{ }
>   };
>   MODULE_DEVICE_TABLE(i2c, it66121_id);


  reply	other threads:[~2025-08-19 14:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 13:08 [PATCH V4 0/5] drm/bridge: it66121: Add initial it66122 support Nishanth Menon
2025-08-19 13:08 ` [PATCH V4 1/5] dt-bindings: display: bridge: it66121: Add compatible string for IT66122 Nishanth Menon
2025-08-19 13:08 ` [PATCH V4 2/5] drm/bridge: it66121: Drop ftrace like dev_dbg() prints Nishanth Menon
2025-08-19 13:08 ` [PATCH V4 3/5] drm/bridge: it66121: Sort the compatibles Nishanth Menon
2025-08-19 13:08 ` [PATCH V4 4/5] drm/bridge: it66121: Use vid/pid to detect the type of chip Nishanth Menon
2025-08-19 14:44   ` Andrew Davis [this message]
2025-08-19 13:08 ` [PATCH V4 5/5] drm/bridge: it66121: Add minimal it66122 support Nishanth Menon

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=b8ed887a-1ffd-4ed4-98b0-6e71f8213f6b@ti.com \
    --to=afd@ti.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jkridner@beagleboard.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=nm@ti.com \
    --cc=robertcnelson@gmail.com \
    --cc=robh@kernel.org \
    --cc=tomi.valkeinen@ideasonboard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).