/*
 * iaxxx-sysid-defs.h
 *
 * Copyright (c) 2018 Knowles, inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

/**********************************************************
 * This file is generated by running a format script
 * on header files shared by Firmware.
 *
 * DO NOT EDIT.
 *
 *********************************************************/
#ifndef __IAXXX_SYSTEMID_H__
#define __IAXXX_SYSTEMID_H__

/****************************************************************************
 * Includes
 ***************************************************************************/
#include <linux/kernel.h>
#include <limits.h> /* for INT_MIN, INT_MAX */

/****************************************************************************
 * Constants & Macros
 ***************************************************************************/

/************************************************************************//**
 * @defgroup systemid_defs System Id Definitions
 * @{
 ***************************************************************************/

/************************************************************************//**
 * @defgroup sysid_enum Enumerations
 * @{
 ***************************************************************************/

/************************************************************************//**
 * Resource Type
 *
 * @brief Various types of resources which are identified by system id
 ***************************************************************************/
enum {
	/** For special use
	 */
	IAXXX_SYSID_RESOURCE_TYPE_SPECIAL = (0x0),
	/** device drivers
	 */
	IAXXX_SYSID_RESOURCE_TYPE_DRIVER,
	/** module instances
	 */
	IAXXX_SYSID_RESOURCE_TYPE_MODULE,
	/** Plugin instances
	 */
	IAXXX_SYSID_RESOURCE_TYPE_PLUGIN,
	/** Channels
	 */
	IAXXX_SYSID_RESOURCE_TYPE_CHANNEL,
	/** Tunnels
	 */
	IAXXX_SYSID_RESOURCE_TYPE_TUNNEL,
	/** Streams
	 */
	IAXXX_SYSID_RESOURCE_TYPE_STREAM,
	/** Devices (Peripherals)
	 */
	IAXXX_SYSID_RESOURCE_TYPE_DEVICE,
	/** Bluetooth
	 */
	IAXXX_SYSID_RESOURCE_TYPE_BT,
	/** Sensor
	 */
	IAXXX_SYSID_RESOURCE_TYPE_SENSOR,
	/** Debug
	 */
	IAXXX_SYSID_RESOURCE_TYPE_DEBUG,
	/** File
	 */
	IAXXX_SYSID_RESOURCE_TYPE_FILE,

	IAXXX_SYSID_RESOURCE_TYPE_NUM,

	/* Force enums to be of size int */
	IAXXX_SYSID_RESOURCE_TYPE_FORCE_SIZE = INT_MAX,
};


/************************************************************************//**
 * Driver Type
 *
 * @brief Various types of drivers which are identified by system id
 ****************************************************************************/
enum sysid_driver_type_e {
	IAXXX_SYSID_DRIVER_TYPE_NONE = 0,
	/** I2C driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_I2C,
	/** SPI driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SPI,
	/** UART driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_UART,
	/** SLIMBUS control driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SLIMBUS_CTRL,
	/** SoundWire control driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SOUNDWIRE_CTRL,
	/** I3C driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_I3C_CTRL,
	/** PCM driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_PCM,
	/** PDM input driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_PDM_IN,
	/** PDM output driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_PDM_OUT,
	/** I2S driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_I2S,
	/** SLIMBUS data driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SLIMBUS_DATA,
	/** SoundWire data driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SOUNDWIRE_DATA,
	/** I3C data driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_I3C_DATA,
	/** SSP driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SSP,
	/** AF driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_AF,
	/** DAC driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_DAC,
	/** A400 driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_A400,
	/** Filter input driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_FILTER_IN,
	/** Filter output driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_FILTER_OUT,
	/** STRM timer driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_STMR_TIMER,
	/** STMR presentation timer driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_STMR_PT,
	/** Timer driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SW_TIMER,
	/** WCPT Timer driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_TIMER,
	/** PLL driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_PLL,
	/** DMA driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_DMA,
	/** GPIO-A driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_GPIOA,
	/** GPIO-B driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_GPIOB,
	/** Register Map driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_REGMAP,
	/** Flash driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_FLASHDRV,
	/** Button driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_BUTTON,
	/** LED driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_LED,
	/** ADAU1361 driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_ADAU1361,
	/** USB driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_USBDRV,
	/** CSR8811 driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_CSR8811,
	/** CYW20707 driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_CYW20707,
	/** MAC driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_MAC,
	/** BQ27425 driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_BQ27425,
	/** sensor driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_SENSOR,
	/** Flicker driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_FLICKER,
	/** DMA Stream Driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_DMA_STRM,
	/** CPU stream driver
	 */
	IAXXX_SYSID_DRIVER_TYPE_CPUSTRMDRV,
	IAXXX_SYSID_DRIVER_TYPE_NUM,
	/* Force enums to be of size int */
	IAXXX_SYSID_DRIVER_TYPE_FORCE_SIZE = INT_MAX,
};


/************************************************************************//**
 * Device Type
 *
 * @brief Various types of peripheral devices which are identified by system id
 ***************************************************************************/
