海思3519A uboot开机画面

首先确保在 linux 下已经调好 mipi 驱动,使用 uboot 已经移植好了 mipi 相关驱动,只需要点亮屏幕背光,以及屏相关的初始化。
首先需要在 Main.c 中增加 pwm 初始化的代码,pwm 初始化写寄存器即可,但是需要注意,需要将 PWM_OUT 和 pwm 时钟打开,再去配置寄存器:

    //open pwm,start screen light back
    //PWM_OUT0
    writel(1,0x04058074);
    //PERI_CRG101 PWM clock
    writel(0x008AAA80,0x04510194);
    //PWM0 REG
    writel(0,0x045a000c);
    writel(1000,0x045a0000);
    writel(500,0x045a0004);
    writel(10,0x045a0008);
    writel(5,0x045a000c);

然后在 cmd_vo_hi3519av100.c do_startvo 函数,会调到 mipi_tx_display,调到 Mipi_tx.c ,需要在此完成自己屏幕初始化的部分:

/ * name : mipi_tx_display
 * desc : mipi_tx interface display.*/
int mipi_tx_display(unsigned int vosync)
{
    int ret;
    combo_dev_cfg_t *mipi_tx_config;
    printf("this is mipi_tx begin,vosync:%d.\n",vosync);
    /* mipi_tx drv init.*/
    mipi_tx_module_init();
    switch (vosync) {
        case VO_OUTPUT_576P50:
            mipi_tx_config = &g_mipi_tx_720x576_50_config;
            break;
        case VO_OUTPUT_720P60:
            mipi_tx_config = &g_mipi_tx_1280x720_60_config;
            break;
        case VO_OUTPUT_1080P60:
            mipi_tx_config = &g_mipi_tx_1920x1080_60_config;
            break;
        case VO_OUTPUT_1024x768_60:
            mipi_tx_config = &g_mipi_tx_1024x768_60_config;
            break;
        case VO_OUTPUT_1280x1024_60:
            mipi_tx_config = &g_mipi_tx_1280x1024_60_config;
            break;
        case VO_OUTPUT_720x1280_60:
            printf("%s,%d,vo sync: VO_OUTPUT_720x1280_60\n", __FUNCTION__, __LINE__);
            mipi_tx_config = &g_mipi_tx_720x1280_60_config;
            break;
        case VO_OUTPUT_1080x1920_60:
            mipi_tx_config = &g_mipi_tx_1080x1920_60_config;
            break;
        default:
            printf("%s,%d,unsupported vo sync\n", __FUNCTION__, __LINE__);
            mipi_tx_config = &g_mipi_tx_1920x1080_60_config;
            break;
    }
    /* step 1 : config mipi_tx controller.*/
    ret = mipi_tx_ioctl(HI_MIPI_TX_SET_DEV_CFG, (unsigned long)mipi_tx_config);
    if (ret != 0) {
        printf("MIPI_TX SET_DEV_CONFIG failed\n");
        return -1;
    }
    /* step 2 : init display device (do it yourself ).*/
    mipi_tx_screen_init();
    udelay(1000);
    /* step 3 : enable mipi_tx controller.*/
    ret = mipi_tx_ioctl(HI_MIPI_TX_ENABLE, (unsigned long)0);
    if (ret != 0) {
        printf("MIPI_TX enable failed\n");
        return -1;
    }
    printf("this is mipi_tx end.\n");
    return 0;
}

其中,step 2 的 mipi_tx_screen_init 是我们需要完成的屏幕初始化函数,这里就是给 mipi_tx 发送命令,初始化屏幕:


