一个硬件驱动:TI am335x系列(am3352)LCD驱动修改移植的方法

步骤如下:

  1. /arch/arm/mach-omap2/board-am335xevm.c/lcdc_init()

{得到LCD硬件参数struct da8xx_lcdc_platform_data} ->

am33xx_register_lcdc() ->

omap_device_build() ->  

omap_device_build_ss() ->

platform_device_add_data(){pdev->dev.platform_data = d}

 

2、platform_device端注册过程:

omap_device_build_ss(){pdev = platform_device_alloc(pdev_name, pdev_id);} -> omap_device_register() ->

platform_device_add()

 

3、platform_device设备名确定过程:

am33xx_register_lcdc(){char *dev_name = "da8xx_lcdc";} ->

omap_device_build() ->

omap_device_build_ss(){pdev = platform_device_alloc(pdev_name, pdev_id);}

 

4、通过设备名搜索找到设备驱动文件: drivers/video/da8xx-fb.c

 

5、board-am335xevm.c记录的屏的类型有:

.type    = "TFC_S9700RTWV35TR_01B",

.type   = "NHD-4.3-ATXI#-T-1",

  da8xx-fb.c记录的屏的类型有:

.name = "Sharp_LCD035Q3DG01",

.name = "Sharp_LK043T1DG01",

.name = "TFC_S9700RTWV35TR_01B",

.name = "NHD-4.3-ATXI#-T-1",

 

6、配置驱动程序进入fb_probe()获取LCD硬件参数用于配置struct da8xx_lcdc_platform_data:

struct da8xx_lcdc_platform_data *fb_pdata = device->

dev.platform_data;

 

7、匹配合适的屏,并输出屏的类型(通过dmesg查看匹配信息是否正确),否则退出驱动:

{

    if (i == ARRAY_SIZE(known_lcd_panels)) {

       dev_err(&device->dev, "GLCD: No valid panel found\n");

       ret = -ENODEV;

       goto err_pm_runtime_disable;

    } else

       dev_info(&device->dev, "GLCD: Found %s panel\n",

                   fb_pdata->type);

}

 

8、fb_probe()接下来复位LCD并配置硬件参数,最后申请fb_info注册framebuffer设备

 

9、硬件资源设置:

am33xx_register_lcdc(){oh=omap_hwmod_lookup(oh_name);}-> omap_device_build(...struct omap_hwmod *oh,...){struct omap_hwmod *ohs[] = { oh };} ->

omap_device_build_ss(...struct omap_hwmod **ohs,...) ->

omap_device_alloc(...struct omap_hwmod **ohs,...){od->hwmods = hwmods(来至于参数ohs);} ->

omap_device_fill_resources(od, res){omap_hwmod_fill_resources(od->hwmods[i], res){填充 struct resource}} ->

 platform_device_add_resources(){pdev->resource = r;}

 

10、资源来源omap_hwmod:

omap_hwmod_lookup(oh_name) ->

_lookup(name) ->

遍历链表omap_hwmod_list

并返回struct omap_hwmod

 

11、被返回的返回struct omap_hwmod来至于:

MACHINE_START ->

am33xx_init_early() ->

am33xx_hwmod_init() ->

omap_hwmod_register(){将am33xx_lcdc_hwmod添加到omap_hwmod_list链表当中}

static struct omap_hwmod am33xx_lcdc_hwmod = {

   ......

    .slaves       = am33xx_lcdc_slaves,//记录了物理起始地址

    ......

    };

 

12、总结:两个数据结构共同决定LCD控制寄存器的配置参数:

static struct lcd_ctrl_config lcd_cfg = {

     &disp_panel,

    .ac_bias       = 255,

    .ac_bias_intrpt       = 0,

    .dma_burst_sz       = 16,

    .bpp           = 32,

    .fdd           = 0x80,

    .tft_alt_mode       = 0,

    .stn_565_mode       = 0,

    .mono_8bit_mode       = 0,

    .invert_line_clock   = 1,

    .invert_frm_clock   = 1,

    .sync_edge       = 0,

    .sync_ctrl       = 1,

    .raster_order       = 0,

};

static struct da8xx_panel known_lcd_panels[] = {

    [2] = {

       .name = "TFC_S9700RTWV35TR_01B",

       .width = 800,

       .height = 480,

       .hfp = 39,

       .hbp = 39,

       .hsw = 47,

       .vfp = 13,

       .vbp = 29,

       .vsw = 2,

       .pxl_clk = 30000000,

       .invert_pxl_clk = 0,

   }

}

欢迎加入物联网交流群:816697676

展开阅读全文

没有更多推荐了,返回首页

应支付0元
点击重新获取
扫码支付

支付成功即可阅读