Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions boards/shields/g1120b0mipi/boards/mimxrt595_evk_cm33.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2023, NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

/* Change deep sleep config for suspend mode to keep SMARTDMA ram powered,
* so the SMARTDMA will continue functioning after deep sleep
*/
&suspend {
deep-sleep-config = <0xC800>,
<0x80030004>,
<0xFFFFFFFF>,
<0>;
};
29 changes: 28 additions & 1 deletion drivers/display/display_rm67162.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/pm/policy.h>
#include <zephyr/pm/device.h>
#include <zephyr/sys/byteorder.h>

LOG_MODULE_REGISTER(rm67162, CONFIG_DISPLAY_LOG_LEVEL);
Expand Down Expand Up @@ -568,6 +569,31 @@ static int rm67162_set_orientation(const struct device *dev,
return -ENOTSUP;
}

#ifdef CONFIG_PM_DEVICE

static int rm67162_pm_action(const struct device *dev,
enum pm_device_action action)
{
const struct rm67162_config *config = dev->config;
struct rm67162_data *data = dev->data;
struct mipi_dsi_device mdev = {0};

mdev.data_lanes = config->num_of_lanes;
mdev.pixfmt = data->pixel_format;

switch (action) {
case PM_DEVICE_ACTION_SUSPEND:
/* Detach from the MIPI DSI controller */
return mipi_dsi_detach(config->mipi_dsi, config->channel, &mdev);
case PM_DEVICE_ACTION_RESUME:
return mipi_dsi_attach(config->mipi_dsi, config->channel, &mdev);
default:
return -ENOTSUP;
}
}

#endif /* CONFIG_PM_DEVICE */

