Lines Matching full:ac
3 * acpi_ac.c - ACPI AC Adapter Driver ($Revision: 27 $)
24 #define ACPI_AC_DEVICE_NAME "AC Adapter"
32 ACPI_MODULE_NAME("ac");
35 MODULE_DESCRIPTION("ACPI AC Adapter Driver");
69 .name = "ac",
92 AC Adapter Management
95 static int acpi_ac_get_state(struct acpi_ac *ac) in acpi_ac_get_state() argument
99 if (!ac) in acpi_ac_get_state()
102 status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, in acpi_ac_get_state()
103 &ac->state); in acpi_ac_get_state()
106 "Error reading AC Adapter state")); in acpi_ac_get_state()
107 ac->state = ACPI_AC_STATUS_UNKNOWN; in acpi_ac_get_state()
121 struct acpi_ac *ac = to_acpi_ac(psy); in get_ac_property() local
123 if (!ac) in get_ac_property()
126 if (acpi_ac_get_state(ac)) in get_ac_property()
131 val->intval = ac->state; in get_ac_property()
149 struct acpi_ac *ac = acpi_driver_data(device); in acpi_ac_notify() local
151 if (!ac) in acpi_ac_notify()
163 * A buggy BIOS may notify AC first and then sleep for in acpi_ac_notify()
165 * EC event handler (_Qxx). This will cause the AC state in acpi_ac_notify()
172 acpi_ac_get_state(ac); in acpi_ac_notify()
175 (u32) ac->state); in acpi_ac_notify()
176 acpi_notifier_call_chain(device, event, (u32) ac->state); in acpi_ac_notify()
177 kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE); in acpi_ac_notify()
186 struct acpi_ac *ac = container_of(nb, struct acpi_ac, battery_nb); in acpi_ac_battery_notify() local
190 * On HP Pavilion dv6-6179er AC status notifications aren't triggered in acpi_ac_battery_notify()
193 * discharging. Re-reading AC status triggers lost AC notifications, in acpi_ac_battery_notify()
194 * if AC status has changed. in acpi_ac_battery_notify()
198 acpi_ac_get_state(ac); in acpi_ac_battery_notify()
248 struct acpi_ac *ac = NULL; in acpi_ac_add() local
254 ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); in acpi_ac_add()
255 if (!ac) in acpi_ac_add()
258 ac->device = device; in acpi_ac_add()
261 device->driver_data = ac; in acpi_ac_add()
263 result = acpi_ac_get_state(ac); in acpi_ac_add()
267 psy_cfg.drv_data = ac; in acpi_ac_add()
269 ac->charger_desc.name = acpi_device_bid(device); in acpi_ac_add()
270 ac->charger_desc.type = POWER_SUPPLY_TYPE_MAINS; in acpi_ac_add()
271 ac->charger_desc.properties = ac_props; in acpi_ac_add()
272 ac->charger_desc.num_properties = ARRAY_SIZE(ac_props); in acpi_ac_add()
273 ac->charger_desc.get_property = get_ac_property; in acpi_ac_add()
274 ac->charger = power_supply_register(&ac->device->dev, in acpi_ac_add()
275 &ac->charger_desc, &psy_cfg); in acpi_ac_add()
276 if (IS_ERR(ac->charger)) { in acpi_ac_add()
277 result = PTR_ERR(ac->charger); in acpi_ac_add()
283 ac->state ? "on-line" : "off-line"); in acpi_ac_add()
285 ac->battery_nb.notifier_call = acpi_ac_battery_notify; in acpi_ac_add()
286 register_acpi_notifier(&ac->battery_nb); in acpi_ac_add()
289 kfree(ac); in acpi_ac_add()
298 struct acpi_ac *ac; in acpi_ac_resume() local
304 ac = acpi_driver_data(to_acpi_device(dev)); in acpi_ac_resume()
305 if (!ac) in acpi_ac_resume()
308 old_state = ac->state; in acpi_ac_resume()
309 if (acpi_ac_get_state(ac)) in acpi_ac_resume()
311 if (old_state != ac->state) in acpi_ac_resume()
312 kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE); in acpi_ac_resume()
321 struct acpi_ac *ac = NULL; in acpi_ac_remove() local
327 ac = acpi_driver_data(device); in acpi_ac_remove()
329 power_supply_unregister(ac->charger); in acpi_ac_remove()
330 unregister_acpi_notifier(&ac->battery_nb); in acpi_ac_remove()
332 kfree(ac); in acpi_ac_remove()
351 pr_info(PREFIX "AC: found native %s PMIC, not loading\n", in acpi_ac_init()