linux/drivers/video/backlight/ili922x.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * (C) Copyright 2008
 * Stefano Babic, DENX Software Engineering, [email protected].
 *
 * This driver implements a lcd device for the ILITEK 922x display
 * controller. The interface to the display is SPI and the display's
 * memory is cyclically updated over the RGB interface.
 */

#include <linux/fb.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/lcd.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/string.h>

/* Register offset, see manual section 8.2 */
#define REG_START_OSCILLATION
#define REG_DRIVER_CODE_READ
#define REG_DRIVER_OUTPUT_CONTROL
#define REG_LCD_AC_DRIVEING_CONTROL
#define REG_ENTRY_MODE
#define REG_COMPARE_1
#define REG_COMPARE_2
#define REG_DISPLAY_CONTROL_1
#define REG_DISPLAY_CONTROL_2
#define REG_DISPLAY_CONTROL_3
#define REG_FRAME_CYCLE_CONTROL
#define REG_EXT_INTF_CONTROL
#define REG_POWER_CONTROL_1
#define REG_POWER_CONTROL_2
#define REG_POWER_CONTROL_3
#define REG_POWER_CONTROL_4
#define REG_RAM_ADDRESS_SET
#define REG_WRITE_DATA_TO_GRAM
#define REG_RAM_WRITE_MASK1
#define REG_RAM_WRITE_MASK2
#define REG_GAMMA_CONTROL_1
#define REG_GAMMA_CONTROL_2
#define REG_GAMMA_CONTROL_3
#define REG_GAMMA_CONTROL_4
#define REG_GAMMA_CONTROL_5
#define REG_GAMMA_CONTROL_6
#define REG_GAMMA_CONTROL_7
#define REG_GAMMA_CONTROL_8
#define REG_GAMMA_CONTROL_9
#define REG_GAMMA_CONTROL_10
#define REG_GATE_SCAN_CONTROL
#define REG_VERT_SCROLL_CONTROL
#define REG_FIRST_SCREEN_DRIVE_POS
#define REG_SECOND_SCREEN_DRIVE_POS
#define REG_RAM_ADDR_POS_H
#define REG_RAM_ADDR_POS_V
#define REG_OSCILLATOR_CONTROL
#define REG_GPIO
#define REG_OTP_VCM_PROGRAMMING
#define REG_OTP_VCM_STATUS_ENABLE
#define REG_OTP_PROGRAMMING_ID_KEY

/*
 * maximum frequency for register access
 * (not for the GRAM access)
 */
#define ILITEK_MAX_FREQ_REG

/*
 * Device ID as found in the datasheet (supports 9221 and 9222)
 */
#define ILITEK_DEVICE_ID
#define ILITEK_DEVICE_ID_MASK

/* Last two bits in the START BYTE */
#define START_RS_INDEX
#define START_RS_REG
#define START_RW_WRITE
#define START_RW_READ

/*
 * START_BYTE(id, rs, rw)
 *
 * Set the start byte according to the required operation.
 * The start byte is defined as:
 *   ----------------------------------
 *  | 0 | 1 | 1 | 1 | 0 | ID | RS | RW |
 *   ----------------------------------
 * @id: display's id as set by the manufacturer
 * @rs: operation type bit, one of:
 *	  - START_RS_INDEX	set the index register
 *	  - START_RS_REG	write/read registers/GRAM
 * @rw: read/write operation
 *	 - START_RW_WRITE	write
 *	 - START_RW_READ	read
 */
#define START_BYTE(id, rs, rw)

/*
 * CHECK_FREQ_REG(spi_device s, spi_transfer x) - Check the frequency
 *	for the SPI transfer. According to the datasheet, the controller
 *	accept higher frequency for the GRAM transfer, but it requires
 *	lower frequency when the registers are read/written.
 *	The macro sets the frequency in the spi_transfer structure if
 *	the frequency exceeds the maximum value.
 * @s: pointer to an SPI device
 * @x: pointer to the read/write buffer pair
 */
#define CHECK_FREQ_REG(s, x)

#define CMD_BUFSIZE

#define POWER_IS_ON(pwr)

#define set_tx_byte(b)

/*
 * ili922x_id - id as set by manufacturer
 */
static int ili922x_id =;
module_param(ili922x_id, int, 0);

static int tx_invert;
module_param(tx_invert, int, 0);

/*
 * driver's private structure
 */
struct ili922x {};

/**
 * ili922x_read_status - read status register from display
 * @spi: spi device
 * @rs:  output value
 */
static int ili922x_read_status(struct spi_device *spi, u16 *rs)
{}

/**
 * ili922x_read - read register from display
 * @spi: spi device
 * @reg: offset of the register to be read
 * @rx:  output value
 */
static int ili922x_read(struct spi_device *spi, u8 reg, u16 *rx)
{}

/**
 * ili922x_write - write a controller register
 * @spi: struct spi_device *
 * @reg: offset of the register to be written
 * @value: value to be written
 */
static int ili922x_write(struct spi_device *spi, u8 reg, u16 value)
{}

#ifdef DEBUG
/**
 * ili922x_reg_dump - dump all registers
 *
 * @spi: pointer to an SPI device
 */
static void ili922x_reg_dump(struct spi_device *spi)
{
	u8 reg;
	u16 rx;

	dev_dbg(&spi->dev, "ILI922x configuration registers:\n");
	for (reg = REG_START_OSCILLATION;
	     reg <= REG_OTP_PROGRAMMING_ID_KEY; reg++) {
		ili922x_read(spi, reg, &rx);
		dev_dbg(&spi->dev, "reg @ 0x%02X: 0x%04X\n", reg, rx);
	}
}
#else
static inline void ili922x_reg_dump(struct spi_device *spi) {}
#endif

/**
 * set_write_to_gram_reg - initialize the display to write the GRAM
 * @spi: spi device
 */
static void set_write_to_gram_reg(struct spi_device *spi)
{}

/**
 * ili922x_poweron - turn the display on
 * @spi: spi device
 *
 * The sequence to turn on the display is taken from
 * the datasheet and/or the example code provided by the
 * manufacturer.
 */
static int ili922x_poweron(struct spi_device *spi)
{}

/**
 * ili922x_poweroff - turn the display off
 * @spi: spi device
 */
static int ili922x_poweroff(struct spi_device *spi)
{}

/**
 * ili922x_display_init - initialize the display by setting
 *			  the configuration registers
 * @spi: spi device
 */
static void ili922x_display_init(struct spi_device *spi)
{}

static int ili922x_lcd_power(struct ili922x *lcd, int power)
{}

static int ili922x_set_power(struct lcd_device *ld, int power)
{}

static int ili922x_get_power(struct lcd_device *ld)
{}

static const struct lcd_ops ili922x_ops =;

static int ili922x_probe(struct spi_device *spi)
{}

static void ili922x_remove(struct spi_device *spi)
{}

static struct spi_driver ili922x_driver =;

module_spi_driver();

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