<div dir="ltr"><div dir="ltr">Hi Maxime,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Maxime Ripard <maxime@cerno.tech> 于2021年3月24日周三 下午7:27写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Feb 22, 2021 at 09:28:22PM +0800, Kevin Tang wrote:<br>
> Adds dsi host controller support for the Unisoc's display subsystem.<br>
> Adds dsi phy support for the Unisoc's display subsystem.<br>
> Only MIPI DSI Displays supported, DP/TV/HMDI will be support<br>
> in the feature.<br>
> <br>
> v1:<br>
> - Remove dphy and dsi graph binding, merge the dphy driver into the dsi.<br>
> <br>
> v2:<br>
> - Use drm_xxx to replace all DRM_XXX.<br>
> - Use kzalloc to replace devm_kzalloc for sprd_dsi structure init.<br>
> <br>
> v4:<br>
> - Use drmm_helpers to allocate encoder.<br>
> - Move allocate encoder and connector to bind funtion.<br>
<br>
You're missing your Signed-off-by<br>
<br>
And there's a bunch of errors warnings and (important) checks reported<br>
by checkpatch --strict that you should fix.<br></blockquote><div>Thks, it's will be fixed on patch v5. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> ---<br>
> drivers/gpu/drm/sprd/Makefile | 7 +-<br>
> drivers/gpu/drm/sprd/dw_dsi_ctrl.c | 794 +++++++++++++<br>
> drivers/gpu/drm/sprd/dw_dsi_ctrl.h | 1475 ++++++++++++++++++++++++<br>
> drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.c | 157 +++<br>
> drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.h | 26 +<br>
> drivers/gpu/drm/sprd/megacores_pll.c | 317 +++++<br>
> drivers/gpu/drm/sprd/megacores_pll.h | 146 +++<br>
> drivers/gpu/drm/sprd/sprd_drm.c | 1 +<br>
> drivers/gpu/drm/sprd/sprd_drm.h | 1 +<br>
> drivers/gpu/drm/sprd/sprd_dsi.c | 1132 ++++++++++++++++++<br>
> drivers/gpu/drm/sprd/sprd_dsi.h | 104 ++<br>
> 11 files changed, 4158 insertions(+), 2 deletions(-)<br>
> create mode 100644 drivers/gpu/drm/sprd/dw_dsi_ctrl.c<br>
> create mode 100644 drivers/gpu/drm/sprd/dw_dsi_ctrl.h<br>
> create mode 100644 drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.c<br>
> create mode 100644 drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.h<br>
> create mode 100644 drivers/gpu/drm/sprd/megacores_pll.c<br>
> create mode 100644 drivers/gpu/drm/sprd/megacores_pll.h<br>
> create mode 100644 drivers/gpu/drm/sprd/sprd_dsi.c<br>
> create mode 100644 drivers/gpu/drm/sprd/sprd_dsi.h<br>
> <br>
> diff --git a/drivers/gpu/drm/sprd/Makefile b/drivers/gpu/drm/sprd/Makefile<br>
> index 6c25bfa99..d49f4977b 100644<br>
> --- a/drivers/gpu/drm/sprd/Makefile<br>
> +++ b/drivers/gpu/drm/sprd/Makefile<br>
> @@ -1,5 +1,8 @@<br>
> # SPDX-License-Identifier: GPL-2.0<br>
> <br>
> obj-y := sprd_drm.o \<br>
> - sprd_dpu.o<br>
> -<br>
> + sprd_dpu.o \<br>
> + sprd_dsi.o \<br>
> + dw_dsi_ctrl.o \<br>
> + dw_dsi_ctrl_ppi.o \<br>
<br>
So it's a designware IP? There's a driver for it already that seems<br>
fairly similar:<br>
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c<br></blockquote><div><div><span class="gmail-il">Our dw</span> dsi controller is not a standard synopsys ip, we have updated a lot on the basic ip version,</div><div>the entire control register is different, i have cc to drm/bridge reviewers and maintainers.</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> + megacores_pll.o<br>
> diff --git a/drivers/gpu/drm/sprd/dw_dsi_ctrl.c b/drivers/gpu/drm/sprd/dw_dsi_ctrl.c<br>
> new file mode 100644<br>
> index 000000000..1034aba4a<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/dw_dsi_ctrl.c<br>
> @@ -0,0 +1,794 @@<br>
> +// SPDX-License-Identifier: GPL-2.0<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#include <linux/io.h><br>
> +#include <linux/init.h><br>
> +#include <linux/delay.h><br>
> +#include <linux/module.h><br>
> +<br>
> +#include "dw_dsi_ctrl.h"<br>
> +<br>
> +/*<br>
> + * Modify power status of DSI Host core<br>
> + */<br>
> +void dsi_power_enable(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(enable, ®->SOFT_RESET);<br>
> +}<br>
> +/*<br>
> + * Enable/disable DPI video mode<br>
> + */<br>
> +void dsi_video_mode(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(0, ®->DSI_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Enable command mode (Generic interface)<br>
> + */<br>
> +void dsi_cmd_mode(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(1, ®->DSI_MODE_CFG);<br>
> +}<br>
> +<br>
> +bool dsi_is_cmd_mode(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + return readl(®->DSI_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Configure the read back virtual channel for the generic interface<br>
> + */<br>
> +void dsi_rx_vcid(struct dsi_context *ctx, u8 vc)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x1C virtual_channel_id;<br>
> +<br>
> + virtual_channel_id.val = readl(®->VIRTUAL_CHANNEL_ID);<br>
> + virtual_channel_id.bits.gen_rx_vcid = vc;<br>
> +<br>
> + writel(virtual_channel_id.val, ®->VIRTUAL_CHANNEL_ID);<br>
> +}<br>
> +/*<br>
> + * Write the DPI video virtual channel destination<br>
> + */<br>
> +void dsi_video_vcid(struct dsi_context *ctx, u8 vc)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x1C virtual_channel_id;<br>
> +<br>
> + virtual_channel_id.val = readl(®->VIRTUAL_CHANNEL_ID);<br>
> + virtual_channel_id.bits.video_pkt_vcid = vc;<br>
> +<br>
> + writel(virtual_channel_id.val, ®->VIRTUAL_CHANNEL_ID);<br>
> +}<br>
> +/*<br>
> + * Set DPI video mode type (burst/non-burst - with sync pulses or events)<br>
> + */<br>
> +void dsi_dpi_video_burst_mode(struct dsi_context *ctx, int mode)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x38 vid_mode_cfg;<br>
> +<br>
> + vid_mode_cfg.val = readl(®->VID_MODE_CFG);<br>
> + vid_mode_cfg.bits.vid_mode_type = mode;<br>
> +<br>
> + writel(vid_mode_cfg.val, ®->VID_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Set DPI video color coding<br>
> + */<br>
> +void dsi_dpi_color_coding(struct dsi_context *ctx, int coding)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x20 dpi_video_format;<br>
> +<br>
> + dpi_video_format.val = readl(®->DPI_VIDEO_FORMAT);<br>
> + dpi_video_format.bits.dpi_video_mode_format = coding;<br>
> +<br>
> + writel(dpi_video_format.val, ®->DPI_VIDEO_FORMAT);<br>
> +}<br>
> +/*<br>
> + * Configure the Horizontal Line time<br>
> + * param "byte_cycle" taken to transmit the total of the horizontal line<br>
> + */<br>
> +void dsi_dpi_hline_time(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x2C video_line_time;<br>
> +<br>
> + video_line_time.val = readl(®->VIDEO_LINE_TIME);<br>
> + video_line_time.bits.video_line_time = byte_cycle;<br>
> +<br>
> + writel(video_line_time.val, ®->VIDEO_LINE_TIME);<br>
> +}<br>
> +/*<br>
> + * Configure the Horizontal back porch time<br>
> + * param "byte_cycle" taken to transmit the horizontal back porch<br>
> + */<br>
> +void dsi_dpi_hbp_time(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x28 video_line_hblk_time;<br>
> +<br>
> + video_line_hblk_time.val = readl(®->VIDEO_LINE_HBLK_TIME);<br>
> + video_line_hblk_time.bits.video_line_hbp_time = byte_cycle;<br>
> +<br>
> + writel(video_line_hblk_time.val, ®->VIDEO_LINE_HBLK_TIME);<br>
> +}<br>
> +/*<br>
> + * Configure the Horizontal sync time,<br>
> + * param "byte_cycle" taken to transmit the horizontal sync<br>
> + */<br>
> +void dsi_dpi_hsync_time(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x28 video_line_hblk_time;<br>
> +<br>
> + video_line_hblk_time.val = readl(®->VIDEO_LINE_HBLK_TIME);<br>
> + video_line_hblk_time.bits.video_line_hsa_time = byte_cycle;<br>
> +<br>
> + writel(video_line_hblk_time.val, ®->VIDEO_LINE_HBLK_TIME);<br>
> +}<br>
> +/*<br>
> + * Configure the vertical active lines of the video stream<br>
> + */<br>
> +void dsi_dpi_vact(struct dsi_context *ctx, u16 lines)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x34 video_active_lines;<br>
> +<br>
> + video_active_lines.val = readl(®->VIDEO_VACTIVE_LINES);<br>
> + video_active_lines.bits.vactive_lines = lines;<br>
> +<br>
> + writel(video_active_lines.val, ®->VIDEO_VACTIVE_LINES);<br>
> +}<br>
> +<br>
> +void dsi_dpi_vfp(struct dsi_context *ctx, u16 lines)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x30 video_vblk_lines;<br>
> +<br>
> + video_vblk_lines.val = readl(®->VIDEO_VBLK_LINES);<br>
> + video_vblk_lines.bits.vfp_lines = lines;<br>
> +<br>
> + writel(video_vblk_lines.val, ®->VIDEO_VBLK_LINES);<br>
> +}<br>
> +<br>
> +void dsi_dpi_vbp(struct dsi_context *ctx, u16 lines)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x30 video_vblk_lines;<br>
> +<br>
> + video_vblk_lines.val = readl(®->VIDEO_VBLK_LINES);<br>
> + video_vblk_lines.bits.vbp_lines = lines;<br>
> +<br>
> + writel(video_vblk_lines.val, ®->VIDEO_VBLK_LINES);<br>
> +}<br>
> +<br>
> +void dsi_dpi_vsync(struct dsi_context *ctx, u16 lines)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x30 video_vblk_lines;<br>
> +<br>
> + video_vblk_lines.val = readl(®->VIDEO_VBLK_LINES);<br>
> + video_vblk_lines.bits.vsa_lines = lines;<br>
> +<br>
> + writel(video_vblk_lines.val, ®->VIDEO_VBLK_LINES);<br>
> +}<br>
> +<br>
> +void dsi_dpi_hporch_lp_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x38 vid_mode_cfg;<br>
> +<br>
> + vid_mode_cfg.val = readl(®->VID_MODE_CFG);<br>
> +<br>
> + vid_mode_cfg.bits.lp_hfp_en = enable;<br>
> + vid_mode_cfg.bits.lp_hbp_en = enable;<br>
> +<br>
> + writel(vid_mode_cfg.val, ®->VID_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Enable return to low power mode inside vertical active lines periods when<br>
> + * timing allows<br>
> + */<br>
> +void dsi_dpi_vporch_lp_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x38 vid_mode_cfg;<br>
> +<br>
> + vid_mode_cfg.val = readl(®->VID_MODE_CFG);<br>
> +<br>
> + vid_mode_cfg.bits.lp_vact_en = enable;<br>
> + vid_mode_cfg.bits.lp_vfp_en = enable;<br>
> + vid_mode_cfg.bits.lp_vbp_en = enable;<br>
> + vid_mode_cfg.bits.lp_vsa_en = enable;<br>
> +<br>
> + writel(vid_mode_cfg.val, ®->VID_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Enable FRAME BTA ACK<br>
> + */<br>
> +void dsi_dpi_frame_ack_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x38 vid_mode_cfg;<br>
> +<br>
> + vid_mode_cfg.val = readl(®->VID_MODE_CFG);<br>
> + vid_mode_cfg.bits.frame_bta_ack_en = enable;<br>
> +<br>
> + writel(vid_mode_cfg.val, ®->VID_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Write no of chunks to core - taken into consideration only when multi packet<br>
> + * is enabled<br>
> + */<br>
> +void dsi_dpi_chunk_num(struct dsi_context *ctx, u16 num)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x24 video_pkt_config;<br>
> +<br>
> + video_pkt_config.val = readl(®->VIDEO_PKT_CONFIG);<br>
> + video_pkt_config.bits.video_line_chunk_num = num;<br>
> +<br>
> + writel(video_pkt_config.val, ®->VIDEO_PKT_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Write the null packet size - will only be taken into account when null<br>
> + * packets are enabled.<br>
> + */<br>
> +void dsi_dpi_null_packet_size(struct dsi_context *ctx, u16 size)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xC0 video_nullpkt_size;<br>
> +<br>
> + video_nullpkt_size.val = readl(®->VIDEO_NULLPKT_SIZE);<br>
> + video_nullpkt_size.bits.video_nullpkt_size = size;<br>
> +<br>
> + writel(video_nullpkt_size.val, ®->VIDEO_NULLPKT_SIZE);<br>
> +}<br>
> +/*<br>
> + * Write video packet size. obligatory for sending video<br>
> + */<br>
> +void dsi_dpi_video_packet_size(struct dsi_context *ctx, u16 size)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x24 video_pkt_config;<br>
> +<br>
> + video_pkt_config.val = readl(®->VIDEO_PKT_CONFIG);<br>
> + video_pkt_config.bits.video_pkt_size = size;<br>
> +<br>
> + writel(video_pkt_config.val, ®->VIDEO_PKT_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Specifiy the size of the packet memory write start/continue<br>
> + */<br>
> +void dsi_edpi_max_pkt_size(struct dsi_context *ctx, u16 size)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xC4 dcs_wm_pkt_size;<br>
> +<br>
> + dcs_wm_pkt_size.val = readl(®->DCS_WM_PKT_SIZE);<br>
> + dcs_wm_pkt_size.bits.dcs_wm_pkt_size = size;<br>
> +<br>
> + writel(dcs_wm_pkt_size.val, ®->DCS_WM_PKT_SIZE);<br>
> +}<br>
> +/*<br>
> + * Enable tear effect acknowledge<br>
> + */<br>
> +void dsi_tear_effect_ack_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x68 cmd_mode_cfg;<br>
> +<br>
> + cmd_mode_cfg.val = readl(®->CMD_MODE_CFG);<br>
> + cmd_mode_cfg.bits.tear_fx_en = enable;<br>
> +<br>
> + writel(cmd_mode_cfg.val, ®->CMD_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Set DCS command packet transmission to transmission type<br>
> + */<br>
> +void dsi_cmd_mode_lp_cmd_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x68 cmd_mode_cfg;<br>
> +<br>
> + cmd_mode_cfg.val = readl(®->CMD_MODE_CFG);<br>
> +<br>
> + cmd_mode_cfg.bits.gen_sw_0p_tx = enable;<br>
> + cmd_mode_cfg.bits.gen_sw_1p_tx = enable;<br>
> + cmd_mode_cfg.bits.gen_sw_2p_tx = enable;<br>
> + cmd_mode_cfg.bits.gen_lw_tx = enable;<br>
> + cmd_mode_cfg.bits.dcs_sw_0p_tx = enable;<br>
> + cmd_mode_cfg.bits.dcs_sw_1p_tx = enable;<br>
> + cmd_mode_cfg.bits.dcs_lw_tx = enable;<br>
> + cmd_mode_cfg.bits.max_rd_pkt_size = enable;<br>
> +<br>
> + cmd_mode_cfg.bits.gen_sr_0p_tx = enable;<br>
> + cmd_mode_cfg.bits.gen_sr_1p_tx = enable;<br>
> + cmd_mode_cfg.bits.gen_sr_2p_tx = enable;<br>
> + cmd_mode_cfg.bits.dcs_sr_0p_tx = enable;<br>
> +<br>
> + writel(cmd_mode_cfg.val, ®->CMD_MODE_CFG);<br>
> +}<br>
> +/*<br>
> + * Set DCS read command packet transmission to transmission type<br>
> + */<br>
> +void dsi_video_mode_lp_cmd_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x38 vid_mode_cfg;<br>
> +<br>
> + vid_mode_cfg.val = readl(®->VID_MODE_CFG);<br>
> + vid_mode_cfg.bits.lp_cmd_en = enable;<br>
> +<br>
> + writel(vid_mode_cfg.val, ®->VID_MODE_CFG);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Write command header in the generic interface (which also sends DCS commands) as a subset<br>
> + */<br>
> +void dsi_set_packet_header(struct dsi_context *ctx,<br>
> + u8 vc,<br>
> + u8 type,<br>
> + u8 wc_lsb,<br>
> + u8 wc_msb)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x6C gen_hdr;<br>
> +<br>
> + gen_hdr.bits.gen_dt = type;<br>
> + gen_hdr.bits.gen_vc = vc;<br>
> + gen_hdr.bits.gen_wc_lsbyte = wc_lsb;<br>
> + gen_hdr.bits.gen_wc_msbyte = wc_msb;<br>
> +<br>
> + writel(gen_hdr.val, ®->GEN_HDR);<br>
> +}<br>
> +/*<br>
> + * Write the payload of the long packet commands<br>
> + */<br>
> +void dsi_set_packet_payload(struct dsi_context *ctx, u32 payload)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(payload, ®->GEN_PLD_DATA);<br>
> +}<br>
> +/*<br>
> + * Read the payload of the long packet commands<br>
> + */<br>
> +u32 dsi_get_rx_payload(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + return readl(®->GEN_PLD_DATA);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Enable Bus Turn-around request<br>
> + */<br>
> +void dsi_bta_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(enable, ®->TA_EN);<br>
> +}<br>
> +/*<br>
> + * Enable EOTp reception<br>
> + */<br>
> +void dsi_eotp_rx_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xBC eotp_en;<br>
> +<br>
> + eotp_en.val = readl(®->EOTP_EN);<br>
> + eotp_en.bits.rx_eotp_en = enable;<br>
> +<br>
> + writel(eotp_en.val, ®->EOTP_EN);<br>
> +}<br>
> +/*<br>
> + * Enable EOTp transmission<br>
> + */<br>
> +void dsi_eotp_tx_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xBC eotp_en;<br>
> +<br>
> + eotp_en.val = readl(®->EOTP_EN);<br>
> + eotp_en.bits.tx_eotp_en = enable;<br>
> +<br>
> + writel(eotp_en.val, ®->EOTP_EN);<br>
> +}<br>
> +/*<br>
> + * Enable ECC reception, error correction and reporting<br>
> + */<br>
> +void dsi_ecc_rx_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xB4 rx_pkt_check_config;<br>
> +<br>
> + rx_pkt_check_config.val = readl(®->RX_PKT_CHECK_CONFIG);<br>
> + rx_pkt_check_config.bits.rx_pkt_ecc_en = enable;<br>
> +<br>
> + writel(rx_pkt_check_config.val, ®->RX_PKT_CHECK_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Enable CRC reception, error reporting<br>
> + */<br>
> +void dsi_crc_rx_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xB4 rx_pkt_check_config;<br>
> +<br>
> + rx_pkt_check_config.val = readl(®->RX_PKT_CHECK_CONFIG);<br>
> + rx_pkt_check_config.bits.rx_pkt_crc_en = enable;<br>
> +<br>
> + writel(rx_pkt_check_config.val, ®->RX_PKT_CHECK_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Get status of read command<br>
> + */<br>
> +bool dsi_is_bta_returned(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x98 cmd_mode_status;<br>
> +<br>
> + cmd_mode_status.val = readl(®->CMD_MODE_STATUS);<br>
> +<br>
> + return cmd_mode_status.bits.gen_cmd_rdcmd_done;<br>
> +}<br>
> +/*<br>
> + * Get the FULL status of generic read payload fifo<br>
> + */<br>
> +bool dsi_is_rx_payload_fifo_full(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x98 cmd_mode_status;<br>
> +<br>
> + cmd_mode_status.val = readl(®->CMD_MODE_STATUS);<br>
> +<br>
> + return cmd_mode_status.bits.gen_cmd_rdata_fifo_full;<br>
> +}<br>
> +/*<br>
> + * Get the EMPTY status of generic read payload fifo<br>
> + */<br>
> +bool dsi_is_rx_payload_fifo_empty(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x98 cmd_mode_status;<br>
> +<br>
> + cmd_mode_status.val = readl(®->CMD_MODE_STATUS);<br>
> +<br>
> + return cmd_mode_status.bits.gen_cmd_rdata_fifo_empty;<br>
> +}<br>
> +/*<br>
> + * Get the FULL status of generic write payload fifo<br>
> + */<br>
> +bool dsi_is_tx_payload_fifo_full(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x98 cmd_mode_status;<br>
> +<br>
> + cmd_mode_status.val = readl(®->CMD_MODE_STATUS);<br>
> +<br>
> + return cmd_mode_status.bits.gen_cmd_wdata_fifo_full;<br>
> +}<br>
> +/*<br>
> + * Get the EMPTY status of generic write payload fifo<br>
> + */<br>
> +bool dsi_is_tx_payload_fifo_empty(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x98 cmd_mode_status;<br>
> +<br>
> + cmd_mode_status.val = readl(®->CMD_MODE_STATUS);<br>
> +<br>
> + return cmd_mode_status.bits.gen_cmd_wdata_fifo_empty;<br>
> +}<br>
> +/*<br>
> + * Get the EMPTY status of generic command fifo<br>
> + */<br>
> +bool dsi_is_tx_cmd_fifo_empty(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x98 cmd_mode_status;<br>
> +<br>
> + cmd_mode_status.val = readl(®->CMD_MODE_STATUS);<br>
> +<br>
> + return cmd_mode_status.bits.gen_cmd_cmd_fifo_empty;<br>
> +}<br>
> +/*<br>
> + * DPI interface signal delay config<br>
> + * param byte_cycle period for waiting after controller receiving HSYNC from<br>
> + * DPI interface to start read pixel data from memory.<br>
> + */<br>
> +void dsi_dpi_sig_delay(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xD0 video_sig_delay_config;<br>
> +<br>
> + video_sig_delay_config.val = readl(®->VIDEO_SIG_DELAY_CONFIG);<br>
> + video_sig_delay_config.bits.video_sig_delay = byte_cycle;<br>
> +<br>
> + writel(video_sig_delay_config.val, ®->VIDEO_SIG_DELAY_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure how many cycles of byte clock would the PHY module take<br>
> + * to switch data lane from high speed to low power<br>
> + */<br>
> +void dsi_datalane_hs2lp_config(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xAC phy_datalane_time_config;<br>
> +<br>
> + phy_datalane_time_config.val = readl(®->PHY_DATALANE_TIME_CONFIG);<br>
> + phy_datalane_time_config.bits.phy_datalane_hs_to_lp_time = byte_cycle;<br>
> +<br>
> + writel(phy_datalane_time_config.val, ®->PHY_DATALANE_TIME_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure how many cycles of byte clock would the PHY module take<br>
> + * to switch the data lane from to low power high speed<br>
> + */<br>
> +void dsi_datalane_lp2hs_config(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xAC phy_datalane_time_config;<br>
> +<br>
> + phy_datalane_time_config.val = readl(®->PHY_DATALANE_TIME_CONFIG);<br>
> + phy_datalane_time_config.bits.phy_datalane_lp_to_hs_time = byte_cycle;<br>
> +<br>
> + writel(phy_datalane_time_config.val, ®->PHY_DATALANE_TIME_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure how many cycles of byte clock would the PHY module take<br>
> + * to switch clock lane from high speed to low power<br>
> + */<br>
> +void dsi_clklane_hs2lp_config(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xA8 phy_clklane_time_config;<br>
> +<br>
> + phy_clklane_time_config.val = readl(®->PHY_CLKLANE_TIME_CONFIG);<br>
> + phy_clklane_time_config.bits.phy_clklane_hs_to_lp_time = byte_cycle;<br>
> +<br>
> + writel(phy_clklane_time_config.val, ®->PHY_CLKLANE_TIME_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure how many cycles of byte clock would the PHY module take<br>
> + * to switch clock lane from to low power high speed<br>
> + */<br>
> +void dsi_clklane_lp2hs_config(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xA8 phy_clklane_time_config;<br>
> +<br>
> + phy_clklane_time_config.val = readl(®->PHY_CLKLANE_TIME_CONFIG);<br>
> + phy_clklane_time_config.bits.phy_clklane_lp_to_hs_time = byte_cycle;<br>
> +<br>
> + writel(phy_clklane_time_config.val, ®->PHY_CLKLANE_TIME_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure how many cycles of byte clock would the PHY module take<br>
> + * to turn the bus around to start receiving<br>
> + */<br>
> +void dsi_max_read_time(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(byte_cycle, ®->MAX_READ_TIME);<br>
> +}<br>
> +/*<br>
> + * Enable the automatic mechanism to stop providing clock in the clock<br>
> + * lane when time allows<br>
> + */<br>
> +void dsi_nc_clk_en(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x74 phy_clk_lane_lp_ctrl;<br>
> +<br>
> + phy_clk_lane_lp_ctrl.val = readl(®->PHY_CLK_LANE_LP_CTRL);<br>
> + phy_clk_lane_lp_ctrl.bits.auto_clklane_ctrl_en = enable;<br>
> +<br>
> + writel(phy_clk_lane_lp_ctrl.val, ®->PHY_CLK_LANE_LP_CTRL);<br>
> +}<br>
> +/*<br>
> + * Write transmission escape timeout<br>
> + * a safe guard so that the state machine would reset if transmission<br>
> + * takes too long<br>
> + */<br>
> +void dsi_tx_escape_division(struct dsi_context *ctx, u8 div)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(div, ®->TX_ESC_CLK_CONFIG);<br>
> +}<br>
> +/* <br>
> + * Configure timeout divisions (so they would have more clock ticks)<br>
> + * div no of hs cycles before transiting back to LP in<br>
> + * (lane_clk / div)<br>
> + */<br>
> +void dsi_timeout_clock_division(struct dsi_context *ctx, u8 div)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(div, ®->TIMEOUT_CNT_CLK_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure the Low power receive time out<br>
> + */<br>
> +void dsi_lp_rx_timeout(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(byte_cycle, ®->LRX_H_TO_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Configure a high speed transmission time out<br>
> + */<br>
> +void dsi_hs_tx_timeout(struct dsi_context *ctx, u16 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(byte_cycle, ®->HTX_TO_CONFIG);<br>
> +}<br>
> +/*<br>
> + * Get the error 0 interrupt register status<br>
> + */<br>
> +u32 dsi_int0_status(struct dsi_context *ctx)<br>
> +{<br>
> + struct sprd_dsi *dsi = container_of(ctx, struct sprd_dsi, ctx);<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x08 protocol_int_sts;<br>
> +<br>
> + protocol_int_sts.val = readl(®->PROTOCOL_INT_STS);<br>
> + writel(protocol_int_sts.val, ®->PROTOCOL_INT_CLR);<br>
> +<br>
> + if (protocol_int_sts.bits.dphy_errors_0)<br>
> + drm_err(dsi->drm, "dphy_err: escape entry error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.dphy_errors_1)<br>
> + drm_err(dsi->drm, "dphy_err: lp data transmission sync error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.dphy_errors_2)<br>
> + drm_err(dsi->drm, "dphy_err: control error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.dphy_errors_3)<br>
> + drm_err(dsi->drm, "dphy_err: LP0 contention error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.dphy_errors_4)<br>
> + drm_err(dsi->drm, "dphy_err: LP1 contention error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_0)<br>
> + drm_err(dsi->drm, "ack_err: SoT error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_1)<br>
> + drm_err(dsi->drm, "ack_err: SoT Sync error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_2)<br>
> + drm_err(dsi->drm, "ack_err: EoT Sync error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_3)<br>
> + drm_err(dsi->drm, "ack_err: Escape Mode Entry Command error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_4)<br>
> + drm_err(dsi->drm, "ack_err: LP Transmit Sync error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_5)<br>
> + drm_err(dsi->drm, "ack_err: Peripheral Timeout error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_6)<br>
> + drm_err(dsi->drm, "ack_err: False Control error\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_7)<br>
> + drm_err(dsi->drm, "ack_err: reserved (specific to device)\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_8)<br>
> + drm_err(dsi->drm, "ack_err: ECC error, single-bit (corrected)\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_9)<br>
> + drm_err(dsi->drm, "ack_err: ECC error, multi-bit (not corrected)\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_10)<br>
> + drm_err(dsi->drm, "ack_err: checksum error (long packet only)\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_11)<br>
> + drm_err(dsi->drm, "ack_err: not recognized DSI data type\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_12)<br>
> + drm_err(dsi->drm, "ack_err: DSI VC ID Invalid\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_13)<br>
> + drm_err(dsi->drm, "ack_err: invalid transmission length\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_14)<br>
> + drm_err(dsi->drm, "ack_err: reserved (specific to device)\n");<br>
> +<br>
> + if (protocol_int_sts.bits.ack_with_err_15)<br>
> + drm_err(dsi->drm, "ack_err: DSI protocol violation\n");<br>
> +<br>
> + return 0;<br>
> +}<br>
> +/*<br>
> + * Get the error 1 interrupt register status<br>
> + */<br>
> +u32 dsi_int1_status(struct dsi_context *ctx)<br>
> +{<br>
> + struct sprd_dsi *dsi = container_of(ctx, struct sprd_dsi, ctx);<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x10 internal_int_sts;<br>
> + u32 status = 0;<br>
> +<br>
> + internal_int_sts.val = readl(®->INTERNAL_INT_STS);<br>
> + writel(internal_int_sts.val, ®->INTERNAL_INT_CLR);<br>
> +<br>
> + if (internal_int_sts.bits.receive_pkt_size_err)<br>
> + drm_err(dsi->drm, "receive packet size error\n");<br>
> +<br>
> + if (internal_int_sts.bits.eotp_not_receive_err)<br>
> + drm_err(dsi->drm, "EoTp packet is not received\n");<br>
> +<br>
> + if (internal_int_sts.bits.gen_cmd_cmd_fifo_wr_err)<br>
> + drm_err(dsi->drm, "cmd header-fifo is full\n");<br>
> +<br>
> + if (internal_int_sts.bits.gen_cmd_rdata_fifo_rd_err)<br>
> + drm_err(dsi->drm, "cmd read-payload-fifo is empty\n");<br>
> +<br>
> + if (internal_int_sts.bits.gen_cmd_rdata_fifo_wr_err)<br>
> + drm_err(dsi->drm, "cmd read-payload-fifo is full\n");<br>
> +<br>
> + if (internal_int_sts.bits.gen_cmd_wdata_fifo_wr_err)<br>
> + drm_err(dsi->drm, "cmd write-payload-fifo is full\n");<br>
> +<br>
> + if (internal_int_sts.bits.gen_cmd_wdata_fifo_rd_err)<br>
> + drm_err(dsi->drm, "cmd write-payload-fifo is empty\n");<br>
> +<br>
> + if (internal_int_sts.bits.dpi_pix_fifo_wr_err) {<br>
> + drm_err(dsi->drm, "DPI pixel-fifo is full\n");<br>
> + status |= DSI_INT_STS_NEED_SOFT_RESET;<br>
> + }<br>
> +<br>
> + if (internal_int_sts.bits.ecc_single_err)<br>
> + drm_err(dsi->drm, "ECC single error in a received packet\n");<br>
> +<br>
> + if (internal_int_sts.bits.ecc_multi_err)<br>
> + drm_err(dsi->drm, "ECC multiple error in a received packet\n");<br>
> +<br>
> + if (internal_int_sts.bits.crc_err)<br>
> + drm_err(dsi->drm, "CRC error in the received packet payload\n");<br>
> +<br>
> + if (internal_int_sts.bits.hs_tx_timeout)<br>
> + drm_err(dsi->drm, "high-speed transmission timeout\n");<br>
> +<br>
> + if (internal_int_sts.bits.lp_rx_timeout)<br>
> + drm_err(dsi->drm, "low-power reception timeout\n");<br>
> +<br>
> + return status;<br>
> +}<br>
> +/*<br>
> + * Configure MASK (hiding) of interrupts coming from error 0 source<br>
> + */<br>
> +void dsi_int0_mask(struct dsi_context *ctx, u32 mask)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(mask, ®->MASK_PROTOCOL_INT);<br>
> +}<br>
> +/*<br>
> + * Configure MASK (hiding) of interrupts coming from error 1 source<br>
> + */<br>
> +void dsi_int1_mask(struct dsi_context *ctx, u32 mask)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(mask, ®->MASK_INTERNAL_INT);<br>
> +}<br>
> diff --git a/drivers/gpu/drm/sprd/dw_dsi_ctrl.h b/drivers/gpu/drm/sprd/dw_dsi_ctrl.h<br>
> new file mode 100644<br>
> index 000000000..ffba62130<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/dw_dsi_ctrl.h<br>
> @@ -0,0 +1,1475 @@<br>
> +/* SPDX-License-Identifier: GPL-2.0 */<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#ifndef _DW_DSI_CTRL_H_<br>
> +#define _DW_DSI_CTRL_H_<br>
> +<br>
> +#include <asm/types.h><br>
> +<br>
> +#include "sprd_dsi.h"<br>
> +<br>
> +struct dsi_reg {<br>
> + union _0x00 {<br>
> + u32 val;<br>
> + struct _DSI_VERSION {<br>
> + u32 dsi_version: 16;<br>
> + u32 reserved: 16;<br>
> + } bits;<br>
> + } DSI_VERSION;<br>
> +<br>
> + union _0x04 {<br>
> + u32 val;<br>
> + struct _SOFT_RESET {<br>
> + /*<br>
> + * This bit configures the core either to work normal or to<br>
> + * reset. It's default value is 0. After the core configur-<br>
> + * ation, to enable the mipi_dsi_host, set this register to 1.<br>
> + * 1: power up 0: reset core<br>
> + */<br>
> + u32 dsi_soft_reset: 1;<br>
> +<br>
> + u32 reserved: 31;<br>
> + } bits;<br>
> + } SOFT_RESET;<br>
> +<br>
> + union _0x08 {<br>
> + u32 val;<br>
> + struct _PROTOCOL_INT_STS {<br>
> + /* ErrEsc escape entry error from Lane 0 */<br>
> + u32 dphy_errors_0: 1;<br>
> +<br>
> + /* ErrSyncEsc low-power data transmission synchronization<br>
> + * error from Lane 0<br>
> + */<br>
> + u32 dphy_errors_1: 1;<br>
> +<br>
> + /* ErrControl error from Lane 0 */<br>
> + u32 dphy_errors_2: 1;<br>
> +<br>
> + /* ErrContentionLP0 LP0 contention error from Lane 0 */<br>
> + u32 dphy_errors_3: 1;<br>
> +<br>
> + /* ErrContentionLP1 LP1 contention error from Lane 0 */<br>
> + u32 dphy_errors_4: 1;<br>
> +<br>
> + /* debug mode protocol errors */<br>
> + u32 protocol_debug_err: 11;<br>
> +<br>
> + /* SoT error from the Acknowledge error report */<br>
> + u32 ack_with_err_0: 1;<br>
> +<br>
> + /* SoT Sync error from the Acknowledge error report */<br>
> + u32 ack_with_err_1: 1;<br>
> +<br>
> + /* EoT Sync error from the Acknowledge error report */<br>
> + u32 ack_with_err_2: 1;<br>
> +<br>
> + /* Escape Mode Entry Command error from the Acknowledge<br>
> + * error report<br>
> + */<br>
> + u32 ack_with_err_3: 1;<br>
> +<br>
> + /* LP Transmit Sync error from the Acknowledge error report */<br>
> + u32 ack_with_err_4: 1;<br>
> +<br>
> + /* Peripheral Timeout error from the Acknowledge error report */<br>
> + u32 ack_with_err_5: 1;<br>
> +<br>
> + /* False Control error from the Acknowledge error report */<br>
> + u32 ack_with_err_6: 1;<br>
> +<br>
> + /* reserved (specific to device) from the Acknowledge error<br>
> + * report<br>
> + */<br>
> + u32 ack_with_err_7: 1;<br>
> +<br>
> + /* ECC error, single-bit (detected and corrected) from the<br>
> + * Acknowledge error report<br>
> + */<br>
> + u32 ack_with_err_8: 1;<br>
> +<br>
> + /* ECC error, multi-bit (detected, not corrected) from the<br>
> + * Acknowledge error report<br>
> + */<br>
> + u32 ack_with_err_9: 1;<br>
> +<br>
> + /* checksum error (long packet only) from the Acknowledge<br>
> + * error report<br>
> + */<br>
> + u32 ack_with_err_10: 1;<br>
> +<br>
> + /* not recognized DSI data type from the Acknowledge error<br>
> + * report<br>
> + */<br>
> + u32 ack_with_err_11: 1;<br>
> +<br>
> + /* DSI VC ID Invalid from the Acknowledge error report */<br>
> + u32 ack_with_err_12: 1;<br>
> +<br>
> + /* invalid transmission length from the Acknowledge error<br>
> + * report<br>
> + */<br>
> + u32 ack_with_err_13: 1;<br>
> +<br>
> + /* reserved (specific to device) from the Acknowledge error<br>
> + * report<br>
> + */<br>
> + u32 ack_with_err_14: 1;<br>
> +<br>
> + /* DSI protocol violation from the Acknowledge error report */<br>
> + u32 ack_with_err_15: 1;<br>
> +<br>
> + } bits;<br>
> + } PROTOCOL_INT_STS;<br>
> +<br>
> + union _0x0C {<br>
> + u32 val;<br>
> + struct _MASK_PROTOCOL_INT {<br>
> + u32 mask_dphy_errors_0: 1;<br>
> + u32 mask_dphy_errors_1: 1;<br>
> + u32 mask_dphy_errors_2: 1;<br>
> + u32 mask_dphy_errors_3: 1;<br>
> + u32 mask_dphy_errors_4: 1;<br>
> + u32 mask_protocol_debug_err: 11;<br>
> + u32 mask_ack_with_err_0: 1;<br>
> + u32 mask_ack_with_err_1: 1;<br>
> + u32 mask_ack_with_err_2: 1;<br>
> + u32 mask_ack_with_err_3: 1;<br>
> + u32 mask_ack_with_err_4: 1;<br>
> + u32 mask_ack_with_err_5: 1;<br>
> + u32 mask_ack_with_err_6: 1;<br>
> + u32 mask_ack_with_err_7: 1;<br>
> + u32 mask_ack_with_err_8: 1;<br>
> + u32 mask_ack_with_err_9: 1;<br>
> + u32 mask_ack_with_err_10: 1;<br>
> + u32 mask_ack_with_err_11: 1;<br>
> + u32 mask_ack_with_err_12: 1;<br>
> + u32 mask_ack_with_err_13: 1;<br>
> + u32 mask_ack_with_err_14: 1;<br>
> + u32 mask_ack_with_err_15: 1;<br>
> + } bits;<br>
> + } MASK_PROTOCOL_INT;<br>
> +<br>
> + union _0x10 {<br>
> + u32 val;<br>
> + struct _INTERNAL_INT_STS {<br>
> + /* This bit indicates that the packet size error is detected<br>
> + * during the packet reception.<br>
> + */<br>
> + u32 receive_pkt_size_err: 1;<br>
> +<br>
> + /* This bit indicates that the EoTp packet is not received at<br>
> + * the end of the incoming peripheral transmission<br>
> + */<br>
> + u32 eotp_not_receive_err: 1;<br>
> +<br>
> + /* This bit indicates that the system tried to write a command<br>
> + * through the Generic interface and the FIFO is full. There-<br>
> + * fore, the command is not written.<br>
> + */<br>
> + u32 gen_cmd_cmd_fifo_wr_err: 1;<br>
> +<br>
> + /* This bit indicates that during a DCS read data, the payload<br>
> + * FIFO becomes empty and the data sent to the interface is<br>
> + * corrupted.<br>
> + */<br>
> + u32 gen_cmd_rdata_fifo_rd_err: 1;<br>
> +<br>
> + /* This bit indicates that during a generic interface packet<br>
> + * read back, the payload FIFO becomes full and the received<br>
> + * data is corrupted.<br>
> + */<br>
> + u32 gen_cmd_rdata_fifo_wr_err: 1;<br>
> +<br>
> + /* This bit indicates that the system tried to write a payload<br>
> + * data through the Generic interface and the FIFO is full.<br>
> + * Therefore, the payload is not written.<br>
> + */<br>
> + u32 gen_cmd_wdata_fifo_wr_err: 1;<br>
> +<br>
> + /* This bit indicates that during a Generic interface packet<br>
> + * build, the payload FIFO becomes empty and corrupt data is<br>
> + * sent.<br>
> + */<br>
> + u32 gen_cmd_wdata_fifo_rd_err: 1;<br>
> +<br>
> + /* This bit indicates that during a DPI pixel line storage,<br>
> + * the payload FIFO becomes full and the data stored is<br>
> + * corrupted.<br>
> + */<br>
> + u32 dpi_pix_fifo_wr_err: 1;<br>
> +<br>
> + /* internal debug error */<br>
> + u32 internal_debug_err: 19;<br>
> +<br>
> + /* This bit indicates that the ECC single error is detected<br>
> + * and corrected in a received packet.<br>
> + */<br>
> + u32 ecc_single_err: 1;<br>
> +<br>
> + /* This bit indicates that the ECC multiple error is detected<br>
> + * in a received packet.<br>
> + */<br>
> + u32 ecc_multi_err: 1;<br>
> +<br>
> + /* This bit indicates that the CRC error is detected in the<br>
> + * received packet payload.<br>
> + */<br>
> + u32 crc_err: 1;<br>
> +<br>
> + /* This bit indicates that the high-speed transmission timeout<br>
> + * counter reached the end and contention is detected.<br>
> + */<br>
> + u32 hs_tx_timeout: 1;<br>
> +<br>
> + /* This bit indicates that the low-power reception timeout<br>
> + * counter reached the end and contention is detected.<br>
> + */<br>
> + u32 lp_rx_timeout: 1;<br>
> +<br>
> + } bits;<br>
> + } INTERNAL_INT_STS;<br>
> +<br>
> + union _0x14 {<br>
> + u32 val;<br>
> + struct _MASK_INTERNAL_INT {<br>
> + u32 mask_receive_pkt_size_err: 1;<br>
> + u32 mask_eopt_not_receive_err: 1;<br>
> + u32 mask_gen_cmd_cmd_fifo_wr_err: 1;<br>
> + u32 mask_gen_cmd_rdata_fifo_rd_err: 1;<br>
> + u32 mask_gen_cmd_rdata_fifo_wr_err: 1;<br>
> + u32 mask_gen_cmd_wdata_fifo_wr_err: 1;<br>
> + u32 mask_gen_cmd_wdata_fifo_rd_err: 1;<br>
> + u32 mask_dpi_pix_fifo_wr_err: 1;<br>
> + u32 mask_internal_debug_err: 19;<br>
> + u32 mask_ecc_single_err: 1;<br>
> + u32 mask_ecc_multi_err: 1;<br>
> + u32 mask_crc_err: 1;<br>
> + u32 mask_hs_tx_timeout: 1;<br>
> + u32 mask_lp_rx_timeout: 1;<br>
> + } bits;<br>
> + } MASK_INTERNAL_INT;<br>
> +<br>
> + union _0x18 {<br>
> + u32 val;<br>
> + struct _DSI_MODE_CFG {<br>
> + /* This bit configures the operation mode<br>
> + * 0: Video mode ; 1: Command mode<br>
> + */<br>
> + u32 cmd_video_mode: 1;<br>
> +<br>
> + u32 reserved: 31;<br>
> +<br>
> + } bits;<br>
> + } DSI_MODE_CFG;<br>
> +<br>
> + union _0x1C {<br>
> + u32 val;<br>
> + struct _VIRTUAL_CHANNEL_ID {<br>
> + /* This field indicates the Generic interface read-back<br>
> + * virtual channel identification<br>
> + */<br>
> + u32 gen_rx_vcid: 2;<br>
> +<br>
> + /* This field configures the DPI virtual channel id that<br>
> + * is indexed to the VIDEO mode packets<br>
> + */<br>
> + u32 video_pkt_vcid: 2;<br>
> +<br>
> + u32 reserved: 28;<br>
> +<br>
> + } bits;<br>
> + } VIRTUAL_CHANNEL_ID;<br>
> +<br>
> + union _0x20 {<br>
> + u32 val;<br>
> + struct _DPI_VIDEO_FORMAT {<br>
> + /*<br>
> + * This field configures the DPI color coding as follows:<br>
> + * 0000: 16-bit configuration 1<br>
> + * 0001: 16-bit configuration 2<br>
> + * 0010: 16-bit configuration 3<br>
> + * 0011: 18-bit configuration 1<br>
> + * 0100: 18-bit configuration 2<br>
> + * 0101: 24-bit<br>
> + * 0110: 20-bit YCbCr 4:2:2 loosely packed<br>
> + * 0111: 24-bit YCbCr 4:2:2<br>
> + * 1000: 16-bit YCbCr 4:2:2<br>
> + * 1001: 30-bit<br>
> + * 1010: 36-bit<br>
> + * 1011: 12-bit YCbCr 4:2:0<br>
> + * 1100: Compression Display Stream<br>
> + * 1101-1111: 12-bit YCbCr 4:2:0<br>
> + */<br>
> + u32 dpi_video_mode_format: 6;<br>
> +<br>
> + /* When set to 1, this bit activates loosely packed<br>
> + * variant to 18-bit configurations<br>
> + */<br>
> + u32 loosely18_en: 1;<br>
> +<br>
> + u32 reserved: 25;<br>
> +<br>
> + } bits;<br>
> + } DPI_VIDEO_FORMAT;<br>
> +<br>
> + union _0x24 {<br>
> + u32 val;<br>
> + struct _VIDEO_PKT_CONFIG {<br>
> + /*<br>
> + * This field configures the number of pixels in a single<br>
> + * video packet. For 18-bit not loosely packed data types,<br>
> + * this number must be a multiple of 4. For YCbCr data<br>
> + * types, it must be a multiple of 2, as described in the<br>
> + * DSI specification.<br>
> + */<br>
> + u32 video_pkt_size: 16;<br>
> +<br>
> + /*<br>
> + * This register configures the number of chunks to be<br>
> + * transmitted during a Line period (a chunk consists of<br>
> + * a video packet and a null packet). If set to 0 or 1,<br>
> + * the video line is transmitted in a single packet. If<br>
> + * set to 1, the packet is part of a chunk, so a null packet<br>
> + * follows it if vid_null_size > 0. Otherwise, multiple chunks<br>
> + * are used to transmit each video line.<br>
> + */<br>
> + u32 video_line_chunk_num: 16;<br>
> +<br>
> + } bits;<br>
> + } VIDEO_PKT_CONFIG;<br>
> +<br>
> + union _0x28 {<br>
> + u32 val;<br>
> + struct _VIDEO_LINE_HBLK_TIME {<br>
> + /* This field configures the Horizontal Back Porch period<br>
> + * in lane byte clock cycles<br>
> + */<br>
> + u32 video_line_hbp_time: 16;<br>
> +<br>
> + /* This field configures the Horizontal Synchronism Active<br>
> + * period in lane byte clock cycles<br>
> + */<br>
> + u32 video_line_hsa_time: 16;<br>
> +<br>
> + } bits;<br>
> + } VIDEO_LINE_HBLK_TIME;<br>
> +<br>
> + union _0x2C {<br>
> + u32 val;<br>
> + struct _VIDEO_LINE_TIME {<br>
> + /* This field configures the size of the total line time<br>
> + * (HSA+HBP+HACT+HFP) counted in lane byte clock cycles<br>
> + */<br>
> + u32 video_line_time: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> +<br>
> + } bits;<br>
> + } VIDEO_LINE_TIME;<br>
> +<br>
> + union _0x30 {<br>
> + u32 val;<br>
> + struct _VIDEO_VBLK_LINES {<br>
> + /* This field configures the Vertical Front Porch period<br>
> + * measured in number of horizontal lines<br>
> + */<br>
> + u32 vfp_lines: 10;<br>
> +<br>
> + /* This field configures the Vertical Back Porch period<br>
> + * measured in number of horizontal lines<br>
> + */<br>
> + u32 vbp_lines: 10;<br>
> +<br>
> + /* This field configures the Vertical Synchronism Active<br>
> + * period measured in number of horizontal lines<br>
> + */<br>
> + u32 vsa_lines: 10;<br>
> +<br>
> + u32 reserved: 2;<br>
> +<br>
> + } bits;<br>
> + } VIDEO_VBLK_LINES;<br>
> +<br>
> + union _0x34 {<br>
> + u32 val;<br>
> + struct _VIDEO_VACTIVE_LINES {<br>
> + /* This field configures the Vertical Active period measured<br>
> + * in number of horizontal lines<br>
> + */<br>
> + u32 vactive_lines: 14;<br>
> +<br>
> + u32 reserved: 18;<br>
> +<br>
> + } bits;<br>
> + } VIDEO_VACTIVE_LINES;<br>
> +<br>
> + union _0x38 {<br>
> + u32 val;<br>
> + struct _VID_MODE_CFG {<br>
> + /*<br>
> + * This field indicates the video mode transmission type as<br>
> + * follows:<br>
> + * 00: Non-burst with sync pulses<br>
> + * 01: Non-burst with sync events<br>
> + * 10 and 11: Burst mode<br>
> + */<br>
> + u32 vid_mode_type: 2;<br>
> +<br>
> + u32 reserved_0: 6;<br>
> +<br>
> + /* When set to 1, this bit enables the return to low-power<br>
> + * inside the VSA period when timing allows.<br>
> + */<br>
> + u32 lp_vsa_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the return to low-power<br>
> + * inside the VBP period when timing allows.<br>
> + */<br>
> + u32 lp_vbp_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the return to low-power<br>
> + * inside the VFP period when timing allows.<br>
> + */<br>
> + u32 lp_vfp_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the return to low-power<br>
> + * inside the VACT period when timing allows.<br>
> + */<br>
> + u32 lp_vact_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the return to low-power<br>
> + * inside the HBP period when timing allows.<br>
> + */<br>
> + u32 lp_hbp_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the return to low-power<br>
> + * inside the HFP period when timing allows.<br>
> + */<br>
> + u32 lp_hfp_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the request for an ack-<br>
> + * nowledge response at the end of a frame.<br>
> + */<br>
> + u32 frame_bta_ack_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the command transmission<br>
> + * only in low-power mode.<br>
> + */<br>
> + u32 lp_cmd_en: 1;<br>
> +<br>
> + u32 reserved_1: 16;<br>
> +<br>
> + } bits;<br>
> + } VID_MODE_CFG;<br>
> +<br>
> + union _0x3C {<br>
> + u32 val;<br>
> + struct _SDF_MODE_CONFIG {<br>
> + /*<br>
> + * This field defines the 3D mode on/off & display orientation:<br>
> + * 00: 3D mode off (2D mode on)<br>
> + * 01: 3D mode on, portrait orientation<br>
> + * 10: 3D mode on, landscape orientation<br>
> + * 11: Reserved<br>
> + */<br>
> + u32 rf_3d_mode: 2;<br>
> +<br>
> + /*<br>
> + * This field defines the 3D image format:<br>
> + * 00: Line (alternating lines of left and right data)<br>
> + * 01: Frame (alternating frames of left and right data)<br>
> + * 10: Pixel (alternating pixels of left and right data)<br>
> + * 11: Reserved<br>
> + */<br>
> + u32 rf_3d_format: 2;<br>
> +<br>
> + /*<br>
> + * This field defines whether there is a second VSYNC pulse<br>
> + * between Left and Right Images, when 3D Image Format is<br>
> + * Frame-based:<br>
> + * 0: No sync pulses between left and right data<br>
> + * 1: Sync pulse (HSYNC, VSYNC, blanking) between left and<br>
> + * right data<br>
> + */<br>
> + u32 second_vsync_en: 1;<br>
> +<br>
> + /*<br>
> + * This bit defines the left or right order:<br>
> + * 0: Left eye data is sent first, and then the right eye data<br>
> + * is sent.<br>
> + * 1: Right eye data is sent first, and then the left eye data<br>
> + * is sent.<br>
> + */<br>
> + u32 left_right_order: 1;<br>
> +<br>
> + u32 reserved_0: 2;<br>
> +<br>
> + /*<br>
> + * When set, causes the next VSS packet to include 3D control<br>
> + * payload in every VSS packet.<br>
> + */<br>
> + u32 rf_3d_payload_en: 1;<br>
> +<br>
> + u32 reserved_1: 23;<br>
> +<br>
> + } bits;<br>
> + } SDF_MODE_CONFIG;<br>
> +<br>
> + union _0x40 {<br>
> + u32 val;<br>
> + struct _TIMEOUT_CNT_CLK_CONFIG {<br>
> + /*<br>
> + * This field indicates the division factor for the Time Out<br>
> + * clock used as the timing unit in the configuration of HS to<br>
> + * LP and LP to HS transition error.<br>
> + */<br>
> + u32 timeout_cnt_clk_config: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> +<br>
> + } bits;<br>
> + } TIMEOUT_CNT_CLK_CONFIG;<br>
> +<br>
> + union _0x44 {<br>
> + u32 val;<br>
> + struct _HTX_TO_CONFIG {<br>
> + /*<br>
> + * This field configures the timeout counter that triggers<br>
> + * a high speed transmission timeout contention detection<br>
> + * (measured in TO_CLK_DIVISION cycles).<br>
> + *<br>
> + * If using the non-burst mode and there is no sufficient<br>
> + * time to switch from HS to LP and back in the period which<br>
> + * is from one line data finishing to the next line sync<br>
> + * start, the DSI link returns the LP state once per frame,<br>
> + * then you should configure the TO_CLK_DIVISION and<br>
> + * hstx_to_cnt to be in accordance with:<br>
> + * hstx_to_cnt * lanebyteclkperiod * TO_CLK_DIVISION >= the<br>
> + * time of one FRAME data transmission * (1 + 10%)<br>
> + *<br>
> + * In burst mode, RGB pixel packets are time-compressed,<br>
> + * leaving more time during a scan line. Therefore, if in<br>
> + * burst mode and there is sufficient time to switch from HS<br>
> + * to LP and back in the period of time from one line data<br>
> + * finishing to the next line sync start, the DSI link can<br>
> + * return LP mode and back in this time interval to save power.<br>
> + * For this, configure the TO_CLK_DIVISION and hstx_to_cnt<br>
> + * to be in accordance with:<br>
> + * hstx_to_cnt * lanebyteclkperiod * TO_CLK_DIVISION >= the<br>
> + * time of one LINE data transmission * (1 + 10%)<br>
> + */<br>
> + u32 htx_to_cnt_limit: 32;<br>
> + } bits;<br>
> + } HTX_TO_CONFIG;<br>
> +<br>
> + union _0x48 {<br>
> + u32 val;<br>
> + struct _LRX_H_TO_CONFIG {<br>
> + /*<br>
> + * This field configures the timeout counter that triggers<br>
> + * a low-power reception timeout contention detection (measured<br>
> + * in TO_CLK_DIVISION cycles).<br>
> + */<br>
> + u32 lrx_h_to_cnt_limit: 32;<br>
> + } bits;<br>
> + } LRX_H_TO_CONFIG;<br>
> +<br>
> + union _0x4C {<br>
> + u32 val;<br>
> + struct _RD_PRESP_TO_CONFIG {<br>
> + /*<br>
> + * This field sets a period for which the DWC_mipi_dsi_host<br>
> + * keeps the link still, after sending a low-power read oper-<br>
> + * ation. This period is measured in cycles of lanebyteclk.<br>
> + * The counting starts when the D-PHY enters the Stop state<br>
> + * and causes no interrupts.<br>
> + */<br>
> + u32 lprd_presp_to_cnt_limit: 16;<br>
> +<br>
> + /*<br>
> + * This field sets a period for which the DWC_mipi_dsi_host<br>
> + * keeps the link still, after sending a high-speed read oper-<br>
> + * ation. This period is measured in cycles of lanebyteclk.<br>
> + * The counting starts when the D-PHY enters the Stop state<br>
> + * and causes no interrupts.<br>
> + */<br>
> + u32 hsrd_presp_to_cnt_limit: 16;<br>
> +<br>
> + } bits;<br>
> + } RD_PRESP_TO_CONFIG;<br>
> +<br>
> + union _0x50 {<br>
> + u32 val;<br>
> + struct _HSWR_PRESP_TO_CONFIG {<br>
> + /*<br>
> + * This field sets a period for which the DWC_mipi_dsi_host<br>
> + * keeps the link inactive after sending a high-speed write<br>
> + * operation. This period is measured in cycles of lanebyteclk.<br>
> + * The counting starts when the D-PHY enters the Stop state<br>
> + * and causes no interrupts.<br>
> + */<br>
> + u32 hswr_presp_to_cnt_limit: 16;<br>
> +<br>
> + u32 reserved_0: 8;<br>
> +<br>
> + /*<br>
> + * When set to 1, this bit ensures that the peripheral response<br>
> + * timeout caused by hs_wr_to_cnt is used only once per eDPI<br>
> + * frame, when both the following conditions are met:<br>
> + * dpivsync_edpiwms has risen and fallen.<br>
> + * Packets originated from eDPI have been transmitted and its<br>
> + * FIFO is empty again In this scenario no non-eDPI requests<br>
> + * are sent to the D-PHY, even if there is traffic from generic<br>
> + * or DBI ready to be sent, making it return to stop state.<br>
> + * When it does so, PRESP_TO counter is activated and only when<br>
> + * it finishes does the controller send any other traffic that<br>
> + * is ready.<br>
> + */<br>
> + u32 hswr_presp_to_mode: 1;<br>
> +<br>
> + u32 reserved_1: 7;<br>
> +<br>
> + } bits;<br>
> + } HSWR_PRESP_TO_CONFIG;<br>
> +<br>
> + union _0x54 {<br>
> + u32 val;<br>
> + struct _LPWR_PRESP_TO_CONFIG {<br>
> + /*<br>
> + * This field sets a period for which the DWC_mipi_dsi_host<br>
> + * keeps the link still, after sending a low-power write oper-<br>
> + * ation. This period is measured in cycles of lanebyteclk.<br>
> + * The counting starts when the D-PHY enters the Stop state<br>
> + * and causes no interrupts.<br>
> + */<br>
> + u32 lpwr_presp_to_cnt_limit: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> +<br>
> + } bits;<br>
> + } LPWR_PRESP_TO_CONFIG;<br>
> +<br>
> + union _0x58 {<br>
> + u32 val;<br>
> + struct _BTA_PRESP_TO_CONFIG {<br>
> + /*<br>
> + * This field sets a period for which the DWC_mipi_dsi_host<br>
> + * keeps the link still, after completing a Bus Turn-Around.<br>
> + * This period is measured in cycles of lanebyteclk. The<br>
> + * counting starts when the D-PHY enters the Stop state and<br>
> + * causes no interrupts.<br>
> + */<br>
> + u32 bta_presp_to_cnt_limit: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> +<br>
> + } bits;<br>
> + } BTA_PRESP_TO_CONFIG;<br>
> +<br>
> + union _0x5C {<br>
> + u32 val;<br>
> + struct _TX_ESC_CLK_CONFIG {<br>
> + /*<br>
> + * This field indicates the division factor for the TX Escape<br>
> + * clock source (lanebyteclk). The values 0 and 1 stop the<br>
> + * TX_ESC clock generation.<br>
> + */<br>
> + u32 tx_esc_clk_config: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> +<br>
> + } bits;<br>
> + } TX_ESC_CLK_CONFIG;<br>
> +<br>
> + union _0x60 {<br>
> + u32 val;<br>
> + struct _VACT_CMD_TRANS_LIMIT {<br>
> + /*<br>
> + * This field is used for the transmission of commands in<br>
> + * low-power mode. It defines the size, in bytes, of the<br>
> + * largest packet that can fit in a line during the VACT<br>
> + * region.<br>
> + */<br>
> + u32 vact_cmd_trans_limit: 8;<br>
> +<br>
> + u32 reserved: 24;<br>
> +<br>
> + } bits;<br>
> + } VACT_CMD_TRANS_LIMIT;<br>
> +<br>
> + union _0x64 {<br>
> + u32 val;<br>
> + struct _VBLK_CMD_TRANS_LIMIT {<br>
> + /*<br>
> + * This field is used for the transmission of commands in<br>
> + * low-power mode. It defines the size, in bytes, of the<br>
> + * largest packet that can fit in a line during the VSA, VBP,<br>
> + * and VFP regions.<br>
> + */<br>
> + u32 vblk_cmd_trans_limit: 8;<br>
> +<br>
> + u32 reserved: 24;<br>
> +<br>
> + } bits;<br>
> + } VBLK_CMD_TRANS_LIMIT;<br>
> +<br>
> + union _0x68 {<br>
> + u32 val;<br>
> + struct _CMD_MODE_CFG {<br>
> + /*<br>
> + * When set to 1, this bit enables the tearing effect<br>
> + * acknowledge request.<br>
> + */<br>
> + u32 tear_fx_en: 1;<br>
> +<br>
> + /*<br>
> + * When set to 1, this bit enables the acknowledge request<br>
> + * after each packet transmission.<br>
> + */<br>
> + u32 ack_rqst_en: 1;<br>
> +<br>
> + u32 reserved_0: 3;<br>
> +<br>
> + u32 pps_tx: 1;<br>
> + u32 exq_tx: 1;<br>
> + u32 cmc_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic short write packet with<br>
> + * zero parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_sw_0p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic short write packet with<br>
> + * one parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_sw_1p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic short write packet with<br>
> + * two parameters command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_sw_2p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic short read packet with<br>
> + * zero parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_sr_0p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic short read packet with<br>
> + * one parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_sr_1p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic short read packet with<br>
> + * two parameters command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_sr_2p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the Generic long write packet command<br>
> + * transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 gen_lw_tx: 1;<br>
> +<br>
> + u32 reserved_1: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the DCS short write packet with zero<br>
> + * parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 dcs_sw_0p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the DCS short write packet with one<br>
> + * parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 dcs_sw_1p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the DCS short read packet with zero<br>
> + * parameter command transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 dcs_sr_0p_tx: 1;<br>
> +<br>
> + /*<br>
> + * This bit configures the DCS long write packet command<br>
> + * transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 dcs_lw_tx: 1;<br>
> +<br>
> + u32 reserved_2: 4;<br>
> +<br>
> + /*<br>
> + * This bit configures the maximum read packet size command<br>
> + * transmission type:<br>
> + * 0: High-speed 1: Low-power<br>
> + */<br>
> + u32 max_rd_pkt_size: 1;<br>
> +<br>
> + u32 reserved_3: 7;<br>
> +<br>
> + } bits;<br>
> + } CMD_MODE_CFG;<br>
> +<br>
> + union _0x6C {<br>
> + u32 val;<br>
> + struct _GEN_HDR {<br>
> + /*<br>
> + * This field configures the packet data type of the header<br>
> + * packet.<br>
> + */<br>
> + u32 gen_dt: 6;<br>
> +<br>
> + /*<br>
> + * This field configures the virtual channel id of the header<br>
> + * packet.<br>
> + */<br>
> + u32 gen_vc: 2;<br>
> +<br>
> + /*<br>
> + * This field configures the least significant byte of the<br>
> + * header packet's Word count for long packets or data 0 for<br>
> + * short packets.<br>
> + */<br>
> + u32 gen_wc_lsbyte: 8;<br>
> +<br>
> + /*<br>
> + * This field configures the most significant byte of the<br>
> + * header packet's word count for long packets or data 1 for<br>
> + * short packets.<br>
> + */<br>
> + u32 gen_wc_msbyte: 8;<br>
> +<br>
> + u32 reserved: 8;<br>
> +<br>
> + } bits;<br>
> + } GEN_HDR;<br>
> +<br>
> + union _0x70 {<br>
> + u32 val;<br>
> + struct _GEN_PLD_DATA {<br>
> + /* This field indicates byte 1 of the packet payload. */<br>
> + u32 gen_pld_b1: 8;<br>
> +<br>
> + /* This field indicates byte 2 of the packet payload. */<br>
> + u32 gen_pld_b2: 8;<br>
> +<br>
> + /* This field indicates byte 3 of the packet payload. */<br>
> + u32 gen_pld_b3: 8;<br>
> +<br>
> + /* This field indicates byte 4 of the packet payload. */<br>
> + u32 gen_pld_b4: 8;<br>
> +<br>
> + } bits;<br>
> + } GEN_PLD_DATA;<br>
> +<br>
> + union _0x74 {<br>
> + u32 val;<br>
> + struct _PHY_CLK_LANE_LP_CTRL {<br>
> + /* This bit controls the D-PHY PPI txrequestclkhs signal */<br>
> + u32 phy_clklane_tx_req_hs: 1;<br>
> +<br>
> + /* This bit enables the automatic mechanism to stop providing<br>
> + * clock in the clock lane when time allows.<br>
> + */<br>
> + u32 auto_clklane_ctrl_en: 1;<br>
> +<br>
> + u32 reserved: 30;<br>
> + } bits;<br>
> + } PHY_CLK_LANE_LP_CTRL;<br>
> +<br>
> + union _0x78 {<br>
> + u32 val;<br>
> + struct _PHY_INTERFACE_CTRL {<br>
> + /* When set to 0, this bit places the D-PHY macro in power-<br>
> + * down state.<br>
> + */<br>
> + u32 rf_phy_shutdown: 1;<br>
> +<br>
> + /* When set to 0, this bit places the digital section of the<br>
> + * D-PHY in the reset state.<br>
> + */<br>
> + u32 rf_phy_reset_n: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the D-PHY Clock Lane<br>
> + * module.<br>
> + */<br>
> + u32 rf_phy_clk_en: 1;<br>
> +<br>
> + /* When the D-PHY is in ULPS, this bit enables the D-PHY PLL. */<br>
> + u32 rf_phy_force_pll: 1;<br>
> +<br>
> + /* ULPS mode Request on clock lane */<br>
> + u32 rf_phy_clk_txrequlps: 1;<br>
> +<br>
> + /* ULPS mode Exit on clock lane */<br>
> + u32 rf_phy_clk_txexitulps: 1;<br>
> +<br>
> + /* ULPS mode Request on all active data lanes */<br>
> + u32 rf_phy_data_txrequlps: 1;<br>
> +<br>
> + /* ULPS mode Exit on all active data lanes */<br>
> + u32 rf_phy_data_txexitulps: 1;<br>
> +<br>
> + u32 reserved: 24;<br>
> + } bits;<br>
> + } PHY_INTERFACE_CTRL;<br>
> +<br>
> + union _0x7C {<br>
> + u32 val;<br>
> + struct _PHY_TX_TRIGGERS {<br>
> + /* This field controls the trigger transmissions. */<br>
> + u32 phy_tx_triggers: 4;<br>
> +<br>
> + u32 reserved: 28;<br>
> + } bits;<br>
> + } PHY_TX_TRIGGERS;<br>
> +<br>
> + union _0x80 {<br>
> + u32 val;<br>
> + struct _DESKEW_START {<br>
> + u32 deskew_start: 1;<br>
> + u32 reserved: 31;<br>
> + } bits;<br>
> + } DESKEW_START;<br>
> +<br>
> + union _0x84 {<br>
> + u32 val;<br>
> + struct _DESKEW_MODE {<br>
> + u32 deskew_mode: 2;<br>
> + u32 reserved: 30;<br>
> + } bits;<br>
> + } DESKEW_MODE;<br>
> +<br>
> + union _0x88 {<br>
> + u32 val;<br>
> + struct _DESKEW_TIME {<br>
> + u32 deskew_time: 32;<br>
> + } bits;<br>
> + } DESKEW_TIME;<br>
> +<br>
> + union _0x8C {<br>
> + u32 val;<br>
> + struct _DESKEW_PERIOD {<br>
> + u32 deskew_period: 32;<br>
> + } bits;<br>
> + } DESKEW_PERIOD;<br>
> +<br>
> + union _0x90 {<br>
> + u32 val;<br>
> + struct _DESKEW_BUSY {<br>
> + u32 deskew_busy: 1;<br>
> + u32 reserved: 31;<br>
> + } bits;<br>
> + } DESKEW_BUSY;<br>
> +<br>
> + union _0x94 {<br>
> + u32 val;<br>
> + struct _DESKEW_LANE_MASK {<br>
> + u32 deskew_lane0_mask: 1;<br>
> + u32 deskew_lane1_mask: 1;<br>
> + u32 deskew_lane2_mask: 1;<br>
> + u32 deskew_lane3_mask: 1;<br>
> + u32 reserved: 28;<br>
> + } bits;<br>
> + } DESKEW_LANE_MASK;<br>
> +<br>
> + union _0x98 {<br>
> + u32 val;<br>
> + struct _CMD_MODE_STATUS {<br>
> + /*<br>
> + * This bit is set when a read command is issued and cleared<br>
> + * when the entire response is stored in the FIFO.<br>
> + * Value after reset: 0x0<br>
> + *<br>
> + * NOTE:<br>
> + * For mipi-dsi-r1p0 IP, this bit is set immediately when<br>
> + * the read cmd is set to the GEN_HDR register.<br>
> + *<br>
> + * For dsi-ctrl-r1p0 IP, this bit is set only after the read<br>
> + * cmd was actually sent out from the controller.<br>
> + */<br>
> + u32 gen_cmd_rdcmd_ongoing: 1;<br>
> +<br>
> + /*<br>
> + * This bit indicates the empty status of the generic read<br>
> + * payload FIFO.<br>
> + * Value after reset: 0x1<br>
> + */<br>
> + u32 gen_cmd_rdata_fifo_empty: 1;<br>
> +<br>
> + /*<br>
> + * This bit indicates the full status of the generic read<br>
> + * payload FIFO.<br>
> + * Value after reset: 0x0<br>
> + */<br>
> + u32 gen_cmd_rdata_fifo_full: 1;<br>
> +<br>
> + /*<br>
> + * This bit indicates the empty status of the generic write<br>
> + * payload FIFO.<br>
> + * Value after reset: 0x1<br>
> + */<br>
> + u32 gen_cmd_wdata_fifo_empty: 1;<br>
> +<br>
> + /*<br>
> + * This bit indicates the full status of the generic write<br>
> + * payload FIFO.<br>
> + * Value after reset: 0x0<br>
> + */<br>
> + u32 gen_cmd_wdata_fifo_full: 1;<br>
> +<br>
> + /*<br>
> + * This bit indicates the empty status of the generic<br>
> + * command FIFO.<br>
> + * Value after reset: 0x1<br>
> + */<br>
> + u32 gen_cmd_cmd_fifo_empty: 1;<br>
> +<br>
> + /*<br>
> + * This bit indicates the full status of the generic<br>
> + * command FIFO.<br>
> + * Value after reset: 0x0<br>
> + */<br>
> + u32 gen_cmd_cmd_fifo_full: 1;<br>
> +<br>
> + /*<br>
> + * This bit is set when the entire response of read is<br>
> + * stored in the rx payload FIFO. And it will be cleared<br>
> + * automaticlly after read this bit each time.<br>
> + * Value after reset: 0x0<br>
> + *<br>
> + * NOTE: this bit is just supported for dsi-ctrl-r1p0 IP<br>
> + */<br>
> + u32 gen_cmd_rdcmd_done: 1;<br>
> +<br>
> + u32 reserved : 24;<br>
> +<br>
> + } bits;<br>
> + } CMD_MODE_STATUS;<br>
> +<br>
> + union _0x9C {<br>
> + u32 val;<br>
> + struct _PHY_STATUS {<br>
> + /* the status of phydirection D-PHY signal */<br>
> + u32 phy_direction: 1;<br>
> +<br>
> + /* the status of phylock D-PHY signal */<br>
> + u32 phy_lock: 1;<br>
> +<br>
> + /* the status of rxulpsesc0lane D-PHY signal */<br>
> + u32 phy_rxulpsesc0lane: 1;<br>
> +<br>
> + /* the status of phystopstateclklane D-PHY signal */<br>
> + u32 phy_stopstateclklane: 1;<br>
> +<br>
> + /* the status of phystopstate0lane D-PHY signal */<br>
> + u32 phy_stopstate0lane: 1;<br>
> +<br>
> + /* the status of phystopstate1lane D-PHY signal */<br>
> + u32 phy_stopstate1lane: 1;<br>
> +<br>
> + /* the status of phystopstate2lane D-PHY signal */<br>
> + u32 phy_stopstate2lane: 1;<br>
> +<br>
> + /* the status of phystopstate3lane D-PHY signal */<br>
> + u32 phy_stopstate3lane: 1;<br>
> +<br>
> + /* the status of phyulpsactivenotclk D-PHY signal */<br>
> + u32 phy_ulpsactivenotclk: 1;<br>
> +<br>
> + /* the status of ulpsactivenot0lane D-PHY signal */<br>
> + u32 phy_ulpsactivenot0lane: 1;<br>
> +<br>
> + /* the status of ulpsactivenot1lane D-PHY signal */<br>
> + u32 phy_ulpsactivenot1lane: 1;<br>
> +<br>
> + /* the status of ulpsactivenot2lane D-PHY signal */<br>
> + u32 phy_ulpsactivenot2lane: 1;<br>
> +<br>
> + /* the status of ulpsactivenot3lane D-PHY signal */<br>
> + u32 phy_ulpsactivenot3lane: 1;<br>
> +<br>
> + u32 reserved: 19;<br>
> +<br>
> + } bits;<br>
> + } PHY_STATUS;<br>
> +<br>
> + union _0xA0 {<br>
> + u32 val;<br>
> + struct _PHY_MIN_STOP_TIME {<br>
> + /* This field configures the minimum wait period to request<br>
> + * a high-speed transmission after the Stop state.<br>
> + */<br>
> + u32 phy_min_stop_time: 8;<br>
> +<br>
> + u32 reserved: 24;<br>
> + } bits;<br>
> + } PHY_MIN_STOP_TIME;<br>
> +<br>
> + union _0xA4 {<br>
> + u32 val;<br>
> + struct _PHY_LANE_NUM_CONFIG {<br>
> + /*<br>
> + * This field configures the number of active data lanes:<br>
> + * 00: One data lane (lane 0)<br>
> + * 01: Two data lanes (lanes 0 and 1)<br>
> + * 10: Three data lanes (lanes 0, 1, and 2)<br>
> + * 11: Four data lanes (lanes 0, 1, 2, and 3)<br>
> + */<br>
> + u32 phy_lane_num: 2;<br>
> +<br>
> + u32 reserved: 30;<br>
> +<br>
> + } bits;<br>
> + } PHY_LANE_NUM_CONFIG;<br>
> +<br>
> + union _0xA8 {<br>
> + u32 val;<br>
> + struct _PHY_CLKLANE_TIME_CONFIG {<br>
> + /*<br>
> + * This field configures the maximum time that the D-PHY<br>
> + * clock lane takes to go from low-power to high-speed<br>
> + * transmission measured in lane byte clock cycles.<br>
> + */<br>
> + u32 phy_clklane_lp_to_hs_time: 16;<br>
> +<br>
> + /*<br>
> + * This field configures the maximum time that the D-PHY<br>
> + * clock lane takes to go from high-speed to low-power<br>
> + * transmission measured in lane byte clock cycles.<br>
> + */<br>
> + u32 phy_clklane_hs_to_lp_time: 16;<br>
> +<br>
> + } bits;<br>
> + } PHY_CLKLANE_TIME_CONFIG;<br>
> +<br>
> + union _0xAC {<br>
> + u32 val;<br>
> + struct _PHY_DATALANE_TIME_CONFIG {<br>
> + /*<br>
> + * This field configures the maximum time that the D-PHY data<br>
> + * lanes take to go from low-power to high-speed transmission<br>
> + * measured in lane byte clock cycles.<br>
> + */<br>
> + u32 phy_datalane_lp_to_hs_time: 16;<br>
> +<br>
> + /*<br>
> + * This field configures the maximum time that the D-PHY data<br>
> + * lanes take to go from high-speed to low-power transmission<br>
> + * measured in lane byte clock cycles.<br>
> + */<br>
> + u32 phy_datalane_hs_to_lp_time: 16;<br>
> +<br>
> + } bits;<br>
> + } PHY_DATALANE_TIME_CONFIG;<br>
> +<br>
> + union _0xB0 {<br>
> + u32 val;<br>
> + struct _MAX_READ_TIME {<br>
> + /*<br>
> + * This field configures the maximum time required to perform<br>
> + * a read command in lane byte clock cycles. This register can<br>
> + * only be modified when no read command is in progress.<br>
> + */<br>
> + u32 max_rd_time: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> +<br>
> + } bits;<br>
> + } MAX_READ_TIME;<br>
> +<br>
> + union _0xB4 {<br>
> + u32 val;<br>
> + struct _RX_PKT_CHECK_CONFIG {<br>
> + /* When set to 1, this bit enables the ECC reception, error<br>
> + * correction, and reporting.<br>
> + */<br>
> + u32 rx_pkt_ecc_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the CRC reception and error<br>
> + * reporting.<br>
> + */<br>
> + u32 rx_pkt_crc_en: 1;<br>
> +<br>
> + u32 reserved: 30;<br>
> +<br>
> + } bits;<br>
> + } RX_PKT_CHECK_CONFIG;<br>
> +<br>
> + union _0xB8 {<br>
> + u32 val;<br>
> + struct _TA_EN {<br>
> + /* When set to 1, this bit enables the Bus Turn-Around (BTA)<br>
> + * request.<br>
> + */<br>
> + u32 ta_en: 1;<br>
> +<br>
> + u32 reserved: 31;<br>
> +<br>
> + } bits;<br>
> + } TA_EN;<br>
> +<br>
> + union _0xBC {<br>
> + u32 val;<br>
> + struct _EOTP_EN {<br>
> + /* When set to 1, this bit enables the EoTp transmission */<br>
> + u32 tx_eotp_en: 1;<br>
> +<br>
> + /* When set to 1, this bit enables the EoTp reception. */<br>
> + u32 rx_eotp_en: 1;<br>
> +<br>
> + u32 reserved: 30;<br>
> +<br>
> + } bits;<br>
> + } EOTP_EN;<br>
> +<br>
> + union _0xC0 {<br>
> + u32 val;<br>
> + struct _VIDEO_NULLPKT_SIZE {<br>
> + /*<br>
> + * This register configures the number of bytes inside a null<br>
> + * packet. Setting it to 0 disables the null packets.<br>
> + */<br>
> + u32 video_nullpkt_size: 13;<br>
> +<br>
> + u32 reserved: 19;<br>
> +<br>
> + } bits;<br>
> + } VIDEO_NULLPKT_SIZE;<br>
> +<br>
> + union _0xC4 {<br>
> + u32 val;<br>
> + struct _DCS_WM_PKT_SIZE {<br>
> + /*<br>
> + * This field configures the maximum allowed size for an eDPI<br>
> + * write memory command, measured in pixels. Automatic parti-<br>
> + * tioning of data obtained from eDPI is permanently enabled.<br>
> + */<br>
> + u32 dcs_wm_pkt_size: 16;<br>
> +<br>
> + u32 reserved: 16;<br>
> + } bits;<br>
> + } DCS_WM_PKT_SIZE;<br>
> +<br>
> + union _0xC8 {<br>
> + u32 val;<br>
> + struct _PROTOCOL_INT_CLR {<br>
> + u32 clr_dphy_errors_0: 1;<br>
> + u32 clr_dphy_errors_1: 1;<br>
> + u32 clr_dphy_errors_2: 1;<br>
> + u32 clr_dphy_errors_3: 1;<br>
> + u32 clr_dphy_errors_4: 1;<br>
> + u32 clr_protocol_debug_err: 11;<br>
> + u32 clr_ack_with_err_0: 1;<br>
> + u32 clr_ack_with_err_1: 1;<br>
> + u32 clr_ack_with_err_2: 1;<br>
> + u32 clr_ack_with_err_3: 1;<br>
> + u32 clr_ack_with_err_4: 1;<br>
> + u32 clr_ack_with_err_5: 1;<br>
> + u32 clr_ack_with_err_6: 1;<br>
> + u32 clr_ack_with_err_7: 1;<br>
> + u32 clr_ack_with_err_8: 1;<br>
> + u32 clr_ack_with_err_9: 1;<br>
> + u32 clr_ack_with_err_10: 1;<br>
> + u32 clr_ack_with_err_11: 1;<br>
> + u32 clr_ack_with_err_12: 1;<br>
> + u32 clr_ack_with_err_13: 1;<br>
> + u32 clr_ack_with_err_14: 1;<br>
> + u32 clr_ack_with_err_15: 1;<br>
> + } bits;<br>
> + } PROTOCOL_INT_CLR;<br>
> +<br>
> + union _0xCC {<br>
> + u32 val;<br>
> + struct _INTERNAL_INT_CLR {<br>
> + u32 clr_receive_pkt_size_err: 1;<br>
> + u32 clr_eopt_not_receive_err: 1;<br>
> + u32 clr_gen_cmd_cmd_fifo_wr_err: 1;<br>
> + u32 clr_gen_cmd_rdata_fifo_rd_err: 1;<br>
> + u32 clr_gen_cmd_rdata_fifo_wr_err: 1;<br>
> + u32 clr_gen_cmd_wdata_fifo_wr_err: 1;<br>
> + u32 clr_gen_cmd_wdata_fifo_rd_err: 1;<br>
> + u32 clr_dpi_pix_fifo_wr_err: 1;<br>
> + u32 clr_internal_debug_err: 19;<br>
> + u32 clr_ecc_single_err: 1;<br>
> + u32 clr_ecc_multi_err: 1;<br>
> + u32 clr_crc_err: 1;<br>
> + u32 clr_hs_tx_timeout: 1;<br>
> + u32 clr_lp_rx_timeout: 1;<br>
> + } bits;<br>
> + } INTERNAL_INT_CLR;<br>
> +<br>
> + union _0xD0 {<br>
> + u32 val;<br>
> + struct _VIDEO_SIG_DELAY_CONFIG {<br>
> +<br>
> + /*<br>
> + * DPI interface signal delay to be used in clk lanebyte<br>
> + * domain for control logic to read video data from pixel<br>
> + * memory in mannal mode, measured in clk_lanebyte cycles<br>
> + */<br>
> + u32 video_sig_delay: 24;<br>
> +<br>
> + /*<br>
> + * 1'b1: mannal mode<br>
> + * dsi controller will use video_sig_delay value as<br>
> + * the delay for the packet handle logic to read video<br>
> + * data from pixel memory.<br>
> + *<br>
> + * 1'b0: auto mode<br>
> + * dsi controller will auto calculate the delay for<br>
> + * the packet handle logic to read video data from<br>
> + * pixel memory.<br>
> + */<br>
> + u32 video_sig_delay_mode: 1;<br>
> +<br>
> + u32 reserved: 7;<br>
> + } bits;<br>
> + } VIDEO_SIG_DELAY_CONFIG;<br>
> +<br>
> + u32 reservedD4_EC[7];<br>
> +<br>
> + union _0xF0 {<br>
> + u32 val;<br>
> + struct _PHY_TST_CTRL0 {<br>
> + /* PHY test interface clear (active high) */<br>
> + u32 phy_testclr: 1;<br>
> +<br>
> + /* This bit is used to clock the TESTDIN bus into the D-PHY */<br>
> + u32 phy_testclk: 1;<br>
> +<br>
> + u32 reserved: 30;<br>
> + } bits;<br>
> + } PHY_TST_CTRL0;<br>
> +<br>
> + union _0xF4 {<br>
> + u32 val;<br>
> + struct _PHY_TST_CTRL1 {<br>
> + /* PHY test interface input 8-bit data bus for internal<br>
> + * register programming and test functionalities access.<br>
> + */<br>
> + u32 phy_testdin: 8;<br>
> +<br>
> + /* PHY output 8-bit data bus for read-back and internal<br>
> + * probing functionalities.<br>
> + */<br>
> + u32 phy_testdout: 8;<br>
> +<br>
> + /*<br>
> + * PHY test interface operation selector:<br>
> + * 1: The address write operation is set on the falling edge<br>
> + * of the testclk signal.<br>
> + * 0: The data write operation is set on the rising edge of<br>
> + * the testclk signal.<br>
> + */<br>
> + u32 phy_testen: 1;<br>
> +<br>
> + u32 reserved: 15;<br>
> + } bits;<br>
> + } PHY_TST_CTRL1;<br>
> +<br>
> + u32 reservedF8_1FC[66];<br>
> +<br>
> + union _0x200 {<br>
> + u32 val;<br>
> + struct _INT_PLL_STS {<br>
> + u32 int_pll_sts: 1;<br>
> + u32 reserved: 31;<br>
> + } bits;<br>
> + } INT_PLL_STS;<br>
> +<br>
> + union _0x204 {<br>
> + u32 val;<br>
> + struct _INT_PLL_MSK {<br>
> + u32 int_pll_msk: 1;<br>
> + u32 reserved: 31;<br>
> + } bits;<br>
> + } INT_PLL_MSK;<br>
> +<br>
> + union _0x208 {<br>
> + u32 val;<br>
> + struct _INT_PLL_CLR {<br>
> + u32 int_pll_clr: 1;<br>
> + u32 reserved: 31;<br>
> + } bits;<br>
> + } INT_PLL_CLR;<br>
> +<br>
> +};<br>
> +<br>
> +void dsi_power_enable(struct dsi_context *ctx, int enable);<br>
> +void dsi_video_mode(struct dsi_context *ctx);<br>
> +void dsi_cmd_mode(struct dsi_context *ctx);<br>
> +bool dsi_is_cmd_mode(struct dsi_context *ctx);<br>
> +void dsi_rx_vcid(struct dsi_context *ctx, u8 vc);<br>
> +void dsi_video_vcid(struct dsi_context *ctx, u8 vc);<br>
> +void dsi_dpi_video_burst_mode(struct dsi_context *ctx, int mode);<br>
> +void dsi_dpi_color_coding(struct dsi_context *ctx, int coding);<br>
> +void dsi_dpi_sig_delay(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_dpi_hline_time(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_dpi_hsync_time(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_dpi_hbp_time(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_dpi_vact(struct dsi_context *ctx, u16 lines);<br>
> +void dsi_dpi_vfp(struct dsi_context *ctx, u16 lines);<br>
> +void dsi_dpi_vbp(struct dsi_context *ctx, u16 lines);<br>
> +void dsi_dpi_vsync(struct dsi_context *ctx, u16 lines);<br>
> +void dsi_dpi_hporch_lp_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_dpi_vporch_lp_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_dpi_frame_ack_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_dpi_chunk_num(struct dsi_context *ctx, u16 no);<br>
> +void dsi_dpi_null_packet_size(struct dsi_context *ctx, u16 size);<br>
> +void dsi_dpi_video_packet_size(struct dsi_context *ctx, u16 size);<br>
> +void dsi_edpi_max_pkt_size(struct dsi_context *ctx, u16 size);<br>
> +void dsi_tear_effect_ack_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_cmd_mode_lp_cmd_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_video_mode_lp_cmd_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_set_packet_header(struct dsi_context *ctx, u8 vc, u8 type,<br>
> + u8 wc_lsb, u8 wc_msb);<br>
> +void dsi_set_packet_payload(struct dsi_context *ctx, u32 payload);<br>
> +u32 dsi_get_rx_payload(struct dsi_context *ctx);<br>
> +void dsi_bta_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_eotp_rx_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_eotp_tx_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_ecc_rx_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_crc_rx_en(struct dsi_context *ctx, int enable);<br>
> +bool dsi_is_bta_returned(struct dsi_context *ctx);<br>
> +bool dsi_is_rx_payload_fifo_full(struct dsi_context *ctx);<br>
> +bool dsi_is_rx_payload_fifo_empty(struct dsi_context *ctx);<br>
> +bool dsi_is_tx_payload_fifo_full(struct dsi_context *ctx);<br>
> +bool dsi_is_tx_payload_fifo_empty(struct dsi_context *ctx);<br>
> +bool dsi_is_tx_cmd_fifo_empty(struct dsi_context *ctx);<br>
> +void dsi_datalane_hs2lp_config(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_datalane_lp2hs_config(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_clklane_hs2lp_config(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_clklane_lp2hs_config(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_max_read_time(struct dsi_context *ctx, u16 byte_cycle);<br>
> +void dsi_nc_clk_en(struct dsi_context *ctx, int enable);<br>
> +void dsi_tx_escape_division(struct dsi_context *ctx, u8 div);<br>
> +void dsi_timeout_clock_division(struct dsi_context *ctx, u8 div);<br>
> +void dsi_lp_rx_timeout(struct dsi_context *ctx, u16 count);<br>
> +void dsi_hs_tx_timeout(struct dsi_context *ctx, u16 count);<br>
> +u32 dsi_int0_status(struct dsi_context *ctx);<br>
> +u32 dsi_int1_status(struct dsi_context *ctx);<br>
> +void dsi_int0_mask(struct dsi_context *ctx, u32 mask);<br>
> +void dsi_int1_mask(struct dsi_context *ctx, u32 mask);<br>
> +<br>
> +#endif /* _DW_DSI_CTRL_H_ */<br>
> diff --git a/drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.c b/drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.c<br>
> new file mode 100644<br>
> index 000000000..6e28d7cf6<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.c<br>
> @@ -0,0 +1,157 @@<br>
> +// SPDX-License-Identifier: GPL-2.0<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#include <linux/io.h><br>
> +#include <linux/init.h><br>
> +#include <linux/module.h><br>
> +<br>
> +#include "dw_dsi_ctrl.h"<br>
> +#include "dw_dsi_ctrl_ppi.h"<br>
> +<br>
> +/*<br>
> + * Reset D-PHY module<br>
> + */<br>
> +void dsi_phy_rstz(struct dsi_context *ctx, int level)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x78 phy_interface_ctrl;<br>
> +<br>
> + phy_interface_ctrl.val = readl(®->PHY_INTERFACE_CTRL);<br>
> + phy_interface_ctrl.bits.rf_phy_reset_n = level;<br>
> +<br>
> + writel(phy_interface_ctrl.val, ®->PHY_INTERFACE_CTRL);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Power up/down D-PHY module<br>
> + */<br>
> +void dsi_phy_shutdownz(struct dsi_context *ctx, int level)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x78 phy_interface_ctrl;<br>
> +<br>
> + phy_interface_ctrl.val = readl(®->PHY_INTERFACE_CTRL);<br>
> + phy_interface_ctrl.bits.rf_phy_shutdown = level;<br>
> +<br>
> + writel(phy_interface_ctrl.val, ®->PHY_INTERFACE_CTRL);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Configure minimum wait period for HS transmission request after a stop state<br>
> + */<br>
> +void dsi_phy_stop_wait_time(struct dsi_context *ctx, u8 byte_cycle)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(byte_cycle, ®->PHY_MIN_STOP_TIME);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Set number of active lanes<br>
> + */<br>
> +void dsi_phy_datalane_en(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> +<br>
> + writel(ctx->lanes - 1, ®->PHY_LANE_NUM_CONFIG);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Enable clock lane module<br>
> + */<br>
> +void dsi_phy_clklane_en(struct dsi_context *ctx, int en)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x78 phy_interface_ctrl;<br>
> +<br>
> + phy_interface_ctrl.val = readl(®->PHY_INTERFACE_CTRL);<br>
> + phy_interface_ctrl.bits.rf_phy_clk_en = en;<br>
> +<br>
> + writel(phy_interface_ctrl.val, ®->PHY_INTERFACE_CTRL);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Request the PHY module to start transmission of high speed clock.<br>
> + * This causes the clock lane to start transmitting DDR clock on the<br>
> + * lane interconnect.<br>
> + */<br>
> +void dsi_phy_clk_hs_rqst(struct dsi_context *ctx, int enable)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x74 phy_clk_lane_lp_ctrl;<br>
> +<br>
> + phy_clk_lane_lp_ctrl.val = readl(®->PHY_CLK_LANE_LP_CTRL);<br>
> + phy_clk_lane_lp_ctrl.bits.auto_clklane_ctrl_en = 0;<br>
> + phy_clk_lane_lp_ctrl.bits.phy_clklane_tx_req_hs = enable;<br>
> +<br>
> + writel(phy_clk_lane_lp_ctrl.val, ®->PHY_CLK_LANE_LP_CTRL);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Get D-PHY PPI status<br>
> + */<br>
> +u8 dsi_phy_is_pll_locked(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0x9C phy_status;<br>
> +<br>
> + phy_status.val = readl(®->PHY_STATUS);<br>
> +<br>
> + return phy_status.bits.phy_lock;<br>
> +}<br>
> +<br>
> +void dsi_phy_test_clk(struct dsi_context *ctx, u8 value)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xF0 phy_tst_ctrl0;<br>
> +<br>
> + phy_tst_ctrl0.val = readl(®->PHY_TST_CTRL0);<br>
> + phy_tst_ctrl0.bits.phy_testclk = value;<br>
> +<br>
> + writel(phy_tst_ctrl0.val, ®->PHY_TST_CTRL0);<br>
> +}<br>
> +<br>
> +void dsi_phy_test_clr(struct dsi_context *ctx, u8 value)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xF0 phy_tst_ctrl0;<br>
> +<br>
> + phy_tst_ctrl0.val = readl(®->PHY_TST_CTRL0);<br>
> + phy_tst_ctrl0.bits.phy_testclr = value;<br>
> +<br>
> + writel(phy_tst_ctrl0.val, ®->PHY_TST_CTRL0);<br>
> +}<br>
> +<br>
> +void dsi_phy_test_en(struct dsi_context *ctx, u8 value)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xF4 phy_tst_ctrl1;<br>
> +<br>
> + phy_tst_ctrl1.val = readl(®->PHY_TST_CTRL1);<br>
> + phy_tst_ctrl1.bits.phy_testen = value;<br>
> +<br>
> + writel(phy_tst_ctrl1.val, ®->PHY_TST_CTRL1);<br>
> +}<br>
> +<br>
> +u8 dsi_phy_test_dout(struct dsi_context *ctx)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xF4 phy_tst_ctrl1;<br>
> +<br>
> + phy_tst_ctrl1.val = readl(®->PHY_TST_CTRL1);<br>
> +<br>
> + return phy_tst_ctrl1.bits.phy_testdout;<br>
> +}<br>
> +<br>
> +void dsi_phy_test_din(struct dsi_context *ctx, u8 data)<br>
> +{<br>
> + struct dsi_reg *reg = (struct dsi_reg *)ctx->base;<br>
> + union _0xF4 phy_tst_ctrl1;<br>
> +<br>
> + phy_tst_ctrl1.val = readl(®->PHY_TST_CTRL1);<br>
> + phy_tst_ctrl1.bits.phy_testdin = data;<br>
> +<br>
> + writel(phy_tst_ctrl1.val, ®->PHY_TST_CTRL1);<br>
> +}<br>
> diff --git a/drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.h b/drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.h<br>
> new file mode 100644<br>
> index 000000000..d87fb7579<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/dw_dsi_ctrl_ppi.h<br>
> @@ -0,0 +1,26 @@<br>
> +/* SPDX-License-Identifier: GPL-2.0 */<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#ifndef _DW_DSI_CTRL_PPI_H_<br>
> +#define _DW_DSI_CTRL_PPI_H_<br>
> +<br>
> +#include "sprd_dsi.h"<br>
> +<br>
> +void dsi_phy_rstz(struct dsi_context *ctx, int level);<br>
> +void dsi_phy_shutdownz(struct dsi_context *ctx, int level);<br>
> +void dsi_phy_force_pll(struct dsi_context *ctx, int force);<br>
> +void dsi_phy_stop_wait_time(struct dsi_context *ctx, u8 byte_clk);<br>
> +void dsi_phy_datalane_en(struct dsi_context *ctx);<br>
> +void dsi_phy_clklane_en(struct dsi_context *ctx, int en);<br>
> +void dsi_phy_clk_hs_rqst(struct dsi_context *ctx, int en);<br>
> +u8 dsi_phy_is_pll_locked(struct dsi_context *ctx);<br>
> +void dsi_phy_test_clk(struct dsi_context *ctx, u8 level);<br>
> +void dsi_phy_test_clr(struct dsi_context *ctx, u8 level);<br>
> +void dsi_phy_test_en(struct dsi_context *ctx, u8 level);<br>
> +u8 dsi_phy_test_dout(struct dsi_context *ctx);<br>
> +void dsi_phy_test_din(struct dsi_context *ctx, u8 data);<br>
> +void dsi_phy_bist_en(struct dsi_context *ctx, int en);<br>
> +<br>
> +#endif /* _DW_DSI_CTRL_PPI_H_ */<br>
> \ No newline at end of file<br>
> diff --git a/drivers/gpu/drm/sprd/megacores_pll.c b/drivers/gpu/drm/sprd/megacores_pll.c<br>
> new file mode 100644<br>
> index 000000000..03c1f0f00<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/megacores_pll.c<br>
> @@ -0,0 +1,317 @@<br>
> +// SPDX-License-Identifier: GPL-2.0<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#include <asm/div64.h><br>
> +#include <linux/delay.h><br>
> +#include <linux/init.h><br>
> +#include <linux/kernel.h><br>
> +#include <linux/regmap.h><br>
> +#include <linux/string.h><br>
> +<br>
> +#include "megacores_pll.h"<br>
> +<br>
> +#define L 0<br>
> +#define H 1<br>
> +#define CLK 0<br>
> +#define DATA 1<br>
> +#define INFINITY 0xffffffff<br>
> +#define MIN_OUTPUT_FREQ (100)<br>
> +<br>
> +#define AVERAGE(a, b) (min(a, b) + abs((b) - (a)) / 2)<br>
> +<br>
> +/* sharkle */<br>
> +#define VCO_BAND_LOW 750<br>
> +#define VCO_BAND_MID 1100<br>
> +#define VCO_BAND_HIGH 1500<br>
> +#define PHY_REF_CLK 26000<br>
> +<br>
> +static int dphy_calc_pll_param(struct dphy_pll *pll)<br>
> +{<br>
> + const u32 khz = 1000;<br>
> + const u32 mhz = 1000000;<br>
> + const unsigned long long factor = 100;<br>
> + unsigned long long tmp;<br>
> + int i;<br>
> +<br>
> + pll->potential_fvco = pll->freq / khz;<br>
> + pll->ref_clk = PHY_REF_CLK / khz;<br>
> +<br>
> + for (i = 0; i < 4; ++i) {<br>
> + if (pll->potential_fvco >= VCO_BAND_LOW &&<br>
> + pll->potential_fvco <= VCO_BAND_HIGH) {<br>
> + pll->fvco = pll->potential_fvco;<br>
> + pll->out_sel = BIT(i);<br>
> + break;<br>
> + }<br>
> + pll->potential_fvco <<= 1;<br>
> + }<br>
> + if (pll->fvco == 0)<br>
> + return -EINVAL;<br>
> +<br>
> + if (pll->fvco >= VCO_BAND_LOW && pll->fvco <= VCO_BAND_MID) {<br>
> + /* vco band control */<br>
> + pll->vco_band = 0x0;<br>
> + /* low pass filter control */<br>
> + pll->lpf_sel = 1;<br>
> + } else if (pll->fvco > VCO_BAND_MID && pll->fvco <= VCO_BAND_HIGH) {<br>
> + pll->vco_band = 0x1;<br>
> + pll->lpf_sel = 0;<br>
> + } else<br>
> + return -EINVAL;<br>
> +<br>
> + pll->nint = pll->fvco / pll->ref_clk;<br>
> + tmp = pll->fvco * factor * mhz;<br>
> + do_div(tmp, pll->ref_clk);<br>
> + tmp = tmp - pll->nint * factor * mhz;<br>
> + tmp *= BIT(20);<br>
> + do_div(tmp, 100000000);<br>
> + pll->kint = (u32)tmp;<br>
> + pll->refin = 3; /* pre-divider bypass */<br>
> + pll->sdm_en = true; /* use fraction N PLL */<br>
> + pll->fdk_s = 0x1; /* fraction */<br>
> + pll->cp_s = 0x0;<br>
> + pll->det_delay = 0x1;<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static void dphy_set_pll_reg(struct dphy_pll *pll, struct regmap *regmap)<br>
> +{<br>
> + struct pll_reg *reg = &pll->reg;<br>
> + u8 *val;<br>
> + int i;<br>
> +<br>
> + u8 reg_addr[] = {<br>
> + 0x03, 0x04, 0x06, 0x08, 0x09,<br>
> + 0x0a, 0x0b, 0x0e, 0x0f<br>
> + };<br>
> +<br>
> + reg->_03.bits.prbs_bist = 1;<br>
> + reg->_03.bits.en_lp_treot = true;<br>
> + reg->_03.bits.lpf_sel = pll->lpf_sel;<br>
> + reg->_03.bits.txfifo_bypass = 0;<br>
> + reg->_04.bits.div = pll->div;<br>
> + reg->_04.bits.masterof8lane = 1;<br>
> + reg->_04.bits.cp_s = pll->cp_s;<br>
> + reg->_04.bits.fdk_s = pll->fdk_s;<br>
> + reg->_06.bits.nint = pll->nint;<br>
> + reg->_08.bits.vco_band = pll->vco_band;<br>
> + reg->_08.bits.sdm_en = pll->sdm_en;<br>
> + reg->_08.bits.refin = pll->refin;<br>
> + reg->_09.bits.kint_h = pll->kint >> 12;<br>
> + reg->_0a.bits.kint_m = (pll->kint >> 4) & 0xff;<br>
> + reg->_0b.bits.out_sel = pll->out_sel;<br>
> + reg->_0b.bits.kint_l = pll->kint & 0xf;<br>
> + reg->_0e.bits.pll_pu_byp = 0;<br>
> + reg->_0e.bits.pll_pu = 0;<br>
> + reg->_0e.bits.stopstate_sel = 1;<br>
> + reg->_0f.bits.det_delay = pll->det_delay;<br>
> +<br>
> + val = (u8 *)®<br>
> +<br>
> + for (i = 0; i < sizeof(reg_addr); ++i) {<br>
> + regmap_write(regmap, reg_addr[i], val[i]);<br>
> + DRM_DEBUG("%02x: %02x\n", reg_addr[i], val[i]);<br>
> + }<br>
> +}<br>
> +<br>
> +int dphy_pll_config(struct dsi_context *ctx)<br>
> +{<br>
> + struct sprd_dsi *dsi = container_of(ctx, struct sprd_dsi, ctx);<br>
> + struct regmap *regmap = ctx->regmap;<br>
> + struct dphy_pll *pll = ctx->pll;<br>
> + int ret;<br>
> +<br>
> + pll->freq = ctx->byte_clk * 8;<br>
> +<br>
> + /* FREQ = 26M * (NINT + KINT / 2^20) / out_sel */<br>
> + ret = dphy_calc_pll_param(pll);<br>
> + if (ret) {<br>
> + drm_err(dsi->drm, "failed to calculate dphy pll parameters\n");<br>
> + return ret;<br>
> + }<br>
> + dphy_set_pll_reg(pll, regmap);<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static void dphy_set_timing_reg(struct regmap *regmap, int type, u8 val[])<br>
> +{<br>
> + switch (type) {<br>
> + case REQUEST_TIME:<br>
> + regmap_write(regmap, 0x31, val[CLK]);<br>
> + regmap_write(regmap, 0x41, val[DATA]);<br>
> + regmap_write(regmap, 0x51, val[DATA]);<br>
> + regmap_write(regmap, 0x61, val[DATA]);<br>
> + regmap_write(regmap, 0x71, val[DATA]);<br>
> +<br>
> + regmap_write(regmap, 0x90, val[CLK]);<br>
> + regmap_write(regmap, 0xa0, val[DATA]);<br>
> + regmap_write(regmap, 0xb0, val[DATA]);<br>
> + regmap_write(regmap, 0xc0, val[DATA]);<br>
> + regmap_write(regmap, 0xd0, val[DATA]);<br>
> + break;<br>
> + case PREPARE_TIME:<br>
> + regmap_write(regmap, 0x32, val[CLK]);<br>
> + regmap_write(regmap, 0x42, val[DATA]);<br>
> + regmap_write(regmap, 0x52, val[DATA]);<br>
> + regmap_write(regmap, 0x62, val[DATA]);<br>
> + regmap_write(regmap, 0x72, val[DATA]);<br>
> +<br>
> + regmap_write(regmap, 0x91, val[CLK]);<br>
> + regmap_write(regmap, 0xa1, val[DATA]);<br>
> + regmap_write(regmap, 0xb1, val[DATA]);<br>
> + regmap_write(regmap, 0xc1, val[DATA]);<br>
> + regmap_write(regmap, 0xd1, val[DATA]);<br>
> + break;<br>
> + case ZERO_TIME:<br>
> + regmap_write(regmap, 0x33, val[CLK]);<br>
> + regmap_write(regmap, 0x43, val[DATA]);<br>
> + regmap_write(regmap, 0x53, val[DATA]);<br>
> + regmap_write(regmap, 0x63, val[DATA]);<br>
> + regmap_write(regmap, 0x73, val[DATA]);<br>
> +<br>
> + regmap_write(regmap, 0x92, val[CLK]);<br>
> + regmap_write(regmap, 0xa2, val[DATA]);<br>
> + regmap_write(regmap, 0xb2, val[DATA]);<br>
> + regmap_write(regmap, 0xc2, val[DATA]);<br>
> + regmap_write(regmap, 0xd2, val[DATA]);<br>
> + break;<br>
> + case TRAIL_TIME:<br>
> + regmap_write(regmap, 0x34, val[CLK]);<br>
> + regmap_write(regmap, 0x44, val[DATA]);<br>
> + regmap_write(regmap, 0x54, val[DATA]);<br>
> + regmap_write(regmap, 0x64, val[DATA]);<br>
> + regmap_write(regmap, 0x74, val[DATA]);<br>
> +<br>
> + regmap_write(regmap, 0x93, val[CLK]);<br>
> + regmap_write(regmap, 0xa3, val[DATA]);<br>
> + regmap_write(regmap, 0xb3, val[DATA]);<br>
> + regmap_write(regmap, 0xc3, val[DATA]);<br>
> + regmap_write(regmap, 0xd3, val[DATA]);<br>
> + break;<br>
> + case EXIT_TIME:<br>
> + regmap_write(regmap, 0x36, val[CLK]);<br>
> + regmap_write(regmap, 0x46, val[DATA]);<br>
> + regmap_write(regmap, 0x56, val[DATA]);<br>
> + regmap_write(regmap, 0x66, val[DATA]);<br>
> + regmap_write(regmap, 0x76, val[DATA]);<br>
> +<br>
> + regmap_write(regmap, 0x95, val[CLK]);<br>
> + regmap_write(regmap, 0xA5, val[DATA]);<br>
> + regmap_write(regmap, 0xB5, val[DATA]);<br>
> + regmap_write(regmap, 0xc5, val[DATA]);<br>
> + regmap_write(regmap, 0xd5, val[DATA]);<br>
> + break;<br>
> + case CLKPOST_TIME:<br>
> + regmap_write(regmap, 0x35, val[CLK]);<br>
> + regmap_write(regmap, 0x94, val[CLK]);<br>
> + break;<br>
> +<br>
> + /* the following just use default value */<br>
> + case SETTLE_TIME:<br>
> + case TA_GET:<br>
> + case TA_GO:<br>
> + case TA_SURE:<br>
> + break;<br>
> + default:<br>
> + break;<br>
> + }<br>
> +}<br>
> +<br>
> +void dphy_timing_config(struct dsi_context *ctx)<br>
> +{<br>
> + struct regmap *regmap = ctx->regmap;<br>
> + struct dphy_pll *pll = ctx->pll;<br>
> + const u32 factor = 2;<br>
> + const u32 scale = 100;<br>
> + u32 t_ui, t_byteck, t_half_byteck;<br>
> + u32 range[2], constant;<br>
> + u8 val[2];<br>
> + u32 tmp = 0;<br>
> +<br>
> + /* t_ui: 1 ui, byteck: 8 ui, half byteck: 4 ui */<br>
> + t_ui = 1000 * scale / (pll->freq / 1000);<br>
> + t_byteck = t_ui << 3;<br>
> + t_half_byteck = t_ui << 2;<br>
> + constant = t_ui << 1;<br>
> +<br>
> + /* REQUEST_TIME: HS T-LPX: LP-01<br>
> + * For T-LPX, mipi spec defined min value is 50ns,<br>
> + * but maybe it shouldn't be too small, because BTA,<br>
> + * LP-10, LP-00, LP-01, all of this is related to T-LPX.<br>
> + */<br>
> + range[L] = 50 * scale;<br>
> + range[H] = INFINITY;<br>
> + val[CLK] = DIV_ROUND_UP(range[L] * (factor << 1), t_byteck) - 2;<br>
> + val[DATA] = val[CLK];<br>
> + dphy_set_timing_reg(regmap, REQUEST_TIME, val);<br>
> +<br>
> + /* PREPARE_TIME: HS sequence: LP-00 */<br>
> + range[L] = 38 * scale;<br>
> + range[H] = 95 * scale;<br>
> + tmp = AVERAGE(range[L], range[H]);<br>
> + val[CLK] = DIV_ROUND_UP(AVERAGE(range[L], range[H]),<br>
> + t_half_byteck) - 1;<br>
> + range[L] = 40 * scale + 4 * t_ui;<br>
> + range[H] = 85 * scale + 6 * t_ui;<br>
> + tmp |= AVERAGE(range[L], range[H]) << 16;<br>
> + val[DATA] = DIV_ROUND_UP(AVERAGE(range[L], range[H]),<br>
> + t_half_byteck) - 1;<br>
> + dphy_set_timing_reg(regmap, PREPARE_TIME, val);<br>
> +<br>
> + /* ZERO_TIME: HS-ZERO */<br>
> + range[L] = 300 * scale;<br>
> + range[H] = INFINITY;<br>
> + val[CLK] = DIV_ROUND_UP(range[L] * factor + (tmp & 0xffff)<br>
> + - 525 * t_byteck / 100, t_byteck) - 2;<br>
> + range[L] = 145 * scale + 10 * t_ui;<br>
> + val[DATA] = DIV_ROUND_UP(range[L] * factor<br>
> + + ((tmp >> 16) & 0xffff) - 525 * t_byteck / 100,<br>
> + t_byteck) - 2;<br>
> + dphy_set_timing_reg(regmap, ZERO_TIME, val);<br>
> +<br>
> + /* TRAIL_TIME: HS-TRAIL */<br>
> + range[L] = 60 * scale;<br>
> + range[H] = INFINITY;<br>
> + val[CLK] = DIV_ROUND_UP(range[L] * factor - constant, t_half_byteck);<br>
> + range[L] = max(8 * t_ui, 60 * scale + 4 * t_ui);<br>
> + val[DATA] = DIV_ROUND_UP(range[L] * 3 / 2 - constant, t_half_byteck) - 2;<br>
> + dphy_set_timing_reg(regmap, TRAIL_TIME, val);<br>
> +<br>
> + /* EXIT_TIME: */<br>
> + range[L] = 100 * scale;<br>
> + range[H] = INFINITY;<br>
> + val[CLK] = DIV_ROUND_UP(range[L] * factor, t_byteck) - 2;<br>
> + val[DATA] = val[CLK];<br>
> + dphy_set_timing_reg(regmap, EXIT_TIME, val);<br>
> +<br>
> + /* CLKPOST_TIME: */<br>
> + range[L] = 60 * scale + 52 * t_ui;<br>
> + range[H] = INFINITY;<br>
> + val[CLK] = DIV_ROUND_UP(range[L] * factor, t_byteck) - 2;<br>
> + val[DATA] = val[CLK];<br>
> + dphy_set_timing_reg(regmap, CLKPOST_TIME, val);<br>
> +<br>
> + /* SETTLE_TIME:<br>
> + * This time is used for receiver. So for transmitter,<br>
> + * it can be ignored.<br>
> + */<br>
> +<br>
> + /* TA_GO:<br>
> + * transmitter drives bridge state(LP-00) before releasing control,<br>
> + * reg 0x1f default value: 0x04, which is good.<br>
> + */<br>
> +<br>
> + /* TA_SURE:<br>
> + * After LP-10 state and before bridge state(LP-00),<br>
> + * reg 0x20 default value: 0x01, which is good.<br>
> + */<br>
> +<br>
> + /* TA_GET:<br>
> + * receiver drives Bridge state(LP-00) before releasing control<br>
> + * reg 0x21 default value: 0x03, which is good.<br>
> + */<br>
> +}<br>
> diff --git a/drivers/gpu/drm/sprd/megacores_pll.h b/drivers/gpu/drm/sprd/megacores_pll.h<br>
> new file mode 100644<br>
> index 000000000..750dbbc09<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/megacores_pll.h<br>
> @@ -0,0 +1,146 @@<br>
> +/* SPDX-License-Identifier: GPL-2.0 */<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#ifndef _MEGACORES_PLL_H_<br>
> +#define _MEGACORES_PLL_H_<br>
> +<br>
> +#include "sprd_dsi.h"<br>
> +<br>
> +enum PLL_TIMING {<br>
> + NONE,<br>
> + REQUEST_TIME,<br>
> + PREPARE_TIME,<br>
> + SETTLE_TIME,<br>
> + ZERO_TIME,<br>
> + TRAIL_TIME,<br>
> + EXIT_TIME,<br>
> + CLKPOST_TIME,<br>
> + TA_GET,<br>
> + TA_GO,<br>
> + TA_SURE,<br>
> + TA_WAIT,<br>
> +};<br>
> +<br>
> +struct pll_reg {<br>
> + union __reg_03__ {<br>
> + struct __03 {<br>
> + u8 prbs_bist: 1;<br>
> + u8 en_lp_treot: 1;<br>
> + u8 lpf_sel: 4;<br>
> + u8 txfifo_bypass: 1;<br>
> + u8 freq_hopping: 1;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _03;<br>
> + union __reg_04__ {<br>
> + struct __04 {<br>
> + u8 div: 3;<br>
> + u8 masterof8lane: 1;<br>
> + u8 hop_trig: 1;<br>
> + u8 cp_s: 2;<br>
> + u8 fdk_s: 1;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _04;<br>
> + union __reg_06__ {<br>
> + struct __06 {<br>
> + u8 nint: 7;<br>
> + u8 mod_en: 1;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _06;<br>
> + union __reg_07__ {<br>
> + struct __07 {<br>
> + u8 kdelta_h: 8;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _07;<br>
> + union __reg_08__ {<br>
> + struct __08 {<br>
> + u8 vco_band: 1;<br>
> + u8 sdm_en: 1;<br>
> + u8 refin: 2;<br>
> + u8 kdelta_l: 4;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _08;<br>
> + union __reg_09__ {<br>
> + struct __09 {<br>
> + u8 kint_h: 8;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _09;<br>
> + union __reg_0a__ {<br>
> + struct __0a {<br>
> + u8 kint_m: 8;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _0a;<br>
> + union __reg_0b__ {<br>
> + struct __0b {<br>
> + u8 out_sel: 4;<br>
> + u8 kint_l: 4;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _0b;<br>
> + union __reg_0c__ {<br>
> + struct __0c {<br>
> + u8 kstep_h: 8;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _0c;<br>
> + union __reg_0d__ {<br>
> + struct __0d {<br>
> + u8 kstep_m: 8;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _0d;<br>
> + union __reg_0e__ {<br>
> + struct __0e {<br>
> + u8 pll_pu_byp: 1;<br>
> + u8 pll_pu: 1;<br>
> + u8 hsbist_len: 2;<br>
> + u8 stopstate_sel: 1;<br>
> + u8 kstep_l: 3;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _0e;<br>
> + union __reg_0f__ {<br>
> + struct __0f {<br>
> + u8 det_delay:2;<br>
> + u8 kdelta: 4;<br>
> + u8 ldo0p4:2;<br>
> + } bits;<br>
> + u8 val;<br>
> + } _0f;<br>
> +};<br>
> +<br>
> +struct dphy_pll {<br>
> + u8 refin; /* Pre-divider control signal */<br>
> + u8 cp_s; /* 00: SDM_EN=1, 10: SDM_EN=0 */<br>
> + u8 fdk_s; /* PLL mode control: integer or fraction */<br>
> + u8 sdm_en;<br>
> + u8 div;<br>
> + u8 int_n; /* integer N PLL */<br>
> + u32 ref_clk; /* dphy reference clock, unit: MHz */<br>
> + u32 freq; /* panel config, unit: KHz */<br>
> + u32 fvco;<br>
> + u32 potential_fvco;<br>
> + u32 nint; /* sigma delta modulator NINT control */<br>
> + u32 kint; /* sigma delta modulator KINT control */<br>
> + u8 lpf_sel; /* low pass filter control */<br>
> + u8 out_sel; /* post divider control */<br>
> + u8 vco_band; /* vco range */<br>
> + u8 det_delay;<br>
> +<br>
> + struct pll_reg reg;<br>
> +};<br>
> +<br>
> +struct dsi_context;<br>
> +<br>
> +int dphy_pll_config(struct dsi_context *ctx);<br>
> +void dphy_timing_config(struct dsi_context *ctx);<br>
> +<br>
> +#endif /* _MEGACORES_PLL_H_ */<br>
> \ No newline at end of file<br>
> diff --git a/drivers/gpu/drm/sprd/sprd_drm.c b/drivers/gpu/drm/sprd/sprd_drm.c<br>
> index c626c6caf..1613b5db3 100644<br>
> --- a/drivers/gpu/drm/sprd/sprd_drm.c<br>
> +++ b/drivers/gpu/drm/sprd/sprd_drm.c<br>
> @@ -192,6 +192,7 @@ static struct platform_driver sprd_drm_driver = {<br>
> static struct platform_driver *sprd_drm_drivers[] = {<br>
> &sprd_drm_driver,<br>
> &sprd_dpu_driver,<br>
> + &sprd_dsi_driver,<br>
> };<br>
> <br>
> static int __init sprd_drm_init(void)<br>
> diff --git a/drivers/gpu/drm/sprd/sprd_drm.h b/drivers/gpu/drm/sprd/sprd_drm.h<br>
> index 85d4a8b9f..95d1b972f 100644<br>
> --- a/drivers/gpu/drm/sprd/sprd_drm.h<br>
> +++ b/drivers/gpu/drm/sprd/sprd_drm.h<br>
> @@ -14,5 +14,6 @@ struct sprd_drm {<br>
> };<br>
> <br>
> extern struct platform_driver sprd_dpu_driver;<br>
> +extern struct platform_driver sprd_dsi_driver;<br>
> <br>
> #endif /* _SPRD_DRM_H_ */<br>
> diff --git a/drivers/gpu/drm/sprd/sprd_dsi.c b/drivers/gpu/drm/sprd/sprd_dsi.c<br>
> new file mode 100644<br>
> index 000000000..d892b1934<br>
> --- /dev/null<br>
> +++ b/drivers/gpu/drm/sprd/sprd_dsi.c<br>
> @@ -0,0 +1,1132 @@<br>
> +// SPDX-License-Identifier: GPL-2.0<br>
> +/*<br>
> + * Copyright (C) 2020 Unisoc Inc.<br>
> + */<br>
> +<br>
> +#include <linux/component.h><br>
> +#include <linux/module.h><br>
> +#include <linux/of_address.h><br>
> +#include <linux/of_device.h><br>
> +#include <linux/of_irq.h><br>
> +#include <linux/of_graph.h><br>
> +#include <video/mipi_display.h><br>
> +<br>
> +#include <drm/drm_atomic_helper.h><br>
> +#include <drm/drm_crtc_helper.h><br>
> +#include <drm/drm_of.h><br>
> +#include <drm/drm_probe_helper.h><br>
> +<br>
> +#include "sprd_drm.h"<br>
> +#include "sprd_dpu.h"<br>
> +#include "sprd_dsi.h"<br>
> +#include "dw_dsi_ctrl.h"<br>
> +#include "dw_dsi_ctrl_ppi.h"<br>
> +<br>
> +#define encoder_to_dsi(encoder) \<br>
> + container_of(encoder, struct sprd_dsi, encoder)<br>
> +#define host_to_dsi(host) \<br>
> + container_of(host, struct sprd_dsi, host)<br>
> +#define connector_to_dsi(connector) \<br>
> + container_of(connector, struct sprd_dsi, connector)<br>
> +<br>
> +static int regmap_tst_io_write(void *context, u32 reg, u32 val)<br>
> +{<br>
> + struct sprd_dsi *dsi = context;<br>
> + struct dsi_context *ctx = &dsi->ctx;<br>
> +<br>
> + if (val > 0xff || reg > 0xff)<br>
> + return -EINVAL;<br>
> +<br>
> + drm_dbg(dsi->drm, "reg = 0x%02x, val = 0x%02x\n", reg, val);<br>
> +<br>
> + dsi_phy_test_en(ctx, 1);<br>
> + dsi_phy_test_din(ctx, reg);<br>
> + dsi_phy_test_clk(ctx, 1);<br>
> + dsi_phy_test_clk(ctx, 0);<br>
> + dsi_phy_test_en(ctx, 0);<br>
> + dsi_phy_test_din(ctx, val);<br>
> + dsi_phy_test_clk(ctx, 1);<br>
> + dsi_phy_test_clk(ctx, 0);<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static int regmap_tst_io_read(void *context, u32 reg, u32 *val)<br>
> +{<br>
> + struct sprd_dsi *dsi = context;<br>
> + struct dsi_context *ctx = &dsi->ctx;<br>
> + int ret;<br>
> +<br>
> + if (reg > 0xff)<br>
> + return -EINVAL;<br>
> +<br>
> + dsi_phy_test_en(ctx, 1);<br>
> + dsi_phy_test_din(ctx, reg);<br>
> + dsi_phy_test_clk(ctx, 1);<br>
> + dsi_phy_test_clk(ctx, 0);<br>
> + dsi_phy_test_en(ctx, 0);<br>
> +<br>
> + udelay(1);<br>
> +<br>
> + ret = dsi_phy_test_dout(ctx);<br>
> + if (ret < 0)<br>
> + return ret;<br>
> +<br>
> + *val = ret;<br>
> +<br>
> + drm_dbg(dsi->drm, "reg = 0x%02x, val = 0x%02x\n", reg, *val);<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static struct regmap_bus regmap_tst_io = {<br>
> + .reg_write = regmap_tst_io_write,<br>
> + .reg_read = regmap_tst_io_read,<br>
> +};<br>
> +<br>
> +static const struct regmap_config byte_config = {<br>
> + .reg_bits = 8,<br>
> + .val_bits = 8,<br>
> +};<br>
> +<br>
> +static int dphy_wait_pll_locked(struct dsi_context *ctx)<br>
> +{<br>
> + struct sprd_dsi *dsi = container_of(ctx, struct sprd_dsi, ctx);<br>
> + int i;<br>
> +<br>
> + for (i = 0; i < 50000; i++) {<br>
> + if (dsi_phy_is_pll_locked(ctx))<br>
> + return 0;<br>
> + udelay(3);<br>
> + }<br>
> +<br>
> + drm_err(dsi->drm, "dphy pll can not be locked\n");<br>
> + return -ETIMEDOUT;<br>
> +}<br>
> +<br>
> +static int dsi_wait_tx_payload_fifo_empty(struct dsi_context *ctx)<br>
> +{<br>
> + int i;<br>
> +<br>
> + for (i = 0; i < 5000; i++) {<br>
> + if (dsi_is_tx_payload_fifo_empty(ctx))<br>
> + return 0;<br>
> + udelay(1);<br>
> + }<br>
> +<br>
> + return -ETIMEDOUT;<br>
> +}<br>
> +<br>
> +static int dsi_wait_tx_cmd_fifo_empty(struct dsi_context *ctx)<br>
> +{<br>
> + int i;<br>
> +<br>
> + for (i = 0; i < 5000; i++) {<br>
> + if (dsi_is_tx_cmd_fifo_empty(ctx))<br>
> + return 0;<br>
> + udelay(1);<br>
> + }<br>
> +<br>
> + return -ETIMEDOUT;<br>
> +}<br>
> +<br>
> +static int dsi_wait_rd_resp_completed(struct dsi_context *ctx)<br>
> +{<br>
> + int i;<br>
> +<br>
> + for (i = 0; i < 10000; i++) {<br>
> + if (dsi_is_bta_returned(ctx))<br>
> + return 0;<br>
> + udelay(10);<br>
> + }<br>
> +<br>
> + return -ETIMEDOUT;<br>
> +}<br>
> +<br>
> +static u16 calc_bytes_per_pixel_x100(int coding)<br>
> +{<br>
> + u16 Bpp_x100;<br>
> +<br>
> + switch (coding) {<br>
> + case COLOR_CODE_16BIT_CONFIG1:<br>
> + case COLOR_CODE_16BIT_CONFIG2:<br>
> + case COLOR_CODE_16BIT_CONFIG3:<br>
> + Bpp_x100 = 200;<br>
> + break;<br>
> + case COLOR_CODE_18BIT_CONFIG1:<br>
> + case COLOR_CODE_18BIT_CONFIG2:<br>
> + Bpp_x100 = 225;<br>
> + break;<br>
> + case COLOR_CODE_24BIT:<br>
> + Bpp_x100 = 300;<br>
> + break;<br>
> + case COLOR_CODE_COMPRESSTION:<br>
> + Bpp_x100 = 100;<br>
> + break;<br>
> + case COLOR_CODE_20BIT_YCC422_LOOSELY:<br>
> + Bpp_x100 = 250;<br>
> + break;<br>
> + case COLOR_CODE_24BIT_YCC422:<br>
> + Bpp_x100 = 300;<br>
> + break;<br>
> + case COLOR_CODE_16BIT_YCC422:<br>
> + Bpp_x100 = 200;<br>
> + break;<br>
> + case COLOR_CODE_30BIT:<br>
> + Bpp_x100 = 375;<br>
> + break;<br>
> + case COLOR_CODE_36BIT:<br>
> + Bpp_x100 = 450;<br>
> + break;<br>
> + case COLOR_CODE_12BIT_YCC420:<br>
> + Bpp_x100 = 150;<br>
> + break;<br>
> + default:<br>
> + DRM_ERROR("invalid color coding");<br>
> + Bpp_x100 = 0;<br>
> + break;<br>
> + }<br>
> +<br>
> + return Bpp_x100;<br>
> +}<br>
> +<br>
> +static u8 calc_video_size_step(int coding)<br>
> +{<br>
> + u8 video_size_step;<br>
> +<br>
> + switch (coding) {<br>
> + case COLOR_CODE_16BIT_CONFIG1:<br>
> + case COLOR_CODE_16BIT_CONFIG2:<br>
> + case COLOR_CODE_16BIT_CONFIG3:<br>
> + case COLOR_CODE_18BIT_CONFIG1:<br>
> + case COLOR_CODE_18BIT_CONFIG2:<br>
> + case COLOR_CODE_24BIT:<br>
> + case COLOR_CODE_COMPRESSTION:<br>
> + return video_size_step = 1;<br>
> + case COLOR_CODE_20BIT_YCC422_LOOSELY:<br>
> + case COLOR_CODE_24BIT_YCC422:<br>
> + case COLOR_CODE_16BIT_YCC422:<br>
> + case COLOR_CODE_30BIT:<br>
> + case COLOR_CODE_36BIT:<br>
> + case COLOR_CODE_12BIT_YCC420:<br>
> + return video_size_step = 2;<br>
> + default:<br>
> + DRM_ERROR("invalid color coding");<br>
> + return 0;<br>
> + }<br>
> +}<br>
> +<br>
> +static u16 round_video_size(int coding, u16 video_size)<br>
> +{<br>
> + switch (coding) {<br>
> + case COLOR_CODE_16BIT_YCC422:<br>
> + case COLOR_CODE_24BIT_YCC422:<br>
> + case COLOR_CODE_20BIT_YCC422_LOOSELY:<br>
> + case COLOR_CODE_12BIT_YCC420:<br>
> + /* round up active H pixels to a multiple of 2 */<br>
> + if ((video_size % 2) != 0)<br>
> + video_size += 1;<br>
> + break;<br>
> + default:<br>
> + break;<br>
> + }<br>
> +<br>
> + return video_size;<br>
> +}<br>
> +<br>
> +#define SPRD_MIPI_DSI_FMT_DSC 0xff<br>
> +static u32 fmt_to_coding(u32 fmt)<br>
> +{<br>
> + switch (fmt) {<br>
> + case MIPI_DSI_FMT_RGB565:<br>
> + return COLOR_CODE_16BIT_CONFIG1;<br>
> + case MIPI_DSI_FMT_RGB666:<br>
> + case MIPI_DSI_FMT_RGB666_PACKED:<br>
> + return COLOR_CODE_18BIT_CONFIG1;<br>
> + case MIPI_DSI_FMT_RGB888:<br>
> + return COLOR_CODE_24BIT;<br>
> + case SPRD_MIPI_DSI_FMT_DSC:<br>
> + return COLOR_CODE_COMPRESSTION;<br>
> + default:<br>
> + DRM_ERROR("Unsupported format (%d)\n", fmt);<br>
> + return COLOR_CODE_24BIT;<br>
> + }<br>
> +}<br>
> +<br>
> +#define ns_to_cycle(ns, byte_clk) \<br>
> + DIV_ROUND_UP((ns) * (byte_clk), 1000000)<br>
> +<br>
> +static void sprd_dsi_init(struct dsi_context *ctx)<br>
> +{<br>
> + u16 data_hs2lp, data_lp2hs, clk_hs2lp, clk_lp2hs;<br>
> + u16 max_rd_time;<br>
> + int div;<br>
> +<br>
> + dsi_power_enable(ctx, 0);<br>
> + dsi_int0_mask(ctx, 0xffffffff);<br>
> + dsi_int1_mask(ctx, 0xffffffff);<br>
> + dsi_cmd_mode(ctx);<br>
> + dsi_eotp_rx_en(ctx, 0);<br>
> + dsi_eotp_tx_en(ctx, 0);<br>
> + dsi_ecc_rx_en(ctx, 1);<br>
> + dsi_crc_rx_en(ctx, 1);<br>
> + dsi_bta_en(ctx, 1);<br>
> + dsi_video_vcid(ctx, 0);<br>
> + dsi_rx_vcid(ctx, 0);<br>
> +<br>
> + div = DIV_ROUND_UP(ctx->byte_clk, ctx->esc_clk);<br>
> + dsi_tx_escape_division(ctx, div);<br>
> +<br>
> + max_rd_time = ns_to_cycle(ctx->max_rd_time, ctx->byte_clk);<br>
> + dsi_max_read_time(ctx, max_rd_time);<br>
> +<br>
> + data_hs2lp = ns_to_cycle(ctx->data_hs2lp, ctx->byte_clk);<br>
> + data_lp2hs = ns_to_cycle(ctx->data_lp2hs, ctx->byte_clk);<br>
> + clk_hs2lp = ns_to_cycle(ctx->clk_hs2lp, ctx->byte_clk);<br>
> + clk_lp2hs = ns_to_cycle(ctx->clk_lp2hs, ctx->byte_clk);<br>
> + dsi_datalane_hs2lp_config(ctx, data_hs2lp);<br>
> + dsi_datalane_lp2hs_config(ctx, data_lp2hs);<br>
> + dsi_clklane_hs2lp_config(ctx, clk_hs2lp);<br>
> + dsi_clklane_lp2hs_config(ctx, clk_lp2hs);<br>
> +<br>
> + dsi_power_enable(ctx, 1);<br>
> +}<br>
> +<br>
> +/*<br>
> + * Free up resources and shutdown host controller and PHY<br>
> + */<br>
> +static void sprd_dsi_fini(struct dsi_context *ctx)<br>
> +{<br>
> + dsi_int0_mask(ctx, 0xffffffff);<br>
> + dsi_int1_mask(ctx, 0xffffffff);<br>
> + dsi_power_enable(ctx, 0);<br>
> +}<br>
> +<br>
> +/*<br>
> + * If not in burst mode, it will compute the video and null packet sizes<br>
> + * according to necessity.<br>
> + * Configure timers for data lanes and/or clock lane to return to LP when<br>
> + * bandwidth is not filled by data.<br>
> + */<br>
> +static int sprd_dsi_dpi_video(struct dsi_context *ctx)<br>
> +{<br>
> + struct sprd_dsi *dsi = container_of(ctx, struct sprd_dsi, ctx);<br>
> + struct videomode *vm = &ctx->vm;<br>
<br>
Strictly speaking, there's nothing that guarantees that the preferred<br>
mode is the one you're going to use there. You should use the mode that<br>
is given to you through the connector state.<br>
<br>
Maxime<br>
</blockquote></div></div>