diff mbox series

[3/3] drm/mediatek: dsi: Add dsi cmdq_ctl to send panel initial code

Message ID 1681366162-4949-4-git-send-email-xinlei.lee@mediatek.com
State New
Headers show
Series Add mt8188 compatiable for DSI cmd packet control | expand

Commit Message

xinlei.lee@mediatek.com April 13, 2023, 6:09 a.m. UTC
From: Xinlei Lee <xinlei.lee@mediatek.com>

For mt8188, add dsi cmdq reg control to send long packets to panel initialization.

Signed-off-by: Xinlei Lee <xinlei.lee@mediatek.com>
Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Rex-BC Chen (陳柏辰) April 13, 2023, 7:27 a.m. UTC | #1
Hello Xinlei,

IMO, [2/3] is weird because the driver_data for mt8186 and mt8188 are
the same in [2/3]. So I think [2/3] coulde be squashed into this patch.

BRs,
Bo-Chen

On Thu, 2023-04-13 at 14:09 +0800, xinlei.lee@mediatek.com wrote:
> From: Xinlei Lee <xinlei.lee@mediatek.com>
> 
> For mt8188, add dsi cmdq reg control to send long packets to panel
> initialization.
> 
> Signed-off-by: Xinlei Lee <xinlei.lee@mediatek.com>
> Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 500a3054282d..cbfe5df4647c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -86,6 +86,7 @@
>  
>  #define DSI_CMDQ_SIZE		0x60
>  #define CMDQ_SIZE			0x3f
> +#define CMDQ_SIZE_SEL			BIT(15)
>  
>  #define DSI_HSTX_CKL_WC		0x64
>  
> @@ -178,6 +179,7 @@ struct mtk_dsi_driver_data {
>  	const u32 reg_cmdq_off;
>  	bool has_shadow_ctl;
>  	bool has_size_ctl;
> +	bool cmdq_long_packet_ctl;
>  };
>  
>  struct mtk_dsi {
> @@ -965,6 +967,11 @@ static u32 mtk_dsi_recv_cnt(u8 type, u8
> *read_data)
>  	return 0;
>  }
>  
> +static void mtk_dsi_cmd_packet_ctl(struct mtk_dsi *dsi)
> +{
> +	mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE_SEL, CMDQ_SIZE_SEL);
> +}
> +
>  static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct
> mipi_dsi_msg *msg)
>  {
>  	const char *tx_buf = msg->tx_buf;
> @@ -996,6 +1003,8 @@ static void mtk_dsi_cmdq(struct mtk_dsi *dsi,
> const struct mipi_dsi_msg *msg)
>  
>  	mtk_dsi_mask(dsi, reg_cmdq_off, cmdq_mask, reg_val);
>  	mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE, cmdq_size);
> +	if (dsi->driver_data->cmdq_long_packet_ctl)
> +		mtk_dsi_cmd_packet_ctl(dsi);
>  }
>  
>  static ssize_t mtk_dsi_host_send_cmd(struct mtk_dsi *dsi,
> @@ -1200,18 +1209,21 @@ static const struct mtk_dsi_driver_data
> mt8183_dsi_driver_data = {
>  	.reg_cmdq_off = 0x200,
>  	.has_shadow_ctl = true,
>  	.has_size_ctl = true,
> +	.cmdq_long_packet_ctl = false,
>  };
>  
>  static const struct mtk_dsi_driver_data mt8186_dsi_driver_data = {
>  	.reg_cmdq_off = 0xd00,
>  	.has_shadow_ctl = true,
>  	.has_size_ctl = true,
> +	.cmdq_long_packet_ctl = false,
>  };
>  
>  static const struct mtk_dsi_driver_data mt8188_dsi_driver_data = {
>  	.reg_cmdq_off = 0xd00,
>  	.has_shadow_ctl = true,
>  	.has_size_ctl = true,
> +	.cmdq_long_packet_ctl = true,
>  };
>  
>  static const struct of_device_id mtk_dsi_of_match[] = {
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 500a3054282d..cbfe5df4647c 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -86,6 +86,7 @@ 
 
 #define DSI_CMDQ_SIZE		0x60
 #define CMDQ_SIZE			0x3f
+#define CMDQ_SIZE_SEL			BIT(15)
 
 #define DSI_HSTX_CKL_WC		0x64
 
@@ -178,6 +179,7 @@  struct mtk_dsi_driver_data {
 	const u32 reg_cmdq_off;
 	bool has_shadow_ctl;
 	bool has_size_ctl;
+	bool cmdq_long_packet_ctl;
 };
 
 struct mtk_dsi {
@@ -965,6 +967,11 @@  static u32 mtk_dsi_recv_cnt(u8 type, u8 *read_data)
 	return 0;
 }
 
+static void mtk_dsi_cmd_packet_ctl(struct mtk_dsi *dsi)
+{
+	mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE_SEL, CMDQ_SIZE_SEL);
+}
+
 static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct mipi_dsi_msg *msg)
 {
 	const char *tx_buf = msg->tx_buf;
@@ -996,6 +1003,8 @@  static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct mipi_dsi_msg *msg)
 
 	mtk_dsi_mask(dsi, reg_cmdq_off, cmdq_mask, reg_val);
 	mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE, cmdq_size);
+	if (dsi->driver_data->cmdq_long_packet_ctl)
+		mtk_dsi_cmd_packet_ctl(dsi);
 }
 
 static ssize_t mtk_dsi_host_send_cmd(struct mtk_dsi *dsi,
@@ -1200,18 +1209,21 @@  static const struct mtk_dsi_driver_data mt8183_dsi_driver_data = {
 	.reg_cmdq_off = 0x200,
 	.has_shadow_ctl = true,
 	.has_size_ctl = true,
+	.cmdq_long_packet_ctl = false,
 };
 
 static const struct mtk_dsi_driver_data mt8186_dsi_driver_data = {
 	.reg_cmdq_off = 0xd00,
 	.has_shadow_ctl = true,
 	.has_size_ctl = true,
+	.cmdq_long_packet_ctl = false,
 };
 
 static const struct mtk_dsi_driver_data mt8188_dsi_driver_data = {
 	.reg_cmdq_off = 0xd00,
 	.has_shadow_ctl = true,
 	.has_size_ctl = true,
+	.cmdq_long_packet_ctl = true,
 };
 
 static const struct of_device_id mtk_dsi_of_match[] = {