[PATCH V3 4/4] drm/bridge: it66121: Add minimal it66122 support

Nishanth Menon posted 4 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH V3 4/4] drm/bridge: it66121: Add minimal it66122 support
Posted by Nishanth Menon 1 month, 2 weeks ago
The IT66122 is a pin compatible replacement for the IT66122. Based on
empirical testing, the new device looks to be compatible with IT66121.
However due to a lack of public data sheet at this time beyond overall
feature list[1] (which seems to add additional features vs ITT66121),
it is hard to determine that additional register operations required
to enable additional features.

So, introduce the device as a new compatible that we will detect based
on vid/pid match, with explicit id that can be used to extend the
driver capability as information becomes available later on.

[1] https://www.ite.com.tw/en/product/cate1/IT66122

Signed-off-by: Nishanth Menon <nm@ti.com>
---
Changes in V3:
* Dropped the claim that it is 1-1 replacement of IT66121.
* Based on emperical test result[2], introduce the same configuration of
  IT66121, but provide ID as suggested by Devarsh to allow for future
  expansion of functionality.

NOTE: I did consider the possibility of converting the chip_id into a
bitfield, but decided it is over-engineering, so kept the enum.

[2] https://github.com/beagleboard/linux/commits/v6.1.83-ti-rt-r40

V2: https://lore.kernel.org/all/20250813204106.580141-4-nm@ti.com/

 drivers/gpu/drm/bridge/ite-it66121.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
