drivers/power/supply/rt9467-charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/rt9467-charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/rt9467-charger.c- Extension
.c- Size
- 34162 bytes
- Lines
- 1258
- 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.
- 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/bits.hlinux/bitfield.hlinux/completion.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/kstrtox.hlinux/linear_range.hlinux/module.hlinux/mod_devicetable.hlinux/mutex.hlinux/of.hlinux/power_supply.hlinux/regmap.hlinux/regulator/driver.hlinux/units.hlinux/sysfs.h
Detected Declarations
struct rt9467_chg_dataenum rt9467_fieldsenum rt9467_rangesenum rt9467_adc_chanenum rt9467_chg_typeenum rt9467_iin_limit_selfunction rt9467_otg_of_parse_cbfunction rt9467_register_otg_regulatorfunction rt9467_get_value_from_rangesfunction rt9467_set_value_from_rangesfunction rt9467_get_adc_selfunction rt9467_get_adc_raw_datafunction rt9467_get_adcfunction rt9467_psy_get_statusfunction rt9467_psy_set_ichgfunction rt9467_run_aiclfunction rt9467_psy_set_ieocfunction rt9467_psy_get_propertyfunction rt9467_psy_set_propertyfunction rt9467_chg_prop_is_writeablefunction sysoff_enable_showfunction sysoff_enable_storefunction rt9467_register_psyfunction rt9467_mivr_handlerfunction rt9467_statc_handlerfunction rt9467_wdt_handlerfunction rt9467_report_usb_statefunction rt9467_usb_state_handlerfunction rt9467_aiclmeas_handlerfunction rt9467_request_interruptfunction rt9467_do_charger_initfunction rt9467_is_accessible_regfunction rt9467_check_vendor_infofunction rt9467_reset_chipfunction rt9467_chg_complete_aicl_donefunction rt9467_charger_probe
Annotated Snippet
struct rt9467_chg_data {
struct device *dev;
struct regmap *regmap;
struct regmap_field *rm_field[F_MAX_FIELDS];
struct regmap_irq_chip_data *irq_chip_data;
struct power_supply *psy;
struct mutex adc_lock;
struct mutex attach_lock;
struct mutex ichg_ieoc_lock;
struct regulator_dev *rdev;
struct completion aicl_done;
enum power_supply_usb_type psy_usb_type;
unsigned int old_stat;
unsigned int vid;
int ichg_ua;
int ieoc_ua;
};
static int rt9467_otg_of_parse_cb(struct device_node *of,
const struct regulator_desc *desc,
struct regulator_config *cfg)
{
struct rt9467_chg_data *data = cfg->driver_data;
cfg->ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(of),
"enable", 0, GPIOD_OUT_LOW |
GPIOD_FLAGS_BIT_NONEXCLUSIVE,
desc->name);
if (IS_ERR(cfg->ena_gpiod)) {
cfg->ena_gpiod = NULL;
return 0;
}
return regmap_field_write(data->rm_field[F_OTG_PIN_EN], 1);
}
static const struct regulator_ops rt9467_otg_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_current_limit = regulator_set_current_limit_regmap,
.get_current_limit = regulator_get_current_limit_regmap,
};
static const u32 rt9467_otg_microamp[] = {
500000, 700000, 1100000, 1300000, 1800000, 2100000, 2400000, 3000000
};
static const struct regulator_desc rt9467_otg_desc = {
.name = "rt9476-usb-otg-vbus",
.of_match = "usb-otg-vbus-regulator",
.of_parse_cb = rt9467_otg_of_parse_cb,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.min_uV = RT9467_OTG_MIN_uV,
.uV_step = RT9467_OTG_STEP_uV,
.n_voltages = RT9467_NUM_VOTG,
.curr_table = rt9467_otg_microamp,
.n_current_limits = ARRAY_SIZE(rt9467_otg_microamp),
.csel_reg = RT9467_REG_CHG_CTRL10,
.csel_mask = RT9467_MASK_OTG_CSEL,
.vsel_reg = RT9467_REG_CHG_CTRL5,
.vsel_mask = RT9467_MASK_OTG_VSEL,
.enable_reg = RT9467_REG_CHG_CTRL1,
.enable_mask = RT9467_MASK_OTG_EN,
.ops = &rt9467_otg_regulator_ops,
};
static int rt9467_register_otg_regulator(struct rt9467_chg_data *data)
{
struct regulator_config cfg = {
.dev = data->dev,
.regmap = data->regmap,
.driver_data = data,
};
data->rdev = devm_regulator_register(data->dev, &rt9467_otg_desc, &cfg);
return PTR_ERR_OR_ZERO(data->rdev);
}
static int rt9467_get_value_from_ranges(struct rt9467_chg_data *data,
enum rt9467_fields field,
enum rt9467_ranges rsel,
int *value)
{
const struct linear_range *range = rt9467_ranges + rsel;
unsigned int sel;
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/completion.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`.
- Detected declarations: `struct rt9467_chg_data`, `enum rt9467_fields`, `enum rt9467_ranges`, `enum rt9467_adc_chan`, `enum rt9467_chg_type`, `enum rt9467_iin_limit_sel`, `function rt9467_otg_of_parse_cb`, `function rt9467_register_otg_regulator`, `function rt9467_get_value_from_ranges`, `function rt9467_set_value_from_ranges`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source 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.