drivers: mipi_dsi: initial support for MIPI-DSI drivers

Add initial support for MIPI-DSI drivers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2021-02-17 10:38:33 +01:00 committed by David Leach
commit 83cfd295b9
10 changed files with 567 additions and 0 deletions

View file

@ -50,6 +50,7 @@ add_subdirectory_ifdef(CONFIG_VIRTUALIZATION virtualization)
add_subdirectory_ifdef(CONFIG_PM_CPU_OPS pm_cpu_ops)
add_subdirectory_ifdef(CONFIG_POWER_DOMAIN power_domain)
add_subdirectory_ifdef(CONFIG_DAI dai)
add_subdirectory_ifdef(CONFIG_MIPI_DSI mipi_dsi)
add_subdirectory_ifdef(CONFIG_FLASH_HAS_DRIVER_ENABLED flash)
add_subdirectory_ifdef(CONFIG_SERIAL_HAS_DRIVER serial)
add_subdirectory_ifdef(CONFIG_BT_DRIVERS bluetooth)

View file

@ -139,4 +139,6 @@ source "drivers/usbc/Kconfig"
source "drivers/reset/Kconfig"
source "drivers/mipi_dsi/Kconfig"
endmenu

View file

@ -0,0 +1 @@
zephyr_sources_ifdef(CONFIG_MIPI_DSI mipi_dsi.c)

24
drivers/mipi_dsi/Kconfig Normal file
View file

@ -0,0 +1,24 @@
# Memory controller configuration options
# Copyright (c) 2020 Teslabs Engineering S.L.
# SPDX-License-Identifier: Apache-2.0
menuconfig MIPI_DSI
bool "MIPI-DSI Host Controllers [EXPERIMENTAL]"
select EXPERIMENTAL
help
Add support for MIPI-DSI host controllers
if MIPI_DSI
module = MIPI_DSI
module-str = mipi_dsi
source "subsys/logging/Kconfig.template.log_config"
config MIPI_DSI_INIT_PRIORITY
int "Initialization priority"
default 40
help
MIPI-DSI Host Controllers initialization priority.
endif

106
drivers/mipi_dsi/mipi_dsi.c Normal file
View file

@ -0,0 +1,106 @@
/*
* Copyright (c) 2020 Teslabs Engineering S.L.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/drivers/mipi_dsi.h>
ssize_t mipi_dsi_generic_read(const struct device *dev, uint8_t channel,
const void *params, size_t nparams,
void *buf, size_t len)
{
struct mipi_dsi_msg msg = {
.tx_len = nparams,
.tx_buf = params,
.rx_len = len,
.rx_buf = buf
};
switch (nparams) {
case 0U:
msg.type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
break;
case 1U:
msg.type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
break;
case 2U:
msg.type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
break;
default:
return -EINVAL;
}
return mipi_dsi_transfer(dev, channel, &msg);
}
ssize_t mipi_dsi_generic_write(const struct device *dev, uint8_t channel,
const void *buf, size_t len)
{
struct mipi_dsi_msg msg = {
.tx_buf = buf,
.tx_len = len
};
switch (len) {
case 0U:
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
break;
case 1U:
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
break;
case 2U:
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
break;
default:
msg.type = MIPI_DSI_GENERIC_LONG_WRITE;
break;
}
return mipi_dsi_transfer(dev, channel, &msg);
}
ssize_t mipi_dsi_dcs_read(const struct device *dev, uint8_t channel,
uint8_t cmd, void *buf, size_t len)
{
struct mipi_dsi_msg msg = {
.type = MIPI_DSI_DCS_READ,
.cmd = cmd,
.rx_buf = buf,
.rx_len = len
};
return mipi_dsi_transfer(dev, channel, &msg);
}
ssize_t mipi_dsi_dcs_write(const struct device *dev, uint8_t channel,
uint8_t cmd, const void *buf, size_t len)
{
struct mipi_dsi_msg msg = {
.cmd = cmd,
.tx_buf = buf,
.tx_len = len
};
switch (len) {
case 0U:
msg.type = MIPI_DSI_DCS_SHORT_WRITE;
break;
case 1U:
msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;
break;
default:
msg.type = MIPI_DSI_DCS_LONG_WRITE;
break;
}
return mipi_dsi_transfer(dev, channel, &msg);
}