Beispiel #1
0
static int __devinit 
vt1603_bat_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
    int ret = 0;
    struct vt1603_bat_drvdata *bat_drv = NULL;
    struct vt1603_bat_platform_data *bat_pdata;

    bat_dbg("Enter\n");
    bat_pdata = i2c->dev.platform_data;
    if (NULL == bat_pdata) {
        bat_dbg("vt1603_bat: platform data NULL\n");
        ret = -ENODATA;
        goto out;
    }
    bat_drv = kzalloc(sizeof(*bat_drv), GFP_KERNEL);
    if (!bat_drv) {
        bat_dbg("vt1603_bat: alloc driver data failed\n");
        ret = -ENOMEM;
        goto out;
    }
    vt1603_bat   = bat_drv;
    bat_drv->i2c = i2c;
    dev_set_drvdata(&i2c->dev, bat_drv);
    vt1603_reg_dump(bat_drv, 0xc0, 12);
#ifdef CONFIG_VT1603_BATTERY_ENABLE
    vt1603_bat_info_init(bat_drv);
    vt1603_bat_work(&bat_drv->work);
#endif
    printk(KERN_INFO "VT1603 SAR-ADC Battery Driver OK!\n");
    goto out;

out:
    bat_dbg("Exit\n");
    return ret;
}
Beispiel #2
0
/*
 * vt1603_get_bat_info - get battery status, API for wmt_battery.c
 */
unsigned short vt1603_get_bat_info(int dcin_status)
{
    if (vt1603_bat == NULL)
		return 4444;
	
    if(dcin_status){
		Bat_buf.full = 0;
		Bat_buf.head = 0;
		vt1603_bat_work(&vt1603_bat->work);
		return vt1603_bat->bat_new;
    }else
        return vt1603_bat->bat_val;
	
}