// SPDX-License-Identifier: GPL-2.0
/*
* Driver for panels based on Himax HX8394 controller, such as:
*
* - HannStar HSD060BHW4 5.99" MIPI-DSI panel
*
* Copyright (C) 2021 Kamil Trzciński
*
* Based on drivers/gpu/drm/panel/panel-sitronix-st7703.c
* Copyright (C) Purism SPC 2019
*/
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/media-bus-format.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/regulator/consumer.h>
#include <video/mipi_display.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>
#define DRV_NAME "panel-himax-hx8394"
/* Manufacturer specific commands sent via DSI, listed in HX8394-F datasheet */
#define HX8394_CMD_SETSEQUENCE 0 xb0
#define HX8394_CMD_SETPOWER 0 xb1
#define HX8394_CMD_SETDISP 0 xb2
#define HX8394_CMD_SETCYC 0 xb4
#define HX8394_CMD_SETVCOM 0 xb6
#define HX8394_CMD_SETTE 0 xb7
#define HX8394_CMD_SETSENSOR 0 xb8
#define HX8394_CMD_SETEXTC 0 xb9
#define HX8394_CMD_SETMIPI 0 xba
#define HX8394_CMD_SETOTP 0 xbb
#define HX8394_CMD_SETREGBANK 0 xbd
#define HX8394_CMD_UNKNOWN5 0 xbf
#define HX8394_CMD_UNKNOWN1 0 xc0
#define HX8394_CMD_SETDGCLUT 0 xc1
#define HX8394_CMD_SETID 0 xc3
#define HX8394_CMD_SETDDB 0 xc4
#define HX8394_CMD_UNKNOWN2 0 xc6
#define HX8394_CMD_SETCABC 0 xc9
#define HX8394_CMD_SETCABCGAIN 0 xca
#define HX8394_CMD_SETPANEL 0 xcc
#define HX8394_CMD_SETOFFSET 0 xd2
#define HX8394_CMD_SETGIP0 0 xd3
#define HX8394_CMD_UNKNOWN3 0 xd4
#define HX8394_CMD_SETGIP1 0 xd5
#define HX8394_CMD_SETGIP2 0 xd6
#define HX8394_CMD_SETGPO 0 xd6
#define HX8394_CMD_UNKNOWN4 0 xd8
#define HX8394_CMD_SETSCALING 0 xdd
#define HX8394_CMD_SETIDLE 0 xdf
#define HX8394_CMD_SETGAMMA 0 xe0
#define HX8394_CMD_SETCHEMODE_DYN 0 xe4
#define HX8394_CMD_SETCHE 0 xe5
#define HX8394_CMD_SETCESEL 0 xe6
#define HX8394_CMD_SET_SP_CMD 0 xe9
#define HX8394_CMD_SETREADINDEX 0 xfe
#define HX8394_CMD_GETSPIREAD 0 xff
struct hx8394 {
struct device *dev;
struct drm_panel panel;
struct gpio_desc *reset_gpio;
struct regulator *vcc;
struct regulator *iovcc;
enum drm_panel_orientation orientation;
const struct hx8394_panel_desc *desc;
};
struct hx8394_panel_desc {
const struct drm_display_mode *mode;
unsigned int lanes;
unsigned long mode_flags;
enum mipi_dsi_pixel_format format;
void (*init_sequence)(struct mipi_dsi_multi_context *dsi_ctx);
};
static inline struct hx8394 *panel_to_hx8394(struct drm_panel *panel)
{
return container_of(panel, struct hx8394, panel);
}
static void hsd060bhw4_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/* 5.19.8 SETEXTC: Set extension command (B9h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETEXTC,
0 xff, 0 x83, 0 x94);
/* 5.19.2 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x48, 0 x11, 0 x71, 0 x09, 0 x32, 0 x24, 0 x71, 0 x31, 0 x55, 0 x30);
/* 5.19.9 SETMIPI: Set MIPI control (BAh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETMIPI,
0 x63, 0 x03, 0 x68, 0 x6b, 0 xb2, 0 xc0);
/* 5.19.3 SETDISP: Set display related register (B2h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETDISP,
0 x00, 0 x80, 0 x78, 0 x0c, 0 x07);
/* 5.19.4 SETCYC: Set display waveform cycles (B4h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETCYC,
0 x12, 0 x63, 0 x12, 0 x63, 0 x12, 0 x63, 0 x01, 0 x0c, 0 x7c, 0 x55,
0 x00, 0 x3f, 0 x12, 0 x6b, 0 x12, 0 x6b, 0 x12, 0 x6b, 0 x01, 0 x0c,
0 x7c);
/* 5.19.19 SETGIP0: Set GIP Option0 (D3h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP0,
0 x00, 0 x00, 0 x00, 0 x00, 0 x3c, 0 x1c, 0 x00, 0 x00, 0 x32, 0 x10,
0 x09, 0 x00, 0 x09, 0 x32, 0 x15, 0 xad, 0 x05, 0 xad, 0 x32, 0 x00,
0 x00, 0 x00, 0 x00, 0 x37, 0 x03, 0 x0b, 0 x0b, 0 x37, 0 x00, 0 x00,
0 x00, 0 x0c, 0 x40);
/* 5.19.20 Set GIP Option1 (D5h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP1,
0 x19, 0 x19, 0 x18, 0 x18, 0 x1b, 0 x1b, 0 x1a, 0 x1a, 0 x00, 0 x01,
0 x02, 0 x03, 0 x04, 0 x05, 0 x06, 0 x07, 0 x20, 0 x21, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x24, 0 x25, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18);
/* 5.19.21 Set GIP Option2 (D6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP2,
0 x18, 0 x18, 0 x19, 0 x19, 0 x1b, 0 x1b, 0 x1a, 0 x1a, 0 x07, 0 x06,
0 x05, 0 x04, 0 x03, 0 x02, 0 x01, 0 x00, 0 x25, 0 x24, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x21, 0 x20, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18);
/* 5.19.25 SETGAMMA: Set gamma curve related setting (E0h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGAMMA,
0 x00, 0 x04, 0 x0c, 0 x12, 0 x14, 0 x18, 0 x1a, 0 x18, 0 x31, 0 x3f,
0 x4d, 0 x4c, 0 x54, 0 x65, 0 x6b, 0 x70, 0 x7f, 0 x82, 0 x7e, 0 x8a,
0 x99, 0 x4a, 0 x48, 0 x49, 0 x4b, 0 x4a, 0 x4c, 0 x4b, 0 x7f, 0 x00,
0 x04, 0 x0c, 0 x11, 0 x13, 0 x17, 0 x1a, 0 x18, 0 x31,
0 x3f, 0 x4d, 0 x4c, 0 x54, 0 x65, 0 x6b, 0 x70, 0 x7f,
0 x82, 0 x7e, 0 x8a, 0 x99, 0 x4a, 0 x48, 0 x49, 0 x4b,
0 x4a, 0 x4c, 0 x4b, 0 x7f);
/* 5.19.17 SETPANEL (CCh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPANEL,
0 x0b);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN1,
0 x1f, 0 x31);
/* 5.19.5 SETVCOM: Set VCOM voltage (B6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETVCOM,
0 x7d, 0 x7d);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN3,
0 x02);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x01);
/* 5.19.2 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x00);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x00);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN3,
0 xed);
}
static const struct drm_display_mode hsd060bhw4_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 40 ,
.hsync_end = 720 + 40 + 46 ,
.htotal = 720 + 40 + 46 + 40 ,
.vdisplay = 1440 ,
.vsync_start = 1440 + 9 ,
.vsync_end = 1440 + 9 + 7 ,
.vtotal = 1440 + 9 + 7 + 7 ,
.clock = 74250 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 68 ,
.height_mm = 136 ,
};
static const struct hx8394_panel_desc hsd060bhw4_desc = {
.mode = &hsd060bhw4_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = hsd060bhw4_init_sequence,
};
static void powkiddy_x55_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/* 5.19.8 SETEXTC: Set extension command (B9h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETEXTC,
0 xff, 0 x83, 0 x94);
/* 5.19.9 SETMIPI: Set MIPI control (BAh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETMIPI,
0 x63, 0 x03, 0 x68, 0 x6b, 0 xb2, 0 xc0);
/* 5.19.2 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x48, 0 x12, 0 x72, 0 x09, 0 x32, 0 x54, 0 x71, 0 x71, 0 x57, 0 x47);
/* 5.19.3 SETDISP: Set display related register (B2h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETDISP,
0 x00, 0 x80, 0 x64, 0 x2c, 0 x16, 0 x2f);
/* 5.19.4 SETCYC: Set display waveform cycles (B4h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETCYC,
0 x73, 0 x74, 0 x73, 0 x74, 0 x73, 0 x74, 0 x01, 0 x0c, 0 x86, 0 x75,
0 x00, 0 x3f, 0 x73, 0 x74, 0 x73, 0 x74, 0 x73, 0 x74, 0 x01, 0 x0c,
0 x86);
/* 5.19.5 SETVCOM: Set VCOM voltage (B6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETVCOM,
0 x6e, 0 x6e);
/* 5.19.19 SETGIP0: Set GIP Option0 (D3h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP0,
0 x00, 0 x00, 0 x07, 0 x07, 0 x40, 0 x07, 0 x0c, 0 x00, 0 x08, 0 x10,
0 x08, 0 x00, 0 x08, 0 x54, 0 x15, 0 x0a, 0 x05, 0 x0a, 0 x02, 0 x15,
0 x06, 0 x05, 0 x06, 0 x47, 0 x44, 0 x0a, 0 x0a, 0 x4b, 0 x10, 0 x07,
0 x07, 0 x0c, 0 x40);
/* 5.19.20 Set GIP Option1 (D5h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP1,
0 x1c, 0 x1c, 0 x1d, 0 x1d, 0 x00, 0 x01, 0 x02, 0 x03, 0 x04, 0 x05,
0 x06, 0 x07, 0 x08, 0 x09, 0 x0a, 0 x0b, 0 x24, 0 x25, 0 x18, 0 x18,
0 x26, 0 x27, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x20, 0 x21,
0 x18, 0 x18, 0 x18, 0 x18);
/* 5.19.21 Set GIP Option2 (D6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP2,
0 x1c, 0 x1c, 0 x1d, 0 x1d, 0 x07, 0 x06, 0 x05, 0 x04, 0 x03, 0 x02,
0 x01, 0 x00, 0 x0b, 0 x0a, 0 x09, 0 x08, 0 x21, 0 x20, 0 x18, 0 x18,
0 x27, 0 x26, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x25, 0 x24,
0 x18, 0 x18, 0 x18, 0 x18);
/* 5.19.25 SETGAMMA: Set gamma curve related setting (E0h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGAMMA,
0 x00, 0 x0a, 0 x15, 0 x1b, 0 x1e, 0 x21, 0 x24, 0 x22, 0 x47, 0 x56,
0 x65, 0 x66, 0 x6e, 0 x82, 0 x88, 0 x8b, 0 x9a, 0 x9d, 0 x98, 0 xa8,
0 xb9, 0 x5d, 0 x5c, 0 x61, 0 x66, 0 x6a, 0 x6f, 0 x7f, 0 x7f, 0 x00,
0 x0a, 0 x15, 0 x1b, 0 x1e, 0 x21, 0 x24, 0 x22, 0 x47, 0 x56, 0 x65,
0 x65, 0 x6e, 0 x81, 0 x87, 0 x8b, 0 x98, 0 x9d, 0 x99, 0 xa8, 0 xba,
0 x5d, 0 x5d, 0 x62, 0 x67, 0 x6b, 0 x72, 0 x7f, 0 x7f);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN1,
0 x1f, 0 x31);
/* 5.19.17 SETPANEL (CCh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPANEL,
0 x0b);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN3,
0 x02);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x02);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN4,
0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff,
0 xff, 0 xff);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x00);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x01);
/* 5.19.2 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x00);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x00);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN5,
0 x40, 0 x81, 0 x50, 0 x00, 0 x1a, 0 xfc, 0 x01);
/* Unknown command, not listed in the HX8394-F datasheet */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN2,
0 xed);
}
static const struct drm_display_mode powkiddy_x55_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 44 ,
.hsync_end = 720 + 44 + 20 ,
.htotal = 720 + 44 + 20 + 20 ,
.vdisplay = 1280 ,
.vsync_start = 1280 + 12 ,
.vsync_end = 1280 + 12 + 10 ,
.vtotal = 1280 + 12 + 10 + 10 ,
.clock = 63290 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 67 ,
.height_mm = 121 ,
};
static const struct hx8394_panel_desc powkiddy_x55_desc = {
.mode = &powkiddy_x55_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_NO_EOT_PACKET,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = powkiddy_x55_init_sequence,
};
static void mchp_ac40t08a_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/* DCS commands do not seem to be sent correclty without this delay */
mipi_dsi_msleep(dsi_ctx, 20 );
/* 5.19.8 SETEXTC: Set extension command (B9h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETEXTC,
0 xff, 0 x83, 0 x94);
/* 5.19.9 SETMIPI: Set MIPI control (BAh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETMIPI,
0 x63, 0 x03, 0 x68, 0 x6b, 0 xb2, 0 xc0);
/* 5.19.2 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x48, 0 x12, 0 x72, 0 x09, 0 x32, 0 x54,
0 x71, 0 x71, 0 x57, 0 x47);
/* 5.19.3 SETDISP: Set display related register (B2h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETDISP,
0 x00, 0 x80, 0 x64, 0 x0c, 0 x0d, 0 x2f);
/* 5.19.4 SETCYC: Set display waveform cycles (B4h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETCYC,
0 x73, 0 x74, 0 x73, 0 x74, 0 x73, 0 x74,
0 x01, 0 x0c, 0 x86, 0 x75, 0 x00, 0 x3f,
0 x73, 0 x74, 0 x73, 0 x74, 0 x73, 0 x74,
0 x01, 0 x0c, 0 x86);
/* 5.19.5 SETVCOM: Set VCOM voltage (B6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETVCOM,
0 x6e, 0 x6e);
/* 5.19.19 SETGIP0: Set GIP Option0 (D3h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP0,
0 x00, 0 x00, 0 x07, 0 x07, 0 x40, 0 x07,
0 x0c, 0 x00, 0 x08, 0 x10, 0 x08, 0 x00,
0 x08, 0 x54, 0 x15, 0 x0a, 0 x05, 0 x0a,
0 x02, 0 x15, 0 x06, 0 x05, 0 x06, 0 x47,
0 x44, 0 x0a, 0 x0a, 0 x4b, 0 x10, 0 x07,
0 x07, 0 x0c, 0 x40);
/* 5.19.20 Set GIP Option1 (D5h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP1,
0 x1c, 0 x1c, 0 x1d, 0 x1d, 0 x00, 0 x01,
0 x02, 0 x03, 0 x04, 0 x05, 0 x06, 0 x07,
0 x08, 0 x09, 0 x0a, 0 x0b, 0 x24, 0 x25,
0 x18, 0 x18, 0 x26, 0 x27, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x20, 0 x21, 0 x18, 0 x18,
0 x18, 0 x18);
/* 5.19.21 Set GIP Option2 (D6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP2,
0 x1c, 0 x1c, 0 x1d, 0 x1d, 0 x07, 0 x06,
0 x05, 0 x04, 0 x03, 0 x02, 0 x01, 0 x00,
0 x0b, 0 x0a, 0 x09, 0 x08, 0 x21, 0 x20,
0 x18, 0 x18, 0 x27, 0 x26, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x18, 0 x18, 0 x25, 0 x24, 0 x18, 0 x18,
0 x18, 0 x18);
/* 5.19.25 SETGAMMA: Set gamma curve related setting (E0h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGAMMA,
0 x00, 0 x0a, 0 x15, 0 x1b, 0 x1e, 0 x21,
0 x24, 0 x22, 0 x47, 0 x56, 0 x65, 0 x66,
0 x6e, 0 x82, 0 x88, 0 x8b, 0 x9a, 0 x9d,
0 x98, 0 xa8, 0 xb9, 0 x5d, 0 x5c, 0 x61,
0 x66, 0 x6a, 0 x6f, 0 x7f, 0 x7f, 0 x00,
0 x0a, 0 x15, 0 x1b, 0 x1e, 0 x21, 0 x24,
0 x22, 0 x47, 0 x56, 0 x65, 0 x65, 0 x6e,
0 x81, 0 x87, 0 x8b, 0 x98, 0 x9d, 0 x99,
0 xa8, 0 xba, 0 x5d, 0 x5d, 0 x62, 0 x67,
0 x6b, 0 x72, 0 x7f, 0 x7f);
/* Unknown command, not listed in the HX8394-F datasheet (C0H) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN1,
0 x1f, 0 x73);
/* Set CABC control (C9h)*/
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETCABC,
0 x76, 0 x00, 0 x30);
/* 5.19.17 SETPANEL (CCh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPANEL,
0 x0b);
/* Unknown command, not listed in the HX8394-F datasheet (D4h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN3,
0 x02);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x02);
/* 5.19.11 Set register bank (D8h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN4,
0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff,
0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x00);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x01);
/* 5.19.2 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x00);
/* 5.19.11 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x00);
/* Unknown command, not listed in the HX8394-F datasheet (C6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN2,
0 xed);
}
static const struct drm_display_mode mchp_ac40t08a_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 12 ,
.hsync_end = 720 + 12 + 24 ,
.htotal = 720 + 12 + 12 + 24 ,
.vdisplay = 1280 ,
.vsync_start = 1280 + 13 ,
.vsync_end = 1280 + 14 ,
.vtotal = 1280 + 14 + 13 ,
.clock = 60226 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 76 ,
.height_mm = 132 ,
};
static const struct hx8394_panel_desc mchp_ac40t08a_desc = {
.mode = &mchp_ac40t08a_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = mchp_ac40t08a_init_sequence,
};
/*
* HL055FHAV028C is based on Himax HX8399, so datasheet pages are
* slightly different than HX8394 based panels.
*/
static void hl055fhav028c_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/* 6.3.6 SETEXTC: Set extension command (B9h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETEXTC,
0 xff, 0 x83, 0 x99);
/* 6.3.17 SETOFFSET: Set offset voltage (D2h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETOFFSET,
0 x77);
/* 6.3.1 SETPOWER: Set power (B1h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPOWER,
0 x02, 0 x04, 0 x74, 0 x94, 0 x01, 0 x32,
0 x33, 0 x11, 0 x11, 0 xab, 0 x4d, 0 x56,
0 x73, 0 x02, 0 x02);
/* 6.3.2 SETDISP: Set display related register (B2h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETDISP,
0 x00, 0 x80, 0 x80, 0 xae, 0 x05, 0 x07,
0 x5a, 0 x11, 0 x00, 0 x00, 0 x10, 0 x1e,
0 x70, 0 x03, 0 xd4);
/* 6.3.3 SETCYC: Set display waveform cycles (B4h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETCYC,
0 x00, 0 xff, 0 x02, 0 xc0, 0 x02, 0 xc0,
0 x00, 0 x00, 0 x08, 0 x00, 0 x04, 0 x06,
0 x00, 0 x32, 0 x04, 0 x0a, 0 x08, 0 x21,
0 x03, 0 x01, 0 x00, 0 x0f, 0 xb8, 0 x8b,
0 x02, 0 xc0, 0 x02, 0 xc0, 0 x00, 0 x00,
0 x08, 0 x00, 0 x04, 0 x06, 0 x00, 0 x32,
0 x04, 0 x0a, 0 x08, 0 x01, 0 x00, 0 x0f,
0 xb8, 0 x01);
/* 6.3.18 SETGIP0: Set GIP Option0 (D3h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP0,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x06, 0 x00, 0 x00, 0 x10, 0 x04, 0 x00,
0 x04, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x01,
0 x00, 0 x05, 0 x05, 0 x07, 0 x00, 0 x00,
0 x00, 0 x05, 0 x40);
/* 6.3.19 Set GIP Option1 (D5h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP1,
0 x18, 0 x18, 0 x19, 0 x19, 0 x18, 0 x18,
0 x21, 0 x20, 0 x01, 0 x00, 0 x07, 0 x06,
0 x05, 0 x04, 0 x03, 0 x02, 0 x18, 0 x18,
0 x18, 0 x18, 0 x18, 0 x18, 0 x2f, 0 x2f,
0 x30, 0 x30, 0 x31, 0 x31, 0 x18, 0 x18,
0 x18, 0 x18);
/* 6.3.20 Set GIP Option2 (D6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGIP2,
0 x18, 0 x18, 0 x19, 0 x19, 0 x40, 0 x40,
0 x20, 0 x21, 0 x02, 0 x03, 0 x04, 0 x05,
0 x06, 0 x07, 0 x00, 0 x01, 0 x40, 0 x40,
0 x40, 0 x40, 0 x40, 0 x40, 0 x2f, 0 x2f,
0 x30, 0 x30, 0 x31, 0 x31, 0 x40, 0 x40,
0 x40, 0 x40);
/* 6.3.21 Set GIP Option3 (D8h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN4,
0 xa2, 0 xaa, 0 x02, 0 xa0, 0 xa2, 0 xa8,
0 x02, 0 xa0, 0 xb0, 0 x00, 0 x00, 0 x00,
0 xb0, 0 x00, 0 x00, 0 x00);
/* 6.3.9 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x01);
/* 6.3.21 Set GIP Option3 (D8h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN4,
0 xb0, 0 x00, 0 x00, 0 x00, 0 xb0, 0 x00,
0 x00, 0 x00, 0 xe2, 0 xaa, 0 x03, 0 xf0,
0 xe2, 0 xaa, 0 x03, 0 xf0);
/* 6.3.9 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x02);
/* 6.3.21 Set GIP Option3 (D8h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN4,
0 xe2, 0 xaa, 0 x03, 0 xf0, 0 xe2, 0 xaa,
0 x03, 0 xf0);
/* 6.3.9 Set register bank (BDh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETREGBANK,
0 x00);
/* 6.3.4 SETVCOM: Set VCOM voltage (B6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETVCOM,
0 x7a, 0 x7a);
/* 6.3.26 SETGAMMA: Set gamma curve related setting (E0h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETGAMMA,
0 x00, 0 x18, 0 x27, 0 x24, 0 x5a, 0 x68,
0 x79, 0 x78, 0 x81, 0 x8a, 0 x92, 0 x99,
0 x9e, 0 xa7, 0 xaf, 0 xb4, 0 xb9, 0 xc3,
0 xc7, 0 xd1, 0 xc6, 0 xd4, 0 xd5, 0 x6c,
0 x67, 0 x71, 0 x77, 0 x00, 0 x00, 0 x18,
0 x27, 0 x24, 0 x5a, 0 x68, 0 x79, 0 x78,
0 x81, 0 x8a, 0 x92, 0 x99, 0 x9e, 0 xa7,
0 xaf, 0 xb4, 0 xb9, 0 xc3, 0 xc7, 0 xd1,
0 xc6, 0 xd4, 0 xd5, 0 x6c, 0 x67, 0 x77);
/* Unknown command, not listed in the HX8399-C datasheet (C6h) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_UNKNOWN2,
0 xff, 0 xf9);
/* 6.3.16 SETPANEL (CCh) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, HX8394_CMD_SETPANEL,
0 x08);
}
static const struct drm_display_mode hl055fhav028c_mode = {
.hdisplay = 1080 ,
.hsync_start = 1080 + 32 ,
.hsync_end = 1080 + 32 + 8 ,
.htotal = 1080 + 32 + 8 + 32 ,
.vdisplay = 1920 ,
.vsync_start = 1920 + 16 ,
.vsync_end = 1920 + 16 + 2 ,
.vtotal = 1920 + 16 + 2 + 14 ,
.clock = 134920 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 70 ,
.height_mm = 127 ,
};
static const struct hx8394_panel_desc hl055fhav028c_desc = {
.mode = &hl055fhav028c_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = hl055fhav028c_init_sequence,
};
static int hx8394_enable(struct drm_panel *panel)
{
struct hx8394 *ctx = panel_to_hx8394(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
int ret;
ctx->desc->init_sequence(&dsi_ctx);
mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
if (dsi_ctx.accum_err)
return dsi_ctx.accum_err;
/* Panel is operational 120 msec after reset */
msleep(120 );
mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
if (dsi_ctx.accum_err)
goto sleep_in;
return 0 ;
sleep_in:
ret = dsi_ctx.accum_err;
dsi_ctx.accum_err = 0 ;
/* This will probably fail, but let's try orderly power off anyway. */
mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
mipi_dsi_msleep(&dsi_ctx, 50 );
return ret;
}
static int hx8394_disable(struct drm_panel *panel)
{
struct hx8394 *ctx = panel_to_hx8394(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
mipi_dsi_msleep(&dsi_ctx, 50 ); /* about 3 frames */
return dsi_ctx.accum_err;
}
static int hx8394_unprepare(struct drm_panel *panel)
{
struct hx8394 *ctx = panel_to_hx8394(panel);
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
regulator_disable(ctx->iovcc);
regulator_disable(ctx->vcc);
return 0 ;
}
static int hx8394_prepare(struct drm_panel *panel)
{
struct hx8394 *ctx = panel_to_hx8394(panel);
int ret;
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
ret = regulator_enable(ctx->vcc);
if (ret) {
dev_err(ctx->dev, "Failed to enable vcc supply: %d\n" , ret);
return ret;
}
ret = regulator_enable(ctx->iovcc);
if (ret) {
dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n" , ret);
goto disable_vcc;
}
gpiod_set_value_cansleep(ctx->reset_gpio, 0 );
msleep(180 );
return 0 ;
disable_vcc:
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
regulator_disable(ctx->vcc);
return ret;
}
static int hx8394_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct hx8394 *ctx = panel_to_hx8394(panel);
struct drm_display_mode *mode;
mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
if (!mode) {
dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n" ,
ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
drm_mode_vrefresh(ctx->desc->mode));
return -ENOMEM;
}
drm_mode_set_name(mode);
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
connector->display_info.width_mm = mode->width_mm;
connector->display_info.height_mm = mode->height_mm;
drm_mode_probed_add(connector, mode);
return 1 ;
}
static enum drm_panel_orientation hx8394_get_orientation(struct drm_panel *panel)
{
struct hx8394 *ctx = panel_to_hx8394(panel);
return ctx->orientation;
}
static const struct drm_panel_funcs hx8394_drm_funcs = {
.disable = hx8394_disable,
.unprepare = hx8394_unprepare,
.prepare = hx8394_prepare,
.enable = hx8394_enable,
.get_modes = hx8394_get_modes,
.get_orientation = hx8394_get_orientation,
};
static int hx8394_probe(struct mipi_dsi_device *dsi)
{
struct device *dev = &dsi->dev;
struct hx8394 *ctx;
int ret;
ctx = devm_drm_panel_alloc(dev, struct hx8394, panel,
&hx8394_drm_funcs,
DRM_MODE_CONNECTOR_DSI);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset" , GPIOD_OUT_HIGH);
if (IS_ERR(ctx->reset_gpio))
return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
"Failed to get reset gpio\n" );
ret = of_drm_get_panel_orientation(dev->of_node, &ctx->orientation);
if (ret < 0 ) {
dev_err(dev, "%pOF: failed to get orientation %d\n" , dev->of_node, ret);
return ret;
}
mipi_dsi_set_drvdata(dsi, ctx);
ctx->dev = dev;
ctx->desc = of_device_get_match_data(dev);
dsi->mode_flags = ctx->desc->mode_flags;
dsi->format = ctx->desc->format;
dsi->lanes = ctx->desc->lanes;
ctx->vcc = devm_regulator_get(dev, "vcc" );
if (IS_ERR(ctx->vcc))
return dev_err_probe(dev, PTR_ERR(ctx->vcc),
"Failed to request vcc regulator\n" );
ctx->iovcc = devm_regulator_get(dev, "iovcc" );
if (IS_ERR(ctx->iovcc))
return dev_err_probe(dev, PTR_ERR(ctx->iovcc),
"Failed to request iovcc regulator\n" );
ret = drm_panel_of_backlight(&ctx->panel);
if (ret)
return ret;
drm_panel_add(&ctx->panel);
ret = mipi_dsi_attach(dsi);
if (ret < 0 ) {
dev_err_probe(dev, ret, "mipi_dsi_attach failed\n" );
drm_panel_remove(&ctx->panel);
return ret;
}
dev_dbg(dev, "%ux%u@%u %ubpp dsi %udl - ready\n" ,
ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
drm_mode_vrefresh(ctx->desc->mode),
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
return 0 ;
}
static void hx8394_remove(struct mipi_dsi_device *dsi)
{
struct hx8394 *ctx = mipi_dsi_get_drvdata(dsi);
int ret;
ret = mipi_dsi_detach(dsi);
if (ret < 0 )
dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n" , ret);
drm_panel_remove(&ctx->panel);
}
static const struct of_device_id hx8394_of_match[] = {
{ .compatible = "hannstar,hsd060bhw4" , .data = &hsd060bhw4_desc },
{ .compatible = "huiling,hl055fhav028c" , .data = &hl055fhav028c_desc },
{ .compatible = "powkiddy,x55-panel" , .data = &powkiddy_x55_desc },
{ .compatible = "microchip,ac40t08a-mipi-panel" , .data = &mchp_ac40t08a_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, hx8394_of_match);
static struct mipi_dsi_driver hx8394_driver = {
.probe = hx8394_probe,
.remove = hx8394_remove,
.driver = {
.name = DRV_NAME,
.of_match_table = hx8394_of_match,
},
};
module_mipi_dsi_driver(hx8394_driver);
MODULE_AUTHOR("Kamil Trzciński <ayufan@ayufan.eu>" );
MODULE_DESCRIPTION("DRM driver for Himax HX8394 based MIPI DSI panels" );
MODULE_LICENSE("GPL" );
Messung V0.5 in Prozent C=91 H=98 G=94
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-06-08)
¤
*© Formatika GbR, Deutschland