Lines Matching refs:dev_info

53 static inline int ds2781_battery_io(struct ds2781_device_info *dev_info,  in ds2781_battery_io()  argument
56 return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io); in ds2781_battery_io()
59 static int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf, in w1_ds2781_read() argument
62 return ds2781_battery_io(dev_info, buf, addr, count, 0); in w1_ds2781_read()
65 static inline int ds2781_read8(struct ds2781_device_info *dev_info, u8 *val, in ds2781_read8() argument
68 return ds2781_battery_io(dev_info, val, addr, sizeof(u8), 0); in ds2781_read8()
71 static int ds2781_read16(struct ds2781_device_info *dev_info, s16 *val, in ds2781_read16() argument
77 ret = ds2781_battery_io(dev_info, raw, addr, sizeof(raw), 0); in ds2781_read16()
86 static inline int ds2781_read_block(struct ds2781_device_info *dev_info, in ds2781_read_block() argument
89 return ds2781_battery_io(dev_info, val, addr, count, 0); in ds2781_read_block()
92 static inline int ds2781_write(struct ds2781_device_info *dev_info, u8 *val, in ds2781_write() argument
95 return ds2781_battery_io(dev_info, val, addr, count, 1); in ds2781_write()
108 static int ds2781_save_eeprom(struct ds2781_device_info *dev_info, int reg) in ds2781_save_eeprom() argument
112 ret = ds2781_store_eeprom(dev_info->w1_dev, reg); in ds2781_save_eeprom()
116 ret = ds2781_recall_eeprom(dev_info->w1_dev, reg); in ds2781_save_eeprom()
124 static int ds2781_set_sense_register(struct ds2781_device_info *dev_info, in ds2781_set_sense_register() argument
129 ret = ds2781_write(dev_info, &conductance, in ds2781_set_sense_register()
134 return ds2781_save_eeprom(dev_info, DS2781_RSNSP); in ds2781_set_sense_register()
138 static int ds2781_get_rsgain_register(struct ds2781_device_info *dev_info, in ds2781_get_rsgain_register() argument
141 return ds2781_read16(dev_info, rsgain, DS2781_RSGAIN_MSB); in ds2781_get_rsgain_register()
145 static int ds2781_set_rsgain_register(struct ds2781_device_info *dev_info, in ds2781_set_rsgain_register() argument
151 ret = ds2781_write(dev_info, raw, in ds2781_set_rsgain_register()
156 return ds2781_save_eeprom(dev_info, DS2781_RSGAIN_MSB); in ds2781_set_rsgain_register()
159 static int ds2781_get_voltage(struct ds2781_device_info *dev_info, in ds2781_get_voltage() argument
166 ret = w1_ds2781_read(dev_info, val, DS2781_VOLT_MSB, 2 * sizeof(u8)); in ds2781_get_voltage()
188 static int ds2781_get_temperature(struct ds2781_device_info *dev_info, in ds2781_get_temperature() argument
195 ret = w1_ds2781_read(dev_info, val, DS2781_TEMP_MSB, 2 * sizeof(u8)); in ds2781_get_temperature()
215 static int ds2781_get_current(struct ds2781_device_info *dev_info, in ds2781_get_current() argument
226 ret = ds2781_read8(dev_info, &sense_res_raw, DS2781_RSNSP); in ds2781_get_current()
231 dev_err(dev_info->dev, "sense resistor value is 0\n"); in ds2781_get_current()
252 ret = ds2781_read16(dev_info, &current_raw, reg_msb); in ds2781_get_current()
260 static int ds2781_get_accumulated_current(struct ds2781_device_info *dev_info, in ds2781_get_accumulated_current() argument
271 ret = ds2781_read8(dev_info, &sense_res_raw, DS2781_RSNSP); in ds2781_get_accumulated_current()
276 dev_err(dev_info->dev, "sense resistor value is 0\n"); in ds2781_get_accumulated_current()
289 ret = ds2781_read16(dev_info, &current_raw, DS2781_ACR_MSB); in ds2781_get_accumulated_current()
297 static int ds2781_get_capacity(struct ds2781_device_info *dev_info, in ds2781_get_capacity() argument
303 ret = ds2781_read8(dev_info, &raw, DS2781_RARC); in ds2781_get_capacity()
311 static int ds2781_get_status(struct ds2781_device_info *dev_info, int *status) in ds2781_get_status() argument
315 ret = ds2781_get_current(dev_info, CURRENT_NOW, &current_uA); in ds2781_get_status()
319 ret = ds2781_get_capacity(dev_info, &capacity); in ds2781_get_status()
323 if (power_supply_am_i_supplied(dev_info->bat)) { in ds2781_get_status()
336 static int ds2781_get_charge_now(struct ds2781_device_info *dev_info, in ds2781_get_charge_now() argument
350 ret = ds2781_read16(dev_info, &charge_raw, DS2781_RAAC_MSB); in ds2781_get_charge_now()
358 static int ds2781_get_control_register(struct ds2781_device_info *dev_info, in ds2781_get_control_register() argument
361 return ds2781_read8(dev_info, control_reg, DS2781_CONTROL); in ds2781_get_control_register()
364 static int ds2781_set_control_register(struct ds2781_device_info *dev_info, in ds2781_set_control_register() argument
369 ret = ds2781_write(dev_info, &control_reg, in ds2781_set_control_register()
374 return ds2781_save_eeprom(dev_info, DS2781_CONTROL); in ds2781_set_control_register()
382 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_battery_get_property() local
386 ret = ds2781_get_voltage(dev_info, &val->intval); in ds2781_battery_get_property()
390 ret = ds2781_get_temperature(dev_info, &val->intval); in ds2781_battery_get_property()
402 ret = ds2781_get_current(dev_info, CURRENT_NOW, &val->intval); in ds2781_battery_get_property()
406 ret = ds2781_get_current(dev_info, CURRENT_AVG, &val->intval); in ds2781_battery_get_property()
410 ret = ds2781_get_status(dev_info, &val->intval); in ds2781_battery_get_property()
414 ret = ds2781_get_capacity(dev_info, &val->intval); in ds2781_battery_get_property()
418 ret = ds2781_get_accumulated_current(dev_info, &val->intval); in ds2781_battery_get_property()
422 ret = ds2781_get_charge_now(dev_info, &val->intval); in ds2781_battery_get_property()
452 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_get_pmod_enabled() local
455 ret = ds2781_get_control_register(dev_info, &control_reg); in ds2781_get_pmod_enabled()
471 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_set_pmod_enabled() local
474 ret = ds2781_get_control_register(dev_info, &control_reg); in ds2781_set_pmod_enabled()
483 dev_err(dev_info->dev, "Invalid pmod setting (0 or 1)\n"); in ds2781_set_pmod_enabled()
492 ret = ds2781_set_control_register(dev_info, control_reg); in ds2781_set_pmod_enabled()
506 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_get_sense_resistor_value() local
508 ret = ds2781_read8(dev_info, &sense_resistor, DS2781_RSNSP); in ds2781_get_sense_resistor_value()
524 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_set_sense_resistor_value() local
530 ret = ds2781_set_sense_register(dev_info, new_setting); in ds2781_set_sense_resistor_value()
544 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_get_rsgain_setting() local
546 ret = ds2781_get_rsgain_register(dev_info, &rsgain); in ds2781_get_rsgain_setting()
561 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_set_rsgain_setting() local
569 dev_err(dev_info->dev, "Invalid rsgain setting (0 - 1999)\n"); in ds2781_set_rsgain_setting()
573 ret = ds2781_set_rsgain_register(dev_info, new_setting); in ds2781_set_rsgain_setting()
587 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_get_pio_pin() local
589 ret = ds2781_read8(dev_info, &sfr, DS2781_SFR); in ds2781_get_pio_pin()
605 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_set_pio_pin() local
612 dev_err(dev_info->dev, "Invalid pio_pin setting (0 or 1)\n"); in ds2781_set_pio_pin()
616 ret = ds2781_write(dev_info, &new_setting, in ds2781_set_pio_pin()
631 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_read_param_eeprom_bin() local
633 return ds2781_read_block(dev_info, buf, in ds2781_read_param_eeprom_bin()
644 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_write_param_eeprom_bin() local
647 ret = ds2781_write(dev_info, buf, in ds2781_write_param_eeprom_bin()
652 ret = ds2781_save_eeprom(dev_info, DS2781_EEPROM_BLOCK1_START); in ds2781_write_param_eeprom_bin()
676 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_read_user_eeprom_bin() local
678 return ds2781_read_block(dev_info, buf, in ds2781_read_user_eeprom_bin()
690 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); in ds2781_write_user_eeprom_bin() local
693 ret = ds2781_write(dev_info, buf, in ds2781_write_user_eeprom_bin()
698 ret = ds2781_save_eeprom(dev_info, DS2781_EEPROM_BLOCK0_START); in ds2781_write_user_eeprom_bin()
752 struct ds2781_device_info *dev_info; in ds2781_battery_probe() local
754 dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL); in ds2781_battery_probe()
755 if (!dev_info) in ds2781_battery_probe()
758 platform_set_drvdata(pdev, dev_info); in ds2781_battery_probe()
760 dev_info->dev = &pdev->dev; in ds2781_battery_probe()
761 dev_info->w1_dev = pdev->dev.parent; in ds2781_battery_probe()
762 dev_info->bat_desc.name = dev_name(&pdev->dev); in ds2781_battery_probe()
763 dev_info->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY; in ds2781_battery_probe()
764 dev_info->bat_desc.properties = ds2781_battery_props; in ds2781_battery_probe()
765 dev_info->bat_desc.num_properties = ARRAY_SIZE(ds2781_battery_props); in ds2781_battery_probe()
766 dev_info->bat_desc.get_property = ds2781_battery_get_property; in ds2781_battery_probe()
768 psy_cfg.drv_data = dev_info; in ds2781_battery_probe()
771 dev_info->bat = devm_power_supply_register(&pdev->dev, in ds2781_battery_probe()
772 &dev_info->bat_desc, in ds2781_battery_probe()
774 if (IS_ERR(dev_info->bat)) { in ds2781_battery_probe()
775 dev_err(dev_info->dev, "failed to register battery\n"); in ds2781_battery_probe()
776 return PTR_ERR(dev_info->bat); in ds2781_battery_probe()