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

@@ -0,0 +1,7 @@
#
# Makefile for misc devices that really don't fit anywhere else.
#
obj-y += sofeg01_fhdplus_dsi_cmd_samsung.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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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,533 @@
// 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"
#include "disp_dts_gpio.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
#include "graphics-base-v1.0.h"
#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 (0xf5)
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 LCM_DSI_CMD_MODE 1
#define FRAME_WIDTH (1080)
#define FRAME_HEIGHT (2160)
/* physical size in um */
#define LCM_PHYSICAL_WIDTH (74520)
#define LCM_PHYSICAL_HEIGHT (132480)
#define REGFLAG_DELAY 0xFFFC
#define REGFLAG_UDELAY 0xFFFB
#define REGFLAG_END_OF_TABLE 0xFFFD
#define REGFLAG_RESET_LOW 0xFFFE
#define REGFLAG_RESET_HIGH 0xFFFF
/* for ESD recovery */
static int lastBacklightLevel = -1;
#define CMD_HBM_ENABLE 0xe0
#define CMD_HBM_DISABLE 0x20
static bool hbm_en;
static bool hbm_wait;
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, 160, {} }
};
static struct LCM_setting_table init_setting_cmd[] = {
/* sleep out */
{0x11, 0, {} },
{REGFLAG_DELAY, 25, {} },
/* enable TE */
{0x35, 1, {0x00} },
/* MIPI HS RCV setting */
{0xfc, 2, {0x5a, 0x5a} },
{0xe8, 3, {0x64, 0x08, 0x0c} },
{0xfc, 2, {0xa5, 0xa5} },
/* dimming on */
{0xf0, 2, {0x5a, 0x5a} },
{0x53, 1, {0x28} },
{0xf0, 2, {0xa5, 0xa5} },
/* {0x51, 2, {0x03, 0xff} }, */
{REGFLAG_DELAY, 120, {} },
/* display on */
{0x29, 0, {} },
};
static struct LCM_setting_table bl_level[] = {
{0xf0, 2, {0x5a, 0x5a} },
{0x51, 2, {0xFF, 0xFF} },
{0xf0, 2, {0xa5, 0xa5} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
static struct LCM_setting_table hbm[] = {
{0xf0, 2, {0x5a, 0x5a} },
{0x53, 1, {CMD_HBM_ENABLE} },
{0xf0, 2, {0xa5, 0xa5} },
{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;
#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 = 8;
params->dsi.vertical_frontporch = 20;
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
#if (LCM_DSI_CMD_MODE)
params->dsi.PLL_CLOCK = 480;
#else
params->dsi.PLL_CLOCK = 480;
#endif
params->dsi.PLL_CK_CMD = 480;
params->dsi.PLL_CK_VDO = 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 = 0x53;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x24;
params->lcm_color_mode = HAL_COLOR_MODE_DISPLAY_P3;
#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
params->hbm_en_time = 2;
params->hbm_dis_time = 1;
}
static void lcm_setbacklight_cmdq(void *handle, unsigned int level)
{
unsigned int BacklightLevel;
LCM_LOGI("%s, set backlight: level = %d\n", __func__, level);
if (level > 255)
level = 255;
if (level < 0)
level = 0;
lastBacklightLevel = level;
BacklightLevel = level * 1023 / 255;
bl_level[1].para_list[0] = ((BacklightLevel >> 8) & 0x3);
bl_level[1].para_list[1] = (BacklightLevel & 0xff);
push_table(handle, bl_level, sizeof(bl_level) /
sizeof(struct LCM_setting_table), 1);
}
static bool lcm_get_hbm_state(void)
{
return hbm_en;
}
static bool lcm_get_hbm_wait(void)
{
return hbm_wait;
}
static bool lcm_set_hbm_wait(bool wait)
{
bool old = hbm_wait;
hbm_wait = wait;
return old;
}
static bool lcm_set_hbm_cmdq(bool en, void *qhandle)
{
bool old = hbm_en;
if (hbm_en == en)
goto done;
if (en)
hbm[1].para_list[0] = CMD_HBM_ENABLE;
else
hbm[1].para_list[0] = CMD_HBM_DISABLE;
push_table(qhandle, hbm, ARRAY_SIZE(hbm), 1);
hbm_en = en;
lcm_set_hbm_wait(true);
done:
return old;
}
static void lcm_init(void)
{
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
push_table(NULL, init_setting_cmd, sizeof(init_setting_cmd) /
sizeof(struct LCM_setting_table), 1);
/* Set brightness for ESD recovery */
if (lastBacklightLevel >= 0)
lcm_setbacklight_cmdq(NULL, lastBacklightLevel);
hbm_en = false;
}
static void lcm_suspend(void)
{
push_table(NULL, lcm_suspend_setting, sizeof(lcm_suspend_setting) /
sizeof(struct LCM_setting_table), 1);
hbm_en = false;
}
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_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 1;
}
LCM_LOGI("[LCM NORMAL] [0x53]=0x%02x\n", buffer[0]);
#endif
return 0;
}
static unsigned int lcm_ata_check(unsigned char *buffer)
{
unsigned int ret = 0;
#ifndef BUILD_LK
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);
/* read id return two bytes, version and id */
data_array[0] = 0x00043700;
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);
#endif
return ret;
}
#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.
* In this case 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 */
LCM_LOGI("%s calc error,assign full roi:y=%d,h=%d\n",
__func__, *y, *height);
y1 = 0;
h = FRAME_HEIGHT;
}
LCM_LOGI("%s:(%d,%d,%d,%d) to (%d,%d,%d,%d)\n",
__func__, *x, *y, *width, *height, x1, y1, w, h);
*x = x1;
*width = w;
*y = y1;
*height = h;
}
#endif /* LCM_DSI_CMD_MODE */
struct LCM_DRIVER sofeg01_fhdplus_dsi_cmd_samsung_lcm_drv = {
.name = "sofeg01_fhdplus_dsi_cmd_samsung_drv",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.esd_check = lcm_esd_check,
.set_backlight_cmdq = lcm_setbacklight_cmdq,
.get_hbm_state = lcm_get_hbm_state,
.set_hbm_cmdq = lcm_set_hbm_cmdq,
.get_hbm_wait = lcm_get_hbm_wait,
.set_hbm_wait = lcm_set_hbm_wait,
.ata_check = lcm_ata_check,
.update = lcm_update,
#if (LCM_DSI_CMD_MODE)
.validate_roi = lcm_validate_roi,
#endif
};