Lines Matching +full:- +full:75 +full:mv

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright © 2006-2010 David Woodhouse <dwmw2@infradead.org>
19 #include <linux/olpc-ec.h>
22 #define EC_BAT_VOLTAGE 0x10 /* uint16_t, *9.76/32, mV */
77 val->intval = !!(status & BAT_STAT_AC); in olpc_ac_get_prop()
80 ret = -EINVAL; in olpc_ac_get_prop()
101 if (data->new_proto) { in olpc_bat_get_status()
103 val->intval = POWER_SUPPLY_STATUS_CHARGING; in olpc_bat_get_status()
105 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in olpc_bat_get_status()
107 val->intval = POWER_SUPPLY_STATUS_FULL; in olpc_bat_get_status()
109 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in olpc_bat_get_status()
113 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in olpc_bat_get_status()
115 val->intval = POWER_SUPPLY_STATUS_FULL; in olpc_bat_get_status()
117 val->intval = POWER_SUPPLY_STATUS_CHARGING; in olpc_bat_get_status()
134 val->intval = POWER_SUPPLY_HEALTH_GOOD; in olpc_bat_get_health()
138 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; in olpc_bat_get_health()
142 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; in olpc_bat_get_health()
149 val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; in olpc_bat_get_health()
154 ret = -EIO; in olpc_bat_get_health()
172 val->strval = "Gold Peak"; in olpc_bat_get_mfr()
175 val->strval = "BYD"; in olpc_bat_get_mfr()
178 val->strval = "Unknown"; in olpc_bat_get_mfr()
197 val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH; in olpc_bat_get_tech()
200 val->intval = POWER_SUPPLY_TECHNOLOGY_LiFe; in olpc_bat_get_tech()
203 val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; in olpc_bat_get_tech()
231 val->intval = 3000000*.8; in olpc_bat_get_charge_full_design()
234 return -EIO; in olpc_bat_get_charge_full_design()
242 val->intval = 2800000; in olpc_bat_get_charge_full_design()
245 return -EIO; in olpc_bat_get_charge_full_design()
250 return -EIO; in olpc_bat_get_charge_full_design()
270 val->intval = soc * (full.intval / 100); in olpc_bat_get_charge_now()
296 val->intval = 6000000; in olpc_bat_get_voltage_max_design()
299 return -EIO; in olpc_bat_get_voltage_max_design()
306 val->intval = 6400000; in olpc_bat_get_voltage_max_design()
309 val->intval = 6500000; in olpc_bat_get_voltage_max_design()
312 return -EIO; in olpc_bat_get_voltage_max_design()
317 return -EIO; in olpc_bat_get_voltage_max_design()
325 if (data->little_endian) in ecword_to_cpu()
348 /* Theoretically there's a race here -- the battery could be in olpc_bat_get_property()
350 then we query for some other property of the now-absent battery. in olpc_bat_get_property()
351 It doesn't matter though -- the EC will return the last-known in olpc_bat_get_property()
356 return -ENODEV; in olpc_bat_get_property()
366 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; in olpc_bat_get_property()
368 val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; in olpc_bat_get_property()
370 val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; in olpc_bat_get_property()
373 val->intval = !!(ec_byte & (BAT_STAT_PRESENT | in olpc_bat_get_property()
379 val->intval = POWER_SUPPLY_HEALTH_DEAD; in olpc_bat_get_property()
403 val->intval = ecword_to_cpu(data, ec_word) * 9760L / 32; in olpc_bat_get_property()
411 val->intval = ecword_to_cpu(data, ec_word) * 15625L / 120; in olpc_bat_get_property()
417 val->intval = ec_byte; in olpc_bat_get_property()
421 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL; in olpc_bat_get_property()
423 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW; in olpc_bat_get_property()
425 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; in olpc_bat_get_property()
442 val->intval = ecword_to_cpu(data, ec_word) * 10 / 256; in olpc_bat_get_property()
449 val->intval = (int)ecword_to_cpu(data, ec_word) * 10 / 256; in olpc_bat_get_property()
456 val->intval = ecword_to_cpu(data, ec_word) * 6250 / 15; in olpc_bat_get_property()
463 sprintf(data->bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); in olpc_bat_get_property()
464 val->strval = data->bat_serial; in olpc_bat_get_property()
472 ret = -EINVAL; in olpc_bat_get_property()
501 /* XO-1.5 does not have ambient temperature property */
527 #define EEPROM_SIZE (EEPROM_END - EEPROM_START)
540 pr_err("olpc-battery: " in olpc_bat_eeprom_read()
541 "EC_BAT_EEPROM cmd @ 0x%x failed - %d!\n", in olpc_bat_eeprom_read()
543 return -EIO; in olpc_bat_eeprom_read()
618 if (device_may_wakeup(&data->olpc_ac->dev)) in olpc_battery_suspend()
623 if (device_may_wakeup(&data->olpc_bat->dev)) in olpc_battery_suspend()
643 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in olpc_battery_probe()
645 return -ENOMEM; in olpc_battery_probe()
653 np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec"); in olpc_battery_probe()
657 data->new_proto = true; in olpc_battery_probe()
658 data->little_endian = true; in olpc_battery_probe()
661 data->new_proto = true; in olpc_battery_probe()
669 return -ENXIO; in olpc_battery_probe()
678 ac_psy_cfg.of_node = pdev->dev.of_node; in olpc_battery_probe()
681 data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc, in olpc_battery_probe()
683 if (IS_ERR(data->olpc_ac)) in olpc_battery_probe()
684 return PTR_ERR(data->olpc_ac); in olpc_battery_probe()
686 if (of_device_is_compatible(pdev->dev.of_node, "olpc,xo1.5-battery")) { in olpc_battery_probe()
687 /* XO-1.5 */ in olpc_battery_probe()
691 /* XO-1 */ in olpc_battery_probe()
696 bat_psy_cfg.of_node = pdev->dev.of_node; in olpc_battery_probe()
700 data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc, in olpc_battery_probe()
702 if (IS_ERR(data->olpc_bat)) in olpc_battery_probe()
703 return PTR_ERR(data->olpc_bat); in olpc_battery_probe()
706 device_set_wakeup_capable(&data->olpc_ac->dev, true); in olpc_battery_probe()
707 device_set_wakeup_capable(&data->olpc_bat->dev, true); in olpc_battery_probe()
714 { .compatible = "olpc,xo1-battery" },
715 { .compatible = "olpc,xo1.5-battery" },
722 .name = "olpc-battery",