/*
* Generic FB driver for TFT LCD displays
*
* Copyright (C) 2013 Noralf Tronnes
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/gpio.h>
#include <linux/spi/spi.h>
#include <linux/delay.h>
#include "fbtft.h"
#define DRVNAME "flexfb"
static char *chip;
module_param(chip, charp, 0000);
MODULE_PARM_DESC(chip, "LCD controller");
static unsigned int width;
module_param(width, uint, 0000);
MODULE_PARM_DESC(width, "Display width");
static unsigned int height;
module_param(height, uint, 0000);
MODULE_PARM_DESC(height, "Display height");
static s16 init[512];
static int init_num;
module_param_array(init, short, &init_num, 0000);
MODULE_PARM_DESC(init, "Init sequence");
static unsigned int setaddrwin;
module_param(setaddrwin, uint, 0000);
MODULE_PARM_DESC(setaddrwin, "Which set_addr_win() implementation to use");
static unsigned int buswidth = 8;
module_param(buswidth, uint, 0000);
MODULE_PARM_DESC(buswidth, "Width of databus (default: 8)");
static unsigned int regwidth = 8;
module_param(regwidth, uint, 0000);
MODULE_PARM_DESC(regwidth, "Width of controller register (default: 8)");
static bool nobacklight;
module_param(nobacklight, bool, 0000);
MODULE_PARM_DESC(nobacklight, "Turn off backlight functionality.");
static bool latched;
module_param(latched, bool, 0000);
MODULE_PARM_DESC(latched, "Use with latched 16-bit databus");
static s16 *initp;
static int initp_num;
/* default init sequences */
static s16 st7735r_init[] = {
-1, 0x01,
-2, 150,
-1, 0x11,
-2, 500,
-1, 0xB1, 0x01, 0x2C, 0x2D,
-1, 0xB2, 0x01, 0x2C, 0x2D,
-1, 0xB3, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D,
-1, 0xB4, 0x07,
-1, 0xC0, 0xA2, 0x02, 0x84,
-1, 0xC1, 0xC5,
-1, 0xC2, 0x0A, 0x00,
-1, 0xC3, 0x8A, 0x2A,
-1, 0xC4, 0x8A, 0xEE,
-1, 0xC5, 0x0E,
-1, 0x20,
-1, 0x36, 0xC0,
-1, 0x3A, 0x05,
-1, 0xE0, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20, 0x22,
0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02, 0x10,
-1, 0xE1, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29, 0x2e,
0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03, 0x10,
-1, 0x29,
-2, 100,
-1, 0x13,
-2, 10,
-3
};
static s16 ssd1289_init[] = {
-1, 0x00, 0x0001,
-1, 0x03, 0xA8A4,
-1, 0x0C, 0x0000,
-1, 0x0D, 0x080C,
-1, 0x0E, 0x2B00,
-1, 0x1E, 0x00B7,
-1, 0x01, 0x2B3F,
-1, 0x02, 0x0600,
-1, 0x10, 0x0000,
-1, 0x11, 0x6070,
-1, 0x05, 0x0000,
-1, 0x06, 0x0000,
-1, 0x16, 0xEF1C,
-1, 0x17, 0x0003,
-1, 0x07, 0x0233,
-1, 0x0B, 0x0000,
-1, 0x0F, 0x0000,
-1, 0x41, 0x0000,
-1, 0x42, 0x0000,
-1, 0x48, 0x0000,
-1, 0x49, 0x013F,
-1, 0x4A, 0x0000,
-1, 0x4B, 0x0000,
-1, 0x44, 0xEF00,
-1, 0x45, 0x0000,
-1, 0x46, 0x013F,
-1, 0x30, 0x0707,
-1, 0x31, 0x0204,
-1, 0x32, 0x0204,
-1, 0x33, 0x0502,
-1, 0x34, 0x0507,
-1, 0x35, 0x0204,
-1, 0x36, 0x0204,
-1, 0x37, 0x0502,
-1, 0x3A, 0x0302,
-1, 0x3B, 0x0302,
-1, 0x23, 0x0000,
-1, 0x24, 0x0000,
-1, 0x25, 0x8000,
-1, 0x4f, 0x0000,
-1, 0x4e, 0x0000,
-1, 0x22,
-3
};
static s16 hx8340bn_init[] = {
-1, 0xC1, 0xFF, 0x83, 0x40,
-1, 0x11,
-2,