Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/bridge: it66121: Use vid/pid to detect the type of chip

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>
Reviewed-by: Andrew Davis <afd@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20251029150636.3118628-5-nm@ti.com

authored by

Nishanth Menon and committed by
Neil Armstrong
a8811c0b a1df28b5

+29 -29
+29 -29
drivers/gpu/drm/bridge/ite-it66121.c
··· 312 312 u8 swl; 313 313 bool auto_cts; 314 314 } audio; 315 - const struct it66121_chip_info *info; 315 + enum chip_id id; 316 316 }; 317 317 318 318 static const struct regmap_range_cfg it66121_regmap_banks[] = { ··· 402 402 if (ret) 403 403 return ret; 404 404 405 - if (ctx->info->id == ID_IT66121) { 405 + if (ctx->id == ID_IT66121) { 406 406 ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG, 407 407 IT66121_AFE_IP_EC1, 0); 408 408 if (ret) ··· 428 428 if (ret) 429 429 return ret; 430 430 431 - if (ctx->info->id == ID_IT66121) { 431 + if (ctx->id == ID_IT66121) { 432 432 ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG, 433 433 IT66121_AFE_IP_EC1, 434 434 IT66121_AFE_IP_EC1); ··· 449 449 if (ret) 450 450 return ret; 451 451 452 - if (ctx->info->id == ID_IT6610) { 452 + if (ctx->id == ID_IT6610) { 453 453 ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG, 454 454 IT6610_AFE_XP_BYPASS, 455 455 IT6610_AFE_XP_BYPASS); ··· 599 599 if (ret) 600 600 return ret; 601 601 602 - if (ctx->info->id == ID_IT66121) { 602 + if (ctx->id == ID_IT66121) { 603 603 ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG, 604 604 IT66121_CLK_BANK_PWROFF_RCLK, 0); 605 605 if (ret) ··· 748 748 { 749 749 struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge); 750 750 751 - if (ctx->info->id == ID_IT6610) { 751 + if (ctx->id == ID_IT6610) { 752 752 /* The IT6610 only supports these settings */ 753 753 bridge_state->input_bus_cfg.flags |= DRM_BUS_FLAG_DE_HIGH | 754 754 DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE; ··· 802 802 if (regmap_write(ctx->regmap, IT66121_HDMI_MODE_REG, IT66121_HDMI_MODE_HDMI)) 803 803 goto unlock; 804 804 805 - if (ctx->info->id == ID_IT66121 && 805 + if (ctx->id == ID_IT66121 && 806 806 regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG, 807 807 IT66121_CLK_BANK_PWROFF_TXCLK, 808 808 IT66121_CLK_BANK_PWROFF_TXCLK)) { ··· 815 815 if (it66121_configure_afe(ctx, adjusted_mode)) 816 816 goto unlock; 817 817 818 - if (ctx->info->id == ID_IT66121 && 818 + if (ctx->id == ID_IT66121 && 819 819 regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG, 820 820 IT66121_CLK_BANK_PWROFF_TXCLK, 0)) { 821 821 goto unlock; ··· 1498 1498 "vcn33", "vcn18", "vrf12" 1499 1499 }; 1500 1500 1501 + static const struct it66121_chip_info it66xx_chip_info[] = { 1502 + {.id = ID_IT6610, .vid = 0xca00, .pid = 0x0611 }, 1503 + {.id = ID_IT66121, .vid = 0x4954, .pid = 0x0612 }, 1504 + }; 1505 + 1501 1506 static int it66121_probe(struct i2c_client *client) 1502 1507 { 1503 1508 u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; 1504 1509 struct device_node *ep; 1505 - int ret; 1510 + int ret, i; 1506 1511 struct it66121_ctx *ctx; 1507 1512 struct device *dev = &client->dev; 1513 + const struct it66121_chip_info *chip_info; 1508 1514 1509 1515 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 1510 1516 dev_err(dev, "I2C check functionality failed.\n"); ··· 1528 1522 1529 1523 ctx->dev = dev; 1530 1524 ctx->client = client; 1531 - ctx->info = i2c_get_match_data(client); 1532 1525 1533 1526 of_property_read_u32(ep, "bus-width", &ctx->bus_width); 1534 1527 of_node_put(ep); ··· 1573 1568 revision_id = FIELD_GET(IT66121_REVISION_MASK, device_ids[1]); 1574 1569 device_ids[1] &= IT66121_DEVICE_ID1_MASK; 1575 1570 1576 - if ((vendor_ids[1] << 8 | vendor_ids[0]) != ctx->info->vid || 1577 - (device_ids[1] << 8 | device_ids[0]) != ctx->info->pid) { 1578 - return -ENODEV; 1571 + for (i = 0; i < ARRAY_SIZE(it66xx_chip_info); i++) { 1572 + chip_info = &it66xx_chip_info[i]; 1573 + if ((vendor_ids[1] << 8 | vendor_ids[0]) == chip_info->vid && 1574 + (device_ids[1] << 8 | device_ids[0]) == chip_info->pid) { 1575 + ctx->id = chip_info->id; 1576 + break; 1577 + } 1579 1578 } 1579 + 1580 + if (i == ARRAY_SIZE(it66xx_chip_info)) 1581 + return -ENODEV; 1580 1582 1581 1583 ctx->bridge.of_node = dev->of_node; 1582 1584 ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA; ··· 1618 1606 mutex_destroy(&ctx->lock); 1619 1607 } 1620 1608 1621 - static const struct it66121_chip_info it66121_chip_info = { 1622 - .id = ID_IT66121, 1623 - .vid = 0x4954, 1624 - .pid = 0x0612, 1625 - }; 1626 - 1627 - static const struct it66121_chip_info it6610_chip_info = { 1628 - .id = ID_IT6610, 1629 - .vid = 0xca00, 1630 - .pid = 0x0611, 1631 - }; 1632 - 1633 1609 static const struct of_device_id it66121_dt_match[] = { 1634 - { .compatible = "ite,it6610", &it6610_chip_info }, 1635 - { .compatible = "ite,it66121", &it66121_chip_info }, 1610 + { .compatible = "ite,it6610" }, 1611 + { .compatible = "ite,it66121" }, 1636 1612 { } 1637 1613 }; 1638 1614 MODULE_DEVICE_TABLE(of, it66121_dt_match); 1639 1615 1640 1616 static const struct i2c_device_id it66121_id[] = { 1641 - { "it6610", (kernel_ulong_t)&it6610_chip_info }, 1642 - { "it66121", (kernel_ulong_t)&it66121_chip_info }, 1617 + { .name = "it6610" }, 1618 + { .name = "it66121" }, 1643 1619 { } 1644 1620 }; 1645 1621 MODULE_DEVICE_TABLE(i2c, it66121_id);