drivers/power/supply/ab8500_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/ab8500_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/ab8500_charger.c- Extension
.c- Size
- 105215 bytes
- Lines
- 3754
- Domain
- Driver Families
- Bucket
- drivers/power
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/module.hlinux/device.hlinux/component.hlinux/interrupt.hlinux/delay.hlinux/notifier.hlinux/slab.hlinux/platform_device.hlinux/power_supply.hlinux/completion.hlinux/regulator/consumer.hlinux/err.hlinux/workqueue.hlinux/kobject.hlinux/of.hlinux/mfd/core.hlinux/mfd/abx500/ab8500.hlinux/mfd/abx500.hlinux/usb/otg.hlinux/mutex.hlinux/iio/consumer.hab8500-bm.hab8500-chargalg.h
Detected Declarations
struct ab8500_charger_interruptsstruct ab8500_charger_infostruct ab8500_charger_event_flagsstruct ab8500_charger_usb_statestruct ab8500_charger_max_usb_in_currstruct ab8500_chargerenum ab8500_charger_link_statusenum ab8500_usb_statefunction ab8500_enable_disable_sw_fallbackfunction ab8500_power_supply_changedfunction ab8500_charger_set_usb_connectedfunction ab8500_charger_get_ac_voltagefunction ab8500_charger_ac_cvfunction ab8500_charger_get_vbus_voltagefunction ab8500_charger_get_usb_currentfunction ab8500_charger_get_ac_currentfunction ab8500_charger_usb_cvfunction ab8500_charger_detect_chargersfunction ab8500_charger_max_usb_currfunction ab8500_charger_read_usb_typefunction ab8500_charger_detect_usb_typefunction ab8500_voltage_to_regvalfunction ab8500_current_to_regvalfunction ab8500_vbus_in_curr_to_regvalfunction ab8500_charger_get_usb_curfunction ab8500_charger_check_continue_steppingfunction ab8500_charger_set_currentfunction ab8500_charger_set_vbus_in_currfunction ab8500_charger_set_main_in_currfunction ab8500_charger_set_output_currfunction ab8500_charger_led_enfunction ab8500_charger_ac_enfunction ab8500_charger_usb_enfunction ab8500_charger_usb_check_enablefunction ab8500_charger_ac_check_enablefunction ab8500_charger_watchdog_kickfunction ab8500_charger_update_charger_currentfunction ab8500_charger_get_ext_psy_datafunction ab8500_charger_check_vbat_workfunction ab8500_charger_check_hw_failure_workfunction ab8500_charger_kick_watchdog_workfunction ab8500_charger_ac_workfunction ab8500_charger_usb_attached_workfunction ab8500_charger_ac_attached_workfunction ab8500_charger_detect_usb_type_workfunction ab8500_charger_usb_link_attach_workfunction ab8500_charger_usb_link_status_workfunction ab8500_charger_usb_state_changed_work
Annotated Snippet
struct device_driver *drv = &ab8500_charger_component_drivers[i]->driver;
struct device *p = NULL, *d;
while ((d = platform_find_device_by_driver(p, drv))) {
put_device(p);
component_match_add(dev, &match, component_compare_dev, d);
p = d;
}
put_device(p);
}
if (!match) {
dev_err(dev, "no matching components\n");
ret = -ENODEV;
goto remove_ab8500_bm;
}
if (IS_ERR(match)) {
dev_err(dev, "could not create component match\n");
ret = PTR_ERR(match);
goto remove_ab8500_bm;
}
di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (IS_ERR_OR_NULL(di->usb_phy)) {
dev_err(dev, "failed to get usb transceiver\n");
ret = -EINVAL;
goto remove_ab8500_bm;
}
di->nb.notifier_call = ab8500_charger_usb_notifier_call;
ret = usb_register_notifier(di->usb_phy, &di->nb);
if (ret) {
dev_err(dev, "failed to register usb notifier\n");
goto put_usb_phy;
}
ret = component_master_add_with_match(&pdev->dev,
&ab8500_charger_comp_ops,
match);
if (ret) {
dev_err(dev, "failed to add component master\n");
goto free_notifier;
}
return 0;
free_notifier:
usb_unregister_notifier(di->usb_phy, &di->nb);
put_usb_phy:
usb_put_phy(di->usb_phy);
remove_ab8500_bm:
ab8500_bm_of_remove(di->usb_chg.psy, di->bm);
return ret;
}
static void ab8500_charger_remove(struct platform_device *pdev)
{
struct ab8500_charger *di = platform_get_drvdata(pdev);
component_master_del(&pdev->dev, &ab8500_charger_comp_ops);
usb_unregister_notifier(di->usb_phy, &di->nb);
ab8500_bm_of_remove(di->usb_chg.psy, di->bm);
usb_put_phy(di->usb_phy);
}
static SIMPLE_DEV_PM_OPS(ab8500_charger_pm_ops, ab8500_charger_suspend, ab8500_charger_resume);
static const struct of_device_id ab8500_charger_match[] = {
{ .compatible = "stericsson,ab8500-charger", },
{ },
};
MODULE_DEVICE_TABLE(of, ab8500_charger_match);
static struct platform_driver ab8500_charger_driver = {
.probe = ab8500_charger_probe,
.remove = ab8500_charger_remove,
.driver = {
.name = "ab8500-charger",
.of_match_table = ab8500_charger_match,
.pm = &ab8500_charger_pm_ops,
},
};
static int __init ab8500_charger_init(void)
{
int ret;
ret = platform_register_drivers(ab8500_charger_component_drivers,
ARRAY_SIZE(ab8500_charger_component_drivers));
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/device.h`, `linux/component.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/notifier.h`, `linux/slab.h`.
- Detected declarations: `struct ab8500_charger_interrupts`, `struct ab8500_charger_info`, `struct ab8500_charger_event_flags`, `struct ab8500_charger_usb_state`, `struct ab8500_charger_max_usb_in_curr`, `struct ab8500_charger`, `enum ab8500_charger_link_status`, `enum ab8500_usb_state`, `function ab8500_enable_disable_sw_fallback`, `function ab8500_power_supply_changed`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.