Lines Matching refs:bat
28 struct ingenic_battery *bat = power_supply_get_drvdata(psy); in ingenic_battery_get_property() local
29 struct power_supply_battery_info *info = &bat->info; in ingenic_battery_get_property()
34 ret = iio_read_channel_processed(bat->channel, &val->intval); in ingenic_battery_get_property()
44 ret = iio_read_channel_processed(bat->channel, &val->intval); in ingenic_battery_get_property()
61 static int ingenic_battery_set_scale(struct ingenic_battery *bat) in ingenic_battery_set_scale() argument
67 ret = iio_read_max_channel_raw(bat->channel, &max_raw); in ingenic_battery_set_scale()
69 dev_err(bat->dev, "Unable to read max raw channel value\n"); in ingenic_battery_set_scale()
73 ret = iio_read_avail_channel_attribute(bat->channel, &scale_raw, in ingenic_battery_set_scale()
77 dev_err(bat->dev, "Unable to read channel avail scale\n"); in ingenic_battery_set_scale()
83 max_mV = bat->info.voltage_max_design_uv / 1000; in ingenic_battery_set_scale()
99 dev_err(bat->dev, "Unable to find matching voltage scale\n"); in ingenic_battery_set_scale()
105 ret = iio_write_channel_attribute(bat->channel, in ingenic_battery_set_scale()
126 struct ingenic_battery *bat; in ingenic_battery_probe() local
131 bat = devm_kzalloc(dev, sizeof(*bat), GFP_KERNEL); in ingenic_battery_probe()
132 if (!bat) in ingenic_battery_probe()
135 bat->dev = dev; in ingenic_battery_probe()
136 bat->channel = devm_iio_channel_get(dev, "battery"); in ingenic_battery_probe()
137 if (IS_ERR(bat->channel)) in ingenic_battery_probe()
138 return PTR_ERR(bat->channel); in ingenic_battery_probe()
140 desc = &bat->desc; in ingenic_battery_probe()
146 psy_cfg.drv_data = bat; in ingenic_battery_probe()
149 bat->battery = devm_power_supply_register(dev, desc, &psy_cfg); in ingenic_battery_probe()
150 if (IS_ERR(bat->battery)) in ingenic_battery_probe()
151 return dev_err_probe(dev, PTR_ERR(bat->battery), in ingenic_battery_probe()
154 ret = power_supply_get_battery_info(bat->battery, &bat->info); in ingenic_battery_probe()
159 if (bat->info.voltage_min_design_uv < 0) { in ingenic_battery_probe()
161 return bat->info.voltage_min_design_uv; in ingenic_battery_probe()
163 if (bat->info.voltage_max_design_uv < 0) { in ingenic_battery_probe()
165 return bat->info.voltage_max_design_uv; in ingenic_battery_probe()
168 return ingenic_battery_set_scale(bat); in ingenic_battery_probe()