// Copyright 2018 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.

library ddk.protocol.gpioimpl;

using ddk.protocol.gpio;
using zx;

[Layout = "ddk-protocol"]
protocol GpioImpl {
    /// Configures a GPIO for input.
    ConfigIn(uint32 index, uint32 flags) -> (zx.status s);
    /// Configures a GPIO for output.
    ConfigOut(uint32 index, uint8 initial_value) -> (zx.status s);
    /// Configures the GPIO pin for an alternate function (I2C, SPI, etc)
    /// the interpretation of "function" is platform dependent.
    SetAltFunction(uint32 index, uint64 function) -> (zx.status s);
    /// Configures the GPIO pin drive strength.
    SetDriveStrength(uint32 index, uint64 ua) -> (zx.status s, uint64 actual_ua);
    /// Reads the current value of a GPIO (0 or 1).
    Read(uint32 index) -> (zx.status s, uint8 value);
    /// Sets the current value of the GPIO (any non-zero value maps to 1).
    Write(uint32 index, uint8 value) -> (zx.status s);
    /// Gets an interrupt object pertaining to a particular GPIO pin.
    GetInterrupt(uint32 index, uint32 flags) -> (zx.status s, handle<interrupt> irq);
    /// Release the interrupt.
    ReleaseInterrupt(uint32 index) -> (zx.status s);
    /// Set GPIO polarity.
    SetPolarity(uint32 index, ddk.protocol.gpio.GpioPolarity polarity) -> (zx.status s);
};
