Lines Matching full:ctrl
107 struct dp_ctrl_private *ctrl; in dp_ctrl_push_idle() local
109 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_push_idle()
111 reinit_completion(&ctrl->idle_comp); in dp_ctrl_push_idle()
112 dp_catalog_ctrl_state_ctrl(ctrl->catalog, DP_STATE_CTRL_PUSH_IDLE); in dp_ctrl_push_idle()
114 if (!wait_for_completion_timeout(&ctrl->idle_comp, in dp_ctrl_push_idle()
118 drm_dbg_dp(ctrl->drm_dev, "mainlink off\n"); in dp_ctrl_push_idle()
121 static void dp_ctrl_config_ctrl(struct dp_ctrl_private *ctrl) in dp_ctrl_config_ctrl() argument
124 const u8 *dpcd = ctrl->panel->dpcd; in dp_ctrl_config_ctrl()
133 tbd = dp_link_get_test_bits_depth(ctrl->link, in dp_ctrl_config_ctrl()
134 ctrl->panel->dp_mode.bpp); in dp_ctrl_config_ctrl()
144 config |= ((ctrl->link->link_params.num_lanes - 1) in dp_ctrl_config_ctrl()
156 dp_catalog_ctrl_config_ctrl(ctrl->catalog, config); in dp_ctrl_config_ctrl()
159 static void dp_ctrl_configure_source_params(struct dp_ctrl_private *ctrl) in dp_ctrl_configure_source_params() argument
163 dp_catalog_ctrl_lane_mapping(ctrl->catalog); in dp_ctrl_configure_source_params()
164 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, true); in dp_ctrl_configure_source_params()
166 dp_ctrl_config_ctrl(ctrl); in dp_ctrl_configure_source_params()
168 tb = dp_link_get_test_bits_depth(ctrl->link, in dp_ctrl_configure_source_params()
169 ctrl->panel->dp_mode.bpp); in dp_ctrl_configure_source_params()
170 cc = dp_link_get_colorimetry_config(ctrl->link); in dp_ctrl_configure_source_params()
171 dp_catalog_ctrl_config_misc(ctrl->catalog, cc, tb); in dp_ctrl_configure_source_params()
172 dp_panel_timing_cfg(ctrl->panel); in dp_ctrl_configure_source_params()
607 static void _dp_ctrl_calc_tu(struct dp_ctrl_private *ctrl, in _dp_ctrl_calc_tu() argument
692 drm_dbg_dp(ctrl->drm_dev, in _dp_ctrl_calc_tu()
728 drm_dbg_dp(ctrl->drm_dev, in _dp_ctrl_calc_tu()
923 drm_dbg_dp(ctrl->drm_dev, "TU: valid_boundary_link: %d\n", in _dp_ctrl_calc_tu()
925 drm_dbg_dp(ctrl->drm_dev, "TU: delay_start_link: %d\n", in _dp_ctrl_calc_tu()
927 drm_dbg_dp(ctrl->drm_dev, "TU: boundary_moderation_en: %d\n", in _dp_ctrl_calc_tu()
929 drm_dbg_dp(ctrl->drm_dev, "TU: valid_lower_boundary_link: %d\n", in _dp_ctrl_calc_tu()
931 drm_dbg_dp(ctrl->drm_dev, "TU: upper_boundary_count: %d\n", in _dp_ctrl_calc_tu()
933 drm_dbg_dp(ctrl->drm_dev, "TU: lower_boundary_count: %d\n", in _dp_ctrl_calc_tu()
935 drm_dbg_dp(ctrl->drm_dev, "TU: tu_size_minus1: %d\n", in _dp_ctrl_calc_tu()
941 static void dp_ctrl_calc_tu_parameters(struct dp_ctrl_private *ctrl, in dp_ctrl_calc_tu_parameters() argument
947 drm_mode = &ctrl->panel->dp_mode.drm_mode; in dp_ctrl_calc_tu_parameters()
949 in.lclk = ctrl->link->link_params.rate / 1000; in dp_ctrl_calc_tu_parameters()
953 in.nlanes = ctrl->link->link_params.num_lanes; in dp_ctrl_calc_tu_parameters()
954 in.bpp = ctrl->panel->dp_mode.bpp; in dp_ctrl_calc_tu_parameters()
962 _dp_ctrl_calc_tu(ctrl, &in, tu_table); in dp_ctrl_calc_tu_parameters()
965 static void dp_ctrl_setup_tr_unit(struct dp_ctrl_private *ctrl) in dp_ctrl_setup_tr_unit() argument
972 dp_ctrl_calc_tu_parameters(ctrl, &tu_calc_table); in dp_ctrl_setup_tr_unit()
988 dp_catalog_ctrl_update_transfer_unit(ctrl->catalog, in dp_ctrl_setup_tr_unit()
992 static int dp_ctrl_wait4video_ready(struct dp_ctrl_private *ctrl) in dp_ctrl_wait4video_ready() argument
996 if (!wait_for_completion_timeout(&ctrl->video_comp, in dp_ctrl_wait4video_ready()
1004 static int dp_ctrl_update_vx_px(struct dp_ctrl_private *ctrl) in dp_ctrl_update_vx_px() argument
1006 struct dp_link *link = ctrl->link; in dp_ctrl_update_vx_px()
1013 drm_dbg_dp(ctrl->drm_dev, in dp_ctrl_update_vx_px()
1016 ret = dp_catalog_ctrl_update_vx_px(ctrl->catalog, in dp_ctrl_update_vx_px()
1023 drm_dbg_dp(ctrl->drm_dev, in dp_ctrl_update_vx_px()
1030 drm_dbg_dp(ctrl->drm_dev, in dp_ctrl_update_vx_px()
1038 lane_cnt = ctrl->link->link_params.num_lanes; in dp_ctrl_update_vx_px()
1043 drm_dbg_dp(ctrl->drm_dev, "sink: p|v=0x%x\n", in dp_ctrl_update_vx_px()
1045 ret = drm_dp_dpcd_write(ctrl->aux, DP_TRAINING_LANE0_SET, in dp_ctrl_update_vx_px()
1053 static bool dp_ctrl_train_pattern_set(struct dp_ctrl_private *ctrl, in dp_ctrl_train_pattern_set() argument
1059 drm_dbg_dp(ctrl->drm_dev, "sink: pattern=%x\n", pattern); in dp_ctrl_train_pattern_set()
1066 ret = drm_dp_dpcd_writeb(ctrl->aux, DP_TRAINING_PATTERN_SET, buf); in dp_ctrl_train_pattern_set()
1070 static int dp_ctrl_read_link_status(struct dp_ctrl_private *ctrl, in dp_ctrl_read_link_status() argument
1075 len = drm_dp_dpcd_read_link_status(ctrl->aux, link_status); in dp_ctrl_read_link_status()
1084 static int dp_ctrl_link_train_1(struct dp_ctrl_private *ctrl, in dp_ctrl_link_train_1() argument
1091 dp_catalog_ctrl_state_ctrl(ctrl->catalog, 0); in dp_ctrl_link_train_1()
1095 ret = dp_catalog_ctrl_set_pattern_state_bit(ctrl->catalog, 1); in dp_ctrl_link_train_1()
1098 dp_ctrl_train_pattern_set(ctrl, DP_TRAINING_PATTERN_1 | in dp_ctrl_link_train_1()
1101 ret = dp_ctrl_update_vx_px(ctrl); in dp_ctrl_link_train_1()
1106 old_v_level = ctrl->link->phy_params.v_level; in dp_ctrl_link_train_1()
1108 drm_dp_link_train_clock_recovery_delay(ctrl->aux, ctrl->panel->dpcd); in dp_ctrl_link_train_1()
1110 ret = dp_ctrl_read_link_status(ctrl, link_status); in dp_ctrl_link_train_1()
1115 ctrl->link->link_params.num_lanes)) { in dp_ctrl_link_train_1()
1119 if (ctrl->link->phy_params.v_level >= in dp_ctrl_link_train_1()
1125 if (old_v_level != ctrl->link->phy_params.v_level) { in dp_ctrl_link_train_1()
1127 old_v_level = ctrl->link->phy_params.v_level; in dp_ctrl_link_train_1()
1130 dp_link_adjust_levels(ctrl->link, link_status); in dp_ctrl_link_train_1()
1131 ret = dp_ctrl_update_vx_px(ctrl); in dp_ctrl_link_train_1()
1140 static int dp_ctrl_link_rate_down_shift(struct dp_ctrl_private *ctrl) in dp_ctrl_link_rate_down_shift() argument
1144 switch (ctrl->link->link_params.rate) { in dp_ctrl_link_rate_down_shift()
1146 ctrl->link->link_params.rate = 540000; in dp_ctrl_link_rate_down_shift()
1149 ctrl->link->link_params.rate = 270000; in dp_ctrl_link_rate_down_shift()
1152 ctrl->link->link_params.rate = 162000; in dp_ctrl_link_rate_down_shift()
1161 drm_dbg_dp(ctrl->drm_dev, "new rate=0x%x\n", in dp_ctrl_link_rate_down_shift()
1162 ctrl->link->link_params.rate); in dp_ctrl_link_rate_down_shift()
1168 static int dp_ctrl_link_lane_down_shift(struct dp_ctrl_private *ctrl) in dp_ctrl_link_lane_down_shift() argument
1171 if (ctrl->link->link_params.num_lanes == 1) in dp_ctrl_link_lane_down_shift()
1174 ctrl->link->link_params.num_lanes /= 2; in dp_ctrl_link_lane_down_shift()
1175 ctrl->link->link_params.rate = ctrl->panel->link_info.rate; in dp_ctrl_link_lane_down_shift()
1177 ctrl->link->phy_params.p_level = 0; in dp_ctrl_link_lane_down_shift()
1178 ctrl->link->phy_params.v_level = 0; in dp_ctrl_link_lane_down_shift()
1183 static void dp_ctrl_clear_training_pattern(struct dp_ctrl_private *ctrl) in dp_ctrl_clear_training_pattern() argument
1185 dp_ctrl_train_pattern_set(ctrl, DP_TRAINING_PATTERN_DISABLE); in dp_ctrl_clear_training_pattern()
1186 drm_dp_link_train_channel_eq_delay(ctrl->aux, ctrl->panel->dpcd); in dp_ctrl_clear_training_pattern()
1189 static int dp_ctrl_link_train_2(struct dp_ctrl_private *ctrl, in dp_ctrl_link_train_2() argument
1198 dp_catalog_ctrl_state_ctrl(ctrl->catalog, 0); in dp_ctrl_link_train_2()
1202 if (drm_dp_tps4_supported(ctrl->panel->dpcd)) { in dp_ctrl_link_train_2()
1205 } else if (drm_dp_tps3_supported(ctrl->panel->dpcd)) { in dp_ctrl_link_train_2()
1213 ret = dp_catalog_ctrl_set_pattern_state_bit(ctrl->catalog, state_ctrl_bit); in dp_ctrl_link_train_2()
1217 dp_ctrl_train_pattern_set(ctrl, pattern); in dp_ctrl_link_train_2()
1220 drm_dp_link_train_channel_eq_delay(ctrl->aux, ctrl->panel->dpcd); in dp_ctrl_link_train_2()
1222 ret = dp_ctrl_read_link_status(ctrl, link_status); in dp_ctrl_link_train_2()
1227 ctrl->link->link_params.num_lanes)) { in dp_ctrl_link_train_2()
1231 dp_link_adjust_levels(ctrl->link, link_status); in dp_ctrl_link_train_2()
1232 ret = dp_ctrl_update_vx_px(ctrl); in dp_ctrl_link_train_2()
1241 static int dp_ctrl_link_train(struct dp_ctrl_private *ctrl, in dp_ctrl_link_train() argument
1245 const u8 *dpcd = ctrl->panel->dpcd; in dp_ctrl_link_train()
1250 dp_ctrl_config_ctrl(ctrl); in dp_ctrl_link_train()
1252 link_info.num_lanes = ctrl->link->link_params.num_lanes; in dp_ctrl_link_train()
1253 link_info.rate = ctrl->link->link_params.rate; in dp_ctrl_link_train()
1256 dp_aux_link_configure(ctrl->aux, &link_info); in dp_ctrl_link_train()
1262 drm_dp_dpcd_write(ctrl->aux, DP_DOWNSPREAD_CTRL, encoding, 2); in dp_ctrl_link_train()
1266 drm_dp_dpcd_write(ctrl->aux, DP_EDP_CONFIGURATION_SET, in dp_ctrl_link_train()
1270 ret = dp_ctrl_link_train_1(ctrl, training_step); in dp_ctrl_link_train()
1277 drm_dbg_dp(ctrl->drm_dev, "link training #1 successful\n"); in dp_ctrl_link_train()
1279 ret = dp_ctrl_link_train_2(ctrl, training_step); in dp_ctrl_link_train()
1286 drm_dbg_dp(ctrl->drm_dev, "link training #2 successful\n"); in dp_ctrl_link_train()
1289 dp_catalog_ctrl_state_ctrl(ctrl->catalog, 0); in dp_ctrl_link_train()
1294 static int dp_ctrl_setup_main_link(struct dp_ctrl_private *ctrl, in dp_ctrl_setup_main_link() argument
1299 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, true); in dp_ctrl_setup_main_link()
1301 if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) in dp_ctrl_setup_main_link()
1310 ret = dp_ctrl_link_train(ctrl, training_step); in dp_ctrl_setup_main_link()
1315 static void dp_ctrl_set_clock_rate(struct dp_ctrl_private *ctrl, in dp_ctrl_set_clock_rate() argument
1318 u32 num = ctrl->parser->mp[module].num_clk; in dp_ctrl_set_clock_rate()
1319 struct clk_bulk_data *cfg = ctrl->parser->mp[module].clocks; in dp_ctrl_set_clock_rate()
1326 drm_dbg_dp(ctrl->drm_dev, "setting rate=%lu on clk=%s\n", in dp_ctrl_set_clock_rate()
1336 static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) in dp_ctrl_enable_mainlink_clocks() argument
1339 struct dp_io *dp_io = &ctrl->parser->io; in dp_ctrl_enable_mainlink_clocks()
1342 const u8 *dpcd = ctrl->panel->dpcd; in dp_ctrl_enable_mainlink_clocks()
1344 opts_dp->lanes = ctrl->link->link_params.num_lanes; in dp_ctrl_enable_mainlink_clocks()
1345 opts_dp->link_rate = ctrl->link->link_params.rate / 100; in dp_ctrl_enable_mainlink_clocks()
1351 dev_pm_opp_set_rate(ctrl->dev, ctrl->link->link_params.rate * 1000); in dp_ctrl_enable_mainlink_clocks()
1352 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, true); in dp_ctrl_enable_mainlink_clocks()
1356 drm_dbg_dp(ctrl->drm_dev, "link rate=%d\n", ctrl->link->link_params.rate); in dp_ctrl_enable_mainlink_clocks()
1363 struct dp_ctrl_private *ctrl; in dp_ctrl_reset_irq_ctrl() local
1365 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_reset_irq_ctrl()
1367 dp_catalog_ctrl_reset(ctrl->catalog); in dp_ctrl_reset_irq_ctrl()
1375 dp_catalog_ctrl_enable_irq(ctrl->catalog, enable); in dp_ctrl_reset_irq_ctrl()
1380 struct dp_ctrl_private *ctrl; in dp_ctrl_phy_init() local
1384 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_phy_init()
1385 dp_io = &ctrl->parser->io; in dp_ctrl_phy_init()
1388 dp_catalog_ctrl_phy_reset(ctrl->catalog); in dp_ctrl_phy_init()
1391 drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", in dp_ctrl_phy_init()
1397 struct dp_ctrl_private *ctrl; in dp_ctrl_phy_exit() local
1401 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_phy_exit()
1402 dp_io = &ctrl->parser->io; in dp_ctrl_phy_exit()
1405 dp_catalog_ctrl_phy_reset(ctrl->catalog); in dp_ctrl_phy_exit()
1407 drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", in dp_ctrl_phy_exit()
1411 static bool dp_ctrl_use_fixed_nvid(struct dp_ctrl_private *ctrl) in dp_ctrl_use_fixed_nvid() argument
1413 const u8 *dpcd = ctrl->panel->dpcd; in dp_ctrl_use_fixed_nvid()
1420 return (drm_dp_has_quirk(&ctrl->panel->desc, in dp_ctrl_use_fixed_nvid()
1426 static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) in dp_ctrl_reinitialize_mainlink() argument
1429 struct dp_io *dp_io = &ctrl->parser->io; in dp_ctrl_reinitialize_mainlink()
1433 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); in dp_ctrl_reinitialize_mainlink()
1434 opts_dp->lanes = ctrl->link->link_params.num_lanes; in dp_ctrl_reinitialize_mainlink()
1441 dev_pm_opp_set_rate(ctrl->dev, 0); in dp_ctrl_reinitialize_mainlink()
1442 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); in dp_ctrl_reinitialize_mainlink()
1451 ret = dp_ctrl_enable_mainlink_clocks(ctrl); in dp_ctrl_reinitialize_mainlink()
1460 static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl) in dp_ctrl_deinitialize_mainlink() argument
1466 dp_io = &ctrl->parser->io; in dp_ctrl_deinitialize_mainlink()
1469 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); in dp_ctrl_deinitialize_mainlink()
1471 dp_catalog_ctrl_reset(ctrl->catalog); in dp_ctrl_deinitialize_mainlink()
1473 dev_pm_opp_set_rate(ctrl->dev, 0); in dp_ctrl_deinitialize_mainlink()
1474 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); in dp_ctrl_deinitialize_mainlink()
1485 drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", in dp_ctrl_deinitialize_mainlink()
1490 static int dp_ctrl_link_maintenance(struct dp_ctrl_private *ctrl) in dp_ctrl_link_maintenance() argument
1495 dp_ctrl_push_idle(&ctrl->dp_ctrl); in dp_ctrl_link_maintenance()
1497 ctrl->link->phy_params.p_level = 0; in dp_ctrl_link_maintenance()
1498 ctrl->link->phy_params.v_level = 0; in dp_ctrl_link_maintenance()
1500 ret = dp_ctrl_setup_main_link(ctrl, &training_step); in dp_ctrl_link_maintenance()
1504 dp_ctrl_clear_training_pattern(ctrl); in dp_ctrl_link_maintenance()
1506 dp_catalog_ctrl_state_ctrl(ctrl->catalog, DP_STATE_CTRL_SEND_VIDEO); in dp_ctrl_link_maintenance()
1508 ret = dp_ctrl_wait4video_ready(ctrl); in dp_ctrl_link_maintenance()
1513 static bool dp_ctrl_send_phy_test_pattern(struct dp_ctrl_private *ctrl) in dp_ctrl_send_phy_test_pattern() argument
1517 u32 pattern_requested = ctrl->link->phy_params.phy_test_pattern_sel; in dp_ctrl_send_phy_test_pattern()
1519 drm_dbg_dp(ctrl->drm_dev, "request: 0x%x\n", pattern_requested); in dp_ctrl_send_phy_test_pattern()
1521 if (dp_catalog_ctrl_update_vx_px(ctrl->catalog, in dp_ctrl_send_phy_test_pattern()
1522 ctrl->link->phy_params.v_level, in dp_ctrl_send_phy_test_pattern()
1523 ctrl->link->phy_params.p_level)) { in dp_ctrl_send_phy_test_pattern()
1527 dp_catalog_ctrl_send_phy_pattern(ctrl->catalog, pattern_requested); in dp_ctrl_send_phy_test_pattern()
1528 dp_ctrl_update_vx_px(ctrl); in dp_ctrl_send_phy_test_pattern()
1529 dp_link_send_test_response(ctrl->link); in dp_ctrl_send_phy_test_pattern()
1531 pattern_sent = dp_catalog_ctrl_read_phy_pattern(ctrl->catalog); in dp_ctrl_send_phy_test_pattern()
1560 drm_dbg_dp(ctrl->drm_dev, "%s: test->0x%x\n", in dp_ctrl_send_phy_test_pattern()
1565 static int dp_ctrl_process_phy_test_request(struct dp_ctrl_private *ctrl) in dp_ctrl_process_phy_test_request() argument
1570 if (!ctrl->link->phy_params.phy_test_pattern_sel) { in dp_ctrl_process_phy_test_request()
1571 drm_dbg_dp(ctrl->drm_dev, in dp_ctrl_process_phy_test_request()
1581 ret = dp_ctrl_off(&ctrl->dp_ctrl); in dp_ctrl_process_phy_test_request()
1587 ret = dp_ctrl_on_link(&ctrl->dp_ctrl); in dp_ctrl_process_phy_test_request()
1593 pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; in dp_ctrl_process_phy_test_request()
1594 dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", pixel_rate * 1000); in dp_ctrl_process_phy_test_request()
1596 ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, true); in dp_ctrl_process_phy_test_request()
1602 dp_ctrl_send_phy_test_pattern(ctrl); in dp_ctrl_process_phy_test_request()
1609 struct dp_ctrl_private *ctrl; in dp_ctrl_handle_sink_request() local
1617 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_handle_sink_request()
1618 sink_request = ctrl->link->sink_request; in dp_ctrl_handle_sink_request()
1621 drm_dbg_dp(ctrl->drm_dev, "PHY_TEST_PATTERN request\n"); in dp_ctrl_handle_sink_request()
1622 if (dp_ctrl_process_phy_test_request(ctrl)) { in dp_ctrl_handle_sink_request()
1629 if (dp_ctrl_link_maintenance(ctrl)) { in dp_ctrl_handle_sink_request()
1636 dp_link_send_test_response(ctrl->link); in dp_ctrl_handle_sink_request()
1637 if (dp_ctrl_link_maintenance(ctrl)) { in dp_ctrl_handle_sink_request()
1663 static bool dp_ctrl_channel_eq_ok(struct dp_ctrl_private *ctrl) in dp_ctrl_channel_eq_ok() argument
1666 int num_lanes = ctrl->link->link_params.num_lanes; in dp_ctrl_channel_eq_ok()
1668 dp_ctrl_read_link_status(ctrl, link_status); in dp_ctrl_channel_eq_ok()
1676 struct dp_ctrl_private *ctrl; in dp_ctrl_on_link() local
1687 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_on_link()
1689 rate = ctrl->panel->link_info.rate; in dp_ctrl_on_link()
1690 pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; in dp_ctrl_on_link()
1692 dp_power_clk_enable(ctrl->power, DP_CORE_PM, true); in dp_ctrl_on_link()
1694 if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) { in dp_ctrl_on_link()
1695 drm_dbg_dp(ctrl->drm_dev, in dp_ctrl_on_link()
1700 ctrl->link->link_params.rate = rate; in dp_ctrl_on_link()
1701 ctrl->link->link_params.num_lanes = in dp_ctrl_on_link()
1702 ctrl->panel->link_info.num_lanes; in dp_ctrl_on_link()
1705 drm_dbg_dp(ctrl->drm_dev, "rate=%d, num_lanes=%d, pixel_rate=%lu\n", in dp_ctrl_on_link()
1706 ctrl->link->link_params.rate, ctrl->link->link_params.num_lanes, in dp_ctrl_on_link()
1709 rc = dp_ctrl_enable_mainlink_clocks(ctrl); in dp_ctrl_on_link()
1714 rc = dp_ctrl_reinitialize_mainlink(ctrl); in dp_ctrl_on_link()
1722 rc = dp_ctrl_setup_main_link(ctrl, &training_step); in dp_ctrl_on_link()
1728 if (!dp_catalog_link_is_connected(ctrl->catalog)) in dp_ctrl_on_link()
1731 dp_ctrl_read_link_status(ctrl, link_status); in dp_ctrl_on_link()
1733 rc = dp_ctrl_link_rate_down_shift(ctrl); in dp_ctrl_on_link()
1736 ctrl->link->link_params.num_lanes)) { in dp_ctrl_on_link()
1741 rc = dp_ctrl_link_lane_down_shift(ctrl); in dp_ctrl_on_link()
1753 if (!dp_catalog_link_is_connected(ctrl->catalog)) in dp_ctrl_on_link()
1756 dp_ctrl_read_link_status(ctrl, link_status); in dp_ctrl_on_link()
1759 ctrl->link->link_params.num_lanes)) in dp_ctrl_on_link()
1760 rc = dp_ctrl_link_rate_down_shift(ctrl); in dp_ctrl_on_link()
1762 rc = dp_ctrl_link_lane_down_shift(ctrl); in dp_ctrl_on_link()
1770 dp_ctrl_clear_training_pattern(ctrl); in dp_ctrl_on_link()
1774 if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) in dp_ctrl_on_link()
1788 dp_ctrl_clear_training_pattern(ctrl); in dp_ctrl_on_link()
1790 dp_ctrl_deinitialize_mainlink(ctrl); in dp_ctrl_on_link()
1797 static int dp_ctrl_link_retrain(struct dp_ctrl_private *ctrl) in dp_ctrl_link_retrain() argument
1801 return dp_ctrl_setup_main_link(ctrl, &training_step); in dp_ctrl_link_retrain()
1808 struct dp_ctrl_private *ctrl; in dp_ctrl_on_stream() local
1815 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_on_stream()
1817 pixel_rate = pixel_rate_orig = ctrl->panel->dp_mode.drm_mode.clock; in dp_ctrl_on_stream()
1822 drm_dbg_dp(ctrl->drm_dev, "rate=%d, num_lanes=%d, pixel_rate=%lu\n", in dp_ctrl_on_stream()
1823 ctrl->link->link_params.rate, in dp_ctrl_on_stream()
1824 ctrl->link->link_params.num_lanes, pixel_rate); in dp_ctrl_on_stream()
1826 if (!dp_power_clk_status(ctrl->power, DP_CTRL_PM)) { /* link clk is off */ in dp_ctrl_on_stream()
1827 ret = dp_ctrl_enable_mainlink_clocks(ctrl); in dp_ctrl_on_stream()
1834 dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", pixel_rate * 1000); in dp_ctrl_on_stream()
1836 ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, true); in dp_ctrl_on_stream()
1842 if (force_link_train || !dp_ctrl_channel_eq_ok(ctrl)) in dp_ctrl_on_stream()
1843 dp_ctrl_link_retrain(ctrl); in dp_ctrl_on_stream()
1846 dp_ctrl_clear_training_pattern(ctrl); in dp_ctrl_on_stream()
1852 reinit_completion(&ctrl->video_comp); in dp_ctrl_on_stream()
1854 dp_ctrl_configure_source_params(ctrl); in dp_ctrl_on_stream()
1856 dp_catalog_ctrl_config_msa(ctrl->catalog, in dp_ctrl_on_stream()
1857 ctrl->link->link_params.rate, in dp_ctrl_on_stream()
1858 pixel_rate_orig, dp_ctrl_use_fixed_nvid(ctrl)); in dp_ctrl_on_stream()
1860 dp_ctrl_setup_tr_unit(ctrl); in dp_ctrl_on_stream()
1862 dp_catalog_ctrl_state_ctrl(ctrl->catalog, DP_STATE_CTRL_SEND_VIDEO); in dp_ctrl_on_stream()
1864 ret = dp_ctrl_wait4video_ready(ctrl); in dp_ctrl_on_stream()
1868 mainlink_ready = dp_catalog_ctrl_mainlink_ready(ctrl->catalog); in dp_ctrl_on_stream()
1869 drm_dbg_dp(ctrl->drm_dev, in dp_ctrl_on_stream()
1878 struct dp_ctrl_private *ctrl; in dp_ctrl_off_link_stream() local
1883 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_off_link_stream()
1884 dp_io = &ctrl->parser->io; in dp_ctrl_off_link_stream()
1888 dp_link_psm_config(ctrl->link, &ctrl->panel->link_info, true); in dp_ctrl_off_link_stream()
1890 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); in dp_ctrl_off_link_stream()
1892 if (dp_power_clk_status(ctrl->power, DP_STREAM_PM)) { in dp_ctrl_off_link_stream()
1893 ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, false); in dp_ctrl_off_link_stream()
1900 dev_pm_opp_set_rate(ctrl->dev, 0); in dp_ctrl_off_link_stream()
1901 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); in dp_ctrl_off_link_stream()
1913 drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", in dp_ctrl_off_link_stream()
1920 struct dp_ctrl_private *ctrl; in dp_ctrl_off_link() local
1925 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_off_link()
1926 dp_io = &ctrl->parser->io; in dp_ctrl_off_link()
1929 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); in dp_ctrl_off_link()
1931 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); in dp_ctrl_off_link()
1949 struct dp_ctrl_private *ctrl; in dp_ctrl_off() local
1957 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_off()
1958 dp_io = &ctrl->parser->io; in dp_ctrl_off()
1961 dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); in dp_ctrl_off()
1963 dp_catalog_ctrl_reset(ctrl->catalog); in dp_ctrl_off()
1965 ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, false); in dp_ctrl_off()
1969 dev_pm_opp_set_rate(ctrl->dev, 0); in dp_ctrl_off()
1970 ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); in dp_ctrl_off()
1976 drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", in dp_ctrl_off()
1984 struct dp_ctrl_private *ctrl; in dp_ctrl_isr() local
1990 ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); in dp_ctrl_isr()
1992 isr = dp_catalog_ctrl_get_interrupt(ctrl->catalog); in dp_ctrl_isr()
1995 drm_dbg_dp(ctrl->drm_dev, "dp_video_ready\n"); in dp_ctrl_isr()
1996 complete(&ctrl->video_comp); in dp_ctrl_isr()
2000 drm_dbg_dp(ctrl->drm_dev, "idle_patterns_sent\n"); in dp_ctrl_isr()
2001 complete(&ctrl->idle_comp); in dp_ctrl_isr()
2010 struct dp_ctrl_private *ctrl; in dp_ctrl_get() local
2019 ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); in dp_ctrl_get()
2020 if (!ctrl) { in dp_ctrl_get()
2037 init_completion(&ctrl->idle_comp); in dp_ctrl_get()
2038 init_completion(&ctrl->video_comp); in dp_ctrl_get()
2041 ctrl->parser = parser; in dp_ctrl_get()
2042 ctrl->panel = panel; in dp_ctrl_get()
2043 ctrl->power = power; in dp_ctrl_get()
2044 ctrl->aux = aux; in dp_ctrl_get()
2045 ctrl->link = link; in dp_ctrl_get()
2046 ctrl->catalog = catalog; in dp_ctrl_get()
2047 ctrl->dev = dev; in dp_ctrl_get()
2049 return &ctrl->dp_ctrl; in dp_ctrl_get()