blob: 51226db956f9832e1ecd27b4cd8df67693b7e47b [file] [log] [blame]
#ifndef __DXS_LIB_H__
#define __DXS_LIB_H__
/******************************************************************************
Copyright (c) 2014-2015 Lantiq Deutschland GmbH
Copyright (c) 2015-2016 Lantiq Beteiligungs-GmbH & Co.KG
Copyright 2016, Intel Corporation.
For licensing information, see the file 'LICENSE' in the root folder of
this software module.
******************************************************************************/
/**
\file dxs_lib.h
This file contains the device and channel structure definitions.
*/
/* ========================================================================== */
/* Includes */
/* ========================================================================== */
#include "dxs_config.h"
#include <stdint.h>
#include <semaphore.h>
#include <string.h>
#include <pthread.h>
#include <endian.h>
#include "dxs_fifo.h"
#ifdef EVENT_LOGGER_DEBUG
#include <linux/ioctl.h>
#include "el_ioctl.h"
#endif /* EVENT_LOGGER_DEBUG */
/* ========================================================================== */
/* Macro definitions */
/* ========================================================================== */
#define CH_PER_DEVICE 2
#ifdef EVENT_LOGGER_DEBUG
#define DXS_LIB_DEV_TYPE 17
#endif
#define POINTER_ASSERT(pPointer) \
do \
{ \
if (pPointer == NULL) \
{ \
DXS_RETURN(DXS_statusInvalidParam); \
} \
} while (0)
/* ========================================================================== */
/* Type definitions */
/* ========================================================================== */
typedef struct dxs_device_t DXS_DEVICE_t;
typedef struct dxs_channel_t DXS_CHANNEL_t;
/* dxs_hsm.h uses DXS_CHANNEL_t, therefore it should be placed after the
* typedef of DXS_CHANNEL_t*/
#include "dxs_hsm.h"
/** Channel structure */
struct dxs_channel_t
{
/** channel number starting from 0 */
uint8_t nCh;
/** status flags */
#define DXS_CH_BBD_DOWNLOADED 0x00000001
#define DXS_CH_DIAL_DATA_INITIALIZED 0x00000008
volatile uint32_t flags;
/** pointer to parent device */
DXS_DEVICE_t *pParent;
/* mask for event reporting, 64 bits */
uint32_t event_mask[2];
/** PCM resource */
void *pcm;
/** SDD resource */
void *sdd;
/** SIG resource */
void *sig;
#ifdef DXS_FEAT_HSM
DXS_DIAL_DATA_t DXS_DialData;
#endif /* DXS_FEAT_HSM */
void *ring;
};
/** Device structure */
struct dxs_device_t
{
/** device number */
uint8_t nDevNum;
/** chip select number */
uint8_t chipSelect;
/** IRQ line number */
int32_t irqNumber;
/** DCDC variant */
uint8_t dcdcType;
/** Access mode */
DXS_ACCESS_MODE_t access;
/** device status flags */
#define DXS_DEV_INITIALIZED 0x00000001
#define DXS_DEV_PRAM_PATCH_DOWNLOADED 0x00000002
#define DXS_DEV_OBX_HND_INITIALIZED 0x00000004
#define DXS_DEV_ACCESS_INITIALIZED 0x00000008
volatile uint32_t flags;
/** SPI device fd */
int spidev;
/** Device ROM mask version */
uint32_t rom_mask_ver;
/** Patch download sync sem */
sem_t mtxPatchDwld;
/** Waiting status flag */
volatile uint32_t bWaitingInPatchDwld;
/** outbox data serving thread */
pthread_t obxThread;
/** outbox data thread semaphore */
sem_t obxSemaphore;
/** signaling semaphore used by
the outbox thread for command
read response */
sem_t obxCmdDataSem;
/** condition to stop the thread */
volatile uint8_t obxThreadStop;
/** Flag to discard events.
Used at startup until the startup finished event is received. */
uint8_t obxDiscardEvents;
/** mailbox access mutex */
pthread_mutex_t mtxMbxAcc;
/** cached command inbox length */
uint8_t nMbxCachedCbiLen;
/** event queue */
FIFO_t *event_queue;
/** command outbox data queue */
FIFO_t *cmd_obx_queue;
/** waiting list (the device is a member of) */
void *wait_list;
/* ======= fw capabilities: ====== */
/** actual analog channels count */
uint8_t nChannels;
/** capabilities handler */
void *caps;
/* === end of fw capabilities: === */
/* TODO: last error */
/** device event memory pool */
void *event_pool;
/** pcm resource handler */
void *pcm;
/** GPIO resource */
void *gpio;
/* 2022-3-17, expand array size from 32 to 512.
*
* DXS_ObxRead does not check array boundary;
* This will protect memory afterwards from overwritten.
*/
/** copy of the mailbox */
uint16_t dmbx[512];
/** channel array */
DXS_CHANNEL_t pChannel[CH_PER_DEVICE];
#ifdef EVENT_LOGGER_DEBUG
int32_t el_fd;
#endif
};
/* ========================================================================== */
/* Function prototypes */
/* ========================================================================== */
#endif /* __DXS_LIB_H__ */