Lines Matching refs:dev_info
55 static inline int ds2780_battery_io(struct ds2780_device_info *dev_info, in ds2780_battery_io() argument
58 return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io); in ds2780_battery_io()
61 static inline int ds2780_read8(struct ds2780_device_info *dev_info, u8 *val, in ds2780_read8() argument
64 return ds2780_battery_io(dev_info, val, addr, sizeof(u8), 0); in ds2780_read8()
67 static int ds2780_read16(struct ds2780_device_info *dev_info, s16 *val, in ds2780_read16() argument
73 ret = ds2780_battery_io(dev_info, raw, addr, sizeof(raw), 0); in ds2780_read16()
82 static inline int ds2780_read_block(struct ds2780_device_info *dev_info, in ds2780_read_block() argument
85 return ds2780_battery_io(dev_info, val, addr, count, 0); in ds2780_read_block()
88 static inline int ds2780_write(struct ds2780_device_info *dev_info, u8 *val, in ds2780_write() argument
91 return ds2780_battery_io(dev_info, val, addr, count, 1); in ds2780_write()
104 static int ds2780_save_eeprom(struct ds2780_device_info *dev_info, int reg) in ds2780_save_eeprom() argument
108 ret = ds2780_store_eeprom(dev_info->w1_dev, reg); in ds2780_save_eeprom()
112 ret = ds2780_recall_eeprom(dev_info->w1_dev, reg); in ds2780_save_eeprom()
120 static int ds2780_set_sense_register(struct ds2780_device_info *dev_info, in ds2780_set_sense_register() argument
125 ret = ds2780_write(dev_info, &conductance, in ds2780_set_sense_register()
130 return ds2780_save_eeprom(dev_info, DS2780_RSNSP_REG); in ds2780_set_sense_register()
134 static int ds2780_get_rsgain_register(struct ds2780_device_info *dev_info, in ds2780_get_rsgain_register() argument
137 return ds2780_read16(dev_info, rsgain, DS2780_RSGAIN_MSB_REG); in ds2780_get_rsgain_register()
141 static int ds2780_set_rsgain_register(struct ds2780_device_info *dev_info, in ds2780_set_rsgain_register() argument
147 ret = ds2780_write(dev_info, raw, in ds2780_set_rsgain_register()
152 return ds2780_save_eeprom(dev_info, DS2780_RSGAIN_MSB_REG); in ds2780_set_rsgain_register()
155 static int ds2780_get_voltage(struct ds2780_device_info *dev_info, in ds2780_get_voltage() argument
170 ret = ds2780_read16(dev_info, &voltage_raw, in ds2780_get_voltage()
183 static int ds2780_get_temperature(struct ds2780_device_info *dev_info, in ds2780_get_temperature() argument
199 ret = ds2780_read16(dev_info, &temperature_raw, in ds2780_get_temperature()
214 static int ds2780_get_current(struct ds2780_device_info *dev_info, in ds2780_get_current() argument
225 ret = ds2780_read8(dev_info, &sense_res_raw, DS2780_RSNSP_REG); in ds2780_get_current()
230 dev_err(dev_info->dev, "sense resistor value is 0\n"); in ds2780_get_current()
251 ret = ds2780_read16(dev_info, ¤t_raw, reg_msb); in ds2780_get_current()
259 static int ds2780_get_accumulated_current(struct ds2780_device_info *dev_info, in ds2780_get_accumulated_current() argument
270 ret = ds2780_read8(dev_info, &sense_res_raw, DS2780_RSNSP_REG); in ds2780_get_accumulated_current()
275 dev_err(dev_info->dev, "sense resistor value is 0\n"); in ds2780_get_accumulated_current()
288 ret = ds2780_read16(dev_info, ¤t_raw, DS2780_ACR_MSB_REG); in ds2780_get_accumulated_current()
296 static int ds2780_get_capacity(struct ds2780_device_info *dev_info, in ds2780_get_capacity() argument
302 ret = ds2780_read8(dev_info, &raw, DS2780_RARC_REG); in ds2780_get_capacity()
310 static int ds2780_get_status(struct ds2780_device_info *dev_info, int *status) in ds2780_get_status() argument
314 ret = ds2780_get_current(dev_info, CURRENT_NOW, ¤t_uA); in ds2780_get_status()
318 ret = ds2780_get_capacity(dev_info, &capacity); in ds2780_get_status()
334 static int ds2780_get_charge_now(struct ds2780_device_info *dev_info, in ds2780_get_charge_now() argument
348 ret = ds2780_read16(dev_info, &charge_raw, DS2780_RAAC_MSB_REG); in ds2780_get_charge_now()
356 static int ds2780_get_control_register(struct ds2780_device_info *dev_info, in ds2780_get_control_register() argument
359 return ds2780_read8(dev_info, control_reg, DS2780_CONTROL_REG); in ds2780_get_control_register()
362 static int ds2780_set_control_register(struct ds2780_device_info *dev_info, in ds2780_set_control_register() argument
367 ret = ds2780_write(dev_info, &control_reg, in ds2780_set_control_register()
372 return ds2780_save_eeprom(dev_info, DS2780_CONTROL_REG); in ds2780_set_control_register()
380 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_battery_get_property() local
384 ret = ds2780_get_voltage(dev_info, &val->intval); in ds2780_battery_get_property()
388 ret = ds2780_get_temperature(dev_info, &val->intval); in ds2780_battery_get_property()
400 ret = ds2780_get_current(dev_info, CURRENT_NOW, &val->intval); in ds2780_battery_get_property()
404 ret = ds2780_get_current(dev_info, CURRENT_AVG, &val->intval); in ds2780_battery_get_property()
408 ret = ds2780_get_status(dev_info, &val->intval); in ds2780_battery_get_property()
412 ret = ds2780_get_capacity(dev_info, &val->intval); in ds2780_battery_get_property()
416 ret = ds2780_get_accumulated_current(dev_info, &val->intval); in ds2780_battery_get_property()
420 ret = ds2780_get_charge_now(dev_info, &val->intval); in ds2780_battery_get_property()
450 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_get_pmod_enabled() local
453 ret = ds2780_get_control_register(dev_info, &control_reg); in ds2780_get_pmod_enabled()
469 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_set_pmod_enabled() local
472 ret = ds2780_get_control_register(dev_info, &control_reg); in ds2780_set_pmod_enabled()
481 dev_err(dev_info->dev, "Invalid pmod setting (0 or 1)\n"); in ds2780_set_pmod_enabled()
490 ret = ds2780_set_control_register(dev_info, control_reg); in ds2780_set_pmod_enabled()
504 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_get_sense_resistor_value() local
506 ret = ds2780_read8(dev_info, &sense_resistor, DS2780_RSNSP_REG); in ds2780_get_sense_resistor_value()
522 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_set_sense_resistor_value() local
528 ret = ds2780_set_sense_register(dev_info, new_setting); in ds2780_set_sense_resistor_value()
542 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_get_rsgain_setting() local
544 ret = ds2780_get_rsgain_register(dev_info, &rsgain); in ds2780_get_rsgain_setting()
559 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_set_rsgain_setting() local
567 dev_err(dev_info->dev, "Invalid rsgain setting (0 - 1999)\n"); in ds2780_set_rsgain_setting()
571 ret = ds2780_set_rsgain_register(dev_info, new_setting); in ds2780_set_rsgain_setting()
585 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_get_pio_pin() local
587 ret = ds2780_read8(dev_info, &sfr, DS2780_SFR_REG); in ds2780_get_pio_pin()
603 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_set_pio_pin() local
610 dev_err(dev_info->dev, "Invalid pio_pin setting (0 or 1)\n"); in ds2780_set_pio_pin()
614 ret = ds2780_write(dev_info, &new_setting, in ds2780_set_pio_pin()
629 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_read_param_eeprom_bin() local
631 return ds2780_read_block(dev_info, buf, in ds2780_read_param_eeprom_bin()
642 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_write_param_eeprom_bin() local
645 ret = ds2780_write(dev_info, buf, in ds2780_write_param_eeprom_bin()
650 ret = ds2780_save_eeprom(dev_info, DS2780_EEPROM_BLOCK1_START); in ds2780_write_param_eeprom_bin()
674 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_read_user_eeprom_bin() local
676 return ds2780_read_block(dev_info, buf, in ds2780_read_user_eeprom_bin()
687 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); in ds2780_write_user_eeprom_bin() local
690 ret = ds2780_write(dev_info, buf, in ds2780_write_user_eeprom_bin()
695 ret = ds2780_save_eeprom(dev_info, DS2780_EEPROM_BLOCK0_START); in ds2780_write_user_eeprom_bin()
748 struct ds2780_device_info *dev_info; in ds2780_battery_probe() local
750 dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL); in ds2780_battery_probe()
751 if (!dev_info) in ds2780_battery_probe()
754 platform_set_drvdata(pdev, dev_info); in ds2780_battery_probe()
756 dev_info->dev = &pdev->dev; in ds2780_battery_probe()
757 dev_info->w1_dev = pdev->dev.parent; in ds2780_battery_probe()
758 dev_info->bat_desc.name = dev_name(&pdev->dev); in ds2780_battery_probe()
759 dev_info->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY; in ds2780_battery_probe()
760 dev_info->bat_desc.properties = ds2780_battery_props; in ds2780_battery_probe()
761 dev_info->bat_desc.num_properties = ARRAY_SIZE(ds2780_battery_props); in ds2780_battery_probe()
762 dev_info->bat_desc.get_property = ds2780_battery_get_property; in ds2780_battery_probe()
764 psy_cfg.drv_data = dev_info; in ds2780_battery_probe()
767 dev_info->bat = devm_power_supply_register(&pdev->dev, in ds2780_battery_probe()
768 &dev_info->bat_desc, in ds2780_battery_probe()
770 if (IS_ERR(dev_info->bat)) { in ds2780_battery_probe()
771 dev_err(dev_info->dev, "failed to register battery\n"); in ds2780_battery_probe()
772 return PTR_ERR(dev_info->bat); in ds2780_battery_probe()