drivers/phy/phy-lpc18xx-usb-otg.c
Source file repositories/reference/linux-study-clean/drivers/phy/phy-lpc18xx-usb-otg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/phy-lpc18xx-usb-otg.c- Extension
.c- Size
- 3432 bytes
- Lines
- 146
- Domain
- Driver Families
- Bucket
- drivers/phy
- 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/clk.hlinux/err.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct lpc18xx_usb_otg_phyfunction lpc18xx_usb_otg_phy_initfunction lpc18xx_usb_otg_phy_exitfunction lpc18xx_usb_otg_phy_power_onfunction lpc18xx_usb_otg_phy_power_offfunction lpc18xx_usb_otg_phy_probe
Annotated Snippet
struct lpc18xx_usb_otg_phy {
struct phy *phy;
struct clk *clk;
struct regmap *reg;
};
static int lpc18xx_usb_otg_phy_init(struct phy *phy)
{
struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy);
int ret;
/* The PHY must be clocked at 480 MHz */
ret = clk_set_rate(lpc->clk, 480000000);
if (ret)
return ret;
return clk_prepare(lpc->clk);
}
static int lpc18xx_usb_otg_phy_exit(struct phy *phy)
{
struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy);
clk_unprepare(lpc->clk);
return 0;
}
static int lpc18xx_usb_otg_phy_power_on(struct phy *phy)
{
struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy);
int ret;
ret = clk_enable(lpc->clk);
if (ret)
return ret;
/* The bit in CREG is cleared to enable the PHY */
ret = regmap_update_bits(lpc->reg, LPC18XX_CREG_CREG0,
LPC18XX_CREG_CREG0_USB0PHY, 0);
if (ret) {
clk_disable(lpc->clk);
return ret;
}
return 0;
}
static int lpc18xx_usb_otg_phy_power_off(struct phy *phy)
{
struct lpc18xx_usb_otg_phy *lpc = phy_get_drvdata(phy);
int ret;
ret = regmap_update_bits(lpc->reg, LPC18XX_CREG_CREG0,
LPC18XX_CREG_CREG0_USB0PHY,
LPC18XX_CREG_CREG0_USB0PHY);
if (ret)
return ret;
clk_disable(lpc->clk);
return 0;
}
static const struct phy_ops lpc18xx_usb_otg_phy_ops = {
.init = lpc18xx_usb_otg_phy_init,
.exit = lpc18xx_usb_otg_phy_exit,
.power_on = lpc18xx_usb_otg_phy_power_on,
.power_off = lpc18xx_usb_otg_phy_power_off,
.owner = THIS_MODULE,
};
static int lpc18xx_usb_otg_phy_probe(struct platform_device *pdev)
{
struct phy_provider *phy_provider;
struct lpc18xx_usb_otg_phy *lpc;
lpc = devm_kzalloc(&pdev->dev, sizeof(*lpc), GFP_KERNEL);
if (!lpc)
return -ENOMEM;
lpc->reg = syscon_node_to_regmap(pdev->dev.of_node->parent);
if (IS_ERR(lpc->reg)) {
dev_err(&pdev->dev, "failed to get syscon\n");
return PTR_ERR(lpc->reg);
}
lpc->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(lpc->clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
Annotation
- Immediate include surface: `linux/clk.h`, `linux/err.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct lpc18xx_usb_otg_phy`, `function lpc18xx_usb_otg_phy_init`, `function lpc18xx_usb_otg_phy_exit`, `function lpc18xx_usb_otg_phy_power_on`, `function lpc18xx_usb_otg_phy_power_off`, `function lpc18xx_usb_otg_phy_probe`.
- Atlas domain: Driver Families / drivers/phy.
- 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.