enum sysid_iaxxx_device_type_e {
	/** Button device
	 */
	IAXXX_SYSID_DEVICE_TYPE_BUTTON,
	/** LED device
	 */
	IAXXX_SYSID_DEVICE_TYPE_LED,
	/** Flash device
	 */
	IAXXX_SYSID_DEVICE_TYPE_FLASH,
	/** CODEC device
	 */
	IAXXX_SYSID_DEVICE_TYPE_CODEC,
	/** Sensor device
	 */
	IAXXX_SYSID_DEVICE_TYPE_SENSOR,
	/** Input pin device
	 */
	IAXXX_SYSID_DEVICE_TYPE_INPUT_PIN,
	/** Output pin device
	 */
	IAXXX_SYSID_DEVICE_TYPE_OUTPUT_PIN,
	/** STMR timer device
	 */
	IAXXX_SYSID_DEVICE_TYPE_STMR_TMR,
	/** STRM PT device
	 */
	IAXXX_SYSID_DEVICE_TYPE_STMR_PT,
	/** Interface device
	 */
	IAXXX_SYSID_DEVICE_TYPE_INTERFACE,
	/** USB device
	 */
	IAXXX_SYSID_DEVICE_TYPE_USB,
	/** Bluetooth device
	 */
	IAXXX_SYSID_DEVICE_TYPE_BT,
	/** Battery Fuel Gauge Device
	 */
	IAXXX_SYSID_DEVICE_TYPE_BATTERY,

	IAXXX_SYSID_DEVICE_TYPE_NUM,

	/* Force enums to be of size int */
	IAXXX_SYSID_DEVICE_TYPE_FORCE_SIZE = INT_MAX,
};


/*************************************************************************//**
 * Special Resource Type
 *
 * @brief Various special resource system Ids
 ****************************************************************************/
enum sysid_special_type_e {
	/** Invalid resource
	 */
	IAXXX_SYSID_SPECIAL_TYPE_INVALID = 0,
	/** Special resource Host
	 */
	IAXXX_SYSID_SPECIAL_TYPE_HOST,
	/** Use for broadcast
	 */
	IAXXX_SYSID_SPECIAL_TYPE_ALL = (0xF),

	IAXXX_SYSID_SPECIAL_TYPE_NUM,

	/* Force enums to be of size int */
	IAXXX_SYSID_SPECIAL_TYPE_FORCE_SIZE = INT_MAX,
};
/************************************************************************//**
 * Direction
 *
 * @brief Value of direction field used by various system ids
 ***************************************************************************/
enum sysid_dir_e {
	/** Input direction
	 */
	IAXXX_SYSID_DIR_IN = 0,
	/** Output direction
	 */
	IAXXX_SYSID_DIR_OUT,

	/* Force enums to be of size int */
	IAXXX_SYSID_DIR_FORCE_SIZE = INT_MAX,
};

/*************************************************************************//**
 * @}
 ****************************************************************************/


/*************************************************************************//**
 * @defgroup sysid_const Constants
 * @{
 ****************************************************************************/

/** Bit offset of the 'resource type' field in the system id
 */
#define IAXXX_SYSID_POS_RESOURCE_TYPE             (12)
/** Bit mask of the 'resource type' field in the system id
 */
#define IAXXX_SYSID_MASK_RESOURCE_TYPE            (0xF000)

/** Bit offset of the 'special resource type' field in the system id
 */
#define IAXXX_SYSID_POS_SPECIAL_TYPE              (8)
/** Bit mask of the 'special resource type' field in the driver system id
 */
#define IAXXX_SYSID_MASK_SPECIAL_TYPE             (0x0F00)

/** Bit offset of the 'special resource instance index' field in the system id
 */
#define IAXXX_SYSID_POS_SPECIAL_INST_INDEX        (0)
/** Bit mask of the 'special resource instance index' field in the system id
 */
#define IAXXX_SYSID_MASK_SPECIAL_INST_INDEX       (0x00FF)

/**Bit offset of the 'driver type' field in the driver system id
 */
#define IAXXX_SYSID_POS_DRIVER_TYPE               (5)
/** Bit mask of the 'driver type' field in the driver system id
 */
#define IAXXX_SYSID_MASK_DRIVER_TYPE              (0x0FE0)

/** Bit offset of the 'driver instance index' field in the driver system id
 */
#define IAXXX_SYSID_POS_DRIVER_INST_INDEX         (0)
/** Bit mask of the 'driver instance index' field in the driver system id
 */
#define IAXXX_SYSID_MASK_DRIVER_INST_INDEX        (0x001F)


/** Bit offset of the 'module processor id' field
 * in the module instance system id
 */
#define IAXXX_SYSID_POS_MODULE_PROC_ID            (9)
/** Bit mask of the 'module processor id' field
 * in the module instance system id
 */
#define IAXXX_SYSID_MASK_MODULE_PROC_ID           (0x0E00)

/** Bit offset of the 'module type' field
 *  in the module instance system id
 */
#define IAXXX_SYSID_POS_MODULE_TYPE               (4)
/** Bit mask of the 'module type' field
 *  in the module instance system id
 */
#define IAXXX_SYSID_MASK_MODULE_TYPE              (0x01F0)

/** Bit offset of the 'module instance number' field
 * in the module instance system id
 */
#define IAXXX_SYSID_POS_MODULE_INST               (0)
/** Bit mask of the 'module instance number' field
 * in the module instance system id
 */
#define IAXXX_SYSID_MASK_MODULE_INST              (0x000F)


/** Bit offset of the 'plugin id' field in the plugin system id
 */
#define IAXXX_SYSID_POS_PLUGIN_ID                 (6)
/** Bit mask of the 'plugin id' field in the plugin system id
 */
#define IAXXX_SYSID_MASK_PLUGIN_ID                (0x0FC0)

/** Bit offset of the 'plugin endpoint direction' field
 * in the plugin system id
 */
#define IAXXX_SYSID_POS_PLUGIN_EP_DIR             (5)
/** Bit mask of the 'plugin endpoint direction' field
 * in the plugin system id
 */
#define IAXXX_SYSID_MASK_PLUGIN_EP_DIR            (0x0020)

