添加跟AUXADC_LCM_VOLTAGE_CHANNEL相关的代码,读取channel端的电压值以区分不同的屏,可在suspend函数中将读id的函数内容放进去读取打印电压值
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2008
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
#ifdef BUILD_LK
#include "platform/mt_gpio.h"
#else
#include
#if defined(BUILD_UBOOT)
#include
#else
//#include
#endif
#endif
#include "lcm_drv.h"
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
//static unsigned int lcm_esd_test = FALSE; ///only for ESD test
//----------------------------------------------------------------------------
// RGK add for lcm detect
//----------------------------------------------------------------------------
//#include
#define MIN_VOLTAGE (800)
#define MAX_VOLTAGE (999)
#define LCM_COMPARE_BY_ADC 0 // lcm compare id by adc
// ---------------------------------------------------------------------------
// Local Constants
// ---------------------------------------------------------------------------
#define AUXADC_LCM_VOLTAGE_CHANNEL 1
#define FRAME_WIDTH (480)
#define FRAME_HEIGHT (960)
#define REGFLAG_DELAY 0xFFE
#define REGFLAG_END_OF_TABLE 0xFFF // END OF REGISTERS MARKER
// ---------------------------------------------------------------------------
// Local Variables
// ---------------------------------------------------------------------------
static 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))
// add for lcm detect ,read adc voltage
extern int IMM_GetOneChannelValue(int dwChannel, int data[4], int* rawdata);
#define LCM_ID_ST7701 (0x8802)
// ---------------------------------------------------------------------------
// 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)
struct LCM_setting_table {
unsigned int cmd;
unsigned char count;
unsigned char para_list[128];
};
static struct LCM_setting_table lcm_initialization_setting[] = {
{0x11,0,{0x00}},
{REGFLAG_DELAY,150,{}},
{0xFF,5,{0x77,0x01,0x00,0x00,0x10}},
{0xC0,2,{0x77,0x00}},
{0xC1,2,{0x0A,0x02}},
{0xC2,2,{0x07,0x02}},
{0xC6,1,{0x07}},
{0xB0,16,{0x00,0x04,0x0C,0x0D,0x11,0x07,0x00,0x07,0x07,0x1A,0x05,0x13,0x12,0x29,0x30,0x19}},
{0xB1,16,{0x00,0x0D,0x13,0x0D,0x11,0x06,0x00,0x08,0x07,0x1B,0x04,0x14,0x11,0x29,0x30,0x19}},
{0xFF,5,{0x77,0x01,0x00,0x00,0x11}},
{0xB0,1,{0x73}},
{0xB1,1,{0x35}}, //57
{0xB2,1,{0x87}},
{0xB3,1,{0x80}},
{0xB5,1,{0x47}},
{0xB7,1,{0x87}},
{0xB8,1,{0x20}},
{0xC1,1,{0x78}},
{0xC2,1,{0x78}},
{0xD0,1,{0x88}},
{0xE0,3,{0x00,0x00,0x02}},
{0xE1,11,{0x05,0x8C,0x00,0x00,0x04,0x8C,0x00,0x00,0x00,0x20,0x20}},
{0xE2,13,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
{0xE3,4,{0x00,0x00,0x33,0x00}},
{0xE4,2,{0x22,0x00}},
{0xE5,16,{0x09,0xD5,0xBB,0x8C,0x07,0xD5,0xBB,0x8C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
{0xE6,4,{0x00,0x00,0x33,0x00}},
{0xE7,2,{0x22,0x00}},
{0xE8,16,{0x08,0xD5,0xBB,0x8C,0x06,0xD5,0xBB,0x8C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
{0xEB,7,{0x02,0x00,0x40,0x40,0x00,0x00,0x00}},
{0xEC,2,{0x00,0x00}},
{0xED,16,{0xAC,0x54,0x0B,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xB0,0x45,0xCA}},
{0xFF,5,{0x77,0x01,0x00,0x00,0x00}},
{0x29,0,{0x00}},
{REGFLAG_DELAY,20,{}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
/*
static struct LCM_setting_table lcm_sleep_out_setting[] = {
// Sleep Out
{0x11, 1, {0x00}},
{REGFLAG_DELAY, 120, {}},
// Display ON
{0x29, 1, {0x00}},
{REGFLAG_DELAY, 10, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
*/
static struct LCM_setting_table lcm_prepare_setting[] = {
{0xBF, 3, {0x91,0x61,0xF2}}, // page 1
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
// Display off sequence
//{0x01, 1, {0x00}},
//{REGFLAG_DELAY, 100, {}},
{0x28, 1, {0x00}},
{REGFLAG_DELAY, 30, {}},
// Sleep Mode On
{0x10, 1, {0x00}},
{REGFLAG_DELAY, 100, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
//unsigned int Vcomxxx=0x30;
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 cmd;
cmd = table[i].cmd;
switch (cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
/*if(lcm_initialization_setting[i].cmd==0xBE)
{
Vcomxxx=Vcomxxx+2;
lcm_initialization_setting[i].para_list[1]=Vcomxxx;
}*/
dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
}
}
}
// ---------------------------------------------------------------------------
// LCM Driver Implementations
// ---------------------------------------------------------------------------
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->type = LCM_TYPE_DSI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
// DSI
/* Command mode setting */
params->dsi.LANE_NUM = LCM_TWO_LANE;//LCM_FOUR_LANE;//LCM_THREE_LANE;//LCM_TWO_LANE;//LCM_THREE_LANE;//LCM_TWO_LANE;//3LANE
//The following defined the fomat for data coming from LCD engine.
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
// Video mode setting
params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
params->dsi.vertical_sync_active = 6;//2
params->dsi.vertical_backporch = 18;//10
params->dsi.vertical_frontporch = 12;//11
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 10;//14
params->dsi.horizontal_backporch = 42;//80
params->dsi.horizontal_frontporch = 32;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.compatibility_for_nvk = 0;
// Bit rate calculation
//1 Every lane speed
//params->dsi.pll_select=1;
//params->dsi.PLL_CLOCK = LCM_DSI_6589_PLL_CLOCK_377;
params->dsi.PLL_CLOCK=197;//172;//185;//213;//208
}
static unsigned int lcm_compare_id(void);
static void lcm_init(void)
{
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(20);
SET_RESET_PIN(1);
MDELAY(180);
push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static void lcm_suspend(void)
{
//lcm_compare_id();
push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
}
static void lcm_resume(void)
{
lcm_init();
//push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
}
static void lcm_setbacklight(unsigned int level)
{
unsigned int data_array[16];
#if defined(BUILD_LK)
printf("%s, %d\n", __func__, level);
#elif defined(BUILD_UBOOT)
printf("%s, %d\n", __func__, level);
#else
printk("lcm_setbacklight = %d\n", level);
#endif
if(level > 255)
level = 255;
data_array[0]= 0x00023902;
data_array[1] =(0x51|(level<<8));
dsi_set_cmdq(data_array, 2, 1);
}
static unsigned int lcm_compare_id(void)
{
unsigned short device_id;
unsigned char buffer[2];
unsigned int array[16];
int data[4] = {0,0,0,0};
int res = 0;
int rawdata = 0;
unsigned int lcm_vol = 0;
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(100);
#ifdef AUXADC_LCM_VOLTAGE_CHANNEL
res = IMM_GetOneChannelValue(AUXADC_LCM_VOLTAGE_CHANNEL,data,&rawdata);
if(res < 0)
{
#ifndef BUILD_LK
printk("[adc_uboot]: get data error\n");
#endif
return 0;
}
#endif
lcm_vol = data[0]*1000+data[1]*10;
push_table(lcm_prepare_setting, sizeof(lcm_prepare_setting) / sizeof(struct LCM_setting_table), 1);
//*************Enable CMD2 Page1 *******************//
array[0] = 0x00033700;// read id return two byte,version and id
dsi_set_cmdq(array, 1, 1);
read_reg_v2(0xa1, buffer, 3);//a1 7701
device_id = buffer[0]<<8|buffer[1];
#ifdef BUILD_LK
printf("st7701_fwvga_dsi_vdo_dx_a6_qy_lcm_drv uboot %s\n", __func__);
printf("st7701 %s, id = 0x%x 0x%x lcm_vol =%d device_id =0x%x \n", __func__, buffer[0], buffer[1],lcm_vol,device_id);//should be 0x8009
#else
printk("st7701_fwvga_dsi_vdo_dx_a6_qy_lcm_drv kernel %s\n", __func__);
printk("st7701 %s, id = 0x%x 0x%x lcm_vol =%d device_id =0x%x \n", __func__, buffer[0], buffer[1],lcm_vol,device_id);//should be 0x8009
#endif
//return 1;
return (LCM_ID_ST7701 == device_id && (lcm_vol>1000 && lcm_vol<1300))?1:0; //51K
}
// ---------------------------------------------------------------------------
// Get LCM Driver Hooks
// ---------------------------------------------------------------------------
LCM_DRIVER st7701_dsi_vdo_common_lcm_drv =
{
.name = "st7701_dsi_vdo_common",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.set_backlight = lcm_setbacklight,
.compare_id = lcm_compare_id,
//.esd_check = lcm_esd_check,
//.esd_recover = lcm_esd_recover,
//.set_pwm = lcm_setpwm,
//.get_pwm = lcm_getpwm,
};