index 5ac9631bcd9a..a108d287722d 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -287,6 +287,7 @@
 enum chip_id {
 	ID_IT6610,
 	ID_IT66121,
+	ID_IT66122,
 };
 
 struct it66121_chip_info {
@@ -402,7 +403,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
 		if (ret)
 			return ret;
 
-		if (ctx->id == ID_IT66121) {
+		if (ctx->id == ID_IT66121 || ctx->id == ID_IT66122) {
 			ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
 						IT66121_AFE_IP_EC1, 0);
 			if (ret)
@@ -428,7 +429,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
 		if (ret)
 			return ret;
 
-		if (ctx->id == ID_IT66121) {
+		if (ctx->id == ID_IT66121 || ctx->id == ID_IT66122) {
 			ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
 						IT66121_AFE_IP_EC1,
 						IT66121_AFE_IP_EC1);
@@ -599,7 +600,7 @@ static int it66121_bridge_attach(struct drm_bridge *bridge,
 	if (ret)
 		return ret;
 
-	if (ctx->id == ID_IT66121) {
+	if (ctx->id == ID_IT66121 || ctx->id == ID_IT66122) {
 		ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
 					IT66121_CLK_BANK_PWROFF_RCLK, 0);
 		if (ret)
@@ -802,7 +803,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->id == ID_IT66121 &&
+	if ((ctx->id == ID_IT66121 || ctx->id == ID_IT66122) &&
 	    regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
 			      IT66121_CLK_BANK_PWROFF_TXCLK,
 			      IT66121_CLK_BANK_PWROFF_TXCLK)) {
@@ -815,7 +816,7 @@ void it66121_bridge_mode_set(struct drm_bridge *bridge,
 	if (it66121_configure_afe(ctx, adjusted_mode))
 		goto unlock;
 
-	if (ctx->id == ID_IT66121 &&
+	if ((ctx->id == ID_IT66121 || ctx->id == ID_IT66122) &&
 	    regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
 			      IT66121_CLK_BANK_PWROFF_TXCLK, 0)) {
 		goto unlock;
@@ -1614,12 +1615,14 @@ static void it66121_remove(struct i2c_client *client)
 }
 
 static const struct it66121_chip_info it66xx_chip_info[] = {
+	{.id = ID_IT66122, .vid = 0x4954, .pid = 0x0622 },
 	{.id = ID_IT66121, .vid = 0x4954, .pid = 0x0612 },
 	{.id = ID_IT6610, .vid = 0xca00, .pid = 0x0611 },
 	{ }
 };
 
 static const struct of_device_id it66121_dt_match[] = {
+	{ .compatible = "ite,it66122", &it66xx_chip_info },
 	{ .compatible = "ite,it66121", &it66xx_chip_info },
 	{ .compatible = "ite,it6610", &it66xx_chip_info },
 	{ }
@@ -1627,6 +1630,7 @@ static const struct of_device_id it66121_dt_match[] = {
 MODULE_DEVICE_TABLE(of, it66121_dt_match);
 
 static const struct i2c_device_id it66121_id[] = {
+	{ "it66122", (kernel_ulong_t)&it66xx_chip_info },
 	{ "it66121", (kernel_ulong_t)&it66xx_chip_info },
 	{ "it6610", (kernel_ulong_t)&it66xx_chip_info },
 	{ }
-- 
2.47.0
Re: [PATCH V3 4/4] drm/bridge: it66121: Add minimal it66122 support
Posted by Andrew Davis 1 month, 2 weeks ago
On 8/14/25 10:41 PM, Nishanth Menon wrote:
> The IT66122 is a pin compatible replacement for the IT66122. Based on
> empirical testing, the new device looks to be compatible with IT66121.
> However due to a lack of public data sheet at this time beyond overall
> feature list[1] (which seems to add additional features vs ITT66121),
> it is hard to determine that additional register operations required
> to enable additional features.
> 
> So, introduce the device as a new compatible that we will detect based
> on vid/pid match, with explicit id that can be used to extend the
> driver capability as information becomes available later on.
> 
> [1] https://www.ite.com.tw/en/product/cate1/IT66122
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> Changes in V3:
> * Dropped the claim that it is 1-1 replacement of IT66121.
> * Based on emperical test result[2], introduce the same configuration of
>    IT66121, but provide ID as suggested by Devarsh to allow for future
>    expansion of functionality.
> 
> NOTE: I did consider the possibility of converting the chip_id into a
> bitfield, but decided it is over-engineering, so kept the enum.
> 

But over-engineering is so much more fun :D

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

> [2] https://github.com/beagleboard/linux/commits/v6.1.83-ti-rt-r40
> 
> V2: https://lore.kernel.org/all/20250813204106.580141-4-nm@ti.com/
> 
>   drivers/gpu/drm/bridge/ite-it66121.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
> index 5ac9631bcd9a..a108d287722d 100644
> --- a/drivers/gpu/drm/bridge/ite-it66121.c
> +++ b/drivers/gpu/drm/bridge/ite-it66121.c
> @@ -287,6 +287,7 @@
>   enum chip_id {
>   	ID_IT6610,
>   	ID_IT66121,
> +	ID_IT66122,
>   };
>   
>   struct it66121_chip_info {
> @@ -402,7 +403,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
>   		if (ret)
>   			return ret;
>   
> -		if (ctx->id == ID_IT66121) {
> +		if (ctx->id == ID_IT66121 || ctx->id == ID_IT66122) {
>   			ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
>   						IT66121_AFE_IP_EC1, 0);
>   			if (ret)
> @@ -428,7 +429,7 @@ static int it66121_configure_afe(struct it66121_ctx *ctx,
>   		if (ret)
>   			return ret;
>   
> -		if (ctx->id == ID_IT66121) {
> +		if (ctx->id == ID_IT66121 || ctx->id == ID_IT66122) {
>   			ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
>   						IT66121_AFE_IP_EC1,
>   						IT66121_AFE_IP_EC1);
> @@ -599,7 +600,7 @@ static int it66121_bridge_attach(struct drm_bridge *bridge,
>   	if (ret)
>   		return ret;
>   
> -	if (ctx->id == ID_IT66121) {
> +	if (ctx->id == ID_IT66121 || ctx->id == ID_IT66122) {
>   		ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>   					IT66121_CLK_BANK_PWROFF_RCLK, 0);
>   		if (ret)
> @@ -802,7 +803,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->id == ID_IT66121 &&
> +	if ((ctx->id == ID_IT66121 || ctx->id == ID_IT66122) &&
>   	    regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>   			      IT66121_CLK_BANK_PWROFF_TXCLK,
>   			      IT66121_CLK_BANK_PWROFF_TXCLK)) {
> @@ -815,7 +816,7 @@ void it66121_bridge_mode_set(struct drm_bridge *bridge,
>   	if (it66121_configure_afe(ctx, adjusted_mode))
>   		goto unlock;
>   
> -	if (ctx->id == ID_IT66121 &&
> +	if ((ctx->id == ID_IT66121 || ctx->id == ID_IT66122) &&
>   	    regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>   			      IT66121_CLK_BANK_PWROFF_TXCLK, 0)) {
>   		goto unlock;
> @@ -1614,12 +1615,14 @@ static void it66121_remove(struct i2c_client *client)
>   }
>   
>   static const struct it66121_chip_info it66xx_chip_info[] = {
> +	{.id = ID_IT66122, .vid = 0x4954, .pid = 0x0622 },
>   	{.id = ID_IT66121, .vid = 0x4954, .pid = 0x0612 },
>   	{.id = ID_IT6610, .vid = 0xca00, .pid = 0x0611 },
>   	{ }
>   };
>   
>   static const struct of_device_id it66121_dt_match[] = {
> +	{ .compatible = "ite,it66122", &it66xx_chip_info },
>   	{ .compatible = "ite,it66121", &it66xx_chip_info },
>   	{ .compatible = "ite,it6610", &it66xx_chip_info },
>   	{ }
> @@ -1627,6 +1630,7 @@ static const struct of_device_id it66121_dt_match[] = {
>   MODULE_DEVICE_TABLE(of, it66121_dt_match);
>   
>   static const struct i2c_device_id it66121_id[] = {
> +	{ "it66122", (kernel_ulong_t)&it66xx_chip_info },
>   	{ "it66121", (kernel_ulong_t)&it66xx_chip_info },
>   	{ "it6610", (kernel_ulong_t)&it66xx_chip_info },
>   	{ }