From 4844d015a4dbca4fe9314c531240826250b60142 Mon Sep 17 00:00:00 2001 From: "Mike J. Chen" Date: Fri, 6 Oct 2023 12:23:04 -0700 Subject: [PATCH] drivers: mipi_dsi: dsi_mcux_2l add msg flag for low power mode Previous version of dsi_mcux_2l hardcoded some MIPI DSI transfers to use high speed mode but others used low power mode. Now dsi_mcux_2l will use high speed mode by default for all transfers unless a new msg flag is set to indicate the transfer must use low power mode. Note that the new flag is different than the existing MIPI_DSI_MODE_LPM flag, which so far only applied to cmd messages sent in video mode, or could be interpreted as for all messages, but would not allow per message mode control. This new message flag allows client to control transfer mode per message transfer. Signed-off-by: Mike J. Chen --- drivers/mipi_dsi/dsi_mcux_2l.c | 6 ++++-- include/zephyr/drivers/mipi_dsi.h | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mipi_dsi/dsi_mcux_2l.c b/drivers/mipi_dsi/dsi_mcux_2l.c index 934f267e188331..3c51eb4d8c46e8 100644 --- a/drivers/mipi_dsi/dsi_mcux_2l.c +++ b/drivers/mipi_dsi/dsi_mcux_2l.c @@ -162,7 +162,8 @@ static int dsi_mcux_tx_color(const struct device *dev, uint8_t channel, .sendDscCmd = true, .dscCmd = msg->cmd, .txDataType = kDSI_TxDataDcsLongWr, - .flags = kDSI_TransferUseHighSpeed, + /* default to high speed unless told to use low power */ + .flags = (msg->flags & MIPI_DSI_MSG_USE_LPM) ? 0 : kDSI_TransferUseHighSpeed, }; /* @@ -354,6 +355,8 @@ static ssize_t dsi_mcux_transfer(const struct device *dev, uint8_t channel, dsi_xfer.txData = msg->tx_buf; dsi_xfer.rxDataSize = msg->rx_len; dsi_xfer.rxData = msg->rx_buf; + /* default to high speed unless told to use low power */ + dsi_xfer.flags = (msg->flags & MIPI_DSI_MSG_USE_LPM) ? 0 : kDSI_TransferUseHighSpeed; switch (msg->type) { case MIPI_DSI_DCS_READ: @@ -373,7 +376,6 @@ static ssize_t dsi_mcux_transfer(const struct device *dev, uint8_t channel, dsi_xfer.sendDscCmd = true; dsi_xfer.dscCmd = msg->cmd; dsi_xfer.txDataType = kDSI_TxDataDcsLongWr; - dsi_xfer.flags = kDSI_TransferUseHighSpeed; if (msg->flags & MCUX_DSI_2L_FB_DATA) { /* * Special case- transfer framebuffer data using diff --git a/include/zephyr/drivers/mipi_dsi.h b/include/zephyr/drivers/mipi_dsi.h index 6373c1010f09a1..d26854fc1a6f90 100644 --- a/include/zephyr/drivers/mipi_dsi.h +++ b/include/zephyr/drivers/mipi_dsi.h @@ -217,6 +217,12 @@ struct mipi_dsi_device { uint32_t mode_flags; }; +/* + * Per message flag to indicate the message must be sent + * using Low Power Mode instead of controller default. + */ +#define MIPI_DSI_MSG_USE_LPM BIT(0x0) + /** MIPI-DSI read/write message. */ struct mipi_dsi_msg { /** Payload data type. */