Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
config MTK_LCM
bool "Enable LCM driver"
default n
help
define LCM driver config to enable LCM driver.
To set LCM driver which you choose avoid cannot driver LCM.
Please make sure CONFIG_MTK_LCM in xxxxxx_defconfig.mk.
And also make sure true on in ProjectConfig.mk
config CUSTOM_KERNEL_LCM
string "define mediatek kernel LCM driver"
help
To choose kernel LCM driver name.
This config is to select which LCM driver you want to use.
Please make sure CUSTOME_KERNEL_LCM in xxxxx_defconfig.mk.
And also make sure turn on in ProjectConfig.mk
config MTK_LCM_DEVICE_TREE_SUPPORT
bool "support LCM device tree connect with display drivers"
help
Decide whether to support LCM device tree based configuration.
This feature requires the connection between display driver and LCM devices.
Please also turn on MTK_LCM_DEVICE_TREE_SUPPORT in ProjectConfig.mk.
If not define MTK_LCM_DEVICE_TREE_SUPPORT
there will not connect between display driver and LCM devices.
+46
View File
@@ -0,0 +1,46 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-$(CONFIG_MTK_LCM) += mt65xx_lcm_list.o \
lcm_common.o \
lcm_gpio.o \
lcm_i2c.o \
lcm_pmic.o \
lcm_util.o
LCM_LISTS := $(subst ",,$(CONFIG_CUSTOM_KERNEL_LCM))
obj-$(CONFIG_MTK_LCM) += $(foreach LCM,$(LCM_LISTS),$(LCM)/)
ifeq (y, $(filter y, $(CONFIG_MACH_MT6761)))
MTK_PLATFORM:= $(subst ",,mt6765)
else
MTK_PLATFORM:= $(subst ",,$(CONFIG_MTK_PLATFORM))
endif
subdir-ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
subdir-ccflags-$(CONFIG_MTK_FB) += -I$(srctree)/drivers/misc/mediatek/video/$(MTK_PLATFORM)/dispsys \
-I$(srctree)/drivers/misc/mediatek/video/$(MTK_PLATFORM)/dispsys/mt6735 \
-I$(srctree)/drivers/misc/mediatek/video/$(MTK_PLATFORM)/videox \
-I$(srctree)/drivers/misc/mediatek/video/include
LCM_DEFINES := $(shell echo $(CONFIG_CUSTOM_KERNEL_LCM) | tr a-z A-Z)
DEFINES += $(foreach LCM,$(LCM_DEFINES),$(LCM))
DEFINES += MTK_LCM_PHYSICAL_ROTATION=\"$(MTK_LCM_PHYSICAL_ROTATION)\"
ccflags-$(CONFIG_MTK_LCM) += $(addprefix -D, $(DEFINES))
ccflags-$(CONFIG_MTK_LCM_DEVICE_TREE_SUPPORT) += -DMTK_LCM_DEVICE_TREE_SUPPORT
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += es6311_anx6585_zigzag_wxga.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,848 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifdef BUILD_LK
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#else
#include <linux/string.h>
#include <linux/wait.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#include <asm-generic/gpio.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/mm_types.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
#include <linux/clk.h>
#endif
#endif
#include "lcm_drv.h"
static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
{
gpio_direction_output(GPIO, output);
gpio_set_value(GPIO, output);
}
#ifndef BUILD_LK
static unsigned int GPIO_LCD_RST_EN; /* GPIO45 */
static unsigned int GPIO_LCD_PWR_EN; /* GPIO158 */
void lcm_request_gpio_control(struct device *dev)
{
GPIO_LCD_RST_EN = of_get_named_gpio(dev->of_node, "lcd_rst_pin", 0);
gpio_request(GPIO_LCD_RST_EN, "GPIO_LCD_RST_EN");
GPIO_LCD_PWR_EN = of_get_named_gpio(dev->of_node, "gpio_lcd_pwr_en", 0);
gpio_request(GPIO_LCD_PWR_EN, "GPIO_LCD_PWR_EN");
}
static int lcm_driver_probe(struct device *dev, void const *data)
{
lcm_request_gpio_control(dev);
return 0;
}
static const struct of_device_id lcm_platform_of_match[] = {
{
.compatible = "es,es6311_anx6585_zigzag_wxga",
.data = 0,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, platform_of_match);
static int lcm_platform_probe(struct platform_device *pdev)
{
const struct of_device_id *id;
id = of_match_node(lcm_platform_of_match, pdev->dev.of_node);
if (!id)
return -ENODEV;
return lcm_driver_probe(&pdev->dev, id->data);
}
static struct platform_driver lcm_driver = {
.probe = lcm_platform_probe,
.driver = {
.name = "es6311_anx6585_zigzag_wxga",
.owner = THIS_MODULE,
.of_match_table = lcm_platform_of_match,
},
};
static int __init lcm_init(void)
{
pr_notice("[Kernel/LCM] register lcm init driver\n");
if (platform_driver_register(&lcm_driver)) {
pr_notice("LCM: failed to register this driver!\n");
return -ENODEV;
}
return 0;
}
static void __exit lcm_exit(void)
{
platform_driver_unregister(&lcm_driver);
}
late_initcall(lcm_init);
module_exit(lcm_exit);
MODULE_AUTHOR("mediatek");
MODULE_DESCRIPTION("LCM display subsystem driver");
MODULE_LICENSE("GPL");
#endif
/* ------------------------------------------------------------------- */
/* Local Constants */
/* ------------------------------------------------------------------- */
#define FRAME_WIDTH (800)
#define FRAME_HEIGHT (1280)
/* ------------------------------------------------------------------- */
/* Local Variables */
/* ------------------------------------------------------------------- */
static struct LCM_UTIL_FUNCS lcm_util = { 0 };
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* ------------------------------------------------------------------- */
/* Local Functions */
/* ------------------------------------------------------------------- */
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define LCM_DSI_CMD_MODE 0
static void lcm_initial_registers(void)
{
unsigned int data_array[16];
data_array[0] = 0x00053902;
data_array[1] = 0xA555AAFF;
data_array[2] = 0x00000125;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000020FC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(2);
data_array[0] = 0x00033902;
data_array[1] = 0x000000FC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(2);
data_array[0] = 0x00033902;
data_array[1] = 0x000020FC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(2);
data_array[0] = 0x00053902;
data_array[1] = 0x2555AAFF;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000008;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000168B1;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000008B6;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00043902;
data_array[1] = 0x080201B8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x004444BB;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000000BC;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x106802BD;
data_array[2] = 0x00000010;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000080C8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000108;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x004F4FB3;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001010B4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000505B5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003535B9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002525BA;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000068BC;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000068BD;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000033BE;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x00000CC0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000000CA;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000208;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000001EE;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00113902;
data_array[1] = 0x000000B0;
data_array[2] = 0x002A000F;
data_array[3] = 0x00540040;
data_array[4] = 0x00930076;
data_array[5] = 0x000000C5;
dsi_set_cmdq(data_array, 6, 1);
data_array[0] = 0x00113902;
data_array[1] = 0x01F000B1;
data_array[2] = 0x01660132;
data_array[3] = 0x02FF01BB;
data_array[4] = 0x02420201;
data_array[5] = 0x00000085;
dsi_set_cmdq(data_array, 6, 1);
data_array[0] = 0x00113902;
data_array[1] = 0x02AF02B2;
data_array[2] = 0x030503E0;
data_array[3] = 0x03540335;
data_array[4] = 0x03A00384;
data_array[5] = 0x000000C4;
dsi_set_cmdq(data_array, 6, 1);
data_array[0] = 0x00053902;
data_array[1] = 0x03F203B3;
data_array[2] = 0x000000FF;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000308;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000000B0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000000B1;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x170008B2;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x000005B6;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0xA00053BA;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0xA00053BB;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = 0x000000C0;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = 0x000000C1;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000060C4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x0000C0C5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000508;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000617B0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000617B1;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000617B2;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000617B3;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000617B4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000617B5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x00000CB8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000000B9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000000BA;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x00000ABB;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000002BC;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x010103BD;
data_array[2] = 0x00000303;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000007C0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x0000A2C4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002003C8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002101C9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00043902;
data_array[1] = 0x010000CC;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00043902;
data_array[1] = 0x010000CD;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0xFC0400D1;
data_array[2] = 0x00001407;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x000510D2;
data_array[2] = 0x00001603;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000006E5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000006E6;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000006E7;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000006E8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000006E9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000006EA;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000030ED;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000608;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001117B0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001016B1;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001812B2;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001913B3;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003100B4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003431B5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002934B6;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x00332AB7;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002D2EB8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003408B9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000834BA;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002E2DBB;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002A34BC;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003429BD;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003134BE;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000031BF;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001319C0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001218C1;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001610C2;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001711C3;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003434E5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001812C4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001913C5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001117C6;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001016C7;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003108C8;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003431C9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002934CA;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x00332ACB;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002E2DCC;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003400CD;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000034CE;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002D2ECF;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x002A34D0;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003429D1;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003134D2;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x000831D3;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001610D4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001711D5;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001319D6;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x001218D7;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00033902;
data_array[1] = 0x003434E6;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x000000D8;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x000000D9;
data_array[2] = 0x00000000;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00023902;
data_array[1] = 0x000000E7;
dsi_set_cmdq(data_array, 2, 1);
#if 0
data_array[0] = 0x00110500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(120);
data_array[0] = 0x00290500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(10);
#endif
data_array[0] = 0x00023902;
data_array[1] = 0x00000035;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00063902;
data_array[1] = 0x52AA55F0;
data_array[2] = 0x00000108;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00110500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(120);
data_array[0] = 0x00290500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(10);
}
static void lcm_init_power(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, 1);
MDELAY(10);
}
static void lcm_suspend_power(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0);
MDELAY(20);
}
static void lcm_resume_power(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, 1);
}
/* ------------------------------------------------------------------- */
/* LCM Driver Implementations */
/* ------------------------------------------------------------------- */
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->density = 160;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
#else
params->dsi.mode = BURST_VDO_MODE;
#endif
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 5;
params->dsi.vertical_backporch = 3;
params->dsi.vertical_frontporch = 8;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 5;
params->dsi.horizontal_backporch = 59;
params->dsi.horizontal_frontporch = 16;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.PLL_CLOCK = 210;
}
static void lcm_init_lcm(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
#ifdef BUILD_LK
lcm_resume();
#endif
}
void lcm_suspend(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_RST_EN, 1);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST_EN, 0);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0);
}
void lcm_resume(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_RST_EN, 0);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0);
MDELAY(1);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, 1);
MDELAY(2);
lcm_set_gpio_output(GPIO_LCD_RST_EN, 1);
MDELAY(5);
lcm_set_gpio_output(GPIO_LCD_RST_EN, 0);
MDELAY(5);
lcm_set_gpio_output(GPIO_LCD_RST_EN, 1);
MDELAY(5);
lcm_initial_registers();
}
#if (LCM_DSI_CMD_MODE)
static void lcm_update(unsigned int x,
unsigned int y, unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00290508;
dsi_set_cmdq(data_array, 1, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
#endif
static unsigned int lcm_ata_check(unsigned char *buffer)
{
return 1;
}
struct LCM_DRIVER es6311_anx6585_zigzag_wxga_lcm_drv = {
.name = "es6311_anx6585_zigzag_wxga",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init_lcm,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.ata_check = lcm_ata_check,
#if (LCM_DSI_CMD_MODE)
.update = lcm_update,
#endif
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += ft8201_wxga_vdo_incell_boe.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,623 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
#include <linux/string.h>
#include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#include "lcm_define.h"
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
/* #include <linux/jiffies.h> */
/* #include <linux/delay.h> */
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#endif
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#else
#include "disp_dts_gpio.h"
#include <linux/gpio.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
#include <linux/clk.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#endif
#endif
#ifndef MACH_FPGA
#include <lcm_pmic.h>
#endif
#ifdef BUILD_LK
#define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
#define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
#define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID (0x98)
static const unsigned int BL_MIN_LEVEL = 20;
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) \
lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define GPIO_OUT_LOW 0
#define GPIO_OUT_ONE 1
#define GPIO_OUT_ZERO 0
#ifndef BUILD_LK
static unsigned int GPIO_LCD_RST;
static unsigned int GPIO_LCD_LED_EN;
static unsigned int GPIO_LCD_PWR_ENP;
static unsigned int GPIO_LCD_PWR_ENN;
struct pinctrl *lcd_pinctrl1;
struct pinctrl_state *lcd_disp_pwm;
struct pinctrl_state *lcd_disp_pwm_gpio;
void lcm_request_gpio_control(struct device *dev)
{
int ret;
pr_notice("[Kernel/LCM] %s enter\n", __func__);
GPIO_LCD_RST = of_get_named_gpio(dev->of_node, "gpio_lcd_rst", 0);
gpio_request(GPIO_LCD_RST, "GPIO_LCD_RST");
GPIO_LCD_LED_EN = of_get_named_gpio(dev->of_node, "gpio_lcd_led_en", 0);
gpio_request(GPIO_LCD_LED_EN, "GPIO_LCD_LED_EN");
GPIO_LCD_PWR_ENP = of_get_named_gpio(dev->of_node,
"gpio_lcd_pwr_enp", 0);
gpio_request(GPIO_LCD_PWR_ENP, "GPIO_LCD_PWR_ENP");
GPIO_LCD_PWR_ENN = of_get_named_gpio(dev->of_node,
"gpio_lcd_pwr_enn", 0);
gpio_request(GPIO_LCD_PWR_ENN, "GPIO_LCD_PWR_ENN");
lcd_pinctrl1 = devm_pinctrl_get(dev);
if (IS_ERR(lcd_pinctrl1)) {
ret = PTR_ERR(lcd_pinctrl1);
pr_notice(" Cannot find lcd_pinctrl1 %d!\n", ret);
}
lcd_disp_pwm = pinctrl_lookup_state(lcd_pinctrl1, "disp_pwm");
if (IS_ERR(lcd_pinctrl1)) {
ret = PTR_ERR(lcd_pinctrl1);
pr_notice(" Cannot find lcd_disp_pwm %d!\n", ret);
}
lcd_disp_pwm_gpio = pinctrl_lookup_state(lcd_pinctrl1, "disp_pwm_gpio");
if (IS_ERR(lcd_pinctrl1)) {
ret = PTR_ERR(lcd_pinctrl1);
pr_notice(" Cannot find lcd_disp_pwm_gpio %d!\n", ret);
}
}
static int lcm_driver_probe(struct device *dev, void const *data)
{
lcm_request_gpio_control(dev);
return 0;
}
static const struct of_device_id lcm_platform_of_match[] = {
{
.compatible = "ft,ft8201",
.data = 0,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, platform_of_match);
static int lcm_platform_probe(struct platform_device *pdev)
{
const struct of_device_id *id;
id = of_match_node(lcm_platform_of_match, pdev->dev.of_node);
if (!id)
return -ENODEV;
return lcm_driver_probe(&pdev->dev, id->data);
}
static struct platform_driver lcm_driver = {
.probe = lcm_platform_probe,
.driver = {
.name = "ft8201",
.owner = THIS_MODULE,
.of_match_table = lcm_platform_of_match,
},
};
static int __init lcm_drv_init(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
if (platform_driver_register(&lcm_driver)) {
pr_notice("LCM: failed to register disp driver\n");
return -ENODEV;
}
return 0;
}
static void __exit lcm_drv_exit(void)
{
platform_driver_unregister(&lcm_driver);
pr_notice("LCM: Unregister lcm driver done\n");
}
late_initcall(lcm_drv_init);
module_exit(lcm_drv_exit);
MODULE_AUTHOR("mediatek");
MODULE_DESCRIPTION("Display subsystem Driver");
MODULE_LICENSE("GPL");
#endif
/* ----------------------------------------------------------------- */
/* Local Constants */
/* ----------------------------------------------------------------- */
static const unsigned char LCD_MODULE_ID = 0x01;
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (800)
#define FRAME_HEIGHT (1280)
#define LCM_DENSITY (213)
#define LCM_PHYSICAL_WIDTH (107640)
#define LCM_PHYSICAL_HEIGHT (172224)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* ----------------------------------------------------------------- */
/* Local Variables */
/* ----------------------------------------------------------------- */
static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
{
#ifdef BUILD_LK
mt_set_gpio_mode(GPIO, GPIO_MODE_00);
mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO, output);
#else
gpio_direction_output(GPIO, output);
gpio_set_value(GPIO, output);
#endif
}
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} }
};
static struct LCM_setting_table init_setting_vdo[] = {
{0x11, 0x01, {0x00} },
{REGFLAG_DELAY, 20, {} },
{0x50, 2, {0x5a, 0x0c} },
{0x80, 1, {0xfd} },
{REGFLAG_DELAY, 120, {} },
{0x29, 0x01, {0x00} },
{REGFLAG_DELAY, 20, {} },
{0x50, 1, {0x00} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH/1000;
params->physical_height = LCM_PHYSICAL_HEIGHT/1000;
params->density = LCM_DENSITY;
/* params->physical_width_um = LCM_PHYSICAL_WIDTH; */
/* params->physical_height_um = LCM_PHYSICAL_HEIGHT; */
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
/* lcm_dsi_mode = CMD_MODE; */
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
/* params->dsi.switch_mode = CMD_MODE; */
/* lcm_dsi_mode = SYNC_PULSE_VDO_MODE; */
#endif
/* LCM_LOGI("lcm_get_params lcm_dsi_mode %d\n", lcm_dsi_mode); */
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 8;
params->dsi.vertical_backporch = 32;
params->dsi.vertical_frontporch = 184;
/* disable dynamic frame rate */
/* params->dsi.vertical_frontporch_for_low_power = 540; */
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 14;
params->dsi.horizontal_backporch = 60;
params->dsi.horizontal_frontporch = 170;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.ssc_range = 4;
params->dsi.ssc_disable = 1;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
#if (LCM_DSI_CMD_MODE)
params->dsi.PLL_CLOCK = 270;
#else
params->dsi.PLL_CLOCK = 300;
#endif
/* params->dsi.PLL_CK_CMD = 220; */
/* params->dsi.PLL_CK_VDO = 255; */
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 0;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 0;
params->corner_pattern_width = 720;
params->corner_pattern_height = 32;
#endif
/* params->use_gpioID = 1; */
/* params->gpioID_value = 0; */
}
#ifdef BUILD_LK
#ifndef MACH_FPGA
#define SM5109_SLAVE_ADDR_WRITE 0x7C
#define I2C_SM5109_PMU_CHANNEL 5
#define I2C_SM5109_PMU_SLAVE_7_BIT_ADDR 0x3E
static int SM5109_read_byte(kal_uint8 addr, kal_uint8 *dataBuffer)
{
kal_uint32 ret = I2C_OK;
kal_uint16 len;
struct mt_i2c_t SM5109_i2c;
*dataBuffer = addr;
SM5109_i2c.id = I2C_SM5109_PMU_CHANNEL;
SM5109_i2c.addr = I2C_SM5109_PMU_SLAVE_7_BIT_ADDR;
SM5109_i2c.mode = ST_MODE;
SM5109_i2c.speed = 100;
len = 1;
ret = i2c_write_read(&SM5109_i2c, dataBuffer, len, len);
if (ret != I2C_OK)
LCM_LOGI("%s: i2c_read failed! ret: %d\n",
__func__, ret);
return ret;
}
static int SM5109_write_byte(kal_uint8 addr, kal_uint8 value)
{
kal_uint32 ret_code = I2C_OK;
kal_uint8 write_data[2];
kal_uint16 len;
struct mt_i2c_t SM5109_i2c;
write_data[0] = addr;
write_data[1] = value;
SM5109_i2c.id = I2C_SM5109_PMU_CHANNEL;
SM5109_i2c.addr = I2C_SM5109_PMU_SLAVE_7_BIT_ADDR;
SM5109_i2c.mode = ST_MODE;
SM5109_i2c.speed = 100;
len = 2;
ret_code = i2c_write(&SM5109_i2c, write_data, len);
return ret_code;
}
static int SM5109_REG_MASK(kal_uint8 addr, kal_uint8 val, kal_uint8 mask)
{
kal_uint8 SM5109_reg = 0;
kal_uint32 ret = 0;
ret = SM5109_read_byte(addr, &SM5109_reg);
SM5109_reg &= ~mask;
SM5109_reg |= val;
ret = SM5109_write_byte(addr, SM5109_reg);
return ret;
}
#endif
#endif
static void lcm_init_power(void)
{
}
static void lcm_suspend_power(void)
{
}
static void lcm_resume_power(void)
{
}
static void lcm_init(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_PWR_ENP, GPIO_OUT_ONE);
MDELAY(1);
lcm_set_gpio_output(GPIO_LCD_PWR_ENN, GPIO_OUT_ONE);
MDELAY(5);
#ifdef BUILD_LK
/* set AVDD */
/* 4.0V + 20 * 100mV */
ret = SM5109_REG_MASK(0x00, 20, (0x1F << 0));
if (ret < 0)
pr_notice("[Kernel/LCM] cmd=%0x--i2c write error\n", 0x00);
else
pr_notice("[Kernel/LCM] cmd=%0x--i2c write success\n", 0x00);
/* set AVEE */
/* -4.0V - 20 * 100mV */
ret = SM5109_REG_MASK(0x01, 20, (0x1F << 0));
if (ret < 0)
pr_notice("[Kernel/LCM] cmd=%0x--i2c write error\n", 0x01);
else
pr_notice("[Kernel/LCM] cmd=%0x--i2c write success\n", 0x01);
/* enable AVDD & AVEE discharge*/
ret = SM5109_REG_MASK(0x03, (1<<0) | (1<<1), (1<<0) | (1<<1));
if (ret < 0)
pr_notice("[Kernel/LCM] cmd=%0x--i2c write error\n", 0x03);
else
pr_notice("[Kernel/LCM] cmd=%0x--i2c write success\n", 0x03);
MDELAY(8);
#endif
/* after 6ms reset HLH */
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO);
MDELAY(1);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(50);
lcm_set_gpio_output(GPIO_LCD_LED_EN, GPIO_OUT_ONE);
MDELAY(2);
pinctrl_select_state(lcd_pinctrl1, lcd_disp_pwm);
push_table(NULL,
init_setting_vdo,
sizeof(init_setting_vdo) / sizeof(struct LCM_setting_table),
1);
pr_notice("[Kernel/LCM] %s exit\n", __func__);
}
static void lcm_suspend(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
push_table(NULL,
lcm_suspend_setting,
sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table),
1);
MDELAY(10);
pinctrl_select_state(lcd_pinctrl1, lcd_disp_pwm_gpio);
lcm_set_gpio_output(GPIO_LCD_LED_EN, GPIO_OUT_ZERO);
MDELAY(2);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO);
lcm_set_gpio_output(GPIO_LCD_PWR_ENP, GPIO_OUT_ZERO);
MDELAY(1);
lcm_set_gpio_output(GPIO_LCD_PWR_ENN, GPIO_OUT_ZERO);
MDELAY(5);
}
static void lcm_resume(void)
{
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_init();
}
#if (LCM_DSI_CMD_MODE)
/* partial update restrictions:
* 1. roi width must be 1080 (full lcm width)
* 2. vertical start (y) must be multiple of 16
* 3. vertical height (h) must be multiple of 16
*/
static void lcm_validate_roi(int *x, int *y, int *width, int *height)
{
unsigned int y1 = *y;
unsigned int y2 = *height + y1 - 1;
unsigned int x1, w, h;
x1 = 0;
w = FRAME_WIDTH;
y1 = round_down(y1, 16);
h = y2 - y1 + 1;
/* in some cases, roi maybe empty. Then we need to use minimu roi */
if (h < 16)
h = 16;
h = round_up(h, 16);
/* check height again */
if (y1 >= FRAME_HEIGHT || y1 + h > FRAME_HEIGHT) {
/* assign full screen roi */
pr_notice("%s calc error, assign full roi: y=%d, h=%d\n",
__func__, *y, *height);
y1 = 0;
h = FRAME_HEIGHT;
}
/*LCM_LOGD("lcm_validate_roi (%d,%d,%d,%d) to (%d,%d,%d,%d)\n",*/
/* *x, *y, *width, *height, x1, y1, w, h);*/
*x = x1;
*width = w;
*y = y1;
*height = h;
}
#endif
static unsigned int lcm_ata_check(unsigned char *buffer)
{
return 1;
}
struct LCM_DRIVER ft8201_wxga_vdo_incell_boe_lcm_drv = {
.name = "ft8201_wxga_vdo_incell_boe",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.ata_check = lcm_ata_check,
#if (LCM_DSI_CMD_MODE)
.validate_roi = lcm_validate_roi,
#endif
};
@@ -0,0 +1,32 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _BACKLIGHT_I2C_MAP_HX_H
#define _BACKLIGHT_I2C_MAP_HX_H
int backlight_i2c_map_hx[] = {
20, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64,
66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 98,
100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130,
132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162,
164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 186, 190, 194, 198, 200, 202,
204, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 254, 258, 262,
266, 272, 278, 284, 290, 296, 302, 308, 314, 320, 326, 332, 338, 344, 350, 356,
362, 368, 374, 380, 386, 392, 398, 404, 410, 416, 422, 428, 436, 444, 452, 460,
468, 476, 484, 492, 500, 508, 516, 524, 532, 540, 550, 562, 574, 586, 598, 610,
622, 634, 646, 658, 670, 682, 694, 706, 718, 730, 744, 758, 772, 786, 800, 814,
828, 842, 856, 870, 884, 898, 912, 926, 940,
954, 972, 990, 1008, 1026, 1044, 1062,
1080, 1098, 1116, 1134, 1152, 1170, 1188, 1206, 1224,
1242, 1264, 1286, 1308, 1330, 1352, 1374,
1396, 1418, 1440, 1462, 1484, 1506, 1528, 1550, 1572,
1594, 1624, 1654, 1684, 1714, 1744, 1774,
1804, 1834, 1864, 1894, 1924, 1954, 1984, 2014, 2044,
2074, 2110, 2146, 2182, 2218, 2254, 2290,
2326, 2362, 2398, 2434, 2470, 2506, 2542, 2578, 2614,
2650, 2686, 2722, 2758, 2794, 2830, 2866,
2902, 2938, 2974, 3010, 3046, 3082, 3118, 3154, 3190,
3216, 3242, 3268, 3294, 3320, 3335, 3350
};
#endif
@@ -0,0 +1,22 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83102p_wxga_vdo_incell_boe.o
obj-y += sgm37604a.o
obj-y += ocp2138.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,553 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/string.h>
#include <linux/wait.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#include <asm-generic/gpio.h>
#include <linux/mm.h>
#include <linux/mm_types.h>
#include <linux/types.h>
#include <linux/vmalloc.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
#include <linux/clk.h>
#endif
#endif
#include "lcm_drv.h"
#include "lcm_util.h"
#include "Backlight_I2C_map_hx.h"
#include "sgm37604a.h"
#include "ocp2138.h"
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
/* #include <linux/jiffies.h> */
/* #include <linux/delay.h> */
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/string.h>
#include <linux/wait.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#include <asm-generic/gpio.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/mm_types.h>
#include <linux/types.h>
#include <linux/vmalloc.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
#include <linux/clk.h>
#endif
#endif
static unsigned int GPIO_LCD_RST = 370;/* GPIO45 */
static unsigned int GPIO_LCD_PWR_ENN = 494;/* GPIO169 */
static unsigned int GPIO_LCD_PWR_ENP = 490;/* GPIO165 */
static unsigned int GPIO_LCD_PWM_EN = 368;/* GPIO43 */
static unsigned int GPIO_LCD_BL_EN = 483;/* GPIO158 */
#ifndef BUILD_LK
static void lcm_request_gpio_control(struct device *dev)
{
GPIO_LCD_RST = of_get_named_gpio(dev->of_node, "gpio_lcd_rst", 0);
gpio_request(GPIO_LCD_RST, "GPIO_LCD_RST");
pr_info("[KE/LCM] GPIO_LCD_RST = 0x%x\n", GPIO_LCD_RST);
GPIO_LCD_PWR_ENN = of_get_named_gpio(dev->of_node, "gpio_lcd_pwr_enn", 0);
gpio_request(GPIO_LCD_PWR_ENN, "GPIO_LCD_PWR_ENN");
pr_info("[KE/LCM] GPIO_LCD_PWR_ENN = 0x%x\n", GPIO_LCD_PWR_ENN);
GPIO_LCD_PWR_ENP = of_get_named_gpio(dev->of_node, "gpio_lcd_pwr_enp", 0);
gpio_request(GPIO_LCD_PWR_ENP, "GPIO_LCD_PWR_ENP");
pr_info("[KE/LCM] GPIO_LCD_PWR_ENP = 0x%x\n", GPIO_LCD_PWR_ENP);
GPIO_LCD_PWM_EN = of_get_named_gpio(dev->of_node, "gpio_lcd_pwm_en", 0);
gpio_request(GPIO_LCD_PWM_EN, "GPIO_LCD_PWM_EN");
pr_info("[KE/LCM] GPIO_LCD_PWM_EN = 0x%x\n", GPIO_LCD_PWM_EN);
GPIO_LCD_BL_EN = of_get_named_gpio(dev->of_node, "gpio_lcd_bl_en", 0);
gpio_request(GPIO_LCD_BL_EN, "GPIO_LCD_BL_EN");
pr_info("[KE/LCM] GPIO_LCD_BL_EN = 0x%x\n", GPIO_LCD_BL_EN);
}
static int lcm_driver_probe(struct device *dev, void const *data)
{
pr_info("[KE/LCM] %s Enter\n", __func__);
lcm_request_gpio_control(dev);
return 0;
}
static const struct of_device_id lcm_platform_of_match[] = {
{
.compatible = "hx,hx83102p",
.data = 0,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, platform_of_match);
static int lcm_platform_probe(struct platform_device *pdev)
{
const struct of_device_id *id;
id = of_match_node(lcm_platform_of_match, pdev->dev.of_node);
if (!id)
return -ENODEV;
return lcm_driver_probe(&pdev->dev, id->data);
}
static struct platform_driver lcm_driver = {
.probe = lcm_platform_probe,
.driver = {
.name = "hx83102p_wxga_vdo_incell_boe",
.owner = THIS_MODULE,
.of_match_table = lcm_platform_of_match,
},
};
static int __init lcm_init(void)
{
if (platform_driver_register(&lcm_driver)) {
pr_info("LCM: failed to register this driver!\n");
return -ENODEV;
}
return 0;
}
static void __exit lcm_exit(void)
{
platform_driver_unregister(&lcm_driver);
}
late_initcall(lcm_init);
module_exit(lcm_exit);
MODULE_AUTHOR("mediatek");
MODULE_DESCRIPTION("LCM display subsystem driver");
MODULE_LICENSE("GPL");
#endif
/* --------------------------------------------------------------------- */
/* Local Constants */
/* --------------------------------------------------------------------- */
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (1200)
#define FRAME_HEIGHT (2000)
#define LCM_ID_NT35595 (0x95)
#define GPIO_OUT_ONE 1
#define GPIO_OUT_ZERO 0
#define REGFLAG_DELAY 0xFC
#define REGFLAG_END_OF_TABLE 0xFD
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* --------------------------------------------------------------------- */
/* Local Variables */
/* --------------------------------------------------------------------- */
static struct LCM_UTIL_FUNCS lcm_util = {0};
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* --------------------------------------------------------------------- */
/* Local Functions */
/* --------------------------------------------------------------------- */
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifdef BUILD_LK
#define LCD_DEBUG(fmt) dprintf(CRITICAL, fmt)
#else
#define LCD_DEBUG(fmt) pr_debug(fmt)
#endif
static unsigned short s_last_backlight_level = 255; //default level, must align with lk
static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
{
#ifdef BUILD_LK
mt_set_gpio_mode(GPIO, GPIO_MODE_00);
mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO, output);
#else
gpio_direction_output(GPIO, output);
gpio_set_value(GPIO, output);
#endif
}
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 60, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 80, {} },
{0xB1, 1, {0x21} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table lcm_initinal_setting[] = {
{ 0xB9, 3, { 0x83, 0x10, 0x2E } },
{ 0xE9, 1, { 0xCD } },
{ 0xBB, 1, { 0x01 } },
{ REGFLAG_DELAY, 5, { } },
{ 0xE9, 1, { 0x00 } },
{ 0xD1, 4, { 0x67, 0x0C, 0xFF, 0x05 } },
{ 0xB1, 17, { 0x10, 0xFA, 0xAF, 0xAF, 0x2B, 0x2B, 0xC1, 0x75, 0x39,
0x36, 0x36, 0x36, 0x36, 0x22, 0x21, 0x15, 0x00 } },
{ 0xB2, 16, { 0x00, 0xB0, 0x47, 0xD0, 0x00, 0x2C, 0x50, 0x2C, 0x00,
0x00, 0x00, 0x00, 0x15, 0x20, 0xD7, 0x00 } },
{ 0xB4, 16, { 0x38, 0x47, 0x38, 0x47, 0x66, 0x4E, 0x00, 0x00, 0x01,
0x72, 0x01, 0x58, 0x00, 0xFF, 0x00, 0xFF } },
{ 0xBF, 3, { 0xFC, 0x85, 0x80 } },
{ 0xD2, 2, { 0x2B, 0x2B } },
{ 0xD3, 43, { 0x00, 0x00, 0x00, 0x00, 0x78, 0x04, 0x00, 0x14, 0x00,
0x27, 0x00, 0x44, 0x4F, 0x29, 0x29, 0x00, 0x00, 0x32, 0x10,
0x25, 0x00, 0x25, 0x32, 0x10, 0x1F, 0x00, 0x1F, 0x32, 0x18,
0x10, 0x08, 0x10, 0x00, 0x00, 0x20, 0x30, 0x01, 0x55, 0x21,
0x2E, 0x01, 0x55, 0x0F } },
{ REGFLAG_DELAY, 5, { } },
{ 0xE0, 46, { 0x00, 0x04, 0x0B, 0x11, 0x17, 0x26, 0x3D, 0x45, 0x4D,
0x4A, 0x65, 0x6D, 0x75, 0x87, 0x86, 0x92, 0x9D, 0xB0, 0xAF,
0x56, 0x5E, 0x68, 0x70, 0x00, 0x04, 0x0B, 0x11, 0x17, 0x26,
0x3D, 0x45, 0x4D, 0x4A, 0x65, 0x6D, 0x75, 0x87, 0x86, 0x92,
0x9D, 0xB0, 0xAF, 0x56, 0x5E, 0x68, 0x70 } },
{ REGFLAG_DELAY, 5, { } },
{ 0xCB, 5, { 0x00, 0x13, 0x08, 0x02, 0x34 } },
{ 0xBD, 1, { 0x01 } },
{ 0xB1, 4, { 0x01, 0x9B, 0x01, 0x31 } },
{ 0xCB, 10, { 0xF4, 0x36, 0x12, 0x16, 0xC0, 0x28, 0x6C, 0x85, 0x3F, 0x04 } },
{ 0xD3, 11, { 0x01, 0x00, 0x3C, 0x00, 0x00, 0x11, 0x10, 0x00, 0x0E,
0x00, 0x01 } },
{ REGFLAG_DELAY, 5, { } },
{ 0xBD, 1, { 0x02 } },
{ 0xB4, 6, { 0x4E, 0x00, 0x33, 0x11, 0x33, 0x88 } },
{ 0xBF, 3, { 0xF2, 0x00, 0x02 } },
{ 0xBD, 1, { 0x00 } },
{ 0xC0, 14, { 0x23, 0x23, 0x22, 0x11, 0xA2, 0x17, 0x00, 0x80, 0x00,
0x00, 0x08, 0x00, 0x63, 0x63 } },
{ 0xC6, 1, { 0xF9 } },
{ 0xC7, 1, { 0x30 } },
{ 0xC8, 8, { 0x00, 0x04, 0x04, 0x00, 0x00, 0x85, 0x43, 0xFF } },
{ 0xD0, 3, { 0x07, 0x04, 0x05 } },
{ 0xD5, 44, { 0x21, 0x20, 0x21, 0x20, 0x25, 0x24, 0x25, 0x24, 0x18,
0x18, 0x18, 0x18, 0x1A, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B,
0x1B, 0x03, 0x02, 0x03, 0x02, 0x01, 0x00, 0x01, 0x00, 0x07,
0x06, 0x07, 0x06, 0x05, 0x04, 0x05, 0x04, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18 } },
{ REGFLAG_DELAY, 5, { } },
{ 0xE7, 23, { 0x12, 0x13, 0x02, 0x02, 0x57, 0x57, 0x0E, 0x0E, 0x1B,
0x28, 0x29, 0x74, 0x28, 0x74, 0x01, 0x07, 0x00, 0x00, 0x00,
0x00, 0x17, 0x00, 0x68 } },
{ 0xBD, 1, { 0x01 } },
{ 0xE7, 7, { 0x02, 0x38, 0x01, 0x93, 0x0D, 0xD9, 0x0E } },
{ 0xBD, 1, { 0x02 } },
{ 0xE7, 28, { 0xFF, 0x01, 0xFF, 0x01, 0x00, 0x00, 0x22, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x02, 0x40 } },
{ 0xBD, 1, { 0x00 } },
{ 0xBA, 8, { 0x70, 0x03, 0xA8, 0x83, 0xF2, 0x00, 0xC0, 0x0D } },
{ 0xBD, 1, { 0x02 } },
{ 0xD8, 12, { 0xAF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0xAF, 0xFF, 0xFF,
0xFF, 0xF0, 0x00 } },
{ 0xBD, 1, { 0x03 } },
{ 0xD8, 24, { 0xAA, 0xAA, 0xAA, 0xAA, 0xA0, 0x00, 0xAA, 0xAA, 0xAA,
0xAA, 0xA0, 0x00, 0x55, 0x55, 0x55, 0x55, 0x50, 0x00, 0x55,
0x55, 0x55, 0x55, 0x50, 0x00 } },
{ 0xBD, 1, { 0x00 } },
{ 0xE1, 2, { 0x01, 0x04 } },
{ 0xCC, 1, { 0x02 } },
{ 0xBD, 1, { 0x03 } },
{ 0xB2, 1, { 0x80 } },
{ 0xBD, 1, { 0x00 } },
{ 0x35, 1, { 0x00 } },
{ 0xB2, 16, { 0x00, 0xB0, 0x47, 0xD0, 0x00, 0x2C, 0x50, 0x2C, 0x00,
0x00, 0x00, 0x00, 0x15, 0x20, 0xD7, 0x00 } },
{ 0x11, 0, { 0x11 } },
{ REGFLAG_DELAY, 60, { } },
{ 0x29, 0, { 0x29 } },
{ REGFLAG_DELAY, 20, { } },
};
static void push_table(struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
for (i = 0; i < count; i++) {
unsigned int cmd;
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V2(cmd, table[i].count,
table[i].para_list, force_update);
}
}
}
/* --------------------------------------------------------------------- */
/* LCM Driver Implementations */
/* --------------------------------------------------------------------- */
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.cont_clock = 1;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.mode = BURST_VDO_MODE;
params->dsi.LANE_NUM = LCM_FOUR_LANE;
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
params->dsi.packet_size = 256;
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 8;
params->dsi.vertical_backporch = 38;
params->dsi.vertical_frontporch = 80;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 8;
params->dsi.horizontal_backporch = 28;
params->dsi.horizontal_frontporch = 42;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
/* params->dsi.ssc_disable = 1; */
#if (LCM_DSI_CMD_MODE)
params->dsi.PLL_CLOCK = 500;
#else
params->dsi.PLL_CLOCK = 525;
#endif
}
static void lcm_init_power(void)
{
pr_info("[Kernel/LCM] %s()\n", __func__);
/* set AVDD*/
/*5.7V + 0.1* 100mV*/
ocp2138_write_byte(0x00, 0x11);
/* set AVEE */
/*-5.70V - 0.1* 100mV*/
ocp2138_write_byte(0x01, 0x11);
MDELAY(5);
lcm_set_gpio_output(GPIO_LCD_PWR_ENP, GPIO_OUT_ONE);
MDELAY(5);
lcm_set_gpio_output(GPIO_LCD_PWR_ENN, GPIO_OUT_ONE);
MDELAY(5);
}
static void lcm_init_lcm(void)
{
pr_info("[KERNEL/LCM] hx83102p %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(50);
lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE);
MDELAY(5);
//register
sgm37604a_write_byte(0x11, 0x00);
sgm37604a_write_byte(0x1A, 0);
sgm37604a_write_byte(0x19, 0);
MDELAY(10);
push_table(lcm_initinal_setting,
sizeof(lcm_initinal_setting) / sizeof(struct LCM_setting_table), 1);
}
static void lcm_suspend(void)
{
pr_info("[Kernel/LCM] hx83102p %s() enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ZERO);
push_table(lcm_suspend_setting,
sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table), 1);
MDELAY(15);
}
static void lcm_suspend_power(void)
{
pr_info("[Kernel/LCM] %s\n", __func__);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO);
MDELAY(3);
lcm_set_gpio_output(GPIO_LCD_PWR_ENN, GPIO_OUT_ZERO);
MDELAY(3);
lcm_set_gpio_output(GPIO_LCD_PWR_ENP, GPIO_OUT_ZERO);
MDELAY(15);
}
static void lcm_resume_power(void)
{
lcm_init_power();
}
static void lcm_resume(void)
{
pr_info("[Kernel/LCM] hx83102p %s enter\n", __func__);
lcm_init_lcm();
pr_info("[Kernel/LCM] %s s_last_backlight_level=%d\n", __func__, s_last_backlight_level);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[2];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00023700; /* read id return two byte, version and id */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xF4, buffer, 2);
id = buffer[0]; /* we only need ID */
#ifdef BUILD_LK
dprintf(0, "%s, [LK/LCM] hx83102p: id = 0x%08x\n", __func__, id);
#else
pr_info("%s, [Kernel/LCM] hx83102p: id = 0x%08x\n", __func__, id);
#endif
if (id == LCM_ID_NT35595)
return 1;
else
return 0;
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
int sgm_level = 0;
if (level > 255)
level = 255;
sgm_level = backlight_i2c_map_hx[level];
pr_info("lsy_kernel %s,hx83102p backlight: level = %d sgm_level = %d\n",
__func__, level, sgm_level);
while (level != s_last_backlight_level) {
if (level > s_last_backlight_level)
s_last_backlight_level++;
else if (level < s_last_backlight_level)
s_last_backlight_level--;
sgm37604a_write_byte(0x1A, (backlight_i2c_map_hx[s_last_backlight_level] & 0x0F));
sgm37604a_write_byte(0x19, (backlight_i2c_map_hx[s_last_backlight_level] >> 4));
}
pr_info("s_last_backlight_level=%d\n", s_last_backlight_level);
}
struct LCM_DRIVER hx83102p_wxga_vdo_incell_boe_lcm_drv = {
.name = "hx83102p_wxga_vdo_incell_boe",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init_lcm,
.resume = lcm_resume,
.suspend = lcm_suspend,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
};
@@ -0,0 +1,163 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef BUILD_LK
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/miscdevice.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/kobject.h>
#include <linux/platform_device.h>
#include <linux/atomic.h>
#include <linux/of.h>
#include <linux/module.h>
#include "ocp2138.h"
/* I2C Slave Setting */
#define ocp2138_SLAVE_ADDR_WRITE 0x3E
static struct i2c_client *new_client;
static const struct i2c_device_id ocp2138_i2c_id[] = { {"ocp2138", 0}, {} };
static int ocp2138_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int ocp2138_driver_remove(struct i2c_client *client);
#ifdef CONFIG_OF
static const struct of_device_id ocp2138_id[] = {
{.compatible = "ocp2138"},
{},
};
MODULE_DEVICE_TABLE(of, ocp2138_id);
#endif
static struct i2c_driver ocp2138_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "ocp2138",
#ifdef CONFIG_OF
.of_match_table = of_match_ptr(ocp2138_id),
#endif
},
.probe = ocp2138_driver_probe,
.remove = ocp2138_driver_remove,
.id_table = ocp2138_i2c_id,
};
static DEFINE_MUTEX(ocp2138_i2c_access);
/* I2C Function For Read/Write */
int ocp2138_read_byte(unsigned char cmd, unsigned char *returnData)
{
char cmd_buf[2] = { 0x00, 0x00 };
char readData = 0;
int ret = 0;
mutex_lock(&ocp2138_i2c_access);
cmd_buf[0] = cmd;
ret = i2c_master_send(new_client, &cmd_buf[0], 1);
ret = i2c_master_recv(new_client, &cmd_buf[1], 1);
if (ret < 0) {
mutex_unlock(&ocp2138_i2c_access);
return 0;
}
readData = cmd_buf[1];
*returnData = readData;
mutex_unlock(&ocp2138_i2c_access);
return 1;
}
int ocp2138_write_byte(unsigned char cmd, unsigned char writeData)
{
char write_data[2] = { 0 };
int ret = 0;
pr_notice("[KE/ocp2138] cmd: %02x, data: %02x,%s\n", cmd, writeData, __func__);
mutex_lock(&ocp2138_i2c_access);
write_data[0] = cmd;
write_data[1] = writeData;
ret = i2c_master_send(new_client, write_data, 2);
if (ret < 0) {
mutex_unlock(&ocp2138_i2c_access);
pr_notice("[ocp2138] I2C write fail!!!\n");
return 0;
}
mutex_unlock(&ocp2138_i2c_access);
return 1;
}
static int ocp2138_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int err = 0;
pr_notice("[KE/ocp2138] name=%s addr=0x%x\n",
client->name, client->addr);
new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (!new_client) {
err = -ENOMEM;
goto exit;
}
memset(new_client, 0, sizeof(struct i2c_client));
new_client = client;
return 0;
exit:
return err;
}
static int ocp2138_driver_remove(struct i2c_client *client)
{
pr_notice("[KE/ocp2138] %s\n", __func__);
new_client = NULL;
i2c_unregister_device(client);
return 0;
}
#define ocp2138_BUSNUM 5
static int __init ocp2138_init(void)
{
pr_notice("[KE/ocp2138] %s\n", __func__);
if (i2c_add_driver(&ocp2138_driver) != 0)
pr_notice("[KE/ocp2138] failed to register ocp2138 i2c driver.\n");
else
pr_notice("[KE/ocp2138] Success to register ocp2138 i2c driver.\n");
return 0;
}
static void __exit ocp2138_exit(void)
{
i2c_del_driver(&ocp2138_driver);
}
module_init(ocp2138_init);
module_exit(ocp2138_exit);
#endif
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _ocp2138_SW_H_
#define _ocp2138_SW_H_
#ifndef BUILD_LK
struct ocp2138_setting_table {
unsigned char cmd;
unsigned char data;
};
extern int ocp2138_read_byte(unsigned char cmd, unsigned char *returnData);
extern int ocp2138_write_byte(unsigned char cmd, unsigned char writeData);
#endif
#endif
@@ -0,0 +1,163 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef BUILD_LK
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/miscdevice.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/kobject.h>
#include <linux/platform_device.h>
#include <linux/atomic.h>
#include <linux/of.h>
#include <linux/module.h>
#include "sgm37604a.h"
/* I2C Slave Setting */
#define sgm37604a_SLAVE_ADDR_WRITE 0x36
static struct i2c_client *new_client;
static const struct i2c_device_id sgm37604a_i2c_id[] = { {"sgm37604a", 0}, {} };
static int sgm37604a_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int sgm37604a_driver_remove(struct i2c_client *client);
#ifdef CONFIG_OF
static const struct of_device_id sgm37604a_id[] = {
{.compatible = "sgm37604a"},
{},
};
MODULE_DEVICE_TABLE(of, sgm37604a_id);
#endif
static struct i2c_driver sgm37604a_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "sgm37604a",
#ifdef CONFIG_OF
.of_match_table = of_match_ptr(sgm37604a_id),
#endif
},
.probe = sgm37604a_driver_probe,
.remove = sgm37604a_driver_remove,
.id_table = sgm37604a_i2c_id,
};
static DEFINE_MUTEX(sgm37604a_i2c_access);
/* I2C Function For Read/Write */
int sgm37604a_read_byte(unsigned char cmd, unsigned char *returnData)
{
char cmd_buf[2] = { 0x00, 0x00 };
char readData = 0;
int ret = 0;
mutex_lock(&sgm37604a_i2c_access);
cmd_buf[0] = cmd;
ret = i2c_master_send(new_client, &cmd_buf[0], 1);
ret = i2c_master_recv(new_client, &cmd_buf[1], 1);
if (ret < 0) {
mutex_unlock(&sgm37604a_i2c_access);
return 0;
}
readData = cmd_buf[1];
*returnData = readData;
mutex_unlock(&sgm37604a_i2c_access);
return 1;
}
int sgm37604a_write_byte(unsigned char cmd, unsigned char writeData)
{
char write_data[2] = { 0 };
int ret = 0;
pr_notice("[KE/sgm37604a] cmd: %02x, data: %02x,%s\n", cmd, writeData, __func__);
mutex_lock(&sgm37604a_i2c_access);
write_data[0] = cmd;
write_data[1] = writeData;
ret = i2c_master_send(new_client, write_data, 2);
if (ret < 0) {
mutex_unlock(&sgm37604a_i2c_access);
pr_notice("[sgm37604a] I2C write fail!!!\n");
return 0;
}
mutex_unlock(&sgm37604a_i2c_access);
return 1;
}
static int sgm37604a_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int err = 0;
pr_notice("[KE/sgm37604a] name=%s addr=0x%x\n",
client->name, client->addr);
new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (!new_client) {
err = -ENOMEM;
goto exit;
}
memset(new_client, 0, sizeof(struct i2c_client));
new_client = client;
return 0;
exit:
return err;
}
static int sgm37604a_driver_remove(struct i2c_client *client)
{
pr_notice("[KE/sgm37604a] %s\n", __func__);
new_client = NULL;
i2c_unregister_device(client);
return 0;
}
#define sgm37604a_BUSNUM 5
static int __init sgm37604a_init(void)
{
pr_notice("[KE/sgm37604a] %s\n", __func__);
if (i2c_add_driver(&sgm37604a_driver) != 0)
pr_notice("[KE/sgm37604a] failed to register sgm37604a i2c driver.\n");
else
pr_notice("[KE/sgm37604a] Success to register sgm37604a i2c driver.\n");
return 0;
}
static void __exit sgm37604a_exit(void)
{
i2c_del_driver(&sgm37604a_driver);
}
module_init(sgm37604a_init);
module_exit(sgm37604a_exit);
#endif
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _sgm37604a_SW_H_
#define _sgm37604a_SW_H_
#ifndef BUILD_LK
struct sgm37604a_setting_table {
unsigned char cmd;
unsigned char data;
};
extern int sgm37604a_read_byte(unsigned char cmd, unsigned char *returnData);
extern int sgm37604a_write_byte(unsigned char cmd, unsigned char writeData);
#endif
#endif
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 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0xef,
};
#endif
@@ -0,0 +1,664 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
#include "data_hw_roundedpattern.h"
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_HX83112B 0x83
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "lcm_i2c.h"
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* i2c control start */
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
.of_match_table = _lcm_i2c_of_match,
},
};
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
/* i2c control end */
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x05, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 0x02, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.ssc_disable = 1;
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* mipi hopping part sample */
params->dsi.dynamic_switch_mipi = 1;
//params->dsi.vertical_backporch_dyn = 12;
params->dsi.data_rate_dyn = 1029;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 1;
params->corner_pattern_height = ROUND_CORNER_H_TOP;
params->corner_pattern_height_bot = ROUND_CORNER_H_BOT;
params->corner_pattern_tp_size = sizeof(top_rc_pattern);
params->corner_pattern_lt_addr = (void *)top_rc_pattern;
#endif
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
if (lcm_util.set_gpio_lcd_enp_bias) {
lcm_util.set_gpio_lcd_enp_bias(1);
_lcm_i2c_write_bytes(0x0, 0xf);
_lcm_i2c_write_bytes(0x1, 0xf);
} else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
if (lcm_util.set_gpio_lcd_enp_bias)
lcm_util.set_gpio_lcd_enp_bias(0);
else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt4801_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_auo_rt4801_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_auo_rt5081.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x20,
0x20, 0xc0,
0x15, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xc0, 0x40,
0x40, 0xc0,
0x13, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x50,
0x50, 0xf0,
0x12, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x10,
0x10, 0xc0,
0x10, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 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20, 0xcf,
0xd, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0xaf, 0x20,
0x70, 0xef,
0xe, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x10, 0xbf,
0x10, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xdf, 0x40,
0x50, 0xef,
0x12, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xcf, 0x5f,
0x40, 0xbf,
0x14, 0x0, 0x3, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x20, 0x20, 0xbf,
0x17, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,639 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#include <linux/regulator/consumer.h>
#include <linux/string.h>
#include <linux/kernel.h>
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#define LCM_ID_HX83112B 0x83
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 50, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table init_setting_cmd[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x05, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF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00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 30, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
}
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
int lcm_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
int lcm_bias_enable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
int lcm_bias_disable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
#else
int lcm_bias_regulator_init(void)
{
return 0;
}
int lcm_bias_enable(void)
{
return 0;
}
int lcm_bias_disable(void)
{
return 0;
}
#endif
/* turn on gate ic & control voltage to 5.5V */
/* equle display_bais_enable ,mt6768 need +/-5.5V */
static void lcm_init_power(void)
{
lcm_bias_enable();
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
lcm_bias_disable();
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_cmd, ARRAY_SIZE(init_setting_cmd), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int y0 = y;
unsigned int y1 = y0 + height - 1;
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x30;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00123909;
dsi_set_cmdq(data_array, 1, 0);
}
/* partial update restrictions:
* 1. roi width must be 1080 (full lcm width)
*/
static void lcm_validate_roi(int *x, int *y, int *width, int *height)
{
unsigned int x1, w;
x1 = 0;
w = FRAME_WIDTH;
*x = x1;
*width = w;
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt5081_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_auo_rt5081_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
.validate_roi = lcm_validate_roi,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_auo_rt5081_fhd.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x20,
0x20, 0xc0,
0x15, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xc0, 0x40,
0x40, 0xc0,
0x13, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x50,
0x50, 0xf0,
0x12, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x10,
0x10, 0xc0,
0x10, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x70,
0x70, 0xf0,
0xf, 0x0, 0x2, 0x1, 0x29, 0x4, 0x38, 0x4, 0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,
0xe, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x10, 0xbf,
0x10, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xdf, 0x40,
0x50, 0xef,
0x12, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xcf, 0x5f,
0x40, 0xbf,
0x14, 0x0, 0x3, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x20, 0x20, 0xbf,
0x17, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,637 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#include <linux/regulator/consumer.h>
#include <linux/string.h>
#include <linux/kernel.h>
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (1920)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#define LCM_ID_HX83112B 0x83
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 50, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table init_setting_cmd[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x05, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
}
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
int lcm_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
int lcm_bias_enable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
int lcm_bias_disable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
#else
int lcm_bias_regulator_init(void)
{
return 0;
}
int lcm_bias_enable(void)
{
return 0;
}
int lcm_bias_disable(void)
{
return 0;
}
#endif
/* turn on gate ic & control voltage to 5.5V */
/* equle display_bais_enable ,mt6768 need +/-5.5V */
static void lcm_init_power(void)
{
lcm_bias_enable();
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
lcm_bias_disable();
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_cmd, ARRAY_SIZE(init_setting_cmd), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt5081_fhd_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_auo_rt5081_fhd_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x20,
0x20, 0xc0,
0x15, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xc0, 0x40,
0x40, 0xc0,
0x13, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x50,
0x50, 0xf0,
0x12, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x10,
0x10, 0xc0,
0x10, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0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0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0xaf, 0x20,
0x70, 0xef,
0xe, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x10, 0xbf,
0x10, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xdf, 0x40,
0x50, 0xef,
0x12, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xcf, 0x5f,
0x40, 0xbf,
0x14, 0x0, 0x3, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x20, 0x20, 0xbf,
0x17, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,641 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#include <linux/regulator/consumer.h>
#include <linux/string.h>
#include <linux/kernel.h>
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1440)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (320)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#define LCM_ID_HX83112B 0x83
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 50, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table init_setting_cmd[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x05, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01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FC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
}
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
int lcm_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
int lcm_bias_enable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
int lcm_bias_disable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
#else
int lcm_bias_regulator_init(void)
{
return 0;
}
int lcm_bias_enable(void)
{
return 0;
}
int lcm_bias_disable(void)
{
return 0;
}
#endif
/* turn on gate ic & control voltage to 5.5V */
/* equle display_bais_enable ,mt6768 need +/-5.5V */
static void lcm_init_power(void)
{
lcm_bias_enable();
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
lcm_bias_disable();
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_cmd, ARRAY_SIZE(init_setting_cmd), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp_1560.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x20,
0x20, 0xc0,
0x15, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xc0, 0x40,
0x40, 0xc0,
0x13, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x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 0x9f,
0xa, 0x0, 0x2, 0x1, 0x2a, 0x4, 0x38, 0x4, 0x2, 0x0, 0xcf, 0x30,
0x10, 0xcf,
0xb, 0x0, 0x2, 0x1, 0x29, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x40,
0x20, 0xcf,
0xd, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0xaf, 0x20,
0x70, 0xef,
0xe, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x10, 0xbf,
0x10, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xdf, 0x40,
0x50, 0xef,
0x12, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xcf, 0x5f,
0x40, 0xbf,
0x14, 0x0, 0x3, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x20, 0x20, 0xbf,
0x17, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,641 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#include <linux/regulator/consumer.h>
#include <linux/string.h>
#include <linux/kernel.h>
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1560)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (320)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#define LCM_ID_HX83112B 0x83
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 50, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table init_setting_cmd[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x05, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
}
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
int lcm_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
int lcm_bias_enable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
int lcm_bias_disable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
#else
int lcm_bias_regulator_init(void)
{
return 0;
}
int lcm_bias_enable(void)
{
return 0;
}
int lcm_bias_disable(void)
{
return 0;
}
#endif
/* turn on gate ic & control voltage to 5.5V */
/* equle display_bais_enable ,mt6768 need +/-5.5V */
static void lcm_init_power(void)
{
lcm_bias_enable();
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
lcm_bias_disable();
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_cmd, ARRAY_SIZE(init_setting_cmd), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp_1560_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp_1560_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_fhd_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 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# include <linux/string.h>
# include <linux/kernel.h>
#endif
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
#include "data_hw_roundedpattern.h"
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_HX83112B 0x83
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "lcm_i2c.h"
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (1920)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* i2c control start */
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
.of_match_table = _lcm_i2c_of_match,
},
};
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
/* i2c control end */
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 1;
params->corner_pattern_height = ROUND_CORNER_H_TOP;
params->corner_pattern_height_bot = ROUND_CORNER_H_BOT;
params->corner_pattern_tp_size = sizeof(top_rc_pattern);
params->corner_pattern_lt_addr = (void *)top_rc_pattern;
#endif
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
if (lcm_util.set_gpio_lcd_enp_bias) {
lcm_util.set_gpio_lcd_enp_bias(1);
_lcm_i2c_write_bytes(0x0, 0xf);
_lcm_i2c_write_bytes(0x1, 0xf);
} else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
if (lcm_util.set_gpio_lcd_enp_bias)
lcm_util.set_gpio_lcd_enp_bias(0);
else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_fhd_auo_rt4801_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_fhd_auo_rt4801_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_cmd_hdp_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x20,
0x20, 0xc0,
0x15, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xc0, 0x40,
0x40, 0xc0,
0x13, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x50,
0x50, 0xf0,
0x12, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x10,
0x10, 0xc0,
0x10, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x70,
0x70, 0xf0,
0xf, 0x0, 0x2, 0x1, 0x29, 0x4, 0x38, 0x4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0xef,
0xe, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x10, 0xbf,
0x10, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xdf, 0x40,
0x50, 0xef,
0x12, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xcf, 0x5f,
0x40, 0xbf,
0x14, 0x0, 0x3, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x20, 0x20, 0xbf,
0x17, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,662 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
#include "data_hw_roundedpattern.h"
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_HX83112B 0x83
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "lcm_i2c.h"
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1440)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (320)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* i2c control start */
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
.of_match_table = _lcm_i2c_of_match,
},
};
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
/* i2c control end */
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x09, 0x09, 0x09,
0x09, 0x32, 0x10, 0x09, 0x00, 0x09} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x02, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBC, 0x01, {0x07} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 620;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 480;
params->dsi.PLL_CK_VDO = 440;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 1;
params->corner_pattern_height = ROUND_CORNER_H_TOP;
params->corner_pattern_height_bot = ROUND_CORNER_H_BOT;
params->corner_pattern_tp_size = sizeof(top_rc_pattern);
params->corner_pattern_lt_addr = (void *)top_rc_pattern;
#endif
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
if (lcm_util.set_gpio_lcd_enp_bias) {
lcm_util.set_gpio_lcd_enp_bias(1);
_lcm_i2c_write_bytes(0x0, 0xf);
_lcm_i2c_write_bytes(0x1, 0xf);
} else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
if (lcm_util.set_gpio_lcd_enp_bias)
lcm_util.set_gpio_lcd_enp_bias(0);
else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_hdp_auo_rt4801_lcm_drv = {
.name = "hx83112b_fhdp_dsi_cmd_hdp_auo_rt4801_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_vdo_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern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x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,696 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
#include "data_hw_roundedpattern.h"
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_HX83112B 0x83
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "lcm_i2c.h"
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* i2c control start */
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
.of_match_table = _lcm_i2c_of_match,
},
};
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
/* i2c control end */
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xC2, 0x01, {0x83} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
0x08, 0x32, 0x10, 0x08, 0x00, 0x08} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x00, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static struct dynamic_fps_info lcm_dynamic_fps_setting[] = {
{60, 20},
{50, 458},
{40, 1115},
{30, 2210},
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
unsigned int i = 0;
unsigned int dynamic_fps_levels = 0;
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 20;
params->dsi.vertical_frontporch_for_low_power = 750;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 490;
params->dsi.PLL_CK_CMD = 480;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* mipi hopping part sample */
params->dsi.dynamic_switch_mipi = 1;
//params->dsi.vertical_backporch_dyn = 12;
//PLL_CLOCK * 2, clock no change
params->dsi.data_rate_dyn = 980;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 1;
params->corner_pattern_height = ROUND_CORNER_H_TOP;
params->corner_pattern_height_bot = ROUND_CORNER_H_BOT;
params->corner_pattern_tp_size = sizeof(top_rc_pattern);
params->corner_pattern_lt_addr = (void *)top_rc_pattern;
#endif
/*ARR setting*/
params->dsi.dynamic_fps_levels = 4;
params->max_refresh_rate = 60;
params->min_refresh_rate = 30;
dynamic_fps_levels =
sizeof(lcm_dynamic_fps_setting)/sizeof(struct dynamic_fps_info);
dynamic_fps_levels =
params->dsi.dynamic_fps_levels <
dynamic_fps_levels
? params->dsi.dynamic_fps_levels
: dynamic_fps_levels;
for (i = 0; i < dynamic_fps_levels; i++) {
params->dsi.dynamic_fps_table[i].fps =
lcm_dynamic_fps_setting[i].fps;
params->dsi.dynamic_fps_table[i].vfp =
lcm_dynamic_fps_setting[i].vfp;
/* params->dsi.dynamic_fps_table[i].idle_check_interval =
* lcm_dynamic_fps_setting[i].idle_check_interval;
*/
}
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
if (lcm_util.set_gpio_lcd_enp_bias) {
lcm_util.set_gpio_lcd_enp_bias(1);
_lcm_i2c_write_bytes(0x0, 0xf);
_lcm_i2c_write_bytes(0x1, 0xf);
} else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
if (lcm_util.set_gpio_lcd_enp_bias)
lcm_util.set_gpio_lcd_enp_bias(0);
else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_auo_rt4801_lcm_drv = {
.name = "hx83112b_fhdp_dsi_vdo_auo_rt4801_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_vdo_auo_rt5081.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA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x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,627 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#define LCM_ID_HX83112B 0x83
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 50, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xC2, 0x01, {0x83} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
0x08, 0x32, 0x10, 0x08, 0x00, 0x08} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x00, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 150, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 23;
params->dsi.vertical_frontporch_for_low_power = 750;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 487;
params->dsi.PLL_CK_CMD = 480;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
}
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
int lcm_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
int lcm_bias_enable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
int lcm_bias_disable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
#else
int lcm_bias_regulator_init(void)
{
return 0;
}
int lcm_bias_enable(void)
{
return 0;
}
int lcm_bias_disable(void)
{
return 0;
}
#endif
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
lcm_bias_enable();
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
lcm_bias_disable();
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_auo_rt5081_lcm_drv = {
.name = "hx83112b_fhdp_dsi_vdo_auo_rt5081_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_vdo_auo_rt5081_hdp.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_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x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,632 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1440)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (320)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#define LCM_ID_HX83112B 0x83
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 50, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xC2, 0x01, {0x83} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
0x08, 0x32, 0x10, 0x08, 0x00, 0x08} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x00, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 150, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 23;
params->dsi.vertical_frontporch_for_low_power = 750;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 487;
params->dsi.PLL_CK_CMD = 480;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
}
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
int lcm_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
int lcm_bias_enable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5500000, 5500000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
int lcm_bias_disable(void)
{
int ret = 0;
int retval = 0;
lcm_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
#else
int lcm_bias_regulator_init(void)
{
return 0;
}
int lcm_bias_enable(void)
{
return 0;
}
int lcm_bias_disable(void)
{
return 0;
}
#endif
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
lcm_bias_enable();
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
lcm_bias_disable();
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_auo_rt5081_hdp_lcm_drv = {
.name = "hx83112b_fhdp_dsi_vdo_auo_rt5081_hdp_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_vdo_fhd_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20,
0x20, 0xa0,
0x17, 0x0, 0x2, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x20,
0x20, 0xc0,
0x15, 0x0, 0x2, 0x1, 0x23, 0x4, 0x38, 0x4, 0x2, 0x0, 0xc0, 0x40,
0x40, 0xc0,
0x13, 0x0, 0x2, 0x1, 0x25, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x50,
0x50, 0xf0,
0x12, 0x0, 0x2, 0x1, 0x26, 0x4, 0x38, 0x4, 0x2, 0x0, 0xb0, 0x10,
0x10, 0xc0,
0x10, 0x0, 0x2, 0x1, 0x28, 0x4, 0x38, 0x4, 0x2, 0x0, 0xf0, 0x70,
0x70, 0xf0,
0xf, 0x0, 0x2, 0x1, 0x29, 0x4, 0x38, 0x4, 0x2, 0x0, 0xd0, 0x20,
0x20, 0xd0,
0xe, 0x0, 0x2, 0x1, 0x2a, 0x4, 0x38, 0x4, 0x2, 0x0, 0xd0, 0x10,
0x10, 0xd0,
0xd, 0x0, 0x1, 0x1, 0x2b, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x10,
0xa0,
0xc, 0x0, 0x1, 0x1, 0x2c, 0x4, 0x38, 0x4, 0x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f,
0x14, 0x0, 0x3, 0x1, 0x21, 0x4, 0x38, 0x4, 0x2, 0x0, 0xef, 0x7f,
0x20, 0x20, 0xbf,
0x17, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0x9f, 0x4f,
0x20, 0x9f,
0x19, 0x0, 0x4, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xef, 0x9f,
0x5f, 0x10, 0x10, 0x5f, 0xbf,
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xbf, 0x6f,
0x20, 0x30, 0x9f, 0xef,
};
#endif
@@ -0,0 +1,663 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
#include "data_hw_roundedpattern.h"
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_HX83112B 0x83
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "lcm_i2c.h"
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (1920)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* i2c control start */
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
.of_match_table = _lcm_i2c_of_match,
},
};
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
/* i2c control end */
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xC2, 0x01, {0x83} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
0x08, 0x32, 0x10, 0x08, 0x00, 0x08} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x00, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 20;
params->dsi.vertical_frontporch_for_low_power = 750;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 490;
params->dsi.PLL_CK_CMD = 480;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 1;
params->corner_pattern_height = ROUND_CORNER_H_TOP;
params->corner_pattern_height_bot = ROUND_CORNER_H_BOT;
params->corner_pattern_tp_size = sizeof(top_rc_pattern);
params->corner_pattern_lt_addr = (void *)top_rc_pattern;
#endif
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
if (lcm_util.set_gpio_lcd_enp_bias) {
lcm_util.set_gpio_lcd_enp_bias(1);
_lcm_i2c_write_bytes(0x0, 0xf);
_lcm_i2c_write_bytes(0x1, 0xf);
} else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
if (lcm_util.set_gpio_lcd_enp_bias)
lcm_util.set_gpio_lcd_enp_bias(0);
else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_fhd_auo_rt4801_lcm_drv = {
.name = "hx83112b_fhdp_dsi_vdo_fhd_auo_rt4801_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += hx83112b_fhdp_dsi_vdo_hdp_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,111 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0,
0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60,
0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x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2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
# include <linux/string.h>
# include <linux/kernel.h>
#endif
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
#include "data_hw_roundedpattern.h"
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
# include <platform/upmu_common.h>
# include <platform/mt_gpio.h>
# include <platform/mt_i2c.h>
# include <platform/mt_pmic.h>
# include <string.h>
#elif defined(BUILD_UBOOT)
# include <asm/arch/mt_gpio.h>
#endif
#ifdef BUILD_LK
# define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
# define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
# define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
# define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_HX83112B 0x83
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/init.h>
# include <linux/list.h>
# include <linux/i2c.h>
# include <linux/irq.h>
# include <linux/uaccess.h>
# include <linux/interrupt.h>
# include <linux/io.h>
# include <linux/platform_device.h>
#endif
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include "lcm_i2c.h"
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1440)
#define VIRTUAL_WIDTH (1080)
#define VIRTUAL_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (64500)
#define LCM_PHYSICAL_HEIGHT (129000)
#define LCM_DENSITY (320)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* i2c control start */
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
.of_match_table = _lcm_i2c_of_match,
},
};
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
/* i2c control end */
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
};
static struct LCM_setting_table init_setting_vdo[] = {
{0xB9, 0x03, {0x83, 0x11, 0x2B} },
{0xB1, 0x0A, {0xF8, 0x29, 0x29, 0x00, 0x00, 0x0F, 0x14, 0x0F,
0x14, 0x33} },
{0xD2, 0x02, {0x2C, 0x2C} },
{0xB2, 0x0B, {0x80, 0x02, 0x00, 0x80, 0x70, 0x00, 0x08, 0x1C,
0x09, 0x01, 0x04} },
{0xE9, 0x01, {0xD1} },
{0xB2, 0x02, {0x00, 0x08} },
{0xE9, 0x01, {0x00} },
{0xE9, 0x01, {0xCE} },
{0xB2, 0x01, {0xA3} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x02} },
{0xB2, 0x02, {0xB5, 0x0A} },
{0xBD, 0x01, {0x00} },
{0xDD, 0x08, {0x00, 0x00, 0x08, 0x1C, 0x09, 0x34, 0x34, 0x8B} },
{0xB4, 0x18, {0x01, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD0,
0x00, 0x00, 0x0F, 0xCB, 0x01, 0x00, 0x00, 0x13,
0x00, 0x2E, 0x08, 0x01, 0x12, 0x00, 0x00, 0x2E} },
{0xBD, 0x01, {0x02} },
{0xB4, 0x01, {0x92} },
{0xBD, 0x01, {0x00} },
{0xB6, 0x03, {0x81, 0x81, 0xE3} },
{0xC0, 0x01, {0x44} },
{0xC2, 0x01, {0x83} },
{0xCC, 0x01, {0x08} },
{0xBD, 0x01, {0x03} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x02} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x01} },
{0xC1, 0x39, {0xFF, 0xFA, 0xF6, 0xF3, 0xEF, 0xEB, 0xE7, 0xE0,
0xDC, 0xD9, 0xD6, 0xD2, 0xCF, 0xCB, 0xC7, 0xC3,
0xBF, 0xBB, 0xB7, 0xB0, 0xA8, 0xA1, 0x9A, 0x92,
0x89, 0x81, 0x7A, 0x73, 0x6B, 0x63, 0x5A, 0x51,
0x48, 0x40, 0x38, 0x31, 0x29, 0x20, 0x16, 0x0D,
0x09, 0x07, 0x05, 0x02, 0x00, 0x08, 0x2E, 0xF6,
0x20, 0x18, 0x94, 0xF8, 0x6F, 0x59, 0x18, 0xFC,
0x00} },
{0xBD, 0x01, {0x00} },
{0xC1, 0x01, {0x01} },
{0xD3, 0x16, {0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A,
0x0A, 0x07, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08,
0x08, 0x32, 0x10, 0x08, 0x00, 0x08} },
{0xE9, 0x01, {0xE3} },
{0xD3, 0x03, {0x05, 0x08, 0x86} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC8} },
{0xD3, 0x01, {0x81} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD5, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x21, 0x20, 0x18, 0x18, 0x19, 0x19, 0x18, 0x18,
0x03, 0x03, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 0x30, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x31, 0x31, 0x30, 0x30, 0x2F, 0x2F, 0x31, 0x31,
0x30, 0x30, 0x2F, 0x2F, 0xC0, 0x18, 0x40, 0x40,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01,
0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19,
0x20, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD8, 0x18, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xBD, 0x01, {0x01} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA} },
{0xBD, 0x01, {0x02} },
{0xD8, 0x0C, {0xAF, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA, 0xAA, 0xFF,
0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x03} },
{0xD8, 0x18, {0xAA, 0xAA, 0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xAA,
0xAB, 0xAA, 0xAE, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA,
0xBA, 0xAA, 0xAA, 0xFF, 0xFA, 0xAA, 0xBA, 0xAA} },
{0xBD, 0x01, {0x00} },
{0xE7, 0x19, {0x09, 0x09, 0x00, 0x07, 0xE6, 0x00, 0x27, 0x00,
0x07, 0x00, 0x00, 0xE6, 0x2A, 0x00, 0xE6, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x12,
0x04} },
{0xE9, 0x01, {0xE4} },
{0xE7, 0x02, {0x17, 0x69} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x01} },
{0xE7, 0x09, {0x00, 0x00, 0x01, 0x20, 0x01, 0x0E, 0x08, 0xEE,
0x09} },
{0xBD, 0x01, {0x02} },
{0xE7, 0x03, {0x20, 0x20, 0x00} },
{0xBD, 0x01, {0x03} },
{0xE7, 0x06, {0x00, 0x08, 0x01, 0x00, 0x00, 0x20} },
{0xE9, 0x01, {0xC9} },
{0xE7, 0x02, {0x2E, 0xCB} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0xD1, 0x01, {0x27} },
{0xBD, 0x01, {0x01} },
{0xE9, 0x01, {0xC2} },
{0xCB, 0x01, {0x27} },
{0xE9, 0x01, {0x00} },
{0xBD, 0x01, {0x00} },
{0x51, 0x02, {0x0F, 0xFF} },
{0x53, 0x01, {0x24} },
{0x55, 0x01, {0x00} },
{0x35, 0x01, {0x00} },
{0x44, 2, {0x08, 0x66} }, /* set TE event @ line 0x866(2150) */
{0x11, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0xE9, 0x01, {0xC2} },
{0xB0, 0x01, {0x01} },
{0xE9, 0x01, {0x00} },
{0x29, 0, {} },
{REGFLAG_DELAY, 20, {} },
};
static struct LCM_setting_table
__maybe_unused lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 150, {} },
};
static struct LCM_setting_table __maybe_unused lcm_sleep_out_setting[] = {
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 50, {} },
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->virtual_width = VIRTUAL_WIDTH;
params->virtual_height = VIRTUAL_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
LCM_LOGI("%s: lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 20;
params->dsi.vertical_frontporch_for_low_power = 750;
params->dsi.vertical_active_line = VIRTUAL_HEIGHT;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 40;
params->dsi.horizontal_active_pixel = VIRTUAL_WIDTH;
/* params->dsi.ssc_disable = 1; */
#ifndef CONFIG_FPGA_EARLY_PORTING
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 490;
params->dsi.PLL_CK_CMD = 480;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9d;
/* for ARR 2.0 */
params->max_refresh_rate = 60;
params->min_refresh_rate = 45;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->round_corner_en = 1;
params->corner_pattern_height = ROUND_CORNER_H_TOP;
params->corner_pattern_height_bot = ROUND_CORNER_H_BOT;
params->corner_pattern_tp_size = sizeof(top_rc_pattern);
params->corner_pattern_lt_addr = (void *)top_rc_pattern;
#endif
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_init_power(void)
{
if (lcm_util.set_gpio_lcd_enp_bias) {
lcm_util.set_gpio_lcd_enp_bias(1);
_lcm_i2c_write_bytes(0x0, 0xf);
_lcm_i2c_write_bytes(0x1, 0xf);
} else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
static void lcm_suspend_power(void)
{
SET_RESET_PIN(0);
if (lcm_util.set_gpio_lcd_enp_bias)
lcm_util.set_gpio_lcd_enp_bias(0);
else
LCM_LOGI("set_gpio_lcd_enp_bias not defined...\n");
}
/* turn on gate ic & control voltage to 5.5V */
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
lcm_init_power();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo, ARRAY_SIZE(init_setting_vdo), 1);
LCM_LOGI("hx83112b_fhdp----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
ARRAY_SIZE(lcm_suspend_setting), 1);
}
static void lcm_resume(void)
{
lcm_init();
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int id[3] = {0x83, 0x11, 0x2B};
unsigned int data_array[3];
unsigned char read_buf[3];
data_array[0] = 0x00033700; /* set max return size = 3 */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, read_buf, 3); /* read lcm id */
LCM_LOGI("ATA read = 0x%x, 0x%x, 0x%x\n",
read_buf[0], read_buf[1], read_buf[2]);
if ((read_buf[0] == id[0]) &&
(read_buf[1] == id[1]) &&
(read_buf[2] == id[2]))
ret = 1;
else
ret = 0;
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,hx83112b backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
#ifdef LCM_SET_DISPLAY_ON_DELAY
lcm_set_display_on();
#endif
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0;
unsigned char buffer[1];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00013700; /* read id return 1byte */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xDA, buffer, 1);
id = buffer[0]; /* we only need ID */
LCM_LOGI("%s,hx83112b id = 0x%08x\n", __func__, id);
if (id == LCM_ID_HX83112B)
return 1;
else
return 0;
}
struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_hdp_auo_rt4801_lcm_drv = {
.name = "hx83112b_fhdp_dsi_vdo_hdp_auo_rt4801_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.compare_id = lcm_compare_id,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += ili9881c_hd_dsi_vdo_ilitek_nt50358.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,958 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 MediaTek Inc.
*
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
#include <linux/string.h>
#include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#else
/*#include <mach/mt_pm_ldo.h>*/
#ifdef CONFIG_MTK_LEGACY
#include <mach/mt_gpio.h>
#endif
#endif
#ifdef CONFIG_MTK_LEGACY
#include <cust_gpio_usage.h>
#endif
#ifndef CONFIG_FPGA_EARLY_PORTING
#if defined(CONFIG_MTK_LEGACY)
#include <cust_i2c.h>
#endif
#endif
#ifdef BUILD_LK
#define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
#define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
#define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID (0x98)
static const unsigned int BL_MIN_LEVEL = 20;
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) \
lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define set_gpio_lcd_enp(cmd) \
lcm_util.set_gpio_lcd_enp_bias(cmd)
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
/* #include <linux/jiffies.h> */
/* #include <linux/delay.h> */
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#ifndef CONFIG_FPGA_EARLY_PORTING
#define I2C_I2C_LCD_BIAS_CHANNEL 0
#define TPS_I2C_BUSNUM I2C_I2C_LCD_BIAS_CHANNEL /* for I2C channel 0 */
#define I2C_ID_NAME "tps65132"
#define TPS_ADDR 0x3E
#if defined(CONFIG_MTK_LEGACY)
static struct i2c_board_info tps65132_board_info __initdata = {
I2C_BOARD_INFO(I2C_ID_NAME, TPS_ADDR)
};
#endif
#if !defined(CONFIG_MTK_LEGACY)
static const struct of_device_id lcm_of_match[] = {
{.compatible = "mediatek,I2C_LCD_BIAS"},
{},
};
#endif
/*static struct i2c_client *tps65132_i2c_client;*/
struct i2c_client *tps65132_i2c_client;
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int tps65132_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int tps65132_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct tps65132_dev {
struct i2c_client *client;
};
static const struct i2c_device_id tps65132_id[] = {
{I2C_ID_NAME, 0},
{}
};
/* #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
/* static struct i2c_client_address_data addr_data = { .forces = forces,}; */
/* #endif */
static struct i2c_driver tps65132_iic_driver = {
.id_table = tps65132_id,
.probe = tps65132_probe,
.remove = tps65132_remove,
/* .detect = mt6605_detect, */
.driver = {
.owner = THIS_MODULE,
.name = "tps65132",
#if !defined(CONFIG_MTK_LEGACY)
.of_match_table = lcm_of_match,
#endif
},
};
static int tps65132_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
LCM_LOGI("tps65132_iic_probe\n");
LCM_LOGI("TPS: info==>name=%s addr=0x%x\n", client->name, client->addr);
tps65132_i2c_client = client;
return 0;
}
static int tps65132_remove(struct i2c_client *client)
{
LCM_LOGI("%s\n", __func__);
tps65132_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
/*static int tps65132_write_bytes(unsigned char addr, unsigned char value)*/
#if !defined(CONFIG_ARCH_MT6797)
int tps65132_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = tps65132_i2c_client;
char write_data[2] = { 0 };
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
LCM_LOGI("tps65132 write data fail !!\n");
return ret;
}
#endif
static int __init tps65132_iic_init(void)
{
LCM_LOGI("%s\n", __func__);
#if defined(CONFIG_MTK_LEGACY)
i2c_register_board_info(TPS_I2C_BUSNUM, &tps65132_board_info, 1);
#endif
LCM_LOGI("tps65132_iic_init2\n");
i2c_add_driver(&tps65132_iic_driver);
LCM_LOGI("%s success\n", __func__);
return 0;
}
static void __exit tps65132_iic_exit(void)
{
LCM_LOGI("%s\n", __func__);
i2c_del_driver(&tps65132_iic_driver);
}
module_init(tps65132_iic_init);
module_exit(tps65132_iic_exit);
MODULE_AUTHOR("Mike Liu");
MODULE_DESCRIPTION("MTK TPS65132 I2C Driver");
MODULE_LICENSE("GPL");
#endif
#endif
/* static unsigned char lcd_id_pins_value = 0xFF; */
static const unsigned char LCD_MODULE_ID = 0x01;
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1440)
#define LCM_DENSITY (320)
#define LCM_PHYSICAL_WIDTH (64800)
#define LCM_PHYSICAL_HEIGHT (129600)
#ifndef CONFIG_FPGA_EARLY_PORTING
#define GPIO_65132_EN GPIO_LCD_BIAS_ENP_PIN
#endif
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
static struct LCM_DSI_MODE_SWITCH_CMD lcm_switch_mode_cmd;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0x4F, 1, {0x01} },
{REGFLAG_DELAY, 120, {} }
};
static struct LCM_setting_table init_setting[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x03} },
/* GIP_1 */
{ 0x01, 0x01, {0x00} },
{ 0x02, 0x01, {0x00} },
{ 0x03, 0x01, {0x53} },
{ 0x04, 0x01, {0x13} },
{ 0x05, 0x01, {0x00} },
{ 0x06, 0x01, {0x03} },
{ 0x07, 0x01, {0x02} },
{ 0x08, 0x01, {0x00} },
{ 0x09, 0x01, {0x28} },
{ 0x0a, 0x01, {0x28} },
{ 0x0b, 0x01, {0x00} },
{ 0x0c, 0x01, {0x01} },
{ 0x0d, 0x01, {0x00} },
{ 0x0e, 0x01, {0x00} },
{ 0x0f, 0x01, {0x28} },
{ 0x10, 0x01, {0x28} },
{ 0x11, 0x01, {0x00} },
{ 0x12, 0x01, {0x00} },
{ 0x13, 0x01, {0x00} },
{ 0x14, 0x01, {0x00} },
{ 0x15, 0x01, {0x00} },
{ 0x16, 0x01, {0x00} },
{ 0x17, 0x01, {0x00} },
{ 0x18, 0x01, {0x00} },
{ 0x19, 0x01, {0x00} },
{ 0x1a, 0x01, {0x00} },
{ 0x1b, 0x01, {0x00} },
{ 0x1c, 0x01, {0x00} },
{ 0x1d, 0x01, {0x00} },
{ 0x1e, 0x01, {0x44} },
{ 0x1f, 0x01, {0x80} },
{ 0x20, 0x01, {0x01} },
{ 0x21, 0x01, {0x02} },
{ 0x22, 0x01, {0x00} },
{ 0x23, 0x01, {0x00} },
{ 0x24, 0x01, {0x00} },
{ 0x25, 0x01, {0x00} },
{ 0x26, 0x01, {0x00} },
{ 0x27, 0x01, {0x00} },
{ 0x28, 0x01, {0x33} },
{ 0x29, 0x01, {0x03} },
{ 0x2a, 0x01, {0x00} },
{ 0x2b, 0x01, {0x00} },
{ 0x2c, 0x01, {0x00} },
{ 0x2d, 0x01, {0x00} },
{ 0x2e, 0x01, {0x00} },
{ 0x2f, 0x01, {0x00} },
{ 0x30, 0x01, {0x00} },
{ 0x31, 0x01, {0x00} },
{ 0x32, 0x01, {0x00} },
{ 0x33, 0x01, {0x00} },
{ 0x34, 0x01, {0x04} },
{ 0x35, 0x01, {0x00} },
{ 0x36, 0x01, {0x00} },
{ 0x37, 0x01, {0x00} },
{ 0x38, 0x01, {0x3c} },
{ 0x39, 0x01, {0x00} },
{ 0x3a, 0x01, {0x40} },
{ 0x3b, 0x01, {0x00} },
{ 0x3c, 0x01, {0x00} },
{ 0x3d, 0x01, {0x00} },
{ 0x3e, 0x01, {0x00} },
{ 0x3f, 0x01, {0x00} },
{ 0x40, 0x01, {0x00} },
{ 0x41, 0x01, {0x00} },
{ 0x42, 0x01, {0x00} },
{ 0x43, 0x01, {0x00} },
{ 0x44, 0x01, {0x00} },
{REGFLAG_UDELAY, 100, {} },
/* GIP_2 */
{ 0x50, 0x01, {0x01} },
{ 0x51, 0x01, {0x23} },
{ 0x52, 0x01, {0x45} },
{ 0x53, 0x01, {0x67} },
{ 0x54, 0x01, {0x89} },
{ 0x55, 0x01, {0xab} },
{ 0x56, 0x01, {0x01} },
{ 0x57, 0x01, {0x23} },
{ 0x58, 0x01, {0x45} },
{ 0x59, 0x01, {0x67} },
{ 0x5a, 0x01, {0x89} },
{ 0x5b, 0x01, {0xab} },
{ 0x5c, 0x01, {0xcd} },
{ 0x5d, 0x01, {0xef} },
{REGFLAG_UDELAY, 100, {} },
/* GIP_3 */
{ 0x5e, 0x01, {0x11} },
{ 0x5f, 0x01, {0x01} },
{ 0x60, 0x01, {0x00} },
{ 0x61, 0x01, {0x15} },
{ 0x62, 0x01, {0x14} },
{ 0x63, 0x01, {0x0c} },
{ 0x64, 0x01, {0x0d} },
{ 0x65, 0x01, {0x0e} },
{ 0x66, 0x01, {0x0f} },
{ 0x67, 0x01, {0x06} },
{ 0x68, 0x01, {0x02} },
{ 0x69, 0x01, {0x02} },
{ 0x6a, 0x01, {0x02} },
{ 0x6b, 0x01, {0x02} },
{ 0x6c, 0x01, {0x02} },
{ 0x6d, 0x01, {0x02} },
{ 0x6e, 0x01, {0x08} },
{ 0x6f, 0x01, {0x02} },
{ 0x70, 0x01, {0x02} },
{ 0x71, 0x01, {0x02} },
{ 0x72, 0x01, {0x02} },
{ 0x73, 0x01, {0x02} },
{ 0x74, 0x01, {0x02} },
{ 0x75, 0x01, {0x01} },
{ 0x76, 0x01, {0x00} },
{ 0x77, 0x01, {0x15} },
{ 0x78, 0x01, {0x14} },
{ 0x79, 0x01, {0x0C} },
{ 0x7a, 0x01, {0x0D} },
{ 0x7b, 0x01, {0x0e} },
{ 0x7c, 0x01, {0x0f} },
{ 0x7d, 0x01, {0x08} },
{ 0x7e, 0x01, {0x02} },
{ 0x7f, 0x01, {0x02} },
{ 0x80, 0x01, {0x02} },
{ 0x81, 0x01, {0x02} },
{ 0x82, 0x01, {0x02} },
{ 0x83, 0x01, {0x02} },
{ 0x84, 0x01, {0x06} },
{ 0x85, 0x01, {0x02} },
{ 0x86, 0x01, {0x02} },
{ 0x87, 0x01, {0x02} },
{ 0x88, 0x01, {0x02} },
{ 0x89, 0x01, {0x02} },
{ 0x8A, 0x01, {0x02} },
{REGFLAG_UDELAY, 100, {} },
/* CMD_Page 4 */
{ 0xFF, 0x03, {0x98, 0x81, 0x04} },
{ 0x6C, 0x01, {0x15} },
{ 0x6E, 0x01, {0x2b} },
{ 0x6F, 0x01, {0x35} },
{ 0x35, 0x01, {0x1f} },
{ 0x3A, 0x01, {0x24} },
{ 0x8D, 0x01, {0x14} },
{ 0x87, 0x01, {0xBA} },
{ 0x26, 0x01, {0x76} },
{ 0xB2, 0x01, {0xD1} },
{ 0xB5, 0x01, {0x06} },
{ 0x33, 0x01, {0x14} },
{ 0x7a, 0x01, {0x10} },
{REGFLAG_UDELAY, 100, {} },
/* CMD_Page 1 */
{ 0xFF, 0x03, {0x98, 0x81, 0x01} },
{ 0x22, 0x01, {0x0A} },
{ 0x31, 0x01, {0x00} },
{ 0x53, 0x01, {0x83} },
{ 0x55, 0x01, {0x9C} },
{ 0x50, 0x01, {0xC7} },
{ 0x51, 0x01, {0xC4} },
{ 0x60, 0x01, {0x1A} },
{ 0x62, 0x01, {0x00} },
{ 0x63, 0x01, {0x00} },
{ 0x2E, 0x01, {0xF0} },
/* ============Gamma START============= */
/* Pos Register */
{ 0xA0, 0x01, {0x02} },
{ 0xA1, 0x01, {0x22} },
{ 0xA2, 0x01, {0x31} },
{ 0xA3, 0x01, {0x15} },
{ 0xA4, 0x01, {0x19} },
{ 0xA5, 0x01, {0x2B} },
{ 0xA6, 0x01, {0x1F} },
{ 0xA7, 0x01, {0x20} },
{ 0xA8, 0x01, {0x92} },
{ 0xA9, 0x01, {0x1C} },
{ 0xAA, 0x01, {0x28} },
{ 0xAB, 0x01, {0x7C} },
{ 0xAC, 0x01, {0x1B} },
{ 0xAD, 0x01, {0x1B} },
{ 0xAE, 0x01, {0x4F} },
{ 0xAF, 0x01, {0x23} },
{ 0xB0, 0x01, {0x29} },
{ 0xB1, 0x01, {0x56} },
{ 0xB2, 0x01, {0x5F} },
{ 0xB3, 0x01, {0x3F} },
/* Neg Register */
{ 0xC0, 0x01, {0x02} },
{ 0xC1, 0x01, {0x22} },
{ 0xC2, 0x01, {0x31} },
{ 0xC3, 0x01, {0x15} },
{ 0xC4, 0x01, {0x19} },
{ 0xC5, 0x01, {0x2B} },
{ 0xC6, 0x01, {0x1F} },
{ 0xC7, 0x01, {0x20} },
{ 0xC8, 0x01, {0x92} },
{ 0xC9, 0x01, {0x1C} },
{ 0xCA, 0x01, {0x28} },
{ 0xCB, 0x01, {0x7C} },
{ 0xCC, 0x01, {0x1B} },
{ 0xCD, 0x01, {0x1B} },
{ 0xCE, 0x01, {0x4F} },
{ 0xCF, 0x01, {0x23} },
{ 0xD0, 0x01, {0x29} },
{ 0xD1, 0x01, {0x56} },
{ 0xD2, 0x01, {0x5F} },
{ 0xD3, 0x01, {0x3F} },
/* ============ Gamma END=========== */
/* CMD_Page 0 */
{ 0xFF, 0x03, {0x98, 0x81, 0x00} },
{ 0x35, 0x01, {0x00} },
{ 0x11, 0x01, {0x00} },
{REGFLAG_DELAY, 120, {} },
{ 0x29, 0x01, {0x00} },
{REGFLAG_DELAY, 20, {} }
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH/1000;
params->physical_height = LCM_PHYSICAL_HEIGHT/1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
#endif
LCM_LOGI("%s lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 16;
params->dsi.vertical_frontporch = 40;
params->dsi.vertical_frontporch_for_low_power = 540;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 20;
params->dsi.horizontal_backporch = 80;
params->dsi.horizontal_frontporch = 80;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.ssc_disable = 1;
#ifndef CONFIG_FPGA_EARLY_PORTING
#if (LCM_DSI_CMD_MODE)
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 220;
#else
/* this value must be in MTK suggested table */
params->dsi.PLL_CLOCK = 255;
#endif
params->dsi.PLL_CK_CMD = 220;
params->dsi.PLL_CK_VDO = 255;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
#ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
params->corner_pattern_width = 32;
params->corner_pattern_height = 32;
#endif
}
#ifdef BUILD_LK
#ifndef CONFIG_FPGA_EARLY_PORTING
#define TPS65132_SLAVE_ADDR_WRITE 0x7C
static struct mt_i2c_t TPS65132_i2c;
static int TPS65132_write_byte(kal_uint8 addr, kal_uint8 value)
{
kal_uint32 ret_code = I2C_OK;
kal_uint8 write_data[2];
kal_uint16 len;
write_data[0] = addr;
write_data[1] = value;
TPS65132_i2c.id = I2C_I2C_LCD_BIAS_CHANNEL; /* I2C2; */
/* Since i2c will left shift 1 bit, we need to set FAN5405 I2C address to >>1 */
TPS65132_i2c.addr = (TPS65132_SLAVE_ADDR_WRITE >> 1);
TPS65132_i2c.mode = ST_MODE;
TPS65132_i2c.speed = 100;
len = 2;
ret_code = i2c_write(&TPS65132_i2c, write_data, len);
/* printf("%s: i2c_write: ret_code: %d\n", __func__, ret_code); */
return ret_code;
}
#else
/* extern int mt8193_i2c_write(u16 addr, u32 data); */
/* extern int mt8193_i2c_read(u16 addr, u32 *data); */
/* #define TPS65132_write_byte(add, data) mt8193_i2c_write(add, data) */
/* #define TPS65132_read_byte(add) mt8193_i2c_read(add) */
#endif
#endif
static void lcm_init_power(void)
{
}
static void lcm_suspend_power(void)
{
}
static void lcm_resume_power(void)
{
}
static void lcm_init(void)
{
unsigned char cmd = 0x0;
unsigned char data = 0xFF;
#ifndef CONFIG_FPGA_EARLY_PORTING
int ret = 0;
#endif
cmd = 0x00;
data = 0x0E;
SET_RESET_PIN(0);
#ifndef CONFIG_FPGA_EARLY_PORTING
#ifdef CONFIG_MTK_LEGACY
mt_set_gpio_mode(GPIO_65132_EN, GPIO_MODE_00);
mt_set_gpio_dir(GPIO_65132_EN, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO_65132_EN, GPIO_OUT_ONE);
#else
set_gpio_lcd_enp(1);
#endif
MDELAY(5);
#ifdef BUILD_LK
ret = TPS65132_write_byte(cmd, data);
#else
#if !defined(CONFIG_ARCH_MT6797)
ret = tps65132_write_bytes(cmd, data);
#endif
#endif
if (ret < 0) {
pr_info("ili9881c----tps6132----cmd=%0x--i2c write error----\n",
cmd);
} else {
pr_info("ili9881c----tps6132----cmd=%0x--i2c write success----\n",
cmd);
}
cmd = 0x01;
data = 0x0E;
#ifdef BUILD_LK
ret = TPS65132_write_byte(cmd, data);
#else
#if !defined(CONFIG_ARCH_MT6797)
ret = tps65132_write_bytes(cmd, data);
#endif
#endif
if (ret < 0) {
pr_info("ili9881c----tps6132----cmd=%0x--i2c write error----\n",
cmd);
} else {
pr_info("ili9881c----tps6132----cmd=%0x--i2c write success----\n",
cmd);
}
#endif
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
if (lcm_dsi_mode == CMD_MODE) {
LCM_LOGI("ili9881c----not support ----lcm mode\n");
} else {
push_table(NULL, init_setting,
sizeof(init_setting) / sizeof(struct LCM_setting_table),
1);
LCM_LOGI("ili9881c----tps6132----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table),
1);
MDELAY(10);
#ifndef CONFIG_FPGA_EARLY_PORTING
#ifdef CONFIG_MTK_LEGACY
mt_set_gpio_mode(GPIO_65132_EN, GPIO_MODE_00);
mt_set_gpio_dir(GPIO_65132_EN, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO_65132_EN, GPIO_OUT_ZERO);
#else
set_gpio_lcd_enp(0);
#endif
#endif
/*SET_RESET_PIN(0);*/
}
static void lcm_resume(void)
{
lcm_init();
}
static void lcm_update(unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0, version_id = 0;
unsigned char buffer[2];
unsigned int array[16];
struct LCM_setting_table switch_table_page1[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x01} }
};
struct LCM_setting_table switch_table_page0[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x00} }
};
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
push_table(NULL, switch_table_page1,
sizeof(switch_table_page1) / sizeof(struct LCM_setting_table),
1);
array[0] = 0x00023700; /* read id return two byte,version and id */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0x00, buffer, 1);
id = buffer[0]; /* we only need ID */
read_reg_v2(0x01, buffer, 1);
version_id = buffer[0];
LCM_LOGI("%s,ili9881c_id=0x%08x,version_id=0x%x\n",
__func__, id, version_id);
push_table(NULL, switch_table_page0,
sizeof(switch_table_page0) / sizeof(struct LCM_setting_table),
1);
if (id == LCM_ID && version_id == 0x81)
return 1;
else
return 0;
}
/* return TRUE: need recovery */
/* return FALSE: No need recovery */
static unsigned int lcm_esd_check(void)
{
#ifndef BUILD_LK
char buffer[3];
int array[4];
array[0] = 0x00013700;
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0x53, buffer, 1);
if (buffer[0] != 0x24) {
LCM_LOGI("[LCM ERROR] [0x53]=0x%02x\n", buffer[0]);
return TRUE;
}
LCM_LOGI("[LCM NORMAL] [0x53]=0x%02x\n", buffer[0]);
return FALSE;
#else
return FALSE;
#endif
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int x0 = FRAME_WIDTH / 4;
unsigned int x1 = FRAME_WIDTH * 3 / 4;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned int data_array[3];
unsigned char read_buf[4];
LCM_LOGI("ATA check size = 0x%x,0x%x,0x%x,0x%x\n",
x0_MSB, x0_LSB, x1_MSB, x1_LSB);
data_array[0] = 0x0005390A; /* HS packet */
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00043700;/* read id return two byte,version and id */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x2A, read_buf, 4);
if ((read_buf[0] == x0_MSB) && (read_buf[1] == x0_LSB)
&& (read_buf[2] == x1_MSB) && (read_buf[3] == x1_LSB))
ret = 1;
else
ret = 0;
x0 = 0;
x1 = FRAME_WIDTH - 1;
x0_MSB = ((x0 >> 8) & 0xFF);
x0_LSB = (x0 & 0xFF);
x1_MSB = ((x1 >> 8) & 0xFF);
x1_LSB = (x1 & 0xFF);
data_array[0] = 0x0005390A; /* HS packet */
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,ili9881c backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level,
sizeof(bl_level) / sizeof(struct LCM_setting_table), 1);
}
static void *lcm_switch_mode(int mode)
{
#ifndef BUILD_LK
/* customization:
* 1. V2C config 2 values, C2V config 1 value;
* 2. config mode control register
*/
if (mode == 0) { /* V2C */
lcm_switch_mode_cmd.mode = CMD_MODE;
lcm_switch_mode_cmd.addr = 0xBB; /* mode control addr */
/* enabel GRAM firstly, ensure writing one frame to GRAM */
lcm_switch_mode_cmd.val[0] = 0x13;
/* disable video mode secondly */
lcm_switch_mode_cmd.val[1] = 0x10;
} else { /* C2V */
lcm_switch_mode_cmd.mode = SYNC_PULSE_VDO_MODE;
lcm_switch_mode_cmd.addr = 0xBB;
/* disable GRAM and enable video mode */
lcm_switch_mode_cmd.val[0] = 0x03;
}
return (void *)(&lcm_switch_mode_cmd);
#else
return NULL;
#endif
}
struct LCM_DRIVER ili9881c_hd_dsi_vdo_ilitek_nt50358_lcm_drv = {
.name = "ili9881c_hd_dsi_vdo_ilitek_nt50358_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.compare_id = lcm_compare_id,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.esd_check = lcm_esd_check,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
.switch_mode = lcm_switch_mode,
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += ili9881h_hdp_dsi_vdo_ilitek_rt5081_19_9_90hz.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,860 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
#include <linux/string.h>
#include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#else
#include "disp_dts_gpio.h"
#endif
#ifdef BUILD_LK
#define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
#define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
#define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID (0x98)
static const unsigned int BL_MIN_LEVEL = 20;
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) \
lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
/*DynFPS*/
#define dfps_dsi_send_cmd( \
cmdq, cmd, count, para_list, force_update, sendmode) \
lcm_util.dsi_dynfps_send_cmd( \
cmdq, cmd, count, para_list, force_update, sendmode)
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
/* #include <linux/jiffies.h> */
/* #include <linux/delay.h> */
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#endif
/* static unsigned char lcd_id_pins_value = 0xFF; */
static const unsigned char LCD_MODULE_ID = 0x01;
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1520)
#define LCM_PHYSICAL_WIDTH (64800)
#define LCM_PHYSICAL_HEIGHT (129600)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x00} },
{0x28, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} }
};
static struct LCM_setting_table init_setting_vdo[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x01} },
{ 0x00, 0x01, {0x48} },
{ 0x01, 0x01, {0x34} },
{ 0x02, 0x01, {0x35} },
{ 0x03, 0x01, {0x5E} },
{ 0x08, 0x01, {0x86} },
{ 0x09, 0x01, {0x01} },
{ 0x0a, 0x01, {0x73} },
{ 0x0b, 0x01, {0x00} },
{ 0x0c, 0x01, {0x35} },
{ 0x0d, 0x01, {0x35} },
{ 0x0e, 0x01, {0x05} },
{ 0x0f, 0x01, {0x05} },
{ 0x28, 0x01, {0x48} },
{ 0x29, 0x01, {0x86} },
{ 0x2A, 0x01, {0x48} },
{ 0x2B, 0x01, {0x86} },
{ 0x31, 0x01, {0x07} },
{ 0x32, 0x01, {0x23} },
{ 0x33, 0x01, {0x00} },
{ 0x34, 0x01, {0x0B} },
{ 0x35, 0x01, {0x09} },
{ 0x36, 0x01, {0x02} },
{ 0x37, 0x01, {0x15} },
{ 0x38, 0x01, {0x17} },
{ 0x39, 0x01, {0x11} },
{ 0x3A, 0x01, {0x13} },
{ 0x3B, 0x01, {0x22} },
{ 0x3C, 0x01, {0x01} },
{ 0x3D, 0x01, {0x07} },
{ 0x3E, 0x01, {0x07} },
{ 0x3F, 0x01, {0x07} },
{ 0x40, 0x01, {0x07} },
{ 0x41, 0x01, {0x07} },
{ 0x42, 0x01, {0x07} },
{ 0x43, 0x01, {0x07} },
{ 0x44, 0x01, {0x07} },
{ 0x45, 0x01, {0x07} },
{ 0x46, 0x01, {0x07} },
{ 0x47, 0x01, {0x07} },
{ 0x48, 0x01, {0x23} },
{ 0x49, 0x01, {0x00} },
{ 0x4A, 0x01, {0x0A} },
{ 0x4B, 0x01, {0x08} },
{ 0x4C, 0x01, {0x02} },
{ 0x4D, 0x01, {0x14} },
{ 0x4E, 0x01, {0x16} },
{ 0x4F, 0x01, {0x10} },
{ 0x50, 0x01, {0x12} },
{ 0x51, 0x01, {0x22} },
{ 0x52, 0x01, {0x01} },
{ 0x53, 0x01, {0x07} },
{ 0x54, 0x01, {0x07} },
{ 0x55, 0x01, {0x07} },
{ 0x56, 0x01, {0x07} },
{ 0x57, 0x01, {0x07} },
{ 0x58, 0x01, {0x07} },
{ 0x59, 0x01, {0x07} },
{ 0x5a, 0x01, {0x07} },
{ 0x5b, 0x01, {0x07} },
{ 0x5c, 0x01, {0x07} },
{ 0x61, 0x01, {0x07} },
{ 0x62, 0x01, {0x23} },
{ 0x63, 0x01, {0x00} },
{ 0x64, 0x01, {0x08} },
{ 0x65, 0x01, {0x0A} },
{ 0x66, 0x01, {0x02} },
{ 0x67, 0x01, {0x12} },
{ 0x68, 0x01, {0x10} },
{ 0x69, 0x01, {0x16} },
{ 0x6a, 0x01, {0x14} },
{ 0x6b, 0x01, {0x22} },
{ 0x6c, 0x01, {0x01} },
{ 0x6d, 0x01, {0x07} },
{ 0x6e, 0x01, {0x07} },
{ 0x6f, 0x01, {0x07} },
{ 0x70, 0x01, {0x07} },
{ 0x71, 0x01, {0x07} },
{ 0x72, 0x01, {0x07} },
{ 0x73, 0x01, {0x07} },
{ 0x74, 0x01, {0x07} },
{ 0x75, 0x01, {0x07} },
{ 0x76, 0x01, {0x07} },
{ 0x77, 0x01, {0x07} },
{ 0x78, 0x01, {0x23} },
{ 0x79, 0x01, {0x00} },
{ 0x7a, 0x01, {0x09} },
{ 0x7b, 0x01, {0x0B} },
{ 0x7c, 0x01, {0x02} },
{ 0x7d, 0x01, {0x13} },
{ 0x7e, 0x01, {0x11} },
{ 0x7f, 0x01, {0x17} },
{ 0x80, 0x01, {0x15} },
{ 0x81, 0x01, {0x22} },
{ 0x82, 0x01, {0x01} },
{ 0x83, 0x01, {0x07} },
{ 0x84, 0x01, {0x07} },
{ 0x85, 0x01, {0x07} },
{ 0x86, 0x01, {0x07} },
{ 0x87, 0x01, {0x07} },
{ 0x88, 0x01, {0x07} },
{ 0x89, 0x01, {0x07} },
{ 0x8a, 0x01, {0x07} },
{ 0x8b, 0x01, {0x07} },
{ 0x8c, 0x01, {0x07} },
{ 0xd0, 0x01, {0x01} },
{ 0xd1, 0x01, {0x00} },
{ 0xe2, 0x01, {0x00} },
{ 0xe6, 0x01, {0x22} },
{ 0xe7, 0x01, {0x54} },
{ 0xB0, 0x01, {0x33} },
{ 0xB1, 0x01, {0x33} },
{ 0xB2, 0x01, {0x00} },
{ 0xE7, 0x01, {0x54} },
{ 0xFF, 0x03, {0x98, 0x81, 0x02} },
{ 0x40, 0x01, {0x52} },
{ 0x4B, 0x01, {0x5A} },
{ 0x4D, 0x01, {0x4E} },
{ 0x1A, 0x01, {0x48} },
{ 0x4E, 0x01, {0x00} },
{ 0x1A, 0x01, {0x48} },
{ 0x70, 0x01, {0x34} },
{ 0x73, 0x01, {0x0A} },
{ 0x79, 0x01, {0x06} },
{ 0xFF, 0x03, {0x98, 0x81, 0x05} },
{ 0x03, 0x01, {0x01} },
{ 0x04, 0x01, {0x43} },
{ 0x58, 0x01, {0x63} },
{ 0x63, 0x01, {0x88} },
{ 0x64, 0x01, {0x88} },
{ 0x68, 0x01, {0x65} },
{ 0x69, 0x01, {0x7F} },
{ 0x6A, 0x01, {0xC9} },
{ 0x6B, 0x01, {0xCF} },
{ 0xFF, 0x03, {0x98, 0x81, 0x06} },
{ 0x11, 0x01, {0x03} },
{ 0x13, 0x01, {0x15} },
{ 0x14, 0x01, {0x41} },
{ 0x15, 0x01, {0xc2} },
{ 0x16, 0x01, {0x40} },
{ 0x17, 0x01, {0x48} },
{ 0x18, 0x01, {0x3B} },
{ 0xD6, 0x01, {0x85} },
{ 0x27, 0x01, {0x20} },
{ 0x28, 0x01, {0x20} },
{ 0x2E, 0x01, {0x01} },
{ 0xC0, 0x01, {0xF7} },
{ 0xC1, 0x01, {0x02} },
{ 0xC2, 0x01, {0x04} },
{ 0x48, 0x01, {0x0F} },
{ 0x4D, 0x01, {0x80} },
{ 0x4E, 0x01, {0x40} },
{ 0x7C, 0x01, {0x40} },
{ 0x94, 0x01, {0x00} },
{ 0xFF, 0x03, {0x98, 0x81, 0x07} },
{ 0x0F, 0x01, {0x02} },
{ 0xFF, 0x03, {0x98, 0x81, 0x08} },
{ 0xE0, 0x27, {0x00, 0x24, 0x3C, 0x51, 0x74, 0x40,
0x97, 0xB6, 0xDE, 0x03, 0x55, 0x42, 0x7A,
0xAF, 0xE4, 0xAA, 0x1B, 0x5E, 0x88, 0xBB,
0xFE, 0xE6, 0x1C, 0x5E, 0x93, 0x03, 0xEC} },
{ 0xE1, 0x27, {0x00, 0x24, 0x3C, 0x51, 0x74, 0x40,
0x97, 0xB6, 0xDE, 0x03, 0x55, 0x42, 0x7A,
0xAF, 0xE4, 0xAA, 0x1B, 0x5E, 0x88, 0xBB,
0xFE, 0xE6, 0x1C, 0x5E, 0x93, 0x03, 0xEC} },
{ 0xFF, 0x03, {0x98, 0x81, 0x0E} },
{ 0x00, 0x01, {0xA0} },
{ 0x13, 0x01, {0x05} },
{ 0x11, 0x01, {0x90} },
{ 0xFF, 0x03, {0x98, 0x81, 0x06} },
{ 0xD5, 0x01, {0x34} },
{ 0x58, 0x01, {0xBD} },
{ 0x94, 0x01, {0x01} },
{ 0x13, 0x01, {0x4A} },
{ 0x14, 0x01, {0x2F} },
{ 0x15, 0x01, {0x0E} },
{ 0x16, 0x01, {0x2F} },
{ 0xFF, 0x03, {0x98, 0x81, 0x00} },
{ 0x11, 0x00, {} },
{ REGFLAG_DELAY, 120, {} },
{ 0xFF, 0x03, {0x98, 0x81, 0x02} },
{ 0x47, 0x01, {0x00} },
{ 0xFF, 0x03, {0x98, 0x81, 0x06} },
{ 0xD5, 0x01, {0x30} },
{ 0x58, 0x01, {0xD5} },
{ 0x94, 0x01, {0x01} },
{ 0x17, 0x01, {0xFF} },
{ 0x18, 0x01, {0x00} },
{ 0xFF, 0x03, {0x98, 0x81, 0x00} },
{ 0x29, 0x00, {} },
{ REGFLAG_DELAY, 20, {} },
{ 0x35, 0x01, {0x00} }
};
static struct LCM_setting_table bl_level[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x00} },
{0x51, 2, {0x0F, 0xFF} },
/* {0x53, 1, {0x2C} }, */
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
/*******************Dynfps start*************************/
#ifdef CONFIG_MTK_HIGH_FRAME_RATE
#define DFPS_MAX_CMD_NUM 10
struct LCM_dfps_cmd_table {
bool need_send_cmd;
enum LCM_Send_Cmd_Mode sendmode;
struct LCM_setting_table prev_f_cmd[DFPS_MAX_CMD_NUM];
};
static struct LCM_dfps_cmd_table
dfps_cmd_table[DFPS_LEVELNUM][DFPS_LEVELNUM] = {
/**********level 0 to 0,1 cmd*********************/
[DFPS_LEVEL0][DFPS_LEVEL0] = {
false,
LCM_SEND_IN_CMD,
/*prev_frame cmd*/
{
{REGFLAG_END_OF_TABLE, 0x00, {} },
},
},
/*60->90*/
[DFPS_LEVEL0][DFPS_LEVEL1] = {
true,
LCM_SEND_IN_CMD,
/*prev_frame cmd*/
{
{0xFF, 1, {0x25} },
{0xFB, 1, {0x01} },
{0x18, 1, {0x20} },
{REGFLAG_END_OF_TABLE, 0x00, {} },
},
},
/**********level 1 to 0,1 cmd*********************/
/*90->60*/
[DFPS_LEVEL1][DFPS_LEVEL0] = {
true,
LCM_SEND_IN_CMD,
/*prev_frame cmd*/
{
{0xFF, 1, {0x25} },
{0xFB, 1, {0x01} },
{0x18, 1, {0x21} },
{REGFLAG_END_OF_TABLE, 0x00, {} },
},
},
[DFPS_LEVEL1][DFPS_LEVEL1] = {
false,
LCM_SEND_IN_CMD,
/*prev_frame cmd*/
{
{REGFLAG_END_OF_TABLE, 0x00, {} },
},
},
};
#endif
/*******************Dynfps end*************************/
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
#ifdef CONFIG_MTK_HIGH_FRAME_RATE
/*DynFPS*/
static void lcm_dfps_int(struct LCM_DSI_PARAMS *dsi)
{
struct dfps_info *dfps_params = dsi->dfps_params;
dsi->dfps_enable = 1;
dsi->dfps_default_fps = 6000;/*real fps * 100, to support float*/
dsi->dfps_def_vact_tim_fps = 9000;/*real vact timing fps * 100*/
/*traversing array must less than DFPS_LEVELS*/
/*DPFS_LEVEL0*/
dfps_params[1].level = DFPS_LEVEL0;
dfps_params[1].fps = 6000;/*real fps * 100, to support float*/
dfps_params[1].vact_timing_fps = 9000;/*real vact timing fps * 100*/
/*if mipi clock solution*/
/*dfps_params[0].PLL_CLOCK = xx;*/
/*dfps_params[0].data_rate = xx; */
/*if HFP solution*/
/*dfps_params[0].horizontal_frontporch = xx;*/
dfps_params[1].vertical_frontporch = 36;
dfps_params[1].vertical_frontporch_for_low_power = 540;
/*if need mipi hopping params add here*/
/*dfps_params[0].PLL_CLOCK_dyn =xx;
*dfps_params[0].horizontal_frontporch_dyn =xx ;
* dfps_params[0].vertical_frontporch_dyn = 1291;
*/
/*DPFS_LEVEL1*/
dfps_params[0].level = DFPS_LEVEL1;
dfps_params[0].fps = 9000;/*real fps * 100, to support float*/
dfps_params[0].vact_timing_fps = 9000;/*real vact timing fps * 100*/
/*if mipi clock solution*/
/*dfps_params[1].PLL_CLOCK = xx;*/
/*dfps_params[1].data_rate = xx; */
/*if HFP solution*/
/*dfps_params[1].horizontal_frontporch = xx;*/
dfps_params[0].vertical_frontporch = 320;
dfps_params[0].vertical_frontporch_for_low_power = 540;
/*if need mipi hopping params add here*/
/*dfps_params[1].PLL_CLOCK_dyn =xx;
*dfps_params[1].horizontal_frontporch_dyn =xx ;
* dfps_params[1].vertical_frontporch_dyn= 54;
* dfps_params[1].vertical_frontporch_for_low_power_dyn =xx;
*/
dsi->dfps_num = 2;
}
#endif
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH/1000;
params->physical_height = LCM_PHYSICAL_HEIGHT/1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
#endif
pr_debug("%s:lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 8;
params->dsi.vertical_backporch = 20;
params->dsi.vertical_frontporch = 320;
params->dsi.vertical_frontporch_for_low_power = 540;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 8;
params->dsi.horizontal_backporch = 10;
params->dsi.horizontal_frontporch = 36;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.ssc_disable = 1;
#if (LCM_DSI_CMD_MODE)
params->dsi.PLL_CLOCK = 424;
#else
params->dsi.PLL_CLOCK = 424;
#endif
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
#ifdef CONFIG_MTK_HIGH_FRAME_RATE
/****DynFPS start****/
lcm_dfps_int(&(params->dsi));
/****DynFPS end****/
#endif
}
static void lcm_init_power(void)
{
/*pr_debug("lcm_init_power\n");*/
display_bias_enable();
MDELAY(15);
}
static void lcm_suspend_power(void)
{
/*pr_debug("lcm_suspend_power\n");*/
SET_RESET_PIN(0);
MDELAY(2);
display_bias_disable();
}
static void lcm_resume_power(void)
{
/*pr_debug("lcm_resume_power\n");*/
/*lcm_init_power();*/
display_bias_enable();
MDELAY(15);
}
static void lcm_init(void)
{
/*pr_debug("lcm_init\n");*/
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_vdo,
sizeof(init_setting_vdo) / sizeof(struct LCM_setting_table),
1);
pr_debug("ili9881c----rt5081----lcm mode = vdo mode :%d----\n",
lcm_dsi_mode);
}
static void lcm_suspend(void)
{
/*pr_debug("lcm_suspend\n");*/
push_table(NULL, lcm_suspend_setting,
sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table),
1);
}
static void lcm_resume(void)
{
/*pr_debug("lcm_resume\n");*/
lcm_init();
}
static void lcm_update(unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0, version_id = 0;
unsigned char buffer[2];
unsigned int array[16];
struct LCM_setting_table switch_table_page1[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x01} }
};
struct LCM_setting_table switch_table_page0[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x00} }
};
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
push_table(NULL, switch_table_page1,
sizeof(switch_table_page1) / sizeof(struct LCM_setting_table),
1);
array[0] = 0x00023700; /* read id return two byte,version and id */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0x00, buffer, 1);
id = buffer[0]; /* we only need ID */
read_reg_v2(0x01, buffer, 1);
version_id = buffer[0];
pr_debug("%s,ili9881c_id=0x%08x,version_id=0x%x\n",
__func__, id, version_id);
push_table(NULL, switch_table_page0,
sizeof(switch_table_page0) / sizeof(struct LCM_setting_table),
1);
if (id == LCM_ID && version_id == 0x81)
return 1;
else
return 0;
}
/* return TRUE: need recovery */
/* return FALSE: No need recovery */
static unsigned int lcm_esd_check(void)
{
char buffer[3];
int array[4];
array[0] = 0x00013700;
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0x0A, buffer, 1);
if (buffer[0] != 0x9C) {
pr_debug("[LCM ERROR] [0x53]=0x%02x\n", buffer[0]);
return TRUE;
}
pr_debug("[LCM NORMAL] [0x53]=0x%02x\n", buffer[0]);
return FALSE;
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
unsigned int ret = 0;
unsigned int x0 = FRAME_WIDTH / 4;
unsigned char x0_MSB = (x0 & 0xFF);
unsigned int data_array[2];
unsigned char read_buf[2];
unsigned int num1 = 0, num2 = 0;
struct LCM_setting_table switch_table_page0[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x00} }
};
struct LCM_setting_table switch_table_page2[] = {
{ 0xFF, 0x03, {0x98, 0x81, 0x02} }
};
MDELAY(20);
num1 = sizeof(switch_table_page2) / sizeof(struct LCM_setting_table);
push_table(NULL, switch_table_page2, num1, 1);
pr_debug("before read ATA check x0_MSB = 0x%x\n", x0_MSB);
pr_debug("before read ATA check read buff = 0x%x\n", read_buf[0]);
data_array[0] = 0x00023902;
data_array[1] = x0_MSB << 8 | 0x30;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00013700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x30, read_buf, 1);
pr_debug("after read ATA check size = 0x%x\n", read_buf[0]);
num2 = sizeof(switch_table_page0) / sizeof(struct LCM_setting_table);
push_table(NULL, switch_table_page0, num2, 1);
if (read_buf[0] == x0_MSB)
ret = 1;
else
ret = 0;
return ret;
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
pr_debug("%s,ili9881c backlight: level = %d\n", __func__, level);
bl_level[1].para_list[0] = (level&0xFF) >> 4;
bl_level[1].para_list[1] = (level&0x0F) << 4;
push_table(handle, bl_level,
sizeof(bl_level) / sizeof(struct LCM_setting_table), 1);
}
static void *lcm_switch_mode(int mode)
{
return NULL;
}
#if (LCM_DSI_CMD_MODE)
/* partial update restrictions:
* 1. roi width must be 1080 (full lcm width)
* 2. vertical start (y) must be multiple of 16
* 3. vertical height (h) must be multiple of 16
*/
static void lcm_validate_roi(int *x, int *y, int *width, int *height)
{
}
#endif
/*******************Dynfps start*************************/
#ifdef CONFIG_MTK_HIGH_FRAME_RATE
static void dfps_dsi_push_table(
void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update, enum LCM_Send_Cmd_Mode sendmode)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_END_OF_TABLE:
return;
default:
dfps_dsi_send_cmd(
cmdq, cmd, table[i].count,
table[i].para_list, force_update, sendmode);
break;
}
}
}
static bool lcm_dfps_need_inform_lcm(
unsigned int from_level, unsigned int to_level, struct LCM_PARAMS *params)
{
struct LCM_dfps_cmd_table *p_dfps_cmds = NULL;
if (from_level == to_level) {
LCM_LOGI("%s,same level\n", __func__);
return false;
}
p_dfps_cmds =
&(dfps_cmd_table[from_level][to_level]);
params->sendmode = p_dfps_cmds->sendmode;
return p_dfps_cmds->need_send_cmd;
}
static void lcm_dfps_inform_lcm(void *cmdq_handle,
unsigned int from_level, unsigned int to_level, struct LCM_PARAMS *params)
{
struct LCM_dfps_cmd_table *p_dfps_cmds = NULL;
enum LCM_Send_Cmd_Mode sendmode = LCM_SEND_IN_CMD;
if (from_level == to_level) {
LCM_LOGI("%s,same level\n", __func__);
goto done;
}
p_dfps_cmds =
&(dfps_cmd_table[from_level][to_level]);
if (p_dfps_cmds &&
!(p_dfps_cmds->need_send_cmd)) {
LCM_LOGI("%s,no cmd[L%d->L%d]\n",
__func__, from_level, to_level);
goto done;
}
sendmode = params->sendmode;
dfps_dsi_push_table(
cmdq_handle, p_dfps_cmds->prev_f_cmd,
ARRAY_SIZE(p_dfps_cmds->prev_f_cmd), 1, sendmode);
done:
LCM_LOGI("%s,done %d->%d\n",
__func__, from_level, to_level);
}
#endif
/*******************Dynfps end*************************/
struct LCM_DRIVER ili9881h_hdp_dsi_vdo_ilitek_rt5081_19_9_90hz_lcm_drv = {
.name = "ili9881h_hdp_dsi_vdo_ilitek_rt5081_19_9_90hz_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.compare_id = lcm_compare_id,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.esd_check = lcm_esd_check,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
.switch_mode = lcm_switch_mode,
#if (LCM_DSI_CMD_MODE)
.validate_roi = lcm_validate_roi,
#endif
#ifdef CONFIG_MTK_HIGH_FRAME_RATE
/*DynFPS*/
.dfps_send_lcm_cmd = lcm_dfps_inform_lcm,
.dfps_need_send_cmd = lcm_dfps_need_inform_lcm,
#endif
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += ili9882n_hdp_dsi_vdo_rt4801_90hz.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,80 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2022 MediaTek Inc.
*/
#ifndef _DATA_HW_ROUNDEDPATTERN_H_
#define _DATA_HW_ROUNDEDPATTERN_H_
#define ROUND_CORNER_H_TOP 32
#define ROUND_CORNER_H_BOT 32
static unsigned char top_rc_pattern[] = {
0x1d, 0x0, 0x3, 0x1, 0x1b, 0x4, 0x38, 0x4, 0x3, 0x0, 0xf0, 0xa0, 0x30, 0x30, 0xa0, 0xf0,
0x1b, 0x0, 0x2, 0x1, 0x1d, 0x4, 0x38, 0x4, 0x3, 0x0, 0xc0, 0x60, 0x10, 0x60, 0xc0,
0x19, 0x0, 0x2, 0x1, 0x1f, 0x4, 0x38, 0x4, 0x2, 0x0, 0xa0, 0x20, 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c.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __LCM_COMMON_H__
#define __LCM_COMMON_H__
#include "lcm_drv.h"
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
enum LCM_STATUS {
LCM_STATUS_OK = 0,
LCM_STATUS_ERROR,
};
void lcm_common_parse_dts(const struct LCM_DTS *DTS,
unsigned char force_update);
void lcm_common_set_util_funcs(const struct LCM_UTIL_FUNCS *util);
void lcm_common_get_params(LCM_PARAMS *params);
void lcm_common_init(void);
void lcm_common_suspend(void);
void lcm_common_resume(void);
void lcm_common_update(unsigned int x, unsigned int y, unsigned int width,
unsigned int height);
void lcm_common_setbacklight(unsigned int level);
void lcm_common_setbacklight_cmdq(void *handle, unsigned int level);
unsigned int lcm_common_compare_id(void);
unsigned int lcm_common_ata_check(unsigned char *buffer);
#endif
#endif
@@ -0,0 +1,65 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef _LCM_DEFINE_H
#define _LCM_DEFINE_H
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
/* LCM_FUNC */
#define LCM_FUNC_GPIO 1
#define LCM_FUNC_I2C 2
#define LCM_FUNC_UTIL 3
#define LCM_FUNC_CMD 4
/* LCM_GPIO_TYPE */
#define LCM_GPIO_MODE 1
#define LCM_GPIO_DIR 2
#define LCM_GPIO_OUT 3
/* LCM_GPIO_MODE_DATA */
#define LCM_GPIO_MODE_00 0
#define LCM_GPIO_MODE_01 1
#define LCM_GPIO_MODE_02 2
#define LCM_GPIO_MODE_03 3
#define LCM_GPIO_MODE_04 4
#define LCM_GPIO_MODE_05 5
#define LCM_GPIO_MODE_06 6
#define LCM_GPIO_MODE_07 7
#define MAX_LCM_GPIO_MODE 8
/* LCM_GPIO_DIR_DATA */
#define LCM_GPIO_DIR_IN 0
#define LCM_GPIO_DIR_OUT 1
/* LCM_GPIO_OUT_DATA */
#define LCM_GPIO_OUT_ZERO 0
#define LCM_GPIO_OUT_ONE 1
/* LCM_I2C_TYPE */
#define LCM_I2C_WRITE 1
/* LCM_UTIL_TYPE */
#define LCM_UTIL_RESET 1
#define LCM_UTIL_MDELAY 2
#define LCM_UTIL_UDELAY 3
#define LCM_UTIL_WRITE_CMD_V1 4
#define LCM_UTIL_WRITE_CMD_V2 5
#define LCM_UTIL_READ_CMD_V1 6
#define LCM_UTIL_READ_CMD_V2 7
#define LCM_UTIL_WRITE_CMD_V21 8
#define LCM_UTIL_WRITE_CMD_V22 9
#define LCM_UTIL_WRITE_CMD_V23 10
#define LCM_UTIL_RAR 11
/* LCM_UTIL_RESET_DATA */
#define LCM_UTIL_RESET_LOW 0
#define LCM_UTIL_RESET_HIGH 1
/* LCM_UTIL_WRITE_CMD_V2_DATA */
#define LCM_UTIL_WRITE_CMD_V2_NULL 0xF9
#endif
#endif /* _LCM_DEFINE_H */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __LCM_EXT_H__
#define __LCM_EXT_H__
extern struct i2c_client *tps65132_i2c_client;
extern int tps65132_write_bytes(unsigned char addr, unsigned char value);
#endif
+22
View File
@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __LCM_GPIO_H__
#define __LCM_GPIO_H__
#include "lcm_drv.h"
#include "lcm_common.h"
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
#define LCM_GPIO_DEVICE "lcm_mode"
enum LCM_STATUS lcm_gpio_set_data(char type, const struct LCM_DATA_T1 *t1);
#endif
#endif
+19
View File
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __LCM_I2C_H__
#define __LCM_I2C_H__
#include "lcm_drv.h"
#include "lcm_common.h"
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
enum LCM_STATUS lcm_i2c_set_data(char type, const struct LCM_DATA_T2 *t2);
#endif
extern struct i2c_client *_lcm_i2c_client;
#endif
+14
View File
@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __LCM_PMIC_H__
#define __LCM_PMIC_H__
#include "lcm_drv.h"
#include "lcm_common.h"
#endif
+35
View File
@@ -0,0 +1,35 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __LCM_UTIL_H__
#define __LCM_UTIL_H__
#include "lcm_drv.h"
#include "lcm_common.h"
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
enum LCM_STATUS lcm_util_set_data(const struct LCM_UTIL_FUNCS *lcm_util,
char type, struct LCM_DATA_T1 *t1);
enum LCM_STATUS lcm_util_set_write_cmd_v1(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T5 *t5,
unsigned char force_update);
enum LCM_STATUS lcm_util_set_write_cmd_v11(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T5 *t5,
unsigned char force_update, void *cmdq);
enum LCM_STATUS lcm_util_set_write_cmd_v2(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T3 *t3,
unsigned char force_update);
enum LCM_STATUS lcm_util_set_write_cmd_v23(
const struct LCM_UTIL_FUNCS *lcm_util, void *handle,
struct LCM_DATA_T3 *t3, unsigned char force_update);
enum LCM_STATUS lcm_util_set_read_cmd_v2(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T4 *t4,
unsigned int *compare);
#endif
#endif
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += jd9365_hd720_dsi.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,729 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 MediaTek Inc.
*
*/
#include <linux/module.h>
#ifdef BUILD_LK
#include <string.h>
#include <platform/mt_gpio.h>
#include <platform/mt_pmic.h>
#include <platform/upmu_common.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#else
#include <linux/wait.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#include <linux/gpio.h>
#include <asm-generic/gpio.h>
#include <linux/string.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#endif
#ifdef CONFIG_OF
#include <linux/regulator/consumer.h>
#endif
#include "lcm_drv.h"
static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output);
#ifndef BUILD_LK
static unsigned int LCD_RST_PIN;
static unsigned int LCD_PWR_EN_PIN;
static unsigned int LCD_PWR_BIAS_ENP_PIN;
void lcm_request_gpio_control(struct device *dev)
{
LCD_RST_PIN = of_get_named_gpio(dev->of_node, "lcd_rst_pin", 0);
gpio_request(LCD_RST_PIN, "LCD_RST_PIN");
LCD_PWR_EN_PIN = of_get_named_gpio(dev->of_node, "lcd_pwr_en_pin", 0);
gpio_request(LCD_PWR_EN_PIN, "LCD_PWR_EN_PIN");
LCD_PWR_BIAS_ENP_PIN =
of_get_named_gpio(dev->of_node, "lcd_pwr_bias_enp_pin", 0);
gpio_request(LCD_PWR_BIAS_ENP_PIN, "LCD_PWR_BIAS_ENP_PIN");
}
static int lcm_driver_probe(struct device *dev, void const *data)
{
lcm_request_gpio_control(dev);
lcm_set_gpio_output(LCD_PWR_EN_PIN, 1);
lcm_set_gpio_output(LCD_PWR_BIAS_ENP_PIN, 1);
return 0;
}
static const struct of_device_id lcm_platform_of_match[] = {
{
.compatible = "jdi,jd9365_dsi_vdo",
.data = 0,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, platform_of_match);
static int lcm_platform_probe(struct platform_device *pdev)
{
const struct of_device_id *id;
id = of_match_node(lcm_platform_of_match, pdev->dev.of_node);
if (!id)
return -ENODEV;
return lcm_driver_probe(&pdev->dev, id->data);
}
static struct platform_driver lcm_driver = {
.probe = lcm_platform_probe,
.driver = {
.name = "jd9365_dsi_vdo",
.owner = THIS_MODULE,
.of_match_table = lcm_platform_of_match,
},
};
static int __init lcm_init(void)
{
pr_debug("LCM: register lcm init driver done\n");
if (platform_driver_register(&lcm_driver)) {
pr_notice("LCM: failed to register this driver!\n");
return -ENODEV;
}
return 0;
}
static void __exit lcm_exit(void)
{
platform_driver_unregister(&lcm_driver);
}
late_initcall(lcm_init);
module_exit(lcm_exit);
MODULE_AUTHOR("mediatek");
MODULE_DESCRIPTION("LCM display subsystem driver");
MODULE_LICENSE("GPL");
#endif
/* ----------------------------------------------------------------- */
/* Local Constants */
/* ----------------------------------------------------------------- */
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
#define GPIO_OUT_ONE 1
#define GPIO_OUT_ZERO 0
#ifdef GPIO_LCM_RST
#define GPIO_LCD_RST GPIO_LCM_RST
#endif
#ifdef GPIO_LCM_PWR_EN
#define GPIO_LCD_PWR_EN GPIO_LCM_PWR_EN
#else
#define GPIO_LCD_PWR_EN 0xFFFFFFFF
#endif
#ifdef GPIO_LCD_BIAS_ENP_PIN
#define GPIO_LCD_BIAS_ENP GPIO_LCD_BIAS_ENP_PIN
#endif
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* --------------------------------------------------------------------- */
/* Local Functions */
/* --------------------------------------------------------------------- */
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) \
lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) \
lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
/* ------------------------------------------------ */
/* Local Constants */
/* ------------------------------------------------ */
#define REGFLAG_DELAY 0xFC
#define REGFLAG_END_OF_TABLE 0xFD
/* END OF REGISTERS MARKER */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* ---------------------------------------------------------------- */
/* Local Variables */
/* ---------------------------------------------------------------- */
static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
{
if (GPIO == 0xFFFFFFFF) {
#ifdef BUILD_LK
printf("[LK/LCM] GPIO_LCD_PWR_EN = 0x%x\n", GPIO_LCD_PWR_EN);
printf("[LK/LCM] GPIO_LCD_BIAS_ENP = 0x%x\n",
GPIO_LCD_BIAS_ENP);
printf("[LK/LCM] GPIO_LCM_RST = 0x%x\n", GPIO_LCD_RST);
#else
pr_debug("[Kernel/LCM] GPIO_LCD_PWR_EN = 0x%x\n",
LCD_PWR_EN_PIN);
pr_debug("[Kernel/LCM] GPIO_LCD_BIAS_ENP = 0x%x\n",
LCD_PWR_BIAS_ENP_PIN);
pr_debug("[Kernel/LCM] GPIO_LCM_RST = 0x%x\n", LCD_RST_PIN);
#endif
return;
}
#ifdef BUILD_LK
mt_set_gpio_mode(GPIO, GPIO_MODE_00);
mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO, (output > 0) ? GPIO_OUT_ONE : GPIO_OUT_ZERO);
#else
gpio_direction_output(GPIO, output);
gpio_set_value(GPIO, output);
#endif
}
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[64];
};
#ifndef BUILD_LK
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
#endif
static struct LCM_setting_table lcm_initialization_setting[] = {
{0xE0, 1, {0x00} },
{0xE1, 1, {0x93} },
{0xE2, 1, {0x65} },
{0xE3, 1, {0xF8} },
{0xE0, 1, {0x04} },
{0x2D, 1, {0x03} },
{0xE0, 1, {0x00} },
{0x70, 1, {0x10} },
{0x71, 1, {0x13} },
{0x72, 1, {0x06} },
{0x75, 1, {0x03} },
{0x80, 1, {0x03} },
{0xE0, 1, {0x01} },
{0x00, 1, {0x00} },
{0x01, 1, {0xB5} },
{0x03, 1, {0x00} },
{0x04, 1, {0xA0} },
{0x0A, 1, {0x07} },
{0x0C, 1, {0x74} },
{0x17, 1, {0x00} },
{0x18, 1, {0xD7} },
{0x19, 1, {0x01} },
{0x1A, 1, {0x00} },
{0x1B, 1, {0xD7} },
{0x1C, 1, {0x01} },
{0x1F, 1, {0x74} },
{0x20, 1, {0x19} },
{0x21, 1, {0x19} },
{0x22, 1, {0x0E} },
{0x27, 1, {0x43} },
{0x37, 1, {0x09} },
{0x38, 1, {0x04} },
{0x39, 1, {0x08} },
{0x3A, 1, {0x18} },
{0x3B, 1, {0x18} },
{0x3C, 1, {0x72} },
{0x3E, 1, {0xFF} },
{0x3E, 1, {0xFF} },
{0x3F, 1, {0xFF} },
{0x40, 1, {0x04} },
{0x41, 1, {0xA0} },
{0x43, 1, {0x08} },
{0x44, 1, {0x07} },
{0x45, 1, {0x30} },
{0x55, 1, {0x01} },
{0x56, 1, {0x01} },
{0x57, 1, {0x65} },
{0x58, 1, {0x0A} },
{0x59, 1, {0x0A} },
{0x5A, 1, {0x28} },
{0x5B, 1, {0x0F} },
{0x5D, 1, {0x7C} },
{0x5E, 1, {0x5F} },
{0x5F, 1, {0x4D} },
{0x60, 1, {0x3F} },
{0x61, 1, {0x39} },
{0x62, 1, {0x29} },
{0x63, 1, {0x2B} },
{0x64, 1, {0x12} },
{0x65, 1, {0x28} },
{0x66, 1, {0x24} },
{0x67, 1, {0x22} },
{0x68, 1, {0x3E} },
{0x69, 1, {0x2C} },
{0x6A, 1, {0x33} },
{0x6B, 1, {0x26} },
{0x6C, 1, {0x23} },
{0x6D, 1, {0x18} },
{0x6E, 1, {0x09} },
{0x6F, 1, {0x00} },
{0x70, 1, {0x7C} },
{0x71, 1, {0x5F} },
{0x72, 1, {0x4D} },
{0x73, 1, {0x3F} },
{0x74, 1, {0x39} },
{0x75, 1, {0x29} },
{0x76, 1, {0x2B} },
{0x77, 1, {0x12} },
{0x78, 1, {0x28} },
{0x79, 1, {0x24} },
{0x7A, 1, {0x22} },
{0x7B, 1, {0x3E} },
{0x7C, 1, {0x2C} },
{0x7D, 1, {0x33} },
{0x7E, 1, {0x26} },
{0x7F, 1, {0x23} },
{0x80, 1, {0x18} },
{0x81, 1, {0x09} },
{0x82, 1, {0x00} },
{0xE0, 1, {0x02} },
{0x00, 1, {0x37} },
{0x01, 1, {0x17} },
{0x02, 1, {0x0A} },
{0x03, 1, {0x06} },
{0x04, 1, {0x08} },
{0x05, 1, {0x04} },
{0x06, 1, {0x00} },
{0x07, 1, {0x1F} },
{0x08, 1, {0x1F} },
{0x09, 1, {0x1F} },
{0x0A, 1, {0x1F} },
{0x0B, 1, {0x1F} },
{0x0C, 1, {0x1F} },
{0x0D, 1, {0x1F} },
{0x0E, 1, {0x1F} },
{0x0F, 1, {0x1F} },
{0x10, 1, {0x3F} },
{0x11, 1, {0x1F} },
{0x12, 1, {0x1F} },
{0x13, 1, {0x1E} },
{0x14, 1, {0x10} },
{0x15, 1, {0x1F} },
{0x16, 1, {0x37} },
{0x17, 1, {0x17} },
{0x18, 1, {0x0B} },
{0x19, 1, {0x07} },
{0x1A, 1, {0x09} },
{0x1B, 1, {0x05} },
{0x1C, 1, {0x01} },
{0x1D, 1, {0x1F} },
{0x1E, 1, {0x1F} },
{0x1F, 1, {0x1F} },
{0x20, 1, {0x1F} },
{0x21, 1, {0x1F} },
{0x22, 1, {0x1F} },
{0x23, 1, {0x1F} },
{0x24, 1, {0x1F} },
{0x25, 1, {0x1F} },
{0x26, 1, {0x1F} },
{0x27, 1, {0x1F} },
{0x28, 1, {0x1F} },
{0x29, 1, {0x1E} },
{0x2A, 1, {0x11} },
{0x2B, 1, {0x1F} },
{0x2C, 1, {0x37} },
{0x2D, 1, {0x17} },
{0x2E, 1, {0x05} },
{0x2F, 1, {0x09} },
{0x30, 1, {0x07} },
{0x31, 1, {0x0B} },
{0x32, 1, {0x11} },
{0x33, 1, {0x1F} },
{0x34, 1, {0x1F} },
{0x35, 1, {0x1F} },
{0x36, 1, {0x1F} },
{0x37, 1, {0x1F} },
{0x38, 1, {0x1F} },
{0x39, 1, {0x1F} },
{0x3A, 1, {0x1F} },
{0x3B, 1, {0x1F} },
{0x3C, 1, {0x3F} },
{0x3D, 1, {0x1F} },
{0x3E, 1, {0x1E} },
{0x3F, 1, {0x1F} },
{0x40, 1, {0x01} },
{0x41, 1, {0x1F} },
{0x42, 1, {0x38} },
{0x43, 1, {0x18} },
{0x44, 1, {0x04} },
{0x45, 1, {0x08} },
{0x46, 1, {0x06} },
{0x47, 1, {0x0A} },
{0x48, 1, {0x10} },
{0x49, 1, {0x1F} },
{0x4A, 1, {0x1F} },
{0x4B, 1, {0x1F} },
{0x4C, 1, {0x1F} },
{0x4D, 1, {0x1F} },
{0x4E, 1, {0x1F} },
{0x4F, 1, {0x1F} },
{0x50, 1, {0x1F} },
{0x51, 1, {0x1F} },
{0x52, 1, {0x1F} },
{0x53, 1, {0x1F} },
{0x54, 1, {0x1E} },
{0x55, 1, {0x1F} },
{0x56, 1, {0x00} },
{0x57, 1, {0x1F} },
{0x58, 1, {0x10} },
{0x59, 1, {0x00} },
{0x5A, 1, {0x00} },
{0x5B, 1, {0x10} },
{0x5C, 1, {0x01} },
{0x5D, 1, {0x50} },
{0x5E, 1, {0x01} },
{0x5F, 1, {0x02} },
{0x60, 1, {0x30} },
{0x61, 1, {0x01} },
{0x62, 1, {0x02} },
{0x63, 1, {0x06} },
{0x64, 1, {0x6A} },
{0x65, 1, {0x55} },
{0x66, 1, {0x08} },
{0x67, 1, {0x73} },
{0x68, 1, {0x05} },
{0x69, 1, {0x08} },
{0x6A, 1, {0x6E} },
{0x6B, 1, {0x00} },
{0x6C, 1, {0x00} },
{0x6D, 1, {0x00} },
{0x6E, 1, {0x00} },
{0x6F, 1, {0x88} },
{0x70, 1, {0x00} },
{0x71, 1, {0x00} },
{0x72, 1, {0x06} },
{0x73, 1, {0x7B} },
{0x74, 1, {0x00} },
{0x75, 1, {0x80} },
{0x76, 1, {0x00} },
{0x77, 1, {0x0D} },
{0x78, 1, {0x18} },
{0x79, 1, {0x00} },
{0x7A, 1, {0x00} },
{0x7B, 1, {0x00} },
{0x7C, 1, {0x00} },
{0x7D, 1, {0x03} },
{0x7E, 1, {0x7B} },
{0xE0, 1, {0x04} },
{0x04, 1, {0x01} },
{0x0E, 1, {0x38} },
{0x2B, 1, {0x2B} },
{0x2E, 1, {0x44} },
{0xE0, 1, {0x00} },
{0xE6, 1, {0x02} },
{0xE6, 1, {0x02} },
{0x11, 0, {} },
{REGFLAG_DELAY, 20, {} },
{0x29, 0, {} },
{REGFLAG_DELAY, 5, {} },
{0x35, 1, {0x00} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void dsi_send_cmdq_tinno(unsigned int cmd, unsigned char count,
unsigned char *para_list, unsigned char force_update)
{
unsigned int item[16];
unsigned char dsi_cmd = (unsigned char)cmd;
unsigned char dc;
int index = 0, length = 0;
memset(item, 0, sizeof(item));
if (count + 1 > 60)
return;
if (count == 0) {
item[0] = 0x0500 | (dsi_cmd << 16);
length = 1;
} else if (count == 1) {
item[0] = 0x1500 | (dsi_cmd << 16) | (para_list[0] << 24);
length = 1;
} else {
/* Count include command. */
item[0] = 0x3902 | ((count + 1) << 16);
++length;
while (1) {
if (index == count + 1)
break;
if (index == 0)
dc = cmd;
else
dc = para_list[index - 1];
/* an item make up of 4data. */
item[index / 4 + 1] |= (dc << (8 * (index % 4)));
if (index % 4 == 0)
++length;
++index;
}
}
dsi_set_cmdq(item, length, force_update);
}
static void push_table(struct LCM_setting_table *table, unsigned int count,
unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_send_cmdq_tinno(cmd, table[i].count,
table[i].para_list, force_update);
/* dsi_set_cmdq_V2(cmd, table[i].count,
* table[i].para_list, force_update);
*/
}
}
}
static void init_lcm_registers(void)
{
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) /
sizeof(struct LCM_setting_table), 1);
}
/* ------------------------------------------------------------------- */
/* LCM Driver Implementations */
/* ------------------------------------------------------------------- */
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->density = 213;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
#endif
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
params->dsi.intermediat_buffer_num = 2;
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
#ifdef BUILD_LK
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 1;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9c;
#endif
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 4;
params->dsi.vertical_frontporch = 16;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 55;
params->dsi.horizontal_backporch = 53;
params->dsi.horizontal_frontporch = 24;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
/* video mode timing */
params->dsi.word_count = FRAME_WIDTH * 3;
params->dsi.PLL_CLOCK = 213; /* 270 */
}
static void lcm_init_lcm(void)
{
#ifdef BUILD_LK
printf("[LK/LCM] lcm_init() enter\n");
lcm_set_gpio_output(GPIO_LCM_RST, GPIO_OUT_ONE);
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_BIAS_ENP, GPIO_OUT_ONE);
MDELAY(20);
lcm_set_gpio_output(GPIO_LCM_RST, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCM_RST, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCM_RST, GPIO_OUT_ZERO);
MDELAY(120);
init_lcm_registers();
#else
pr_notice("[Kernel/LCM] lcm_init() enter\n");
lcm_set_gpio_output(LCD_PWR_EN_PIN, GPIO_OUT_ONE);
MDELAY(20);
lcm_set_gpio_output(LCD_PWR_BIAS_ENP_PIN, GPIO_OUT_ONE);
#endif
}
void lcm_suspend(void)
{
#ifndef BUILD_LK
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(LCD_RST_PIN, GPIO_OUT_ZERO);
MDELAY(5);
push_table(lcm_suspend_setting,
sizeof(lcm_suspend_setting) /
sizeof(struct LCM_setting_table), 1);
lcm_set_gpio_output(LCD_PWR_BIAS_ENP_PIN, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(LCD_PWR_EN_PIN, GPIO_OUT_ZERO);
#endif
}
void lcm_resume(void)
{
#ifndef BUILD_LK
pr_notice("[Kernel/LCM] %s enter\n", __func__);
lcm_set_gpio_output(LCD_PWR_EN_PIN, GPIO_OUT_ONE);
MDELAY(5);
lcm_set_gpio_output(LCD_PWR_BIAS_ENP_PIN, GPIO_OUT_ONE);
MDELAY(5);
lcm_set_gpio_output(LCD_RST_PIN, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(LCD_RST_PIN, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(LCD_RST_PIN, GPIO_OUT_ZERO);
MDELAY(10);
init_lcm_registers();
#endif
}
#if (LCM_DSI_CMD_MODE)
static void lcm_update(unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
#endif
struct LCM_DRIVER jd9365_hd720_dsi_lcm_drv = {
.name = "jd9365_hd720_dsi",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init_lcm,
.suspend = lcm_suspend,
.resume = lcm_resume,
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += kd070fhfid015_dsi_1200x1920.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,778 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
/*****************************************************************************
*
* Filename:
* ---------
* kd070fhfid015_dsi_1200x1920.c
*
* Project:
* --------
* ALPS
*
* Description:
* ------------
* Source code of LCM driver
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by CC/CQ. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#define LCM_NAME "kd070"
#define PANEL_DRV_NAME "kd070fhfid015_dsi_1200x1920"
#define PANEL_PLAT_NAME "kd070-disp"
// ---------------------------------------------------------------------------
#ifdef BUILD_LK
#include <string.h>
#include <mt_gpio.h>
#include <platform/mt_pmic.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
//#include <cust_gpio_usage.h>
#include <cust_leds.h>
#include <cust_display.h>
//#include <platform/primary_display.h>
#include <boot_mode.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#error "BUILD_UBOOT not implemented yet!"
#else
#include <linux/string.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/wait.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/input.h>
#include <linux/debugfs.h>
#include <linux/fs.h>
#include <linux/seq_file.h>
#include <linux/module.h>
#endif
//#define ST7701S_ESD_CHECK
// ---------------------------------------------------------------------------
#include "ddp_hal.h"
#ifdef BUILD_LK
#include "ddp_dsi.h"
#endif
#include "lcm_drv.h"
// ---------------------------------------------------------------------------
#ifndef DIV_ROUND_UP
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
#endif
#ifndef DIV_ROUND_CLOSEST
#define DIV_ROUND_CLOSEST(n, d) (((n) + ((d) >> 1)) / (d))
#endif
// ---------------------------------------------------------------------------
// Local Constants
// ---------------------------------------------------------------------------
#define FRAME_WIDTH (1200)
#define FRAME_HEIGHT (1920)
#define LCM_PHYSICAL_WIDTH (94500)
#define LCM_PHYSICAL_HEIGHT (151200)
/**
* density = sqrt(width * width + height * height) / diagonal;
* diagonal: unit inch
* LCM_DENSITY = sqrt(1200*1200+1920*1920)/7 = 323;
*/
#define LCM_DENSITY (320)
// ---------------------------------------------------------------------------
// Local Variables
// ---------------------------------------------------------------------------
#ifdef GPIO_LCM_RST
#define GPIO_LCD_RST (45 | 0x80000000)
#else
#define GPIO_LCD_RST (45 | 0x80000000)
#endif
#ifdef GPIO_LCM_BL_EN
#define GPIO_LCD_BL_EN (44 | 0x80000000)
#else
#define GPIO_LCD_BL_EN (44 | 0x80000000)
#endif
#ifdef GPIO_LCM_PWR_EN
#define GPIO_LCD_PWR_EN (153 | 0x80000000)
#else
#define GPIO_LCD_PWR_EN (153 | 0x80000000)
#endif
#ifdef BUILD_LK
extern void DSI_clk_HS_mode(DISP_MODULE_ENUM module, void *cmdq, bool enter);
#else
extern void DSI_clk_HS_mode(enum DISP_MODULE_ENUM module, void *cmdq, bool enter);
#endif
#ifdef BUILD_LK
#define SET_RESET_PIN(v) lcm_set_gpio_output(GPIO_LCD_RST, v) //(lcm_util.set_reset_pin((v)))
#else
#define SET_RESET_PIN(v) gpio_direction_output(gpio_rst, v)
#endif
#ifdef BUILD_LK
#define SET_DCDC_PIN(v) lcm_set_gpio_output(GPIO_LCD_PWR_EN, v)
#else
#define SET_DCDC_PIN(v) gpio_direction_output(gpio_dcdc, v)
#endif
#ifdef BUILD_LK
#define SET_BL_PIN(v) lcm_set_gpio_output(GPIO_LCD_BL_EN, v)
#else
#define SET_BL_PIN(v) gpio_direction_output(gpio_bl, v)
#endif
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define GPIO_OUT_ONE 1
#define GPIO_OUT_ZERO 0
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
#ifdef BUILD_LK
/* debug levels: 0-2 */
#define LCM_LOG(string, args...) printf(string, ##args)
#define LCM_LOGE(string, args...) dprintf(0, "[LCM/"LCM_NAME"]ERR: "string, ##args)
#define LCM_LOGI(string, args...) dprintf(0, "[LCM/"LCM_NAME"] "string, ##args)
#define LCM_LOGD(string, args...) dprintf(0, "[LCM/"LCM_NAME"] "string, ##args)
#define LCM_LOGV(string, args...) dprintf(3, "[LCM/"LCM_NAME"] "string, ##args)
#else
#define LCM_LOG(fmt, args...) pr_info(fmt, ##args)
#define LCM_LOGE(fmt, args...) pr_info("[LCM/"LCM_NAME"]ERR: "fmt, ##args)
#define LCM_LOGI(fmt, args...) pr_info("[LCM/"LCM_NAME"] "fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_info("[LCM/"LCM_NAME"] "fmt, ##args)
#define LCM_LOGV(fmt, args...) pr_debug("[LCM/"LCM_NAME"] "fmt, ##args)
#define LCM_DEV_LOGE(dev, fmt, args...) dev_info(dev, "[LCM]ERR: "fmt, ##args)
#define LCM_DEV_LOGI(dev, fmt, args...) dev_info(dev, "[LCM] "fmt, ##args)
#define LCM_DEV_LOGD(dev, fmt, args...) dev_dbg(dev, "[LCM] "fmt, ##args)
#define LCM_DEV_LOGV(dev, fmt, args...) dev_dbg(dev, "[LCM] "fmt, ##args)
#endif
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Local Functions
// ---------------------------------------------------------------------------
static struct LCM_UTIL_FUNCS lcm_util;
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
(lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update))
#define dsi_set_cmdq(pdata, queue_size, force_update) \
(lcm_util.dsi_set_cmdq(pdata, queue_size, force_update))
#define wrtie_cmd(cmd) \
(lcm_util.dsi_write_cmd(cmd))
#define write_regs(addr, pdata, byte_nums) \
(lcm_util.dsi_write_regs(addr, pdata, byte_nums))
#define read_reg \
(lcm_util.dsi_read_reg())
#define read_reg_v2(cmd, buffer, buffer_size) \
(lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size))
#ifdef BUILD_LK
#define INVALID_GPIO 0xFFFFFFFF
static void lcm_set_gpio_output(unsigned int gpio, unsigned int output)
{
if (gpio != INVALID_GPIO) {
LCM_LOGI("GPIO %u: output %u\n", gpio & 0x0ff, output);
mt_set_gpio_mode(gpio, GPIO_MODE_00);
mt_set_gpio_dir(gpio, GPIO_DIR_OUT);
mt_set_gpio_out(gpio, (output > 0) ? GPIO_OUT_ONE : GPIO_OUT_ZERO);
}
}
#endif
#ifdef BUILD_LK
#else /* !BUILD_LK */
/******************************************************************************/
static int gpio_rst;
static int gpio_dcdc;
static int gpio_bl;
/* Refer to mtkfb.c _parse_tag_videolfb() */
struct tag_videolfb {
u64 fb_base;
u32 islcmfound;
u32 fps;
u32 vram;
char lcmname[1]; /* this is the minimum size */
};
static bool panel_parse_tag_videolfb(void)
{
bool found = false, parsed = false;
struct tag_videolfb *videolfb_tag = NULL;
struct device_node *chosen_node;
LCM_LOGV("%s() enter\n", __func__);
if (parsed)
goto _end;
chosen_node = of_find_node_by_path("/chosen");
if (!chosen_node)
chosen_node = of_find_node_by_path("/chosen@0");
if (chosen_node) {
videolfb_tag = (struct tag_videolfb *)of_get_property(chosen_node,
"atag,videolfb", NULL);
if (videolfb_tag) {
LCM_LOGD("videolfb_tag->lcmname=%s\n", videolfb_tag->lcmname);
LCM_LOGD("videolfb_tag->islcmfound=0x%x\n", videolfb_tag->islcmfound);
if (videolfb_tag->lcmname[0] != '\0' &&
strcmp(PANEL_DRV_NAME, videolfb_tag->lcmname) == 0)
found = true;
else
LCM_LOGI("'%s' not found (%s)\n",
PANEL_DRV_NAME, videolfb_tag->lcmname);
parsed = true;
}
}
_end:
LCM_LOGV("%s() exit: %d\n", __func__, found);
return found;
}
static struct regulator *lcm_vdd;
static void lcm_get_regulators(struct device *dev)
{
int ret = 0;
LCM_LOGD("%s() enter\n", __func__);
lcm_vdd = devm_regulator_get_optional(dev, "lcm-1v8");
if (IS_ERR(lcm_vdd)) {
LCM_LOGE("no 'lcm-1v8' regulator found: %ld\n", PTR_ERR(lcm_vdd));
lcm_vdd = NULL;
} else {
ret = regulator_enable(lcm_vdd);
if (ret)
LCM_LOGE("failed to enable lcm-1v8 power: %d\n", ret);
else
LCM_LOGD("lcm-1v8 power enabled\n");
}
LCM_LOGV("%s() exit\n", __func__);
}
static int lcm_driver_probe(struct device *dev)
{
int ret = 0;
LCM_LOGD("%s() enter\n", __func__);
lcm_get_regulators(dev);
gpio_rst = of_get_named_gpio(dev->of_node, "gpio_lcd_rst", 0);
ret = devm_gpio_request(dev, gpio_rst, "kd070-rst");
if (ret) {
LCM_LOGE("request gpio %d failed: %d\n", gpio_rst, ret);
return -1;
}
gpio_dcdc = of_get_named_gpio(dev->of_node, "gpio_lcd_dcdc", 0);
ret = devm_gpio_request(dev, gpio_dcdc, "kd070-dcdc");
if (ret) {
LCM_LOGE("request gpio %d failed: %d\n", gpio_dcdc, ret);
return -1;
}
gpio_bl = of_get_named_gpio(dev->of_node, "gpio_lcd_bl", 0);
ret = devm_gpio_request(dev, gpio_bl, "kd070-dcdc");
if (ret) {
LCM_LOGE("request gpio %d failed: %d\n", gpio_bl, ret);
return -1;
}
LCM_LOGV("%s() exit\n", __func__);
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id lcm_of_ids[] = {
{ .compatible = PANEL_PLAT_NAME, },
{}
};
MODULE_DEVICE_TABLE(of, lcm_of_ids);
#endif
static int lcm_platform_probe(struct platform_device *pdev)
{
const struct of_device_id *id;
LCM_LOGD("%s() enter\n", __func__);
id = of_match_node(lcm_of_ids, pdev->dev.of_node);
if (!id)
return -ENODEV;
return lcm_driver_probe(&pdev->dev);
}
static void lcm_shutdown(struct platform_device *pdev)
{
LCM_LOGD("%s() enter\n", __func__);
//is_shutdown = true;
LCM_LOGV("%s() exit\n", __func__);
}
static struct platform_driver lcm_driver = {
.driver = {
.name = PANEL_DRV_NAME,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = lcm_of_ids,
#endif
},
.probe = lcm_platform_probe,
.shutdown = lcm_shutdown,
};
static int __init panel_init(void)
{
LCM_LOGD("LCM: Register panel driver for %s\n", PANEL_DRV_NAME);
if (!panel_parse_tag_videolfb()) {
LCM_LOGD("%s: panel not found\n", __func__, PANEL_DRV_NAME);
return -ENODEV;
}
if (platform_driver_register(&lcm_driver)) {
LCM_LOGE("LCM: failed to register driver %s!\n", PANEL_DRV_NAME);
return -ENODEV;
}
return 0;
}
static void __exit panel_exit(void)
{
platform_driver_unregister(&lcm_driver);
LCM_LOGD("LCM: Unregister driver %s done\n", PANEL_DRV_NAME);
}
module_init(panel_init);
module_exit(panel_exit);
MODULE_AUTHOR("mediatek");
MODULE_DESCRIPTION("LCM display subsystem driver");
MODULE_LICENSE("GPL");
#endif /* BUILD_LK */
static struct LCM_setting_table bl_level[] = {{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(struct LCM_setting_table *table, unsigned int count
, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
LCM_LOGD("%s() enter\n", __func__);
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
goto end;
default:
dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
//MDELAY(1);
break;
}
}
end:
LCM_LOGV("%s() exit\n", __func__);
}
// ---------------------------------------------------------------------------
// LCM Driver Implementations
// ---------------------------------------------------------------------------
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
LCM_LOGD("%s() enter\n", __func__);
memset(params, 0, sizeof(struct LCM_PARAMS));
#ifdef BUILD_LK
params->dsi.edp_panel = 1;
#endif
params->type = LCM_TYPE_DSI;
params->lcm_if = LCM_INTERFACE_DSI0;
params->lcm_cmd_if = LCM_INTERFACE_DSI0;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH / 1000;
params->physical_height = LCM_PHYSICAL_HEIGHT / 1000;
#ifndef BUILD_LK
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
#endif
params->dsi.mode = SYNC_EVENT_VDO_MODE;
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the format for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
// Highly depends on LCD driver capability.
params->dsi.packet_size = 256;
/* Video mode setting */
params->dsi.intermediat_buffer_num = 0;
params->dsi.word_count = FRAME_WIDTH * 3;
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 4; //10;
params->dsi.vertical_backporch = 4; //20;
params->dsi.vertical_frontporch = 8; //20;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 16; //20;
params->dsi.horizontal_backporch = 45; //72;
params->dsi.horizontal_frontporch = 144; //176;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
// Bit rate calculation
//params->dsi.PLL_CLOCK = LCM_DSI_6589_PLL_CLOCK_442; //260;
//bit rate 60 fps-->996.328Mhz 494 416 450 ok; 474.5 fail
//1 Every lane speed
params->dsi.data_rate = 1040;//1000;//960;//600; /* Mbps *//**/
params->dsi.PLL_CLOCK = params->dsi.data_rate >> 1; /* MHz */
/* Workaround for MIPI DSI test: THS-PREPARE is too low */
/* Refer to DSI_PHY_TIMCONFIG() in ddp_dsi.c */
{
static unsigned char THS_PREPARE; /* THS_PREPARE */
static unsigned char THS_PREPARE_and_ZERO; /* THS_PREPARE + THS_ZERO */
if (THS_PREPARE == 0 || THS_PREPARE_and_ZERO == 0) {
u32 cycle_time = 8000 / params->dsi.data_rate + 0x01;
u32 ui = 1000 / params->dsi.data_rate + 0x01;
#define DSI_NS_TO_CYCLE(n, c) ((n) / (c))
/* Refer to the default calculation in DSI_PHY_TIMCONFIG() */
THS_PREPARE = DSI_NS_TO_CYCLE((0x40 + 0x5 * ui), cycle_time);
if (THS_PREPARE < 1)
THS_PREPARE = 1;
/* Increase 2 cycle for Data THS-PREPARE */
THS_PREPARE += 2;
/* THS_PREPARE + THS_ZERO */
/* Refer to the default calculation in DSI_PHY_TIMCONFIG() */
THS_PREPARE_and_ZERO = DSI_NS_TO_CYCLE((0xC8 + 0x0a * ui), cycle_time);
LCM_LOGI("%s: THS_PREPARE=%d THS_PREPARE_and_ZERO=%d\n", __func__,
THS_PREPARE, THS_PREPARE_and_ZERO);
#undef DSI_NS_TO_CYCLE
}
params->dsi.HS_PRPR = THS_PREPARE;
params->dsi.HS_ZERO = THS_PREPARE_and_ZERO;
}
params->dsi.ssc_disable = 1;
params->dsi.pll_select = 0; /* 0: MIPI_PLL; 1: LVDS_PLL */
params->dsi.cont_clock = 0;
params->dsi.null_packet_en = 0;
LCM_LOGV("%s() exit\n", __func__);
}
#ifdef BUILD_LK
bool lk_power_initd;
#endif
static void lcm_init_power(void)
{
LCM_LOGD("%s() enter\n", __func__);
#ifdef BUILD_LK
bool lk_power_initd = false;
if (lk_power_initd == false) {
/* It's unnecessary to run twice in LK */
lk_power_initd = true;
/*Iinit lcm power */
// VIOVCC(1.8V) is depended on VDD(3.3V) , can not control
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO); //RST (H)->(L)GPIO20
lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ZERO); //DCDC_EN (H)->(L)GPIO129
lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ZERO); //LED (L)->(H)
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE); //DCDC_EN (L)->(H)GPIO129
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE); //LED (L)->(H)
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE); //RST (L)->(H)GPIO20
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO); //RST (H)->(L)GPIO20
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE); //RST (L)->(H)GPIO20
#if defined(GPIO_DSI_SWITCH) && defined(GPIO_DSI_SWITCH_DSI_OUTPUT)
/* DSI Switch 1 */
lcm_set_gpio_output(GPIO_DSI_SWITCH, GPIO_DSI_SWITCH_DSI_OUTPUT);
#endif
#if defined(GPIO_DSI_SWITCH2) && defined(GPIO_DSI_SWITCH2_DSI_OUTPUT)
/* DSI Switch 2 */
lcm_set_gpio_output(GPIO_DSI_SWITCH2, GPIO_DSI_SWITCH2_DSI_OUTPUT);
#endif
MDELAY(120);
}
#endif
LCM_LOGV("%s() exit\n", __func__);
}
#ifdef BUILD_LK
u32 kd070fhfid015_get_android_lcd_density(void)
{
return LCM_DENSITY;
}
#endif
static void init_lcm_registers(void)
{
unsigned int data_array[16];
data_array[0] = 0x00010500; //soft reset
dsi_set_cmdq(data_array, 1, 1);
MDELAY(5);
data_array[0] = 0x00110500; //exit sleep mode
dsi_set_cmdq(data_array, 1, 1);
MDELAY(120);
data_array[0] = 0x04B02300; //MCAP
dsi_set_cmdq(data_array, 1, 1);
data_array[0] = 0x00062902; //interface setting
data_array[1] = 0x000814B3; //5 paras 04-->14 //cmd-->video mode
data_array[2] = 0x00000022;
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00022902; //interface ID setting
data_array[1] = 0x00000CB4;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x00032902; //DSI control
data_array[1] = 0x00D33AB6; //D3
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x2C531500; //control display
dsi_set_cmdq(data_array, 1, 1);
data_array[0] = 0x773A1500; //set pixel format
dsi_set_cmdq(data_array, 1, 1);
data_array[0] = 0x00290500; //set display on
dsi_set_cmdq(data_array, 1, 1);
MDELAY(20);
}
#ifdef BUILD_LK
static void lcm_power_disable(void)
{
LCM_LOGD("%s() enter\n", __func__);
lk_power_initd = false;
LCM_LOGV("%s() exit\n", __func__);
}
#endif
static void lcm_init(void)
{
LCM_LOGD("%s() enter\n", __func__);
init_lcm_registers();
LCM_LOGV("%s() exit\n", __func__);
}
static void lcm_suspend_power(void)
{
LCM_LOGD("%s() enter\n", __func__);
SET_RESET_PIN(0);
MDELAY(5);
SET_BL_PIN(0);
MDELAY(5);
regulator_disable(lcm_vdd);
MDELAY(20);
SET_DCDC_PIN(0);
LCM_LOGV("%s() exit\n", __func__);
}
static void lcm_suspend(void)
{
unsigned int data_array[16];
LCM_LOGD("%s() enter\n", __func__);
data_array[0] = 0x00280500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(20);
data_array[0] = 0x00100500;
dsi_set_cmdq(data_array, 1, 1);
LCM_LOGV("%s() exit\n", __func__);
}
static void lcm_resume_power(void)
{
LCM_LOGD("%s() enter\n", __func__);
SET_DCDC_PIN(1);
MDELAY(5);
regulator_enable(lcm_vdd);
MDELAY(5);
SET_BL_PIN(1);
MDELAY(20);
SET_RESET_PIN(1);
MDELAY(5);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(50);
LCM_LOGV("%s() exit\n", __func__);
}
static void lcm_resume(void)
{
LCM_LOGD("%s() enter\n", __func__);
lcm_init();
LCM_LOGV("%s() exit\n", __func__);
}
static void lcm_set_backlight(unsigned int level)
{
LCM_LOGD("%s() enter level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(bl_level, ARRAY_SIZE(bl_level), 1);
}
static void push_table_cmdq(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
break;
}
}
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGD("%s() enter level=%d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table_cmdq(handle, bl_level, ARRAY_SIZE(bl_level), 1);
}
struct LCM_DRIVER kd070fhfid015_dsi_1200x1920_lcm_drv = {
.name = PANEL_DRV_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.init_power = lcm_init_power,
.suspend = lcm_suspend,
.suspend_power = lcm_suspend_power,
.resume = lcm_resume,
.resume_power = lcm_resume_power,
//.compare_id = lcm_compare_id,
.set_backlight = lcm_set_backlight,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
};
File diff suppressed because it is too large. Load diff
+326
View File
@@ -0,0 +1,326 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
#include <linux/string.h>
#include <linux/wait.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/module.h>
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/upmu_hw.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#else
#ifdef CONFIG_MTK_LEGACY
#include <mach/mt_pm_ldo.h> /* hwPowerOn */
#include <mt-plat/upmu_common.h>
#include <mach/upmu_sw.h>
#include <mach/upmu_hw.h>
#else
#include <mt-plat/upmu_common.h>
#include <mach/upmu_sw.h>
#include <mach/upmu_hw.h>
#endif
#endif
#ifdef CONFIG_MTK_LEGACY
#include <mach/mt_gpio.h>
#include <cust_gpio_usage.h>
#include <cust_i2c.h>
#else
#include <mt-plat/mt_gpio.h>
#endif
#include "lcm_define.h"
#include "lcm_drv.h"
#include "lcm_gpio.h"
#ifdef CONFIG_MTK_LEGACY
#if defined(GPIO_LCD_BIAS_ENP_PIN)
#define GPIO_65132_EN GPIO_LCD_BIAS_ENP_PIN
#else
#define GPIO_65132_EN 0
#endif
#else
#ifdef CONFIG_PINCTRL
static struct pinctrl *_lcm_gpio;
static struct pinctrl_state *_lcm_gpio_mode_default;
static struct pinctrl_state *_lcm_gpio_mode[MAX_LCM_GPIO_MODE];
static unsigned char _lcm_gpio_mode_list[MAX_LCM_GPIO_MODE][128] = {
"lcm_mode_00",
"lcm_mode_01",
"lcm_mode_02",
"lcm_mode_03",
"lcm_mode_04",
"lcm_mode_05",
"lcm_mode_06",
"lcm_mode_07"
};
static unsigned int GPIO_LCD_PWR_EN;
static unsigned int GPIO_LCD_BL_EN;
#endif
/* function definitions */
static int __init _lcm_gpio_init(void);
static void __exit _lcm_gpio_exit(void);
static int _lcm_gpio_probe(struct platform_device *pdev);
static int _lcm_gpio_remove(struct platform_device *pdev);
#ifdef CONFIG_OF
static const struct of_device_id _lcm_gpio_of_ids[] = {
{.compatible = "mediatek,lcm_mode",},
{},
};
MODULE_DEVICE_TABLE(of, _lcm_gpio_of_ids);
#endif
static struct platform_driver _lcm_gpio_driver = {
.driver = {
.name = LCM_GPIO_DEVICE,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(_lcm_gpio_of_ids),
},
.probe = _lcm_gpio_probe,
.remove = _lcm_gpio_remove,
};
module_platform_driver(_lcm_gpio_driver);
#endif
#ifdef CONFIG_MTK_LEGACY
#else
/* LCM GPIO probe */
static int _lcm_gpio_probe(struct platform_device *pdev)
{
#ifdef CONFIG_PINCTRL
int ret;
unsigned int mode;
const struct of_device_id *match;
struct device *dev = &pdev->dev;
pr_debug("[LCM][GPIO] enter %s, %d\n", __func__, __LINE__);
_lcm_gpio = devm_pinctrl_get(dev);
if (IS_ERR(_lcm_gpio)) {
ret = PTR_ERR(_lcm_gpio);
pr_info("[LCM][ERROR] Cannot find _lcm_gpio!\n");
return ret;
}
_lcm_gpio_mode_default = pinctrl_lookup_state(_lcm_gpio, "default");
if (IS_ERR(_lcm_gpio_mode_default)) {
ret = PTR_ERR(_lcm_gpio_mode_default);
pr_info("[LCM][ERROR] Cannot find lcm_mode_default %d!\n",
ret);
}
for (mode = LCM_GPIO_MODE_00; mode < MAX_LCM_GPIO_MODE; mode++) {
_lcm_gpio_mode[mode] =
pinctrl_lookup_state(_lcm_gpio,
_lcm_gpio_mode_list[mode]);
if (IS_ERR(_lcm_gpio_mode[mode]))
pr_info("[LCM][ERROR] Cannot find lcm_mode:%d! skip it.\n",
mode);
}
if (dev->of_node) {
match = of_match_device(of_match_ptr(_lcm_gpio_of_ids), dev);
if (!match) {
pr_info("[LCM][ERROR] No device match found\n");
return -ENODEV;
}
}
GPIO_LCD_PWR_EN =
of_get_named_gpio(dev->of_node, "lcm_power_gpio", 0);
GPIO_LCD_BL_EN =
of_get_named_gpio(dev->of_node, "lcm_bl_gpio", 0);
ret = gpio_request(GPIO_LCD_PWR_EN, "lcm_power_gpio");
if (ret < 0)
pr_info("[LCM][ERROR] Unable to request GPIO_LCD_PWR_EN\n");
ret = gpio_request(GPIO_LCD_BL_EN, "lcm_bl_gpio");
if (ret < 0)
pr_info("[LCM][ERROR] Unable to request GPIO_LCD_BL_EN\n");
pr_debug("[LCM][GPIO] _lcm_gpio_get_info end!\n");
#endif
return 0;
}
static int _lcm_gpio_remove(struct platform_device *pdev)
{
#ifdef CONFIG_PINCTRL
gpio_free(GPIO_LCD_BL_EN);
gpio_free(GPIO_LCD_PWR_EN);
#endif
return 0;
}
/* called when loaded into kernel */
static int __init _lcm_gpio_init(void)
{
pr_debug("MediaTek LCM GPIO driver init\n");
if (platform_driver_register(&_lcm_gpio_driver) != 0) {
pr_info("unable to register LCM GPIO driver.\n");
return -1;
}
return 0;
}
/* should never be called */
static void __exit _lcm_gpio_exit(void)
{
pr_debug("MediaTek LCM GPIO driver exit\n");
platform_driver_unregister(&_lcm_gpio_driver);
}
#endif
static enum LCM_STATUS _lcm_gpio_check_data(char type,
const struct LCM_DATA_T1 *t1)
{
switch (type) {
case LCM_GPIO_MODE:
switch (t1->data) {
case LCM_GPIO_MODE_00:
case LCM_GPIO_MODE_01:
case LCM_GPIO_MODE_02:
case LCM_GPIO_MODE_03:
case LCM_GPIO_MODE_04:
case LCM_GPIO_MODE_05:
case LCM_GPIO_MODE_06:
case LCM_GPIO_MODE_07:
break;
default:
pr_info("[LCM][ERROR] %s/%d: %d, %d\n",
__func__, __LINE__, type, t1->data);
return LCM_STATUS_ERROR;
}
break;
case LCM_GPIO_DIR:
switch (t1->data) {
case LCM_GPIO_DIR_IN:
case LCM_GPIO_DIR_OUT:
break;
default:
pr_info("[LCM][ERROR] %s/%d: %d, %d\n",
__func__, __LINE__, type, t1->data);
return LCM_STATUS_ERROR;
}
break;
case LCM_GPIO_OUT:
switch (t1->data) {
case LCM_GPIO_OUT_ZERO:
case LCM_GPIO_OUT_ONE:
break;
default:
pr_info("[LCM][ERROR] %s/%d: %d, %d\n",
__func__, __LINE__, type, t1->data);
return LCM_STATUS_ERROR;
}
break;
default:
pr_info("[LCM][ERROR] %s/%d: %d\n",
__func__, __LINE__, type);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_gpio_set_data(char type, const struct LCM_DATA_T1 *t1)
{
/* check parameter is valid */
if (_lcm_gpio_check_data(type, t1) == LCM_STATUS_OK) {
switch (type) {
#ifdef CONFIG_MTK_LEGACY
case LCM_GPIO_MODE:
mt_set_gpio_mode(GPIO_65132_EN, (unsigned int)t1->data);
break;
case LCM_GPIO_DIR:
mt_set_gpio_dir(GPIO_65132_EN, (unsigned int)t1->data);
break;
case LCM_GPIO_OUT:
mt_set_gpio_out(GPIO_65132_EN, (unsigned int)t1->data);
break;
#else
#ifdef CONFIG_PINCTRL
case LCM_GPIO_MODE:
pr_debug("[LCM][GPIO] %s/%d: set mode: %d\n",
__func__, __LINE__, (unsigned int)t1->data);
pinctrl_select_state(_lcm_gpio,
_lcm_gpio_mode[(unsigned int)t1->data]);
break;
case LCM_GPIO_DIR:
pr_debug("[LCM][GPIO] %s/%d: set dir: %d, %d\n",
__func__, __LINE__, GPIO_LCD_PWR_EN,
(unsigned int)t1->data);
gpio_direction_output(GPIO_LCD_PWR_EN, (int)t1->data);
break;
case LCM_GPIO_OUT:
pr_debug("[LCM][GPIO] %s/%d: set out: %d, %d\n",
__func__, __LINE__, GPIO_LCD_PWR_EN,
(unsigned int)t1->data);
gpio_set_value(GPIO_LCD_PWR_EN, (int)t1->data);
break;
#else
case LCM_GPIO_MODE:
case LCM_GPIO_DIR:
case LCM_GPIO_OUT:
break;
#endif
#endif
default:
pr_info("[LCM][ERROR] %s/%d: %d\n",
__func__, __LINE__, type);
return LCM_STATUS_ERROR;
}
} else {
pr_info("[LCM][ERROR] %s: 0x%x, 0x%x\n",
__func__, type, t1->data);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
#ifdef CONFIG_MTK_LEGACY
#else
module_init(_lcm_gpio_init);
module_exit(_lcm_gpio_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MediaTek LCM GPIO driver");
MODULE_AUTHOR("Joey Pan<joey.pan@mediatek.com>");
#endif
#endif
+276
View File
@@ -0,0 +1,276 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <linux/irq.h>
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/string.h>
#include <linux/wait.h>
#endif
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/upmu_hw.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#else
#ifdef CONFIG_MTK_LEGACY
#include <mach/mt_pm_ldo.h> /* hwPowerOn */
#include <mt-plat/upmu_common.h>
#include <mach/upmu_sw.h>
#include <mach/upmu_hw.h>
#endif
#endif
#ifdef CONFIG_MTK_LEGACY
#include <mach/mt_gpio.h>
#include <cust_gpio_usage.h>
#include <cust_i2c.h>
#endif
#include "lcm_define.h"
#include "lcm_drv.h"
#include "lcm_i2c.h"
/*****************************************************************************
* Define
*****************************************************************************/
#ifndef CONFIG_FPGA_EARLY_PORTING
#ifdef CONFIG_MTK_LEGACY
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM I2C_I2C_LCD_BIAS_CHANNEL /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "tps65132"
#else
#define LCM_I2C_ADDR 0x3E
#define LCM_I2C_BUSNUM 1 /* for I2C channel 0 */
#define LCM_I2C_ID_NAME "I2C_LCD_BIAS"
#endif
/*****************************************************************************
* GLobal Variable
*****************************************************************************/
#ifdef CONFIG_MTK_LEGACY
static struct i2c_board_info _lcm_i2c_board_info __initdata = {
I2C_BOARD_INFO(LCM_I2C_ID_NAME, LCM_I2C_ADDR)
};
#else
static const struct of_device_id _lcm_i2c_of_match[] = {
{ .compatible = "mediatek,I2C_LCD_BIAS", },
{},
};
#endif
static struct i2c_client *_lcm_i2c_client;
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int _lcm_i2c_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct _lcm_i2c_dev {
struct i2c_client *client;
};
static const struct i2c_device_id _lcm_i2c_id[] = {
{LCM_I2C_ID_NAME, 0},
{}
};
/* #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
/* static struct i2c_client_address_data addr_data = { .forces = forces,}; */
/* #endif */
static struct i2c_driver _lcm_i2c_driver = {
.id_table = _lcm_i2c_id,
.probe = _lcm_i2c_probe,
.remove = _lcm_i2c_remove,
/* .detect = _lcm_i2c_detect, */
.driver = {
.owner = THIS_MODULE,
.name = LCM_I2C_ID_NAME,
#ifdef CONFIG_MTK_LEGACY
#else
.of_match_table = _lcm_i2c_of_match,
#endif
},
};
/*****************************************************************************
* Extern Area
*****************************************************************************/
/*****************************************************************************
* Function
*****************************************************************************/
static int _lcm_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
pr_debug("[LCM][I2C] %s\n", __func__);
pr_debug("[LCM][I2C] NT: info==>name=%s addr=0x%x\n",
client->name, client->addr);
_lcm_i2c_client = client;
return 0;
}
static int _lcm_i2c_remove(struct i2c_client *client)
{
pr_debug("[LCM][I2C] %s\n", __func__);
_lcm_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
static int _lcm_i2c_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = _lcm_i2c_client;
char write_data[2] = { 0 };
if (client == NULL) {
pr_debug("ERROR!! _lcm_i2c_client is null\n");
return 0;
}
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
pr_info("[LCM][ERROR] _lcm_i2c write data fail !!\n");
return ret;
}
/*
* module load/unload record keeping
*/
static int __init _lcm_i2c_init(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
#ifdef CONFIG_MTK_LEGACY
i2c_register_board_info(LCM_I2C_BUSNUM, &_lcm_i2c_board_info, 1);
pr_debug("[LCM][I2C] _lcm_i2c_init2\n");
#endif
i2c_add_driver(&_lcm_i2c_driver);
pr_debug("[LCM][I2C] %s success\n", __func__);
return 0;
}
static void __exit _lcm_i2c_exit(void)
{
pr_debug("[LCM][I2C] %s\n", __func__);
i2c_del_driver(&_lcm_i2c_driver);
}
static enum LCM_STATUS _lcm_i2c_check_data(char type,
const struct LCM_DATA_T2 *t2)
{
switch (type) {
case LCM_I2C_WRITE:
if (t2->cmd > 0xFF) {
pr_info("[LCM][ERROR] %s/%d: %d\n",
__func__, __LINE__, t2->cmd);
return LCM_STATUS_ERROR;
}
if (t2->data > 0xFF) {
pr_info("[LCM][ERROR] %s/%d: %d\n",
__func__, __LINE__, t2->data);
return LCM_STATUS_ERROR;
}
break;
default:
pr_info("[LCM][ERROR] %s/%d: %d\n", __func__, __LINE__, type);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
#endif
enum LCM_STATUS lcm_i2c_set_data(char type, const struct LCM_DATA_T2 *t2)
{
#ifndef CONFIG_FPGA_EARLY_PORTING
unsigned int ret_code = 0;
/* check parameter is valid */
if (_lcm_i2c_check_data(type, t2) == LCM_STATUS_OK) {
switch (type) {
case LCM_I2C_WRITE:
pr_debug("[LCM][I2C] %s/%d: %d, 0x%x, 0x%x\n",
__func__, __LINE__, type, t2->cmd, t2->data);
ret_code =
_lcm_i2c_write_bytes((unsigned char)t2->cmd,
(unsigned char)t2->data);
break;
default:
pr_info("[LCM][ERROR] %s/%d: %d\n",
__func__, __LINE__, type);
return LCM_STATUS_ERROR;
}
} else {
pr_info("[LCM][ERROR] %s/%d: %d, 0x%x, 0x%x\n",
__func__, __LINE__, type, t2->cmd, t2->data);
return LCM_STATUS_ERROR;
}
if (ret_code < 0) {
pr_info("[LCM][ERROR] %s/%d: 0x%x, 0x%x, %d\n",
__func__, __LINE__, (unsigned int)t2->cmd,
(unsigned int)t2->data, ret_code);
return LCM_STATUS_ERROR;
}
#endif
return LCM_STATUS_OK;
}
#ifndef CONFIG_FPGA_EARLY_PORTING
module_init(_lcm_i2c_init);
module_exit(_lcm_i2c_exit);
MODULE_AUTHOR("Joey Pan");
MODULE_DESCRIPTION("MTK LCM I2C Driver");
MODULE_LICENSE("GPL");
#endif
#else
struct i2c_client *_lcm_i2c_client;
#endif
+149
View File
@@ -0,0 +1,149 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/regulator/consumer.h>
#include <linux/string.h>
#include <linux/kernel.h>
#if defined(CONFIG_RT5081_PMU_DSV) || defined(CONFIG_MT6370_PMU_DSV)
static struct regulator *disp_bias_pos;
static struct regulator *disp_bias_neg;
static int regulator_inited;
int display_bias_regulator_init(void)
{
int ret = 0;
if (regulator_inited)
return ret;
/* please only get regulator once in a driver */
disp_bias_pos = regulator_get(NULL, "dsv_pos");
if (IS_ERR(disp_bias_pos)) { /* handle return value */
ret = PTR_ERR(disp_bias_pos);
pr_info("get dsv_pos fail, error: %d\n", ret);
return ret;
}
disp_bias_neg = regulator_get(NULL, "dsv_neg");
if (IS_ERR(disp_bias_neg)) { /* handle return value */
ret = PTR_ERR(disp_bias_neg);
pr_info("get dsv_neg fail, error: %d\n", ret);
return ret;
}
regulator_inited = 1;
return ret; /* must be 0 */
}
EXPORT_SYMBOL(display_bias_regulator_init);
int disp_late_bias_enable(void)
{
int ret = 0;
int retval = 0;
display_bias_regulator_init();
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
EXPORT_SYMBOL(disp_late_bias_enable);
int display_bias_enable(void)
{
int ret = 0;
int retval = 0;
display_bias_regulator_init();
/* set voltage with min & max*/
ret = regulator_set_voltage(disp_bias_pos, 5400000, 5400000);
if (ret < 0)
pr_info("set voltage disp_bias_pos fail, ret = %d\n", ret);
retval |= ret;
ret = regulator_set_voltage(disp_bias_neg, 5400000, 5400000);
if (ret < 0)
pr_info("set voltage disp_bias_neg fail, ret = %d\n", ret);
retval |= ret;
/* enable regulator */
ret = regulator_enable(disp_bias_pos);
if (ret < 0)
pr_info("enable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_enable(disp_bias_neg);
if (ret < 0)
pr_info("enable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
EXPORT_SYMBOL(display_bias_enable);
int display_bias_disable(void)
{
int ret = 0;
int retval = 0;
display_bias_regulator_init();
ret = regulator_disable(disp_bias_neg);
if (ret < 0)
pr_info("disable regulator disp_bias_neg fail, ret = %d\n",
ret);
retval |= ret;
ret = regulator_disable(disp_bias_pos);
if (ret < 0)
pr_info("disable regulator disp_bias_pos fail, ret = %d\n",
ret);
retval |= ret;
return retval;
}
EXPORT_SYMBOL(display_bias_disable);
#else
int display_bias_regulator_init(void)
{
return 0;
}
EXPORT_SYMBOL(display_bias_regulator_init);
int display_bias_enable(void)
{
return 0;
}
EXPORT_SYMBOL(display_bias_enable);
int disp_late_bias_enable(void)
{
return 0;
}
EXPORT_SYMBOL(disp_late_bias_enable);
int display_bias_disable(void)
{
return 0;
}
EXPORT_SYMBOL(display_bias_disable);
#endif
+257
View File
@@ -0,0 +1,257 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#if defined(MTK_LCM_DEVICE_TREE_SUPPORT)
#include <linux/string.h>
#include <linux/wait.h>
#include "lcm_define.h"
#include "lcm_drv.h"
#include "lcm_util.h"
static enum LCM_STATUS _lcm_util_check_data(char type,
const struct LCM_DATA_T1 *t1)
{
switch (type) {
case LCM_UTIL_RESET:
switch (t1->data) {
case LCM_UTIL_RESET_LOW:
case LCM_UTIL_RESET_HIGH:
break;
default:
return LCM_STATUS_ERROR;
}
break;
case LCM_UTIL_MDELAY:
case LCM_UTIL_UDELAY:
case LCM_UTIL_RAR:
/* no limitation */
break;
default:
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
static enum LCM_STATUS _lcm_util_check_write_cmd_v1(
const struct LCM_DATA_T5 *t5)
{
if (t5 == NULL)
return LCM_STATUS_ERROR;
if (t5->size == 0)
return LCM_STATUS_ERROR;
return LCM_STATUS_OK;
}
static enum LCM_STATUS _lcm_util_check_write_cmd_v2(
const struct LCM_DATA_T3 *t3)
{
if (t3 == NULL)
return LCM_STATUS_ERROR;
if ((t3->size > 0) && (t3->data == NULL))
return LCM_STATUS_ERROR;
return LCM_STATUS_OK;
}
static enum LCM_STATUS _lcm_util_check_write_cmd_v23(
const struct LCM_DATA_T3 *t3)
{
if (t3 == NULL)
return LCM_STATUS_ERROR;
return LCM_STATUS_OK;
}
static enum LCM_STATUS _lcm_util_check_read_cmd_v2(
const struct LCM_DATA_T4 *t4)
{
if (t4 == NULL)
return LCM_STATUS_ERROR;
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_util_set_data(const struct LCM_UTIL_FUNCS *lcm_util,
char type, struct LCM_DATA_T1 *t1)
{
/* check parameter is valid */
if (_lcm_util_check_data(type, t1) == LCM_STATUS_OK) {
switch (type) {
case LCM_UTIL_RESET:
lcm_util->set_reset_pin((unsigned int)t1->data);
break;
case LCM_UTIL_MDELAY:
lcm_util->mdelay((unsigned int)t1->data);
break;
case LCM_UTIL_UDELAY:
lcm_util->udelay((unsigned int)t1->data);
break;
case LCM_UTIL_RAR:
lcm_util->rar((unsigned int)t1->data);
break;
default:
pr_debug("[LCM][ERROR] %s/%d: %d\n",
__func__, __LINE__, type);
return LCM_STATUS_ERROR;
}
} else {
pr_debug("[LCM][ERROR] %s/%d: 0x%x, 0x%x\n",
__func__, __LINE__, type, t1->data);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_util_set_write_cmd_v1(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T5 *t5,
unsigned char force_update)
{
unsigned int i;
unsigned int cmd[32];
/* check parameter is valid */
if (_lcm_util_check_write_cmd_v1(t5) == LCM_STATUS_OK) {
memset(cmd, 0x0, sizeof(unsigned int) * 32);
for (i = 0; i < t5->size; i++)
cmd[i] = (t5->cmd[i * 4 + 3] << 24)
| (t5->cmd[i * 4 + 2] << 16)
| (t5->cmd[i * 4 + 1] << 8)
| (t5->cmd[i * 4]);
lcm_util->dsi_set_cmdq(cmd, (unsigned int)t5->size,
force_update);
} else {
pr_debug("[LCM][ERROR] %s/%d: 0x%p, %d\n",
__func__, __LINE__, t5->cmd, t5->size);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_util_set_write_cmd_v11(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T5 *t5,
unsigned char force_update, void *cmdq)
{
unsigned int i;
unsigned int cmd[32];
if (lcm_util->dsi_set_cmdq_V11 == NULL)
return LCM_STATUS_OK;
/* check parameter is valid */
if (_lcm_util_check_write_cmd_v1(t5) == LCM_STATUS_OK) {
memset(cmd, 0x0, sizeof(unsigned int) * 32);
for (i = 0; i < t5->size; i++)
cmd[i] = (t5->cmd[i * 4 + 3] << 24)
| (t5->cmd[i * 4 + 2] << 16)
| (t5->cmd[i * 4 + 1] << 8)
| (t5->cmd[i * 4]);
lcm_util->dsi_set_cmdq_V11(cmdq, cmd,
(unsigned int)t5->size, force_update);
} else {
pr_debug("[LCM][ERROR] %s/%d: 0x%p, %d\n",
__func__, __LINE__, t5->cmd, t5->size);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_util_set_write_cmd_v2(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T3 *t3,
unsigned char force_update)
{
/* check parameter is valid */
if (_lcm_util_check_write_cmd_v2(t3) == LCM_STATUS_OK) {
if (t3->cmd == LCM_UTIL_WRITE_CMD_V2_NULL) {
lcm_util->dsi_set_null((unsigned char)t3->cmd,
(unsigned char)t3->size,
(unsigned char *)t3->data, force_update);
} else {
lcm_util->dsi_set_cmdq_V2((unsigned char)t3->cmd,
(unsigned char)t3->size,
(unsigned char *)t3->data, force_update);
}
} else {
pr_debug("[LCM][ERROR] %s/%d: 0x%x, %d, 0x%p\n",
__func__, __LINE__, t3->cmd, t3->size, t3->data);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_util_set_write_cmd_v23(
const struct LCM_UTIL_FUNCS *lcm_util, void *handle,
struct LCM_DATA_T3 *t3, unsigned char force_update)
{
/* check parameter is valid */
if (_lcm_util_check_write_cmd_v23(t3) == LCM_STATUS_OK)
lcm_util->dsi_set_cmdq_V23(handle, (unsigned char)t3->cmd,
(unsigned char)t3->size,
(unsigned char *)t3->data, force_update);
else {
pr_debug("[LCM][ERROR] %s/%d: 0x%x, %d, 0x%p\n",
__func__, __LINE__, t3->cmd, t3->size, t3->data);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
enum LCM_STATUS lcm_util_set_read_cmd_v2(
const struct LCM_UTIL_FUNCS *lcm_util, struct LCM_DATA_T4 *t4,
unsigned int *compare)
{
if (compare == NULL) {
pr_debug("[LCM][ERROR] %s/%d: NULL parameter\n",
__func__, __LINE__);
return LCM_STATUS_ERROR;
}
*compare = 0;
/* check parameter is valid */
if (_lcm_util_check_read_cmd_v2(t4) == LCM_STATUS_OK) {
unsigned char buffer[4];
lcm_util->dsi_dcs_read_lcm_reg_v2(
(unsigned char)t4->cmd, buffer, 4);
if (buffer[(unsigned int)t4->location] ==
((unsigned char)t4->data))
*compare = 1;
} else {
pr_debug("[LCM][ERROR] %s/%d: 0x%x, %d, 0x%x\n",
__func__, __LINE__, t4->cmd, t4->location, t4->data);
return LCM_STATUS_ERROR;
}
return LCM_STATUS_OK;
}
#endif
File diff suppressed because it is too large. Load diff
+349
View File
@@ -0,0 +1,349 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
* Author: Joey Pan <joey.pan@mediatek.com>
*/
#ifndef __MT65XX_LCM_LIST_H__
#define __MT65XX_LCM_LIST_H__
#include <lcm_drv.h>
extern struct LCM_DRIVER otm1282a_hd720_dsi_vdo_60hz_lcm_drv;
extern struct LCM_DRIVER otm1282a_hd720_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_8163_lcm_drv;
extern struct LCM_DRIVER nt35523_wxga_dsi_vdo_8163_lcm_drv;
extern struct LCM_DRIVER vvx10f008b00_wuxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER r63319_wqhd_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER nt35598_wqhd_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER lp079x01_lcm_drv;
extern struct LCM_DRIVER hx8369_lcm_drv;
extern struct LCM_DRIVER hx8369_6575_lcm_drv;
extern struct LCM_DRIVER hx8363_6575_dsi_lcm_drv;
extern struct LCM_DRIVER hx8363_6575_dsi_hvga_lcm_drv;
extern struct LCM_DRIVER hx8363_6575_dsi_qvga_lcm_drv;
extern struct LCM_DRIVER hx8363b_wvga_dsi_cmd_drv;
extern struct LCM_DRIVER bm8578_lcm_drv;
extern struct LCM_DRIVER nt35582_mcu_lcm_drv;
extern struct LCM_DRIVER nt35582_mcu_6575_lcm_drv;
extern struct LCM_DRIVER nt35582_rgb_6575_lcm_drv;
extern struct LCM_DRIVER hx8357b_lcm_drv;
extern struct LCM_DRIVER hx8357c_hvga_dsi_cmd_drv;
extern struct LCM_DRIVER hx8369_dsi_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_6575_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_6575_hvga_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_6575_qvga_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8369b_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8369b_wvga_dsi_vdo_drv;
extern struct LCM_DRIVER hx8389b_qhd_dsi_vdo_drv;
extern struct LCM_DRIVER hx8369_hvga_lcm_drv;
extern struct LCM_DRIVER ili9481_lcm_drv;
extern struct LCM_DRIVER nt35582_lcm_drv;
extern struct LCM_DRIVER s6d0170_lcm_drv;
extern struct LCM_DRIVER spfd5461a_lcm_drv;
extern struct LCM_DRIVER ta7601_lcm_drv;
extern struct LCM_DRIVER tft1p3037_lcm_drv;
extern struct LCM_DRIVER ha5266_lcm_drv;
extern struct LCM_DRIVER hsd070idw1_lcm_drv;
extern struct LCM_DRIVER lg4571_lcm_drv;
extern struct LCM_DRIVER lg4573b_wvga_dsi_vdo_lh430mv1_drv;
extern struct LCM_DRIVER lvds_wsvga_lcm_drv;
extern struct LCM_DRIVER lvds_wsvga_ti_lcm_drv;
extern struct LCM_DRIVER lvds_wsvga_ti_n_lcm_drv;
extern struct LCM_DRIVER nt35565_3d_lcm_drv;
extern struct LCM_DRIVER tm070ddh03_lcm_drv;
extern struct LCM_DRIVER r61408_lcm_drv;
extern struct LCM_DRIVER r61408_wvga_dsi_cmd_drv;
extern struct LCM_DRIVER nt35510_lcm_drv;
extern struct LCM_DRIVER nt35510_dpi_lcm_drv;
extern struct LCM_DRIVER nt35510_hvga_lcm_drv;
extern struct LCM_DRIVER nt35510_qvga_lcm_drv;
extern struct LCM_DRIVER nt35510_wvga_dsi_cmd_drv;
extern struct LCM_DRIVER nt35510_6517_lcm_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6572_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6572_hvga_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6572_fwvga_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6572_qvga_drv;
extern struct LCM_DRIVER nt35510_dsi_vdo_6572_drv;
extern struct LCM_DRIVER nt35510_dpi_6572_lcm_drv;
extern struct LCM_DRIVER nt35510_mcu_6572_lcm_drv;
extern struct LCM_DRIVER nt51012_hd720_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35532_fhd_dsi_vdo_sharp_lcm_drv;
extern struct LCM_DRIVER otm1901a_fhd_dsi_vdo_tpv_lcm_drv;
extern struct LCM_DRIVER r63350a_fhd_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER r63303_idisplay_lcm_drv;
extern struct LCM_DRIVER hj080ia_lcm_drv;
extern struct LCM_DRIVER hj101na02a_lcm_drv;
extern struct LCM_DRIVER hj101na02a_8135_lcm_drv;
extern struct LCM_DRIVER hsd070pfw3_lcm_drv;
extern struct LCM_DRIVER hsd070pfw3_8135_lcm_drv;
extern struct LCM_DRIVER cm_n070ice_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER ej101ia_lcm_drv;
extern struct LCM_DRIVER scf0700m48ggu02_lcm_drv;
extern struct LCM_DRIVER nt35510_fwvga_lcm_drv;
#if defined(GN_SSD2825_SMD_S6E8AA)
extern struct LCM_DRIVER gn_ssd2825_smd_s6e8aa;
#endif
extern struct LCM_DRIVER nt35517_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_bld_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_tm_lcm_drv;
extern struct LCM_DRIVER otm1280a_hd720_dsi_cmd_drv;
extern struct LCM_DRIVER otm8018b_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER otm8018b_dsi_vdo_txd_fwvga_lcm_drv;
extern struct LCM_DRIVER nt35512_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35512_wvga_dsi_vdo_boe_drv;
extern struct LCM_DRIVER hx8369_rgb_6585_fpga_lcm_drv;
extern struct LCM_DRIVER hx8369_rgb_6572_fpga_lcm_drv;
extern struct LCM_DRIVER hx8369_mcu_6572_lcm_drv;
extern struct LCM_DRIVER hx8369a_wvga_dsi_cmd_drv;
extern struct LCM_DRIVER hx8369a_wvga_dsi_vdo_drv;
extern struct LCM_DRIVER hx8392a_dsi_cmd_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_cmd_3lane_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_cmd_wvga_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_cmd_fwvga_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_cmd_qhd_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_vdo_2lane_lcm_drv;
extern struct LCM_DRIVER hx8392a_dsi_vdo_3lane_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER ssd2075_hd720_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_auo_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_auo_fwvga_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_auo_wvga_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_auo_qhd_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_cmi_lcm_drv;
extern struct LCM_DRIVER nt35516_qhd_dsi_cmd_ipsboe_lcm_drv;
extern struct LCM_DRIVER nt35516_qhd_dsi_cmd_ipsboe_wvga_lcm_drv;
extern struct LCM_DRIVER nt35516_qhd_dsi_cmd_ipsboe_fwvga_lcm_drv;
extern struct LCM_DRIVER nt35516_qhd_dsi_cmd_ips9k1431_drv;
extern struct LCM_DRIVER nt35516_qhd_dsi_cmd_tft9k1342_drv;
extern struct LCM_DRIVER bp070ws1_lcm_drv;
extern struct LCM_DRIVER bp101wx1_lcm_drv;
extern struct LCM_DRIVER bp101wx1_n_lcm_drv;
extern struct LCM_DRIVER nt35516_qhd_rav4_lcm_drv;
extern struct LCM_DRIVER r63311_fhd_dsi_vdo_sharp_lcm_drv;
extern struct LCM_DRIVER r81592_hvga_dsi_cmd_drv;
extern struct LCM_DRIVER rm68190_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_nt50358_fwvga_lcm_drv;
extern struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_nt50358_qhd_lcm_drv;
extern struct LCM_DRIVER nt35596_fhd_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_tps65132_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_vdo_truly_tps65132_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_vdo_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_720p_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_qhd_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_fwvga_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_wvga_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_tps65132_720p_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_6735_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_6735_720p_lcm_drv;
extern struct LCM_DRIVER nt35596_fhd_dsi_vdo_yassy_lcm_drv;
extern struct LCM_DRIVER nt35596_hd720_dsi_vdo_truly_tps65132_lcm_drv;
extern struct LCM_DRIVER nt35590_hd720_dsi_cmd_truly2_lcm_drv;
extern struct LCM_DRIVER otm9608_wvga_dsi_cmd_drv;
extern struct LCM_DRIVER otm9608_fwvga_dsi_cmd_drv;
extern struct LCM_DRIVER otm9608_qhd_dsi_cmd_drv;
extern struct LCM_DRIVER otm9608_qhd_dsi_vdo_drv;
extern struct LCM_DRIVER otm8009a_fwvga_dsi_cmd_tianma_lcm_drv;
extern struct LCM_DRIVER otm8009a_fwvga_dsi_vdo_tianma_lcm_drv;
extern struct LCM_DRIVER hx8389b_qhd_dsi_vdo_tianma_lcm_drv;
extern struct LCM_DRIVER cm_otc3108bhv161_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER auo_b079xat02_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8389b_qhd_dsi_vdo_tianma055xdhp_lcm_drv;
extern struct LCM_DRIVER cpt_claa101fp01_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER cpt_claa101fp01_dsi_vdo_8163_lcm_drv;
extern struct LCM_DRIVER h070d_18dm_lcm_drv;
extern struct LCM_DRIVER hx8394a_hd720_dsi_vdo_tianma_lcm_drv;
extern struct LCM_DRIVER hx8394d_hd720_dsi_vdo_tianma_lcm_drv;
extern struct LCM_DRIVER cpt_clap070wp03xg_sn65dsi83_lcm_drv;
extern struct LCM_DRIVER nt35520_hd720_tm_lcm_drv;
extern struct LCM_DRIVER nt35520_hd720_boe_lcm_drv;
extern struct LCM_DRIVER nt35521_hd720_dsi_vdo_boe_lcm_drv;
extern struct LCM_DRIVER nt35521_hd720_tm_lcm_drv;
extern struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_rt5081_lcm_drv;
extern struct LCM_DRIVER r69429_wuxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER r69429_wuxga_dsi_cmd_lcm_drv;
extern struct LCM_DRIVER rm68210_hd720_dsi_ufoe_cmd_lcm_drv;
extern struct LCM_DRIVER r63311_fhd_dsi_vedio_lcm_drv;
extern struct LCM_DRIVER otm1283a_6589_hd_dsi;
extern struct LCM_DRIVER hx8394a_hd720_dsi_vdo_tianma_v2_lcm_drv;
extern struct LCM_DRIVER cpt_clap070wp03xg_lvds_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_cmd_6571_lcm_drv;
extern struct LCM_DRIVER hx8369_dsi_vdo_6571_lcm_drv;
extern struct LCM_DRIVER hx8369_dbi_6571_lcm_drv;
extern struct LCM_DRIVER hx8369_dpi_6571_lcm_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6571_lcm_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6571_hvga_lcm_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_6571_qvga_lcm_drv;
extern struct LCM_DRIVER nt35510_dsi_vdo_6571_lcm_drv;
extern struct LCM_DRIVER nt35510_dbi_6571_lcm_drv;
extern struct LCM_DRIVER nt35510_dpi_6571_lcm_drv;
extern struct LCM_DRIVER nt35590_dsi_cmd_6571_fwvga_lcm_drv;
extern struct LCM_DRIVER nt35590_dsi_cmd_6571_qhd_lcm_drv;
extern struct LCM_DRIVER it6151_edp_dsi_video_sharp_lcm_drv;
extern struct LCM_DRIVER nt35517_qhd_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER otm1283a_hd720_dsi_vdo_tm_lcm_drv;
extern struct LCM_DRIVER otm1284a_hd720_dsi_vdo_tm_lcm_drv;
extern struct LCM_DRIVER otm1285a_hd720_dsi_vdo_tm_lcm_drv;
extern struct LCM_DRIVER hx8389b_qhd_dsi_vdo_lgd_lcm_drv;
extern struct LCM_DRIVER it6151_fhd_edp_dsi_video_auo_lcm_drv;
extern struct LCM_DRIVER tf070mc_rgb_v18_mt6571_lcm_drv;
extern struct LCM_DRIVER zs070ih5015b3h6_mt6571_lcm_drv;
extern struct LCM_DRIVER a080ean01_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER it6121_g156xw01v1_lvds_vdo_lcm_drv;
extern struct LCM_DRIVER cpt_clap070wp03xg_lvds_lcm_drv;
extern struct LCM_DRIVER r63315_fhd_dsi_vdo_truly_lcm_drv;
extern struct LCM_DRIVER it6151_lp079qx1_edp_dsi_video_lcm_drv;
extern struct LCM_DRIVER RX_498HX_615B_lcm_drv;
extern struct LCM_DRIVER RX_498HX_615B_82_lcm_drv;
extern struct LCM_DRIVER ili9806c_dsi_vdo_djn_fwvga_lcm_drv;
extern struct LCM_DRIVER hx8389b_hd720_dsi_vdo_drv;
extern struct LCM_DRIVER r69338_hd720_dsi_vdo_jdi_drv;
extern struct LCM_DRIVER r69338_hd720_5in_dsi_vdo_jdi_dw8768_drv;
extern struct LCM_DRIVER db7436_dsi_vdo_fwvga_drv;
extern struct LCM_DRIVER r63417_fhd_dsi_cmd_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER r63417_fhd_dsi_cmd_truly_nt50358_720p_lcm_drv;
extern struct LCM_DRIVER r63417_fhd_dsi_cmd_truly_nt50358_qhd_lcm_drv;
extern struct LCM_DRIVER r63417_fhd_dsi_vdo_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER r63419_wqhd_truly_phantom_cmd_lcm_drv;
extern struct LCM_DRIVER r63419_wqhd_truly_phantom_vdo_lcm_drv;
extern struct LCM_DRIVER r63419_fhd_truly_phantom_lcm_drv;
extern struct LCM_DRIVER r63423_wqhd_truly_phantom_lcm_drv;
extern struct LCM_DRIVER kd070d5450nha6_rgb_dpi_lcm_drv;
extern struct LCM_DRIVER kr101ia2s_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER kr070ia4t_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER r69338_hd720_dsi_vdo_jdi_dw8755a_drv;
extern struct LCM_DRIVER otm9605a_qhd_dsi_vdo_drv;
extern struct LCM_DRIVER ili9806e_dsi_vdo_fwvga_drv;
extern struct LCM_DRIVER otm1906a_fhd_dsi_cmd_auto_lcm_drv;
extern struct LCM_DRIVER clap070wp03xg_lvds_lcm_drv;
extern struct LCM_DRIVER nt35523_wxga_dsi_vdo_boe_lcm_drv;
extern struct LCM_DRIVER otm1906b_fhd_dsi_cmd_jdi_tps65132_lcm_drv;
extern struct LCM_DRIVER otm1906b_fhd_dsi_cmd_jdi_tps65132_mt6797_lcm_drv;
extern struct LCM_DRIVER otm1906b_fhd_dsi_vdo_jdi_tps65132_mt6797_lcm_drv;
extern struct LCM_DRIVER s6e3fa2_fhd1080_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35523_wsvga_dsi_vdo_boe_lcm_drv;
extern struct LCM_DRIVER ek79023_dsi_wsvga_vdo_lcm_drv;
extern struct LCM_DRIVER nt35532_fhd_dsi_vdo_sharp_lcm_drv;
extern struct LCM_DRIVER s6d7aa0_wxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8394c_wxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER it6151_lp079qx1_edp_dsi_video_8163evb_lcm_drv;
extern struct LCM_DRIVER sy20810800210132_wuxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_truly_nt50358_720p_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_truly_nt50358_qhd_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_truly_rt4801_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_truly_rt5081_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_truly_rt5081_720p_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_hdp_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_hdp_19_9_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_hdp_1560_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_hdp_1680_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_hdp_20_9_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_720p_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_truly_rt5081_qhd_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_truly_rt5081_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_truly_rt5081_720p_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_truly_rt5081_qhd_lcm_drv;
extern struct LCM_DRIVER nt35510_dsi_cmd_lcm_drv;
extern struct LCM_DRIVER rm69032_dsi_cmd_lcm_drv;
extern struct LCM_DRIVER st7789h2_dbi_lcm_drv;
extern struct LCM_DRIVER ek79007_wsvgalnl_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER cm_n070ice_dsi_vdo_mt8173_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_extern_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_2th_lcm_drv;
extern struct LCM_DRIVER r69429_wqxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER hx8394c_wxga_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt35595_truly_fhd_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER nt36850_wqhd_dsi_2k_cmd_lcm_drv;
extern struct LCM_DRIVER s6e3ha3_wqhd_2k_cmd_lcm_drv;
extern struct LCM_DRIVER s6e3fa3_fhd_cmd_lcm_drv;
extern struct LCM_DRIVER nt35595_fhd_dsi_cmd_truly_nt50358_720p_extern_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_cmd_auo_nt50358_laneswap_lcm_drv;
extern struct LCM_DRIVER nt35695_fhd_dsi_vdo_auo_nt50358_laneswap_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_rt4801_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_rt5081_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_rt5081_720p_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_rt5081_qhd_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_rt5081_hdp_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_rt5081_hdp_19_9_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_720p_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_qhd_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_hdp_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_hdp_19_9_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_hdp_1560_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_hdp_1680_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_rt5081_hdp_20_9_lcm_drv;
extern struct LCM_DRIVER claa101fp01_dsi_vdo_lcm_drv;
extern struct LCM_DRIVER r61322_fhd_dsi_vdo_sharp_lfr_lcm_drv;
extern struct LCM_DRIVER s6e3ha3_wqhd_2k_cmd_laneswap_drv;
extern struct LCM_DRIVER nt36380_wqhd_vdo_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_vdo_auo_nt50358_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_nt50358_720p_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_nt50358_hdp_lcm_drv;
extern struct LCM_DRIVER nt35695B_fhd_dsi_cmd_auo_nt50358_qhd_lcm_drv;
extern struct LCM_DRIVER ili9881c_hdp_dsi_vdo_ilitek_rt5081_lcm_drv;
extern struct LCM_DRIVER nt51021_wuxga_dsi_vdo_mt8173_lcm_drv;
extern struct LCM_DRIVER ili9881c_hdp_dsi_vdo_ilitek_rt5081_lcm_drv_ebbg;
extern struct LCM_DRIVER hx8394f_hd720_dsi_vdo_tianma_lcm_drv;
extern struct LCM_DRIVER jd9365_hd720_dsi_lcm_drv;
extern struct LCM_DRIVER nt36672_fhdp_dsi_vdo_auo_lcm_drv;
extern struct LCM_DRIVER nt36672_fhdp_dsi_vdo_auo_laneswap_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_60hz_wo_dsc_shenchao_lcm_drv;
extern struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_nt50358_lcm_drv;
extern struct LCM_DRIVER ili9881h_hdp_dsi_vdo_ilitek_rt5081_19_9_lcm_drv;
extern struct LCM_DRIVER ili9881h_hdp_dsi_vdo_ilitek_rt5081_19_9_90hz_lcm_drv;
extern struct LCM_DRIVER ili9881c_hd_dsi_vdo_ilitek_nt50358_lcm_drv;
extern struct LCM_DRIVER ili9882n_hdp_dsi_vdo_rt4801_90hz_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt4801_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_fhd_auo_rt4801_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_auo_rt4801_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt5081_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_auo_rt5081_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_cmd_auo_rt5081_hdp_lcm_drv;
extern struct LCM_DRIVER hx83112b_fhdp_dsi_vdo_auo_rt5081_hdp_lcm_drv;
extern struct LCM_DRIVER es6311_anx6585_zigzag_wxga_lcm_drv;
extern struct LCM_DRIVER ft8201_wxga_vdo_incell_boe_lcm_drv;
extern struct LCM_DRIVER nt51021h_wuxga_vdo_oncell_boe_lcm_drv;
extern struct LCM_DRIVER nt36672ah_hdp_dsi_vdo_tcl_csot_lcm_drv;
extern struct LCM_DRIVER nt36672ah_hdp_dsi_vdo_tcl_csot_fwvplus_lcm_drv;
extern struct LCM_DRIVER sofeg01_fhdplus_dsi_cmd_samsung_lcm_drv;
#if defined(NT36672C_FHDP_DSI_VDO_AUO_CPHY_90HZ_TIANMA)
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_auo_cphy_90hz_tianma_lcm_drv;
#endif
extern struct LCM_DRIVER oppo_tianma_td4310_fhdp_dsi_vdo_rt5081_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_60hz_shenchao_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_90hz_shenchao_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_90hz_shenchao_6382_lcm_drv;
extern struct LCM_DRIVER r66451_fhdp_dsi_cmd_tianma_lcm_drv;
extern struct LCM_DRIVER td4320_fhdp_dsi_vdo_auo_rt4801_lcm_drv;
extern struct LCM_DRIVER td4320_fhdp_dsi_vdo_auo_rt5081_lcm_drv;
/*6768 otm */
extern struct LCM_DRIVER otm1911a_fhdp_dsi_vdo_truly_rt5081_lcm_drv;
extern struct LCM_DRIVER otm1911a_fhdp_dsi_vdo_truly_rt5081_hdp_lcm_drv;
extern struct LCM_DRIVER hx83102p_wxga_vdo_incell_boe_lcm_drv;
extern struct LCM_DRIVER otm1911a_fhdp_dsi_vdo_truly_rt4801_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_120hz_shenchao_6382_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_auo_cphy_90hz_jdi_lcm_drv;
extern struct LCM_DRIVER nt36672c_fhdp_dsi_vdo_dsc_txd_boe_lcm_drv;
extern struct LCM_DRIVER kd070fhfid015_dsi_1200x1920_lcm_drv;
#ifdef BUILD_LK
extern void mdelay(unsigned long msec);
#endif
#endif
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35521_hd_dsi_vdo_truly_nt50358.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,856 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
#include <linux/string.h>
#include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#else
/*#include <mach/mt_pm_ldo.h>*/
#ifdef CONFIG_MTK_LEGACY
#include <mach/mt_gpio.h>
#endif
#endif
#ifdef CONFIG_MTK_LEGACY
#include <cust_gpio_usage.h>
#endif
#ifndef CONFIG_FPGA_EARLY_PORTING
#if defined(CONFIG_MTK_LEGACY)
#include <cust_i2c.h>
#endif
#endif
#ifdef BUILD_LK
#define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
#define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
#define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_NT35521 (0xf5)
static const unsigned int BL_MIN_LEVEL = 20;
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) \
lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define set_gpio_lcd_enp(cmd) \
lcm_util.set_gpio_lcd_enp_bias(cmd)
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
/* #include <linux/jiffies.h> */
/* #include <linux/delay.h> */
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#ifndef CONFIG_FPGA_EARLY_PORTING
#define I2C_I2C_LCD_BIAS_CHANNEL 0
#define TPS_I2C_BUSNUM I2C_I2C_LCD_BIAS_CHANNEL /* for I2C channel 0 */
#define I2C_ID_NAME "tps65132"
#define TPS_ADDR 0x3E
#if defined(CONFIG_MTK_LEGACY)
static struct i2c_board_info tps65132_board_info __initdata = { I2C_BOARD_INFO(I2C_ID_NAME, TPS_ADDR) };
#endif
#if !defined(CONFIG_MTK_LEGACY)
static const struct of_device_id lcm_of_match[] = {
{.compatible = "mediatek,I2C_LCD_BIAS"},
{},
};
#endif
/*static struct i2c_client *tps65132_i2c_client;*/
struct i2c_client *tps65132_i2c_client;
/*****************************************************************************
* Function Prototype
*****************************************************************************/
static int tps65132_probe(struct i2c_client *client, const struct i2c_device_id *id);
static int tps65132_remove(struct i2c_client *client);
/*****************************************************************************
* Data Structure
*****************************************************************************/
struct tps65132_dev {
struct i2c_client *client;
};
static const struct i2c_device_id tps65132_id[] = {
{I2C_ID_NAME, 0},
{}
};
/* #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
/* static struct i2c_client_address_data addr_data = { .forces = forces,}; */
/* #endif */
static struct i2c_driver tps65132_iic_driver = {
.id_table = tps65132_id,
.probe = tps65132_probe,
.remove = tps65132_remove,
/* .detect = mt6605_detect, */
.driver = {
.owner = THIS_MODULE,
.name = "tps65132",
#if !defined(CONFIG_MTK_LEGACY)
.of_match_table = lcm_of_match,
#endif
},
};
static int tps65132_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
LCM_LOGI("tps65132_iic_probe\n");
LCM_LOGI("TPS: info==>name=%s addr=0x%x\n", client->name, client->addr);
tps65132_i2c_client = client;
return 0;
}
static int tps65132_remove(struct i2c_client *client)
{
LCM_LOGI("%s\n", __func__);
tps65132_i2c_client = NULL;
i2c_unregister_device(client);
return 0;
}
/*static int tps65132_write_bytes(unsigned char addr, unsigned char value)*/
#if !defined(CONFIG_ARCH_MT6797)
int tps65132_write_bytes(unsigned char addr, unsigned char value)
{
int ret = 0;
struct i2c_client *client = tps65132_i2c_client;
char write_data[2] = { 0 };
write_data[0] = addr;
write_data[1] = value;
ret = i2c_master_send(client, write_data, 2);
if (ret < 0)
LCM_LOGI("tps65132 write data fail !!\n");
return ret;
}
#endif
static int __init tps65132_iic_init(void)
{
LCM_LOGI("%s\n", __func__);
#if defined(CONFIG_MTK_LEGACY)
i2c_register_board_info(TPS_I2C_BUSNUM, &tps65132_board_info, 1);
#endif
LCM_LOGI("tps65132_iic_init2\n");
i2c_add_driver(&tps65132_iic_driver);
LCM_LOGI("%s success\n", __func__);
return 0;
}
static void __exit tps65132_iic_exit(void)
{
LCM_LOGI("%s\n", __func__);
i2c_del_driver(&tps65132_iic_driver);
}
module_init(tps65132_iic_init);
module_exit(tps65132_iic_exit);
MODULE_AUTHOR("Mike Liu");
MODULE_DESCRIPTION("MTK TPS65132 I2C Driver");
MODULE_LICENSE("GPL");
#endif
#endif
/* static unsigned char lcd_id_pins_value = 0xFF; */
static const unsigned char LCD_MODULE_ID = 0x01;
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
#define LCM_DENSITY (320)
#define LCM_PHYSICAL_WIDTH (68040)
#define LCM_PHYSICAL_HEIGHT (120960)
#ifndef CONFIG_FPGA_EARLY_PORTING
#define GPIO_65132_EN GPIO_LCD_BIAS_ENP_PIN
#endif
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
static struct LCM_DSI_MODE_SWITCH_CMD lcm_switch_mode_cmd;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0x4F, 1, {0x01} },
{REGFLAG_DELAY, 120, {} }
};
static struct LCM_setting_table init_setting[] = {
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x00} },/*page 0*/
{0x6F, 1, {0x02} },
{0xB8, 1, {0x0C} },
{0xB1, 2, {0x68, 0x27} },
{0xBD, 5, {0x01, 0xA3, 0x20, 0x10, 0x01} },
{0xBB, 2, {0x74, 0x74} },
{0xBC, 2, {0x00, 0x00} },
{0xB6, 1, {0x01} },
{0xC8, 1, {0x83} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x01} },/*page 1*/
{0xB0, 2, {0x0F, 0x0F} },
{0xB1, 2, {0x0F, 0x0F } },
{0xCE, 1, {0x66} },
{0xC0, 1, {0x0C} },
{0xB5, 2, {0x04, 0x04} },
{0xBE, 1, {0x2F} }, /*0x3d -1.07*/
{0xB3, 2, {0x2B, 0x2B} },
{0xB4, 2, {0x0F, 0x0F} },
{0xB9, 2, {0x46, 0x46} },
{0xBA, 2, {0x16, 0x16} },
{0xBC, 2, {0xA2, 0x00} },
{0xBD, 2, {0xA2, 0x00} },
{0xCA, 1, {0x00} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x02} },/*page2*/
{0xED, 1, {0x01} },
{0xEF, 4, {0x11, 0x0D, 0x16, 0x19} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x06} },/*page6*/
{0xB0, 2, {0x2E, 0x09} },
{0xB1, 2, {0x0B, 0x23} },
{0xB2, 2, {0x1D, 0x25} },
{0xB3, 2, {0x1F, 0x11} },
{0xB4, 2, {0x2E, 0x2E} },
{0xB5, 2, {0x2E, 0x17} },
{0xB6, 2, {0x13, 0x19} },
{0xB7, 2, {0x2E, 0x2E} },
{0xB8, 2, {0x01, 0x03} },
{0xB9, 2, {0x2E, 0x2E} },
{0xBA, 2, {0x2E, 0x2E} },
{0xBB, 2, {0x02, 0x00} },
{0xBC, 2, {0x2E, 0x2E} },
{0xBD, 2, {0x18, 0x12} },
{0xBE, 2, {0x16, 0x2E} },
{0xBF, 2, {0x2E, 0x2E} },
{0xC0, 2, {0x10, 0x1E} },
{0xC1, 2, {0x24, 0x1C} },
{0xC2, 2, {0x22, 0x0A} },
{0xC3, 2, {0x08, 0x2E} },
{0xE5, 2, {0x2E, 0x2E} },
{0xC4, 2, {0x2E, 0x02} },
{0xC5, 2, {0x00, 0x24} },
{0xC6, 2, {0x1E, 0x22} },
{0xC7, 2, {0x1C, 0x18} },
{0xC8, 2, {0x2E, 0x2E} },
{0xC9, 2, {0x2E, 0x12} },
{0xCA, 2, {0x16, 0x10} },
{0xCB, 2, {0x2E, 0x2E} },
{0xCC, 2, {0x0A, 0x08} },
{0xCD, 2, {0x2E, 0x2E} },
{0xCE, 2, {0x2E, 0x2E} },
{0xCF, 2, {0x09, 0x0B} },
{0xD0, 2, {0x2E, 0x2E} },
{0xD1, 2, {0x11, 0x17} },
{0xD2, 2, {0x13, 0x2E} },
{0xD3, 2, {0x2E, 0x2E} },
{0xD4, 2, {0x19, 0x1D} },
{0xD5, 2, {0x23, 0x1F} },
{0xD6, 2, {0x25, 0x01} },
{0xD7, 2, {0x03, 0x2E} },
{0xE6, 2, {0x2E, 0x2E } },
{0xD8, 5, {0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD9, 5, {0x00, 0x00, 0x00, 0x00, 0x00} },
{0xE7, 1, {0x00} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x05} },/*page5*/
{0xB0, 2, {0x17, 0x06 } },
{0xB1, 2, {0x17, 0x06} },
{0xB2, 2, {0x17, 0x06} },
{0xB3, 2, {0x17, 0x06} },
{0xB4, 2, {0x17, 0x06} },
{0xB5, 2, {0x17, 0x06} },
{0xB6, 2, {0x17, 0x06} },
{0xB7, 2, {0x17, 0x06} },
{0xB8, 1, {0x00} },
{0xB9, 2, {0x00, 0x03 } },
{0xBA, 2, {0x00, 0x03} },
{0xBB, 2, {0x00, 0x00} },
{0xBC, 2, {0x00, 0x01} },
{0xBD, 5, {0x0F, 0x03, 0x03, 0x00, 0x03} },
{0xC0, 1, {0x07} },
{0xC1, 1, {0x05} },
{0xC4, 1, {0x82} },
{0xC5, 1, {0x80} },
{0xC8, 2, {0x03, 0x20} },
{0xC9, 2, {0x01, 0x21} },
{0xCA, 2, {0x03, 0x20} },
{0xCB, 2, {0x07, 0x20} },
{0xD1, 11, {0x03, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD2, 11, {0x03, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD3, 11, {0x03, 0x05, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD4, 11, {0x03, 0x05, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xE5, 1, {0x06} },
{0xE6, 1, {0x06} },
{0xE7, 1, {0x06} },
{0xE8, 1, {0x06} },
{0xE9, 1, {0x0A} },
{0xEA, 1, {0x06} },
{0xEB, 1, {0x06} },
{0xEC, 1, {0x06} },
{0xED, 1, {0x30} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x03} },
{0xB0, 2, {0x00, 0x00} },
{0xB1, 2, {0x00, 0x00} },
{0xB2, 5, {0x04, 0x00, 0x40, 0x01, 0x58} },
{0xB3, 5, {0x04, 0x00, 0x40, 0x01, 0x58} },
{0xB6, 5, {0x04, 0x00, 0x46, 0x01, 0x68} },
{0xB7, 5, {0x04, 0x00, 0x46, 0x01, 0x68} },
{0xBA, 5, {0x44, 0x00, 0x46, 0x01, 0x55} },
{0xBB, 5, {0x44, 0x00, 0x46, 0x01, 0x55} },
{0xBC, 5, {0x53, 0x00, 0x15, 0x00, 0x48} },
{0xBD, 5, {0x53, 0x00, 0x15, 0x00, 0x48} },
{0x35, 1, {0x00} },
{0x44, 2, {0x01, 0xf4} },
{0x11, 0, { } },
{0x29, 0, { } },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x04} },/*page4*/
};
#if 0
static struct LCM_setting_table lcm_set_window[] = {
{0x2A, 4, {0x00, 0x00, (FRAME_WIDTH >> 8), (FRAME_WIDTH & 0xFF)} },
{0x2B, 4, {0x00, 0x00, (FRAME_HEIGHT >> 8), (FRAME_HEIGHT & 0xFF)} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
#endif
#if 0
static struct LCM_setting_table lcm_sleep_out_setting[] = {
/* Sleep Out */
{0x11, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
/* Display ON */
{0x29, 1, {0x00} },
{REGFLAG_DELAY, 20, {} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
/* Display off sequence */
{0x28, 1, {0x00} },
{REGFLAG_DELAY, 20, {} },
/* Sleep Mode On */
{0x10, 1, {0x00} },
{REGFLAG_DELAY, 120, {} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
#endif
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH/1000;
params->physical_height = LCM_PHYSICAL_HEIGHT/1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
#endif
LCM_LOGI("%s lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 6;
params->dsi.vertical_frontporch = 50;
params->dsi.vertical_frontporch_for_low_power = 470;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 50;
params->dsi.horizontal_backporch = 50;
params->dsi.horizontal_frontporch = 50;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.ssc_disable = 0;
#ifndef CONFIG_FPGA_EARLY_PORTING
#if (LCM_DSI_CMD_MODE)
params->dsi.PLL_CLOCK = 220; /* this value must be in MTK suggested table */
#else
params->dsi.PLL_CLOCK = 224; /* this value must be in MTK suggested table */
#endif
params->dsi.PLL_CK_CMD = 220;
params->dsi.PLL_CK_VDO = 224;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
}
#ifdef BUILD_LK
#ifndef CONFIG_FPGA_EARLY_PORTING
#define TPS65132_SLAVE_ADDR_WRITE 0x7C
static struct mt_i2c_t TPS65132_i2c;
static int TPS65132_write_byte(kal_uint8 addr, kal_uint8 value)
{
kal_uint32 ret_code = I2C_OK;
kal_uint8 write_data[2];
kal_uint16 len;
write_data[0] = addr;
write_data[1] = value;
TPS65132_i2c.id = I2C_I2C_LCD_BIAS_CHANNEL; /* I2C2; */
/* Since i2c will left shift 1 bit, we need to set FAN5405 I2C address to >>1 */
TPS65132_i2c.addr = (TPS65132_SLAVE_ADDR_WRITE >> 1);
TPS65132_i2c.mode = ST_MODE;
TPS65132_i2c.speed = 100;
len = 2;
ret_code = i2c_write(&TPS65132_i2c, write_data, len);
/* printf("%s: i2c_write: ret_code: %d\n", __func__, ret_code); */
return ret_code;
}
#else
/* extern int mt8193_i2c_write(u16 addr, u32 data); */
/* extern int mt8193_i2c_read(u16 addr, u32 *data); */
/* #define TPS65132_write_byte(add, data) mt8193_i2c_write(add, data) */
/* #define TPS65132_read_byte(add) mt8193_i2c_read(add) */
#endif
#endif
static void lcm_init_power(void)
{
}
static void lcm_suspend_power(void)
{
}
static void lcm_resume_power(void)
{
}
static void lcm_init(void)
{
unsigned char cmd = 0x0;
unsigned char data = 0xFF;
#ifndef CONFIG_FPGA_EARLY_PORTING
int ret = 0;
#endif
cmd = 0x00;
data = 0x0E;
SET_RESET_PIN(0);
#ifndef CONFIG_FPGA_EARLY_PORTING
#ifdef CONFIG_MTK_LEGACY
mt_set_gpio_mode(GPIO_65132_EN, GPIO_MODE_00);
mt_set_gpio_dir(GPIO_65132_EN, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO_65132_EN, GPIO_OUT_ONE);
#else
set_gpio_lcd_enp(1);
#endif
MDELAY(5);
#ifdef BUILD_LK
ret = TPS65132_write_byte(cmd, data);
#else
#if !defined(CONFIG_ARCH_MT6797)
ret = tps65132_write_bytes(cmd, data);
#endif
#endif
if (ret < 0)
LCM_LOGI("nt35521----tps6132----cmd=%0x--i2c write error----\n", cmd);
else
LCM_LOGI("nt35521----tps6132----cmd=%0x--i2c write success----\n", cmd);
cmd = 0x01;
data = 0x0E;
#ifdef BUILD_LK
ret = TPS65132_write_byte(cmd, data);
#else
#if !defined(CONFIG_ARCH_MT6797)
ret = tps65132_write_bytes(cmd, data);
#endif
#endif
if (ret < 0)
LCM_LOGI("nt35521----tps6132----cmd=%0x--i2c write error----\n", cmd);
else
LCM_LOGI("nt35521----tps6132----cmd=%0x--i2c write success----\n", cmd);
#endif
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
if (lcm_dsi_mode == CMD_MODE) {
LCM_LOGI("nt35521----not support ----lcm mode\n");
} else {
push_table(NULL, init_setting, sizeof(init_setting) / sizeof(struct LCM_setting_table), 1);
LCM_LOGI("nt35521----tps6132----lcm mode = vdo mode :%d----\n", lcm_dsi_mode);
}
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting, sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table), 1);
MDELAY(10);
#ifndef CONFIG_FPGA_EARLY_PORTING
#ifdef CONFIG_MTK_LEGACY
mt_set_gpio_mode(GPIO_65132_EN, GPIO_MODE_00);
mt_set_gpio_dir(GPIO_65132_EN, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO_65132_EN, GPIO_OUT_ZERO);
#else
set_gpio_lcd_enp(0);
#endif
#endif
/*SET_RESET_PIN(0);*/
}
static void lcm_resume(void)
{
lcm_init();
}
static void lcm_update(unsigned int x, unsigned int y, unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0, version_id = 0;
unsigned char buffer[2];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
array[0] = 0x00023700; /* read id return two byte,version and id */
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xF4, buffer, 2);
id = buffer[0]; /* we only need ID */
read_reg_v2(0xDB, buffer, 1);
version_id = buffer[0];
LCM_LOGI("%s,nt35521_id=0x%08x,version_id=0x%x\n", __func__, id, version_id);
if (id == LCM_ID_NT35521 && version_id == 0x80)
return 1;
else
return 0;
}
/* return TRUE: need recovery */
/* return FALSE: No need recovery */
static unsigned int lcm_esd_check(void)
{
#ifndef BUILD_LK
char buffer[3];
int array[4];
array[0] = 0x00013700;
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0x53, buffer, 1);
if (buffer[0] != 0x24) {
LCM_LOGI("[LCM ERROR] [0x53]=0x%02x\n", buffer[0]);
return TRUE;
}
LCM_LOGI("[LCM NORMAL] [0x53]=0x%02x\n", buffer[0]);
return FALSE;
#else
return FALSE;
#endif
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
#ifndef BUILD_LK
unsigned int ret = 0;
unsigned int x0 = FRAME_WIDTH / 4;
unsigned int x1 = FRAME_WIDTH * 3 / 4;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned int data_array[3];
unsigned char read_buf[4];
LCM_LOGI("ATA check size = 0x%x,0x%x,0x%x,0x%x\n", x0_MSB, x0_LSB, x1_MSB, x1_LSB);
data_array[0] = 0x0005390A; /* HS packet */
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00043700; /* read id return two byte,version and id */
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x2A, read_buf, 4);
if ((read_buf[0] == x0_MSB) && (read_buf[1] == x0_LSB)
&& (read_buf[2] == x1_MSB) && (read_buf[3] == x1_LSB))
ret = 1;
else
ret = 0;
x0 = 0;
x1 = FRAME_WIDTH - 1;
x0_MSB = ((x0 >> 8) & 0xFF);
x0_LSB = (x0 & 0xFF);
x1_MSB = ((x1 >> 8) & 0xFF);
x1_LSB = (x1 & 0xFF);
data_array[0] = 0x0005390A; /* HS packet */
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
return ret;
#else
return 0;
#endif
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,nt35521 backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level, sizeof(bl_level) / sizeof(struct LCM_setting_table), 1);
}
static void *lcm_switch_mode(int mode)
{
#ifndef BUILD_LK
/* customization: 1. V2C config 2 values, C2V config 1 value; 2. config mode control register */
if (mode == 0) { /* V2C */
lcm_switch_mode_cmd.mode = CMD_MODE;
lcm_switch_mode_cmd.addr = 0xBB; /* mode control addr */
lcm_switch_mode_cmd.val[0] = 0x13; /* enabel GRAM firstly, ensure writing one frame to GRAM */
lcm_switch_mode_cmd.val[1] = 0x10; /* disable video mode secondly */
} else { /* C2V */
lcm_switch_mode_cmd.mode = SYNC_PULSE_VDO_MODE;
lcm_switch_mode_cmd.addr = 0xBB;
lcm_switch_mode_cmd.val[0] = 0x03; /* disable GRAM and enable video mode */
}
return (void *)(&lcm_switch_mode_cmd);
#else
return NULL;
#endif
}
struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_nt50358_lcm_drv = {
.name = "nt35521_hd_dsi_vdo_truly_nt50358_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.compare_id = lcm_compare_id,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.esd_check = lcm_esd_check,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
.switch_mode = lcm_switch_mode,
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35521_hd_dsi_vdo_truly_rt5081.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,571 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#define LOG_TAG "LCM"
#ifndef BUILD_LK
#include <linux/string.h>
#include <linux/kernel.h>
#endif
#include "lcm_drv.h"
#ifdef BUILD_LK
#include <platform/upmu_common.h>
#include <platform/mt_gpio.h>
#include <platform/mt_i2c.h>
#include <platform/mt_pmic.h>
#include <string.h>
#elif defined(BUILD_UBOOT)
#include <asm/arch/mt_gpio.h>
#else
#include "disp_dts_gpio.h"
#endif
#ifdef BUILD_LK
#define LCM_LOGI(string, args...) dprintf(0, "[LK/"LOG_TAG"]"string, ##args)
#define LCM_LOGD(string, args...) dprintf(1, "[LK/"LOG_TAG"]"string, ##args)
#else
#define LCM_LOGI(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
#define LCM_ID_NT35521 (0xf5)
static const unsigned int BL_MIN_LEVEL = 20;
static struct LCM_UTIL_FUNCS lcm_util;
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define MDELAY(n) (lcm_util.mdelay(n))
#define UDELAY(n) (lcm_util.udelay(n))
#define dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V22(cmdq, cmd, count, ppara, force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) \
lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
/* #include <linux/jiffies.h> */
/* #include <linux/delay.h> */
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#endif
/* static unsigned char lcd_id_pins_value = 0xFF; */
static const unsigned char LCD_MODULE_ID = 0x01;
#define LCM_DSI_CMD_MODE 0
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
#define LCM_DENSITY (320)
#define LCM_PHYSICAL_WIDTH (0)
#define LCM_PHYSICAL_HEIGHT (0)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
static struct LCM_DSI_MODE_SWITCH_CMD lcm_switch_mode_cmd;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_suspend_setting[] = {
{0x28, 0, {} },
{0x10, 0, {} },
{REGFLAG_DELAY, 120, {} },
{0x4F, 1, {0x01} },
{REGFLAG_DELAY, 120, {} }
};
static struct LCM_setting_table init_setting[] = {
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x00} },/*page 0*/
{0x6F, 1, {0x02} },
{0xB8, 1, {0x0C} },
{0xB1, 2, {0x68, 0x27} },
{0xBD, 5, {0x01, 0xA3, 0x20, 0x10, 0x01} },
{0xBB, 2, {0x74, 0x74} },
{0xBC, 2, {0x00, 0x00} },
{0xB6, 1, {0x01} },
{0xC8, 1, {0x83} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x01} },/*page 1*/
{0xB0, 2, {0x0F, 0x0F} },
{0xB1, 2, {0x0F, 0x0F } },
{0xCE, 1, {0x66} },
{0xC0, 1, {0x0C} },
{0xB5, 2, {0x04, 0x04} },
{0xBE, 1, {0x2F} }, /*0x3d -1.07*/
{0xB3, 2, {0x2B, 0x2B} },
{0xB4, 2, {0x0F, 0x0F} },
{0xB9, 2, {0x46, 0x46} },
{0xBA, 2, {0x16, 0x16} },
{0xBC, 2, {0xA2, 0x00} },
{0xBD, 2, {0xA2, 0x00} },
{0xCA, 1, {0x00} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x02} },/*page2*/
{0xED, 1, {0x01} },
{0xEF, 4, {0x11, 0x0D, 0x16, 0x19} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x06} },/*page6*/
{0xB0, 2, {0x2E, 0x09} },
{0xB1, 2, {0x0B, 0x23} },
{0xB2, 2, {0x1D, 0x25} },
{0xB3, 2, {0x1F, 0x11} },
{0xB4, 2, {0x2E, 0x2E} },
{0xB5, 2, {0x2E, 0x17} },
{0xB6, 2, {0x13, 0x19} },
{0xB7, 2, {0x2E, 0x2E} },
{0xB8, 2, {0x01, 0x03} },
{0xB9, 2, {0x2E, 0x2E} },
{0xBA, 2, {0x2E, 0x2E} },
{0xBB, 2, {0x02, 0x00} },
{0xBC, 2, {0x2E, 0x2E} },
{0xBD, 2, {0x18, 0x12} },
{0xBE, 2, {0x16, 0x2E} },
{0xBF, 2, {0x2E, 0x2E} },
{0xC0, 2, {0x10, 0x1E} },
{0xC1, 2, {0x24, 0x1C} },
{0xC2, 2, {0x22, 0x0A} },
{0xC3, 2, {0x08, 0x2E} },
{0xE5, 2, {0x2E, 0x2E} },
{0xC4, 2, {0x2E, 0x02} },
{0xC5, 2, {0x00, 0x24} },
{0xC6, 2, {0x1E, 0x22} },
{0xC7, 2, {0x1C, 0x18} },
{0xC8, 2, {0x2E, 0x2E} },
{0xC9, 2, {0x2E, 0x12} },
{0xCA, 2, {0x16, 0x10} },
{0xCB, 2, {0x2E, 0x2E} },
{0xCC, 2, {0x0A, 0x08} },
{0xCD, 2, {0x2E, 0x2E} },
{0xCE, 2, {0x2E, 0x2E} },
{0xCF, 2, {0x09, 0x0B} },
{0xD0, 2, {0x2E, 0x2E} },
{0xD1, 2, {0x11, 0x17} },
{0xD2, 2, {0x13, 0x2E} },
{0xD3, 2, {0x2E, 0x2E} },
{0xD4, 2, {0x19, 0x1D} },
{0xD5, 2, {0x23, 0x1F} },
{0xD6, 2, {0x25, 0x01} },
{0xD7, 2, {0x03, 0x2E} },
{0xE6, 2, {0x2E, 0x2E } },
{0xD8, 5, {0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD9, 5, {0x00, 0x00, 0x00, 0x00, 0x00} },
{0xE7, 1, {0x00} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x05} },/*page5*/
{0xB0, 2, {0x17, 0x06 } },
{0xB1, 2, {0x17, 0x06} },
{0xB2, 2, {0x17, 0x06} },
{0xB3, 2, {0x17, 0x06} },
{0xB4, 2, {0x17, 0x06} },
{0xB5, 2, {0x17, 0x06} },
{0xB6, 2, {0x17, 0x06} },
{0xB7, 2, {0x17, 0x06} },
{0xB8, 1, {0x00} },
{0xB9, 2, {0x00, 0x03 } },
{0xBA, 2, {0x00, 0x03} },
{0xBB, 2, {0x00, 0x00} },
{0xBC, 2, {0x00, 0x01} },
{0xBD, 5, {0x0F, 0x03, 0x03, 0x00, 0x03} },
{0xC0, 1, {0x07} },
{0xC1, 1, {0x05} },
{0xC4, 1, {0x82} },
{0xC5, 1, {0x80} },
{0xC8, 2, {0x03, 0x20} },
{0xC9, 2, {0x01, 0x21} },
{0xCA, 2, {0x03, 0x20} },
{0xCB, 2, {0x07, 0x20} },
{0xD1, 11,
{0x03, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD2, 11,
{0x03, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD3, 11,
{0x03, 0x05, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xD4, 11,
{0x03, 0x05, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
{0xE5, 1, {0x06} },
{0xE6, 1, {0x06} },
{0xE7, 1, {0x06} },
{0xE8, 1, {0x06} },
{0xE9, 1, {0x0A} },
{0xEA, 1, {0x06} },
{0xEB, 1, {0x06} },
{0xEC, 1, {0x06} },
{0xED, 1, {0x30} },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x03} },
{0xB0, 2, {0x00, 0x00} },
{0xB1, 2, {0x00, 0x00} },
{0xB2, 5, {0x04, 0x00, 0x40, 0x01, 0x58} },
{0xB3, 5, {0x04, 0x00, 0x40, 0x01, 0x58} },
{0xB6, 5, {0x04, 0x00, 0x46, 0x01, 0x68} },
{0xB7, 5, {0x04, 0x00, 0x46, 0x01, 0x68} },
{0xBA, 5, {0x44, 0x00, 0x46, 0x01, 0x55} },
{0xBB, 5, {0x44, 0x00, 0x46, 0x01, 0x55} },
{0xBC, 5, {0x53, 0x00, 0x15, 0x00, 0x48} },
{0xBD, 5, {0x53, 0x00, 0x15, 0x00, 0x48} },
{0x35, 1, {0x00} },
{0x44, 2, {0x01, 0xf4} },
{0x11, 0, { } },
{0x29, 0, { } },
{0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x04} },/*page4*/
};
static struct LCM_setting_table bl_level[] = {
{0x51, 1, {0xFF} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void push_table(void *cmdq, struct LCM_setting_table *table,
unsigned int count, unsigned char force_update)
{
unsigned int i;
unsigned int cmd;
for (i = 0; i < count; i++) {
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
if (table[i].count <= 10)
MDELAY(table[i].count);
else
MDELAY(table[i].count);
break;
case REGFLAG_UDELAY:
UDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V22(cmdq, cmd, table[i].count,
table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = LCM_PHYSICAL_WIDTH/1000;
params->physical_height = LCM_PHYSICAL_HEIGHT/1000;
params->physical_width_um = LCM_PHYSICAL_WIDTH;
params->physical_height_um = LCM_PHYSICAL_HEIGHT;
params->density = LCM_DENSITY;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
params->dsi.switch_mode = SYNC_PULSE_VDO_MODE;
lcm_dsi_mode = CMD_MODE;
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
params->dsi.switch_mode = CMD_MODE;
lcm_dsi_mode = SYNC_PULSE_VDO_MODE;
#endif
LCM_LOGI("%s lcm_dsi_mode %d\n", __func__, lcm_dsi_mode);
params->dsi.switch_mode_enable = 0;
/* DSI */
/* Command mode setting */
params->dsi.LANE_NUM = LCM_FOUR_LANE;
/* The following defined the fomat for data coming from LCD engine. */
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
/* Highly depends on LCD driver capability. */
params->dsi.packet_size = 256;
/* video mode timing */
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 6;
params->dsi.vertical_frontporch = 85;
params->dsi.vertical_frontporch_for_low_power = 540;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 50;
params->dsi.horizontal_backporch = 50;
params->dsi.horizontal_frontporch = 50;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.ssc_disable = 1;
params->dsi.ssc_range = 5;
#ifndef CONFIG_FPGA_EARLY_PORTING
#if (LCM_DSI_CMD_MODE)
params->dsi.PLL_CLOCK = 220;
#else
params->dsi.PLL_CLOCK = 224;
#endif
params->dsi.PLL_CK_CMD = 220;
params->dsi.PLL_CK_VDO = 224;
#else
params->dsi.pll_div1 = 0;
params->dsi.pll_div2 = 0;
params->dsi.fbk_div = 0x1;
#endif
params->dsi.CLK_HS_POST = 36;
params->dsi.clk_lp_per_line_enable = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
}
static void lcm_init_power(void)
{
display_bias_enable();
}
static void lcm_suspend_power(void)
{
display_bias_disable();
}
static void lcm_resume_power(void)
{
SET_RESET_PIN(0);
display_bias_enable();
}
static void lcm_init(void)
{
SET_RESET_PIN(0);
MDELAY(15);
SET_RESET_PIN(1);
MDELAY(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
if (lcm_dsi_mode == CMD_MODE) {
LCM_LOGI("nt35521----not support ----lcm mode\n");
} else {
push_table(NULL, init_setting,
sizeof(init_setting) / sizeof(struct LCM_setting_table), 1);
LCM_LOGI("nt35521-tps6132-lcm mode=vdo mode :%d\n",
lcm_dsi_mode);
}
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting,
sizeof(lcm_suspend_setting) / sizeof(struct LCM_setting_table), 1);
MDELAY(10);
/*SET_RESET_PIN(0);*/
}
static void lcm_resume(void)
{
lcm_init();
}
static void lcm_update(unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
unsigned char x0_LSB = (x0 & 0xFF);
unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
unsigned char x1_LSB = (x1 & 0xFF);
unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
unsigned char y0_LSB = (y0 & 0xFF);
unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
unsigned char y1_LSB = (y1 & 0xFF);
unsigned int data_array[16];
data_array[0] = 0x00053902;
data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
data_array[2] = (x1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x00053902;
data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
data_array[2] = (y1_LSB);
dsi_set_cmdq(data_array, 3, 1);
data_array[0] = 0x002c3909;
dsi_set_cmdq(data_array, 1, 0);
}
static unsigned int lcm_compare_id(void)
{
unsigned int id = 0, version_id = 0;
unsigned char buffer[2];
unsigned int array[16];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(1);
SET_RESET_PIN(1);
MDELAY(20);
/* read id return two byte,version and id */
array[0] = 0x00023700;
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xF4, buffer, 2);
id = buffer[0]; /* we only need ID */
read_reg_v2(0xDB, buffer, 1);
version_id = buffer[0];
LCM_LOGI("%s,nt35521_id=0x%08x,version_id=0x%x\n",
__func__, id, version_id);
if (id == LCM_ID_NT35521 && version_id == 0x80)
return 1;
else
return 0;
}
/* return TRUE: need recovery */
/* return FALSE: No need recovery */
static unsigned int lcm_esd_check(void)
{
#ifndef BUILD_LK
char buffer[3];
int array[4];
array[0] = 0x00013700;
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0x53, buffer, 1);
if (buffer[0] != 0x24) {
LCM_LOGI("[LCM ERROR] [0x53]=0x%02x\n", buffer[0]);
return TRUE;
}
LCM_LOGI("[LCM NORMAL] [0x53]=0x%02x\n", buffer[0]);
return FALSE;
#else
return FALSE;
#endif
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
/*skip ata check*/
return 1;
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
LCM_LOGI("%s,nt35521 backlight: level = %d\n", __func__, level);
bl_level[0].para_list[0] = level;
push_table(handle, bl_level,
sizeof(bl_level) / sizeof(struct LCM_setting_table), 1);
}
static void *lcm_switch_mode(int mode)
{
#ifndef BUILD_LK
/* customization: 1. V2C config 2 values, C2V config 1 value; */
/*2. config mode control register */
if (mode == 0) { /* V2C */
lcm_switch_mode_cmd.mode = CMD_MODE;
lcm_switch_mode_cmd.addr = 0xBB; /* mode control addr */
/* enabel GRAM firstly, ensure writing one frame to GRAM */
lcm_switch_mode_cmd.val[0] = 0x13;
/* disable video mode secondly */
lcm_switch_mode_cmd.val[1] = 0x10;
} else { /* C2V */
lcm_switch_mode_cmd.mode = SYNC_PULSE_VDO_MODE;
lcm_switch_mode_cmd.addr = 0xBB;
/* disable GRAM and enable video mode */
lcm_switch_mode_cmd.val[0] = 0x03;
}
return (void *)(&lcm_switch_mode_cmd);
#else
return NULL;
#endif
}
struct LCM_DRIVER nt35521_hd_dsi_vdo_truly_rt5081_lcm_drv = {
.name = "nt35521_hd_dsi_vdo_truly_rt5081_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.compare_id = lcm_compare_id,
.init_power = lcm_init_power,
.resume_power = lcm_resume_power,
.suspend_power = lcm_suspend_power,
.esd_check = lcm_esd_check,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.ata_check = lcm_ata_check,
.update = lcm_update,
.switch_mode = lcm_switch_mode,
};
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35532_fhd_dsi_vdo_sharp.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,399 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef BUILD_LK
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/irq.h>
#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/string.h>
#include <linux/wait.h>
#include <linux/gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of_gpio.h>
#include <asm-generic/gpio.h>
#include <linux/mm.h>
#include <linux/mm_types.h>
#include <linux/types.h>
#include <linux/vmalloc.h>
#ifdef CONFIG_OF
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
#include <linux/clk.h>
#endif
#endif
#include "lcm_drv.h"
#ifndef BUILD_LK
static unsigned int GPIO_LCD_RST; /* GPIO45: panel reset pin for control */
static unsigned int GPIO_LCD_PWR_EN; /* GPIO158: panel 1.8V for control */
static unsigned int GPIO_LCD_PWR2_EN; /* GPIO159: panel 2.8V for control */
static unsigned int GPIO_LCD_PWR; /* GPIO166: panel power enable */
static void lcm_request_gpio_control(struct device *dev)
{
GPIO_LCD_RST = of_get_named_gpio(dev->of_node, "gpio_lcd_rst", 0);
gpio_request(GPIO_LCD_RST, "GPIO_LCD_RST");
pr_notice("[KE/LCM] GPIO_LCD_RST = 0x%x\n", GPIO_LCD_RST);
GPIO_LCD_PWR = of_get_named_gpio(dev->of_node, "gpio_lcd_pwr", 0);
gpio_request(GPIO_LCD_PWR, "GPIO_LCD_PWR");
pr_notice("[KE/LCM] GPIO_LCD_PWR = 0x%x\n", GPIO_LCD_PWR);
GPIO_LCD_PWR_EN = of_get_named_gpio(dev->of_node, "gpio_lcd_pwr_en", 0);
gpio_request(GPIO_LCD_PWR_EN, "GPIO_LCD_PWR_EN");
pr_notice("[KE/LCM] GPIO_LCD_PWR_EN = 0x%x\n", GPIO_LCD_PWR_EN);
GPIO_LCD_PWR2_EN = of_get_named_gpio(dev->of_node, "gpio_lcd_pwr2_en",
0);
gpio_request(GPIO_LCD_PWR2_EN, "GPIO_LCD_PWR2_EN");
pr_notice("[KE/LCM] GPIO_LCD_PWR2_EN = 0x%x\n", GPIO_LCD_PWR2_EN);
}
static int lcm_driver_probe(struct device *dev, void const *data)
{
pr_notice("[Kernel/LCM] %s\n", __func__);
lcm_request_gpio_control(dev);
return 0;
}
static const struct of_device_id lcm_platform_of_match[] = {
{
.compatible = "sharp,nt35532",
.data = 0,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, platform_of_match);
static int lcm_platform_probe(struct platform_device *pdev)
{
const struct of_device_id *id;
id = of_match_node(lcm_platform_of_match, pdev->dev.of_node);
if (!id)
return -ENODEV;
return lcm_driver_probe(&pdev->dev, id->data);
}
static struct platform_driver lcm_driver = {
.probe = lcm_platform_probe,
.driver = {
.name = "nt35532_fhd_dsi_vdo_sharp",
.owner = THIS_MODULE,
.of_match_table = lcm_platform_of_match,
},
};
static int __init lcm_init(void)
{
if (platform_driver_register(&lcm_driver)) {
pr_notice("LCM: failed to register this driver!\n");
return -ENODEV;
}
return 0;
}
static void __exit lcm_exit(void)
{
platform_driver_unregister(&lcm_driver);
}
late_initcall(lcm_init);
module_exit(lcm_exit);
MODULE_AUTHOR("mediatek");
MODULE_DESCRIPTION("LCM display subsystem driver");
MODULE_LICENSE("GPL");
#endif
/* ----------------------------------------------------------------- */
/* Local Constants */
/* ----------------------------------------------------------------- */
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (1920)
#define GPIO_OUT_ONE 1
#define GPIO_OUT_ZERO 0
#define REGFLAG_DELAY 0xFE
#define REGFLAG_END_OF_TABLE 0xFF
#define LCM_DSI_CMD_MODE 0
#define LCM_ID_NT35532 0x80
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* ----------------------------------------------------------------- */
/* Local Variables */
/* ----------------------------------------------------------------- */
static struct LCM_UTIL_FUNCS lcm_util = {0};
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* ----------------------------------------------------------------- */
/* Local Functions */
/* ----------------------------------------------------------------- */
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) \
lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) \
lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) \
lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg lcm_util.dsi_read_reg()
#define read_reg_v2(cmd, buffer, buffer_size) \
lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#ifdef BUILD_LK
#define LCM_LOGI(string, args...) dprintf(CRITICAL, "[LK/"LOG_TAG"]"string, \
##args)
#define LCM_LOGD(string, args...) dprintf(INFO, "[LK/"LOG_TAG"]"string, ##args)
#else
#define LCM_LOGI(fmt, args...) pr_notice("[KERNEL/"LOG_TAG"]"fmt, ##args)
#define LCM_LOGD(fmt, args...) pr_debug("[KERNEL/"LOG_TAG"]"fmt, ##args)
#endif
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[64];
};
static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
{
#ifdef BUILD_LK
mt_set_gpio_mode(GPIO, GPIO_MODE_00);
mt_set_gpio_dir(GPIO, GPIO_DIR_OUT);
mt_set_gpio_out(GPIO, output);
#else
gpio_set_value(GPIO, output);
#endif
}
static struct LCM_setting_table lcm_initialization_setting[] = {
/* Select page command*/
{0xFF, 1, { 0x00 } },
/* Non-reload command */
{0xFB, 1, { 0x01 } },
{REGFLAG_DELAY, 23, { } },
/* Select page command*/
{0xFF, 1, { 0x00 } },
{0xD3, 1, { 0x08 } },
{0xD4, 1, { 0x0E } },
/* Sleep out*/
{0x11, 0, { } },
{REGFLAG_DELAY, 120, { } },
/* Display on */
{0x29, 0, { } },
{REGFLAG_DELAY, 20, { } },
/* Set LED light */
{0x51, 1, { 0xFF } },
/* Set LED on */
{0x53, 1, { 0x2C } },
/* Set CABC on */
{0x55, 1, { 0x03 } },
};
static struct LCM_setting_table lcm_suspend_setting[] = {
/* Turn off backlight */
{0x53, 1, { 0x00 } },
{REGFLAG_DELAY, 1, { } },
/* Display off */
{0x28, 0, { } },
{REGFLAG_DELAY, 20, { } },
/* Sleep in */
{0x10, 0, { } },
{REGFLAG_DELAY, 120, { } },
/* Select page command */
{0xFF, 1, { 0x00 } },
{REGFLAG_DELAY, 1, { } },
};
static void push_table(struct LCM_setting_table *table, unsigned int count,
unsigned char force_update)
{
unsigned int i;
for (i = 0; i < count; i++) {
unsigned int cmd;
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY:
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE:
break;
default:
dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list,
force_update);
}
}
}
/* ----------------------------------------------------------------- */
/* LCM Driver Implementations */
/* ----------------------------------------------------------------- */
static void lcm_set_util_funcs(const struct LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(struct LCM_UTIL_FUNCS));
}
static void lcm_get_params(struct LCM_PARAMS *params)
{
memset(params, 0, sizeof(struct LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
#if (LCM_DSI_CMD_MODE)
params->dsi.mode = CMD_MODE;
#else
params->dsi.mode = SYNC_PULSE_VDO_MODE;
#endif
params->dsi.LANE_NUM = LCM_FOUR_LANE;
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 6;
params->dsi.vertical_frontporch = 14;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 8;
params->dsi.horizontal_backporch = 16;
params->dsi.horizontal_frontporch = 72;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.PLL_CLOCK = 430;
}
static void lcm_init_lcm(void)
{
pr_notice("[Kernel/LCM] %s\n", __func__);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) /
sizeof(struct LCM_setting_table), 1);
}
static void lcm_init_power(void)
{
#ifdef BUILD_LK
printf("[LK/LCM] %s enter\n", __func__);
lcm_set_gpio_output(GPIO_LCD_PWR, GPIO_OUT_ONE);
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_PWR2_EN, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(30);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO);
MDELAY(2);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(5);
#else
pr_notice("[KERNEL/LCM] %s enter\n", __func__);
#endif
}
static void lcm_resume(void)
{
pr_notice("[Kernel/LCM] %s\n", __func__);
lcm_init_lcm();
}
static void lcm_resume_power(void)
{
pr_notice("[Kernel/LCM] %s\n", __func__);
lcm_set_gpio_output(GPIO_LCD_PWR, GPIO_OUT_ONE);
MDELAY(20);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_PWR2_EN, GPIO_OUT_ONE);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ONE);
MDELAY(10);
}
static void lcm_suspend(void)
{
pr_notice("[Kernel/LCM] %s\n", __func__);
push_table(lcm_suspend_setting,
sizeof(lcm_suspend_setting) /
sizeof(struct LCM_setting_table), 1);
}
static void lcm_suspend_power(void)
{
pr_notice("[Kernel/LCM] %s\n", __func__);
lcm_set_gpio_output(GPIO_LCD_RST, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_PWR2_EN, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_PWR_EN, GPIO_OUT_ZERO);
MDELAY(10);
lcm_set_gpio_output(GPIO_LCD_PWR, GPIO_OUT_ZERO);
}
struct LCM_DRIVER nt35532_fhd_dsi_vdo_sharp_lcm_drv = {
.name = "nt35532_fhd_dsi_vdo_sharp_lcm_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init_lcm,
.init_power = lcm_init_power,
.resume = lcm_resume,
.resume_power = lcm_resume_power,
.suspend = lcm_suspend,
.suspend_power = lcm_suspend_power,
};
@@ -0,0 +1,21 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_auo_rt4801.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_auo_rt5081.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_auo_rt5081_720p.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_auo_rt5081_hdp.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_auo_rt5081_hdp_19_9.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_truly_rt5081.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_cmd_truly_rt5081_720p.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_vdo_auo_rt5081.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_vdo_auo_rt5081_hdp.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
@@ -0,0 +1,20 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.
#
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += nt35695B_fhd_dsi_vdo_auo_rt5081_hdp_1560.o
ccflags-$(CONFIG_MTK_LCM) += -I$(srctree)/drivers/misc/mediatek/lcm/inc
Loaded 100 of 80519 files, more files were not shown because too many files have changed in this diff. Show more