/** Bit offset of the 'plugin endpoint index' field in the plugin system id
 */
#define IAXXX_SYSID_POS_PLUGIN_EP_INDEX           (0)
/** Bit mask of the 'plugin endpoint index' field in the plugin system id
 */
#define IAXXX_SYSID_MASK_PLUGIN_EP_INDEX          (0x001F)


/** Bit offset of the 'channel id' field
 *  in the channel system id
 */
#define IAXXX_SYSID_POS_CHANNEL_ID                (6)
/** Bit mask of the 'channel id' field in the channel system id
 */
#define IAXXX_SYSID_MASK_CHANNEL_ID               (0x0FC0)

/** Bit offset of the 'channel endpoint direction' field
 * in the channel system id
 */
#define IAXXX_SYSID_POS_CHANNEL_EP_DIR            (5)
/** Bit mask of the 'channel endpoint direction' field
 * in the channel system id
 */
#define IAXXX_SYSID_MASK_CHANNEL_EP_DIR           (0x0020)

/** Bit offset of the 'channel endpoint index' field
 * in the channel system id
 */
#define IAXXX_SYSID_POS_CHANNEL_EP_INDEX          (0)
/** Bit mask of the 'channel endpoint index' field
 * in the channel system id
 */
#define IAXXX_SYSID_MASK_CHANNEL_EP_INDEX         (0x001F)


/** Bit offset of the 'tunnel id' field in the tunnel system id
 */
#define IAXXX_SYSID_POS_TUNNEL_ID                 (6)
/** Bit mask of the 'tunnel id' field in the tunnel system id
 */
#define IAXXX_SYSID_MASK_TUNNEL_ID                (0x0FC0)

/** Bit offset of the 'tunnel endpoint direction' field
 * in the tunnel system id
 */
#define IAXXX_SYSID_POS_TUNNEL_EP_DIR             (5)
/** Bit mask of the 'tunnel endpoint direction' field
 * in the tunnel system id
 */
#define IAXXX_SYSID_MASK_TUNNEL_EP_DIR            (0x0020)

/** Bit offset of the 'tunnel endpoint index' field
 * in the tunnel system id
 */
#define IAXXX_SYSID_POS_TUNNEL_EP_INDEX           (0)
/** Bit mask of the 'tunnel endpoint index' field
 * in the tunnel system id
 */
#define IAXXX_SYSID_MASK_TUNNEL_EP_INDEX          (0x001F)


/** Bit offset of the 'BT ' field in the bt endpoint system id
 */
#define IAXXX_SYSID_POS_BT_ID                     (6)
/** Bit mask of the 'bt id' field in the bt endpoint system id
 */
#define IAXXX_SYSID_MASK_BT_ID                    (0x0FC0)

/** Bit offset of the 'BT endpoint direction' field
 * in the BT endpoint system id
 */
#define IAXXX_SYSID_POS_BT_EP_DIR                 (5)
/** Bit mask of the 'BT endpoint direction' field
 * in the BT endpoint system id
 */
#define IAXXX_SYSID_MASK_BT_EP_DIR                (0x0020)

/** Bit offset of the 'BT endpoint index' field
 * in the BT endpoint system id
 */
#define IAXXX_SYSID_POS_BT_EP_INDEX               (0)
/** Bit mask of the 'BT endpoint index' field
 * in the BT endpoint system id
 */
#define IAXXX_SYSID_MASK_BT_EP_INDEX              (0x001F)


/** Bit offset of the 'FILE ' field in the file endpoint system id
 */
#define IAXXX_SYSID_POS_FILE_ID                   (6)
/** Bit mask of the 'flie id' field in the file endpoint system id
 */
#define IAXXX_SYSID_MASK_FILE_ID                  (0x0FC0)

/** Bit offset of the 'FILE endpoint direction' field
 * in the FILE endpoint system id
 */
#define IAXXX_SYSID_POS_FILE_EP_DIR               (5)
/** Bit mask of the 'FILE endpoint direction' field
 * in the FILE endpoint system id
 */
#define IAXXX_SYSID_MASK_FILE_EP_DIR              (0x0020)

/** Bit offset of the 'FILE endpoint index' field
 * in the FILE endpoint system id
 */
#define IAXXX_SYSID_POS_FILE_EP_INDEX             (0)
/** Bit mask of the 'FILE endpoint index' field
 * in the FILE endpoint system id
 */
#define IAXXX_SYSID_MASK_FILE_EP_INDEX            (0x001F)
/** Bit offset of the 'Sensor ' field in the sensor endpoint system id
 */
#define IAXXX_SYSID_POS_SENSOR_ID                 (6)
/** Bit mask of the 'sensor id' field in the sensor endpoint system id
 */
#define IAXXX_SYSID_MASK_SENSOR_ID                (0x0FC0)

/** Bit offset of the 'Sensor endpoint direction' field
 * in the Sensor endpoint system id
 */
#define IAXXX_SYSID_POS_SENSOR_EP_DIR             (5)
/** Bit mask of the 'Sensor endpoint direction' field
 * in the Sensor endpoint system id
 */
#define IAXXX_SYSID_MASK_SENSOR_EP_DIR            (0x0020)

/** Bit offset of the 'Sensor endpoint index' field
 * in the Sensor endpoint system id
 */
#define IAXXX_SYSID_POS_SENSOR_EP_INDEX           (0)
/** Bit mask of the 'Sensor endpoint index' field
 * in the Sensor endpoint system id
 */
#define IAXXX_SYSID_MASK_SENSOR_EP_INDEX          (0x001F)


