From: xubilv Date: Thu, 13 Oct 2016 09:47:57 +0000 (+0800) Subject: drm/rockchip: mipi: dsi: add send mipi command function X-Git-Tag: firefly_0821_release~1404 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0113511f347bc46aa2445b7bc33c3cc4c2187c59;p=firefly-linux-kernel-4.4.55.git drm/rockchip: mipi: dsi: add send mipi command function Change-Id: If0699d8d5a42320ba064b698486a912794dfbfb7 Signed-off-by: xubilv --- diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 6115e81dbfb7..69e8b35b6fab 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -574,10 +574,12 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val) { int ret; + int sts = 0; ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS, - val, !(val & GEN_CMD_FULL), 1000, + sts, !(sts & GEN_CMD_FULL), 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret < 0) { dev_err(dsi->dev, "failed to get available command FIFO\n"); return ret; @@ -586,8 +588,9 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val) dsi_write(dsi, DSI_GEN_HDR, val); ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS, - val, val & (GEN_CMD_EMPTY | GEN_PLD_W_EMPTY), + sts, sts & (GEN_CMD_EMPTY | GEN_PLD_W_EMPTY), 1000, CMD_PKT_STATUS_TIMEOUT_US); + if (ret < 0) { dev_err(dsi->dev, "failed to write command FIFO\n"); return ret; @@ -596,8 +599,8 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 val) return 0; } -static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, - const struct mipi_dsi_msg *msg) +static int dw_mipi_dsi_short_write(struct dw_mipi_dsi *dsi, + const struct mipi_dsi_msg *msg) { const u16 *tx_buf = msg->tx_buf; u32 val = GEN_HDATA(*tx_buf) | GEN_HTYPE(msg->type); @@ -611,13 +614,14 @@ static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, return dw_mipi_dsi_gen_pkt_hdr_write(dsi, val); } -static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi, - const struct mipi_dsi_msg *msg) +static int dw_mipi_dsi_long_write(struct dw_mipi_dsi *dsi, + const struct mipi_dsi_msg *msg) { const u32 *tx_buf = msg->tx_buf; int len = msg->tx_len, pld_data_bytes = sizeof(*tx_buf), ret; u32 val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type); u32 remainder = 0; + u32 sts = 0; if (msg->tx_len < 3) { dev_err(dsi->dev, "wrong tx buf length %zu for long write\n", @@ -637,7 +641,7 @@ static int dw_mipi_dsi_dcs_long_write(struct dw_mipi_dsi *dsi, } ret = readx_poll_timeout(readl, dsi->base + DSI_CMD_PKT_STATUS, - val, !(val & GEN_PLD_W_FULL), 1000, + sts, !(sts & GEN_PLD_W_FULL), 1000, CMD_PKT_STATUS_TIMEOUT_US); if (ret < 0) { dev_err(dsi->dev, @@ -658,11 +662,15 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, switch (msg->type) { case MIPI_DSI_DCS_SHORT_WRITE: case MIPI_DSI_DCS_SHORT_WRITE_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: - ret = dw_mipi_dsi_dcs_short_write(dsi, msg); + ret = dw_mipi_dsi_short_write(dsi, msg); break; case MIPI_DSI_DCS_LONG_WRITE: - ret = dw_mipi_dsi_dcs_long_write(dsi, msg); + case MIPI_DSI_GENERIC_LONG_WRITE: + ret = dw_mipi_dsi_long_write(dsi, msg); break; default: dev_err(dsi->dev, "unsupported message type\n");