summaryrefslogtreecommitdiff
path: root/documentation/6.components/device-driver/phye/phye_ofw.md
blob: 8309460f87516bb7d27138fcd5193246738b0d68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@page page_device_phye_ofw Phye and device tree

# Device tree binding (`phye.c`)

Consumers reference PHY providers with standard graph properties. Requires **`RT_USING_OFW`**.

---

## Properties (consumer node)

| Property | Role |
| --- | --- |
| **`phys`** | Phandle list to PHY provider node(s) |
| **`#phy-cells`** | On **provider** — specifier length per entry |
| **`phy-names`** | Optional string ID per entry (for **`rt_phye_get_by_name`**) |

Example (SATA host):

```dts
ahci: sata@... {
    phys = <&sata_phy 0>;
    phy-names = "sata-phy";
};
```

---

## Resolution flow (`ofw_phye_get_by_index`)

```
  rt_ofw_parse_phandle_cells(np, "phys", "#phy-cells", index, &args)
       |
       |  args.data = provider rt_ofw_node *
       v
  rt_platform_ofw_request(provider_np)   /* probe provider if needed */
       |
       v
  phye = rt_ofw_data(provider_np)
       |
       v
  phye->ops->ofw_parse(phye, &args)     /* optional */
```

If **`ofw_parse`** fails, **`get_by_index`** returns **`rt_err_ptr(err)`**.

Provider platform driver must **`rt_phye_register`** in **`probe`** after **`rt_dm_dev_bind_fwdata`**.

---

## Provider node

| Element | Role |
| --- | --- |
| **`compatible`** | Selects PHY driver (SoC or generic) |
| **`#phy-cells`** | Usually `0` or mode/lane index |
| **`clocks` / `resets` / regulators** | Handled in provider **`probe`**, not by core |

Cell semantics are **driver-specific** — document in BSP binding and implement in **`ofw_parse`**.

---

## Pitfalls

| Issue | Mitigation |
| --- | --- |
| Provider not probed | **`rt_platform_ofw_request`** before **`rt_ofw_data`** (core does this) |
| **`ofw_parse` omitted** | **`#phy-cells` ignored** — wrong mode if cells non-zero |
| Index / name mismatch | **`phy-names`** must align with **`phys`** order |
| Missing **`phys`** | **`get_by_index`** returns NULL — fail host **`probe`** |

## See also

- @ref page_device_phye_core
- @ref page_device_ofw_base
- @ref page_device_phye_provider