drivers/extcon/extcon-axp288.c
Source file repositories/reference/linux-study-clean/drivers/extcon/extcon-axp288.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/extcon/extcon-axp288.c- Extension
.c- Size
- 13973 bytes
- Lines
- 527
- 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/acpi.hlinux/module.hlinux/kernel.hlinux/io.hlinux/slab.hlinux/interrupt.hlinux/platform_device.hlinux/property.hlinux/notifier.hlinux/extcon-provider.hlinux/regmap.hlinux/mfd/axp20x.hlinux/usb/role.hlinux/workqueue.hasm/cpu_device_id.hasm/intel-family.hasm/iosf_mbi.h
Detected Declarations
struct axp288_extcon_infoenum axp288_extcon_regenum axp288_extcon_irqfunction axp288_extcon_log_rsifunction axp288_get_id_pinfunction axp288_usb_role_workfunction axp288_get_vbus_attachfunction axp288_handle_chrg_det_eventfunction axp288_extcon_id_evtfunction axp288_extcon_isrfunction axp288_extcon_enablefunction axp288_put_role_swfunction axp288_extcon_find_role_swfunction axp288_extcon_probefunction axp288_extcon_suspendfunction axp288_extcon_resume
Annotated Snippet
struct axp288_extcon_info {
struct device *dev;
struct regmap *regmap;
struct regmap_irq_chip_data *regmap_irqc;
struct usb_role_switch *role_sw;
struct work_struct role_work;
int irq[EXTCON_IRQ_END];
struct extcon_dev *edev;
struct extcon_dev *id_extcon;
struct notifier_block id_nb;
unsigned int previous_cable;
bool vbus_attach;
};
static const struct x86_cpu_id cherry_trail_cpu_ids[] = {
X86_MATCH_VFM(INTEL_ATOM_AIRMONT, NULL),
{}
};
/* Power up/down reason string array */
static const char * const axp288_pwr_up_down_info[] = {
"Last wake caused by user pressing the power button",
"Last wake caused by a charger insertion",
"Last wake caused by a battery insertion",
"Last wake caused by SOC initiated global reset",
"Last wake caused by cold reset",
"Last shutdown caused by PMIC UVLO threshold",
"Last shutdown caused by SOC initiated cold off",
"Last shutdown caused by user pressing the power button",
};
/*
* Decode and log the given "reset source indicator" (rsi)
* register and then clear it.
*/
static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
{
unsigned int val, i, clear_mask = 0;
unsigned long bits;
int ret;
ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val);
if (ret < 0) {
dev_err(info->dev, "failed to read reset source indicator\n");
return;
}
bits = val & GENMASK(ARRAY_SIZE(axp288_pwr_up_down_info) - 1, 0);
for_each_set_bit(i, &bits, ARRAY_SIZE(axp288_pwr_up_down_info))
dev_dbg(info->dev, "%s\n", axp288_pwr_up_down_info[i]);
clear_mask = bits;
/* Clear the register value for next reboot (write 1 to clear bit) */
regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask);
}
/*
* The below code to control the USB role-switch on devices with an AXP288
* may seem out of place, but there are 2 reasons why this is the best place
* to control the USB role-switch on such devices:
* 1) On many devices the USB role is controlled by AML code, but the AML code
* only switches between the host and none roles, because of Windows not
* really using device mode. To make device mode work we need to toggle
* between the none/device roles based on Vbus presence, and this driver
* gets interrupts on Vbus insertion / removal.
* 2) In order for our BC1.2 charger detection to work properly the role
* mux must be properly set to device mode before we do the detection.
*/
/* Returns the id-pin value, note pulled low / false == host-mode */
static bool axp288_get_id_pin(struct axp288_extcon_info *info)
{
enum usb_role role;
if (info->id_extcon)
return extcon_get_state(info->id_extcon, EXTCON_USB_HOST) <= 0;
/* We cannot access the id-pin, see what mode the AML code has set */
role = usb_role_switch_get_role(info->role_sw);
return role != USB_ROLE_HOST;
}
static void axp288_usb_role_work(struct work_struct *work)
{
struct axp288_extcon_info *info =
container_of(work, struct axp288_extcon_info, role_work);
enum usb_role role;
bool id_pin;
int ret;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/module.h`, `linux/kernel.h`, `linux/io.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/property.h`.
- Detected declarations: `struct axp288_extcon_info`, `enum axp288_extcon_reg`, `enum axp288_extcon_irq`, `function axp288_extcon_log_rsi`, `function axp288_get_id_pin`, `function axp288_usb_role_work`, `function axp288_get_vbus_attach`, `function axp288_handle_chrg_det_event`, `function axp288_extcon_id_evt`, `function axp288_extcon_isr`.
- 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.