drivers/usb/typec/tcpm/maxim_contaminant.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/maxim_contaminant.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/maxim_contaminant.c- Extension
.c- Size
- 12227 bytes
- Lines
- 451
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/device.hlinux/irqreturn.hlinux/module.hlinux/regmap.hlinux/usb/tcpci.hlinux/usb/tcpm.hlinux/usb/typec.htcpci_maxim.h
Detected Declarations
enum fladc_selectfunction max_contaminant_adc_to_mvfunction max_contaminant_read_adc_mvfunction max_contaminant_read_resistance_kohmfunction max_contaminant_read_comparatorsfunction max_contaminant_detect_contaminantfunction max_contaminant_enable_dry_detectionfunction max_contaminant_enable_togglingfunction max_contaminant_is_contaminant
Annotated Snippet
if (IS_CC_OPEN(cc_status)) {
u8 role_ctrl, role_ctrl_backup;
ret = max_tcpci_read8(chip, TCPC_ROLE_CTRL, &role_ctrl);
if (ret < 0)
return false;
role_ctrl_backup = role_ctrl;
role_ctrl |= 0x0F;
role_ctrl &= ~(TCPC_ROLE_CTRL_DRP);
ret = max_tcpci_write8(chip, TCPC_ROLE_CTRL, role_ctrl);
if (ret < 0)
return false;
chip->contaminant_state = max_contaminant_detect_contaminant(chip);
ret = max_tcpci_write8(chip, TCPC_ROLE_CTRL, role_ctrl_backup);
if (ret < 0)
return false;
if (chip->contaminant_state == DETECTED) {
max_contaminant_enable_dry_detection(chip);
return true;
}
ret = max_contaminant_enable_toggling(chip);
if (ret)
dev_err(chip->dev,
"Failed to enable toggling, ret=%d",
ret);
}
} else if (chip->contaminant_state == DETECTED) {
if (!(cc_status & TCPC_CC_STATUS_TOGGLING)) {
chip->contaminant_state = max_contaminant_detect_contaminant(chip);
if (chip->contaminant_state == DETECTED) {
max_contaminant_enable_dry_detection(chip);
return true;
} else {
ret = max_contaminant_enable_toggling(chip);
if (ret) {
dev_err(chip->dev,
"Failed to enable toggling, ret=%d",
ret);
return true;
}
}
}
}
*cc_handled = false;
return false;
}
MODULE_DESCRIPTION("MAXIM TCPC CONTAMINANT Module");
MODULE_AUTHOR("Badhri Jagan Sridharan <badhri@google.com>");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/device.h`, `linux/irqreturn.h`, `linux/module.h`, `linux/regmap.h`, `linux/usb/tcpci.h`, `linux/usb/tcpm.h`, `linux/usb/typec.h`.
- Detected declarations: `enum fladc_select`, `function max_contaminant_adc_to_mv`, `function max_contaminant_read_adc_mv`, `function max_contaminant_read_resistance_kohm`, `function max_contaminant_read_comparators`, `function max_contaminant_detect_contaminant`, `function max_contaminant_enable_dry_detection`, `function max_contaminant_enable_toggling`, `function max_contaminant_is_contaminant`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
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.