OTM1287A在MSM8909上的移植

高通平台是根据board-id来匹配dts文件,查看lk日志,找到如下log,由此可以断定board-id=8
B -    262971 - CDT version:3,Platform ID:8,Major ID:1,Minor ID:0,Subtype:0
查看kernel/arch/arm/boot/dts/qcom/msm8909-1gb-mtp.dts文件发现,高通默认的dts配置是mtp,根据board-id将其改为qrd-skue,方法如下:
1.查看kernel/arch/arm/boot/dts/qcom/msm8909-1gb-qrd-skue.dts文件,其board-id是0x1000b,将其改为8。
#include "msm8909-qrd-skue.dtsi"

/ {
        qcom,board-id= <8 0>;/*qcom,board-id= <0x1000b 0>;*/
};
同时修改kernel/arch/arm/boot/dts/qcom/msm8909-1gb-mtp.dts文件,将board-id改为0x1000b。
#include "msm8909-mtp.dtsi"
#include "msm8909-pm8909.dtsi"
#include "msm8909-pm8909-mtp.dtsi"

/ {
        model = "Qualcomm Technologies, Inc. MSM8909-PM8909 1GB MTP";
        compatible = "qcom,msm8909-mtp", "qcom,msm8909", "qcom,mtp";
        qcom,board-id= <0x1000b 0>;/*qcom,board-id= <8 0>;*/
};
LCD的配置涉及LK和Kernel两部分。LK中,RST引脚的配置在bootable/bootloader/lk/target/msm8909/include/target/display.h,GPIO25作为LCD的RST引脚。
/*---------------------------------------------------------------------------*/
/* GPIO configuration                                                        */
/*---------------------------------------------------------------------------*/
static struct gpio_pin reset_gpio = { 
  "msmgpio", 25, 3, 1, 0, 1
};
在bootable/bootloader/lk/dev/gcdb/display/include/目录下新建文件panel_otm1287a_720p_video.h,LCD的参数都在这个文件中配置,比较重要的是LCD的timing时序配置:
/*---------------------------------------------------------------------------*/
/* Panel timing                                                              */
/*---------------------------------------------------------------------------*/
static const uint32_t otm1287a_720p_video_timings[] = {
        0x92, 0x1A, 0x12, 0x00, 0x3E, 0x42, 0x16, 0x1E, 0x14, 0x03, 0x04, 0x00
};

这个时序是根据高通提供的office计算出来的,文件名为80-NH713-1_F_DSI_Timing_Parameters.xlsm,可在Createpoint下载,文档需要用office2013打开,在表格中输入LCD的参数,即可计算出上述时序,其中有一项(DSIPHY_TIMING_CTRL_0)需要按Ctrl+K才可以显示。
LCD的帧率配置:

static struct panel_config otm1287a_720p_video_panel_data = {
        "qcom,mdss_dsi_otm1287a_720p_video", "dsi:0:", "qcom,mdss-dsi-panel",
        10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
};
LCD的分辨率和同步脉冲以及前后沿宽度配置:
static struct panel_resolution otm1287a_720p_video_panel_res = {
        720, 1280, 52, 100, 24, 0, 8, 20, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 
};
每个像素用3个字节即24bit表示:
static struct color_info otm1287a_720p_video_color = {
        24, 0, 0xff, 0, 0, 0 
};
寄存器配置:
static char otm1287a_hd720_dsi_vdo_junda_cmd1[] = {
                0x02,0x00,0x29,0xC0,
                0x00,0x00,0xFF,0xFF,
};

static char otm1287a_hd720_dsi_vdo_junda_cmd2[] = {
                0x04,0x00,0x29,0xC0,
                0xFF,0x12,0x87,0x01
};

static char otm1287a_hd720_dsi_vdo_junda_cmd3[] = {
                0x02,0x00,0x29,0xC0,
                0x00,0x80,0xFF,0xFF,
};

