drivers/usb/phy/phy-am335x-control.c
Source file repositories/reference/linux-study-clean/drivers/usb/phy/phy-am335x-control.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/phy/phy-am335x-control.c- Extension
.c- Size
- 4460 bytes
- Lines
- 194
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/platform_device.hlinux/err.hlinux/of.hlinux/io.hlinux/delay.hlinux/usb/otg.hphy-am335x-control.h
Detected Declarations
struct am335x_control_usbfunction am335x_phy_wkupfunction am335x_phy_powerfunction matchfunction am335x_control_usb_probeexport am335x_get_phy_control
Annotated Snippet
struct am335x_control_usb {
struct device *dev;
void __iomem *phy_reg;
void __iomem *wkup;
spinlock_t lock;
struct phy_control phy_ctrl;
};
#define AM335X_USB0_CTRL 0x0
#define AM335X_USB1_CTRL 0x8
#define AM335x_USB_WKUP 0x0
#define USBPHY_CM_PWRDN (1 << 0)
#define USBPHY_OTG_PWRDN (1 << 1)
#define USBPHY_OTGVDET_EN (1 << 19)
#define USBPHY_OTGSESSEND_EN (1 << 20)
#define AM335X_PHY0_WK_EN (1 << 0)
#define AM335X_PHY1_WK_EN (1 << 8)
static void am335x_phy_wkup(struct phy_control *phy_ctrl, u32 id, bool on)
{
struct am335x_control_usb *usb_ctrl;
u32 val;
u32 reg;
usb_ctrl = container_of(phy_ctrl, struct am335x_control_usb, phy_ctrl);
switch (id) {
case 0:
reg = AM335X_PHY0_WK_EN;
break;
case 1:
reg = AM335X_PHY1_WK_EN;
break;
default:
WARN_ON(1);
return;
}
spin_lock(&usb_ctrl->lock);
val = readl(usb_ctrl->wkup);
if (on)
val |= reg;
else
val &= ~reg;
writel(val, usb_ctrl->wkup);
spin_unlock(&usb_ctrl->lock);
}
static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id,
enum usb_dr_mode dr_mode, bool on)
{
struct am335x_control_usb *usb_ctrl;
u32 val;
u32 reg;
usb_ctrl = container_of(phy_ctrl, struct am335x_control_usb, phy_ctrl);
switch (id) {
case 0:
reg = AM335X_USB0_CTRL;
break;
case 1:
reg = AM335X_USB1_CTRL;
break;
default:
WARN_ON(1);
return;
}
val = readl(usb_ctrl->phy_reg + reg);
if (on) {
if (dr_mode == USB_DR_MODE_HOST) {
val &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN |
USBPHY_OTGVDET_EN);
val |= USBPHY_OTGSESSEND_EN;
} else {
val &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN);
val |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN;
}
} else {
val |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
}
writel(val, usb_ctrl->phy_reg + reg);
/*
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/err.h`, `linux/of.h`, `linux/io.h`, `linux/delay.h`, `linux/usb/otg.h`, `phy-am335x-control.h`.
- Detected declarations: `struct am335x_control_usb`, `function am335x_phy_wkup`, `function am335x_phy_power`, `function match`, `function am335x_control_usb_probe`, `export am335x_get_phy_control`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.