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

drm/bridge: anx7625: Fix Set HPD irq detect window to 2ms

Polling firmware HPD GPIO status, set HPD irq detect window to 2ms
after firmware HPD GPIO initial done

Signed-off-by: Xin Ji <xji@analogixsemi.com>
Reviewed-by: Robert Foss <rfoss@kernel.org>
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231120091038.284825-2-xji@analogixsemi.com

authored by

Xin Ji and committed by
Robert Foss
e3af7053 af3145aa

+40 -15
+36 -15
drivers/gpu/drm/bridge/analogix/anx7625.c
··· 1298 1298 XTAL_FRQ_SEL, XTAL_FRQ_27M); 1299 1299 } 1300 1300 1301 + static int anx7625_hpd_timer_config(struct anx7625_data *ctx) 1302 + { 1303 + int ret; 1304 + 1305 + /* Set irq detect window to 2ms */ 1306 + ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, 1307 + HPD_DET_TIMER_BIT0_7, HPD_TIME & 0xFF); 1308 + ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, 1309 + HPD_DET_TIMER_BIT8_15, 1310 + (HPD_TIME >> 8) & 0xFF); 1311 + ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, 1312 + HPD_DET_TIMER_BIT16_23, 1313 + (HPD_TIME >> 16) & 0xFF); 1314 + 1315 + return ret; 1316 + } 1317 + 1318 + static int anx7625_read_hpd_gpio_config_status(struct anx7625_data *ctx) 1319 + { 1320 + return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, GPIO_CTRL_2); 1321 + } 1322 + 1301 1323 static void anx7625_disable_pd_protocol(struct anx7625_data *ctx) 1302 1324 { 1303 1325 struct device *dev = ctx->dev; 1304 - int ret; 1326 + int ret, val; 1305 1327 1306 1328 /* Reset main ocm */ 1307 1329 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, 0x88, 0x40); ··· 1337 1315 DRM_DEV_DEBUG_DRIVER(dev, "disable PD feature fail.\n"); 1338 1316 else 1339 1317 DRM_DEV_DEBUG_DRIVER(dev, "disable PD feature succeeded.\n"); 1318 + 1319 + /* 1320 + * Make sure the HPD GPIO already be configured after OCM release before 1321 + * setting HPD detect window register. Here we poll the status register 1322 + * at maximum 40ms, then config HPD irq detect window register 1323 + */ 1324 + readx_poll_timeout(anx7625_read_hpd_gpio_config_status, 1325 + ctx, val, 1326 + ((val & HPD_SOURCE) || (val < 0)), 1327 + 2000, 2000 * 20); 1328 + 1329 + /* Set HPD irq detect window to 2ms */ 1330 + anx7625_hpd_timer_config(ctx); 1340 1331 } 1341 1332 1342 1333 static int anx7625_ocm_loading_check(struct anx7625_data *ctx) ··· 1472 1437 1473 1438 static int anx7625_read_hpd_status_p0(struct anx7625_data *ctx) 1474 1439 { 1475 - int ret; 1476 - 1477 - /* Set irq detect window to 2ms */ 1478 - ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, 1479 - HPD_DET_TIMER_BIT0_7, HPD_TIME & 0xFF); 1480 - ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, 1481 - HPD_DET_TIMER_BIT8_15, 1482 - (HPD_TIME >> 8) & 0xFF); 1483 - ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, 1484 - HPD_DET_TIMER_BIT16_23, 1485 - (HPD_TIME >> 16) & 0xFF); 1486 - if (ret < 0) 1487 - return ret; 1488 - 1489 1440 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, SYSTEM_STSTUS); 1490 1441 } 1491 1442
+4
drivers/gpu/drm/bridge/analogix/anx7625.h
··· 259 259 #define AP_MIPI_RX_EN BIT(5) /* 1: MIPI RX input in 0: no RX in */ 260 260 #define AP_DISABLE_PD BIT(6) 261 261 #define AP_DISABLE_DISPLAY BIT(7) 262 + 263 + #define GPIO_CTRL_2 0x49 264 + #define HPD_SOURCE BIT(6) 265 + 262 266 /***************************************************************/ 263 267 /* Register definition of device address 0x84 */ 264 268 #define MIPI_PHY_CONTROL_3 0x03