linux/drivers/gpu/drm/panel/panel-novatek-nt35510.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Novatek NT35510 panel driver
 * Copyright (C) 2020 Linus Walleij <[email protected]>
 * Based on code by Robert Teather (C) 2012 Samsung
 *
 * This display driver (and I refer to the physical component NT35510,
 * not this Linux kernel software driver) can handle:
 * 480x864, 480x854, 480x800, 480x720 and 480x640 pixel displays.
 * It has 480x840x24bit SRAM embedded for storing a frame.
 * When powered on the display is by default in 480x800 mode.
 *
 * The actual panels using this component have different names, but
 * the code needed to set up and configure the panel will be similar,
 * so they should all use the NT35510 driver with appropriate configuration
 * per-panel, e.g. for physical size.
 *
 * This driver is for the DSI interface to panels using the NT35510.
 *
 * The NT35510 can also use an RGB (DPI) interface combined with an
 * I2C or SPI interface for setting up the NT35510. If this is needed
 * this panel driver should be refactored to also support that use
 * case.
 */
#include <linux/backlight.h>
#include <linux/bitops.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/regmap.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 NT35510_CMD_CORRECT_GAMMA
#define NT35510_CMD_CONTROL_DISPLAY

#define MCS_CMD_MAUCCTR
#define MCS_CMD_READ_ID1
#define MCS_CMD_READ_ID2
#define MCS_CMD_READ_ID3
#define MCS_CMD_MTP_READ_SETTING
#define MCS_CMD_MTP_READ_PARAM

/*
 * These manufacturer commands are available after we enable manufacturer
 * command set (MCS) for page 0.
 */
#define NT35510_P0_DOPCTR
#define NT35510_P0_SDHDTCTR
#define NT35510_P0_GSEQCTR
#define NT35510_P0_SDEQCTR
#define NT35510_P0_SDVPCTR
#define NT35510_P0_DPFRCTR1
#define NT35510_P0_DPFRCTR2
#define NT35510_P0_DPFRCTR3
#define NT35510_P0_DPMCTR12

#define NT35510_P0_DOPCTR_LEN
#define NT35510_P0_GSEQCTR_LEN
#define NT35510_P0_SDEQCTR_LEN
#define NT35510_P0_SDVPCTR_LEN
#define NT35510_P0_DPFRCTR1_LEN
#define NT35510_P0_DPFRCTR2_LEN
#define NT35510_P0_DPFRCTR3_LEN
#define NT35510_P0_DPMCTR12_LEN

#define NT35510_DOPCTR_0_RAMKP
#define NT35510_DOPCTR_0_DSITE
#define NT35510_DOPCTR_0_DSIG
#define NT35510_DOPCTR_0_DSIM
#define NT35510_DOPCTR_0_EOTP
#define NT35510_DOPCTR_0_N565
#define NT35510_DOPCTR_1_TW_PWR_SEL
#define NT35510_DOPCTR_1_CRGB
#define NT35510_DOPCTR_1_CTB
#define NT35510_DOPCTR_1_CRL
#define NT35510_P0_SDVPCTR_PRG
#define NT35510_P0_SDVPCTR_AVDD
#define NT35510_P0_SDVPCTR_OFFCOL
#define NT35510_P0_SDVPCTR_AVSS
#define NT35510_P0_SDVPCTR_HI_Z

/*
 * These manufacturer commands are available after we enable manufacturer
 * command set (MCS) for page 1.
 */
#define NT35510_P1_SETAVDD
#define NT35510_P1_SETAVEE
#define NT35510_P1_SETVCL
#define NT35510_P1_SETVGH
#define NT35510_P1_SETVRGH
#define NT35510_P1_SETVGL
#define NT35510_P1_BT1CTR
#define NT35510_P1_BT2CTR
#define NT35510_P1_BT3CTR
#define NT35510_P1_BT4CTR
#define NT35510_P1_BT5CTR
#define NT35510_P1_PFMCTR
#define NT35510_P1_SETVGP
#define NT35510_P1_SETVGN
#define NT35510_P1_SETVCMOFF
#define NT35510_P1_VGHCTR
#define NT35510_P1_SET_GAMMA_RED_POS
#define NT35510_P1_SET_GAMMA_GREEN_POS
#define NT35510_P1_SET_GAMMA_BLUE_POS
#define NT35510_P1_SET_GAMMA_RED_NEG
#define NT35510_P1_SET_GAMMA_GREEN_NEG
#define NT35510_P1_SET_GAMMA_BLUE_NEG

