Lines Matching +full:battery +full:- +full:temperature

1 // SPDX-License-Identifier: GPL-2.0-only
4 * h3xxx atmel micro companion support, battery subdevice
13 #include <linux/mfd/ipaq-micro.h>
32 #define MICRO_BATT_STATUS_DEAD 0x20 /* Battery will not charge */
34 #define MICRO_BATT_STATUS_FULL 0x40 /* Battery fully charged */
45 u16 temperature; member
60 /* First send battery message */ in micro_battery_work()
61 ipaq_micro_tx_msg_sync(mb->micro, &msg_battery); in micro_battery_work()
73 * byte 5-9: same for battery 2 in micro_battery_work()
75 mb->ac = msg_battery.rx_data[0]; in micro_battery_work()
76 mb->chemistry = msg_battery.rx_data[1]; in micro_battery_work()
77 mb->voltage = ((((unsigned short)msg_battery.rx_data[3] << 8) + in micro_battery_work()
79 mb->flag = msg_battery.rx_data[4]; in micro_battery_work()
82 pr_debug("second battery ignored\n"); in micro_battery_work()
85 ipaq_micro_tx_msg_sync(mb->micro, &msg_sensor); in micro_battery_work()
86 mb->temperature = msg_sensor.rx_data[1] << 8 | msg_sensor.rx_data[0]; in micro_battery_work()
88 queue_delayed_work(mb->wq, &mb->update, msecs_to_jiffies(BATT_PERIOD)); in micro_battery_work()
93 struct micro_battery *mb = dev_get_drvdata(b->dev.parent); in get_capacity()
95 switch (mb->flag & 0x07) { in get_capacity()
113 struct micro_battery *mb = dev_get_drvdata(b->dev.parent); in get_status()
115 if (mb->flag == MICRO_BATT_STATUS_UNKNOWN) in get_status()
118 if (mb->flag & MICRO_BATT_STATUS_FULL) in get_status()
121 if ((mb->flag & MICRO_BATT_STATUS_CHARGING) || in get_status()
122 (mb->flag & MICRO_BATT_STATUS_CHARGEMAIN)) in get_status()
132 struct micro_battery *mb = dev_get_drvdata(b->dev.parent); in micro_batt_get_property()
136 switch (mb->chemistry) { in micro_batt_get_property()
138 val->intval = POWER_SUPPLY_TECHNOLOGY_NiCd; in micro_batt_get_property()
141 val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH; in micro_batt_get_property()
144 val->intval = POWER_SUPPLY_TECHNOLOGY_LION; in micro_batt_get_property()
147 val->intval = POWER_SUPPLY_TECHNOLOGY_LIPO; in micro_batt_get_property()
150 val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; in micro_batt_get_property()
155 val->intval = get_status(b); in micro_batt_get_property()
158 val->intval = 4700000; in micro_batt_get_property()
161 val->intval = get_capacity(b); in micro_batt_get_property()
164 val->intval = mb->temperature; in micro_batt_get_property()
167 val->intval = mb->voltage; in micro_batt_get_property()
170 return -EINVAL; in micro_batt_get_property()
180 struct micro_battery *mb = dev_get_drvdata(b->dev.parent); in micro_ac_get_property()
184 val->intval = mb->ac; in micro_ac_get_property()
187 return -EINVAL; in micro_ac_get_property()
203 .name = "main-battery",
230 mb = devm_kzalloc(&pdev->dev, sizeof(*mb), GFP_KERNEL); in micro_batt_probe()
232 return -ENOMEM; in micro_batt_probe()
234 mb->micro = dev_get_drvdata(pdev->dev.parent); in micro_batt_probe()
235 mb->wq = alloc_workqueue("ipaq-battery-wq", WQ_MEM_RECLAIM, 0); in micro_batt_probe()
236 if (!mb->wq) in micro_batt_probe()
237 return -ENOMEM; in micro_batt_probe()
239 INIT_DELAYED_WORK(&mb->update, micro_battery_work); in micro_batt_probe()
241 queue_delayed_work(mb->wq, &mb->update, 1); in micro_batt_probe()
243 micro_batt_power = power_supply_register(&pdev->dev, in micro_batt_probe()
250 micro_ac_power = power_supply_register(&pdev->dev, in micro_batt_probe()
257 dev_info(&pdev->dev, "iPAQ micro battery driver\n"); in micro_batt_probe()
263 cancel_delayed_work_sync(&mb->update); in micro_batt_probe()
264 destroy_workqueue(mb->wq); in micro_batt_probe()
275 cancel_delayed_work_sync(&mb->update); in micro_batt_remove()
276 destroy_workqueue(mb->wq); in micro_batt_remove()
283 cancel_delayed_work_sync(&mb->update); in micro_batt_suspend()
291 queue_delayed_work(mb->wq, &mb->update, msecs_to_jiffies(BATT_PERIOD)); in micro_batt_resume()
301 .name = "ipaq-micro-battery",
310 MODULE_DESCRIPTION("driver for iPAQ Atmel micro battery");
311 MODULE_ALIAS("platform:ipaq-micro-battery");