drivers/phy/ti/phy-omap-usb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/ti/phy-omap-usb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/ti/phy-omap-usb2.c- Extension
.c- Size
- 13229 bytes
- Lines
- 539
- Domain
- Driver Families
- Bucket
- drivers/phy
- 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.
- 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/clk.hlinux/delay.hlinux/err.hlinux/io.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/phy/omap_control_phy.hlinux/phy/omap_usb.hlinux/phy/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hlinux/slab.hlinux/sys_soc.hlinux/usb/phy_companion.h
Detected Declarations
struct omap_usbstruct usb_phy_datafunction omap_usb_readlfunction omap_usb_writelfunction omap_usb2_set_comparatorfunction omap_usb_set_vbusfunction omap_usb_start_srpfunction omap_usb_set_hostfunction omap_usb_set_peripheralfunction omap_usb_phy_powerfunction omap_usb_power_offfunction omap_usb_power_onfunction omap_usb2_disable_clocksfunction omap_usb2_enable_clocksfunction omap_usb_initfunction omap_usb_exitfunction omap_usb2_init_erratafunction omap_usb2_put_devicefunction omap_usb2_probefunction omap_usb2_removeexport omap_usb2_set_comparator
Annotated Snippet
struct omap_usb {
struct usb_phy phy;
struct phy_companion *comparator;
void __iomem *pll_ctrl_base;
void __iomem *phy_base;
struct device *dev;
struct device *control_dev;
struct clk *wkupclk;
struct clk *optclk;
u8 flags;
struct regmap *syscon_phy_power; /* ctrl. reg. acces */
unsigned int power_reg; /* power reg. index within syscon */
u32 mask;
u32 power_on;
u32 power_off;
};
#define phy_to_omapusb(x) container_of((x), struct omap_usb, phy)
struct usb_phy_data {
const char *label;
u8 flags;
u32 mask;
u32 power_on;
u32 power_off;
};
static inline u32 omap_usb_readl(void __iomem *addr, unsigned int offset)
{
return __raw_readl(addr + offset);
}
static inline void omap_usb_writel(void __iomem *addr, unsigned int offset,
u32 data)
{
__raw_writel(data, addr + offset);
}
/**
* omap_usb2_set_comparator() - links the comparator present in the system with this phy
*
* @comparator: the companion phy(comparator) for this phy
*
* The phy companion driver should call this API passing the phy_companion
* filled with set_vbus and start_srp to be used by usb phy.
*
* For use by phy companion driver
*/
int omap_usb2_set_comparator(struct phy_companion *comparator)
{
struct omap_usb *phy;
struct usb_phy *x = usb_get_phy(USB_PHY_TYPE_USB2);
if (IS_ERR(x))
return -ENODEV;
phy = phy_to_omapusb(x);
phy->comparator = comparator;
return 0;
}
EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);
static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
{
struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);
if (!phy->comparator || !phy->comparator->set_vbus)
return -ENODEV;
return phy->comparator->set_vbus(phy->comparator, enabled);
}
static int omap_usb_start_srp(struct usb_otg *otg)
{
struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);
if (!phy->comparator || !phy->comparator->start_srp)
return -ENODEV;
return phy->comparator->start_srp(phy->comparator);
}
static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
otg->host = host;
if (!host)
otg->state = OTG_STATE_UNDEFINED;
return 0;
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/io.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`.
- Detected declarations: `struct omap_usb`, `struct usb_phy_data`, `function omap_usb_readl`, `function omap_usb_writel`, `function omap_usb2_set_comparator`, `function omap_usb_set_vbus`, `function omap_usb_start_srp`, `function omap_usb_set_host`, `function omap_usb_set_peripheral`, `function omap_usb_phy_power`.
- Atlas domain: Driver Families / drivers/phy.
- Implementation status: integration 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.