/* * Copyright 2022, NXP * * SPDX-License-Identifier: Apache-2.0 */ #define DT_DRV_COMPAT raydium_rm68200 #include #include #include #include #include LOG_MODULE_REGISTER(rm68200, CONFIG_DISPLAY_LOG_LEVEL); /* DCS Commands */ #define DCS_CMD_PAGE 0xFE #define DCS_CMD_PAGE_UCS 0x0 #define DCS_CMD_PAGE_SET_PAGE0 0x1 #define DCS_CMD_PAGE_SET_PAGE1 0x2 #define DCS_CMD_PAGE_SET_PAGE2 0x3 #define DCS_CMD_PAGE_SET_PAGE3 0x4 /* MCS Commands */ #define MCS_STBCTR 0x12 #define MCS_SGOPCTR 0x16 #define MCS_SDCTR 0x1A #define MCS_INVCTR 0x1B #define MCS_EXT_PWR_IC_TYPE 0x24 #define MCS_EXT_PWR_SET_AVDD 0x25 #define MCS_AVEE_FROM_PFM 0x26 #define MCS_AVDD_FROM_PFM 0x27 #define MCS_SETAVEE 0x29 #define MCS_BT2CTR 0x2B #define MCS_BT3CTR 0x2F #define MCS_BT4CTR 0x34 #define MCS_VCMCTR 0x46 #define MCS_SETVGMN 0x52 #define MCS_SETVGSN 0x53 #define MCS_SETVGMP 0x54 #define MCS_SETVGSP 0x55 #define MCS_SW_CTRL 0x5F #define MCS_GAMMA_VP1 0x60 #define MCS_GAMMA_VP4 0x61 #define MCS_GAMMA_VP8 0x62 #define MCS_GAMMA_VP16 0x63 #define MCS_GAMMA_VP24 0x64 #define MCS_GAMMA_VP52 0x65 #define MCS_GAMMA_VP80 0x66 #define MCS_GAMMA_VP108 0x67 #define MCS_GAMMA_VP147 0x68 #define MCS_GAMMA_VP175 0x69 #define MCS_GAMMA_VP203 0x6A #define MCS_GAMMA_VP231 0x6B #define MCS_GAMMA_VP239 0x6C #define MCS_GAMMA_VP247 0x6D #define MCS_GAMMA_VP251 0x6E #define MCS_GAMMA_VP255 0x6F #define MCS_GAMMA_VN1 0x70 #define MCS_GAMMA_VN4 0x71 #define MCS_GAMMA_VN8 0x72 #define MCS_GAMMA_VN16 0x73 #define MCS_GAMMA_VN24 0x74 #define MCS_GAMMA_VN52 0x75 #define MCS_GAMMA_VN80 0x76 #define MCS_GAMMA_VN108 0x77 #define MCS_GAMMA_VN147 0x78 #define MCS_GAMMA_VN175 0x79 #define MCS_GAMMA_VN203 0x7A #define MCS_GAMMA_VN231 0x7B #define MCS_GAMMA_VN239 0x7C #define MCS_GAMMA_VN247 0x7D #define MCS_GAMMA_VN251 0x7E #define MCS_GAMMA_VN255 0x7F #define MCS_GAMMA_UPDATE 0x80 struct rm68200_config { const struct device *mipi_dsi; const struct gpio_dt_spec reset_gpio; const struct gpio_dt_spec bl_gpio; uint8_t num_of_lanes; uint8_t pixel_format; uint16_t panel_width; uint16_t panel_height; uint8_t channel; }; static int rm68200_dcs_write(const struct device *dev, uint8_t cmd, uint8_t *buf, uint8_t len) { const struct rm68200_config *config = dev->config; return mipi_dsi_dcs_write(config->mipi_dsi, config->channel, cmd, buf, len); } static int rm68200_write(const struct device *dev, const uint16_t x, const uint16_t y, const struct display_buffer_descriptor *desc, const void *buf) { return 0; } static int rm68200_blanking_off(const struct device *dev) { const struct rm68200_config *config = dev->config; if (config->bl_gpio.port != NULL) { return gpio_pin_set_dt(&config->bl_gpio, 1); } else { return -ENOTSUP; } } static int rm68200_blanking_on(const struct device *dev) { const struct rm68200_config *config = dev->config; if (config->bl_gpio.port != NULL) { return gpio_pin_set_dt(&config->bl_gpio, 0); } else { return -ENOTSUP; } } static int rm68200_set_pixel_format(const struct device *dev, const enum display_pixel_format pixel_format) { const struct rm68200_config *config = dev->config; if (pixel_format == config->pixel_format) { return 0; } LOG_ERR("Pixel format change not implemented"); return -ENOTSUP; } static int rm68200_set_orientation(const struct device *dev, const enum display_orientation orientation) { if (orientation == DISPLAY_ORIENTATION_NORMAL) { return 0; } LOG_ERR("Changing display orientation not implemented"); return -ENOTSUP; } static void rm68200_get_capabilities(const struct device *dev, struct display_capabilities *capabilities) { const struct rm68200_config *config = dev->config; memset(capabilities, 0, sizeof(struct display_capabilities)); capabilities->x_resolution = config->panel_width; capabilities->y_resolution = config->panel_height; capabilities->supported_pixel_formats = config->pixel_format; capabilities->current_pixel_format = config->pixel_format; capabilities->current_orientation = DISPLAY_ORIENTATION_NORMAL; } static DEVICE_API(display, rm68200_api) = { .blanking_on = rm68200_blanking_on, .blanking_off = rm68200_blanking_off, .write = rm68200_write, .get_capabilities = rm68200_get_capabilities, .set_pixel_format = rm68200_set_pixel_format, .set_orientation = rm68200_set_orientation, }; static int rm68200_init(const struct device *dev) { const struct rm68200_config *config = dev->config; uint8_t param; int ret; struct mipi_dsi_device mdev; mdev.data_lanes = config->num_of_lanes; mdev.pixfmt = config->pixel_format; /* RM68200 runs in video mode */ mdev.mode_flags = MIPI_DSI_MODE_VIDEO; ret = mipi_dsi_attach(config->mipi_dsi, config->channel, &mdev); if (ret < 0) { LOG_ERR("Could not attach to MIPI-DSI host"); return ret; } if (config->reset_gpio.port != NULL) { ret = gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE); if (ret < 0) { LOG_ERR("Could not configure reset GPIO (%d)", ret); return ret; } /* Power to the display has been enabled via the regulator fixed api during * regulator init. * reset:0 -> reset:1 */ gpio_pin_set_dt(&config->reset_gpio, 0); /* Per datasheet, reset low pulse width should be at least 15usec */ k_sleep(K_USEC(50)); gpio_pin_set_dt(&config->reset_gpio, 1); /* Per datasheet, it is necessary to wait 5msec after releasing reset */ k_sleep(K_MSEC(5)); } param = DCS_CMD_PAGE_SET_PAGE0; rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1); param = 0xC0; rm68200_dcs_write(dev, MCS_EXT_PWR_IC_TYPE, ¶m, 1); param = 0x53; rm68200_dcs_write(dev, MCS_EXT_PWR_SET_AVDD, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_AVEE_FROM_PFM, ¶m, 1); param = 0xE5; rm68200_dcs_write(dev, MCS_BT2CTR, ¶m, 1); param = 0x0A; rm68200_dcs_write(dev, MCS_AVDD_FROM_PFM, ¶m, 1); param = 0x0A; rm68200_dcs_write(dev, MCS_SETAVEE, ¶m, 1); param = 0x52; rm68200_dcs_write(dev, MCS_SGOPCTR, ¶m, 1); param = 0x53; rm68200_dcs_write(dev, MCS_BT3CTR, ¶m, 1); param = 0x5A; rm68200_dcs_write(dev, MCS_BT4CTR, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_INVCTR, ¶m, 1); param = 0x0A; rm68200_dcs_write(dev, MCS_STBCTR, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, MCS_SDCTR, ¶m, 1); param = 0x56; rm68200_dcs_write(dev, MCS_VCMCTR, ¶m, 1); param = 0xA0; rm68200_dcs_write(dev, MCS_SETVGMN, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_SETVGSN, ¶m, 1); param = 0xA0; rm68200_dcs_write(dev, MCS_SETVGMP, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_SETVGSP, ¶m, 1); param = 0x10U | (config->num_of_lanes - 1U); rm68200_dcs_write(dev, MCS_SW_CTRL, ¶m, 1); param = DCS_CMD_PAGE_SET_PAGE2; rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1); /* There is no description for the below registers in the datasheet */ param = 0x05; rm68200_dcs_write(dev, 0x00, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, 0x02, ¶m, 1); param = 0x0F; rm68200_dcs_write(dev, 0x03, ¶m, 1); param = 0x7D; rm68200_dcs_write(dev, 0x04, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x05, ¶m, 1); param = 0x50; rm68200_dcs_write(dev, 0x06, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0x07, ¶m, 1); param = 0x16; rm68200_dcs_write(dev, 0x08, ¶m, 1); param = 0x0D; rm68200_dcs_write(dev, 0x09, ¶m, 1); param = 0x11; rm68200_dcs_write(dev, 0x0A, ¶m, 1); param = 0x7D; rm68200_dcs_write(dev, 0x0B, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x0C, ¶m, 1); param = 0x50; rm68200_dcs_write(dev, 0x0D, ¶m, 1); param = 0x07; rm68200_dcs_write(dev, 0x0E, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x0F, ¶m, 1); param = 0x01; rm68200_dcs_write(dev, 0x10, ¶m, 1); param = 0x02; rm68200_dcs_write(dev, 0x11, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x12, ¶m, 1); param = 0x7D; rm68200_dcs_write(dev, 0x13, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x14, ¶m, 1); param = 0x85; rm68200_dcs_write(dev, 0x15, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x16, ¶m, 1); param = 0x03; rm68200_dcs_write(dev, 0x17, ¶m, 1); param = 0x04; rm68200_dcs_write(dev, 0x18, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0x19, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, 0x1A, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x1B, ¶m, 1); param = 0x7D; rm68200_dcs_write(dev, 0x1C, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x1D, ¶m, 1); param = 0x85; rm68200_dcs_write(dev, 0x1E, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x1F, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x20, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x21, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x22, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x23, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x24, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x25, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x26, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x27, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x28, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x29, ¶m, 1); param = 0x07; rm68200_dcs_write(dev, 0x2A, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x2B, ¶m, 1); param = 0x01; rm68200_dcs_write(dev, 0x2D, ¶m, 1); param = 0x02; rm68200_dcs_write(dev, 0x2F, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x30, ¶m, 1); param = 0x40; rm68200_dcs_write(dev, 0x31, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0x32, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x33, ¶m, 1); param = 0x54; rm68200_dcs_write(dev, 0x34, ¶m, 1); param = 0x7D; rm68200_dcs_write(dev, 0x35, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x36, ¶m, 1); param = 0x03; rm68200_dcs_write(dev, 0x37, ¶m, 1); param = 0x04; rm68200_dcs_write(dev, 0x38, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0x39, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, 0x3A, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x3B, ¶m, 1); param = 0x40; rm68200_dcs_write(dev, 0x3D, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0x3F, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x40, ¶m, 1); param = 0x54; rm68200_dcs_write(dev, 0x41, ¶m, 1); param = 0x7D; rm68200_dcs_write(dev, 0x42, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x43, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x44, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x45, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x46, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x47, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x48, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x49, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x4A, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x4B, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x4C, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x4D, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x4E, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x4F, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x50, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x51, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x52, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x53, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x54, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x55, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x56, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x58, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x59, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x5A, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x5B, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x5C, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x5D, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x5E, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x5F, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x60, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x61, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x62, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x63, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x64, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x65, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x66, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x67, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x68, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x69, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x6A, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x6B, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x6C, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x6D, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x6E, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x6F, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x70, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x71, ¶m, 1); param = 0x20; rm68200_dcs_write(dev, 0x72, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x73, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x74, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x75, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x76, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x77, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x78, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x79, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x7A, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x7B, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x7C, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x7D, ¶m, 1); param = 0xBF; rm68200_dcs_write(dev, 0x7E, ¶m, 1); param = 0x02; rm68200_dcs_write(dev, 0x7F, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, 0x80, ¶m, 1); param = 0x14; rm68200_dcs_write(dev, 0x81, ¶m, 1); param = 0x10; rm68200_dcs_write(dev, 0x82, ¶m, 1); param = 0x16; rm68200_dcs_write(dev, 0x83, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, 0x84, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0x85, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x86, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x87, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x88, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x89, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x8A, ¶m, 1); param = 0x0C; rm68200_dcs_write(dev, 0x8B, ¶m, 1); param = 0x0A; rm68200_dcs_write(dev, 0x8C, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, 0x8D, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x8E, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x8F, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0x90, ¶m, 1); param = 0x04; rm68200_dcs_write(dev, 0x91, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x92, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x93, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x94, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x95, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0x96, ¶m, 1); param = 0x01; rm68200_dcs_write(dev, 0x97, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x98, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x99, ¶m, 1); param = 0x0F; rm68200_dcs_write(dev, 0x9A, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, 0x9B, ¶m, 1); param = 0x0D; rm68200_dcs_write(dev, 0x9C, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x9D, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x9E, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0x9F, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xA0, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xA2, ¶m, 1); param = 0x09; rm68200_dcs_write(dev, 0xA3, ¶m, 1); param = 0x13; rm68200_dcs_write(dev, 0xA4, ¶m, 1); param = 0x17; rm68200_dcs_write(dev, 0xA5, ¶m, 1); param = 0x11; rm68200_dcs_write(dev, 0xA6, ¶m, 1); param = 0x15; rm68200_dcs_write(dev, 0xA7, ¶m, 1); param = 0x07; rm68200_dcs_write(dev, 0xA9, ¶m, 1); param = 0x03; rm68200_dcs_write(dev, 0xAA, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xAB, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xAC, ¶m, 1); param = 0x05; rm68200_dcs_write(dev, 0xAD, ¶m, 1); param = 0x01; rm68200_dcs_write(dev, 0xAE, ¶m, 1); param = 0x17; rm68200_dcs_write(dev, 0xAF, ¶m, 1); param = 0x13; rm68200_dcs_write(dev, 0xB0, ¶m, 1); param = 0x15; rm68200_dcs_write(dev, 0xB1, ¶m, 1); param = 0x11; rm68200_dcs_write(dev, 0xB2, ¶m, 1); param = 0x0F; rm68200_dcs_write(dev, 0xB3, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xB4, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xB5, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xB6, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xB7, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xB8, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, 0xB9, ¶m, 1); param = 0x0D; rm68200_dcs_write(dev, 0xBA, ¶m, 1); param = 0x09; rm68200_dcs_write(dev, 0xBB, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xBC, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xBD, ¶m, 1); param = 0x07; rm68200_dcs_write(dev, 0xBE, ¶m, 1); param = 0x03; rm68200_dcs_write(dev, 0xBF, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xC0, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xC1, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xC2, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xC3, ¶m, 1); param = 0x02; rm68200_dcs_write(dev, 0xC4, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, 0xC5, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xC6, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xC7, ¶m, 1); param = 0x08; rm68200_dcs_write(dev, 0xC8, ¶m, 1); param = 0x0C; rm68200_dcs_write(dev, 0xC9, ¶m, 1); param = 0x0A; rm68200_dcs_write(dev, 0xCA, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xCB, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xCC, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xCD, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xCE, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xCF, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, 0xD0, ¶m, 1); param = 0x10; rm68200_dcs_write(dev, 0xD1, ¶m, 1); param = 0x14; rm68200_dcs_write(dev, 0xD2, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, 0xD3, ¶m, 1); param = 0x16; rm68200_dcs_write(dev, 0xD4, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, 0xD5, ¶m, 1); param = 0x04; rm68200_dcs_write(dev, 0xD6, ¶m, 1); param = 0x3F; rm68200_dcs_write(dev, 0xD7, ¶m, 1); param = 0x02; rm68200_dcs_write(dev, 0xDC, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, 0xDE, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1); param = 0x75; rm68200_dcs_write(dev, 0x01, ¶m, 1); /* Gamma Settings */ param = DCS_CMD_PAGE_SET_PAGE3; rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_GAMMA_VP1, ¶m, 1); param = 0x0C; rm68200_dcs_write(dev, MCS_GAMMA_VP4, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, MCS_GAMMA_VP8, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, MCS_GAMMA_VP16, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, MCS_GAMMA_VP24, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, MCS_GAMMA_VP52, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, MCS_GAMMA_VP80, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, MCS_GAMMA_VP108, ¶m, 1); param = 0x15; rm68200_dcs_write(dev, MCS_GAMMA_VP147, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, MCS_GAMMA_VP175, ¶m, 1); param = 0x10; rm68200_dcs_write(dev, MCS_GAMMA_VP203, ¶m, 1); param = 0x07; rm68200_dcs_write(dev, MCS_GAMMA_VP231, ¶m, 1); param = 0x0F; rm68200_dcs_write(dev, MCS_GAMMA_VP239, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, MCS_GAMMA_VP247, ¶m, 1); param = 0x0C; rm68200_dcs_write(dev, MCS_GAMMA_VP251, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_GAMMA_VP255, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_GAMMA_VN1, ¶m, 1); param = 0x0C; rm68200_dcs_write(dev, MCS_GAMMA_VN4, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, MCS_GAMMA_VN8, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, MCS_GAMMA_VN16, ¶m, 1); param = 0x06; rm68200_dcs_write(dev, MCS_GAMMA_VN24, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, MCS_GAMMA_VN52, ¶m, 1); param = 0x0E; rm68200_dcs_write(dev, MCS_GAMMA_VN80, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, MCS_GAMMA_VN108, ¶m, 1); param = 0x15; rm68200_dcs_write(dev, MCS_GAMMA_VN147, ¶m, 1); param = 0x0B; rm68200_dcs_write(dev, MCS_GAMMA_VN175, ¶m, 1); param = 0x10; rm68200_dcs_write(dev, MCS_GAMMA_VN203, ¶m, 1); param = 0x07; rm68200_dcs_write(dev, MCS_GAMMA_VN231, ¶m, 1); param = 0x0F; rm68200_dcs_write(dev, MCS_GAMMA_VN239, ¶m, 1); param = 0x12; rm68200_dcs_write(dev, MCS_GAMMA_VN247, ¶m, 1); param = 0x0C; rm68200_dcs_write(dev, MCS_GAMMA_VN251, ¶m, 1); param = 0x00; rm68200_dcs_write(dev, MCS_GAMMA_VN255, ¶m, 1); /* Page 0 */ param = DCS_CMD_PAGE_UCS; rm68200_dcs_write(dev, DCS_CMD_PAGE, ¶m, 1); rm68200_dcs_write(dev, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); k_sleep(K_MSEC(200)); rm68200_dcs_write(dev, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); k_sleep(K_MSEC(100)); rm68200_dcs_write(dev, MIPI_DCS_WRITE_MEMORY_START, NULL, 0); param = 0x00; rm68200_dcs_write(dev, MIPI_DCS_SET_TEAR_ON, ¶m, 1); k_sleep(K_MSEC(200)); if (config->bl_gpio.port != NULL) { ret = gpio_pin_configure_dt(&config->bl_gpio, GPIO_OUTPUT_ACTIVE); if (ret < 0) { LOG_ERR("Could not configure bl GPIO (%d)", ret); return ret; } } return 0; } #define RM68200_PANEL(id) \ static const struct rm68200_config rm68200_config_##id = { \ .mipi_dsi = DEVICE_DT_GET(DT_INST_BUS(id)), \ .reset_gpio = GPIO_DT_SPEC_INST_GET_OR(id, reset_gpios, {0}), \ .bl_gpio = GPIO_DT_SPEC_INST_GET_OR(id, bl_gpios, {0}), \ .num_of_lanes = DT_INST_PROP_BY_IDX(id, data_lanes, 0), \ .pixel_format = DT_INST_PROP(id, pixel_format), \ .panel_width = DT_INST_PROP(id, width), \ .panel_height = DT_INST_PROP(id, height), \ .channel = DT_INST_REG_ADDR(id), \ }; \ DEVICE_DT_INST_DEFINE(id, \ &rm68200_init, \ NULL, \ NULL, \ &rm68200_config_##id, \ POST_KERNEL, \ CONFIG_APPLICATION_INIT_PRIORITY, \ &rm68200_api); DT_INST_FOREACH_STATUS_OKAY(RM68200_PANEL)