/** Debug
 *
 *  ----------------------------------------------
 *  | Resource ID | Proc ID | Type | Dir | Index |
 *  ----------------------------------------------
 * bits   4           3        3      1      5
 */
/** Bit offset of the 'debug proc ' field
 *  in the debug endpoint system id
 */
#define IAXXX_SYSID_POS_DEBUG_PROC_ID             (9)
/** Bit mask of the 'debug proc' field
 *  in the debug endpoint system id
 */
#define IAXXX_SYSID_MASK_DEBUG_PROC_ID            (0x0E00)

/** Bit offset of the 'debug type' field
 *  in the debug endpoint system id
 */
#define IAXXX_SYSID_POS_DEBUG_TYPE                (6)
/** Bit mask of the 'debug type' field
 *  in the debug endpoint system id
 */
#define IAXXX_SYSID_MASK_DEBUG_TYPE               (0x01C0)

/** Bit offset of the 'debug endpoint direction' field
 * in the debug endpoint system id
 */
#define IAXXX_SYSID_POS_DEBUG_EP_DIR              (5)
/** Bit mask of the 'debug endpoint direction' field
 * in the debug endpoint system id
 */
#define IAXXX_SYSID_MASK_DEBUG_EP_DIR             (0x0020)

/** Bit offset of the 'debug endpoint index' field
 * in the debug endpoint system id
 */
#define IAXXX_SYSID_POS_DEBUG_EP_INDEX            (0)
/** Bit mask of the 'debug endpoint index' field
 * in the debug endpoint system id
 */
#define IAXXX_SYSID_MASK_DEBUG_EP_INDEX           (0x001F)


/** Bit offset of the 'stream id' field in the stream system id
 */
#define IAXXX_SYSID_POS_STREAM_ID                 (0)
/** Bit mask of the 'stream id' field in the stream system id
 */
#define IAXXX_SYSID_MASK_STREAM_ID                (0x001F)


/** Bit offset of the 'device id' field in the device system id
 */
#define IAXXX_SYSID_POS_DEVICE_ID                 (6)
/** Bit mask of the 'device id' field
 *  in the device system id
 */
#define IAXXX_SYSID_MASK_DEVICE_ID                (0x0FC0)

/** Bit offset of the 'device instance' field
 * in the device system id
 */
#define IAXXX_SYSID_POS_DEVICE_INST               (0)
/** Bit mask of the 'device instance' field
 * in the device system id
 */
#define IAXXX_SYSID_MASK_DEVICE_INST              (0x003F)


/************************************************************************//**
 * @}
 ***************************************************************************/



/************************************************************************//**
 * @defgroup sysid_macros Macros
 * @{
 ***************************************************************************/

/** Get the resource type from the system id
 */
#define IAXXX_SYSID_GET_RESOURCE_TYPE(id)                    \
(((id) & IAXXX_SYSID_MASK_RESOURCE_TYPE) >> IAXXX_SYSID_POS_RESOURCE_TYPE)

/** Evaluates to true if the system id is
 *  special resource system id
 */
#define IAXXX_SYSID_IS_SPECIAL(id)                           \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_SPECIAL)

/** Evaluates to true if the system id is driver system id
 */
#define IAXXX_SYSID_IS_DRIVER(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_DRIVER)

/** Evaluates to true if the system id is
 *  device (peripheral) system id
 */
#define IAXXX_SYSID_IS_DEVICE(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_DEVICE)

/** Evaluates to true if the system id is module instance system id
 */
#define IAXXX_SYSID_IS_MODULE(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_MODULE)

/** Evaluates to true if the system id is plugin instance system id
 */
#define IAXXX_SYSID_IS_PLUGIN(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_PLUGIN)

/** Evaluates to true if the system id is channel system id
 */
#define IAXXX_SYSID_IS_CHANNEL(id)                           \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_CHANNEL)

/** Evaluates to true if the system id is tunnel system id
 */
#define IAXXX_SYSID_IS_TUNNEL(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_TUNNEL)

/** Evaluates to true if the system id is stream system id
 */
#define IAXXX_SYSID_IS_STREAM(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_STREAM)

/** Evaluates to true if the system id is Bluetooth system id
 */
#define IAXXX_SYSID_IS_BT(id)                                \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_BT)

/** Evaluates to true if the system id is sensor system id
 */
#define IAXXX_SYSID_IS_SENSOR(id)                            \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_SENSOR)

/** Evaluates to true if the system id is debug system id
 */
#define IAXXX_SYSID_IS_DEBUG(id)                             \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) == IAXXX_SYSID_RESOURCE_TYPE_DEBUG)

/** Evaluates to true if the system id is host system id
 */
#define IAXXX_SYSID_IS_HOST(id) ((IAXXX_SYSID_IS_SPECIAL(id)) &&   \
	(IAXXX_SYSID_GET_SPECIAL_TYPE(id) == IAXXX_SYSID_SPECIAL_TYPE_HOST))

/** Evaluates to true if the system id is file system id
 */
#define IAXXX_SYSID_IS_FILE(id)                              \
	(IAXXX_SYSID_GET_RESOURCE_TYPE(id) ==  IAXXX_SYSID_RESOURCE_TYPE_FILE)

/* Special Resource type System Ids */
#define IAXXX_SYSID_GEN_SPECIAL_SYSID(type, index)                   \
(((IAXXX_SYSID_RESOURCE_TYPE_SPECIAL << IAXXX_SYSID_POS_RESOURCE_TYPE)     \
		      & IAXXX_SYSID_MASK_RESOURCE_TYPE)   |              \
(((type)                       << IAXXX_SYSID_POS_SPECIAL_TYPE)      \
		      & IAXXX_SYSID_MASK_SPECIAL_TYPE)    |              \
(((index)                      << IAXXX_SYSID_POS_SPECIAL_INST_INDEX)\
		      & IAXXX_SYSID_MASK_SPECIAL_INST_INDEX))

