原创 为AM335x移植Linux内核主线代码(42)LCD之简单粗暴篇

2015-3-3 16:33 3192 21 21 分类: MCU/ 嵌入式 文集: Linux Kernel的DTS

硬件更改: LCD的引脚分布见下面这个帖子!它不是RGB的顺序!之前调试U-Boot的时候是弄错了的。
http://elinux.org/24bit_LCD_for_BBB

在Kernel中调试LCD是出乎意料的简单:
~~~~~~~~~~~~~~~~~~~~
LCD的背光,目前是由LM2733控制的,只有ON和OFF两个状态,因此它的操作也很简单,直接在maria-am335x-commom.dts文件的leds项下添加:

led@2 {
        label = "backlight:lm2677";
        gpios = <&gpio3 17 GPIO_ACTIVE_HIGH>;
        default-state = "off";
};
led@3 {
        label = "display:on";
        gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>;
        default-state = "on";
};

以及:
core_led: pinmux_core_led {
        pinctrl-single,pins = <
                0x1E8 (PIN_OUTPUT | MUX_MODE7)  /* emu1.gpio3_8 */
                0x19C (PIN_OUTPUT | MUX_MODE7)  /* mcasp0_ahclkr.gpio3_17 */
        >;
};

这样背光就会点亮了。
这里使用了普通的GPIO作为驱动LM2733,来点亮背光;如果想要调整背光亮度,则需要在LM2677的负载输出的硬件上增加一个三极管,并且在kernel中添加PWM代码。它并不复杂,不再赘述。


接下来是调试LCD的显示部分:
======================================================================
http://processors.wiki.ti.com/index.php/AM335x_LCD_Controller_Driver%27s_Guide
http://processors.wiki.ti.com/index.php/Sitara_Linux_Training:_Linux_Board_Port#Adding_LCD_and_Touchscreen_Support
http://processors.wiki.ti.com/index.php/Linux_Core_LCD_Controller_User_Guide

Step 1:在make menuconfig中:
→ Device Drivers → Graphics support → Frame buffer Devices
选中:“DA8xx/OMAP-L1xx/AM335x Framebuffer support”

在make menuconfig中:
 → Device Drivers → Graphics support → Direct Rendering Manager
选中:“DRM Support for TI LCDC Display Controller”:

Step 2: 在dts文件中添加:
/ {
        panel {
                compatible = "ti,tilcdc,panel";
                pinctrl-names = "default";
                pinctrl-0 = <&lcd_pins_default>;
                status = "okay";
                panel-info {
                        ac-bias         = <0>;
                        ac-bias-intrpt  = <0>;
                        dma-burst-sz    = <16>;
                        bpp             = <32>;
                        fdd             = <0x80>;
                        sync-edge       = <0>;
                        sync-ctrl       = <0>;
                        raster-order    = <0>;
                        fifo-th         = <0>;
                };
                display-timings {
                        native-mode = <&timing0>;
                        timing0: 480x272 {
                                hactive         = <480>;
                                vactive         = <272>;
                                hback-porch     = <1>;
                                hfront-porch    = <1>;
                                hsync-len       = <45>;
                                vback-porch     = <1>;
                                vfront-porch    = <1>;
                                vsync-len       = <16>;
                                clock-frequency = <9000000>;
                                hsync-active    = <0>;
                                vsync-active    = <0>;
                        };
                };
        };

        /* 其他子项 */
};
        
&am33xx_pinmux {
        pinctrl-names = "default";
        lcd_pins_default: lcd_pins_default {
                pinctrl-single,pins = <
                        0x20 (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad8.lcd_data23 */
                        0x24 (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad9.lcd_data22 */
                        0x28 (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad10.lcd_data21 */
                        0x2c (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad11.lcd_data20 */
                        0x30 (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad12.lcd_data19 */
                        0x34 (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad13.lcd_data18 */
                        0x38 (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad14.lcd_data17 */
                        0x3c (PIN_OUTPUT | MUX_MODE1)   /* gpmc_ad15.lcd_data16 */
                        0xa0 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data0.lcd_data0 */
                        0xa4 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data1.lcd_data1 */
                        0xa8 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data2.lcd_data2 */
                        0xac (PIN_OUTPUT | MUX_MODE0)   /* lcd_data3.lcd_data3 */
                        0xb0 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data4.lcd_data4 */
                        0xb4 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data5.lcd_data5 */
                        0xb8 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data6.lcd_data6 */
                        0xbc (PIN_OUTPUT | MUX_MODE0)   /* lcd_data7.lcd_data7 */
                        0xc0 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data8.lcd_data8 */
                        0xc4 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data9.lcd_data9 */
                        0xc8 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data10.lcd_data10 */
                        0xcc (PIN_OUTPUT | MUX_MODE0)   /* lcd_data11.lcd_data11 */
                        0xd0 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data12.lcd_data12 */
                        0xd4 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data13.lcd_data13 */
                        0xd8 (PIN_OUTPUT | MUX_MODE0)   /* lcd_data14.lcd_data14 */
                        0xdc (PIN_OUTPUT | MUX_MODE0)   /* lcd_data15.lcd_data15 */
                        0xe8 (PIN_OUTPUT | MUX_MODE0)   /* lcd_pclk.lcd_pclk */
                        0xec (PIN_OUTPUT | MUX_MODE0)   /* lcd_ac_bias_en.lcd_ac_bias_en */
                >;

        };
        /* 其他mux */
};

&lcdc {
        status = "okay";
};

就这两个步骤之后,就会发现初始化的打印信息多了(箭头部分是我添加的):
[    1.968847] [drm] Initialized drm 1.1.0 20060810
[    1.973871] ========> tilcdc_drm_init
[    1.977750] ========> tilcdc_tfp410_init
[    1.982601] ========> tilcdc_slave_init
[    1.987371] ========> tilcdc_panel_init
[    1.992466] ========> panel_probe
[    1.996649] ====> get timings
[    2.000061] ====> get info
[    2.003013] ====> bpp = 32
[    2.006896] ========> tilcdc_pdev_probe
[    2.025202] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    2.032217] [drm] No driver support for vblank timestamp query.
[    2.099776] Console: switching to colour frame buffer device 60x34
[    2.111317] tilcdc 4830e000.lcdc: fb0:  frame buffer device
[    2.117301] tilcdc 4830e000.lcdc: registered panic notifier
[    2.123360] [drm] Initialized tilcdc 1.0.0 20121205 on minor 0

执行下面的命令:
tftp -g -l 3color_2.bmp -r 3color_2.bmp 192.168.1.118
cat 800*480.bmp > /dev/fb0

就会发现屏幕上有显示图片了(现在的显示是有重影的,以后再更改),另外,由于我使用的是Forlinx的文件系统,因此可以启动时是QT的界面。另外,由于24根RGB引脚的分配问题,现在的LCD色调有点奇怪,在第二版的硬件中会做相应的更改。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
是不是很简单?是不是很简单?简直是难以置信的简单!
虽然因为把“okay”拼写成“okey”浪费了我很多很多的时间,但实际上它原本的代码非常容易,all you need to do is在dts文件中添加设备就好了,这也说明Linux Kernel是非常简易且健壮的!

文章评论0条评论)

登录后参与讨论
我要评论
0
21
关闭 站长推荐上一条 /2 下一条