static int __devinit max17040_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct input_dev *input_data = NULL; int ret; #ifdef CONFIG_SKY_CHARGER_BATTERY max17040_data.status = BATT_STATE_NONE; #endif dbgme_rel("[MAX17040] max17040_probe [IN]\n"); if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) return -EIO; max17040_data.client = client; i2c_set_clientdata(client, &max17040_data); max17040_data.vcell = 0; max17040_data.soc = 0; #ifdef CONFIG_SKY_CHARGER_BATTERY //registor sky_battery_register(&battery_ops); #endif //mutex is init mutex_init(&max17040_data.i2c_mutex); //rcomp is set max17040_set_rcomp(); //Version of reading max17040_get_version(); #ifdef CONFIG_SKY_CHARGER_BATTERY if (max17040_get_battery_id() != BATT_ID_NONE) max17040_data.status = BATT_STATE_PRESENT; #endif return 0; }
static int max17040_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct power_supply_config psy_cfg = {}; struct max17040_chip *chip; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) return -EIO; chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; chip->client = client; chip->pdata = client->dev.platform_data; i2c_set_clientdata(client, chip); psy_cfg.drv_data = chip; chip->battery = power_supply_register(&client->dev, &max17040_battery_desc, &psy_cfg); if (IS_ERR(chip->battery)) { dev_err(&client->dev, "failed: power supply register\n"); return PTR_ERR(chip->battery); } max17040_reset(client); max17040_get_version(client); INIT_DEFERRABLE_WORK(&chip->work, max17040_work); queue_delayed_work(system_power_efficient_wq, &chip->work, MAX17040_DELAY); return 0; }
static int __devinit max17040_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct input_dev *input_data = NULL; int ret; #if 0 int aflag=0; #endif sleep_dbg("[MAX17040] max17040_probe [IN]\n"); if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) return -EIO; max17040_data.client = client; i2c_set_clientdata(client, &max17040_data); //sys file system are registered max17040_data.battery.name = "batterys"; max17040_data.battery.type = POWER_SUPPLY_TYPE_BATTERY; max17040_data.battery.get_property = max17040_get_property; max17040_data.battery.properties = max17040_battery_props; max17040_data.battery.external_power_changed = max17040_bat_external_power_changed; max17040_data.battery.num_properties = ARRAY_SIZE(max17040_battery_props); ret = power_supply_register(&client->dev, &max17040_data.battery); if (ret) { sleep_dbg("[MAX17040] failed: power supply register [ERROR]\n"); i2c_set_clientdata(client, NULL); return ret; } //The code used in the test mode [TEST MODE] ret = sysfs_create_group(&client->dev.kobj, &max17040_attr_group); if (ret) { sleep_dbg("[MAX17040] failed: sysfs_create_group [ERROR]\n"); } //mutex is init mutex_init(&max17040_data.data_mutex); mutex_init(&max17040_data.i2c_mutex); mutex_init(&max17040_data.quick_mutex); //rcomp is set max17040_set_rcomp(); //Version of reading max17040_get_version(); //read vell and soc max17040_quick_get_vcell(); max17040_quick_get_soc(); #if 0 //check quick start aflag=max17040_check_restart(max17040_data.quick_data.quick_vcell,max17040_data.quick_data.quick_soc); if(aflag) { max17040_restart(); msleep(300); //quick start update time } #endif //The code used in the test mode [TEST MODE] atomic_set(&max17040_data.set_test, 0); input_data = input_allocate_device(); if (!input_data) { sleep_dbg("MAX17040: Unable to input_allocate_device \n"); return -1; } set_bit(EV_REL,input_data->evbit); input_set_capability(input_data, EV_REL, REL_RX); input_set_capability(input_data, EV_REL, REL_RY); /* wake */ input_set_capability(input_data, EV_REL, REL_RZ); /* wake */ input_data->name="max17040"; ret =input_register_device(input_data); if (ret) { sleep_dbg("MAX17040: Unable to register input_data device\n"); return -1; } input_set_drvdata(input_data, &max17040_data); max17040_data.max17040_input_data=input_data; //initialize workqueue and alarm setting wake_lock_init(&max17040_data.work_wake_lock, WAKE_LOCK_SUSPEND, "max17040-battery"); #ifdef MAX17040_ALARM_RTC_ENABLE max17040_data.last_poll=alarm_get_elapsed_realtime(); INIT_WORK(&max17040_data.monitor_work, max17040_work); max17040_data.monitor_wqueue = create_freezeable_workqueue("max17040"); /* init to something sane */ if (!max17040_data.monitor_wqueue) { sleep_dbg("fail_workqueue Error [PROBE FUNCTION]"); return -1; } alarm_init(&max17040_data.alarm, ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, max_battery_alarm_callback); //prevent suspend max17040_prevent_suspend(); #ifdef CONFIG_HAS_EARLYSUSPEND max17040_data.early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; max17040_data.early_suspend.suspend = max17040_batt_early_suspend; max17040_data.early_suspend.resume = max17040_batt_late_resume; dbg("set max17040 EARLY_SUSPEND\n"); register_early_suspend(&max17040_data.early_suspend); #endif //CONFIG_HAS_EARLYSUSPEND queue_work(max17040_data.monitor_wqueue, &max17040_data.monitor_work); #else INIT_DELAYED_WORK_DEFERRABLE(&max17040_data.work, max17040_work); schedule_delayed_work(&max17040_data.work, 0); #endif //MAX17040_ALARM_RTC_ENABLE sleep_dbg("[MAX17040] max17040_probe [OUT]\n"); return 0; }