drivers/power/supply/ab8500_btemp.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/ab8500_btemp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/ab8500_btemp.c- Extension
.c- Size
- 22217 bytes
- Lines
- 832
- Domain
- Driver Families
- Bucket
- drivers/power
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/slab.hlinux/platform_device.hlinux/power_supply.hlinux/completion.hlinux/workqueue.hlinux/jiffies.hlinux/of.hlinux/mfd/core.hlinux/mfd/abx500.hlinux/mfd/abx500/ab8500.hlinux/thermal.hlinux/iio/consumer.hlinux/fixp-arith.hab8500-bm.h
Detected Declarations
struct ab8500_btemp_interruptsstruct ab8500_btemp_eventsstruct ab8500_btemp_rangesstruct ab8500_btempfunction ab8500_btemp_batctrl_volt_to_resfunction ab8500_btemp_read_batctrl_voltagefunction ab8500_btemp_get_batctrl_resfunction ab8500_btemp_idfunction ab8500_btemp_periodic_workfunction ab8500_btemp_batctrlindb_handlerfunction ab8500_btemp_templow_handlerfunction ab8500_btemp_temphigh_handlerfunction ab8500_btemp_lowmed_handlerfunction ab8500_btemp_medhigh_handlerfunction ab8500_btemp_periodicfunction ab8500_btemp_get_tempfunction ab8500_btemp_get_propertyfunction ab8500_btemp_get_ext_psy_datafunction ab8500_btemp_external_power_changedfunction ab8500_btemp_resumefunction ab8500_btemp_suspendfunction ab8500_btemp_bindfunction ab8500_btemp_unbindfunction ab8500_btemp_probefunction ab8500_btemp_remove
Annotated Snippet
struct ab8500_btemp_interrupts {
char *name;
irqreturn_t (*isr)(int irq, void *data);
};
struct ab8500_btemp_events {
bool batt_rem;
bool btemp_high;
bool btemp_medhigh;
bool btemp_lowmed;
bool btemp_low;
bool ac_conn;
bool usb_conn;
};
struct ab8500_btemp_ranges {
int btemp_high_limit;
int btemp_med_limit;
int btemp_low_limit;
};
/**
* struct ab8500_btemp - ab8500 BTEMP device information
* @dev: Pointer to the structure device
* @node: List of AB8500 BTEMPs, hence prepared for reentrance
* @curr_source: What current source we use, in uA
* @bat_temp: Dispatched battery temperature in degree Celsius
* @prev_bat_temp Last measured battery temperature in degree Celsius
* @parent: Pointer to the struct ab8500
* @tz: Thermal zone for the battery
* @adc_bat_ctrl: ADC channel for the battery control
* @fg: Pointer to the struct fg
* @bm: Platform specific battery management information
* @btemp_psy: Structure for BTEMP specific battery properties
* @events: Structure for information about events triggered
* @btemp_ranges: Battery temperature range structure
* @btemp_wq: Work queue for measuring the temperature periodically
* @btemp_periodic_work: Work for measuring the temperature periodically
* @initialized: True if battery id read.
*/
struct ab8500_btemp {
struct device *dev;
struct list_head node;
int curr_source;
int bat_temp;
int prev_bat_temp;
struct ab8500 *parent;
struct thermal_zone_device *tz;
struct iio_channel *bat_ctrl;
struct ab8500_fg *fg;
struct ab8500_bm_data *bm;
struct power_supply *btemp_psy;
struct ab8500_btemp_events events;
struct ab8500_btemp_ranges btemp_ranges;
struct workqueue_struct *btemp_wq;
struct delayed_work btemp_periodic_work;
bool initialized;
};
/* BTEMP power supply properties */
static enum power_supply_property ab8500_btemp_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_TEMP,
};
static LIST_HEAD(ab8500_btemp_list);
/**
* ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
* @di: pointer to the ab8500_btemp structure
* @v_batctrl: measured batctrl voltage
* @inst_curr: measured instant current
*
* This function returns the battery resistance that is
* derived from the BATCTRL voltage.
* Returns value in Ohms.
*/
static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di,
int v_batctrl, int inst_curr)
{
if (is_ab8500_1p1_or_earlier(di->parent)) {
/*
* For ABB cut1.0 and 1.1 BAT_CTRL is internally
* connected to 1.8V through a 450k resistor
*/
return (450000 * (v_batctrl)) / (1800 - v_batctrl);
}
/*
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/device.h`, `linux/component.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/slab.h`, `linux/platform_device.h`.
- Detected declarations: `struct ab8500_btemp_interrupts`, `struct ab8500_btemp_events`, `struct ab8500_btemp_ranges`, `struct ab8500_btemp`, `function ab8500_btemp_batctrl_volt_to_res`, `function ab8500_btemp_read_batctrl_voltage`, `function ab8500_btemp_get_batctrl_res`, `function ab8500_btemp_id`, `function ab8500_btemp_periodic_work`, `function ab8500_btemp_batctrlindb_handler`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- 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.