记录将屏幕TPM0521002P适配到泰山派

一、前言

这块 TPM0521002P 屏幕 是在 2024 年 3 月 17 日购买的,嘉立创打板了大佬设计的转接板一起使用。由于那时对屏幕接口和转接板电路理解还不够深入,尤其是对排线方向、电路连接细节没有经验,调试过程中一直无法点亮屏幕。排查时还发现触摸 IC 发热明显,摸起来有些烫手,一度误以为触摸芯片已经烧坏,因此这块屏幕就被搁置下来,长期处于“吃灰”状态。

最近一段时间的工作内容主要集中在屏幕驱动和点屏调试方面,相关经验积累得比较多。周末整理开发板和旧硬件时又看到了这块屏幕,想着既然触摸大概率已经损坏,不如尝试把屏幕本身点亮,作为一次完整的调试练习。

于是重新从电路入手,仔细分析了当初的转接板原理图和连接方式。对比 DSI 接口定义后发现,之前在连接 DSI 和主板时使用了 同向排线,而这块转接板的设计实际上需要使用 反向排线 才能正确连接信号。确认这一点后,更换排线并重新烧录大佬提供的固件进行测试。

结果非常意外 —— 系统直接启动进入 Android,屏幕正常点亮,而且触摸功能也完全正常。
image

原本以为已经损坏的触摸 IC 并没有问题,这块沉睡已久的屏幕就这样“复活”了,算是一次非常惊喜的调试经历。

二、实际电路连接

image

三、尝试移植到泰山派官方buildroot系统中

由于大佬只发了安卓固件,没有设备树,靠着之前留下来的资料开始移植

1.背光部分

/ {
    
    backlight: backlight {
        status = "okay";
        compatible = "pwm-backlight";
        pwms = <&pwm5 0 25000 0>;
        brightness-levels = <
              0   1   2   3   4   5   6   7
              8   9  10  11  12  13  14  15
             16  17  18  19  20  21  22  23
             24  25  26  27  28  29  30  31
             32  33  34  35  36  37  38  39
             40  41  42  43  44  45  46  47
             48  49  50  51  52  53  54  55
             56  57  58  59  60  61  62  63
             64  65  66  67  68  69  70  71
             72  73  74  75  76  77  78  79
             80  81  82  83  84  85  86  87
             88  89  90  91  92  93  94  95
             96  97  98  99 100 101 102 103
            104 105 106 107 108 109 110 111
            112 113 114 115 116 117 118 119
            120 121 122 123 124 125 126 127
            128 129 130 131 132 133 134 135
            136 137 138 139 140 141 142 143
            144 145 146 147 148 149 150 151
            152 153 154 155 156 157 158 159
            160 161 162 163 164 165 166 167
            168 169 170 171 172 173 174 175
            176 177 178 179 180 181 182 183
            184 185 186 187 188 189 190 191
            192 193 194 195 196 197 198 199
            200 201 202 203 204 205 206 207
            208 209 210 211 212 213 214 215
            216 217 218 219 220 221 222 223
            224 225 226 227 228 229 230 231
            232 233 234 235 236 237 238 239
            240 241 242 243 244 245 246 247
            248 249 250 251 252 253 254 255>;
        default-brightness-level = <100>;
    };

};

&pwm5 {
    status = "okay";
};

这块背光太高了触摸ic会很烫,可以将范围限制在到180以内保险一点

2.触摸部分

&i2c1 {

    status = "okay";

    gt911: touchscreen@14 {
        compatible = "goodix,gt911";
        reg = <0x14>;

        pinctrl-names = "default";
        pinctrl-0 = <&ts_pins>;

        interrupt-parent = <&gpio1>;
        interrupts = <RK_PA0 IRQ_TYPE_EDGE_RISING>;

        irq-gpios = <&gpio1 RK_PA0 GPIO_ACTIVE_HIGH>;
        reset-gpios = <&gpio1 RK_PA1 GPIO_ACTIVE_HIGH>;

        touchscreen-size-x = <1080>;
        touchscreen-size-y = <1920>;

        touchscreen-swapped-x-y;
    };
};  

&pinctrl {
    touch {
        ts_pins: ts-pins {
            /* RK356x 宏定义:引脚编号、功能类型、上下拉配置 */
            rockchip,pins =
                <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>, /* INT */
                <1 RK_PA1 RK_FUNC_GPIO &pcfg_pull_none>; /* RST */
        };
    };
};

这块之前资料写的地址0x5d,实际i2cdetect -y 1后发现地址是0x14,此处也是一个坑,毕竟之前资料是适配rk3399的,情有可原

实测改成下面这样功能也正常因为引脚默认就是gpio功能

