blob: ba794cefb95cf58d94382b075c5328bad001b574 [file] [log] [blame]
// Copyright 2023 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@available(added=HEAD)
library fuchsia.hardware.usb.phy;
using fuchsia.power.system;
using zx;
@discoverable
open protocol UsbPhy {
/// Informs the PHY when the peripheral role connect status changes. If system suspend is
/// enabled, `wake_lease` will hold a wake lease that the callee can use to keep the system
/// awake while the call is being processed.
flexible ConnectStatusChanged(resource struct {
connected bool;
wake_lease fuchsia.power.system.LeaseToken:optional;
}) -> () error zx.Status;
};
service Service {
device client_end:UsbPhy;
};
@discoverable
open protocol ConnectionWatcher {
/// Hanging-get that notifies callers when USB has been connected or
/// disconnected. Returns immediately on the first call, or if the
/// connection status has changed since the last call.
///
/// If present, `setup_wake_lease` will be used to keep the system awake while the call is being
/// processed. In this case a new wake lease will be acquired and passed back through
/// `wake_lease`. `wake_lease` will be present iff `setup_wake_lease` was present.
///
/// Returns:
/// - `ZX_ERR_BAD_STATE`: A hanging-get call was already pending.
/// - `ZX_ERR_NO_RESOURCES`: `setup_wake_lease` was present but a new wake lease could not be
/// acquired.
flexible WatchConnectStatusChanged(resource struct {
setup_wake_lease fuchsia.power.system.LeaseToken:optional;
}) -> (resource struct {
connected bool;
wake_lease fuchsia.power.system.LeaseToken:optional;
}) error zx.Status;
};
service ConnectionWatcherService {
watcher client_end:ConnectionWatcher;
};
type ProtocolVersion = flexible enum {
USB_2_0 = 2;
USB_3_0 = 3;
};
type Mode = flexible enum {
UNKNOWN = 0;
HOST = 1;
PERIPHERAL = 2;
OTG = 3;
};
type UsbPhyMode = table {
1: protocol ProtocolVersion;
2: dr_mode Mode;
3: is_otg_capable bool;
};
type AmlogicPhyType = flexible enum {
G12_A = 0;
G12_B = 1;
};
@serializable
type Metadata = table {
1: usb_phy_modes vector<UsbPhyMode>:MAX;
/// Optional.
2: phy_type AmlogicPhyType;
};