/** Get the special resource type from the driver system id
 */
#define IAXXX_SYSID_GET_SPECIAL_TYPE(sysId)                  \
(((sysId) & IAXXX_SYSID_MASK_SPECIAL_TYPE) >> IAXXX_SYSID_POS_SPECIAL_TYPE)
/** Get the driver instance index from the driver system id
 */
#define IAXXX_SYSID_GET_SPECIAL_INST_INDEX(sysId)            \
	    (((sysId) & IAXXX_SYSID_MASK_SPECIAL_INST_INDEX)     \
		      >> IAXXX_SYSID_POS_SPECIAL_INST_INDEX)

/** Get the special resource type host's ctrl Id
 *  from the system id
 */
#define IAXXX_SYSID_GET_HOST_ID(sysId)                         \
			IAXXX_SYSID_GET_SPECIAL_INST_INDEX(sysId)


/** Generate the driver system id given the type and index
 */
#define IAXXX_SYSID_GEN_DRIVER_SYSID(type, index)                  \
(((IAXXX_SYSID_RESOURCE_TYPE_DRIVER << IAXXX_SYSID_POS_RESOURCE_TYPE)    \
				 & IAXXX_SYSID_MASK_RESOURCE_TYPE)   | \
(((type)                      << IAXXX_SYSID_POS_DRIVER_TYPE)      \
				 & IAXXX_SYSID_MASK_DRIVER_TYPE)     | \
(((index)                     << IAXXX_SYSID_POS_DRIVER_INST_INDEX)\
				 & IAXXX_SYSID_MASK_DRIVER_INST_INDEX))

/** Get the driver type from the driver system id
 */
#define IAXXX_SYSID_GET_DRIVER_TYPE(sysId)                        \
(((sysId) & IAXXX_SYSID_MASK_DRIVER_TYPE) >> IAXXX_SYSID_POS_DRIVER_TYPE)
/** Get the driver instance index from the driver system id
 */
#define IAXXX_SYSID_GET_DRIVER_INST_INDEX(sysId)             \
		(((sysId) & IAXXX_SYSID_MASK_DRIVER_INST_INDEX)  \
			   >> IAXXX_SYSID_POS_DRIVER_INST_INDEX)


/**Generate the module instance system id given the processor id,
 * module type and module instance number
 */
#define IAXXX_SYSID_GEN_MODULE_SYSID(procId, modType, modInst)  \
(((IAXXX_SYSID_RESOURCE_TYPE_MODULE << IAXXX_SYSID_POS_RESOURCE_TYPE) \
			    & IAXXX_SYSID_MASK_RESOURCE_TYPE)  |    \
(((procId)                   << IAXXX_SYSID_POS_MODULE_PROC_ID) \
			    & IAXXX_SYSID_MASK_MODULE_PROC_ID) |    \
(((modType)                  << IAXXX_SYSID_POS_MODULE_TYPE)    \
			    & IAXXX_SYSID_MASK_MODULE_TYPE)    |    \
(((modInst)                  << IAXXX_SYSID_POS_MODULE_INST)    \
			    & IAXXX_SYSID_MASK_MODULE_INST))

/** Get the module processor id from
 * the module instance system id
 */
#define IAXXX_SYSID_GET_MODULE_PROC_ID(sysId)                \
		    (((sysId) & IAXXX_SYSID_MASK_MODULE_PROC_ID) \
			      >> IAXXX_SYSID_POS_MODULE_PROC_ID)
/** Get the module type from the module instance system id
 */
#define IAXXX_SYSID_GET_MODULE_TYPE(sysId)                       \
(((sysId) & IAXXX_SYSID_MASK_MODULE_TYPE) >> IAXXX_SYSID_POS_MODULE_TYPE)
/** Get the module instance number from
 *  the module instance system id
 */
#define IAXXX_SYSID_GET_MODULE_INST(sysId)                       \
(((sysId) & IAXXX_SYSID_MASK_MODULE_INST) >> IAXXX_SYSID_POS_MODULE_INST)


/** Special index value to indicate that the system id refer to
 * plugin instance and not an endpoint of a plugin instance
 */
#define IAXXX_SYSID_INDEX_VALUE_PLUGIN_INST   (0x001F)

/**Generate the plugin (endpoint) system id given the plugin id,
 * direction and index
 */
#define IAXXX_SYSID_GEN_PLUGIN_SYSID(pluginId, dir, index)       \
(((IAXXX_SYSID_RESOURCE_TYPE_PLUGIN << IAXXX_SYSID_POS_RESOURCE_TYPE)  \
		   & IAXXX_SYSID_MASK_RESOURCE_TYPE)    |            \
(((pluginId)                 << IAXXX_SYSID_POS_PLUGIN_ID)       \
		   & IAXXX_SYSID_MASK_PLUGIN_ID)        |            \
(((dir)                      << IAXXX_SYSID_POS_PLUGIN_EP_DIR)   \
		   & IAXXX_SYSID_MASK_PLUGIN_EP_DIR)    |            \
(((index)                    << IAXXX_SYSID_POS_PLUGIN_EP_INDEX) \
		   & IAXXX_SYSID_MASK_PLUGIN_EP_INDEX))

/** Get the plugin id from the plugin (endpoint) system id
 */
