<br />

Added: HEAD

## **PROTOCOLS**

## Debug

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=143)*

### ConnectTarget

Connects to the target device with the given ID. Equivalent to connecting to `TargetService`
via the corresponding driver node.

Returns `INVALID_ARGS` if `target_id` is greater than or equal to `MAX_TARGETS`.
May return an error if there is no such target on the bus; otherwise errors will be returned
when attempting to access the client.

#### Request

| Name | Type |
|---|---|
| `target_id` | `uint8` |
| `server` | `server_end:https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Debug_ConnectTarget_Result` |

### GetControllerProperties

Returns the properties of the host SPMI controller.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#DebugGetControllerPropertiesResponse` |

## Device

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=51)*

Each instance of `Device` represents a target/secondary SPMI device on a SPMI bus.
To support multiple SPMI devices, multiple nodes must be instantiated.

<br />

### CancelWatchControllerWriteCommands

Cancels an pending call to `WatchControllerWriteCommands`. `address` and `size` must
exactly match a previous call to `WatchControllerWriteCommands()`, otherwise `NOT_FOUND`
is returned.

#### Request

| Name | Type |
|---|---|
| `address` | `uint8` |
| `size` | `uint16` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_CancelWatchControllerWriteCommands_Result` |

### GetProperties

Get the properties of the SPMI device.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_GetProperties_Result` |

### RegisterRead

Issue register read commands to the SPMI device.
The implementation may choose which SPMI variation (e.g. extended, long) to use.
When successful, it returns `size_bytes` in `data` read contiguously starting from
`address` in the device.

#### Request

| Name | Type |
|---|---|
| `address` | `uint16` |
| `size_bytes` | `uint32` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_RegisterRead_Result` |

### RegisterWrite

Issue register write commands to the SPMI device.
The implementation may choose which SPMI variation (e.g. extended, long) to use.
When this command is successful, `data` will be written contiguously starting from
`address` in the device.

#### Request

| Name | Type |
|---|---|
| `address` | `uint16` |
| `data` | `vector<uint8>` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_RegisterWrite_Result` |

### WatchControllerWriteCommands

Hanging-get method to receive controller write commands from the device. `address` and
`size` specify the register range to monitor for commands. Multiple overlapping calls to
this method are not allowed.
Returns `INVALID_ARGS` if `address` or `size` are invalid, or `BAD_STATE` if another call
is pending for this register range. Returns `CANCELED` if
`CancelWatchControllerWriteCommands()` was called for this register range.

If this method is meant to keep the system awake (prevents suspension) while watch is setup,
use the passed-in `setup_wake_lease` `LeaseToken`. Then, when the watch is triggered this
method will return a second `wake_lease` `LeaseToken` to prevent suspension.

These keep alive wake lease tokens are provided by the Power Framework's System Activity
Governor. A driver supporting keep alive must be able to get `wake_lease` from System
Activity Governor.

When `wake_lease` is closed, then the created wake lease keeping the system from suspending
at the time of watch triggering is dropped. Hence, to guarantee that the system is not
suspended by the Power Framework a client must either keep this `wake_lease` for as long as
the system needs to stay awake, or a client must get its own wake lease from the Power
Framework before it drops `wake_lease` to prevent suspension.

#### Request

| Name | Type |
|---|---|
| `address` | `uint8` |
| `size` | `uint16` |
| `setup_wake_lease` | `https://fuchsia.dev/reference/fuchsia.power.system//https://fuchsia.dev/reference/fuchsia.power.system#LeaseToken` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_WatchControllerWriteCommands_Result` |

## **STRUCTS**

### Debug_ConnectTarget_Response

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=153)*

\<EMPTY\>

### Device_CancelWatchControllerWriteCommands_Response

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=128)*

\<EMPTY\>

### Device_RegisterRead_Response

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=59)*

| Field | Type | Description | Default |
|---|---|---|---|
| `data` | `vector<uint8>` |   | No default |

### Device_RegisterWrite_Response

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=70)*

\<EMPTY\>

### Device_WatchControllerWriteCommands_Response [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=117)*

| Field | Type | Description | Default |
|---|---|---|---|
| `writes` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Register8>:256` |   | No default |
| `wake_lease` | `https://fuchsia.dev/reference/fuchsia.power.system//https://fuchsia.dev/reference/fuchsia.power.system#LeaseToken` |   | No default |

### Register8

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=43)*

A single register read from or written to with an SPMI command that uses an 8-bit address.

<br />

| Field | Type | Description | Default |
|---|---|---|---|
| `address` | `uint8` |   | No default |
| `data` | `uint8` |   | No default |

## **ENUMS**

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

Type: `uint32`

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=17)*

Errors that this driver may return.

<br />