void mipi_tx_screen_init(void){
    //mipi_tx param.
    char cmd[]={
        0xFF,0x01,
        0xFB,0x01,
        0xFF,0x02,
        0xFB,0x01,
/******* 命令特别长,仅示例 ********/
        0xE5,0x03,
        0xE6,0xA8,
        0xE7,0x03,
        0xE8,0xC8,
        0xE9,0x03,
        0xEA,0xFF,
        0xFF,0x00,
        0xFB,0x01
    };
    unsigned int cmd_size=2;
    char cmd1[] ={0x11,0x29};
    cmd_info_t   cmd_info;
    unsigned int cmd1_size=1;
    unsigned int loop;
    long         ret;
    printf("func:%s line:%d send cmd begin.\n",__FUNCTION__,__LINE__);
    for(loop=0; loop<sizeof(cmd)/cmd_size; loop++) {
        udelay(loop == 12 ? 10000 : 1000);
        cmd_info.devno = 0;
        cmd_info.cmd_size = (((unsigned short)cmd[loop*cmd_size+1])<<8)+(cmd[loop*cmd_size]);
        cmd_info.data_type = 0x15;
        cmd_info.cmd = NULL;
        //printf("func:%s line:%d cmd_size = %x = %x + %x %d\n",__FUNCTION__,__LINE__,cmd_info.cmd_size,
        //((unsigned short)cmd[loop*cmd_size])<<8,cmd[loop*cmd_size+1],loop);
        ret = mipi_tx_ioctl(HI_MIPI_TX_SET_CMD, (unsigned long)(&cmd_info));
        if (0 != ret) {
           printf("MIPI_TX SET CMD failed\n");
        }
    }
    for(loop=0; loop<sizeof(cmd1)/cmd1_size; loop++) {
        cmd_info.devno = 0;
        cmd_info.cmd_size = cmd1[loop];
        cmd_info.data_type = 0x15;
        cmd_info.cmd = NULL;
        //printf("func:%s line:%d cmd_size1 = %x  %d\n",__FUNCTION__,__LINE__,cmd_info.cmd_size,loop);
        ret = mipi_tx_ioctl(HI_MIPI_TX_SET_CMD, (unsigned long)(&cmd_info));
        if (0 != ret) {
            printf("MIPI_TX SET CMD failed\n");
        }
        udelay(10000);
    }
    printf("func:%s line:%d send cmd end.\n",__FUNCTION__,__LINE__);
}

完成上述修改后,就可以在 uboot 命令加载开机画面了,这里 uboot 烧写在 0 大小 768K ,logo 烧写在 768K ,大小 256K,之后是内核和文件系统等,代码如下,

void ShowBootLogo(void)
{
    //open pwm,start screen light back
    //PWM_OUT0
    writel(1,0x04058074);
    //PERI_CRG101 PWM clock
    writel(0x008AAA80,0x04510194);
    //PWM0 REG
    writel(0,0x045a000c);
    writel(1000,0x045a0000);
    writel(500,0x045a0004);
    writel(10,0x045a0008);
    writel(5,0x045a000c);

    //start logo
    setenv("jpeg_addr", "0x52000000"); //image addr start
    setenv("jpeg_size", "0xe671"); //image file size
    setenv("jpeg_emar_buf","0x52200000");
    setenv("vobuf", "0x52400000"); //image decode addr
    //run commands
    run_command("nand read 0x52000000 0xc0000 0xe671",0); //read logo file
    run_command("decjpg 0",0); //decode jpg from jpeg_addr to vobuf
    run_command("setvobg 0 0",0); //set vo background to black
    run_command("startvo 0 16384 45",0); //start vo with mipi 1080*1920 60ps
    run_command("startvl 0 0x52400000 768 180 824 720 190",0);//startvl,768 is decjpg picture stride,be sure [x y w h]/2==0
}

然后,在 main_loop 中调用 ShowBootLogo 即可。
还需要注意的是,在 uboot 中做了 pwm 初始化和 vo 0 显示,所以在 hifb 启动之后,最好先将 vo 0 关闭,再进行其他初始化,避免造成闪烁等现象。

你可能感兴趣的:(linux,linux驱动及海思)