Lines Matching full:dp
14 #include "cdn-dp-core.h"
15 #include "cdn-dp-reg.h"
24 void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk) in cdn_dp_set_fw_clk() argument
26 writel(clk / 1000000, dp->regs + SW_CLK_H); in cdn_dp_set_fw_clk()
29 void cdn_dp_clock_reset(struct cdn_dp_device *dp) in cdn_dp_clock_reset() argument
45 writel(val, dp->regs + SOURCE_DPTX_CAR); in cdn_dp_clock_reset()
48 writel(val, dp->regs + SOURCE_PHY_CAR); in cdn_dp_clock_reset()
54 writel(val, dp->regs + SOURCE_PKT_CAR); in cdn_dp_clock_reset()
62 writel(val, dp->regs + SOURCE_AIF_CAR); in cdn_dp_clock_reset()
68 writel(val, dp->regs + SOURCE_CIPHER_CAR); in cdn_dp_clock_reset()
72 writel(val, dp->regs + SOURCE_CRYPTO_CAR); in cdn_dp_clock_reset()
75 writel(0, dp->regs + APB_INT_MASK); in cdn_dp_clock_reset()
78 static int cdn_dp_mailbox_read(struct cdn_dp_device *dp) in cdn_dp_mailbox_read() argument
82 ret = readx_poll_timeout(readl, dp->regs + MAILBOX_EMPTY_ADDR, in cdn_dp_mailbox_read()
88 return readl(dp->regs + MAILBOX0_RD_DATA) & 0xff; in cdn_dp_mailbox_read()
91 static int cdp_dp_mailbox_write(struct cdn_dp_device *dp, u8 val) in cdp_dp_mailbox_write() argument
95 ret = readx_poll_timeout(readl, dp->regs + MAILBOX_FULL_ADDR, in cdp_dp_mailbox_write()
101 writel(val, dp->regs + MAILBOX0_WR_DATA); in cdp_dp_mailbox_write()
106 static int cdn_dp_mailbox_validate_receive(struct cdn_dp_device *dp, in cdn_dp_mailbox_validate_receive() argument
116 ret = cdn_dp_mailbox_read(dp); in cdn_dp_mailbox_validate_receive()
132 if (cdn_dp_mailbox_read(dp) < 0) in cdn_dp_mailbox_validate_receive()
141 static int cdn_dp_mailbox_read_receive(struct cdn_dp_device *dp, in cdn_dp_mailbox_read_receive() argument
148 ret = cdn_dp_mailbox_read(dp); in cdn_dp_mailbox_read_receive()
158 static int cdn_dp_mailbox_send(struct cdn_dp_device *dp, u8 module_id, in cdn_dp_mailbox_send() argument
170 ret = cdp_dp_mailbox_write(dp, header[i]); in cdn_dp_mailbox_send()
176 ret = cdp_dp_mailbox_write(dp, message[i]); in cdn_dp_mailbox_send()
184 static int cdn_dp_reg_write(struct cdn_dp_device *dp, u16 addr, u32 val) in cdn_dp_reg_write() argument
194 return cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_WRITE_REGISTER, in cdn_dp_reg_write()
198 static int cdn_dp_reg_write_bit(struct cdn_dp_device *dp, u16 addr, in cdn_dp_reg_write_bit() argument
212 return cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_WRITE_FIELD, in cdn_dp_reg_write_bit()
216 int cdn_dp_dpcd_read(struct cdn_dp_device *dp, u32 addr, u8 *data, u16 len) in cdn_dp_dpcd_read() argument
226 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_READ_DPCD, in cdn_dp_dpcd_read()
231 ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX, in cdn_dp_dpcd_read()
237 ret = cdn_dp_mailbox_read_receive(dp, reg, sizeof(reg)); in cdn_dp_dpcd_read()
241 ret = cdn_dp_mailbox_read_receive(dp, data, len); in cdn_dp_dpcd_read()
247 int cdn_dp_dpcd_write(struct cdn_dp_device *dp, u32 addr, u8 value) in cdn_dp_dpcd_write() argument
258 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_WRITE_DPCD, in cdn_dp_dpcd_write()
263 ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX, in cdn_dp_dpcd_write()
268 ret = cdn_dp_mailbox_read_receive(dp, reg, sizeof(reg)); in cdn_dp_dpcd_write()
277 DRM_DEV_ERROR(dp->dev, "dpcd write failed: %d\n", ret); in cdn_dp_dpcd_write()
281 int cdn_dp_load_firmware(struct cdn_dp_device *dp, const u32 *i_mem, in cdn_dp_load_firmware() argument
289 dp->regs + APB_CTRL); in cdn_dp_load_firmware()
292 writel(*i_mem++, dp->regs + ADDR_IMEM + i); in cdn_dp_load_firmware()
295 writel(*d_mem++, dp->regs + ADDR_DMEM + i); in cdn_dp_load_firmware()
298 writel(0, dp->regs + APB_CTRL); in cdn_dp_load_firmware()
301 ret = readx_poll_timeout(readl, dp->regs + KEEP_ALIVE, in cdn_dp_load_firmware()
304 DRM_DEV_ERROR(dp->dev, "failed to loaded the FW reg = %x\n", in cdn_dp_load_firmware()
309 reg = readl(dp->regs + VER_L) & 0xff; in cdn_dp_load_firmware()
310 dp->fw_version = reg; in cdn_dp_load_firmware()
311 reg = readl(dp->regs + VER_H) & 0xff; in cdn_dp_load_firmware()
312 dp->fw_version |= reg << 8; in cdn_dp_load_firmware()
313 reg = readl(dp->regs + VER_LIB_L_ADDR) & 0xff; in cdn_dp_load_firmware()
314 dp->fw_version |= reg << 16; in cdn_dp_load_firmware()
315 reg = readl(dp->regs + VER_LIB_H_ADDR) & 0xff; in cdn_dp_load_firmware()
316 dp->fw_version |= reg << 24; in cdn_dp_load_firmware()
318 DRM_DEV_DEBUG(dp->dev, "firmware version: %x\n", dp->fw_version); in cdn_dp_load_firmware()
323 int cdn_dp_set_firmware_active(struct cdn_dp_device *dp, bool enable) in cdn_dp_set_firmware_active() argument
335 ret = cdp_dp_mailbox_write(dp, msg[i]); in cdn_dp_set_firmware_active()
342 ret = cdn_dp_mailbox_read(dp); in cdn_dp_set_firmware_active()
353 DRM_DEV_ERROR(dp->dev, "set firmware active failed\n"); in cdn_dp_set_firmware_active()
357 int cdn_dp_set_host_cap(struct cdn_dp_device *dp, u8 lanes, bool flip) in cdn_dp_set_host_cap() argument
371 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, in cdn_dp_set_host_cap()
377 ret = cdn_dp_reg_write(dp, DP_AUX_SWAP_INVERSION_CONTROL, in cdn_dp_set_host_cap()
382 DRM_DEV_ERROR(dp->dev, "set host cap failed: %d\n", ret); in cdn_dp_set_host_cap()
386 int cdn_dp_event_config(struct cdn_dp_device *dp) in cdn_dp_event_config() argument
395 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_ENABLE_EVENT, in cdn_dp_event_config()
398 DRM_DEV_ERROR(dp->dev, "set event config failed: %d\n", ret); in cdn_dp_event_config()
403 u32 cdn_dp_get_event(struct cdn_dp_device *dp) in cdn_dp_get_event() argument
405 return readl(dp->regs + SW_EVENTS0); in cdn_dp_get_event()
408 int cdn_dp_get_hpd_status(struct cdn_dp_device *dp) in cdn_dp_get_hpd_status() argument
413 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_HPD_STATE, in cdn_dp_get_hpd_status()
418 ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX, in cdn_dp_get_hpd_status()
423 ret = cdn_dp_mailbox_read_receive(dp, &status, sizeof(status)); in cdn_dp_get_hpd_status()
430 DRM_DEV_ERROR(dp->dev, "get hpd status failed: %d\n", ret); in cdn_dp_get_hpd_status()
437 struct cdn_dp_device *dp = data; in cdn_dp_get_edid_block() local
445 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_GET_EDID, in cdn_dp_get_edid_block()
450 ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX, in cdn_dp_get_edid_block()
456 ret = cdn_dp_mailbox_read_receive(dp, reg, sizeof(reg)); in cdn_dp_get_edid_block()
460 ret = cdn_dp_mailbox_read_receive(dp, edid, length); in cdn_dp_get_edid_block()
469 DRM_DEV_ERROR(dp->dev, "get block[%d] edid failed: %d\n", block, in cdn_dp_get_edid_block()
475 static int cdn_dp_training_start(struct cdn_dp_device *dp) in cdn_dp_training_start() argument
484 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_TRAINING_CONTROL, in cdn_dp_training_start()
492 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, in cdn_dp_training_start()
497 ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX, in cdn_dp_training_start()
503 ret = cdn_dp_mailbox_read_receive(dp, event, sizeof(event)); in cdn_dp_training_start()
514 DRM_DEV_ERROR(dp->dev, "training failed: %d\n", ret); in cdn_dp_training_start()
518 static int cdn_dp_get_training_status(struct cdn_dp_device *dp) in cdn_dp_get_training_status() argument
523 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_READ_LINK_STAT, in cdn_dp_get_training_status()
528 ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX, in cdn_dp_get_training_status()
534 ret = cdn_dp_mailbox_read_receive(dp, status, sizeof(status)); in cdn_dp_get_training_status()
538 dp->max_rate = drm_dp_bw_code_to_link_rate(status[0]); in cdn_dp_get_training_status()
539 dp->max_lanes = status[1]; in cdn_dp_get_training_status()
543 DRM_DEV_ERROR(dp->dev, "get training status failed: %d\n", ret); in cdn_dp_get_training_status()
547 int cdn_dp_train_link(struct cdn_dp_device *dp) in cdn_dp_train_link() argument
551 ret = cdn_dp_training_start(dp); in cdn_dp_train_link()
553 DRM_DEV_ERROR(dp->dev, "Failed to start training %d\n", ret); in cdn_dp_train_link()
557 ret = cdn_dp_get_training_status(dp); in cdn_dp_train_link()
559 DRM_DEV_ERROR(dp->dev, "Failed to get training stat %d\n", ret); in cdn_dp_train_link()
563 DRM_DEV_DEBUG_KMS(dp->dev, "rate:0x%x, lanes:%d\n", dp->max_rate, in cdn_dp_train_link()
564 dp->max_lanes); in cdn_dp_train_link()
568 int cdn_dp_set_video_status(struct cdn_dp_device *dp, int active) in cdn_dp_set_video_status() argument
575 ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_SET_VIDEO, in cdn_dp_set_video_status()
578 DRM_DEV_ERROR(dp->dev, "set video status failed: %d\n", ret); in cdn_dp_set_video_status()
630 int cdn_dp_config_video(struct cdn_dp_device *dp) in cdn_dp_config_video() argument
632 struct video_info *video = &dp->video_info; in cdn_dp_config_video()
633 struct drm_display_mode *mode = &dp->mode; in cdn_dp_config_video()
642 link_rate = dp->max_rate / 1000; in cdn_dp_config_video()
644 ret = cdn_dp_reg_write(dp, BND_HSYNC2VSYNC, VIF_BYPASS_INTERLACE); in cdn_dp_config_video()
648 ret = cdn_dp_reg_write(dp, HSYNC2VSYNC_POL_CTRL, 0); in cdn_dp_config_video()
662 do_div(symbol, dp->max_lanes * link_rate * 8); in cdn_dp_config_video()
666 DRM_DEV_ERROR(dp->dev, in cdn_dp_config_video()
668 mode->clock, dp->max_lanes, link_rate); in cdn_dp_config_video()
676 ret = cdn_dp_reg_write(dp, DP_FRAMER_TU, val); in cdn_dp_config_video()
682 val /= (dp->max_lanes * link_rate); in cdn_dp_config_video()
685 ret = cdn_dp_reg_write(dp, DP_VC_TABLE(15), val); in cdn_dp_config_video()
706 ret = cdn_dp_reg_write(dp, DP_FRAMER_PXL_REPR, val); in cdn_dp_config_video()
712 ret = cdn_dp_reg_write(dp, DP_FRAMER_SP, val); in cdn_dp_config_video()
718 ret = cdn_dp_reg_write(dp, DP_FRONT_BACK_PORCH, val); in cdn_dp_config_video()
723 ret = cdn_dp_reg_write(dp, DP_BYTE_COUNT, val); in cdn_dp_config_video()
728 ret = cdn_dp_reg_write(dp, MSA_HORIZONTAL_0, val); in cdn_dp_config_video()
734 ret = cdn_dp_reg_write(dp, MSA_HORIZONTAL_1, val); in cdn_dp_config_video()
740 ret = cdn_dp_reg_write(dp, MSA_VERTICAL_0, val); in cdn_dp_config_video()
746 ret = cdn_dp_reg_write(dp, MSA_VERTICAL_1, val); in cdn_dp_config_video()
751 ret = cdn_dp_reg_write(dp, MSA_MISC, val); in cdn_dp_config_video()
755 ret = cdn_dp_reg_write(dp, STREAM_CONFIG, 1); in cdn_dp_config_video()
761 ret = cdn_dp_reg_write(dp, DP_HORIZONTAL, val); in cdn_dp_config_video()
767 ret = cdn_dp_reg_write(dp, DP_VERTICAL_0, val); in cdn_dp_config_video()
772 ret = cdn_dp_reg_write(dp, DP_VERTICAL_1, val); in cdn_dp_config_video()
776 ret = cdn_dp_reg_write_bit(dp, DP_VB_ID, 2, 1, 0); in cdn_dp_config_video()
780 DRM_DEV_ERROR(dp->dev, "config video failed: %d\n", ret); in cdn_dp_config_video()
784 int cdn_dp_audio_stop(struct cdn_dp_device *dp, struct audio_info *audio) in cdn_dp_audio_stop() argument
788 ret = cdn_dp_reg_write(dp, AUDIO_PACK_CONTROL, 0); in cdn_dp_audio_stop()
790 DRM_DEV_ERROR(dp->dev, "audio stop failed: %d\n", ret); in cdn_dp_audio_stop()
794 writel(0, dp->regs + SPDIF_CTRL_ADDR); in cdn_dp_audio_stop()
797 writel(0, dp->regs + AUDIO_SRC_CNTL); in cdn_dp_audio_stop()
798 writel(0, dp->regs + AUDIO_SRC_CNFG); in cdn_dp_audio_stop()
799 writel(AUDIO_SW_RST, dp->regs + AUDIO_SRC_CNTL); in cdn_dp_audio_stop()
800 writel(0, dp->regs + AUDIO_SRC_CNTL); in cdn_dp_audio_stop()
803 writel(0, dp->regs + SMPL2PKT_CNTL); in cdn_dp_audio_stop()
804 writel(AUDIO_SW_RST, dp->regs + SMPL2PKT_CNTL); in cdn_dp_audio_stop()
805 writel(0, dp->regs + SMPL2PKT_CNTL); in cdn_dp_audio_stop()
808 writel(AUDIO_SW_RST, dp->regs + FIFO_CNTL); in cdn_dp_audio_stop()
809 writel(0, dp->regs + FIFO_CNTL); in cdn_dp_audio_stop()
812 clk_disable_unprepare(dp->spdif_clk); in cdn_dp_audio_stop()
817 int cdn_dp_audio_mute(struct cdn_dp_device *dp, bool enable) in cdn_dp_audio_mute() argument
821 ret = cdn_dp_reg_write_bit(dp, DP_VB_ID, 4, 1, enable); in cdn_dp_audio_mute()
823 DRM_DEV_ERROR(dp->dev, "audio mute failed: %d\n", ret); in cdn_dp_audio_mute()
828 static void cdn_dp_audio_config_i2s(struct cdn_dp_device *dp, in cdn_dp_audio_config_i2s() argument
835 if (dp->max_lanes == 1) in cdn_dp_audio_config_i2s()
845 writel(0x0, dp->regs + SPDIF_CTRL_ADDR); in cdn_dp_audio_config_i2s()
847 writel(SYNC_WR_TO_CH_ZERO, dp->regs + FIFO_CNTL); in cdn_dp_audio_config_i2s()
853 writel(val, dp->regs + SMPL2PKT_CNFG); in cdn_dp_audio_config_i2s()
865 writel(val, dp->regs + AUDIO_SRC_CNFG); in cdn_dp_audio_config_i2s()
874 writel(val, dp->regs + STTS_BIT_CH(i)); in cdn_dp_audio_config_i2s()
908 writel(val, dp->regs + COM_CH_STTS_BITS); in cdn_dp_audio_config_i2s()
910 writel(SMPL2PKT_EN, dp->regs + SMPL2PKT_CNTL); in cdn_dp_audio_config_i2s()
911 writel(I2S_DEC_START, dp->regs + AUDIO_SRC_CNTL); in cdn_dp_audio_config_i2s()
914 static void cdn_dp_audio_config_spdif(struct cdn_dp_device *dp) in cdn_dp_audio_config_spdif() argument
918 writel(SYNC_WR_TO_CH_ZERO, dp->regs + FIFO_CNTL); in cdn_dp_audio_config_spdif()
921 writel(val, dp->regs + SMPL2PKT_CNFG); in cdn_dp_audio_config_spdif()
922 writel(SMPL2PKT_EN, dp->regs + SMPL2PKT_CNTL); in cdn_dp_audio_config_spdif()
925 writel(val, dp->regs + SPDIF_CTRL_ADDR); in cdn_dp_audio_config_spdif()
927 clk_prepare_enable(dp->spdif_clk); in cdn_dp_audio_config_spdif()
928 clk_set_rate(dp->spdif_clk, CDN_DP_SPDIF_CLK); in cdn_dp_audio_config_spdif()
931 int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio) in cdn_dp_audio_config() argument
937 reset_control_assert(dp->spdif_rst); in cdn_dp_audio_config()
938 reset_control_deassert(dp->spdif_rst); in cdn_dp_audio_config()
941 ret = cdn_dp_reg_write(dp, CM_LANE_CTRL, LANE_REF_CYC); in cdn_dp_audio_config()
945 ret = cdn_dp_reg_write(dp, CM_CTRL, 0); in cdn_dp_audio_config()
950 cdn_dp_audio_config_i2s(dp, audio); in cdn_dp_audio_config()
952 cdn_dp_audio_config_spdif(dp); in cdn_dp_audio_config()
954 ret = cdn_dp_reg_write(dp, AUDIO_PACK_CONTROL, AUDIO_PACK_EN); in cdn_dp_audio_config()
958 DRM_DEV_ERROR(dp->dev, "audio config failed: %d\n", ret); in cdn_dp_audio_config()