&i2c1 {

    status = "okay";

    gt911: touchscreen@14 {
        compatible = "goodix,gt911";
        reg = <0x14>;

        // pinctrl-names = "default";
        // pinctrl-0 = <&ts_pins>;

        interrupt-parent = <&gpio1>;
        interrupts = <RK_PA0 IRQ_TYPE_EDGE_RISING>;

        irq-gpios = <&gpio1 RK_PA0 GPIO_ACTIVE_HIGH>;
        reset-gpios = <&gpio1 RK_PA1 GPIO_ACTIVE_HIGH>;

        touchscreen-size-x = <1080>;
        touchscreen-size-y = <1920>;

        // touchscreen-swapped-x-y;
    };
};  

// &pinctrl {
//     touch {
//         ts_pins: ts-pins {
//             /* RK356x 宏定义:引脚编号、功能类型、上下拉配置 */
//             rockchip,pins =
//                 <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>, /* INT */
//                 <1 RK_PA1 RK_FUNC_GPIO &pcfg_pull_none>; /* RST */
//         };
//     };
// };

3.显示部分

/*
 * video_phy1 needs to be enabled
 * when dsi1 is enabled
 */
&dsi1 {
	status = "okay";
};

&dsi1_in_vp0 {
	status = "okay";
};

&dsi1_in_vp1 {
	status = "disabled";
};

&video_phy1 {
	status = "okay";
};

&route_dsi1 {
	status = "okay";//wucaicheng mipi okay
	connect = <&vp0_out_dsi1>;
};

&dsi1 {
        status = "okay";
    //rockchip,lane-rate = <480>;
    panel {
        compatible ="simple-panel-dsi"; 
        status = "okay"; 
        reg = <0>; 
        power-supply = <&vcc3v3_sys>; 
        backlight = <&backlight>; 
        reset-delay-ms = <20>;
		enable-delay-ms = <100>;
		prepare-delay-ms = <20>;
		unprepare-delay-ms = <20>;
		disable-delay-ms = <20>;
		init-delay-ms = <10>;
        // enable-gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; 
        // reset-gpios  = <&gpio1 0 GPIO_ACTIVE_LOW>; 
		reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
        dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>; 
        dsi,format = <MIPI_DSI_FMT_RGB888>; 
//        bus-format = <MEDIA_BUS_FMT_RGB666_1X24>;
        dsi,lanes = <4>;

        //for king/rp/rd board cannot enable boot logo
        pinctrl-names = "default";
        // pinctrl-0 = <&pwr_en>;
        panel-init-sequence = [
            // init code
    
            
            15 00 02 51 00
            15 00 02 53 0C
            15 00 02 55 00
            05 00 01 11
            05 0A 01 29
        ];

        panel-exit-sequence = [
                            05 00 01 28
                            05 78 01 10
        ];

        display-timings {
            native-mode = <&timing0>;
            timing0: timing0 {
                    clock-frequency = <142000000>;// (1920+4+3+1)*(1080+96+33+12)*60=134800000
            hactive = <1080>;
            hfront-porch = <96>;

            hback-porch = <33>;
            hsync-len = <12>;

            vactive = <1920>;
            vfront-porch = <4>;
            vback-porch = <3>;
            vsync-len = <1>;

            hsync-active = <0>;
            vsync-active = <0>;
            de-active = <0>;
            pixelclk-active = <0>;
            swap-rb = <0>;
            swap-rg = <0>;
            swap-gb = <0>;
            };
            timing1: timing1 {
                    clock-frequency = <148000000>;
                    hactive = <1920>;
                    vactive = <1080>;
                    hback-porch = <100>;
                    hfront-porch = <160>;
                    vback-porch = <25>;
                    vfront-porch = <10>;
                    hsync-len = <20>;
                    vsync-len = <10>;
                    hsync-active = <0>;
                    vsync-active = <0>;
                    de-active = <0>;
                    pixelclk-active = <1>;
            };

         };
                
                
        ports {
            #address-cells = <1>;
            #size-cells = <0>;

            port@0 {
                reg = <0>;
                panel_in_dsi: endpoint {
                    remote-endpoint = <&dsi_out_panel>;
                };
            };
        };
                                
    };
        
    ports {
                #address-cells = <1>;
                #size-cells = <0>;
        
                port@1 {
                    reg = <1>;
                    dsi_out_panel: endpoint {
                        remote-endpoint = <&panel_in_dsi>;
                    };
                };
            };
                    
};

4.内核驱动

上面设置完成后evtest发现还是没有触摸设备,开始debug

root@RK356X:/# grep -n goodix /sys/firmware/devicetree/base/* -r
/sys/firmware/devicetree/base/i2c@fe5a0000/touchscreen@14/compatible:1:goodix,gt911
root@RK356X:/#

上面日志看到设备树加载正常

root@RK356X:/# zcat /proc/config.gz | grep GOODIX 
# CONFIG_TOUCHSCREEN_GOODIX is not set 
root@RK356X:/#

上面日志看到看到内核驱动没有打上,在配置文件中添加 CONFIG_TOUCHSCREEN_GOODIX=y

image

之后evtest可以看到触摸设备正常了,触摸后也有坐标反馈
image
分别触摸左上角和右下角,坐标数据正常
image

posted @ 2026-03-22 10:47  上善若淼  阅读(4)  评论(0)    收藏  举报