come from :https://blog.csdn.net/m0_37166404/article/details/55522071
二、在Kernel中移植lcd
流程大致和在lk中移植lcd差不多
1.首先要写好.dts文件
创建arch/arm/boot/dts/qcom/dsi-panel-xxx-video.dtsi文件
文件就一个节点,&mdss_mdp,这其中有显示屏的节点dsi_xxx,其中很多节点的数值都在上一节有提及
&mdss_mdp {
dsi_xxx: qcom,mdss_dsi_xxx_video {
qcom,mdss-dsi-panel-name = "xxx_panel";
qcom,mdss-dsi-panel-controller = <&mdss_dsi0>;
qcom,mdss-dsi-panel-type = "dsi_video_mode";
qcom,mdss-dsi-panel-destination = "display_1";
qcom,mdss-dsi-panel-framerate = <60>;
qcom,mdss-dsi-virtual-channel-id = <0>;
qcom,mdss-dsi-stream = <0>;
qcom,mdss-dsi-panel-width = <720>;//面板宽度
qcom,mdss-dsi-panel-height = <1280>;//面板高度
qcom,mdss-dsi-h-front-porch = <38>;//水平前沿值
qcom,mdss-dsi-h-back-porch = <30>;//水平后沿值
qcom,mdss-dsi-h-pulse-width = <30>;//水平脉冲宽度
qcom,mdss-dsi-h-sync-skew = <0>;
qcom,mdss-dsi-v-back-porch = <8>;//垂直后沿值
qcom,mdss-dsi-v-front-porch = <10>;//垂直前沿值
qcom,mdss-dsi-v-pulse-width = <6>;//垂直脉冲宽度
qcom,mdss-dsi-h-left-border = <0>;
qcom,mdss-dsi-h-right-border = <0>;
qcom,mdss-dsi-v-top-border = <0>;
qcom,mdss-dsi-v-bottom-border = <0>;
qcom,mdss-dsi-bpp = <24>;
qcom,mdss-dsi-color-order = "rgb_swap_rgb";
qcom,mdss-dsi-underflow-color = <0xff>;
qcom,mdss-dsi-border-color = <0>;
//厂商初始化改为以下属性,每一行一条命令
//39--写,格式,04--写的字节,命令
qcom,mdss-dsi-on-command = [
39 01 00 00 00 00 04 FF 98 81 03
39 01 00 00 00 00 02 01 00
//...
39 01 00 00 00 00 02 35 00
05 01 00 00 78 00 02 11 00
05 01 00 00 00 00 02 29 00];
qcom,mdss-dsi-off-command = [05 01 00 00 32 00 02 28 00
05 01 00 00 78 00 02 10 00];
qcom,mdss-dsi-on-command-state = "dsi_lp_mode";
qcom,mdss-dsi-off-command-state = "dsi_lp_mode";
qcom,mdss-dsi-h-sync-pulse = <1>;
qcom,mdss-dsi-traffic-mode = "burst_mode";
qcom,mdss-dsi-lane-map = "lane_map_0123";
qcom,mdss-dsi-bllp-eof-power-mode;
qcom,mdss-dsi-bllp-power-mode;
qcom,mdss-dsi-lane-0-state;
qcom,mdss-dsi-lane-1-state;
qcom,mdss-dsi-lane-2-state;
qcom,mdss-dsi-lane-3-state;
//指定面板 PHY 定时设置的长度为 12 的数组,跟lk一样
qcom,mdss-dsi-panel-timings = [80 20 11 00 3C 38 1A 20 13 03 04 00];
//指定模式切换后的字节时钟周期,跟lk一样
qcom,mdss-dsi-t-clk-post = <0x04>;
//指定模式切换前的字节时钟周期,跟lk一样
qcom,mdss-dsi-t-clk-pre = <0x1B>;
qcom,mdss-dsi-bl-min-level = <1>;
//背光最大电流,255
qcom,mdss-dsi-bl-max-level = <255>;
qcom,mdss-dsi-dma-trigger = "trigger_sw";
qcom,mdss-dsi-mdp-trigger = "none";
qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
//屏幕的上电时序,1代表拉高,0代表拉低,50代表50时间
qcom,mdss-dsi-reset-sequence = <1 50>, <0 20>, <1 50>;
};
};
在msm8916-mdss.dtsi写有#include “xxx-video.dtsi”
在msm8916-mtp.dtsi写有#include “msm8916.dtsi”
这样就把xxx-video.dtsi写进了msm8916-mtp.dtsi
在msm8916-mtp.dtsi中,有以下三个节点跟屏有关:
&dsi_xxx {
qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm"; //pwm启动背光
qcom,mdss-dsi-bl-pmic-pwm-frequency = <100>;
qcom,mdss-dsi-bl-pmic-bank-select = <0>;
qcom,mdss-dsi-pwm-gpio = <&pm8916_mpps 4 0>;
};
&mdss_dsi0 {
qcom,dsi-pref-prim-pan = <&dsi_xxx>; //跟添加的显示屏的节点名称一样
...
};
&dsi_xxx {
qcom,cont-splash-enabled; //开启内核的持续启动功能
};
2.在kernel中的mdss_dsi.c或者mdss_dsi_panel.c中打开背光引脚和进行reset上电
如:在mdss_dsi_panel_power_on中:
#if 1 //打开背光引脚
if (gpio_is_valid(bl_gpio)) {
ret = gpio_request(bl_gpio, "bl_gpio");
if (ret) {
pr_err("================rc = %d : could not req gpio BL\n", ret);
}
pr_err("set lcd_de_en gpio output high\n");
gpio_direction_output(bl_gpio, 1);
mdelay(80);
}
gpio_free(bl_gpio);
#endif
在mdss_dsi_panel_reset中:
//上电时序
for (i = 0; i < pdata->panel_info.rst_seq_len; ++i) {
gpio_set_value((ctrl_pdata->rst_gpio),
pdata->panel_info.rst_seq[i]);
if (pdata->panel_info.rst_seq[++i])
usleep(pinfo->rst_seq[i] * 1000);
}