#define IAXXX_SYSID_GET_PLUGIN_ID(sysId)                      \
	   (((sysId) & IAXXX_SYSID_MASK_PLUGIN_ID) >> IAXXX_SYSID_POS_PLUGIN_ID)
/** Get the plugin endpoint direction from the plugin (endpoint) system id
 */
#define IAXXX_SYSID_GET_PLUGIN_EP_DIR(sysId)                  \
(((sysId) & IAXXX_SYSID_MASK_PLUGIN_EP_DIR) >> IAXXX_SYSID_POS_PLUGIN_EP_DIR)
/** Get the plugin endpoint index from the plugin (endpoint) system id
 */
#define IAXXX_SYSID_GET_PLUGIN_EP_INDEX(sysId)       (((sysId) & \
	IAXXX_SYSID_MASK_PLUGIN_EP_INDEX) >> IAXXX_SYSID_POS_PLUGIN_EP_INDEX)


/** Special index value to indicate that the system id refer to
 * channel and not an endpoint of the channel
 */
#define IAXXX_SYSID_INDEX_VALUE_CHANNEL   (0x001F)

/** Generate the channel (endpoint) system id given the channel id,
 * direction and index
 */
#define IAXXX_SYSID_GEN_CHANNEL_SYSID(channelId, dir, index)       \
(((IAXXX_SYSID_RESOURCE_TYPE_CHANNEL << IAXXX_SYSID_POS_RESOURCE_TYPE)   \
			      & IAXXX_SYSID_MASK_RESOURCE_TYPE)    |   \
(((channelId)                 << IAXXX_SYSID_POS_CHANNEL_ID)       \
			      & IAXXX_SYSID_MASK_CHANNEL_ID)       |   \
(((dir)                       << IAXXX_SYSID_POS_CHANNEL_EP_DIR)   \
			      & IAXXX_SYSID_MASK_CHANNEL_EP_DIR)   |   \
(((index)                     << IAXXX_SYSID_POS_CHANNEL_EP_INDEX) \
			      & IAXXX_SYSID_MASK_CHANNEL_EP_INDEX))

/** Get the channel id from the channel (endpoint) system id
 */
#define IAXXX_SYSID_GET_CHANNEL_ID(sysId)                       \
(((sysId) & IAXXX_SYSID_MASK_CHANNEL_ID) >> IAXXX_SYSID_POS_CHANNEL_ID)
/** Get the channel endpoint direction from
 *  the channel (endpoint) system id
 */
#define IAXXX_SYSID_GET_CHANNEL_EP_DIR(sysId) \
(((sysId) & IAXXX_SYSID_MASK_CHANNEL_EP_DIR)  \
		 >> IAXXX_SYSID_POS_CHANNEL_EP_DIR)
/** Get the channel endpoint index from
 *  the channel (endpoint) system id
 */
#define IAXXX_SYSID_GET_CHANNEL_EP_INDEX(sysId) \
(((sysId) & IAXXX_SYSID_MASK_CHANNEL_EP_INDEX)  \
	      >> IAXXX_SYSID_POS_CHANNEL_EP_INDEX)


/** Special index value to indicate that the system id refer to
 * tunnel and not an endpoint of the tunnel
 */
#define IAXXX_SYSID_INDEX_VALUE_TUNNEL   (0x001F)

/** Generate the tunnel (endpoint) system id give the tunnel id,
 * direction and index
 */
#define IAXXX_SYSID_GEN_TUNNEL_SYSID(tunnelId, dir, index)       \
(((IAXXX_SYSID_RESOURCE_TYPE_TUNNEL << IAXXX_SYSID_POS_RESOURCE_TYPE)  \
			   & IAXXX_SYSID_MASK_RESOURCE_TYPE)    |    \
(((tunnelId)                 << IAXXX_SYSID_POS_TUNNEL_ID)       \
			   & IAXXX_SYSID_MASK_TUNNEL_ID)        |    \
(((dir)                      << IAXXX_SYSID_POS_TUNNEL_EP_DIR)   \
			   & IAXXX_SYSID_MASK_TUNNEL_EP_DIR)    |    \
(((index)                    << IAXXX_SYSID_POS_TUNNEL_EP_INDEX) \
			   & IAXXX_SYSID_MASK_TUNNEL_EP_INDEX))

/** Get the tunnel id from the tunnel (endpoint) system id
 */
#define IAXXX_SYSID_GET_TUNNEL_ID(sysId)                     \
(((sysId) & IAXXX_SYSID_MASK_TUNNEL_ID) >> IAXXX_SYSID_POS_TUNNEL_ID)
/** Get the tunnel endpoint direction from
 *  the tunnel (endpoint) system id
 */
#define IAXXX_SYSID_GET_TUNNEL_EP_DIR(sysId)                 \
		    (((sysId) & IAXXX_SYSID_MASK_TUNNEL_EP_DIR)  \
			      >> IAXXX_SYSID_POS_TUNNEL_EP_DIR)
/** Get the tunnel endpoint index from
 *  the tunnel (endpoint) system id
 */
#define IAXXX_SYSID_GET_TUNNEL_EP_INDEX(sysId)               \
		(((sysId) & IAXXX_SYSID_MASK_TUNNEL_EP_INDEX)    \
			  >> IAXXX_SYSID_POS_TUNNEL_EP_INDEX)


/** Generate the BT (endpoint) system id give the bt id,
 *  direction and index
 */
