Lines Matching full:it6505

291 #define DEBUGFS_DIR_NAME "it6505-debugfs"
405 struct it6505 { struct
459 /* it6505 driver hold option */ argument
505 .name = "it6505",
526 static int it6505_read(struct it6505 *it6505, unsigned int reg_addr) in it6505_read() argument
530 struct device *dev = it6505->dev; in it6505_read()
532 if (!it6505->powered) in it6505_read()
535 err = regmap_read(it6505->regmap, reg_addr, &value); in it6505_read()
544 static int it6505_write(struct it6505 *it6505, unsigned int reg_addr, in it6505_write() argument
548 struct device *dev = it6505->dev; in it6505_write()
550 if (!it6505->powered) in it6505_write()
553 err = regmap_write(it6505->regmap, reg_addr, reg_val); in it6505_write()
564 static int it6505_set_bits(struct it6505 *it6505, unsigned int reg, in it6505_set_bits() argument
568 struct device *dev = it6505->dev; in it6505_set_bits()
570 if (!it6505->powered) in it6505_set_bits()
573 err = regmap_update_bits(it6505->regmap, reg, mask, value); in it6505_set_bits()
583 static void it6505_debug_print(struct it6505 *it6505, unsigned int reg, in it6505_debug_print() argument
586 struct device *dev = it6505->dev; in it6505_debug_print()
592 val = it6505_read(it6505, reg); in it6505_debug_print()
601 static int it6505_dpcd_read(struct it6505 *it6505, unsigned long offset) in it6505_dpcd_read() argument
605 struct device *dev = it6505->dev; in it6505_dpcd_read()
607 ret = drm_dp_dpcd_readb(&it6505->aux, offset, &value); in it6505_dpcd_read()
615 static int it6505_dpcd_write(struct it6505 *it6505, unsigned long offset, in it6505_dpcd_write() argument
619 struct device *dev = it6505->dev; in it6505_dpcd_write()
621 ret = drm_dp_dpcd_writeb(&it6505->aux, offset, datain); in it6505_dpcd_write()
629 static int it6505_get_dpcd(struct it6505 *it6505, int offset, u8 *dpcd, int num) in it6505_get_dpcd() argument
632 struct device *dev = it6505->dev; in it6505_get_dpcd()
634 ret = drm_dp_dpcd_read(&it6505->aux, offset, dpcd, num); in it6505_get_dpcd()
645 static void it6505_dump(struct it6505 *it6505) in it6505_dump() argument
649 struct device *dev = it6505->dev; in it6505_dump()
653 regs[j] = it6505_read(it6505, i + j); in it6505_dump()
659 static bool it6505_get_sink_hpd_status(struct it6505 *it6505) in it6505_get_sink_hpd_status() argument
663 reg_0d = it6505_read(it6505, REG_SYSTEM_STS); in it6505_get_sink_hpd_status()
671 static int it6505_read_word(struct it6505 *it6505, unsigned int reg) in it6505_read_word() argument
675 val0 = it6505_read(it6505, reg); in it6505_read_word()
679 val1 = it6505_read(it6505, reg + 1); in it6505_read_word()
686 static void it6505_calc_video_info(struct it6505 *it6505) in it6505_calc_video_info() argument
688 struct device *dev = it6505->dev; in it6505_calc_video_info()
695 rddata = it6505_read(it6505, REG_INPUT_CTRL); in it6505_calc_video_info()
700 htotal = it6505_read_word(it6505, REG_INPUT_HTOTAL) & 0x1FFF; in it6505_calc_video_info()
701 hdes = it6505_read_word(it6505, REG_INPUT_HACTIVE_START) & 0x1FFF; in it6505_calc_video_info()
702 hdew = it6505_read_word(it6505, REG_INPUT_HACTIVE_WIDTH) & 0x1FFF; in it6505_calc_video_info()
703 hfph = it6505_read_word(it6505, REG_INPUT_HFRONT_PORCH) & 0x1FFF; in it6505_calc_video_info()
704 hsyncw = it6505_read_word(it6505, REG_INPUT_HSYNC_WIDTH) & 0x1FFF; in it6505_calc_video_info()
706 vtotal = it6505_read_word(it6505, REG_INPUT_VTOTAL) & 0xFFF; in it6505_calc_video_info()
707 vdes = it6505_read_word(it6505, REG_INPUT_VACTIVE_START) & 0xFFF; in it6505_calc_video_info()
708 vdew = it6505_read_word(it6505, REG_INPUT_VACTIVE_WIDTH) & 0xFFF; in it6505_calc_video_info()
709 vfph = it6505_read_word(it6505, REG_INPUT_VFRONT_PORCH) & 0xFFF; in it6505_calc_video_info()
710 vsyncw = it6505_read_word(it6505, REG_INPUT_VSYNC_WIDTH) & 0xFFF; in it6505_calc_video_info()
718 it6505_set_bits(it6505, REG_DATA_CTRL0, ENABLE_PCLK_COUNTER, in it6505_calc_video_info()
721 it6505_set_bits(it6505, REG_DATA_CTRL0, ENABLE_PCLK_COUNTER, in it6505_calc_video_info()
723 rddata = it6505_read_word(it6505, REG_PCLK_COUNTER_VALUE) & in it6505_calc_video_info()
736 it6505->video_info.clock = pclk; in it6505_calc_video_info()
737 it6505->video_info.hdisplay = hdew; in it6505_calc_video_info()
738 it6505->video_info.hsync_start = hdew + hfph; in it6505_calc_video_info()
739 it6505->video_info.hsync_end = hdew + hfph + hsyncw; in it6505_calc_video_info()
740 it6505->video_info.htotal = htotal; in it6505_calc_video_info()
741 it6505->video_info.vdisplay = vdew; in it6505_calc_video_info()
742 it6505->video_info.vsync_start = vdew + vfph; in it6505_calc_video_info()
743 it6505->video_info.vsync_end = vdew + vfph + vsyncw; in it6505_calc_video_info()
744 it6505->video_info.vtotal = vtotal; in it6505_calc_video_info()
747 DRM_MODE_ARG(&it6505->video_info)); in it6505_calc_video_info()
784 static void it6505_clear_int(struct it6505 *it6505) in it6505_clear_int() argument
786 it6505_write(it6505, INT_STATUS_01, 0xFF); in it6505_clear_int()
787 it6505_write(it6505, INT_STATUS_02, 0xFF); in it6505_clear_int()
788 it6505_write(it6505, INT_STATUS_03, 0xFF); in it6505_clear_int()
791 static void it6505_int_mask_enable(struct it6505 *it6505) in it6505_int_mask_enable() argument
793 it6505_write(it6505, INT_MASK_01, BIT(INT_HPD_CHANGE) | in it6505_int_mask_enable()
797 it6505_write(it6505, INT_MASK_02, BIT(INT_AUX_CMD_FAIL) | in it6505_int_mask_enable()
800 it6505_write(it6505, INT_MASK_03, BIT(INT_LINK_TRAIN_FAIL) | in it6505_int_mask_enable()
804 static void it6505_int_mask_disable(struct it6505 *it6505) in it6505_int_mask_disable() argument
806 it6505_write(it6505, INT_MASK_01, 0x00); in it6505_int_mask_disable()
807 it6505_write(it6505, INT_MASK_02, 0x00); in it6505_int_mask_disable()
808 it6505_write(it6505, INT_MASK_03, 0x00); in it6505_int_mask_disable()
811 static void it6505_lane_termination_on(struct it6505 *it6505) in it6505_lane_termination_on() argument
815 regcf = it6505_read(it6505, REG_USER_DRV_PRE); in it6505_lane_termination_on()
818 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, 0x80, 0x00); in it6505_lane_termination_on()
821 if (it6505->lane_swap) { in it6505_lane_termination_on()
822 switch (it6505->lane_count) { in it6505_lane_termination_on()
825 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, in it6505_lane_termination_on()
829 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, in it6505_lane_termination_on()
834 switch (it6505->lane_count) { in it6505_lane_termination_on()
837 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, in it6505_lane_termination_on()
841 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, in it6505_lane_termination_on()
849 static void it6505_lane_termination_off(struct it6505 *it6505) in it6505_lane_termination_off() argument
853 regcf = it6505_read(it6505, REG_USER_DRV_PRE); in it6505_lane_termination_off()
856 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, 0x80, 0x80); in it6505_lane_termination_off()
859 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, 0x0C, 0x00); in it6505_lane_termination_off()
862 static void it6505_lane_power_on(struct it6505 *it6505) in it6505_lane_power_on() argument
864 it6505_set_bits(it6505, REG_LINK_DRV, 0xF1, in it6505_lane_power_on()
865 (it6505->lane_swap ? in it6505_lane_power_on()
866 GENMASK(7, 8 - it6505->lane_count) : in it6505_lane_power_on()
867 GENMASK(3 + it6505->lane_count, 4)) | in it6505_lane_power_on()
871 static void it6505_lane_power_off(struct it6505 *it6505) in it6505_lane_power_off() argument
873 it6505_set_bits(it6505, REG_LINK_DRV, 0xF0, 0x00); in it6505_lane_power_off()
876 static void it6505_lane_off(struct it6505 *it6505) in it6505_lane_off() argument
878 it6505_lane_power_off(it6505); in it6505_lane_off()
879 it6505_lane_termination_off(it6505); in it6505_lane_off()
882 static void it6505_aux_termination_on(struct it6505 *it6505) in it6505_aux_termination_on() argument
886 regcf = it6505_read(it6505, REG_USER_DRV_PRE); in it6505_aux_termination_on()
889 it6505_lane_termination_on(it6505); in it6505_aux_termination_on()
892 it6505_set_bits(it6505, REG_DRV_LN_DATA_SEL, 0x80, 0x80); in it6505_aux_termination_on()
895 static void it6505_aux_power_on(struct it6505 *it6505) in it6505_aux_power_on() argument
897 it6505_set_bits(it6505, REG_AUX, 0x02, 0x02); in it6505_aux_power_on()
900 static void it6505_aux_on(struct it6505 *it6505) in it6505_aux_on() argument
902 it6505_aux_power_on(it6505); in it6505_aux_on()
903 it6505_aux_termination_on(it6505); in it6505_aux_on()
906 static void it6505_aux_reset(struct it6505 *it6505) in it6505_aux_reset() argument
908 it6505_set_bits(it6505, REG_RESET_CTRL, AUX_RESET, AUX_RESET); in it6505_aux_reset()
909 it6505_set_bits(it6505, REG_RESET_CTRL, AUX_RESET, 0x00); in it6505_aux_reset()
912 static void it6505_reset_logic(struct it6505 *it6505) in it6505_reset_logic() argument
914 regmap_write(it6505->regmap, REG_RESET_CTRL, ALL_LOGIC_RESET); in it6505_reset_logic()
918 static bool it6505_aux_op_finished(struct it6505 *it6505) in it6505_aux_op_finished() argument
920 int reg2b = it6505_read(it6505, REG_AUX_CMD_REQ); in it6505_aux_op_finished()
928 static int it6505_aux_wait(struct it6505 *it6505) in it6505_aux_wait() argument
932 struct device *dev = it6505->dev; in it6505_aux_wait()
936 while (!it6505_aux_op_finished(it6505)) { in it6505_aux_wait()
944 status = it6505_read(it6505, REG_AUX_ERROR_STS); in it6505_aux_wait()
953 static ssize_t it6505_aux_operation(struct it6505 *it6505, in it6505_aux_operation() argument
961 if (!it6505_get_sink_hpd_status(it6505)) in it6505_aux_operation()
965 it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, AUX_USER_MODE); in it6505_aux_operation()
972 it6505_set_bits(it6505, REG_AUX_CTRL, in it6505_aux_operation()
976 it6505_set_bits(it6505, REG_AUX_CTRL, in it6505_aux_operation()
982 it6505_set_bits(it6505, REG_AUX_CTRL, AUX_NO_SEGMENT_WR, in it6505_aux_operation()
987 it6505_write(it6505, REG_AUX_ADR_0_7, (address >> 0) & 0xFF); in it6505_aux_operation()
989 it6505_write(it6505, REG_AUX_ADR_8_15, (address >> 8) & 0xFF); in it6505_aux_operation()
991 it6505_write(it6505, REG_AUX_ADR_16_19, in it6505_aux_operation()
995 regmap_bulk_write(it6505->regmap, REG_AUX_OUT_DATA0, buffer, in it6505_aux_operation()
999 it6505_write(it6505, REG_AUX_CMD_REQ, cmd); in it6505_aux_operation()
1001 ret = it6505_aux_wait(it6505); in it6505_aux_operation()
1005 ret = it6505_read(it6505, REG_AUX_ERROR_STS); in it6505_aux_operation()
1035 ret = it6505_read(it6505, REG_AUX_DATA_FIFO); in it6505_aux_operation()
1042 ret = it6505_read(it6505, REG_AUX_DATA_0_7 + i); in it6505_aux_operation()
1060 it6505_set_bits(it6505, REG_AUX_CTRL, in it6505_aux_operation()
1063 it6505_set_bits(it6505, REG_AUX_CTRL, in it6505_aux_operation()
1068 it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, 0); in it6505_aux_operation()
1073 static ssize_t it6505_aux_do_transfer(struct it6505 *it6505, in it6505_aux_do_transfer() argument
1080 mutex_lock(&it6505->aux_lock); in it6505_aux_do_transfer()
1083 ret_size = it6505_aux_operation(it6505, cmd, address + i, in it6505_aux_do_transfer()
1095 mutex_unlock(&it6505->aux_lock); in it6505_aux_do_transfer()
1102 struct it6505 *it6505 = container_of(aux, struct it6505, aux); in it6505_aux_transfer() local
1108 /* IT6505 doesn't support arbitrary I2C read / write. */ in it6505_aux_transfer()
1123 ret = it6505_aux_do_transfer(it6505, cmd, msg->address, msg->buffer, in it6505_aux_transfer()
1146 struct it6505 *it6505 = data; in it6505_get_edid_block() local
1147 struct device *dev = it6505->dev; in it6505_get_edid_block()
1151 it6505_aux_reset(it6505); in it6505_get_edid_block()
1155 ret = it6505_aux_do_transfer(it6505, CMD_AUX_I2C_EDID_READ, in it6505_get_edid_block()
1181 static void it6505_variable_config(struct it6505 *it6505) in it6505_variable_config() argument
1183 it6505->link_rate_bw_code = HBR; in it6505_variable_config()
1184 it6505->lane_count = MAX_LANE_COUNT; in it6505_variable_config()
1185 it6505->link_state = LINK_IDLE; in it6505_variable_config()
1186 it6505->hdcp_desired = HDCP_DESIRED; in it6505_variable_config()
1187 it6505->auto_train_retry = AUTO_TRAIN_RETRY; in it6505_variable_config()
1188 it6505->audio.select = AUDIO_SELECT; in it6505_variable_config()
1189 it6505->audio.sample_rate = AUDIO_SAMPLE_RATE; in it6505_variable_config()
1190 it6505->audio.channel_count = AUDIO_CHANNEL_COUNT; in it6505_variable_config()
1191 it6505->audio.type = AUDIO_TYPE; in it6505_variable_config()
1192 it6505->audio.i2s_input_format = I2S_INPUT_FORMAT; in it6505_variable_config()
1193 it6505->audio.i2s_justified = I2S_JUSTIFIED; in it6505_variable_config()
1194 it6505->audio.i2s_data_delay = I2S_DATA_DELAY; in it6505_variable_config()
1195 it6505->audio.i2s_ws_channel = I2S_WS_CHANNEL; in it6505_variable_config()
1196 it6505->audio.i2s_data_sequence = I2S_DATA_SEQUENCE; in it6505_variable_config()
1197 it6505->audio.word_length = AUDIO_WORD_LENGTH; in it6505_variable_config()
1198 memset(it6505->sha1_input, 0, sizeof(it6505->sha1_input)); in it6505_variable_config()
1199 memset(it6505->bksvs, 0, sizeof(it6505->bksvs)); in it6505_variable_config()
1202 static int it6505_send_video_infoframe(struct it6505 *it6505, in it6505_send_video_infoframe() argument
1207 struct device *dev = it6505->dev; in it6505_send_video_infoframe()
1215 err = it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_AVI_PKT, 0x00); in it6505_send_video_infoframe()
1219 err = regmap_bulk_write(it6505->regmap, REG_AVI_INFO_DB1, in it6505_send_video_infoframe()
1225 err = it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_AVI_PKT, in it6505_send_video_infoframe()
1233 static void it6505_get_extcon_property(struct it6505 *it6505) in it6505_get_extcon_property() argument
1237 struct device *dev = it6505->dev; in it6505_get_extcon_property()
1239 if (it6505->extcon && !it6505->lane_swap_disabled) { in it6505_get_extcon_property()
1240 err = extcon_get_property(it6505->extcon, EXTCON_DISP_DP, in it6505_get_extcon_property()
1247 it6505->lane_swap = property.intval; in it6505_get_extcon_property()
1251 static void it6505_clk_phase_adjustment(struct it6505 *it6505, in it6505_clk_phase_adjustment() argument
1256 it6505_set_bits(it6505, REG_CLK_CTRL0, M_PCLK_DELAY, in it6505_clk_phase_adjustment()
1258 it6505_set_bits(it6505, REG_DATA_CTRL0, VIDEO_LATCH_EDGE, in it6505_clk_phase_adjustment()
1262 static void it6505_link_reset_step_train(struct it6505 *it6505) in it6505_link_reset_step_train() argument
1264 it6505_set_bits(it6505, REG_TRAIN_CTRL0, in it6505_link_reset_step_train()
1266 it6505_dpcd_write(it6505, DP_TRAINING_PATTERN_SET, in it6505_link_reset_step_train()
1270 static void it6505_init(struct it6505 *it6505) in it6505_init() argument
1272 it6505_write(it6505, REG_AUX_OPT, AUX_AUTO_RST | AUX_FIX_FREQ); in it6505_init()
1273 it6505_write(it6505, REG_AUX_CTRL, AUX_NO_SEGMENT_WR); in it6505_init()
1274 it6505_write(it6505, REG_HDCP_CTRL2, HDCP_AN_SEL | HDCP_HW_HPDIRQ_ACT); in it6505_init()
1275 it6505_write(it6505, REG_VID_BUS_CTRL0, IN_DDR | DDR_CD); in it6505_init()
1276 it6505_write(it6505, REG_VID_BUS_CTRL1, 0x01); in it6505_init()
1277 it6505_write(it6505, REG_AUDIO_CTRL0, AUDIO_16B_BOUND); in it6505_init()
1280 it6505_write(it6505, REG_HPD_IRQ_TIME, 0xF5); in it6505_init()
1281 it6505_write(it6505, REG_AUX_DEBUG_MODE, 0x4D); in it6505_init()
1282 it6505_write(it6505, REG_AUX_OPT2, 0x17); in it6505_init()
1283 it6505_write(it6505, REG_HDCP_OPT, 0x60); in it6505_init()
1284 it6505_write(it6505, REG_DATA_MUTE_CTRL, in it6505_init()
1286 it6505_write(it6505, REG_TIME_STMP_CTRL, in it6505_init()
1288 it6505_write(it6505, REG_INFOFRAME_CTRL, 0x00); in it6505_init()
1289 it6505_write(it6505, REG_DRV_0_DB_800_MV, in it6505_init()
1290 afe_setting_table[it6505->afe_setting][0]); in it6505_init()
1291 it6505_write(it6505, REG_PRE_0_DB_800_MV, in it6505_init()
1292 afe_setting_table[it6505->afe_setting][1]); in it6505_init()
1293 it6505_write(it6505, REG_PRE_3P5_DB_800_MV, in it6505_init()
1294 afe_setting_table[it6505->afe_setting][2]); in it6505_init()
1295 it6505_write(it6505, REG_SSC_CTRL0, 0x9E); in it6505_init()
1296 it6505_write(it6505, REG_SSC_CTRL1, 0x1C); in it6505_init()
1297 it6505_write(it6505, REG_SSC_CTRL2, 0x42); in it6505_init()
1300 static void it6505_video_disable(struct it6505 *it6505) in it6505_video_disable() argument
1302 it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, EN_VID_MUTE); in it6505_video_disable()
1303 it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_VID_CTRL_PKT, 0x00); in it6505_video_disable()
1304 it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, VIDEO_RESET); in it6505_video_disable()
1307 static void it6505_video_reset(struct it6505 *it6505) in it6505_video_reset() argument
1309 it6505_link_reset_step_train(it6505); in it6505_video_reset()
1310 it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, EN_VID_MUTE); in it6505_video_reset()
1311 it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_VID_CTRL_PKT, 0x00); in it6505_video_reset()
1313 it6505_set_bits(it6505, REG_VID_BUS_CTRL1, TX_FIFO_RESET, TX_FIFO_RESET); in it6505_video_reset()
1314 it6505_set_bits(it6505, REG_VID_BUS_CTRL1, TX_FIFO_RESET, 0x00); in it6505_video_reset()
1316 it6505_set_bits(it6505, REG_501_FIFO_CTRL, RST_501_FIFO, RST_501_FIFO); in it6505_video_reset()
1317 it6505_set_bits(it6505, REG_501_FIFO_CTRL, RST_501_FIFO, 0x00); in it6505_video_reset()
1319 it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, VIDEO_RESET); in it6505_video_reset()
1321 it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, 0x00); in it6505_video_reset()
1324 static void it6505_update_video_parameter(struct it6505 *it6505, in it6505_update_video_parameter() argument
1327 it6505_clk_phase_adjustment(it6505, mode); in it6505_update_video_parameter()
1328 it6505_video_disable(it6505); in it6505_update_video_parameter()
1331 static bool it6505_audio_input(struct it6505 *it6505) in it6505_audio_input() argument
1335 reg05 = it6505_read(it6505, REG_RESET_CTRL); in it6505_audio_input()
1336 it6505_set_bits(it6505, REG_RESET_CTRL, AUDIO_RESET, 0x00); in it6505_audio_input()
1338 regbe = it6505_read(it6505, REG_AUDIO_INPUT_FREQ); in it6505_audio_input()
1339 it6505_write(it6505, REG_RESET_CTRL, reg05); in it6505_audio_input()
1344 static void it6505_setup_audio_channel_status(struct it6505 *it6505) in it6505_setup_audio_channel_status() argument
1346 enum it6505_audio_sample_rate sample_rate = it6505->audio.sample_rate; in it6505_setup_audio_channel_status()
1350 it6505_write(it6505, REG_IEC958_STS0, it6505->audio.type << 1); in it6505_setup_audio_channel_status()
1351 it6505_write(it6505, REG_IEC958_STS1, 0x00); in it6505_setup_audio_channel_status()
1352 it6505_write(it6505, REG_IEC958_STS2, 0x00); in it6505_setup_audio_channel_status()
1353 it6505_write(it6505, REG_IEC958_STS3, sample_rate); in it6505_setup_audio_channel_status()
1354 it6505_write(it6505, REG_IEC958_STS4, (~sample_rate << 4) | in it6505_setup_audio_channel_status()
1355 audio_word_length_map[it6505->audio.word_length]); in it6505_setup_audio_channel_status()
1358 static void it6505_setup_audio_format(struct it6505 *it6505) in it6505_setup_audio_format() argument
1361 it6505_write(it6505, REG_AUDIO_FMT, in it6505_setup_audio_format()
1362 (it6505->audio.word_length << 5) | in it6505_setup_audio_format()
1363 (it6505->audio.i2s_data_sequence << 4) | in it6505_setup_audio_format()
1364 (it6505->audio.i2s_ws_channel << 3) | in it6505_setup_audio_format()
1365 (it6505->audio.i2s_data_delay << 2) | in it6505_setup_audio_format()
1366 (it6505->audio.i2s_justified << 1) | in it6505_setup_audio_format()
1367 it6505->audio.i2s_input_format); in it6505_setup_audio_format()
1368 if (it6505->audio.select == SPDIF) { in it6505_setup_audio_format()
1369 it6505_write(it6505, REG_AUDIO_FIFO_SEL, 0x00); in it6505_setup_audio_format()
1371 it6505_set_bits(it6505, REG_AUX_OPT, 0xF0, 0x30); in it6505_setup_audio_format()
1373 it6505_write(it6505, REG_AUDIO_FIFO_SEL, 0xE4); in it6505_setup_audio_format()
1376 it6505_write(it6505, REG_AUDIO_CTRL0, 0x20); in it6505_setup_audio_format()
1377 it6505_write(it6505, REG_AUDIO_CTRL1, 0x00); in it6505_setup_audio_format()
1380 static void it6505_enable_audio_source(struct it6505 *it6505) in it6505_enable_audio_source() argument
1384 audio_source_count = BIT(DIV_ROUND_UP(it6505->audio.channel_count, 2)) in it6505_enable_audio_source()
1387 audio_source_count |= it6505->audio.select << 4; in it6505_enable_audio_source()
1389 it6505_write(it6505, REG_AUDIO_SRC_CTRL, audio_source_count); in it6505_enable_audio_source()
1392 static void it6505_enable_audio_infoframe(struct it6505 *it6505) in it6505_enable_audio_infoframe() argument
1394 struct device *dev = it6505->dev; in it6505_enable_audio_infoframe()
1398 audio_info_ca[it6505->audio.channel_count - 1]); in it6505_enable_audio_infoframe()
1400 it6505_write(it6505, REG_AUD_INFOFRAM_DB1, it6505->audio.channel_count in it6505_enable_audio_infoframe()
1402 it6505_write(it6505, REG_AUD_INFOFRAM_DB2, 0x00); in it6505_enable_audio_infoframe()
1403 it6505_write(it6505, REG_AUD_INFOFRAM_DB3, in it6505_enable_audio_infoframe()
1404 audio_info_ca[it6505->audio.channel_count - 1]); in it6505_enable_audio_infoframe()
1405 it6505_write(it6505, REG_AUD_INFOFRAM_DB4, 0x00); in it6505_enable_audio_infoframe()
1406 it6505_write(it6505, REG_AUD_INFOFRAM_SUM, 0x00); in it6505_enable_audio_infoframe()
1409 it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_AUD_CTRL_PKT, in it6505_enable_audio_infoframe()
1413 static void it6505_disable_audio(struct it6505 *it6505) in it6505_disable_audio() argument
1415 it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_AUD_MUTE, EN_AUD_MUTE); in it6505_disable_audio()
1416 it6505_set_bits(it6505, REG_AUDIO_SRC_CTRL, M_AUDIO_I2S_EN, 0x00); in it6505_disable_audio()
1417 it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_AUD_CTRL_PKT, 0x00); in it6505_disable_audio()
1418 it6505_set_bits(it6505, REG_RESET_CTRL, AUDIO_RESET, AUDIO_RESET); in it6505_disable_audio()
1421 static void it6505_enable_audio(struct it6505 *it6505) in it6505_enable_audio() argument
1423 struct device *dev = it6505->dev; in it6505_enable_audio()
1427 it6505_disable_audio(it6505); in it6505_enable_audio()
1429 it6505_setup_audio_channel_status(it6505); in it6505_enable_audio()
1430 it6505_setup_audio_format(it6505); in it6505_enable_audio()
1431 it6505_enable_audio_source(it6505); in it6505_enable_audio()
1432 it6505_enable_audio_infoframe(it6505); in it6505_enable_audio()
1434 it6505_write(it6505, REG_AUDIO_N_0_7, 0x00); in it6505_enable_audio()
1435 it6505_write(it6505, REG_AUDIO_N_8_15, 0x80); in it6505_enable_audio()
1436 it6505_write(it6505, REG_AUDIO_N_16_23, 0x00); in it6505_enable_audio()
1438 it6505_set_bits(it6505, REG_AUDIO_SRC_CTRL, AUDIO_FIFO_RESET, in it6505_enable_audio()
1440 it6505_set_bits(it6505, REG_AUDIO_SRC_CTRL, AUDIO_FIFO_RESET, 0x00); in it6505_enable_audio()
1441 it6505_set_bits(it6505, REG_RESET_CTRL, AUDIO_RESET, 0x00); in it6505_enable_audio()
1442 regbe = it6505_read(it6505, REG_AUDIO_INPUT_FREQ); in it6505_enable_audio()
1445 it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_AUD_MUTE, 0x00); in it6505_enable_audio()
1448 static bool it6505_use_step_train_check(struct it6505 *it6505) in it6505_use_step_train_check() argument
1450 if (it6505->link.revision >= 0x12) in it6505_use_step_train_check()
1451 return it6505->dpcd[DP_TRAINING_AUX_RD_INTERVAL] >= 0x01; in it6505_use_step_train_check()
1456 static void it6505_parse_link_capabilities(struct it6505 *it6505) in it6505_parse_link_capabilities() argument
1458 struct device *dev = it6505->dev; in it6505_parse_link_capabilities()
1459 struct it6505_drm_dp_link *link = &it6505->link; in it6505_parse_link_capabilities()
1462 if (it6505->dpcd[0] == 0) { in it6505_parse_link_capabilities()
1469 link->revision = it6505->dpcd[0]; in it6505_parse_link_capabilities()
1470 link->rate = drm_dp_bw_code_to_link_rate(it6505->dpcd[1]); in it6505_parse_link_capabilities()
1471 link->num_lanes = it6505->dpcd[2] & DP_MAX_LANE_COUNT_MASK; in it6505_parse_link_capabilities()
1473 if (it6505->dpcd[2] & DP_ENHANCED_FRAME_CAP) in it6505_parse_link_capabilities()
1482 it6505->link_rate_bw_code = drm_dp_link_rate_to_bw_code(link->rate); in it6505_parse_link_capabilities()
1484 it6505->link_rate_bw_code); in it6505_parse_link_capabilities()
1485 it6505->link_rate_bw_code = min_t(int, it6505->link_rate_bw_code, in it6505_parse_link_capabilities()
1488 it6505->lane_count = link->num_lanes; in it6505_parse_link_capabilities()
1490 it6505->lane_count); in it6505_parse_link_capabilities()
1491 it6505->lane_count = min_t(int, it6505->lane_count, in it6505_parse_link_capabilities()
1492 it6505->max_lane_count); in it6505_parse_link_capabilities()
1494 it6505->branch_device = drm_dp_is_branch(it6505->dpcd); in it6505_parse_link_capabilities()
1496 it6505->branch_device ? "" : "Not "); in it6505_parse_link_capabilities()
1498 it6505->enable_enhanced_frame = link->capabilities; in it6505_parse_link_capabilities()
1500 it6505->enable_enhanced_frame ? "" : "Not "); in it6505_parse_link_capabilities()
1502 it6505->enable_ssc = (it6505->dpcd[DP_MAX_DOWNSPREAD] & in it6505_parse_link_capabilities()
1505 it6505->enable_ssc ? "0.5" : "0", in it6505_parse_link_capabilities()
1506 it6505->enable_ssc ? "" : "Not "); in it6505_parse_link_capabilities()
1508 it6505->step_train = it6505_use_step_train_check(it6505); in it6505_parse_link_capabilities()
1509 if (it6505->step_train) in it6505_parse_link_capabilities()
1512 bcaps = it6505_dpcd_read(it6505, DP_AUX_HDCP_BCAPS); in it6505_parse_link_capabilities()
1515 it6505->is_repeater = (bcaps & DP_BCAPS_REPEATER_PRESENT); in it6505_parse_link_capabilities()
1517 it6505->is_repeater ? "repeater" : in it6505_parse_link_capabilities()
1521 it6505->hdcp_desired = false; in it6505_parse_link_capabilities()
1524 it6505->hdcp_desired ? "desired" : "undesired"); in it6505_parse_link_capabilities()
1527 static void it6505_setup_ssc(struct it6505 *it6505) in it6505_setup_ssc() argument
1529 it6505_set_bits(it6505, REG_TRAIN_CTRL0, SPREAD_AMP_5, in it6505_setup_ssc()
1530 it6505->enable_ssc ? SPREAD_AMP_5 : 0x00); in it6505_setup_ssc()
1531 if (it6505->enable_ssc) { in it6505_setup_ssc()
1532 it6505_write(it6505, REG_SSC_CTRL0, 0x9E); in it6505_setup_ssc()
1533 it6505_write(it6505, REG_SSC_CTRL1, 0x1C); in it6505_setup_ssc()
1534 it6505_write(it6505, REG_SSC_CTRL2, 0x42); in it6505_setup_ssc()
1535 it6505_write(it6505, REG_SP_CTRL0, 0x07); in it6505_setup_ssc()
1536 it6505_write(it6505, REG_IP_CTRL1, 0x29); in it6505_setup_ssc()
1537 it6505_write(it6505, REG_IP_CTRL2, 0x03); in it6505_setup_ssc()
1539 it6505_set_bits(it6505, REG_TIME_STMP_CTRL, M_STAMP_STEP, in it6505_setup_ssc()
1541 it6505_dpcd_write(it6505, DP_DOWNSPREAD_CTRL, in it6505_setup_ssc()
1544 it6505_dpcd_write(it6505, DP_DOWNSPREAD_CTRL, 0x00); in it6505_setup_ssc()
1545 it6505_set_bits(it6505, REG_TIME_STMP_CTRL, M_STAMP_STEP, in it6505_setup_ssc()
1550 static inline void it6505_link_rate_setup(struct it6505 *it6505) in it6505_link_rate_setup() argument
1552 it6505_set_bits(it6505, REG_TRAIN_CTRL0, FORCE_LBR, in it6505_link_rate_setup()
1553 (it6505->link_rate_bw_code == RBR) ? FORCE_LBR : 0x00); in it6505_link_rate_setup()
1554 it6505_set_bits(it6505, REG_LINK_DRV, DRV_HS, in it6505_link_rate_setup()
1555 (it6505->link_rate_bw_code == RBR) ? 0x00 : DRV_HS); in it6505_link_rate_setup()
1558 static void it6505_lane_count_setup(struct it6505 *it6505) in it6505_lane_count_setup() argument
1560 it6505_get_extcon_property(it6505); in it6505_lane_count_setup()
1561 it6505_set_bits(it6505, REG_TRAIN_CTRL0, LANE_SWAP, in it6505_lane_count_setup()
1562 it6505->lane_swap ? LANE_SWAP : 0x00); in it6505_lane_count_setup()
1563 it6505_set_bits(it6505, REG_TRAIN_CTRL0, LANE_COUNT_MASK, in it6505_lane_count_setup()
1564 (it6505->lane_count - 1) << 1); in it6505_lane_count_setup()
1567 static void it6505_link_training_setup(struct it6505 *it6505) in it6505_link_training_setup() argument
1569 struct device *dev = it6505->dev; in it6505_link_training_setup()
1571 if (it6505->enable_enhanced_frame) in it6505_link_training_setup()
1572 it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, in it6505_link_training_setup()
1575 it6505_link_rate_setup(it6505); in it6505_link_training_setup()
1576 it6505_lane_count_setup(it6505); in it6505_link_training_setup()
1577 it6505_setup_ssc(it6505); in it6505_link_training_setup()
1580 it6505->link_rate_bw_code != RBR ? "HBR" : "RBR", in it6505_link_training_setup()
1581 it6505->lane_count, in it6505_link_training_setup()
1582 it6505->enable_ssc ? "en" : "dis", in it6505_link_training_setup()
1583 it6505->enable_enhanced_frame ? "en" : "dis"); in it6505_link_training_setup()
1586 static bool it6505_link_start_auto_train(struct it6505 *it6505) in it6505_link_start_auto_train() argument
1591 mutex_lock(&it6505->aux_lock); in it6505_link_start_auto_train()
1592 it6505_set_bits(it6505, REG_TRAIN_CTRL0, in it6505_link_start_auto_train()
1594 it6505_write(it6505, REG_TRAIN_CTRL1, FORCE_RETRAIN); in it6505_link_start_auto_train()
1595 it6505_write(it6505, REG_TRAIN_CTRL1, AUTO_TRAIN); in it6505_link_start_auto_train()
1599 link_training_state = it6505_read(it6505, REG_LINK_TRAIN_STS); in it6505_link_start_auto_train()
1610 mutex_unlock(&it6505->aux_lock); in it6505_link_start_auto_train()
1615 static int it6505_drm_dp_link_configure(struct it6505 *it6505) in it6505_drm_dp_link_configure() argument
1619 struct drm_dp_aux *aux = &it6505->aux; in it6505_drm_dp_link_configure()
1621 values[0] = it6505->link_rate_bw_code; in it6505_drm_dp_link_configure()
1622 values[1] = it6505->lane_count; in it6505_drm_dp_link_configure()
1624 if (it6505->enable_enhanced_frame) in it6505_drm_dp_link_configure()
1658 step_train_lane_voltage_para_set(struct it6505 *it6505, in step_train_lane_voltage_para_set() argument
1667 for (i = 0; i < it6505->lane_count; i++) { in step_train_lane_voltage_para_set()
1680 it6505_dpcd_write(it6505, DP_TRAINING_LANE0_SET + i, in step_train_lane_voltage_para_set()
1684 it6505_dpcd_read(it6505, DP_TRAINING_LANE0_SET + i)) in step_train_lane_voltage_para_set()
1692 it6505_step_cr_train(struct it6505 *it6505, in it6505_step_cr_train() argument
1699 const struct drm_dp_aux *aux = &it6505->aux; in it6505_step_cr_train()
1701 it6505_dpcd_write(it6505, DP_DOWNSPREAD_CTRL, in it6505_step_cr_train()
1702 it6505->enable_ssc ? DP_SPREAD_AMP_0_5 : 0x00); in it6505_step_cr_train()
1703 it6505_dpcd_write(it6505, DP_TRAINING_PATTERN_SET, in it6505_step_cr_train()
1708 if (!step_train_lane_voltage_para_set(it6505, in it6505_step_cr_train()
1712 drm_dp_link_train_clock_recovery_delay(aux, it6505->dpcd); in it6505_step_cr_train()
1713 drm_dp_dpcd_read_link_status(&it6505->aux, link_status); in it6505_step_cr_train()
1715 if (drm_dp_clock_recovery_ok(link_status, it6505->lane_count)) { in it6505_step_cr_train()
1716 it6505_set_bits(it6505, REG_TRAIN_CTRL0, FORCE_CR_DONE, in it6505_step_cr_train()
1720 DRM_DEV_DEBUG_DRIVER(it6505->dev, "cr not done"); in it6505_step_cr_train()
1723 it6505->lane_count)) in it6505_step_cr_train()
1726 for (j = 0; j < it6505->lane_count; j++) { in it6505_step_cr_train()
1759 it6505_dpcd_write(it6505, DP_TRAINING_PATTERN_SET, in it6505_step_cr_train()
1766 it6505_step_eq_train(struct it6505 *it6505, in it6505_step_eq_train() argument
1771 const struct drm_dp_aux *aux = &it6505->aux; in it6505_step_eq_train()
1773 it6505_dpcd_write(it6505, DP_TRAINING_PATTERN_SET, in it6505_step_eq_train()
1779 if (!step_train_lane_voltage_para_set(it6505, in it6505_step_eq_train()
1784 drm_dp_link_train_channel_eq_delay(aux, it6505->dpcd); in it6505_step_eq_train()
1785 drm_dp_dpcd_read_link_status(&it6505->aux, link_status); in it6505_step_eq_train()
1787 if (!drm_dp_clock_recovery_ok(link_status, it6505->lane_count)) in it6505_step_eq_train()
1790 if (drm_dp_channel_eq_ok(link_status, it6505->lane_count)) { in it6505_step_eq_train()
1791 it6505_dpcd_write(it6505, DP_TRAINING_PATTERN_SET, in it6505_step_eq_train()
1793 it6505_set_bits(it6505, REG_TRAIN_CTRL0, FORCE_EQ_DONE, in it6505_step_eq_train()
1797 DRM_DEV_DEBUG_DRIVER(it6505->dev, "eq not done"); in it6505_step_eq_train()
1799 for (i = 0; i < it6505->lane_count; i++) { in it6505_step_eq_train()
1819 it6505_dpcd_write(it6505, DP_TRAINING_PATTERN_SET, in it6505_step_eq_train()
1824 static bool it6505_link_start_step_train(struct it6505 *it6505) in it6505_link_start_step_train() argument
1832 DRM_DEV_DEBUG_DRIVER(it6505->dev, "start"); in it6505_link_start_step_train()
1833 err = it6505_drm_dp_link_configure(it6505); in it6505_link_start_step_train()
1837 if (!it6505_step_cr_train(it6505, &lane_voltage_pre_emphasis)) in it6505_link_start_step_train()
1839 if (!it6505_step_eq_train(it6505, &lane_voltage_pre_emphasis)) in it6505_link_start_step_train()
1844 static bool it6505_get_video_status(struct it6505 *it6505) in it6505_get_video_status() argument
1848 reg_0d = it6505_read(it6505, REG_SYSTEM_STS); in it6505_get_video_status()
1856 static void it6505_reset_hdcp(struct it6505 *it6505) in it6505_reset_hdcp() argument
1858 it6505->hdcp_status = HDCP_AUTH_IDLE; in it6505_reset_hdcp()
1860 it6505_set_bits(it6505, REG_HDCP_CTRL1, HDCP_CP_ENABLE, 0x00); in it6505_reset_hdcp()
1861 it6505_set_bits(it6505, REG_RESET_CTRL, HDCP_RESET, HDCP_RESET); in it6505_reset_hdcp()
1864 static void it6505_start_hdcp(struct it6505 *it6505) in it6505_start_hdcp() argument
1866 struct device *dev = it6505->dev; in it6505_start_hdcp()
1869 it6505_reset_hdcp(it6505); in it6505_start_hdcp()
1870 queue_delayed_work(system_wq, &it6505->hdcp_work, in it6505_start_hdcp()
1874 static void it6505_stop_hdcp(struct it6505 *it6505) in it6505_stop_hdcp() argument
1876 it6505_reset_hdcp(it6505); in it6505_stop_hdcp()
1877 cancel_delayed_work(&it6505->hdcp_work); in it6505_stop_hdcp()
1892 static void it6505_hdcp_part1_auth(struct it6505 *it6505) in it6505_hdcp_part1_auth() argument
1894 struct device *dev = it6505->dev; in it6505_hdcp_part1_auth()
1897 it6505_set_bits(it6505, REG_RESET_CTRL, HDCP_RESET, 0x00); in it6505_hdcp_part1_auth()
1899 it6505_set_bits(it6505, REG_HDCP_CTRL1, HDCP_CP_ENABLE, 0x00); in it6505_hdcp_part1_auth()
1902 hdcp_bcaps = it6505_dpcd_read(it6505, DP_AUX_HDCP_BCAPS); in it6505_hdcp_part1_auth()
1910 it6505_set_bits(it6505, REG_HDCP_TRIGGER, in it6505_hdcp_part1_auth()
1915 it6505_set_bits(it6505, REG_HDCP_CTRL2, HDCP_AN_GEN, HDCP_AN_GEN); in it6505_hdcp_part1_auth()
1919 it6505_set_bits(it6505, REG_HDCP_CTRL2, HDCP_AN_GEN, 0x00); in it6505_hdcp_part1_auth()
1921 it6505_set_bits(it6505, REG_HDCP_CTRL1, HDCP_CP_ENABLE, HDCP_CP_ENABLE); in it6505_hdcp_part1_auth()
1923 it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_START, in it6505_hdcp_part1_auth()
1926 it6505->hdcp_status = HDCP_AUTH_GOING; in it6505_hdcp_part1_auth()
1929 static int it6505_sha1_digest(struct it6505 *it6505, u8 *sha1_input, in it6505_sha1_digest() argument
1935 struct device *dev = it6505->dev; in it6505_sha1_digest()
1958 static int it6505_setup_sha1_input(struct it6505 *it6505, u8 *sha1_input) in it6505_setup_sha1_input() argument
1960 struct device *dev = it6505->dev; in it6505_setup_sha1_input()
1964 err = it6505_get_dpcd(it6505, DP_AUX_HDCP_BINFO, binfo, in it6505_setup_sha1_input()
1989 err = it6505_get_dpcd(it6505, DP_AUX_HDCP_KSV_FIFO + in it6505_setup_sha1_input()
2000 it6505->hdcp_down_stream_count = down_stream_count; in it6505_setup_sha1_input()
2004 it6505_set_bits(it6505, REG_HDCP_CTRL2, HDCP_EN_M0_READ, in it6505_setup_sha1_input()
2007 err = regmap_bulk_read(it6505->regmap, REG_M0_0_7, in it6505_setup_sha1_input()
2010 it6505_set_bits(it6505, REG_HDCP_CTRL2, HDCP_EN_M0_READ, 0x00); in it6505_setup_sha1_input()
2022 static bool it6505_hdcp_part2_ksvlist_check(struct it6505 *it6505) in it6505_hdcp_part2_ksvlist_check() argument
2024 struct device *dev = it6505->dev; in it6505_hdcp_part2_ksvlist_check()
2028 i = it6505_setup_sha1_input(it6505, it6505->sha1_input); in it6505_hdcp_part2_ksvlist_check()
2034 it6505_sha1_digest(it6505, it6505->sha1_input, i, (u8 *)av); in it6505_hdcp_part2_ksvlist_check()
2036 err = it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, in it6505_hdcp_part2_ksvlist_check()
2055 struct it6505 *it6505 = container_of(work, struct it6505, in it6505_hdcp_wait_ksv_list() local
2057 struct device *dev = it6505->dev; in it6505_hdcp_wait_ksv_list()
2064 if (!it6505_get_sink_hpd_status(it6505)) in it6505_hdcp_wait_ksv_list()
2067 bstatus = it6505_dpcd_read(it6505, DP_AUX_HDCP_BSTATUS); in it6505_hdcp_wait_ksv_list()
2081 ksv_list_check = it6505_hdcp_part2_ksvlist_check(it6505); in it6505_hdcp_wait_ksv_list()
2085 it6505_set_bits(it6505, REG_HDCP_TRIGGER, in it6505_hdcp_wait_ksv_list()
2090 it6505_set_bits(it6505, REG_HDCP_TRIGGER, in it6505_hdcp_wait_ksv_list()
2097 struct it6505 *it6505 = container_of(work, struct it6505, in it6505_hdcp_work() local
2099 struct device *dev = it6505->dev; in it6505_hdcp_work()
2105 if (!it6505_get_sink_hpd_status(it6505)) in it6505_hdcp_work()
2108 ret = drm_dp_dpcd_read_link_status(&it6505->aux, link_status); in it6505_hdcp_work()
2112 if (ret < 0 || !drm_dp_channel_eq_ok(link_status, it6505->lane_count) || in it6505_hdcp_work()
2113 !it6505_get_video_status(it6505)) { in it6505_hdcp_work()
2118 ret = it6505_get_dpcd(it6505, DP_AUX_HDCP_BKSV, it6505->bksvs, in it6505_hdcp_work()
2119 ARRAY_SIZE(it6505->bksvs)); in it6505_hdcp_work()
2122 it6505_set_bits(it6505, REG_HDCP_TRIGGER, in it6505_hdcp_work()
2127 (int)ARRAY_SIZE(it6505->bksvs), it6505->bksvs); in it6505_hdcp_work()
2129 if (!it6505_hdcp_is_ksv_valid(it6505->bksvs)) { in it6505_hdcp_work()
2131 it6505_set_bits(it6505, REG_HDCP_TRIGGER, in it6505_hdcp_work()
2135 it6505_hdcp_part1_auth(it6505); in it6505_hdcp_work()
2138 static void it6505_show_hdcp_info(struct it6505 *it6505) in it6505_show_hdcp_info() argument
2140 struct device *dev = it6505->dev; in it6505_show_hdcp_info()
2142 u8 *sha1 = it6505->sha1_input; in it6505_show_hdcp_info()
2145 it6505->hdcp_status, it6505->is_repeater); in it6505_show_hdcp_info()
2147 (int)ARRAY_SIZE(it6505->bksvs), it6505->bksvs); in it6505_show_hdcp_info()
2149 if (it6505->is_repeater) { in it6505_show_hdcp_info()
2151 it6505->hdcp_down_stream_count); in it6505_show_hdcp_info()
2153 (int)ARRAY_SIZE(it6505->sha1_input), in it6505_show_hdcp_info()
2154 it6505->sha1_input); in it6505_show_hdcp_info()
2155 for (i = 0; i < it6505->hdcp_down_stream_count; i++) { in it6505_show_hdcp_info()
2165 static void it6505_stop_link_train(struct it6505 *it6505) in it6505_stop_link_train() argument
2167 it6505->link_state = LINK_IDLE; in it6505_stop_link_train()
2168 cancel_work_sync(&it6505->link_works); in it6505_stop_link_train()
2169 it6505_write(it6505, REG_TRAIN_CTRL1, FORCE_RETRAIN); in it6505_stop_link_train()
2172 static void it6505_link_train_ok(struct it6505 *it6505) in it6505_link_train_ok() argument
2174 struct device *dev = it6505->dev; in it6505_link_train_ok()
2176 it6505->link_state = LINK_OK; in it6505_link_train_ok()
2178 it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, 0x00); in it6505_link_train_ok()
2179 it6505_set_bits(it6505, REG_INFOFRAME_CTRL, in it6505_link_train_ok()
2182 if (it6505_audio_input(it6505)) { in it6505_link_train_ok()
2184 it6505_enable_audio(it6505); in it6505_link_train_ok()
2187 if (it6505->hdcp_desired) in it6505_link_train_ok()
2188 it6505_start_hdcp(it6505); in it6505_link_train_ok()
2191 static void it6505_link_step_train_process(struct it6505 *it6505) in it6505_link_step_train_process() argument
2193 struct device *dev = it6505->dev; in it6505_link_step_train_process()
2198 if (it6505->sink_count == 0) { in it6505_link_step_train_process()
2199 DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count:%d, force eq", in it6505_link_step_train_process()
2200 it6505->sink_count); in it6505_link_step_train_process()
2201 it6505_set_bits(it6505, REG_TRAIN_CTRL0, FORCE_EQ_DONE, in it6505_link_step_train_process()
2206 if (!it6505->step_train) { in it6505_link_step_train_process()
2213 it6505_link_reset_step_train(it6505); in it6505_link_step_train_process()
2214 ret = it6505_link_start_step_train(it6505); in it6505_link_step_train_process()
2218 it6505_link_train_ok(it6505); in it6505_link_step_train_process()
2224 it6505->link_state = LINK_IDLE; in it6505_link_step_train_process()
2225 it6505_video_reset(it6505); in it6505_link_step_train_process()
2230 struct it6505 *it6505 = container_of(work, struct it6505, link_works); in it6505_link_training_work() local
2231 struct device *dev = it6505->dev; in it6505_link_training_work()
2234 DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count: %d", in it6505_link_training_work()
2235 it6505->sink_count); in it6505_link_training_work()
2237 if (!it6505_get_sink_hpd_status(it6505)) in it6505_link_training_work()
2240 it6505_link_training_setup(it6505); in it6505_link_training_work()
2241 it6505_reset_hdcp(it6505); in it6505_link_training_work()
2242 it6505_aux_reset(it6505); in it6505_link_training_work()
2244 if (it6505->auto_train_retry < 1) { in it6505_link_training_work()
2245 it6505_link_step_train_process(it6505); in it6505_link_training_work()
2249 ret = it6505_link_start_auto_train(it6505); in it6505_link_training_work()
2251 ret ? "pass" : "failed", it6505->auto_train_retry); in it6505_link_training_work()
2254 it6505->auto_train_retry = AUTO_TRAIN_RETRY; in it6505_link_training_work()
2255 it6505_link_train_ok(it6505); in it6505_link_training_work()
2257 it6505->auto_train_retry--; in it6505_link_training_work()
2258 it6505_dump(it6505); in it6505_link_training_work()
2263 static void it6505_plugged_status_to_codec(struct it6505 *it6505) in it6505_plugged_status_to_codec() argument
2265 enum drm_connector_status status = it6505->connector_status; in it6505_plugged_status_to_codec()
2267 if (it6505->plugged_cb && it6505->codec_dev) in it6505_plugged_status_to_codec()
2268 it6505->plugged_cb(it6505->codec_dev, in it6505_plugged_status_to_codec()
2272 static void it6505_remove_edid(struct it6505 *it6505) in it6505_remove_edid() argument
2274 drm_edid_free(it6505->cached_edid); in it6505_remove_edid()
2275 it6505->cached_edid = NULL; in it6505_remove_edid()
2278 static int it6505_process_hpd_irq(struct it6505 *it6505) in it6505_process_hpd_irq() argument
2280 struct device *dev = it6505->dev; in it6505_process_hpd_irq()
2284 if (!it6505_get_sink_hpd_status(it6505)) { in it6505_process_hpd_irq()
2286 it6505->sink_count = 0; in it6505_process_hpd_irq()
2290 ret = it6505_dpcd_read(it6505, DP_SINK_COUNT); in it6505_process_hpd_irq()
2295 DRM_DEV_DEBUG_DRIVER(dev, "dpcd_sink_count: %d it6505->sink_count:%d", in it6505_process_hpd_irq()
2296 dpcd_sink_count, it6505->sink_count); in it6505_process_hpd_irq()
2298 if (it6505->branch_device && dpcd_sink_count != it6505->sink_count) { in it6505_process_hpd_irq()
2299 memset(it6505->dpcd, 0, sizeof(it6505->dpcd)); in it6505_process_hpd_irq()
2300 it6505->sink_count = dpcd_sink_count; in it6505_process_hpd_irq()
2301 it6505_reset_logic(it6505); in it6505_process_hpd_irq()
2302 it6505_int_mask_enable(it6505); in it6505_process_hpd_irq()
2303 it6505_init(it6505); in it6505_process_hpd_irq()
2304 it6505_remove_edid(it6505); in it6505_process_hpd_irq()
2308 dp_irq_vector = it6505_dpcd_read(it6505, DP_DEVICE_SERVICE_IRQ_VECTOR); in it6505_process_hpd_irq()
2315 it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, in it6505_process_hpd_irq()
2318 bstatus = it6505_dpcd_read(it6505, DP_AUX_HDCP_BSTATUS); in it6505_process_hpd_irq()
2325 ret = drm_dp_dpcd_read_link_status(&it6505->aux, link_status); in it6505_process_hpd_irq()
2334 if (!drm_dp_channel_eq_ok(link_status, it6505->lane_count)) { in it6505_process_hpd_irq()
2335 it6505->auto_train_retry = AUTO_TRAIN_RETRY; in it6505_process_hpd_irq()
2336 it6505_video_reset(it6505); in it6505_process_hpd_irq()
2342 static void it6505_irq_hpd(struct it6505 *it6505) in it6505_irq_hpd() argument
2344 struct device *dev = it6505->dev; in it6505_irq_hpd()
2347 it6505->hpd_state = it6505_get_sink_hpd_status(it6505); in it6505_irq_hpd()
2349 it6505->hpd_state ? "high" : "low"); in it6505_irq_hpd()
2351 if (it6505->hpd_state) { in it6505_irq_hpd()
2352 wait_for_completion_timeout(&it6505->extcon_completion, in it6505_irq_hpd()
2354 it6505_aux_on(it6505); in it6505_irq_hpd()
2355 if (it6505->dpcd[0] == 0) { in it6505_irq_hpd()
2356 it6505_get_dpcd(it6505, DP_DPCD_REV, it6505->dpcd, in it6505_irq_hpd()
2357 ARRAY_SIZE(it6505->dpcd)); in it6505_irq_hpd()
2358 it6505_variable_config(it6505); in it6505_irq_hpd()
2359 it6505_parse_link_capabilities(it6505); in it6505_irq_hpd()
2361 it6505->auto_train_retry = AUTO_TRAIN_RETRY; in it6505_irq_hpd()
2363 it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, in it6505_irq_hpd()
2365 dp_sink_count = it6505_dpcd_read(it6505, DP_SINK_COUNT); in it6505_irq_hpd()
2366 it6505->sink_count = DP_GET_SINK_COUNT(dp_sink_count); in it6505_irq_hpd()
2368 DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count: %d", in it6505_irq_hpd()
2369 it6505->sink_count); in it6505_irq_hpd()
2371 it6505_lane_termination_on(it6505); in it6505_irq_hpd()
2372 it6505_lane_power_on(it6505); in it6505_irq_hpd()
2377 * it6505 not able to receive HPD_IRQ in it6505_irq_hpd()
2381 if (it6505->branch_device && it6505->sink_count == 0) in it6505_irq_hpd()
2382 schedule_work(&it6505->link_works); in it6505_irq_hpd()
2384 if (!it6505_get_video_status(it6505)) in it6505_irq_hpd()
2385 it6505_video_reset(it6505); in it6505_irq_hpd()
2387 memset(it6505->dpcd, 0, sizeof(it6505->dpcd)); in it6505_irq_hpd()
2388 it6505_remove_edid(it6505); in it6505_irq_hpd()
2390 if (it6505->hdcp_desired) in it6505_irq_hpd()
2391 it6505_stop_hdcp(it6505); in it6505_irq_hpd()
2393 it6505_video_disable(it6505); in it6505_irq_hpd()
2394 it6505_disable_audio(it6505); in it6505_irq_hpd()
2395 it6505_stop_link_train(it6505); in it6505_irq_hpd()
2396 it6505_lane_off(it6505); in it6505_irq_hpd()
2397 it6505_link_reset_step_train(it6505); in it6505_irq_hpd()
2400 if (it6505->bridge.dev) in it6505_irq_hpd()
2401 drm_helper_hpd_irq_event(it6505->bridge.dev); in it6505_irq_hpd()
2404 static void it6505_irq_hpd_irq(struct it6505 *it6505) in it6505_irq_hpd_irq() argument
2406 struct device *dev = it6505->dev; in it6505_irq_hpd_irq()
2410 if (it6505_process_hpd_irq(it6505) < 0) in it6505_irq_hpd_irq()
2414 static void it6505_irq_scdt(struct it6505 *it6505) in it6505_irq_scdt() argument
2416 struct device *dev = it6505->dev; in it6505_irq_scdt()
2419 data = it6505_get_video_status(it6505); in it6505_irq_scdt()
2422 it6505_calc_video_info(it6505); in it6505_irq_scdt()
2423 it6505_link_reset_step_train(it6505); in it6505_irq_scdt()
2426 schedule_work(&it6505->link_works); in it6505_irq_scdt()
2429 static void it6505_irq_hdcp_done(struct it6505 *it6505) in it6505_irq_hdcp_done() argument
2431 struct device *dev = it6505->dev; in it6505_irq_hdcp_done()
2434 it6505->hdcp_status = HDCP_AUTH_DONE; in it6505_irq_hdcp_done()
2435 it6505_show_hdcp_info(it6505); in it6505_irq_hdcp_done()
2438 static void it6505_irq_hdcp_fail(struct it6505 *it6505) in it6505_irq_hdcp_fail() argument
2440 struct device *dev = it6505->dev; in it6505_irq_hdcp_fail()
2443 it6505->hdcp_status = HDCP_AUTH_IDLE; in it6505_irq_hdcp_fail()
2444 it6505_show_hdcp_info(it6505); in it6505_irq_hdcp_fail()
2445 it6505_start_hdcp(it6505); in it6505_irq_hdcp_fail()
2448 static void it6505_irq_aux_cmd_fail(struct it6505 *it6505) in it6505_irq_aux_cmd_fail() argument
2450 struct device *dev = it6505->dev; in it6505_irq_aux_cmd_fail()
2455 static void it6505_irq_hdcp_ksv_check(struct it6505 *it6505) in it6505_irq_hdcp_ksv_check() argument
2457 struct device *dev = it6505->dev; in it6505_irq_hdcp_ksv_check()
2460 schedule_work(&it6505->hdcp_wait_ksv_list); in it6505_irq_hdcp_ksv_check()
2463 static void it6505_irq_audio_fifo_error(struct it6505 *it6505) in it6505_irq_audio_fifo_error() argument
2465 struct device *dev = it6505->dev; in it6505_irq_audio_fifo_error()
2469 if (it6505_audio_input(it6505)) in it6505_irq_audio_fifo_error()
2470 it6505_enable_audio(it6505); in it6505_irq_audio_fifo_error()
2473 static void it6505_irq_link_train_fail(struct it6505 *it6505) in it6505_irq_link_train_fail() argument
2475 struct device *dev = it6505->dev; in it6505_irq_link_train_fail()
2478 schedule_work(&it6505->link_works); in it6505_irq_link_train_fail()
2486 static void it6505_irq_video_handler(struct it6505 *it6505, const int *int_status) in it6505_irq_video_handler() argument
2488 struct device *dev = it6505->dev; in it6505_irq_video_handler()
2496 if ((!it6505_get_video_status(it6505) && in it6505_irq_video_handler()
2502 it6505->auto_train_retry = AUTO_TRAIN_RETRY; in it6505_irq_video_handler()
2503 flush_work(&it6505->link_works); in it6505_irq_video_handler()
2504 it6505_stop_hdcp(it6505); in it6505_irq_video_handler()
2505 it6505_video_reset(it6505); in it6505_irq_video_handler()
2514 reg_int03 = it6505_read(it6505, INT_STATUS_03); in it6505_irq_video_handler()
2515 reg_0d = it6505_read(it6505, REG_SYSTEM_STS); in it6505_irq_video_handler()
2518 it6505_write(it6505, INT_STATUS_03, reg_int03); in it6505_irq_video_handler()
2527 it6505_irq_scdt(it6505); in it6505_irq_video_handler()
2532 struct it6505 *it6505 = data; in it6505_int_threaded_handler() local
2533 struct device *dev = it6505->dev; in it6505_int_threaded_handler()
2536 void (*handler)(struct it6505 *it6505); in it6505_int_threaded_handler()
2549 if (it6505->enable_drv_hold || !it6505->powered) in it6505_int_threaded_handler()
2554 int_status[0] = it6505_read(it6505, INT_STATUS_01); in it6505_int_threaded_handler()
2555 int_status[1] = it6505_read(it6505, INT_STATUS_02); in it6505_int_threaded_handler()
2556 int_status[2] = it6505_read(it6505, INT_STATUS_03); in it6505_int_threaded_handler()
2558 it6505_write(it6505, INT_STATUS_01, int_status[0]); in it6505_int_threaded_handler()
2559 it6505_write(it6505, INT_STATUS_02, int_status[1]); in it6505_int_threaded_handler()
2560 it6505_write(it6505, INT_STATUS_03, int_status[2]); in it6505_int_threaded_handler()
2565 it6505_debug_print(it6505, REG_SYSTEM_STS, ""); in it6505_int_threaded_handler()
2568 irq_vec[0].handler(it6505); in it6505_int_threaded_handler()
2570 if (it6505->hpd_state) { in it6505_int_threaded_handler()
2573 irq_vec[i].handler(it6505); in it6505_int_threaded_handler()
2575 it6505_irq_video_handler(it6505, (unsigned int *)int_status); in it6505_int_threaded_handler()
2583 static int it6505_poweron(struct it6505 *it6505) in it6505_poweron() argument
2585 struct device *dev = it6505->dev; in it6505_poweron()
2586 struct it6505_platform_data *pdata = &it6505->pdata; in it6505_poweron()
2589 DRM_DEV_DEBUG_DRIVER(dev, "it6505 start powered on"); in it6505_poweron()
2591 if (it6505->powered) { in it6505_poweron()
2592 DRM_DEV_DEBUG_DRIVER(dev, "it6505 already powered on"); in it6505_poweron()
2623 it6505->powered = true; in it6505_poweron()
2624 it6505_reset_logic(it6505); in it6505_poweron()
2625 it6505_int_mask_enable(it6505); in it6505_poweron()
2626 it6505_init(it6505); in it6505_poweron()
2627 it6505_lane_off(it6505); in it6505_poweron()
2629 enable_irq(it6505->irq); in it6505_poweron()
2634 static int it6505_poweroff(struct it6505 *it6505) in it6505_poweroff() argument
2636 struct device *dev = it6505->dev; in it6505_poweroff()
2637 struct it6505_platform_data *pdata = &it6505->pdata; in it6505_poweroff()
2640 DRM_DEV_DEBUG_DRIVER(dev, "it6505 start power off"); in it6505_poweroff()
2642 if (!it6505->powered) { in it6505_poweroff()
2647 disable_irq_nosync(it6505->irq); in it6505_poweroff()
2664 it6505->powered = false; in it6505_poweroff()
2665 it6505->sink_count = 0; in it6505_poweroff()
2670 static enum drm_connector_status it6505_detect(struct it6505 *it6505) in it6505_detect() argument
2672 struct device *dev = it6505->dev; in it6505_detect()
2676 DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count:%d powered:%d", in it6505_detect()
2677 it6505->sink_count, it6505->powered); in it6505_detect()
2679 mutex_lock(&it6505->mode_lock); in it6505_detect()
2681 if (!it6505->powered) in it6505_detect()
2684 if (it6505->enable_drv_hold) { in it6505_detect()
2685 status = it6505->hpd_state ? connector_status_connected : in it6505_detect()
2690 if (it6505->hpd_state) { in it6505_detect()
2691 it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, in it6505_detect()
2693 dp_sink_count = it6505_dpcd_read(it6505, DP_SINK_COUNT); in it6505_detect()
2694 it6505->sink_count = DP_GET_SINK_COUNT(dp_sink_count); in it6505_detect()
2695 DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count:%d branch:%d", in it6505_detect()
2696 it6505->sink_count, it6505->branch_device); in it6505_detect()
2698 if (it6505->branch_device) { in it6505_detect()
2699 status = (it6505->sink_count != 0) ? in it6505_detect()
2706 it6505->sink_count = 0; in it6505_detect()
2707 memset(it6505->dpcd, 0, sizeof(it6505->dpcd)); in it6505_detect()
2711 if (it6505->connector_status != status) { in it6505_detect()
2712 it6505->connector_status = status; in it6505_detect()
2713 it6505_plugged_status_to_codec(it6505); in it6505_detect()
2716 mutex_unlock(&it6505->mode_lock); in it6505_detect()
2724 struct it6505 *it6505 = container_of(self, struct it6505, event_nb); in it6505_extcon_notifier() local
2726 schedule_work(&it6505->extcon_wq); in it6505_extcon_notifier()
2732 struct it6505 *it6505 = container_of(work, struct it6505, extcon_wq); in it6505_extcon_work() local
2733 struct device *dev = it6505->dev; in it6505_extcon_work()
2736 if (it6505->enable_drv_hold) in it6505_extcon_work()
2739 mutex_lock(&it6505->extcon_lock); in it6505_extcon_work()
2741 state = extcon_get_state(it6505->extcon, EXTCON_DISP_DP); in it6505_extcon_work()
2744 if (state == it6505->extcon_state || unlikely(state < 0)) in it6505_extcon_work()
2746 it6505->extcon_state = state; in it6505_extcon_work()
2758 it6505_poweron(it6505); in it6505_extcon_work()
2760 complete_all(&it6505->extcon_completion); in it6505_extcon_work()
2764 reinit_completion(&it6505->extcon_completion); in it6505_extcon_work()
2766 drm_helper_hpd_irq_event(it6505->bridge.dev); in it6505_extcon_work()
2767 memset(it6505->dpcd, 0, sizeof(it6505->dpcd)); in it6505_extcon_work()
2768 DRM_DEV_DEBUG_DRIVER(dev, "power off it6505 success!"); in it6505_extcon_work()
2772 mutex_unlock(&it6505->extcon_lock); in it6505_extcon_work()
2775 static int it6505_use_notifier_module(struct it6505 *it6505) in it6505_use_notifier_module() argument
2778 struct device *dev = it6505->dev; in it6505_use_notifier_module()
2780 it6505->event_nb.notifier_call = it6505_extcon_notifier; in it6505_use_notifier_module()
2781 INIT_WORK(&it6505->extcon_wq, it6505_extcon_work); in it6505_use_notifier_module()
2782 ret = devm_extcon_register_notifier(it6505->dev, in it6505_use_notifier_module()
2783 it6505->extcon, EXTCON_DISP_DP, in it6505_use_notifier_module()
2784 &it6505->event_nb); in it6505_use_notifier_module()
2790 schedule_work(&it6505->extcon_wq); in it6505_use_notifier_module()
2795 static void it6505_remove_notifier_module(struct it6505 *it6505) in it6505_remove_notifier_module() argument
2797 if (it6505->extcon) { in it6505_remove_notifier_module()
2798 devm_extcon_unregister_notifier(it6505->dev, in it6505_remove_notifier_module()
2799 it6505->extcon, EXTCON_DISP_DP, in it6505_remove_notifier_module()
2800 &it6505->event_nb); in it6505_remove_notifier_module()
2802 flush_work(&it6505->extcon_wq); in it6505_remove_notifier_module()
2808 struct it6505 *it6505 = container_of(work, struct it6505, in it6505_delayed_audio() local
2811 DRM_DEV_DEBUG_DRIVER(it6505->dev, "start"); in it6505_delayed_audio()
2813 if (!it6505->powered) in it6505_delayed_audio()
2816 if (!it6505->enable_drv_hold) in it6505_delayed_audio()
2817 it6505_enable_audio(it6505); in it6505_delayed_audio()
2820 static int __maybe_unused it6505_audio_setup_hw_params(struct it6505 *it6505, in it6505_audio_setup_hw_params() argument
2824 struct device *dev = it6505->dev; in it6505_audio_setup_hw_params()
2831 if (!it6505->bridge.encoder) in it6505_audio_setup_hw_params()
2836 it6505->audio.channel_count); in it6505_audio_setup_hw_params()
2840 it6505->audio.channel_count = params->cea.channels; in it6505_audio_setup_hw_params()
2852 it6505->audio.sample_rate = audio_sample_rate_map[i].rate; in it6505_audio_setup_hw_params()
2856 it6505->audio.word_length = WORD_LENGTH_16BIT; in it6505_audio_setup_hw_params()
2859 it6505->audio.word_length = WORD_LENGTH_18BIT; in it6505_audio_setup_hw_params()
2862 it6505->audio.word_length = WORD_LENGTH_20BIT; in it6505_audio_setup_hw_params()
2866 it6505->audio.word_length = WORD_LENGTH_24BIT; in it6505_audio_setup_hw_params()
2879 struct it6505 *it6505 = dev_get_drvdata(dev); in it6505_audio_shutdown() local
2881 if (it6505->powered) in it6505_audio_shutdown()
2882 it6505_disable_audio(it6505); in it6505_audio_shutdown()
2890 struct it6505 *it6505 = data; in it6505_audio_hook_plugged_cb() local
2892 it6505->plugged_cb = fn; in it6505_audio_hook_plugged_cb()
2893 it6505->codec_dev = codec_dev; in it6505_audio_hook_plugged_cb()
2894 it6505_plugged_status_to_codec(it6505); in it6505_audio_hook_plugged_cb()
2899 static inline struct it6505 *bridge_to_it6505(struct drm_bridge *bridge) in bridge_to_it6505()
2901 return container_of(bridge, struct it6505, bridge); in bridge_to_it6505()
2907 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_attach() local
2908 struct device *dev = it6505->dev; in it6505_bridge_attach()
2917 it6505->aux.drm_dev = bridge->dev; in it6505_bridge_attach()
2919 ret = drm_dp_aux_register(&it6505->aux); in it6505_bridge_attach()
2926 if (it6505->extcon) { in it6505_bridge_attach()
2927 ret = it6505_use_notifier_module(it6505); in it6505_bridge_attach()
2939 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_detach() local
2941 flush_work(&it6505->link_works); in it6505_bridge_detach()
2942 it6505_remove_notifier_module(it6505); in it6505_bridge_detach()
2950 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_mode_valid() local
2955 if (mode->clock > it6505->max_dpi_pixel_clock) in it6505_bridge_mode_valid()
2958 it6505->video_info.clock = mode->clock; in it6505_bridge_mode_valid()
2966 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_atomic_enable() local
2967 struct device *dev = it6505->dev; in it6505_bridge_atomic_enable()
3005 it6505_update_video_parameter(it6505, mode); in it6505_bridge_atomic_enable()
3007 ret = it6505_send_video_infoframe(it6505, &frame); in it6505_bridge_atomic_enable()
3012 it6505_int_mask_enable(it6505); in it6505_bridge_atomic_enable()
3013 it6505_video_reset(it6505); in it6505_bridge_atomic_enable()
3015 it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, in it6505_bridge_atomic_enable()
3022 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_atomic_disable() local
3023 struct device *dev = it6505->dev; in it6505_bridge_atomic_disable()
3027 if (it6505->powered) { in it6505_bridge_atomic_disable()
3028 it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link, in it6505_bridge_atomic_disable()
3030 it6505_video_disable(it6505); in it6505_bridge_atomic_disable()
3037 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_atomic_pre_enable() local
3038 struct device *dev = it6505->dev; in it6505_bridge_atomic_pre_enable()
3048 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_atomic_post_disable() local
3049 struct device *dev = it6505->dev; in it6505_bridge_atomic_post_disable()
3059 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_detect() local
3061 return it6505_detect(it6505); in it6505_bridge_detect()
3067 struct it6505 *it6505 = bridge_to_it6505(bridge); in it6505_bridge_edid_read() local
3068 struct device *dev = it6505->dev; in it6505_bridge_edid_read()
3070 if (!it6505->cached_edid) { in it6505_bridge_edid_read()
3071 it6505->cached_edid = drm_edid_read_custom(connector, in it6505_bridge_edid_read()
3073 it6505); in it6505_bridge_edid_read()
3075 if (!it6505->cached_edid) { in it6505_bridge_edid_read()
3081 return drm_edid_dup(it6505->cached_edid); in it6505_bridge_edid_read()
3101 struct it6505 *it6505 = dev_get_drvdata(dev); in it6505_bridge_resume() local
3103 return it6505_poweron(it6505); in it6505_bridge_resume()
3108 struct it6505 *it6505 = dev_get_drvdata(dev); in it6505_bridge_suspend() local
3110 return it6505_poweroff(it6505); in it6505_bridge_suspend()
3118 static int it6505_init_pdata(struct it6505 *it6505) in it6505_init_pdata() argument
3120 struct it6505_platform_data *pdata = &it6505->pdata; in it6505_init_pdata()
3121 struct device *dev = it6505->dev; in it6505_init_pdata()
3161 static void it6505_parse_dt(struct it6505 *it6505) in it6505_parse_dt() argument
3163 struct device *dev = it6505->dev; in it6505_parse_dt()
3168 u32 *afe_setting = &it6505->afe_setting; in it6505_parse_dt()
3169 u32 *max_lane_count = &it6505->max_lane_count; in it6505_parse_dt()
3170 u32 *max_dpi_pixel_clock = &it6505->max_dpi_pixel_clock; in it6505_parse_dt()
3172 it6505->lane_swap_disabled = in it6505_parse_dt()
3175 if (it6505->lane_swap_disabled) in it6505_parse_dt()
3176 it6505->lane_swap = false; in it6505_parse_dt()
3233 it6505->afe_setting, it6505->max_lane_count); in it6505_parse_dt()
3235 it6505->max_dpi_pixel_clock); in it6505_parse_dt()
3241 struct it6505 *it6505 = file->private_data; in receive_timing_debugfs_show() local
3247 if (!it6505) in receive_timing_debugfs_show()
3250 it6505_calc_video_info(it6505); in receive_timing_debugfs_show()
3251 vid = &it6505->video_info; in receive_timing_debugfs_show()
3280 struct it6505 *it6505 = data; in force_power_on_off_debugfs_write() local
3282 if (!it6505) in force_power_on_off_debugfs_write()
3286 it6505_poweron(it6505); in force_power_on_off_debugfs_write()
3288 it6505_poweroff(it6505); in force_power_on_off_debugfs_write()
3295 struct it6505 *it6505 = data; in enable_drv_hold_debugfs_show() local
3297 if (!it6505) in enable_drv_hold_debugfs_show()
3300 *buf = it6505->enable_drv_hold; in enable_drv_hold_debugfs_show()
3307 struct it6505 *it6505 = data; in enable_drv_hold_debugfs_write() local
3309 if (!it6505) in enable_drv_hold_debugfs_write()
3312 it6505->enable_drv_hold = drv_hold; in enable_drv_hold_debugfs_write()
3314 if (it6505->enable_drv_hold) { in enable_drv_hold_debugfs_write()
3315 it6505_int_mask_disable(it6505); in enable_drv_hold_debugfs_write()
3317 it6505_clear_int(it6505); in enable_drv_hold_debugfs_write()
3318 it6505_int_mask_enable(it6505); in enable_drv_hold_debugfs_write()
3320 if (it6505->powered) { in enable_drv_hold_debugfs_write()
3321 it6505->connector_status = in enable_drv_hold_debugfs_write()
3322 it6505_get_sink_hpd_status(it6505) ? in enable_drv_hold_debugfs_write()
3326 it6505->connector_status = in enable_drv_hold_debugfs_write()
3354 static void debugfs_create_files(struct it6505 *it6505) in debugfs_create_files() argument
3360 it6505->debugfs, it6505, in debugfs_create_files()
3366 static void debugfs_init(struct it6505 *it6505) in debugfs_init() argument
3368 struct device *dev = it6505->dev; in debugfs_init()
3370 it6505->debugfs = debugfs_create_dir(DEBUGFS_DIR_NAME, NULL); in debugfs_init()
3372 if (IS_ERR(it6505->debugfs)) { in debugfs_init()
3377 debugfs_create_files(it6505); in debugfs_init()
3380 static void it6505_debugfs_remove(struct it6505 *it6505) in it6505_debugfs_remove() argument
3382 debugfs_remove_recursive(it6505->debugfs); in it6505_debugfs_remove()
3387 struct it6505 *it6505 = dev_get_drvdata(&client->dev); in it6505_shutdown() local
3389 if (it6505->powered) in it6505_shutdown()
3390 it6505_lane_off(it6505); in it6505_shutdown()
3395 struct it6505 *it6505; in it6505_i2c_probe() local
3400 it6505 = devm_kzalloc(&client->dev, sizeof(*it6505), GFP_KERNEL); in it6505_i2c_probe()
3401 if (!it6505) in it6505_i2c_probe()
3404 mutex_init(&it6505->extcon_lock); in it6505_i2c_probe()
3405 mutex_init(&it6505->mode_lock); in it6505_i2c_probe()
3406 mutex_init(&it6505->aux_lock); in it6505_i2c_probe()
3408 it6505->bridge.of_node = client->dev.of_node; in it6505_i2c_probe()
3409 it6505->connector_status = connector_status_disconnected; in it6505_i2c_probe()
3410 it6505->dev = &client->dev; in it6505_i2c_probe()
3411 i2c_set_clientdata(client, it6505); in it6505_i2c_probe()
3422 it6505->extcon = extcon; in it6505_i2c_probe()
3424 it6505->regmap = devm_regmap_init_i2c(client, &it6505_regmap_config); in it6505_i2c_probe()
3425 if (IS_ERR(it6505->regmap)) { in it6505_i2c_probe()
3427 err = PTR_ERR(it6505->regmap); in it6505_i2c_probe()
3431 err = it6505_init_pdata(it6505); in it6505_i2c_probe()
3437 it6505_parse_dt(it6505); in it6505_i2c_probe()
3439 it6505->irq = client->irq; in it6505_i2c_probe()
3441 if (!it6505->irq) { in it6505_i2c_probe()
3447 err = devm_request_threaded_irq(&client->dev, it6505->irq, NULL, in it6505_i2c_probe()
3451 "it6505-intp", it6505); in it6505_i2c_probe()
3457 INIT_WORK(&it6505->link_works, it6505_link_training_work); in it6505_i2c_probe()
3458 INIT_WORK(&it6505->hdcp_wait_ksv_list, it6505_hdcp_wait_ksv_list); in it6505_i2c_probe()
3459 INIT_DELAYED_WORK(&it6505->hdcp_work, it6505_hdcp_work); in it6505_i2c_probe()
3460 init_completion(&it6505->extcon_completion); in it6505_i2c_probe()
3461 memset(it6505->dpcd, 0, sizeof(it6505->dpcd)); in it6505_i2c_probe()
3462 it6505->powered = false; in it6505_i2c_probe()
3463 it6505->enable_drv_hold = DEFAULT_DRV_HOLD; in it6505_i2c_probe()
3466 it6505_poweron(it6505); in it6505_i2c_probe()
3468 DRM_DEV_DEBUG_DRIVER(dev, "it6505 device name: %s", dev_name(dev)); in it6505_i2c_probe()
3469 debugfs_init(it6505); in it6505_i2c_probe()
3472 it6505->aux.name = "DP-AUX"; in it6505_i2c_probe()
3473 it6505->aux.dev = dev; in it6505_i2c_probe()
3474 it6505->aux.transfer = it6505_aux_transfer; in it6505_i2c_probe()
3475 drm_dp_aux_init(&it6505->aux); in it6505_i2c_probe()
3477 it6505->bridge.funcs = &it6505_bridge_funcs; in it6505_i2c_probe()
3478 it6505->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; in it6505_i2c_probe()
3479 it6505->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | in it6505_i2c_probe()
3481 drm_bridge_add(&it6505->bridge); in it6505_i2c_probe()
3488 struct it6505 *it6505 = i2c_get_clientdata(client); in it6505_i2c_remove() local
3490 drm_bridge_remove(&it6505->bridge); in it6505_i2c_remove()
3491 drm_dp_aux_unregister(&it6505->aux); in it6505_i2c_remove()
3492 it6505_debugfs_remove(it6505); in it6505_i2c_remove()
3493 it6505_poweroff(it6505); in it6505_i2c_remove()
3494 it6505_remove_edid(it6505); in it6505_i2c_remove()
3498 { "it6505", 0 },
3505 { .compatible = "ite,it6505" },
3511 .name = "it6505",
3524 MODULE_DESCRIPTION("IT6505 DisplayPort Transmitter driver");