static const struct display_driver_api rm67162_api = {
.blanking_on = rm67162_blanking_on,
.blanking_off = rm67162_blanking_off,
Expand All @@ -593,9 +619,10 @@ static const struct display_driver_api rm67162_api = {
static struct rm67162_data rm67162_data_##id = { \
.pixel_format = DT_INST_PROP(id, pixel_format), \
}; \
PM_DEVICE_DT_INST_DEFINE(id, rm67162_pm_action); \
DEVICE_DT_INST_DEFINE(id, \
&rm67162_init, \
NULL, \
PM_DEVICE_DT_INST_GET(id), \
&rm67162_data_##id, \
&rm67162_config_##id, \
POST_KERNEL, \
Expand Down
23 changes: 21 additions & 2 deletions drivers/mipi_dsi/dsi_mcux_2l.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ static int dsi_mcux_attach(const struct device *dev,
dsi_config.autoInsertEoTp = config->auto_insert_eotp;
dsi_config.enableNonContinuousHsClk = config->noncontinuous_hs_clk;

imxrt_pre_init_display_interface();

/* Init the DSI module. */
DSI_Init(config->base, &dsi_config);

Expand Down Expand Up @@ -344,6 +346,24 @@ static int dsi_mcux_attach(const struct device *dev,
return 0;
}

static int dsi_mcux_detach(const struct device *dev, uint8_t channel,
const struct mipi_dsi_device *mdev)
{
const struct mcux_mipi_dsi_config *config = dev->config;

/* Enable DPHY auto power down */
DSI_DeinitDphy(config->base);
/* Fully power off DPHY */
config->base->PD_DPHY = 0x1;
/* Deinit MIPI */
DSI_Deinit(config->base);
/* Call IMX RT clock function to gate clocks and power at SOC level */
imxrt_deinit_display_interface();
return 0;
}



static ssize_t dsi_mcux_transfer(const struct device *dev, uint8_t channel,
struct mipi_dsi_msg *msg)
{
Expand Down Expand Up @@ -434,6 +454,7 @@ static ssize_t dsi_mcux_transfer(const struct device *dev, uint8_t channel,

static struct mipi_dsi_driver_api dsi_mcux_api = {
.attach = dsi_mcux_attach,
.detach = dsi_mcux_detach,
.transfer = dsi_mcux_transfer,
};

Expand All @@ -449,8 +470,6 @@ static int mcux_mipi_dsi_init(const struct device *dev)

k_sem_init(&data->transfer_sem, 0, 1);

imxrt_pre_init_display_interface();

if (!device_is_ready(config->bit_clk_dev) ||
!device_is_ready(config->esc_clk_dev) ||
!device_is_ready(config->pixel_clk_dev)) {
Expand Down
26 changes: 26 additions & 0 deletions include/zephyr/drivers/mipi_dsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @ingroup io_interfaces
* @{
*/
#include <errno.h>
#include <sys/types.h>
#include <zephyr/device.h>
#include <zephyr/dt-bindings/mipi_dsi/mipi_dsi.h>
Expand Down Expand Up @@ -247,6 +248,8 @@ __subsystem struct mipi_dsi_driver_api {
const struct mipi_dsi_device *mdev);
ssize_t (*transfer)(const struct device *dev, uint8_t channel,
struct mipi_dsi_msg *msg);
int (*detach)(const struct device *dev, uint8_t channel,
const struct mipi_dsi_device *mdev);
};

/**
Expand Down Expand Up @@ -342,6 +345,29 @@ ssize_t mipi_dsi_dcs_read(const struct device *dev, uint8_t channel,
ssize_t mipi_dsi_dcs_write(const struct device *dev, uint8_t channel,
uint8_t cmd, const void *buf, size_t len);


/**
* @brief Detach a device from the MIPI-DSI bus
*
* @param dev MIPI-DSI host device.
* @param channel Device channel (VID).
* @param mdev MIPI-DSI device description.
*
* @return 0 on success, negative on error
*/
static inline int mipi_dsi_detach(const struct device *dev,
uint8_t channel,
const struct mipi_dsi_device *mdev)
{
const struct mipi_dsi_driver_api *api = (const struct mipi_dsi_driver_api *)dev->api;

if (api->detach == NULL) {
return -ENOSYS;
}

return api->detach(dev, channel, mdev);
}

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 11 additions & 0 deletions samples/drivers/display/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,14 @@ tests:
harness: console
harness_config:
fixture: fixture_display
sample.display.g1120b0mipi:
platform_allow: mimxrt595_evk_cm33
tags: display
harness: console
extra_args: SHIELD=g1120b0mipi
extra_configs:
- CONFIG_PM=y
- CONFIG_PM_DEVICE=y
- CONFIG_IDLE_STACK_SIZE=400
harness_config:
fixture: fixture_display
11 changes: 11 additions & 0 deletions soc/arm/nxp_imx/rt5xx/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,17 @@ void __weak imxrt_post_init_display_interface(void)
/* Deassert MIPI DPHY reset. */
RESET_ClearPeripheralReset(kMIPI_DSI_PHY_RST_SHIFT_RSTn);
}

void __weak imxrt_deinit_display_interface(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this weak?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is following the pattern established in ca19b40. Since our clock management on these SOCs is currently so inflexible, the idea is that a customer board can bypass the clock setup entirely in their custom board if needed. I've done some initial work to attempt to correct this with #62946, but this is currently the short-term solution we're using for this SOC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the attempt to fix this hack in #62946 :-)

{
/* Assert MIPI DPHY and DSI reset */
RESET_SetPeripheralReset(kMIPI_DSI_PHY_RST_SHIFT_RSTn);
RESET_SetPeripheralReset(kMIPI_DSI_CTRL_RST_SHIFT_RSTn);
/* Remove clock from DPHY */
CLOCK_AttachClk(kNONE_to_MIPI_DPHY_CLK);
}


#endif

/**
Expand Down
2 changes: 2 additions & 0 deletions soc/arm/nxp_imx/rt5xx/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
void imxrt_pre_init_display_interface(void);

void imxrt_post_init_display_interface(void);

void imxrt_deinit_display_interface(void);
#endif

#endif
Expand Down