#define IAXXX_SYSID_GEN_BT_SYSID(btId, dir, index)               \
	(((IAXXX_SYSID_RESOURCE_TYPE_BT << IAXXX_SYSID_POS_RESOURCE_TYPE)  \
			   & IAXXX_SYSID_MASK_RESOURCE_TYPE)    |    \
	(((btId)                 << IAXXX_SYSID_POS_BT_ID)           \
			   & IAXXX_SYSID_MASK_BT_ID)            |    \
	(((dir)                  << IAXXX_SYSID_POS_BT_EP_DIR)       \
			   & IAXXX_SYSID_MASK_BT_EP_DIR)        |    \
	(((index)                << IAXXX_SYSID_POS_BT_EP_INDEX)     \
			   & IAXXX_SYSID_MASK_BT_EP_INDEX))

/** Get the bt id from the bt (endpoint) system id
 */
#define IAXXX_SYSID_GET_BT_ID(sysId)                             \
	    (((sysId) & IAXXX_SYSID_MASK_BT_ID) >> IAXXX_SYSID_POS_BT_ID)
/** Get the bt endpoint direction from
 *  the bt (endpoint) system id
 */
#define IAXXX_SYSID_GET_BT_EP_DIR(sysId)                         \
(((sysId) & IAXXX_SYSID_MASK_BT_EP_DIR) >> IAXXX_SYSID_POS_BT_EP_DIR)
/** Get the bt endpoint index from the bt (endpoint) system id
 */
#define IAXXX_SYSID_GET_BT_EP_INDEX(sysId)                       \
(((sysId) & IAXXX_SYSID_MASK_BT_EP_INDEX) >> IAXXX_SYSID_POS_BT_EP_INDEX)


/** Generate the File endpoint system id give the bt id,
 * direction and index
 */
#define IAXXX_SYSID_GEN_FILE_SYSID(fileId, dir, index)              \
(((IAXXX_SYSID_RESOURCE_TYPE_FILE << IAXXX_SYSID_POS_RESOURCE_TYPE) &     \
			   IAXXX_SYSID_MASK_RESOURCE_TYPE)  |           \
(((fileId)                 << IAXXX_SYSID_POS_FILE_ID)        &     \
			   IAXXX_SYSID_MASK_FILE_ID)        |           \
(((dir)                    << IAXXX_SYSID_POS_FILE_EP_DIR)    &     \
			   IAXXX_SYSID_MASK_FILE_EP_DIR)    |           \
(((index)                  << IAXXX_SYSID_POS_FILE_EP_INDEX)  &     \
			   IAXXX_SYSID_MASK_FILE_EP_INDEX))

/** Get the file endpoint id from the file endpoint system id
 */
#define IAXXX_SYSID_GET_FILE_ID(sysId)                           \
	(((sysId) & IAXXX_SYSID_MASK_FILE_ID) >> IAXXX_SYSID_POS_FILE_ID)
/** Get the file endpoint direction from
 *  the file (endpoint) system id
 */
#define IAXXX_SYSID_GET_FILE_EP_DIR(sysId)                       \
(((sysId) & IAXXX_SYSID_MASK_FILE_EP_DIR) >> IAXXX_SYSID_POS_FILE_EP_DIR)
/** Get the file endpoint index from
 *  the file (endpoint) system id
 */
#define IAXXX_SYSID_GET_FILE_EP_INDEX(sysId)  \
(((sysId) & IAXXX_SYSID_MASK_FILE_EP_INDEX)   \
		 >> IAXXX_SYSID_POS_FILE_EP_INDEX)

/** Generate the Sensor(endpoint) system id give the Sensor id,
 *direction and index
 */
#define IAXXX_SYSID_GEN_SENSOR_SYSID(sensorId, dir, index)      \
(((IAXXX_SYSID_RESOURCE_TYPE_SENSOR << IAXXX_SYSID_POS_RESOURCE_TYPE) \
			   & IAXXX_SYSID_MASK_RESOURCE_TYPE)    |   \
(((sensorId)                 << IAXXX_SYSID_POS_SENSOR_ID)      \
			   & IAXXX_SYSID_MASK_SENSOR_ID)        |   \
(((dir)                      << IAXXX_SYSID_POS_SENSOR_EP_DIR)  \
			   & IAXXX_SYSID_MASK_SENSOR_EP_DIR)    |   \
(((index)                    << IAXXX_SYSID_POS_SENSOR_EP_INDEX)\
			   & IAXXX_SYSID_MASK_SENSOR_EP_INDEX))


/** Get the sensor id from the sensor (endpoint) system id
 */
#define IAXXX_SYSID_GET_SENSOR_ID(sysId)                         \
	(((sysId) & IAXXX_SYSID_MASK_SENSOR_ID) >> IAXXX_SYSID_POS_SENSOR_ID)
/** Get the sensor endpoint direction from
 *  the sensor (endpoint) system id
 */
#define IAXXX_SYSID_GET_SENSOR_EP_DIR(sysId)                  \
		    (((sysId) & IAXXX_SYSID_MASK_SENSOR_EP_DIR)   \
				 >> IAXXX_SYSID_POS_SENSOR_EP_DIR)
/** Get the sensor endpoint index from
 *  the sensor (endpoint) system id
 */
#define IAXXX_SYSID_GET_SENSOR_EP_INDEX(sysId)               \
		(((sysId) & IAXXX_SYSID_MASK_SENSOR_EP_INDEX)    \
			   >> IAXXX_SYSID_POS_SENSOR_EP_INDEX)


/** Generate the Debug(endpoint) system id give the Debug id,
 * type direction and index
 */
