<br />

Added: HEAD

## **PROTOCOLS**

## UfsPhy

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=73)*

### GetProperties

Returns the PHY driver's static capabilities. The controller driver calls this once at
initialization to decide which power-management features it may use. A PHY driver that
does not implement this method is treated as supporting none of the optional features.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_GetProperties_Result` |

### Init

Perform the UFS PHY specific initialization which happens before link startup.

#### Request

| Name | Type |
|---|---|
| `ufs_hci` | `client_end:https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#Ufshci` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_Init_Result` |

### PrePowerModeChange

Perform PHY calibration and configuration prior to power mode / gear change.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_PrePowerModeChange_Result` |

### SetPowerState

Transitions the PHY to `state`. See [PowerState](https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#PowerState) for the hardware preconditions of each
target state.

## Power States and Held Resources

Each lower power state holds a strict subset of the resources held by the state above it:

\| State \| Power Domains \| Core Clocks \& Rails \| M-PHY Low-V Rail \| Aux Clock \|
\|---\|---\|---\|---\|---\|
\| `ACTIVE` \| ON \| ON \| ON \| ON \|
\| `LINK_IDLE` \| ON \| ON \| ON \| OFF \|
\| `HIBERNATE_SLEEP` \| ON \| ON \| OFF \| OFF \|
\| `POWER_DOWN` \| OFF \| OFF \| OFF \| OFF \|

## Allowed Transitions

- **Same state (`S -> S`)** : Always idempotent; returns `ZX_OK` without modifying hardware.
- **Higher power to lower power (`ACTIVE -> LINK_IDLE`, `ACTIVE/LINK_IDLE -> HIBERNATE_SLEEP`, or `ACTIVE/LINK_IDLE/HIBERNATE_SLEEP -> POWER_DOWN`)**: Allowed. Releases the additional resources not required in the target state.
- **Any lower power state to `ACTIVE` (`LINK_IDLE/HIBERNATE_SLEEP/POWER_DOWN -> ACTIVE`)** : Allowed. Restores all resources required for `ACTIVE`.
- **Lower power to a higher non-`ACTIVE` state (`POWER_DOWN -> LINK_IDLE`, `POWER_DOWN -> HIBERNATE_SLEEP`, or `HIBERNATE_SLEEP -> LINK_IDLE`)** : Rejected with `ZX_ERR_BAD_STATE`. The caller must transition to `ACTIVE` first.

## Error Semantics

- **Transitions to `ACTIVE`, `LINK_IDLE`, or `HIBERNATE_SLEEP`**: On failure, the PHY rolls back any partial changes (best-effort) and remains in its previous state.
- **Transitions to `POWER_DOWN`** : Every power-down step is attempted even if an earlier step fails, the first error is returned, and the PHY transitions to `POWER_DOWN`.

## Reentrancy

The UFS driver may call `SetPowerState` while holding the locks that serialize its own
UIC traffic (it does so for the `ACTIVE` and `LINK_IDLE` votes issued around doorbells and
interrupts). Implementations must therefore complete `SetPowerState` without calling back
into `Ufshci` (`DmeGet`/`DmeSet`); any DME work belongs in `Init` or `PrePowerModeChange`.

#### Request

| Name | Type |
|---|---|
| `state` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#PowerState` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_SetPowerState_Result` |

## Ufshci

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=52)*

Interface provided by the UFS MAC (controller driver) to the PHY driver,
allowing the PHY driver to send UIC commands (like DME_SET) or access
MAC-level registers required for PHY initialization.

<br />

### DmeGet

Send a UIC DME_GET command to the UFS controller.
If the MIB attribute's value has not been set via the DME_SET command, a hardware reset
default value is returned by the device.
For invalid mib_attribute or gen_selector_index values, a ZX_ERR_INTERNAL error is returned.

#### Request

| Name | Type |
|---|---|
| `mib_attribute` | `uint16` |
| `gen_selector_index` | `uint16` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#Ufshci_DmeGet_Result` |

### DmeSet

Send a UIC DME_SET command to the UFS controller.

#### Request

| Name | Type |
|---|---|
| `mib_attribute` | `uint16` |
| `gen_selector_index` | `uint16` |
| `value` | `uint32` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#Ufshci_DmeSet_Result` |

