找回密码
 注册
关于网站域名变更的通知
查看: 332|回复: 1
打印 上一主题 下一主题

技术分享 | i.MX8M Mini适配MIPI转eDP芯片

[复制链接]

该用户从未签到

跳转到指定楼层
1#
 楼主| 发表于 2024-5-8 09:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x

! p( y! t9 `( Y) P% h, R/ r1 a
% ?+ Y" E0 k3 W$ c1.方案概述
此方案使用HD-8MMN-CORE的核心板搭配TI公司的芯片SN65DSI86转换芯片实现。
SN65DSI86作为一款MIPI DSI转eDP的芯片,支持双通道DSI输入,最大四通道显示输出,最大支持4K@60fps输出,WUXGA 1080P。本方案中将采用单通道DSI输入,双通道DP输出到1080p的屏幕。
HD8MMN-CORE系列工业级核心板基于NXP(Freescale) i.MX8MM系列Cortex-A53高性能处理器设计,支持硬件加密,支持摄像头接口、USB3.0接口、HDMI/MIPI、PCIe、千兆以太网接口、多路串口等,适用于快速开发一系列最具创新性的应用,如多媒体应用、人机界面、工业4.0、车载终端以及边缘计算设备等。

: E4 H! l7 w3 s. I! h' g9 b2.硬件原理图
注:硬件修改REFCLK上需要贴上27M的晶振,TEST2引脚需要通过4.7K电阻上拉到1.8V.
3软件实现3.1软件介绍
内核版本:Linux5.10;
SN65DSI86驱动:drivers/gpu/drm/bridge/ti-sn65dsi86.c
Panel驱动:drivers/gpu/drm/panel/panel-simple.c
, }. {0 C# e+ i3 }% q& ?1 [
3.2驱动移植
内核配置,需要打开如下两项
CONFIG_DRM_TI_SN65DSI86=yCONFIG_DRM_PANEL_SIMPLE=y
7 N' G( p4 b- J1)设备树配置/ {        osc_27m: clock-osc-27m {                compatible = "fixed-clock";                #clock-cells = <span data-raw-text-1715131244818="<0" data-textnode-index-1715131244818="41" data-index-1715131244818="736" data-index-len-1715131244818="736" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                clock-frequency = <span data-raw-text-1715131244818="<27000000" data-textnode-index-1715131244818="45" data-index-1715131244818="781" data-index-len-1715131244818="781" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                clock-output-names = "osc_27m";        };
8 |5 U  C. I- x" x6 Y$ X& f        lcd_backlight: lcd_backlight {                compatible = "pwm-backlight";                pwms = <span data-raw-text-1715131244818="<&pwm1 0 100000" data-textnode-index-1715131244818="63" data-index-1715131244818="961" data-index-len-1715131244818="961" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                status = "okay";
3 h  i: |/ P8 Z. h6 m                brightness-levels = <span data-raw-text-1715131244818="< 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" data-textnode-index-1715131244818="109" data-index-1715131244818="1694" data-index-len-1715131244818="1694" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                enable-gpios = <span data-raw-text-1715131244818="<&gpio1 1 GPIO_ACTIVE_HIGH" data-textnode-index-1715131244818="113" data-index-1715131244818="1753" data-index-len-1715131244818="1753" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                default-brightness-level = <span data-raw-text-1715131244818="<80" data-textnode-index-1715131244818="117" data-index-1715131244818="1801" data-index-len-1715131244818="1801" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;        };        panel {                compatible = "test,test-edp-1080p";        //设置自己的屏幕匹配参数组                backlight = <span data-raw-text-1715131244818="<&lcd_backlight" data-textnode-index-1715131244818="131" data-index-1715131244818="1944" data-index-len-1715131244818="1944" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                no-hpd;$ _7 r/ y& k) K! Z
                port {                        panel1_in: endpoint {                                remote-endpoint = <span data-raw-text-1715131244818="<&sn65_out" data-textnode-index-1715131244818="145" data-index-1715131244818="2096" data-index-len-1715131244818="2096" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                        };                };        };};&pwm1 {        pinctrl-names = "default";        pinctrl-0 = <span data-raw-text-1715131244818="<&pinctrl_pwm1" data-textnode-index-1715131244818="163" data-index-1715131244818="2229" data-index-len-1715131244818="2229" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;        status = "okay";};
9 ?4 J$ D: h3 i5 {; v( i&i2c4 {        clock-frequency = <span data-raw-text-1715131244818="<400000" data-textnode-index-1715131244818="175" data-index-1715131244818="2297" data-index-len-1715131244818="2297" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;        pinctrl-names = "default";        pinctrl-0 = <span data-raw-text-1715131244818="<&pinctrl_i2c4" data-textnode-index-1715131244818="183" data-index-1715131244818="2367" data-index-len-1715131244818="2367" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;        status = "okay";        sn65dsi86@2d {               …….                clock-names = "refclk";          //默认名字          //SN65DSI86仅支持12 MHz, 19.2 MHz, 26 MHz, 27 MHz or 38.4 MHz.                clocks = <span data-raw-text-1715131244818="<&osc_27m" data-textnode-index-1715131244818="205" data-index-1715131244818="2591" data-index-len-1715131244818="2591" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;
, H" @7 q) K& Y3 s& C! R               ……                        port@1 {                                reg = <span data-raw-text-1715131244818="<1" data-textnode-index-1715131244818="215" data-index-1715131244818="2682" data-index-len-1715131244818="2682" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                                sn65_out: endpoint {                                        //data-lanes = <span data-raw-text-1715131244818="<0 1 2 3" data-textnode-index-1715131244818="223" data-index-1715131244818="2799" data-index-len-1715131244818="2799" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;                  //根据eDP屏的通道数设置,这里为2通道                                        data-lanes = <span data-raw-text-1715131244818="<0 1" data-textnode-index-1715131244818="229" data-index-1715131244818="2897" data-index-len-1715131244818="2897" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>;  ……+ ~: g. Z( S3 r  M# L. [
2)驱动修改
添加显示屏的显示参数到驱动中,修改drivers/gpu/drm/panel/panel-simple.c:

3 X4 P+ Y. ?4 ~8 k4 Q! Mtatic const struct display_timing test_edp_1080p_timing = {        .pixelclock = { 153000000, 153000000, 153000000 },        .hactive = { 1920, 1920, 1920 },        .hfront_porch = { 100, 100, 100 },        …..        .bus_format = MEDIA_BUS_FMT_RGB666_1X18,        .connector_type = DRM_MODE_CONNECTOR_eDP,    };static const struct of_device_id platform_of_match[] = {        {                .compatible = "test,test-edp-1080p",                .data = &test_edp_1080p,        },4 P5 t- O+ I: B$ d, n0 s
修改sn65dsi86驱动以适应我们的板卡,修改drivers/gpu/drm/bridge/ti-sn65dsi86.c,修改DSI正确的模式,防止找不到注册的panel出现报错“couldnotfindanypanelnode”,开机过程中打印1次是正常的,SN65DSI86的驱动找不到Panel会被多次调用,直到找到panel为止。
static int ti_sn_bridge_attach(struct drm_bridge *bridge,enum drm_bridge_attach_flags flags){...          //dsi-" data-textnode-index-1715131244818="302" data-index-1715131244818="3752" data-index-len-1715131244818="3752" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>mode_flags = MIPI_DSI_MODE_VIDEO;        dsi-" data-textnode-index-1715131244818="303" data-index-1715131244818="3798" data-index-len-1715131244818="3798" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |                          MIPI_DSI_MODE_EOT_PACKET | MIPI_DSI_MODE_VIDEO_HSE;
$ Q: _+ j8 F4 p5 I/ _* M& q
# a# w; @/ p3 w. I* V; Y5 r3)调试报错在调试过程中碰到“Linktrainingfailed,linkisoff”的报错,是因为SN65DSI86默认只支持ASSR模式的eDP屏幕,对于不支持ASSR模式的eDP屏,硬件上则需要将TEST2引脚拉高到1.8V,且修改相关寄存器将芯片从ASSR模式变为支持标准的DP模式,修改如下:
9 O( ]5 N+ V4 H7 [1 p#define SN_ENH_FRAME_REG                        0x5A#define  ASSR_CONTROL                           BIT(0)...! ~9 A/ Y( C2 u) B
static int ti_sn_link_training(struct ti_sn_bridge *pdata, int dp_rate_idx,const char **last_err_str)    {        unsigned int val;int ret;int i;
& d5 t: K5 z+ I4 I( `3 ^- R% H& Y4 P. O/* set dp clk frequency value */        regmap_update_bits(pdata-" data-textnode-index-1715131244818="342" data-index-1715131244818="4421" data-index-len-1715131244818="4421" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>regmap, SN_DATARATE_CONFIG_REG,                           DP_DATARATE_MASK, DP_DATARATE(dp_rate_idx));0 k* O9 s: d1 W& s" ^
        regmap_write(pdata-" data-textnode-index-1715131244818="344" data-index-1715131244818="4551" data-index-len-1715131244818="4551" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>regmap, 0xff, 0x07);        regmap_write(pdata-" data-textnode-index-1715131244818="349" data-index-1715131244818="4599" data-index-len-1715131244818="4599" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>regmap, 0x16, 0x01);        regmap_write(pdata-" data-textnode-index-1715131244818="354" data-index-1715131244818="4647" data-index-len-1715131244818="4647" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>regmap, 0xff, 0x00);/* For DisplayPort, use the standard DP scrambler seed. */        regmap_update_bits(pdata-" data-textnode-index-1715131244818="360" data-index-1715131244818="4759" data-index-len-1715131244818="4759" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>regmap, SN_ENH_FRAME_REG,ASSR_CONTROL, 0);/* enable DP PLL */        regmap_write(pdata-" data-textnode-index-1715131244818="364" data-index-1715131244818="4848" data-index-len-1715131244818="4848" class="character" style="box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>regmap, SN_PLL_ENABLE_REG, 1);...5 L+ U1 C1 c) j9 b' o
如果未接eDP屏幕会出现如下报错:

6 S( Z8 h: o1 q- Y/ e[ 2.299284] ti_sn65dsi86 3-002d: [drm:ti_sn_bridge_enable] ERROR Can't read lane count (-6); assuming 4           [ 2.765851] ti_sn65dsi86 3-002d: [drm:ti_sn_bridge_enable] ERROR Can't read eDP rev (-6), assuming 1.1
( B' m, e' y/ r  Z1 Z3 W$ {0 h7 Y) E& o( ~9 o: Z& y. W% P

# j* {" U& w: n4 I. a

该用户从未签到

2#
发表于 2024-5-8 10:56 | 只看该作者
有完整的程序吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-7-20 05:14 , Processed in 0.125000 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表