drivers/phy/nuvoton/phy-ma35d1-usb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/nuvoton/phy-ma35d1-usb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/nuvoton/phy-ma35d1-usb2.c- Extension
.c- Size
- 4000 bytes
- Lines
- 144
- 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/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct ma35_usb_phyfunction ma35_usb_phy_power_onfunction ma35_usb_phy_power_offfunction ma35_usb_phy_probe
Annotated Snippet
struct ma35_usb_phy {
struct clk *clk;
struct device *dev;
struct regmap *sysreg;
};
static int ma35_usb_phy_power_on(struct phy *phy)
{
struct ma35_usb_phy *p_phy = phy_get_drvdata(phy);
unsigned int val;
int ret;
ret = clk_prepare_enable(p_phy->clk);
if (ret < 0) {
dev_err(p_phy->dev, "Failed to enable PHY clock: %d\n", ret);
return ret;
}
regmap_read(p_phy->sysreg, MA35_SYS_REG_USBPMISCR, &val);
if (val & PHY0SUSPEND) {
/*
* USB PHY0 is in operation mode already
* make sure USB PHY 60 MHz UTMI Interface Clock ready
*/
ret = regmap_read_poll_timeout(p_phy->sysreg, MA35_SYS_REG_USBPMISCR, val,
val & PHY0DEVCKSTB, 10, 1000);
if (ret == 0)
return 0;
}
/*
* reset USB PHY0.
* wait until USB PHY0 60 MHz UTMI Interface Clock ready
*/
regmap_update_bits(p_phy->sysreg, MA35_SYS_REG_USBPMISCR, 0x7, (PHY0POR | PHY0SUSPEND));
udelay(20);
/* make USB PHY0 enter operation mode */
regmap_update_bits(p_phy->sysreg, MA35_SYS_REG_USBPMISCR, 0x7, PHY0SUSPEND);
/* make sure USB PHY 60 MHz UTMI Interface Clock ready */
ret = regmap_read_poll_timeout(p_phy->sysreg, MA35_SYS_REG_USBPMISCR, val,
val & PHY0DEVCKSTB, 10, 1000);
if (ret == -ETIMEDOUT) {
dev_err(p_phy->dev, "Check PHY clock, Timeout: %d\n", ret);
clk_disable_unprepare(p_phy->clk);
return ret;
}
return 0;
}
static int ma35_usb_phy_power_off(struct phy *phy)
{
struct ma35_usb_phy *p_phy = phy_get_drvdata(phy);
clk_disable_unprepare(p_phy->clk);
return 0;
}
static const struct phy_ops ma35_usb_phy_ops = {
.power_on = ma35_usb_phy_power_on,
.power_off = ma35_usb_phy_power_off,
.owner = THIS_MODULE,
};
static int ma35_usb_phy_probe(struct platform_device *pdev)
{
struct phy_provider *provider;
struct ma35_usb_phy *p_phy;
struct phy *phy;
p_phy = devm_kzalloc(&pdev->dev, sizeof(*p_phy), GFP_KERNEL);
if (!p_phy)
return -ENOMEM;
p_phy->dev = &pdev->dev;
platform_set_drvdata(pdev, p_phy);
p_phy->sysreg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "nuvoton,sys");
if (IS_ERR(p_phy->sysreg))
return dev_err_probe(&pdev->dev, PTR_ERR(p_phy->sysreg),
"Failed to get SYS registers\n");
p_phy->clk = of_clk_get(pdev->dev.of_node, 0);
if (IS_ERR(p_phy->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(p_phy->clk),
"failed to find usb_phy clock\n");
phy = devm_phy_create(&pdev->dev, NULL, &ma35_usb_phy_ops);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/io.h`, `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct ma35_usb_phy`, `function ma35_usb_phy_power_on`, `function ma35_usb_phy_power_off`, `function ma35_usb_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.