/* AVDD and AVEE setting 3 bytes */
#define NT35510_P1_AVDD_LEN
#define NT35510_P1_AVEE_LEN
#define NT35510_P1_VCL_LEN
#define NT35510_P1_VGH_LEN
#define NT35510_P1_VGL_LEN
#define NT35510_P1_VGP_LEN
#define NT35510_P1_VGN_LEN
#define NT35510_P1_VCMOFF_LEN
/* BT1CTR thru BT5CTR setting 3 bytes */
#define NT35510_P1_BT1CTR_LEN
#define NT35510_P1_BT2CTR_LEN
#define NT35510_P1_BT3CTR_LEN
#define NT35510_P1_BT4CTR_LEN
#define NT35510_P1_BT5CTR_LEN
/* 52 gamma parameters times two per color: positive and negative */
#define NT35510_P1_GAMMA_LEN

#define NT35510_WRCTRLD_BCTRL
#define NT35510_WRCTRLD_A
#define NT35510_WRCTRLD_DD
#define NT35510_WRCTRLD_BL
#define NT35510_WRCTRLD_DB
#define NT35510_WRCTRLD_G

#define NT35510_WRCABC_OFF
#define NT35510_WRCABC_UI_MODE
#define NT35510_WRCABC_STILL_MODE
#define NT35510_WRCABC_MOVING_MODE

/**
 * struct nt35510_config - the display-specific NT35510 configuration
 *
 * Some of the settings provide an array of bytes, A, B C which mean:
 * A = normal / idle off mode
 * B = idle on mode
 * C = partial / idle off mode
 *
 * Gamma correction arrays are 10bit numbers, two consecutive bytes
 * makes out one point on the gamma correction curve. The points are
 * not linearly placed along the X axis, we get points 0, 1, 3, 5
 * 7, 11, 15, 23, 31, 47, 63, 95, 127, 128, 160, 192, 208, 224, 232,
 * 240, 244, 248, 250, 252, 254, 255. The voltages tuples form
 * V0, V1, V3 ... V255, with 0x0000 being the lowest voltage and
 * 0x03FF being the highest voltage.
 *
 * Each value must be strictly higher than the previous value forming
 * a rising curve like this:
 *
 * ^
 * |                                        V255
 * |                                 V254
 * |                         ....
 * |                    V5
 * |           V3
 * |     V1
 * | V0
 * +------------------------------------------->
 *
 * The details about all settings can be found in the NT35510 Application
 * Note.
 */
struct nt35510_config {};

/**
 * struct nt35510 - state container for the NT35510 panel
 */
struct nt35510 {};

/* Manufacturer command has strictly this byte sequence */
static const u8 nt35510_mauc_mtp_read_param[] =;
static const u8 nt35510_mauc_mtp_read_setting[] =;
static const u8 nt35510_mauc_select_page_0[] =;
static const u8 nt35510_mauc_select_page_1[] =;
static const u8 nt35510_vgh_on[] =;

static inline struct nt35510 *panel_to_nt35510(struct drm_panel *panel)
{}

#define NT35510_ROTATE_0_SETTING
#define NT35510_ROTATE_180_SETTING

static int nt35510_send_long(struct nt35510 *nt, struct mipi_dsi_device *dsi,
			     u8 cmd, u8 cmdlen, const u8 *seq)
{}

static int nt35510_read_id(struct nt35510 *nt)
{}

/**
 * nt35510_setup_power() - set up power config in page 1
 * @nt: the display instance to set up
 */
static int nt35510_setup_power(struct nt35510 *nt)
{}

/**
 * nt35510_setup_display() - set up display config in page 0
 * @nt: the display instance to set up
 */
static int nt35510_setup_display(struct nt35510 *nt)
{}

static int nt35510_set_brightness(struct backlight_device *bl)
{}

static const struct backlight_ops nt35510_bl_ops =;

/*
 * This power-on sequence
 */
static int nt35510_power_on(struct nt35510 *nt)
{}

static int nt35510_power_off(struct nt35510 *nt)
{}

static int nt35510_unprepare(struct drm_panel *panel)
{}

static int nt35510_prepare(struct drm_panel *panel)
{}

static int nt35510_get_modes(struct drm_panel *panel,
			     struct drm_connector *connector)
{}

static const struct drm_panel_funcs nt35510_drm_funcs =;

static int nt35510_probe(struct mipi_dsi_device *dsi)
{}

static void nt35510_remove(struct mipi_dsi_device *dsi)
{}

/*
 * These gamma correction values are 10bit tuples, so only bits 0 and 1 is
 * ever used in the first byte. They form a positive and negative gamma
 * correction curve for each color, values must be strictly higher for each
 * step on the curve. As can be seen these default curves goes from 0x0001
 * to 0x03FE.
 */
#define NT35510_GAMMA_POS_DEFAULT

#define NT35510_GAMMA_NEG_DEFAULT

/*
 * The Hydis HVA40WV1 panel
 */
static const struct nt35510_config nt35510_hydis_hva40wv1 =;

static const struct nt35510_config nt35510_frida_frd400b25025 =;

static const struct of_device_id nt35510_of_match[] =;
MODULE_DEVICE_TABLE(of, nt35510_of_match);

static struct mipi_dsi_driver nt35510_driver =;
module_mipi_dsi_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();