drivers/power/supply/smb347-charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/smb347-charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/smb347-charger.c- Extension
.c- Size
- 43836 bytes
- Lines
- 1643
- 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/delay.hlinux/err.hlinux/kernel.hlinux/module.hlinux/init.hlinux/interrupt.hlinux/i2c.hlinux/power_supply.hlinux/property.hlinux/regmap.hlinux/regulator/driver.hdt-bindings/power/summit,smb347-charger.h
Detected Declarations
struct smb347_chargerenum smb_charger_chipidfunction hw_to_currentfunction current_to_hwfunction smb347_update_ps_statusfunction smb347_is_ps_onlinefunction smb347_charging_statusfunction smb347_charging_setfunction smb347_charging_enablefunction smb347_charging_disablefunction smb347_start_stop_chargingfunction smb347_set_charge_currentfunction smb347_set_current_limitsfunction smb347_set_voltage_limitsfunction smb347_set_temp_limitsfunction smb347_set_writablefunction smb347_hw_initfunction smb347_interruptfunction smb347_irq_setfunction smb347_irq_enablefunction smb347_irq_disablefunction smb347_irq_initfunction get_const_charge_currentfunction get_const_charge_voltagefunction smb347_get_charging_statusfunction smb347_get_property_lockedfunction smb347_get_propertyfunction smb347_volatile_regfunction smb347_readable_regfunction smb347_dt_parse_dev_infofunction smb347_get_battery_infofunction smb347_usb_vbus_get_current_limitfunction smb347_usb_vbus_set_new_current_limitfunction smb347_usb_vbus_set_current_limitfunction smb347_usb_vbus_regulator_enablefunction smb347_usb_vbus_regulator_disablefunction smb347_probefunction smb347_removefunction smb347_shutdown
Annotated Snippet
struct smb347_charger {
struct device *dev;
struct regmap *regmap;
struct power_supply *mains;
struct power_supply *usb;
struct regulator_dev *usb_rdev;
unsigned int id;
bool mains_online;
bool usb_online;
bool irq_unsupported;
bool usb_vbus_enabled;
unsigned int max_charge_current;
unsigned int max_charge_voltage;
unsigned int pre_charge_current;
unsigned int termination_current;
unsigned int pre_to_fast_voltage;
unsigned int mains_current_limit;
unsigned int usb_hc_current_limit;
unsigned int chip_temp_threshold;
int soft_cold_temp_limit;
int soft_hot_temp_limit;
int hard_cold_temp_limit;
int hard_hot_temp_limit;
bool suspend_on_hard_temp_limit;
unsigned int soft_temp_limit_compensation;
unsigned int charge_current_compensation;
bool use_mains;
bool use_usb;
bool use_usb_otg;
unsigned int enable_control;
unsigned int inok_polarity;
};
enum smb_charger_chipid {
SMB345,
SMB347,
SMB358,
NUM_CHIP_TYPES,
};
/* Fast charge current in uA */
static const unsigned int fcc_tbl[NUM_CHIP_TYPES][8] = {
[SMB345] = { 200000, 450000, 600000, 900000,
1300000, 1500000, 1800000, 2000000 },
[SMB347] = { 700000, 900000, 1200000, 1500000,
1800000, 2000000, 2200000, 2500000 },
[SMB358] = { 200000, 450000, 600000, 900000,
1300000, 1500000, 1800000, 2000000 },
};
/* Pre-charge current in uA */
static const unsigned int pcc_tbl[NUM_CHIP_TYPES][4] = {
[SMB345] = { 150000, 250000, 350000, 450000 },
[SMB347] = { 100000, 150000, 200000, 250000 },
[SMB358] = { 150000, 250000, 350000, 450000 },
};
/* Termination current in uA */
static const unsigned int tc_tbl[NUM_CHIP_TYPES][8] = {
[SMB345] = { 30000, 40000, 60000, 80000,
100000, 125000, 150000, 200000 },
[SMB347] = { 37500, 50000, 100000, 150000,
200000, 250000, 500000, 600000 },
[SMB358] = { 30000, 40000, 60000, 80000,
100000, 125000, 150000, 200000 },
};
/* Input current limit in uA */
static const unsigned int icl_tbl[NUM_CHIP_TYPES][10] = {
[SMB345] = { 300000, 500000, 700000, 1000000, 1500000,
1800000, 2000000, 2000000, 2000000, 2000000 },
[SMB347] = { 300000, 500000, 700000, 900000, 1200000,
1500000, 1800000, 2000000, 2200000, 2500000 },
[SMB358] = { 300000, 500000, 700000, 1000000, 1500000,
1800000, 2000000, 2000000, 2000000, 2000000 },
};
/* Charge current compensation in uA */
static const unsigned int ccc_tbl[NUM_CHIP_TYPES][4] = {
[SMB345] = { 200000, 450000, 600000, 900000 },
[SMB347] = { 250000, 700000, 900000, 1200000 },
[SMB358] = { 200000, 450000, 600000, 900000 },
};
/* Convert register value to current using lookup table */
static int hw_to_current(const unsigned int *tbl, size_t size, unsigned int val)
{
if (val >= size)
return -EINVAL;
return tbl[val];
Annotation
- Immediate include surface: `linux/delay.h`, `linux/err.h`, `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/power_supply.h`.
- Detected declarations: `struct smb347_charger`, `enum smb_charger_chipid`, `function hw_to_current`, `function current_to_hw`, `function smb347_update_ps_status`, `function smb347_is_ps_online`, `function smb347_charging_status`, `function smb347_charging_set`, `function smb347_charging_enable`, `function smb347_charging_disable`.
- 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.