static char otm1287a_hd720_dsi_vdo_junda_cmd4[] = {
                0x03,0x00,0x29,0xC0,
                0xFF,0x12,0x87,0xFF,
};
每两个数组配置一组寄存器,例如上述四个数组分别配置寄存器0xFF00的值为0x12,0xFF01的值为0x87,0xFF02的值为0x01;0xFF80的值为0x12,0xFF81的值为0x87。数组的第0个元素代表0x00,0x29,0xC0后面有效元素的个数,数组元素个数是4的倍数,不足的元素用0xFF填充。panel_otm1287a_720p_video.h文件中的结构体在bootable/bootloader/lk/dev/gcdb/display/include/panel.h中定义。
在bootable/bootloader/lk/target/msm8909/oem_panel.c文件init_panel_data函数内添加OTM1287A的代码,将panel_id强制改为OTM1287A_720P_VIDEO_PANEL,并在switch中添加1287A的case分支:
static int init_panel_data(struct panel_struct *panelstruct,
                        struct msm_panel_info *pinfo,
                        struct mdss_dsi_phy_ctrl *phy_db)
{
        int pan_type = PANEL_TYPE_DSI;

        panel_id = OTM1287A_720P_VIDEO_PANEL;
        switch (panel_id) {
        case OTM1287A_720P_VIDEO_PANEL:
                panelstruct->paneldata        = &otm1287a_720p_video_panel_data;
                panelstruct->panelres         = &otm1287a_720p_video_panel_res;
                panelstruct->color            = &otm1287a_720p_video_color;
                panelstruct->videopanel       = &otm1287a_720p_video_video_panel;
                panelstruct->commandpanel     = &otm1287a_720p_video_command_panel;
                panelstruct->state            = &otm1287a_720p_video_state;
                panelstruct->laneconfig       = &otm1287a_720p_video_lane_config;
                panelstruct->paneltiminginfo  = &otm1287a_720p_video_timing_info;
                panelstruct->panelresetseq    = &otm1287a_720p_video_reset_seq;
                panelstruct->backlightinfo    = &otm1287a_720p_video_backlight;
                pinfo->mipi.panel_cmds        = otm1287a_720p_video_on_command;
                pinfo->mipi.num_of_panel_cmds = OTM1287A_720P_VIDEO_ON_COMMAND;
                memcpy(phy_db->timing, otm1287a_720p_video_timings, TIMING_SIZE);
                break;
        case UNKNOWN_PANEL:
        default:
                memset(panelstruct, 0, sizeof(struct panel_struct));
                memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
                pinfo->mipi.num_of_panel_cmds = 0;
                memset(phy_db->timing, 0, TIMING_SIZE);
                pan_type = PANEL_TYPE_UNKNOWN;
                break;
        }
        return pan_type;
}
Kernel部分首先在kernel/arch/arm/boot/dts/qcom/目录下新建dsi-panel-otm1287a-720p-video.dtsi文件,在该文件中配置LCD的参数,在qcom,mdss-dsi-on-command中,每两条配置一组寄存器:
29 01 00 00 00 00 02 00 A6
29 01 00 00 00 00 02 b3 0f
寄存器0xB3A6的值被配置为0x0F
29 01 00 00 00 00 02 00 90
29 01 00 00 00 00 07 c0 00 62 00 01 00 04
寄存器0xC090,0xC091,0xC092,0xC093,0xC094,0xC095的值依次配置为00,62,00,01,00,04。
qcom,mdss-dsi-panel-timings是根据根据高通提供的excel表格计算出来的。
在kernel/arch/arm/boot/dts/qcom/msm8909-qrd-skue.dtsi中添加1287A的配置:

#include "dsi-panel-otm1287a-720p-video.dtsi"

&dsi_otm1287a_720p_video {
        qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
        qcom,mdss-dsi-bl-pmic-pwm-frequency = <100>;
        qcom,mdss-dsi-bl-pmic-bank-select = <0>;
        qcom,mdss-dsi-pwm-gpio = <&pm8909_mpps 2 0>;
};

你可能感兴趣的:(OTM1287A在MSM8909上的移植)