Lines Matching refs:sbs
57 struct acpi_sbs *sbs; member
135 struct acpi_sbs *sbs = to_acpi_sbs(psy); in sbs_get_ac_property() local
138 val->intval = sbs->charger_present; in sbs_get_ac_property()
327 static int acpi_manager_get_info(struct acpi_sbs *sbs) in acpi_manager_get_info() argument
332 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER, in acpi_manager_get_info()
335 sbs->batteries_supported = battery_system_info & 0x000f; in acpi_manager_get_info()
344 result = acpi_smbus_read(battery->sbs->hc, in acpi_battery_get_info()
365 result = acpi_smbus_read(battery->sbs->hc, in acpi_battery_get_state()
381 return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, in acpi_battery_get_alarm()
388 struct acpi_sbs *sbs = battery->sbs; in acpi_battery_set_alarm() local
394 if (sbs->manager_present) { in acpi_battery_set_alarm()
395 ret = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER, in acpi_battery_set_alarm()
402 ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, in acpi_battery_set_alarm()
409 ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ACPI_SBS_BATTERY, in acpi_battery_set_alarm()
415 static int acpi_ac_get_present(struct acpi_sbs *sbs) in acpi_ac_get_present() argument
420 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_CHARGER, in acpi_ac_get_present()
437 sbs->charger_present = (status >> 15) & 0x1; in acpi_ac_get_present()
479 if (battery->sbs->manager_present) { in acpi_battery_read()
480 result = acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, in acpi_battery_read()
492 acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD, in acpi_battery_read()
518 static int acpi_battery_add(struct acpi_sbs *sbs, int id) in acpi_battery_add() argument
520 struct acpi_battery *battery = &sbs->battery[id]; in acpi_battery_add()
525 battery->sbs = sbs; in acpi_battery_add()
543 battery->bat = power_supply_register(&sbs->device->dev, in acpi_battery_add()
557 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), in acpi_battery_add()
562 static void acpi_battery_remove(struct acpi_sbs *sbs, int id) in acpi_battery_remove() argument
564 struct acpi_battery *battery = &sbs->battery[id]; in acpi_battery_remove()
573 static int acpi_charger_add(struct acpi_sbs *sbs) in acpi_charger_add() argument
576 struct power_supply_config psy_cfg = { .drv_data = sbs, }; in acpi_charger_add()
578 result = acpi_ac_get_present(sbs); in acpi_charger_add()
582 sbs->charger_exists = 1; in acpi_charger_add()
583 sbs->charger = power_supply_register(&sbs->device->dev, in acpi_charger_add()
585 if (IS_ERR(sbs->charger)) { in acpi_charger_add()
586 result = PTR_ERR(sbs->charger); in acpi_charger_add()
587 sbs->charger = NULL; in acpi_charger_add()
590 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), in acpi_charger_add()
591 ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); in acpi_charger_add()
596 static void acpi_charger_remove(struct acpi_sbs *sbs) in acpi_charger_remove() argument
598 if (sbs->charger) in acpi_charger_remove()
599 power_supply_unregister(sbs->charger); in acpi_charger_remove()
605 struct acpi_sbs *sbs = context; in acpi_sbs_callback() local
607 u8 saved_charger_state = sbs->charger_present; in acpi_sbs_callback()
610 if (sbs->charger_exists) { in acpi_sbs_callback()
611 acpi_ac_get_present(sbs); in acpi_sbs_callback()
612 if (sbs->charger_present != saved_charger_state) in acpi_sbs_callback()
613 kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE); in acpi_sbs_callback()
616 if (sbs->manager_present) { in acpi_sbs_callback()
618 if (!(sbs->batteries_supported & (1 << id))) in acpi_sbs_callback()
620 bat = &sbs->battery[id]; in acpi_sbs_callback()
632 struct acpi_sbs *sbs; in acpi_sbs_add() local
636 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); in acpi_sbs_add()
637 if (!sbs) { in acpi_sbs_add()
642 mutex_init(&sbs->lock); in acpi_sbs_add()
644 sbs->hc = acpi_driver_data(acpi_dev_parent(device)); in acpi_sbs_add()
645 sbs->device = device; in acpi_sbs_add()
648 device->driver_data = sbs; in acpi_sbs_add()
650 result = acpi_charger_add(sbs); in acpi_sbs_add()
657 result = acpi_manager_get_info(sbs); in acpi_sbs_add()
659 sbs->manager_present = 1; in acpi_sbs_add()
661 if ((sbs->batteries_supported & (1 << id))) in acpi_sbs_add()
662 acpi_battery_add(sbs, id); in acpi_sbs_add()
666 if (!sbs->manager_present) in acpi_sbs_add()
667 acpi_battery_add(sbs, 0); in acpi_sbs_add()
669 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs); in acpi_sbs_add()
678 struct acpi_sbs *sbs; in acpi_sbs_remove() local
683 sbs = acpi_driver_data(device); in acpi_sbs_remove()
684 if (!sbs) in acpi_sbs_remove()
686 mutex_lock(&sbs->lock); in acpi_sbs_remove()
687 acpi_smbus_unregister_callback(sbs->hc); in acpi_sbs_remove()
689 acpi_battery_remove(sbs, id); in acpi_sbs_remove()
690 acpi_charger_remove(sbs); in acpi_sbs_remove()
691 mutex_unlock(&sbs->lock); in acpi_sbs_remove()
692 mutex_destroy(&sbs->lock); in acpi_sbs_remove()
693 kfree(sbs); in acpi_sbs_remove()
699 struct acpi_sbs *sbs; in acpi_sbs_resume() local
702 sbs = to_acpi_device(dev)->driver_data; in acpi_sbs_resume()
703 acpi_sbs_callback(sbs); in acpi_sbs_resume()