| Name | Value | Description |
|---|---|---|
| ### INTERNAL | `1` | The driver encountered an otherwise unspecified error while performing the operation. |
| ### NOT_SUPPORTED | `2` | The operation is not implemented, supported, or enabled. |
| ### INVALID_ARGS | `3` | An argument is invalid. |
| ### BAD_STATE | `4` | The operation failed because the current state of the driver does not allow it, or a precondition of the operation is not satisfied. |
| ### IO_REFUSED | `5` | The device returned a NACK (negative Acknowledgment). The client may retry the operation after a NACK was sent for instance due to a parity error. |
| ### CANCELED | `6` | The hanging-get method was canceled. |
| ### NOT_FOUND | `7` | No pending hanging-get method was found for the given arguments. |

## **TABLES**

### ControllerInfo

*Defined in [fuchsia.hardware.spmi/metadata.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/metadata.fidl;l=38)*

`ControllerInfo` is passed to SPMI controller drivers via metadata.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `id` | `uint32` | Board-specific controller ID. Optional. |
| ### 2 | `targets` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#TargetInfo>:16` | SPMI target devices on this bus. Optional. |

### DebugGetControllerPropertiesResponse

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=156)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `name` | `string:64` | User friendly string for the controller name. If not set, the controller name is unknown. If included, this string must be non-empty. Optional. |

### Device_GetProperties_Response

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

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `sid` | `uint8` | Unique SPMI target/secondary identifier, corresponds to the SPMI specification sid. Up to 16 secondaries are identifed with an id from 0 to 15 inclusive. Required. |
| ### 2 | `name` | `string:64` | User friendly string for the device name. If not set, the device name is unknown. If included, this string must be non-empty. Optional. |
| ### 3 | `register_width_bytes` | `uint32` | Width in bytes of each register in the device. If not set, the register width defaults to 1 byte. Optional. |

### SubTargetInfo

*Defined in [fuchsia.hardware.spmi/metadata.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/metadata.fidl;l=10)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `address` | `uint16` | The SPMI base register address. Accesses to this sub-target will be restricted to the range \[0, `size`) and offset by `address`. Required. |
| ### 2 | `size` | `uint32` | The size of the SPMI register region accessible to this sub-target. The sum of `address` and `size` must be less than or equal to 65536. Required. |
| ### 3 | `name` | `string:64` | The name of this sub-target to be used for bind properties. Optional. |
| ### 4 | `display_name` | `string` | A human-readable name for this sub-target. Optional. |
| ### 5 | `global_id` | `uint32` | Globally unique ID across all SPMI sub-targets. Required. |

### TargetInfo

*Defined in [fuchsia.hardware.spmi/metadata.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/metadata.fidl;l=25)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `id` | `uint8` | SPMI target ID in \[0, `MAX_TARGETS`), unique for this controller. Required. |
| ### 2 | `sub_targets` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#SubTargetInfo>:65536` | Sub-target register regions within this target. Optional. |
| ### 3 | `name` | `string:64` | The name of this target to be used for bind properties. Optional. |
| ### 4 | `display_name` | `string` | A human-readable name for this target. Optional. |

## **UNIONS**

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

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=153)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Debug_ConnectTarget_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#DriverError` |   |

<br />

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

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=128)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_CancelWatchControllerWriteCommands_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#DriverError` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

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

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

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

<br />

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

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=59)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_RegisterRead_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#DriverError` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

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

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=70)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_RegisterWrite_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#DriverError` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

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

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=117)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#Device_WatchControllerWriteCommands_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.spmi#DriverError` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

## **CONSTANTS**

| Name | Value | Type | Description |
|---|---|---|---|
| [MAX_CONTROLLER_WRITE_COMMANDS](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=14) | `256` | `uint32` | An arbitrary limit on the number of register writes that can be returned to `WatchControllerWriteCommands()`. |
| [MAX_SPMI_NAME_LEN](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=10) | `64` | `uint32` | Maximum length of the SPMI device name. |
| [MAX_SUB_TARGETS](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/metadata.fidl;l=8) | `65536` | `uint32` |   |
| [MAX_TARGETS](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/metadata.fidl;l=7) | `16` | `uint32` |   |

## **SERVICES**

### DebugService

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=167)*

| Name | Type | Transport |
|---|---|---|
| [device](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=168) | `fuchsia.hardware.spmi/Debug` | Channel |

<br />

### SubTargetService

*Defined in [fuchsia.hardware.spmi/spmi.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=139)*

| Name | Type | Transport |
|---|---|---|
| [device](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=140) | `fuchsia.hardware.spmi/Device` | Channel |

<br />

### TargetService

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

| Name | Type | Transport |
|---|---|---|
| [device](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.spmi/spmi.fidl;l=134) | `fuchsia.hardware.spmi/Device` | Channel |

<br />