static int dw_mipi_dsi_dcs_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); if (msg->tx_len > 2) { dev_err(dsi->dev, "too long tx buf length %zu for short write\n", msg->tx_len); return -EINVAL; } 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) { const u8 *tx_buf = msg->tx_buf; int len = msg->tx_len, pld_data_bytes = sizeof(u32), ret; u32 hdr_val = GEN_HDATA(msg->tx_len) | GEN_HTYPE(msg->type); u32 remainder; u32 val; if (msg->tx_len < 3) { DRM_DEV_ERROR(dsi->dev, "wrong tx buf length %zu for long write\n", msg->tx_len); return -EINVAL; } while (DIV_ROUND_UP(len, pld_data_bytes)) { if (len < pld_data_bytes) { remainder = 0; memcpy(&remainder, tx_buf, len); dsi_write(dsi, DSI_GEN_PLD_DATA, remainder); len = 0; } else { memcpy(&remainder, tx_buf, pld_data_bytes); dsi_write(dsi, DSI_GEN_PLD_DATA, remainder); tx_buf += pld_data_bytes; len -= pld_data_bytes; } ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS, val, !(val & GEN_PLD_W_FULL), 1000, CMD_PKT_STATUS_TIMEOUT_US); if (ret < 0) { DRM_DEV_ERROR(dsi->dev, "failed to get available write payload FIFO\n"); return ret; } } return dw_mipi_dsi_gen_pkt_hdr_write(dsi, hdr_val); }
static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, const struct mipi_dsi_msg *msg) { const u8 *tx_buf = msg->tx_buf; u16 data = 0; u32 val; if (msg->tx_len > 0) data |= tx_buf[0]; if (msg->tx_len > 1) data |= tx_buf[1] << 8; if (msg->tx_len > 2) { DRM_DEV_ERROR(dsi->dev, "too long tx buf length %zu for short write\n", msg->tx_len); return -EINVAL; } val = GEN_HDATA(data) | GEN_HTYPE(msg->type); return dw_mipi_dsi_gen_pkt_hdr_write(dsi, val); }