![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
How link-layer drivers acquire and sequence PHY bring-up before training or DMA.
On success, keep PHY powered until **remove** — do not **put** until teardown.
| Step | Call |
|---|---|
| Get | **rt_phye_get_by_name(dev, "sata-phy")** |
| Clocks | **rt_clk_array_prepare_enable** (before PHY) |
| PHY | **rt_phye_init** → **rt_phye_power_on** |
| Host | **rt_ahci_host_register** |
| Fail path | **power_off** → **exit** → disable clocks → **rt_phye_put** |
| Remove | **exit** + **power_off** (note order in source) |
DTS: host node needs **phys** / **phy-names = "sata-phy"** pointing at SATA PHY provider.
Before **rt_pci_host_bridge_probe** or link training:
Exact ordering vs **clk/reset** is SoC-specific — PCI host controllers.
Often uses **usb-nop-xceiv** (Generic USB PHY) or SoC USB PHY:
Generic USB driver may only implement **power_on/power_off/reset** — mode set optional.
| Return | Meaning |
|---|---|
**rt_err_ptr(-RT_EINVAL)** | Bad args |
**rt_err_ptr from ofw_parse** | DT cells wrong |
**NULL** | No **phys** / provider missing |
Always **rt_phye_put** for every successful **get**.
| Issue | Mitigation |
|---|---|
Train before **power_on** | Link fails — follow TRM order |
**set_mode while link up** | Down link first |
Leak **put** | Pair with **get** on all paths |
Double **power_off** in remove | Match **probe** success path |