drivers/usb/misc/qcom_eud.c
Source file repositories/reference/linux-study-clean/drivers/usb/misc/qcom_eud.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/misc/qcom_eud.c- Extension
.c- Size
- 6103 bytes
- Lines
- 267
- 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.
- 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/bitops.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/sysfs.hlinux/usb/role.hlinux/firmware/qcom/qcom_scm.h
Detected Declarations
struct eud_chipfunction enable_eudfunction disable_eudfunction enable_showfunction enable_storefunction usb_attach_detachfunction pet_eudfunction handle_eud_irqfunction handle_eud_irq_threadfunction eud_role_switch_releasefunction eud_probefunction eud_remove
Annotated Snippet
struct eud_chip {
struct device *dev;
struct usb_role_switch *role_sw;
void __iomem *base;
phys_addr_t mode_mgr;
unsigned int int_status;
int irq;
bool enabled;
bool usb_attached;
};
static int enable_eud(struct eud_chip *priv)
{
int ret;
ret = qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1);
if (ret)
return ret;
writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN);
writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
priv->base + EUD_REG_INT1_EN_MASK);
return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
}
static int disable_eud(struct eud_chip *priv)
{
int ret;
ret = qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 0);
if (ret)
return ret;
writel(0, priv->base + EUD_REG_CSR_EUD_EN);
return 0;
}
static ssize_t enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct eud_chip *chip = dev_get_drvdata(dev);
return sysfs_emit(buf, "%d\n", chip->enabled);
}
static ssize_t enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct eud_chip *chip = dev_get_drvdata(dev);
bool enable;
int ret;
if (kstrtobool(buf, &enable))
return -EINVAL;
if (enable) {
ret = enable_eud(chip);
if (!ret)
chip->enabled = enable;
else
disable_eud(chip);
} else {
ret = disable_eud(chip);
}
return ret < 0 ? ret : count;
}
static DEVICE_ATTR_RW(enable);
static struct attribute *eud_attrs[] = {
&dev_attr_enable.attr,
NULL,
};
ATTRIBUTE_GROUPS(eud);
static void usb_attach_detach(struct eud_chip *chip)
{
u32 reg;
/* read ctl_out_1[4] to find USB attach or detach event */
reg = readl(chip->base + EUD_REG_CTL_OUT_1);
chip->usb_attached = reg & EUD_INT_SAFE_MODE;
}
static void pet_eud(struct eud_chip *chip)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct eud_chip`, `function enable_eud`, `function disable_eud`, `function enable_show`, `function enable_store`, `function usb_attach_detach`, `function pet_eud`, `function handle_eud_irq`, `function handle_eud_irq_thread`, `function eud_role_switch_release`.
- Atlas domain: Driver Families / drivers/usb.
- 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.