Document

当你觉得迷茫的时候,那就多学习

android-uboot驱动

uboot驱动,主要是根据标准的格式,按照框架写就行了,我这里平台是基于RK3588s  android12

uboot驱动需要使用U_BOOT_DRIVER函数,添加各个回调

 

U_BOOT_DRIVER(dc_charge_fg) = {
       .name = "dc_charge_fg",
       .id = UCLASS_FG,         //这个是id,会通过uclass_first_device去查找
       .of_match = charge_ids,
       .probe = dc_charge_fg_probe,
       //.ofdata_to_platdata = cw221x_ofdata_to_platdata,
       .ops = &dc_charge_fg_ops,
       .priv_auto_alloc_size = 10,
       //.priv_auto_alloc_size = sizeof(struct cw221x_info),
};

 

说明一个关键点参数: id = UCLASS_FG   


这个是id,会通过uclass_first_device去查找,如下
    for (uclass_first_device(UCLASS_FG, &dev);
         dev;
         uclass_next_device(&dev)) {
        cap = fuel_gauge_capability(dev);
        if (cap == (FG_CAP_CHARGER | FG_CAP_FUEL_GAUGE)) {
            *fuel_gauge = dev;
            *charger = NULL;
        } else if (cap == FG_CAP_FUEL_GAUGE) {
            *fuel_gauge = dev;
        } else if (cap == FG_CAP_CHARGER) {
            *charger = dev;
        }
        else if(cap==6)
        {
            //printf("--------这个是sc89890------\n") ;
        }
        else
        {
            *dc_charge = dev ;
            //printf("-----最后确定找这个----\n") ;
        }
    }
uclass_first_device(UCLASS_FG, &dev)函数,查找有使用UCLASS_FG作为id的drive

然后使用fuel_gauge_capability获取返回值,根据返回值判断是哪一个驱动,这样就获取到了dev了


posted @ 2024-01-06 17:54  陈昌雄  阅读(68)  评论(0编辑  收藏  举报
Document

联系方式

qq: 2224505189

微信: 1935442635

奖励博主