Lines Matching +full:aux +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0-only
35 #include <media/v4l2-fwnode.h>
36 #include <sound/hdmi-codec.h>
50 struct device *dev = &client->dev; in i2c_access_workaround()
53 if (client == ctx->last_client) in i2c_access_workaround()
56 ctx->last_client = client; in i2c_access_workaround()
58 if (client == ctx->i2c.tcpc_client) in i2c_access_workaround()
60 else if (client == ctx->i2c.tx_p0_client) in i2c_access_workaround()
62 else if (client == ctx->i2c.tx_p1_client) in i2c_access_workaround()
64 else if (client == ctx->i2c.rx_p0_client) in i2c_access_workaround()
66 else if (client == ctx->i2c.rx_p1_client) in i2c_access_workaround()
75 client->addr, offset); in i2c_access_workaround()
84 struct device *dev = &client->dev; in anx7625_reg_read()
91 client->addr, reg_addr); in anx7625_reg_read()
101 struct device *dev = &client->dev; in anx7625_reg_block_read()
108 client->addr, reg_addr); in anx7625_reg_block_read()
118 struct device *dev = &client->dev; in anx7625_reg_write()
126 client->addr, reg_addr); in anx7625_reg_write()
136 struct device *dev = &client->dev; in anx7625_reg_block_write()
143 client->addr, reg_addr); in anx7625_reg_block_write()
192 ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client, in anx7625_config_bit_matrix()
195 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, in anx7625_config_bit_matrix()
204 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_CTRL_STATUS); in anx7625_read_ctrl_status_p0()
209 struct device *dev = ctx->dev; in wait_aux_op_finish()
219 DRM_DEV_ERROR(dev, "aux operation fail!\n"); in wait_aux_op_finish()
220 return -EIO; in wait_aux_op_finish()
223 val = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, in wait_aux_op_finish()
226 DRM_DEV_ERROR(dev, "aux status %02x\n", val); in wait_aux_op_finish()
227 return -EIO; in wait_aux_op_finish()
236 struct device *dev = ctx->dev; in anx7625_aux_trans()
243 dev_err(dev, "exceed aux buffer len.\n"); in anx7625_aux_trans()
244 return -EINVAL; in anx7625_aux_trans()
259 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
262 /* Set aux access address */ in anx7625_aux_trans()
263 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
265 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
267 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
271 ret |= anx7625_reg_block_write(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
273 /* Enable aux access */ in anx7625_aux_trans()
274 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
278 dev_err(dev, "cannot access aux related register.\n"); in anx7625_aux_trans()
279 return -EIO; in anx7625_aux_trans()
284 dev_err(dev, "aux IO error: wait aux op finish.\n"); in anx7625_aux_trans()
293 ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client, in anx7625_aux_trans()
297 return -EIO; in anx7625_aux_trans()
310 ret = anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in anx7625_video_mute_control()
313 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in anx7625_video_mute_control()
317 ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in anx7625_video_mute_control()
320 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in anx7625_video_mute_control()
370 return -EINVAL; in anx7625_calculate_m_n()
378 return -EINVAL; in anx7625_calculate_m_n()
394 return -EDOM; in anx7625_calculate_m_n()
414 return -EDOM; in anx7625_calculate_m_n()
429 struct device *dev = ctx->dev; in anx7625_odfc_config()
432 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_16, in anx7625_odfc_config()
434 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_16, in anx7625_odfc_config()
437 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client, in anx7625_odfc_config()
439 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_8, in anx7625_odfc_config()
442 /* Add patch for MIS2-125 (5pcs ANX7625 fail ATE MBIST test) */ in anx7625_odfc_config()
443 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_7, in anx7625_odfc_config()
447 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_7, in anx7625_odfc_config()
449 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_7, in anx7625_odfc_config()
469 drm_edid_get_product_id(ctx->cached_drm_edid, &id); in anx7625_set_k_value()
472 return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_set_k_value()
475 return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_set_k_value()
481 struct device *dev = ctx->dev; in anx7625_dsi_video_timing_config()
487 ret = anx7625_calculate_m_n(ctx->dt.pixelclock.min * 1000, in anx7625_dsi_video_timing_config()
499 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, PIXEL_CLOCK_L, in anx7625_dsi_video_timing_config()
500 (ctx->dt.pixelclock.min / 1000) & 0xFF); in anx7625_dsi_video_timing_config()
501 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, PIXEL_CLOCK_H, in anx7625_dsi_video_timing_config()
502 (ctx->dt.pixelclock.min / 1000) >> 8); in anx7625_dsi_video_timing_config()
504 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
506 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
507 MIPI_LANE_CTRL_0, ctx->pdata.mipi_lanes - 1); in anx7625_dsi_video_timing_config()
510 htotal = ctx->dt.hactive.min + ctx->dt.hfront_porch.min + in anx7625_dsi_video_timing_config()
511 ctx->dt.hback_porch.min + ctx->dt.hsync_len.min; in anx7625_dsi_video_timing_config()
512 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
514 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
517 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
518 HORIZONTAL_ACTIVE_PIXELS_L, ctx->dt.hactive.min & 0xFF); in anx7625_dsi_video_timing_config()
519 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
520 HORIZONTAL_ACTIVE_PIXELS_H, ctx->dt.hactive.min >> 8); in anx7625_dsi_video_timing_config()
522 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
523 HORIZONTAL_FRONT_PORCH_L, ctx->dt.hfront_porch.min); in anx7625_dsi_video_timing_config()
524 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
526 ctx->dt.hfront_porch.min >> 8); in anx7625_dsi_video_timing_config()
528 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
529 HORIZONTAL_SYNC_WIDTH_L, ctx->dt.hsync_len.min); in anx7625_dsi_video_timing_config()
530 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
531 HORIZONTAL_SYNC_WIDTH_H, ctx->dt.hsync_len.min >> 8); in anx7625_dsi_video_timing_config()
533 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
534 HORIZONTAL_BACK_PORCH_L, ctx->dt.hback_porch.min); in anx7625_dsi_video_timing_config()
535 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
536 HORIZONTAL_BACK_PORCH_H, ctx->dt.hback_porch.min >> 8); in anx7625_dsi_video_timing_config()
538 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, ACTIVE_LINES_L, in anx7625_dsi_video_timing_config()
539 ctx->dt.vactive.min); in anx7625_dsi_video_timing_config()
540 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, ACTIVE_LINES_H, in anx7625_dsi_video_timing_config()
541 ctx->dt.vactive.min >> 8); in anx7625_dsi_video_timing_config()
543 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
544 VERTICAL_FRONT_PORCH, ctx->dt.vfront_porch.min); in anx7625_dsi_video_timing_config()
546 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
547 VERTICAL_SYNC_WIDTH, ctx->dt.vsync_len.min); in anx7625_dsi_video_timing_config()
549 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, in anx7625_dsi_video_timing_config()
550 VERTICAL_BACK_PORCH, ctx->dt.vback_porch.min); in anx7625_dsi_video_timing_config()
552 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
554 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
556 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
559 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
561 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_dsi_video_timing_config()
563 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, MIPI_PLL_N_NUM_7_0, in anx7625_dsi_video_timing_config()
568 ret |= anx7625_odfc_config(ctx, post_divider - 1); in anx7625_dsi_video_timing_config()
579 struct device *dev = ctx->dev; in anx7625_swap_dsi_lane3()
581 /* Swap MIPI-DSI data lane 3 P and N */ in anx7625_swap_dsi_lane3()
582 val = anx7625_reg_read(ctx, ctx->i2c.rx_p1_client, MIPI_SWAP); in anx7625_swap_dsi_lane3()
585 return -EIO; in anx7625_swap_dsi_lane3()
589 return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, MIPI_SWAP, val); in anx7625_swap_dsi_lane3()
596 struct device *dev = ctx->dev; in anx7625_api_dsi_config()
598 /* Swap MIPI-DSI data lane 3 P and N */ in anx7625_api_dsi_config()
614 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dsi_config()
621 * P332 D-PHY Probe) default D-PHY timing in anx7625_api_dsi_config()
624 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dsi_config()
628 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_18, in anx7625_api_dsi_config()
638 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_6, in anx7625_api_dsi_config()
641 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_6, in anx7625_api_dsi_config()
645 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dsi_config()
648 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dsi_config()
650 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dsi_config()
661 struct device *dev = ctx->dev; in anx7625_dsi_config()
667 ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in anx7625_dsi_config()
678 ret = anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in anx7625_dsi_config()
681 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in anx7625_dsi_config()
693 struct device *dev = ctx->dev; in anx7625_api_dpi_config()
694 u16 freq = ctx->dt.pixelclock.min / 1000; in anx7625_api_dpi_config()
698 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_api_dpi_config()
700 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_api_dpi_config()
705 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dpi_config()
708 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dpi_config()
711 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, in anx7625_api_dpi_config()
714 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, in anx7625_api_dpi_config()
724 struct device *dev = ctx->dev; in anx7625_dpi_config()
730 ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in anx7625_dpi_config()
750 ret = anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in anx7625_dpi_config()
753 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in anx7625_dpi_config()
763 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, R_RAM_CTRL); in anx7625_read_flash_status()
769 struct device *dev = ctx->dev; in anx7625_hdcp_key_probe()
772 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_probe()
774 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_probe()
781 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_probe()
782 FLASH_LEN_HIGH, (FLASH_BUF_LEN - 1) >> 8); in anx7625_hdcp_key_probe()
783 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_probe()
784 FLASH_LEN_LOW, (FLASH_BUF_LEN - 1) & 0xFF); in anx7625_hdcp_key_probe()
790 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_probe()
799 return -EIO; in anx7625_hdcp_key_probe()
802 ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_probe()
807 return -EIO; in anx7625_hdcp_key_probe()
811 return -EINVAL; in anx7625_hdcp_key_probe()
819 struct device *dev = ctx->dev; in anx7625_hdcp_key_load()
822 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
824 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
826 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
828 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
830 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
833 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
835 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
838 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hdcp_key_load()
847 struct device *dev = ctx->dev; in anx7625_hdcp_disable()
852 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, 0xee, 0x9f); in anx7625_hdcp_disable()
854 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xec, 0x10); in anx7625_hdcp_disable()
856 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xff, 0x01); in anx7625_hdcp_disable()
860 return anx7625_write_and(ctx, ctx->i2c.tx_p0_client, in anx7625_hdcp_disable()
868 struct device *dev = ctx->dev; in anx7625_hdcp_enable()
889 ret = anx7625_reg_write(ctx, ctx->i2c.tx_p0_client, in anx7625_hdcp_enable()
894 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p0_client, in anx7625_hdcp_enable()
899 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p0_client, in anx7625_hdcp_enable()
902 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p0_client, in anx7625_hdcp_enable()
910 ret = anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xee, 0x20); in anx7625_hdcp_enable()
913 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xec, 0x10); in anx7625_hdcp_enable()
915 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xff, 0x01); in anx7625_hdcp_enable()
919 return anx7625_write_or(ctx, ctx->i2c.tx_p0_client, in anx7625_hdcp_enable()
926 struct device *dev = ctx->dev; in anx7625_dp_start()
929 if (!ctx->display_timing_valid) { in anx7625_dp_start()
942 anx7625_write_and(ctx, ctx->i2c.rx_p1_client, 0xee, 0x9f); in anx7625_dp_start()
944 if (ctx->pdata.is_dpi) in anx7625_dp_start()
952 ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_UNDESIRED; in anx7625_dp_start()
954 ctx->dp_en = 1; in anx7625_dp_start()
959 struct device *dev = ctx->dev; in anx7625_dp_stop()
969 ret = anx7625_write_and(ctx, ctx->i2c.tx_p0_client, 0x87, 0xfe); in anx7625_dp_stop()
970 ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, 0x08, 0x7f); in anx7625_dp_stop()
981 ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_UNDESIRED; in anx7625_dp_stop()
983 ctx->dp_en = 0; in anx7625_dp_stop()
990 ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client, RST_CTRL2, in sp_tx_rst_aux()
992 ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, RST_CTRL2, in sp_tx_rst_aux()
1001 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in sp_tx_aux_wr()
1003 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in sp_tx_aux_wr()
1005 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in sp_tx_aux_wr()
1014 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in sp_tx_aux_rd()
1016 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in sp_tx_aux_rd()
1024 struct device *dev = ctx->dev; in sp_tx_get_edid_block()
1028 c = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_BUFF_START); in sp_tx_get_edid_block()
1030 DRM_DEV_ERROR(dev, "IO error : access AUX BUFF.\n"); in sp_tx_get_edid_block()
1031 return -EIO; in sp_tx_get_edid_block()
1046 struct device *dev = ctx->dev; in edid_read()
1057 ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client, in edid_read()
1067 return -EIO; in edid_read()
1077 struct device *dev = ctx->dev; in segments_edid_read()
1080 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in segments_edid_read()
1082 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in segments_edid_read()
1084 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in segments_edid_read()
1092 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in segments_edid_read()
1095 DRM_DEV_ERROR(dev, "IO error : aux initial fail.\n"); in segments_edid_read()
1108 ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client, in segments_edid_read()
1117 return -EIO; in segments_edid_read()
1132 struct device *dev = ctx->dev; in sp_tx_edid_read()
1135 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in sp_tx_edid_read()
1137 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in sp_tx_edid_read()
1139 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client, in sp_tx_edid_read()
1142 DRM_DEV_ERROR(dev, "access aux channel IO error.\n"); in sp_tx_edid_read()
1143 return -EIO; in sp_tx_edid_read()
1224 return -EINVAL; in sp_tx_edid_read()
1227 /* Reset aux channel */ in sp_tx_edid_read()
1230 DRM_DEV_ERROR(dev, "Failed to reset aux channel!\n"); in sp_tx_edid_read()
1239 struct device *dev = ctx->dev; in anx7625_power_on()
1242 if (!ctx->pdata.low_power_mode) { in anx7625_power_on()
1247 for (i = 0; i < ARRAY_SIZE(ctx->pdata.supplies); i++) { in anx7625_power_on()
1248 ret = regulator_enable(ctx->pdata.supplies[i].consumer); in anx7625_power_on()
1260 gpiod_set_value(ctx->pdata.gpio_p_on, 1); in anx7625_power_on()
1263 gpiod_set_value(ctx->pdata.gpio_reset, 1); in anx7625_power_on()
1269 for (--i; i >= 0; i--) in anx7625_power_on()
1270 regulator_disable(ctx->pdata.supplies[i].consumer); in anx7625_power_on()
1275 struct device *dev = ctx->dev; in anx7625_power_standby()
1278 if (!ctx->pdata.low_power_mode) { in anx7625_power_standby()
1283 gpiod_set_value(ctx->pdata.gpio_reset, 0); in anx7625_power_standby()
1285 gpiod_set_value(ctx->pdata.gpio_p_on, 0); in anx7625_power_standby()
1288 ret = regulator_bulk_disable(ARRAY_SIZE(ctx->pdata.supplies), in anx7625_power_standby()
1289 ctx->pdata.supplies); in anx7625_power_standby()
1299 anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_config()
1308 ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, in anx7625_hpd_timer_config()
1310 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, in anx7625_hpd_timer_config()
1313 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client, in anx7625_hpd_timer_config()
1322 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, GPIO_CTRL_2); in anx7625_read_hpd_gpio_config_status()
1327 struct device *dev = ctx->dev; in anx7625_disable_pd_protocol()
1331 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, 0x88, 0x40); in anx7625_disable_pd_protocol()
1333 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_disable_pd_protocol()
1336 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, 0x88, 0x00); in anx7625_disable_pd_protocol()
1360 struct device *dev = ctx->dev; in anx7625_ocm_loading_check()
1363 ret = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, in anx7625_ocm_loading_check()
1370 return -ENODEV; in anx7625_ocm_loading_check()
1376 ctx->i2c.rx_p0_client, in anx7625_ocm_loading_check()
1379 ctx->i2c.rx_p0_client, in anx7625_ocm_loading_check()
1406 struct device *dev = platform->dev; in anx7625_init_gpio()
1411 platform->pdata.gpio_p_on = in anx7625_init_gpio()
1413 if (IS_ERR_OR_NULL(platform->pdata.gpio_p_on)) { in anx7625_init_gpio()
1415 platform->pdata.gpio_p_on = NULL; in anx7625_init_gpio()
1419 platform->pdata.gpio_reset = in anx7625_init_gpio()
1421 if (IS_ERR_OR_NULL(platform->pdata.gpio_reset)) { in anx7625_init_gpio()
1423 platform->pdata.gpio_reset = NULL; in anx7625_init_gpio()
1426 if (platform->pdata.gpio_p_on && platform->pdata.gpio_reset) { in anx7625_init_gpio()
1427 platform->pdata.low_power_mode = 1; in anx7625_init_gpio()
1429 desc_to_gpio(platform->pdata.gpio_p_on), in anx7625_init_gpio()
1430 desc_to_gpio(platform->pdata.gpio_reset)); in anx7625_init_gpio()
1432 platform->pdata.low_power_mode = 0; in anx7625_init_gpio()
1439 ctx->hpd_status = 0; in anx7625_stop_dp_work()
1440 ctx->hpd_high_cnt = 0; in anx7625_stop_dp_work()
1446 struct device *dev = ctx->dev; in anx7625_start_dp_work()
1448 if (ctx->hpd_high_cnt >= 2) { in anx7625_start_dp_work()
1453 ctx->hpd_status = 1; in anx7625_start_dp_work()
1454 ctx->hpd_high_cnt++; in anx7625_start_dp_work()
1457 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, 0xee, 0x9f); in anx7625_start_dp_work()
1460 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xec, 0x10); in anx7625_start_dp_work()
1462 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xff, 0x01); in anx7625_start_dp_work()
1468 ret = anx7625_reg_read(ctx, ctx->i2c.rx_p1_client, 0x86); in anx7625_start_dp_work()
1477 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, SYSTEM_STSTUS); in anx7625_read_hpd_status_p0()
1484 struct device *dev = ctx->dev; in _anx7625_hpd_polling()
1487 if (ctx->pdata.intp_irq) in _anx7625_hpd_polling()
1501 anx7625_reg_write(ctx, ctx->i2c.tcpc_client, in _anx7625_hpd_polling()
1503 anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in _anx7625_hpd_polling()
1508 if (!ctx->pdata.panel_bridge && ctx->bridge_attached) in _anx7625_hpd_polling()
1509 drm_helper_hpd_irq_event(ctx->bridge.dev); in _anx7625_hpd_polling()
1514 static int anx7625_wait_hpd_asserted(struct drm_dp_aux *aux, in anx7625_wait_hpd_asserted() argument
1517 struct anx7625_data *ctx = container_of(aux, struct anx7625_data, aux); in anx7625_wait_hpd_asserted()
1518 struct device *dev = ctx->dev; in anx7625_wait_hpd_asserted()
1531 drm_edid_free(ctx->cached_drm_edid); in anx7625_remove_edid()
1532 ctx->cached_drm_edid = NULL; in anx7625_remove_edid()
1539 for (i = 0; i < ctx->pdata.dp_lane0_swing_reg_cnt; i++) in anx7625_dp_adjust_swing()
1540 anx7625_reg_write(ctx, ctx->i2c.tx_p1_client, in anx7625_dp_adjust_swing()
1542 ctx->pdata.lane0_reg_data[i]); in anx7625_dp_adjust_swing()
1544 for (i = 0; i < ctx->pdata.dp_lane1_swing_reg_cnt; i++) in anx7625_dp_adjust_swing()
1545 anx7625_reg_write(ctx, ctx->i2c.tx_p1_client, in anx7625_dp_adjust_swing()
1547 ctx->pdata.lane1_reg_data[i]); in anx7625_dp_adjust_swing()
1552 struct device *dev = ctx->dev; in dp_hpd_change_handler()
1572 struct device *dev = ctx->dev; in anx7625_hpd_change_detect()
1574 status = anx7625_reg_write(ctx, ctx->i2c.tcpc_client, in anx7625_hpd_change_detect()
1581 intr_vector = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, in anx7625_hpd_change_detect()
1588 status = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, in anx7625_hpd_change_detect()
1597 return -ENOENT; in anx7625_hpd_change_detect()
1599 status = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, in anx7625_hpd_change_detect()
1618 mutex_lock(&ctx->lock); in anx7625_work_func()
1620 if (pm_runtime_suspended(ctx->dev)) { in anx7625_work_func()
1621 mutex_unlock(&ctx->lock); in anx7625_work_func()
1627 mutex_unlock(&ctx->lock); in anx7625_work_func()
1632 if (ctx->bridge_attached) in anx7625_work_func()
1633 drm_helper_hpd_irq_event(ctx->bridge.dev); in anx7625_work_func()
1640 queue_work(ctx->workqueue, &ctx->work); in anx7625_intr_hpd_isr()
1650 num_regs = of_property_read_variable_u8_array(dev->of_node, "analogix,lane0-swing", in anx7625_get_swing_setting()
1651 pdata->lane0_reg_data, 1, DP_TX_SWING_REG_CNT); in anx7625_get_swing_setting()
1653 pdata->dp_lane0_swing_reg_cnt = num_regs; in anx7625_get_swing_setting()
1655 num_regs = of_property_read_variable_u8_array(dev->of_node, "analogix,lane1-swing", in anx7625_get_swing_setting()
1656 pdata->lane1_reg_data, 1, DP_TX_SWING_REG_CNT); in anx7625_get_swing_setting()
1658 pdata->dp_lane1_swing_reg_cnt = num_regs; in anx7625_get_swing_setting()
1666 struct device_node *np = dev->of_node, *ep0; in anx7625_parse_dt()
1671 pdata->is_dpi = 0; /* default dsi mode */ in anx7625_parse_dt()
1672 of_node_put(pdata->mipi_host_node); in anx7625_parse_dt()
1673 pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0); in anx7625_parse_dt()
1674 if (!pdata->mipi_host_node) { in anx7625_parse_dt()
1676 return -ENODEV; in anx7625_parse_dt()
1683 if (of_property_read_u32(ep0, "bus-type", &bus_type)) in anx7625_parse_dt()
1690 if (bus_type == V4L2_FWNODE_BUS_TYPE_DPI) /* bus type is DPI */ in anx7625_parse_dt()
1691 pdata->is_dpi = 1; in anx7625_parse_dt()
1693 pdata->mipi_lanes = MAX_LANES_SUPPORT; in anx7625_parse_dt()
1695 pdata->mipi_lanes = mipi_lanes; in anx7625_parse_dt()
1697 if (pdata->is_dpi) in anx7625_parse_dt()
1702 if (of_property_read_bool(np, "analogix,audio-enable")) in anx7625_parse_dt()
1703 pdata->audio_en = 1; in anx7625_parse_dt()
1711 struct device_node *np = dev->of_node; in anx7625_parse_dt_panel()
1713 pdata->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0); in anx7625_parse_dt_panel()
1714 if (IS_ERR(pdata->panel_bridge)) { in anx7625_parse_dt_panel()
1715 if (PTR_ERR(pdata->panel_bridge) == -ENODEV) { in anx7625_parse_dt_panel()
1716 pdata->panel_bridge = NULL; in anx7625_parse_dt_panel()
1720 return PTR_ERR(pdata->panel_bridge); in anx7625_parse_dt_panel()
1730 struct device_node *bus, *panel; in anx7625_of_panel_on_aux_bus() local
1732 bus = of_get_child_by_name(dev->of_node, "aux-bus"); in anx7625_of_panel_on_aux_bus()
1733 if (!bus) in anx7625_of_panel_on_aux_bus()
1736 panel = of_get_child_by_name(bus, "panel"); in anx7625_of_panel_on_aux_bus()
1737 of_node_put(bus); in anx7625_of_panel_on_aux_bus()
1750 static ssize_t anx7625_aux_transfer(struct drm_dp_aux *aux, in anx7625_aux_transfer() argument
1753 struct anx7625_data *ctx = container_of(aux, struct anx7625_data, aux); in anx7625_aux_transfer()
1754 struct device *dev = ctx->dev; in anx7625_aux_transfer()
1755 u8 request = msg->request & ~DP_AUX_I2C_MOT; in anx7625_aux_transfer()
1758 mutex_lock(&ctx->aux_lock); in anx7625_aux_transfer()
1760 msg->reply = 0; in anx7625_aux_transfer()
1768 ret = -EINVAL; in anx7625_aux_transfer()
1771 ret = anx7625_aux_trans(ctx, msg->request, msg->address, in anx7625_aux_transfer()
1772 msg->size, msg->buffer); in anx7625_aux_transfer()
1775 mutex_unlock(&ctx->aux_lock); in anx7625_aux_transfer()
1782 struct device *dev = ctx->dev; in anx7625_edid_read()
1786 if (ctx->cached_drm_edid) in anx7625_edid_read()
1804 ctx->cached_drm_edid = drm_edid_alloc(edid_buf, FOUR_BLOCK_SIZE); in anx7625_edid_read()
1808 return drm_edid_dup(ctx->cached_drm_edid); in anx7625_edid_read()
1813 struct device *dev = ctx->dev; in anx7625_sink_detect()
1817 if (ctx->pdata.panel_bridge) in anx7625_sink_detect()
1820 return ctx->hpd_status ? connector_status_connected : in anx7625_sink_detect()
1837 if (fmt->fmt != HDMI_DSP_A && fmt->fmt != HDMI_I2S) { in anx7625_audio_hw_params()
1839 return -EINVAL; in anx7625_audio_hw_params()
1843 params->sample_rate, params->sample_width, in anx7625_audio_hw_params()
1844 params->cea.channels); in anx7625_audio_hw_params()
1846 if (fmt->fmt == HDMI_DSP_A) in anx7625_audio_hw_params()
1847 ret = anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1852 ret = anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1858 switch (params->sample_width) { in anx7625_audio_hw_params()
1873 params->sample_width); in anx7625_audio_hw_params()
1874 return -EINVAL; in anx7625_audio_hw_params()
1876 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1881 switch (params->cea.channels) { in anx7625_audio_hw_params()
1896 params->cea.channels); in anx7625_audio_hw_params()
1897 return -EINVAL; in anx7625_audio_hw_params()
1899 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1902 ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1905 ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1909 switch (params->sample_rate) { in anx7625_audio_hw_params()
1933 params->sample_rate); in anx7625_audio_hw_params()
1934 return -EINVAL; in anx7625_audio_hw_params()
1936 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client, in anx7625_audio_hw_params()
1939 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client, in anx7625_audio_hw_params()
1943 return -EIO; in anx7625_audio_hw_params()
1976 if (ctx->plugged_cb && ctx->codec_dev) { in anx7625_audio_update_connector_status()
1977 ctx->plugged_cb(ctx->codec_dev, in anx7625_audio_update_connector_status()
1988 ctx->plugged_cb = fn; in anx7625_audio_hook_plugged_cb()
1989 ctx->codec_dev = codec_dev; in anx7625_audio_hook_plugged_cb()
2000 if (!ctx->connector) { in anx7625_audio_get_eld()
2005 memcpy(buf, ctx->connector->eld, in anx7625_audio_get_eld()
2006 min(sizeof(ctx->connector->eld), len)); in anx7625_audio_get_eld()
2022 struct device *dev = ctx->dev; in anx7625_unregister_audio()
2024 if (ctx->audio_pdev) { in anx7625_unregister_audio()
2025 platform_device_unregister(ctx->audio_pdev); in anx7625_unregister_audio()
2026 ctx->audio_pdev = NULL; in anx7625_unregister_audio()
2041 ctx->audio_pdev = platform_device_register_data(dev, in anx7625_register_audio()
2047 if (IS_ERR(ctx->audio_pdev)) in anx7625_register_audio()
2048 return PTR_ERR(ctx->audio_pdev); in anx7625_register_audio()
2058 struct device *dev = ctx->dev; in anx7625_setup_dsi_device()
2066 host = of_find_mipi_dsi_host_by_node(ctx->pdata.mipi_host_node); in anx7625_setup_dsi_device()
2068 return dev_err_probe(dev, -EPROBE_DEFER, "fail to find dsi host.\n"); in anx7625_setup_dsi_device()
2073 return -EINVAL; in anx7625_setup_dsi_device()
2076 dsi->lanes = ctx->pdata.mipi_lanes; in anx7625_setup_dsi_device()
2077 dsi->format = MIPI_DSI_FMT_RGB888; in anx7625_setup_dsi_device()
2078 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | in anx7625_setup_dsi_device()
2083 ctx->dsi = dsi; in anx7625_setup_dsi_device()
2090 struct device *dev = ctx->dev; in anx7625_attach_dsi()
2095 ret = devm_mipi_dsi_attach(dev, ctx->dsi); in anx7625_attach_dsi()
2116 dev = ctx->dev; in hdcp_check_work_func()
2118 if (!ctx->connector) { in hdcp_check_work_func()
2123 drm_dev = ctx->connector->dev; in hdcp_check_work_func()
2124 drm_modeset_lock(&drm_dev->mode_config.connection_mutex, NULL); in hdcp_check_work_func()
2125 mutex_lock(&ctx->hdcp_wq_lock); in hdcp_check_work_func()
2127 status = anx7625_reg_read(ctx, ctx->i2c.tx_p0_client, 0); in hdcp_check_work_func()
2130 ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_ENABLED; in hdcp_check_work_func()
2131 drm_hdcp_update_content_protection(ctx->connector, in hdcp_check_work_func()
2132 ctx->hdcp_cp); in hdcp_check_work_func()
2136 mutex_unlock(&ctx->hdcp_wq_lock); in hdcp_check_work_func()
2137 drm_modeset_unlock(&drm_dev->mode_config.connection_mutex); in hdcp_check_work_func()
2143 struct device *dev = ctx->dev; in anx7625_connector_atomic_check()
2147 cp = state->content_protection; in anx7625_connector_atomic_check()
2149 if (cp == ctx->hdcp_cp) in anx7625_connector_atomic_check()
2153 if (ctx->dp_en) { in anx7625_connector_atomic_check()
2157 queue_delayed_work(ctx->hdcp_workqueue, in anx7625_connector_atomic_check()
2158 &ctx->hdcp_work, in anx7625_connector_atomic_check()
2164 if (ctx->hdcp_cp != DRM_MODE_CONTENT_PROTECTION_ENABLED) { in anx7625_connector_atomic_check()
2166 return -EINVAL; in anx7625_connector_atomic_check()
2169 ctx->hdcp_cp = DRM_MODE_CONTENT_PROTECTION_UNDESIRED; in anx7625_connector_atomic_check()
2170 drm_hdcp_update_content_protection(ctx->connector, in anx7625_connector_atomic_check()
2171 ctx->hdcp_cp); in anx7625_connector_atomic_check()
2177 return -EINVAL; in anx7625_connector_atomic_check()
2188 struct device *dev = ctx->dev; in anx7625_bridge_attach()
2192 return -EINVAL; in anx7625_bridge_attach()
2194 ctx->aux.drm_dev = bridge->dev; in anx7625_bridge_attach()
2195 err = drm_dp_aux_register(&ctx->aux); in anx7625_bridge_attach()
2197 dev_err(dev, "failed to register aux channel: %d\n", err); in anx7625_bridge_attach()
2201 if (ctx->pdata.panel_bridge) { in anx7625_bridge_attach()
2202 err = drm_bridge_attach(bridge->encoder, in anx7625_bridge_attach()
2203 ctx->pdata.panel_bridge, in anx7625_bridge_attach()
2204 &ctx->bridge, flags); in anx7625_bridge_attach()
2209 ctx->bridge_attached = 1; in anx7625_bridge_attach()
2218 drm_dp_aux_unregister(&ctx->aux); in anx7625_bridge_detach()
2227 struct device *dev = ctx->dev; in anx7625_bridge_mode_valid()
2232 if (mode->clock > SUPPORT_PIXEL_CLOCK) { in anx7625_bridge_mode_valid()
2248 struct device *dev = ctx->dev; in anx7625_bridge_mode_set()
2252 ctx->dt.pixelclock.min = mode->clock; in anx7625_bridge_mode_set()
2253 ctx->dt.hactive.min = mode->hdisplay; in anx7625_bridge_mode_set()
2254 ctx->dt.hsync_len.min = mode->hsync_end - mode->hsync_start; in anx7625_bridge_mode_set()
2255 ctx->dt.hfront_porch.min = mode->hsync_start - mode->hdisplay; in anx7625_bridge_mode_set()
2256 ctx->dt.hback_porch.min = mode->htotal - mode->hsync_end; in anx7625_bridge_mode_set()
2257 ctx->dt.vactive.min = mode->vdisplay; in anx7625_bridge_mode_set()
2258 ctx->dt.vsync_len.min = mode->vsync_end - mode->vsync_start; in anx7625_bridge_mode_set()
2259 ctx->dt.vfront_porch.min = mode->vsync_start - mode->vdisplay; in anx7625_bridge_mode_set()
2260 ctx->dt.vback_porch.min = mode->vtotal - mode->vsync_end; in anx7625_bridge_mode_set()
2262 ctx->display_timing_valid = 1; in anx7625_bridge_mode_set()
2264 DRM_DEV_DEBUG_DRIVER(dev, "pixelclock(%d).\n", ctx->dt.pixelclock.min); in anx7625_bridge_mode_set()
2266 ctx->dt.hactive.min, in anx7625_bridge_mode_set()
2267 ctx->dt.hsync_len.min, in anx7625_bridge_mode_set()
2268 ctx->dt.hfront_porch.min, in anx7625_bridge_mode_set()
2269 ctx->dt.hback_porch.min); in anx7625_bridge_mode_set()
2271 ctx->dt.vactive.min, in anx7625_bridge_mode_set()
2272 ctx->dt.vsync_len.min, in anx7625_bridge_mode_set()
2273 ctx->dt.vfront_porch.min, in anx7625_bridge_mode_set()
2274 ctx->dt.vback_porch.min); in anx7625_bridge_mode_set()
2276 mode->hdisplay, in anx7625_bridge_mode_set()
2277 mode->hsync_start); in anx7625_bridge_mode_set()
2279 mode->hsync_end, in anx7625_bridge_mode_set()
2280 mode->htotal); in anx7625_bridge_mode_set()
2282 mode->vdisplay, in anx7625_bridge_mode_set()
2283 mode->vsync_start); in anx7625_bridge_mode_set()
2285 mode->vsync_end, in anx7625_bridge_mode_set()
2286 mode->vtotal); in anx7625_bridge_mode_set()
2294 struct device *dev = ctx->dev; in anx7625_bridge_mode_fixup()
2302 if (!ctx->pdata.panel_bridge) in anx7625_bridge_mode_fixup()
2305 hsync = mode->hsync_end - mode->hsync_start; in anx7625_bridge_mode_fixup()
2306 hfp = mode->hsync_start - mode->hdisplay; in anx7625_bridge_mode_fixup()
2307 hbp = mode->htotal - mode->hsync_end; in anx7625_bridge_mode_fixup()
2308 hblanking = mode->htotal - mode->hdisplay; in anx7625_bridge_mode_fixup()
2312 hsync, hfp, hbp, adj->clock); in anx7625_bridge_mode_fixup()
2314 adj->hsync_start, adj->hsync_end, adj->htotal); in anx7625_bridge_mode_fixup()
2329 adj_hbp -= 1; in anx7625_bridge_mode_fixup()
2330 adj_hblanking -= 1; in anx7625_bridge_mode_fixup()
2338 adj_hsync -= 1; in anx7625_bridge_mode_fixup()
2343 * This adjusting made for built-in eDP panel, for the externel in anx7625_bridge_mode_fixup()
2350 vref = adj->clock * 1000 / (adj->htotal * adj->vtotal); in anx7625_bridge_mode_fixup()
2352 delta_adj = HBLANKING_MIN - hblanking; in anx7625_bridge_mode_fixup()
2353 adj_clock = vref * delta_adj * adj->vtotal; in anx7625_bridge_mode_fixup()
2354 adj->clock += DIV_ROUND_UP(adj_clock, 1000); in anx7625_bridge_mode_fixup()
2356 delta_adj = hblanking - HBLANKING_MIN; in anx7625_bridge_mode_fixup()
2357 adj_clock = vref * delta_adj * adj->vtotal; in anx7625_bridge_mode_fixup()
2358 adj->clock -= DIV_ROUND_UP(adj_clock, 1000); in anx7625_bridge_mode_fixup()
2365 delta_adj = HP_MIN - adj_hfp; in anx7625_bridge_mode_fixup()
2372 if ((adj_hbp - delta_adj) < HP_MIN) in anx7625_bridge_mode_fixup()
2374 adj_hsync -= delta_adj; in anx7625_bridge_mode_fixup()
2376 adj_hbp -= delta_adj; in anx7625_bridge_mode_fixup()
2378 delta_adj = HP_MIN - adj_hbp; in anx7625_bridge_mode_fixup()
2385 if ((adj_hfp - delta_adj) < HP_MIN) in anx7625_bridge_mode_fixup()
2387 adj_hsync -= delta_adj; in anx7625_bridge_mode_fixup()
2389 adj_hfp -= delta_adj; in anx7625_bridge_mode_fixup()
2394 adj_hsync, adj_hfp, adj_hbp, adj->clock); in anx7625_bridge_mode_fixup()
2397 adj->hsync_start = adj->hdisplay + adj_hfp; in anx7625_bridge_mode_fixup()
2398 adj->hsync_end = adj->hsync_start + adj_hsync; in anx7625_bridge_mode_fixup()
2399 adj->htotal = adj->hsync_end + adj_hbp; in anx7625_bridge_mode_fixup()
2401 adj->hsync_start, adj->hsync_end, adj->htotal); in anx7625_bridge_mode_fixup()
2412 struct device *dev = ctx->dev; in anx7625_bridge_atomic_check()
2416 anx7625_bridge_mode_fixup(bridge, &crtc_state->mode, in anx7625_bridge_atomic_check()
2417 &crtc_state->adjusted_mode); in anx7625_bridge_atomic_check()
2426 struct device *dev = ctx->dev; in anx7625_bridge_atomic_enable()
2431 connector = drm_atomic_get_new_connector_for_encoder(state->base.state, in anx7625_bridge_atomic_enable()
2432 bridge->encoder); in anx7625_bridge_atomic_enable()
2436 ctx->connector = connector; in anx7625_bridge_atomic_enable()
2448 struct device *dev = ctx->dev; in anx7625_bridge_atomic_disable()
2452 ctx->connector = NULL; in anx7625_bridge_atomic_disable()
2455 mutex_lock(&ctx->aux_lock); in anx7625_bridge_atomic_disable()
2457 mutex_unlock(&ctx->aux_lock); in anx7625_bridge_atomic_disable()
2468 struct device *dev = ctx->dev; in anx7625_bridge_detect()
2482 struct device *dev = ctx->dev; in anx7625_bridge_edid_read()
2507 struct device *dev = ctx->dev; in anx7625_register_i2c_dummy_clients()
2509 ctx->i2c.tx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2511 if (IS_ERR(ctx->i2c.tx_p0_client)) in anx7625_register_i2c_dummy_clients()
2512 return PTR_ERR(ctx->i2c.tx_p0_client); in anx7625_register_i2c_dummy_clients()
2514 ctx->i2c.tx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2516 if (IS_ERR(ctx->i2c.tx_p1_client)) in anx7625_register_i2c_dummy_clients()
2517 return PTR_ERR(ctx->i2c.tx_p1_client); in anx7625_register_i2c_dummy_clients()
2519 ctx->i2c.tx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2521 if (IS_ERR(ctx->i2c.tx_p2_client)) in anx7625_register_i2c_dummy_clients()
2522 return PTR_ERR(ctx->i2c.tx_p2_client); in anx7625_register_i2c_dummy_clients()
2524 ctx->i2c.rx_p0_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2526 if (IS_ERR(ctx->i2c.rx_p0_client)) in anx7625_register_i2c_dummy_clients()
2527 return PTR_ERR(ctx->i2c.rx_p0_client); in anx7625_register_i2c_dummy_clients()
2529 ctx->i2c.rx_p1_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2531 if (IS_ERR(ctx->i2c.rx_p1_client)) in anx7625_register_i2c_dummy_clients()
2532 return PTR_ERR(ctx->i2c.rx_p1_client); in anx7625_register_i2c_dummy_clients()
2534 ctx->i2c.rx_p2_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2536 if (IS_ERR(ctx->i2c.rx_p2_client)) in anx7625_register_i2c_dummy_clients()
2537 return PTR_ERR(ctx->i2c.rx_p2_client); in anx7625_register_i2c_dummy_clients()
2539 ctx->i2c.tcpc_client = devm_i2c_new_dummy_device(dev, client->adapter, in anx7625_register_i2c_dummy_clients()
2541 if (IS_ERR(ctx->i2c.tcpc_client)) in anx7625_register_i2c_dummy_clients()
2542 return PTR_ERR(ctx->i2c.tcpc_client); in anx7625_register_i2c_dummy_clients()
2551 mutex_lock(&ctx->lock); in anx7625_runtime_pm_suspend()
2556 mutex_unlock(&ctx->lock); in anx7625_runtime_pm_suspend()
2565 mutex_lock(&ctx->lock); in anx7625_runtime_pm_resume()
2569 mutex_unlock(&ctx->lock); in anx7625_runtime_pm_resume()
2587 static int anx7625_link_bridge(struct drm_dp_aux *aux) in anx7625_link_bridge() argument
2589 struct anx7625_data *platform = container_of(aux, struct anx7625_data, aux); in anx7625_link_bridge()
2590 struct device *dev = aux->dev; in anx7625_link_bridge()
2593 ret = anx7625_parse_dt_panel(dev, &platform->pdata); in anx7625_link_bridge()
2599 platform->bridge.funcs = &anx7625_bridge_funcs; in anx7625_link_bridge()
2600 platform->bridge.of_node = dev->of_node; in anx7625_link_bridge()
2602 platform->bridge.ops |= DRM_BRIDGE_OP_EDID; in anx7625_link_bridge()
2603 if (!platform->pdata.panel_bridge) in anx7625_link_bridge()
2604 platform->bridge.ops |= DRM_BRIDGE_OP_HPD | in anx7625_link_bridge()
2606 platform->bridge.type = platform->pdata.panel_bridge ? in anx7625_link_bridge()
2610 drm_bridge_add(&platform->bridge); in anx7625_link_bridge()
2612 if (!platform->pdata.is_dpi) { in anx7625_link_bridge()
2615 drm_bridge_remove(&platform->bridge); in anx7625_link_bridge()
2626 struct device *dev = &client->dev; in anx7625_i2c_probe()
2628 if (!i2c_check_functionality(client->adapter, in anx7625_i2c_probe()
2630 DRM_DEV_ERROR(dev, "anx7625's i2c bus doesn't support\n"); in anx7625_i2c_probe()
2631 return -ENODEV; in anx7625_i2c_probe()
2637 return -ENOMEM; in anx7625_i2c_probe()
2640 pdata = &platform->pdata; in anx7625_i2c_probe()
2642 platform->dev = &client->dev; in anx7625_i2c_probe()
2645 pdata->supplies[0].supply = "vdd10"; in anx7625_i2c_probe()
2646 pdata->supplies[1].supply = "vdd18"; in anx7625_i2c_probe()
2647 pdata->supplies[2].supply = "vdd33"; in anx7625_i2c_probe()
2648 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pdata->supplies), in anx7625_i2c_probe()
2649 pdata->supplies); in anx7625_i2c_probe()
2656 mutex_init(&platform->lock); in anx7625_i2c_probe()
2657 mutex_init(&platform->hdcp_wq_lock); in anx7625_i2c_probe()
2658 mutex_init(&platform->aux_lock); in anx7625_i2c_probe()
2660 INIT_DELAYED_WORK(&platform->hdcp_work, hdcp_check_work_func); in anx7625_i2c_probe()
2661 platform->hdcp_workqueue = create_workqueue("hdcp workqueue"); in anx7625_i2c_probe()
2662 if (!platform->hdcp_workqueue) { in anx7625_i2c_probe()
2664 ret = -ENOMEM; in anx7625_i2c_probe()
2668 platform->pdata.intp_irq = client->irq; in anx7625_i2c_probe()
2669 if (platform->pdata.intp_irq) { in anx7625_i2c_probe()
2670 INIT_WORK(&platform->work, anx7625_work_func); in anx7625_i2c_probe()
2671 platform->workqueue = alloc_workqueue("anx7625_work", in anx7625_i2c_probe()
2673 if (!platform->workqueue) { in anx7625_i2c_probe()
2675 ret = -ENOMEM; in anx7625_i2c_probe()
2679 ret = devm_request_threaded_irq(dev, platform->pdata.intp_irq, in anx7625_i2c_probe()
2683 "anx7625-intp", platform); in anx7625_i2c_probe()
2690 platform->aux.name = "anx7625-aux"; in anx7625_i2c_probe()
2691 platform->aux.dev = dev; in anx7625_i2c_probe()
2692 platform->aux.transfer = anx7625_aux_transfer; in anx7625_i2c_probe()
2693 platform->aux.wait_hpd_asserted = anx7625_wait_hpd_asserted; in anx7625_i2c_probe()
2694 drm_dp_aux_init(&platform->aux); in anx7625_i2c_probe()
2698 if (ret != -EPROBE_DEFER) in anx7625_i2c_probe()
2703 if (!platform->pdata.is_dpi) { in anx7625_i2c_probe()
2715 ret = -ENOMEM; in anx7625_i2c_probe()
2716 DRM_DEV_ERROR(dev, "fail to reserve I2C bus.\n"); in anx7625_i2c_probe()
2729 * Populating the aux bus will retrigger deferred probe, so it needs to in anx7625_i2c_probe()
2733 ret = devm_of_dp_aux_populate_bus(&platform->aux, anx7625_link_bridge); in anx7625_i2c_probe()
2735 if (ret != -ENODEV) { in anx7625_i2c_probe()
2736 DRM_DEV_ERROR(dev, "failed to populate aux bus : %d\n", ret); in anx7625_i2c_probe()
2740 ret = anx7625_link_bridge(&platform->aux); in anx7625_i2c_probe()
2745 if (!platform->pdata.low_power_mode) { in anx7625_i2c_probe()
2752 if (platform->pdata.intp_irq) in anx7625_i2c_probe()
2753 queue_work(platform->workqueue, &platform->work); in anx7625_i2c_probe()
2755 if (platform->pdata.audio_en) in anx7625_i2c_probe()
2763 if (platform->workqueue) in anx7625_i2c_probe()
2764 destroy_workqueue(platform->workqueue); in anx7625_i2c_probe()
2767 if (platform->hdcp_workqueue) in anx7625_i2c_probe()
2768 destroy_workqueue(platform->hdcp_workqueue); in anx7625_i2c_probe()
2777 drm_bridge_remove(&platform->bridge); in anx7625_i2c_remove()
2779 if (platform->pdata.intp_irq) in anx7625_i2c_remove()
2780 destroy_workqueue(platform->workqueue); in anx7625_i2c_remove()
2782 if (platform->hdcp_workqueue) { in anx7625_i2c_remove()
2783 cancel_delayed_work(&platform->hdcp_work); in anx7625_i2c_remove()
2784 flush_workqueue(platform->hdcp_workqueue); in anx7625_i2c_remove()
2785 destroy_workqueue(platform->hdcp_workqueue); in anx7625_i2c_remove()
2788 if (!platform->pdata.low_power_mode) in anx7625_i2c_remove()
2789 pm_runtime_put_sync_suspend(&client->dev); in anx7625_i2c_remove()
2791 if (platform->pdata.audio_en) in anx7625_i2c_remove()