// @file sns_interrupt.proto
//
// Defines standard message types for the Interrupt Sensor. The Interrupt
// Sensor is a QC written platform Sensor which is used by physical Sensor
// drivers that use interrupts like data-ready interrupt (DRI), FIFO watermark
// interrupt, etc. These physical Sensors must use the API defined in this file
// to send requests to and parse events from the Interrupt Sensor.
//
// Copyright (c) 2016-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.

syntax = "proto2";
import "nanopb.proto";

enum sns_interrupt_msgid
{
  option (nanopb_enumopt).long_names = false;

  // This message is used to register for notifications for a physical interrupt
  // pin with the interrupt sensor.
  SNS_INTERRUPT_MSGID_SNS_INTERRUPT_REQ = 512;

  // This message is used to register for notifications for an In Band
  // Interrupt (IBI).
  SNS_INTERRUPT_MSGID_SNS_IBI_REQ = 514;

  // Data event from interrupt Sensor.
  //
  // This message is generated each time a registered
  // interrupt fires. This message ID corresponds to
  // the message sns_interrupt_event
  SNS_INTERRUPT_MSGID_SNS_INTERRUPT_EVENT  = 1024;

  // Interrupt sensor event marking it as registered
  //
  // This message is generated when an interrupt has
  // been successfully registered. Sensors should not
  // turn on the hardware interrupts until this
  // event has been recieved from the interrupt sensor.
  // This event has no body and the event length is 0
  SNS_INTERRUPT_MSGID_SNS_INTERRUPT_REG_EVENT = 1025;

  // Notification message to the interrupt Sensor that
  // a level triggered interrupt has been serviced and cleared.
  //
  // In case of level triggered interrupts, when the interrupt
  // fires, the interrupt sensor disables the interrupt until
  // it is serviced and cleared at it's source. This message
  // is used to notify the interrupt sensor that the interrupt
  // has been serviced and cleared so that it can be re-enabled.
  // This message is not applicable to edge triggered interrupts.
  // This message does not have any payload.
  SNS_INTERRUPT_MSGID_SNS_INTERRUPT_IS_CLEARED = 513;
}

// Types of interrupt triggers.
enum sns_interrupt_trigger_type
{
  option (nanopb_enumopt).long_names = false;

  SNS_INTERRUPT_TRIGGER_TYPE_RISING = 0;      // Trigger type rising edge.
  SNS_INTERRUPT_TRIGGER_TYPE_FALLING = 1;     // Trigger type falling edge.
  SNS_INTERRUPT_TRIGGER_TYPE_DUAL_EDGE = 2;   // Trigger type rising and falling edge.
  SNS_INTERRUPT_TRIGGER_TYPE_HIGH = 3;        // Trigger type high level.
  SNS_INTERRUPT_TRIGGER_TYPE_LOW = 4;         // Trigger type low level.
}

// Types of interrupt pin drive strength.
enum sns_interrupt_drive_strength
{
  option (nanopb_enumopt).long_names = false;

  SNS_INTERRUPT_DRIVE_STRENGTH_2_MILLI_AMP = 0;  // Specify a 2 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_4_MILLI_AMP = 1;  // Specify a 4 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_6_MILLI_AMP = 2;  // Specify a 6 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_8_MILLI_AMP = 3;  // Specify an 8 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_10_MILLI_AMP = 4; // Specify a 10 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_12_MILLI_AMP = 5; // Specify a 12 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_14_MILLI_AMP = 6; // Specify a 14 mA drive.
  SNS_INTERRUPT_DRIVE_STRENGTH_16_MILLI_AMP = 7; // Specify a 16 mA drive.
}

// Types of interrupt pin pull.
enum sns_interrupt_pull_type
{
  option (nanopb_enumopt).long_names = false;

  SNS_INTERRUPT_PULL_TYPE_NO_PULL = 0;     // Do not specify a pull.
  SNS_INTERRUPT_PULL_TYPE_PULL_DOWN = 1;   // Pull the GPIO down.
  SNS_INTERRUPT_PULL_TYPE_KEEPER = 2;      // Designate as a Keeper.
  SNS_INTERRUPT_PULL_TYPE_PULL_UP = 3;     // Pull the pin up.
}

// Client request message for Interrupt Sensor.
message sns_interrupt_req
{
  // Interrupt pin number.
  required uint32 interrupt_num = 1;

  // Interrupt trigger type.
  required sns_interrupt_trigger_type interrupt_trigger_type = 2;

  // Interrupt pin drive strength configuration.
  required sns_interrupt_drive_strength interrupt_drive_strength = 3;

  // Interrupt pin pull configuration.
  required sns_interrupt_pull_type interrupt_pull_type = 4;

  // Interrupt pin type. True if this is a chip
  // TLMM GPIO. False if this is an SSC TLMM GPIO.
  required bool is_chip_pin = 5;
}

// Client request message for Interrupt Sensor.
message sns_ibi_req
{
  // Slave address for I3C
  required uint32 dynamic_slave_addr = 1;

  // Platform bus instance number (BLSP number)
  required uint32 bus_instance = 2;

  // Number of optional + mandatory bytes supported by the sensor hardware
  required fixed32 ibi_data_bytes = 3;
}

// Event generated by the Interrupt Sensor.
message sns_interrupt_event
{
  // Interrupt pin number or dynamic slave address
  required fixed32 interrupt_num = 1;

  // Timestamp when trigger event on the interrupt
  // was detected.
  required fixed64 timestamp = 2;

  // If an IBI event, the data associated with the event
  optional bytes   ibi_data = 3 [(nanopb).max_size = 32];
}
