drivers/extcon/extcon-lc824206xa.c
Source file repositories/reference/linux-study-clean/drivers/extcon/extcon-lc824206xa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/extcon/extcon-lc824206xa.c- Extension
.c- Size
- 14004 bytes
- Lines
- 496
- Domain
- Driver Families
- Bucket
- drivers/extcon
- 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/bits.hlinux/delay.hlinux/device.hlinux/extcon-provider.hlinux/i2c.hlinux/interrupt.hlinux/module.hlinux/power_supply.hlinux/property.hlinux/regulator/consumer.hlinux/workqueue.h
Detected Declarations
struct lc824206xa_datafunction lc824206xa_read_regfunction lc824206xa_write_regfunction lc824206xa_get_idfunction lc824206xa_set_vbus_boostfunction lc824206xa_charger_detectfunction lc824206xa_workfunction lc824206xa_irqfunction chargerfunction lc824206xa_probe
Annotated Snippet
struct lc824206xa_data {
struct work_struct work;
struct i2c_client *client;
struct extcon_dev *edev;
struct power_supply *psy;
struct regulator *vbus_boost;
unsigned int usb_type;
unsigned int cable;
unsigned int previous_cable;
u8 switch_control;
u8 previous_switch_control;
bool vbus_ok;
bool vbus_boost_enabled;
bool fastcharge_over_miclr;
};
static const unsigned int lc824206xa_cables[] = {
EXTCON_USB_HOST,
EXTCON_CHG_USB_SDP,
EXTCON_CHG_USB_CDP,
EXTCON_CHG_USB_DCP,
EXTCON_CHG_USB_ACA,
EXTCON_CHG_USB_FAST,
EXTCON_NONE,
};
/* read/write reg helpers to add error logging to smbus byte functions */
static int lc824206xa_read_reg(struct lc824206xa_data *data, u8 reg)
{
int ret;
ret = i2c_smbus_read_byte_data(data->client, reg);
if (ret < 0)
dev_err(&data->client->dev, "Error %d reading reg 0x%02x\n", ret, reg);
return ret;
}
static int lc824206xa_write_reg(struct lc824206xa_data *data, u8 reg, u8 val)
{
int ret;
ret = i2c_smbus_write_byte_data(data->client, reg, val);
if (ret < 0)
dev_err(&data->client->dev, "Error %d writing reg 0x%02x\n", ret, reg);
return ret;
}
static int lc824206xa_get_id(struct lc824206xa_data *data)
{
int ret;
ret = lc824206xa_write_reg(data, REG_ID_PIN_ADC_CTRL, ID_PIN_ADC_CONTINUOUS);
if (ret)
return ret;
ret = lc824206xa_read_reg(data, REG_ID_PIN_ADC_VALUE);
lc824206xa_write_reg(data, REG_ID_PIN_ADC_CTRL, ID_PIN_ADC_AUTO);
return ret;
}
static void lc824206xa_set_vbus_boost(struct lc824206xa_data *data, bool enable)
{
int ret;
if (data->vbus_boost_enabled == enable)
return;
if (enable)
ret = regulator_enable(data->vbus_boost);
else
ret = regulator_disable(data->vbus_boost);
if (ret == 0)
data->vbus_boost_enabled = enable;
else
dev_err(&data->client->dev, "Error updating Vbus boost regulator: %d\n", ret);
}
static void lc824206xa_charger_detect(struct lc824206xa_data *data)
{
int charger_type, ret;
charger_type = lc824206xa_read_reg(data, REG_CHARGER_TYPE);
if (charger_type < 0)
return;
Annotation
- Immediate include surface: `linux/bits.h`, `linux/delay.h`, `linux/device.h`, `linux/extcon-provider.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/module.h`, `linux/power_supply.h`.
- Detected declarations: `struct lc824206xa_data`, `function lc824206xa_read_reg`, `function lc824206xa_write_reg`, `function lc824206xa_get_id`, `function lc824206xa_set_vbus_boost`, `function lc824206xa_charger_detect`, `function lc824206xa_work`, `function lc824206xa_irq`, `function charger`, `function lc824206xa_probe`.
- Atlas domain: Driver Families / drivers/extcon.
- 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.