## **STRUCTS**

### UfsPhy_Init_Response

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=77)*

\<EMPTY\>

### UfsPhy_PrePowerModeChange_Response

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=80)*

\<EMPTY\>

### UfsPhy_SetPowerState_Response

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=133)*

\<EMPTY\>

### Ufshci_DmeGet_Response

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=67)*

| Field | Type | Description | Default |
|---|---|---|---|
| `value` | `uint32` |   | No default |

### Ufshci_DmeSet_Response

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=58)*

\<EMPTY\>

## **ENUMS**

### PowerState [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint8`

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=11)*

Operating power states of the UFS PHY, ordered from highest to lowest power consumption.

<br />

| Name | Value | Description |
|---|---|---|
| ### ACTIVE | `1` | All PHY power domains, regulators, and auxiliary clocks are enabled; UFSHCI registers and the UniPro link are accessible. Can be entered from any state with no hardware preconditions. When waking from `POWER_DOWN`, the caller must subsequently re-enable the host controller (`HCE = 1`) and call `Init` to re-initialize the M-PHY before starting the link. |
| ### LINK_IDLE | `2` | The UniPro link is idle in Autonomous Hibernate (AH8) with no in-flight UFSHCI commands or register accesses. Auxiliary clocks may be gated while all power rails and domains remain enabled. Preconditions: Can only be entered from `ACTIVE` after `Init` has succeeded. The UniPro link must be in Autonomous Hibernate (AH8) with no in-flight UFSHCI commands or concurrent register accesses. While in `LINK_IDLE`, UFSHCI registers must not be accessed. |
| ### HIBERNATE_SLEEP | `3` | The UFS device is in Sleep (`START STOP UNIT`) and the UniPro link is in software Hibern8 (`DME_HIBERNATE_ENTER`). Low-voltage M-PHY analog supplies and auxiliary clocks may be disabled while device `VCC` and core power domains remain powered so wake to `ACTIVE` does not require link re-startup. Preconditions: Can only be entered from `ACTIVE` or `LINK_IDLE` after `Init` has succeeded. The UFS device must be in Sleep (`START STOP UNIT`) and the UniPro link must be in software Hibern8 (`DME_HIBERNATE_ENTER`). While in `HIBERNATE_SLEEP`, UFSHCI registers must not be accessed and `DME_HIBERNATE_EXIT` must not be issued. |
| ### POWER_DOWN | `4` | The host controller is stopped (`HCE = 0`) and all UFS device rails, PHY resets, regulators, clocks, and power domains are powered down. Preconditions: Can be entered from any state after the caller has stopped the host controller (`HCE = 0`). While in `POWER_DOWN`, UFSHCI registers must not be accessed and `Ufshci` calls fail with `ZX_ERR_BAD_STATE`. |

## **TABLES**

### UfsPhy_GetProperties_Response

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=85)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `supports_suspend_resume` | `bool` | Whether `POWER_DOWN` suspend and resume are implemented, i.e. the PHY can power down the UFS device, PHY, and host controller power domains and bring them back up. When unset or false the controller driver only uses link hibernation for system suspend. |

## **UNIONS**

### UfsPhy_GetProperties_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=85)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_GetProperties_Response` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### UfsPhy_Init_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=77)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_Init_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Status` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### UfsPhy_PrePowerModeChange_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=80)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_PrePowerModeChange_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Status` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### UfsPhy_SetPowerState_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=133)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#UfsPhy_SetPowerState_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Status` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Ufshci_DmeGet_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=67)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#Ufshci_DmeGet_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Status` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Ufshci_DmeSet_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=58)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.ufs.phy#Ufshci_DmeSet_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Status` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

## **SERVICES**

### Service

*Defined in [fuchsia.hardware.ufs.phy/ufs_phy.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=136)*

| Name | Type | Transport |
|---|---|---|
| [phy](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=137) | `fuchsia.hardware.ufs.phy/UfsPhy` | Channel |
| [inline_crypto](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.ufs.phy/ufs_phy.fidl;l=138) | `fuchsia.hardware.inlineencryption/Controller` | Channel |

<br />