drivers/usb/phy/phy-omap-otg.c
Source file repositories/reference/linux-study-clean/drivers/usb/phy/phy-omap-otg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/phy/phy-omap-otg.c- Extension
.c- Size
- 3796 bytes
- Lines
- 151
- 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.
- 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/io.hlinux/err.hlinux/extcon.hlinux/kernel.hlinux/module.hlinux/interrupt.hlinux/platform_device.hlinux/platform_data/usb-omap1.h
Detected Declarations
struct otg_devicefunction omap_otg_ctrlfunction omap_otg_set_modefunction omap_otg_id_notifierfunction omap_otg_vbus_notifierfunction omap_otg_probe
Annotated Snippet
struct otg_device {
void __iomem *base;
bool id;
bool vbus;
struct extcon_dev *extcon;
struct notifier_block vbus_nb;
struct notifier_block id_nb;
};
#define OMAP_OTG_CTRL 0x0c
#define OMAP_OTG_ASESSVLD (1 << 20)
#define OMAP_OTG_BSESSEND (1 << 19)
#define OMAP_OTG_BSESSVLD (1 << 18)
#define OMAP_OTG_VBUSVLD (1 << 17)
#define OMAP_OTG_ID (1 << 16)
#define OMAP_OTG_XCEIV_OUTPUTS \
(OMAP_OTG_ASESSVLD | OMAP_OTG_BSESSEND | OMAP_OTG_BSESSVLD | \
OMAP_OTG_VBUSVLD | OMAP_OTG_ID)
static void omap_otg_ctrl(struct otg_device *otg_dev, u32 outputs)
{
u32 l;
l = readl(otg_dev->base + OMAP_OTG_CTRL);
l &= ~OMAP_OTG_XCEIV_OUTPUTS;
l |= outputs;
writel(l, otg_dev->base + OMAP_OTG_CTRL);
}
static void omap_otg_set_mode(struct otg_device *otg_dev)
{
if (!otg_dev->id && otg_dev->vbus)
/* Set B-session valid. */
omap_otg_ctrl(otg_dev, OMAP_OTG_ID | OMAP_OTG_BSESSVLD);
else if (otg_dev->vbus)
/* Set A-session valid. */
omap_otg_ctrl(otg_dev, OMAP_OTG_ASESSVLD);
else if (!otg_dev->id)
/* Set B-session end to indicate no VBUS. */
omap_otg_ctrl(otg_dev, OMAP_OTG_ID | OMAP_OTG_BSESSEND);
}
static int omap_otg_id_notifier(struct notifier_block *nb,
unsigned long event, void *ptr)
{
struct otg_device *otg_dev = container_of(nb, struct otg_device, id_nb);
otg_dev->id = event;
omap_otg_set_mode(otg_dev);
return NOTIFY_DONE;
}
static int omap_otg_vbus_notifier(struct notifier_block *nb,
unsigned long event, void *ptr)
{
struct otg_device *otg_dev = container_of(nb, struct otg_device,
vbus_nb);
otg_dev->vbus = event;
omap_otg_set_mode(otg_dev);
return NOTIFY_DONE;
}
static int omap_otg_probe(struct platform_device *pdev)
{
const struct omap_usb_config *config = pdev->dev.platform_data;
struct otg_device *otg_dev;
struct extcon_dev *extcon;
int ret;
u32 rev;
if (!config || !config->extcon)
return -ENODEV;
extcon = extcon_get_extcon_dev(config->extcon);
if (IS_ERR(extcon))
return PTR_ERR(extcon);
otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL);
if (!otg_dev)
return -ENOMEM;
otg_dev->base = devm_ioremap_resource(&pdev->dev, &pdev->resource[0]);
if (IS_ERR(otg_dev->base))
return PTR_ERR(otg_dev->base);
otg_dev->extcon = extcon;
otg_dev->id_nb.notifier_call = omap_otg_id_notifier;
Annotation
- Immediate include surface: `linux/io.h`, `linux/err.h`, `linux/extcon.h`, `linux/kernel.h`, `linux/module.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/platform_data/usb-omap1.h`.
- Detected declarations: `struct otg_device`, `function omap_otg_ctrl`, `function omap_otg_set_mode`, `function omap_otg_id_notifier`, `function omap_otg_vbus_notifier`, `function omap_otg_probe`.
- 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.