#define IAXXX_SYSID_GEN_DEBUG_SYSID(procId, type, dir, index)   \
(((IAXXX_SYSID_RESOURCE_TYPE_DEBUG  << IAXXX_SYSID_POS_RESOURCE_TYPE) \
		       & IAXXX_SYSID_MASK_RESOURCE_TYPE)     |      \
(((procId)                   << IAXXX_SYSID_POS_DEBUG_PROC_ID)  \
		       & IAXXX_SYSID_MASK_DEBUG_PROC_ID)     |      \
(((type)                     << IAXXX_SYSID_POS_DEBUG_TYPE)     \
		       & IAXXX_SYSID_MASK_DEBUG_TYPE)        |      \
(((dir)                      << IAXXX_SYSID_POS_DEBUG_EP_DIR)   \
		       & IAXXX_SYSID_MASK_DEBUG_EP_DIR)      |      \
(((index)                    << IAXXX_SYSID_POS_DEBUG_EP_INDEX) \
		       & IAXXX_SYSID_MASK_DEBUG_EP_INDEX))

/** Get the debug core from the debug (endpoint) system id
 */
#define IAXXX_SYSID_GET_DEBUG_CORE(sysId)                       \
			(((sysId) & IAXXX_SYSID_MASK_DEBUG_PROC_ID) \
				  >> IAXXX_SYSID_POS_DEBUG_PROC_ID)
/** Get the debug type from the debug (endpoint) system id
 */
#define IAXXX_SYSID_GET_DEBUG_TYPE(sysId)                        \
			(((sysId) & IAXXX_SYSID_MASK_DEBUG_TYPE)     \
				  >> IAXXX_SYSID_POS_DEBUG_TYPE)
/** Get the debug endpoint direction from
 *  the debug (endpoint) system id
 */
#define IAXXX_SYSID_GET_DEBUG_EP_DIR(sysId)                      \
(((sysId) & IAXXX_SYSID_MASK_DEBUG_EP_DIR) >> IAXXX_SYSID_POS_DEBUG_EP_DIR)
/** Get the debug endpoint index from
 *  the debug (endpoint) system id
 */
#define IAXXX_SYSID_GET_DEBUG_EP_INDEX(sysId)                  \
		    (((sysId) & IAXXX_SYSID_MASK_DEBUG_EP_INDEX)   \
			      >> IAXXX_SYSID_POS_DEBUG_EP_INDEX)


/** Generate the stream system id given the stream number
 */
#define IAXXX_SYSID_GEN_STREAM_SYSID(streamId)                      \
	(((IAXXX_SYSID_RESOURCE_TYPE_STREAM << IAXXX_SYSID_POS_RESOURCE_TYPE) \
			       & IAXXX_SYSID_MASK_RESOURCE_TYPE)  |     \
	(((streamId)                  << IAXXX_SYSID_POS_STREAM_ID)     \
			       & IAXXX_SYSID_MASK_STREAM_ID))

/** Get the stream number from the stream system id
 */
#define IAXXX_SYSID_GET_STREAM_ID(sysId)                       \
(((sysId) & IAXXX_SYSID_MASK_STREAM_ID) >> IAXXX_SYSID_POS_STREAM_ID)


/** Generate the device system id
 *  given the device id and instance number
 */
#define IAXXX_SYSID_GEN_DEVICE_SYSID(deviceId, inst)                \
	(((IAXXX_SYSID_RESOURCE_TYPE_DEVICE << IAXXX_SYSID_POS_RESOURCE_TYPE) \
			       & IAXXX_SYSID_MASK_RESOURCE_TYPE) |      \
		 (((deviceId) << IAXXX_SYSID_POS_DEVICE_ID)             \
			       & IAXXX_SYSID_MASK_DEVICE_ID)     |      \
		 (((inst)     << IAXXX_SYSID_POS_DEVICE_INST)           \
			       & IAXXX_SYSID_MASK_DEVICE_INST))

/** Get the device id from the device system id
 */
#define IAXXX_SYSID_GET_DEVICE_ID(sysId)                           \
	(((sysId) & IAXXX_SYSID_MASK_DEVICE_ID) >> IAXXX_SYSID_POS_DEVICE_ID)
/** Get the device instance number from the device system id
 */
#define IAXXX_SYSID_GET_DEVICE_INST(sysId)                        \
(((sysId) & IAXXX_SYSID_MASK_DEVICE_INST) >> IAXXX_SYSID_POS_DEVICE_INST)


/************************************************************************//**
 * @}
 ***************************************************************************/

/************************************************************************//**
 * @defgroup sysid_special Special Resource System Ids
 * @{
 ***************************************************************************/

/** Invalid system id
 */
#define IAXXX_SYSID_INVALID                                       \
	    IAXXX_SYSID_GEN_SPECIAL_SYSID(IAXXX_SYSID_SPECIAL_TYPE_INVALID, 0)

/** System id for host
 */
#define IAXXX_SYSID_HOST                                           \
		IAXXX_SYSID_GEN_SPECIAL_SYSID(IAXXX_SYSID_SPECIAL_TYPE_HOST, 0)
#define IAXXX_SYSID_HOST_0                                         \
		IAXXX_SYSID_GEN_SPECIAL_SYSID(IAXXX_SYSID_SPECIAL_TYPE_HOST, 0)
#define IAXXX_SYSID_HOST_1                                         \
		IAXXX_SYSID_GEN_SPECIAL_SYSID(IAXXX_SYSID_SPECIAL_TYPE_HOST, 1)

/*************************************************************************//**
 * @}
 ****************************************************************************/

/*************************************************************************//**
 * @defgroup sysid_const Constants
 * @{
 ****************************************************************************/

/************************************************************************//**
 * System ID type
 ****************************************************************************/


/*************************************************************************//**
 * @}
 ****************************************************************************/

/*************************************************************************//**
 * @}
 ****************************************************************************/

#endif
/* Header sentinel */

/* EOF */

