drivers/phy/ingenic/phy-ingenic-usb.c
Source file repositories/reference/linux-study-clean/drivers/phy/ingenic/phy-ingenic-usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/ingenic/phy-ingenic-usb.c- Extension
.c- Size
- 11068 bytes
- Lines
- 387
- 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/bitfield.hlinux/clk.hlinux/delay.hlinux/io.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/regulator/consumer.h
Detected Declarations
struct ingenic_soc_infostruct ingenic_usb_phyfunction ingenic_usb_phy_initfunction ingenic_usb_phy_exitfunction ingenic_usb_phy_power_onfunction ingenic_usb_phy_power_offfunction ingenic_usb_phy_set_modefunction jz4770_usb_phy_initfunction jz4775_usb_phy_initfunction jz4780_usb_phy_initfunction x1000_usb_phy_initfunction x1830_usb_phy_initfunction x2000_usb_phy_initfunction ingenic_usb_phy_probe
Annotated Snippet
struct ingenic_soc_info {
void (*usb_phy_init)(struct phy *phy);
};
struct ingenic_usb_phy {
const struct ingenic_soc_info *soc_info;
struct phy *phy;
void __iomem *base;
struct clk *clk;
struct regulator *vcc_supply;
};
static int ingenic_usb_phy_init(struct phy *phy)
{
struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
int err;
u32 reg;
err = clk_prepare_enable(priv->clk);
if (err) {
dev_err(&phy->dev, "Unable to start clock: %d\n", err);
return err;
}
priv->soc_info->usb_phy_init(phy);
/* Wait for PHY to reset */
usleep_range(30, 300);
reg = readl(priv->base + REG_USBPCR_OFFSET);
writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET);
usleep_range(300, 1000);
return 0;
}
static int ingenic_usb_phy_exit(struct phy *phy)
{
struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
clk_disable_unprepare(priv->clk);
regulator_disable(priv->vcc_supply);
return 0;
}
static int ingenic_usb_phy_power_on(struct phy *phy)
{
struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
int err;
err = regulator_enable(priv->vcc_supply);
if (err) {
dev_err(&phy->dev, "Unable to enable VCC: %d\n", err);
return err;
}
return 0;
}
static int ingenic_usb_phy_power_off(struct phy *phy)
{
struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
regulator_disable(priv->vcc_supply);
return 0;
}
static int ingenic_usb_phy_set_mode(struct phy *phy,
enum phy_mode mode, int submode)
{
struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
u32 reg;
switch (mode) {
case PHY_MODE_USB_HOST:
reg = readl(priv->base + REG_USBPCR_OFFSET);
u32p_replace_bits(®, 1, USBPCR_USB_MODE);
u32p_replace_bits(®, 0, USBPCR_VBUSVLDEXT);
u32p_replace_bits(®, 0, USBPCR_VBUSVLDEXTSEL);
u32p_replace_bits(®, 0, USBPCR_OTG_DISABLE);
writel(reg, priv->base + REG_USBPCR_OFFSET);
break;
case PHY_MODE_USB_DEVICE:
reg = readl(priv->base + REG_USBPCR_OFFSET);
u32p_replace_bits(®, 0, USBPCR_USB_MODE);
u32p_replace_bits(®, 1, USBPCR_VBUSVLDEXT);
u32p_replace_bits(®, 1, USBPCR_VBUSVLDEXTSEL);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`.
- Detected declarations: `struct ingenic_soc_info`, `struct ingenic_usb_phy`, `function ingenic_usb_phy_init`, `function ingenic_usb_phy_exit`, `function ingenic_usb_phy_power_on`, `function ingenic_usb_phy_power_off`, `function ingenic_usb_phy_set_mode`, `function jz4770_usb_phy_init`, `function jz4775_usb_phy_init`, `function jz4780_usb_phy_init`.
- 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.