lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*******************************************************************************
|
| 2 | * Copyright (C) 2007, ZTE Corporation.
|
| 3 | *
|
| 4 | * File Name:
|
| 5 | * File Mark:
|
| 6 | * Description:
|
| 7 | * Others:
|
| 8 | * Version: 1.0
|
| 9 | * Author: weizhigang
|
| 10 | * Date: 2010-8-6
|
| 11 | * History 1:
|
| 12 | * Date:
|
| 13 | * Version:
|
| 14 | * Author:
|
| 15 | * Modification:
|
| 16 | * History 2:
|
| 17 | ********************************************************************************/
|
| 18 |
|
| 19 | #ifndef _DRVS_SSP_H
|
| 20 | #define _DRVS_SSP_H
|
| 21 |
|
| 22 |
|
| 23 | /****************************************************************************
|
| 24 | * Include files
|
| 25 | ****************************************************************************/
|
| 26 | #include "drvs_dma.h"
|
| 27 |
|
| 28 | /****************************************************************************
|
| 29 | * Macros
|
| 30 | ****************************************************************************/
|
| 31 | //#define SSP_INT_ENABLE 0
|
| 32 | //#define SSP_DMA_ENABLE 1
|
| 33 |
|
| 34 | #define SSP_ASSERT() zOss_ASSERT(0)
|
| 35 |
|
| 36 | #define SSP_ERROR(format,args...) do {SSP_ASSERT();zOss_Printf(1,1,format,##args);} while(0)
|
| 37 |
|
| 38 | #define SSP_DEBUG_RAMLOG
|
| 39 |
|
| 40 | #ifdef SSP_DEBUG_RAMLOG
|
| 41 | #define zDrvSsp_RamLog(s...) zDrvRamlog_PRINTF(RAMLOG_MOD_SPI,s)
|
| 42 | #else
|
| 43 | #define zDrvSsp_RamLog(s...)
|
| 44 | #endif
|
| 45 |
|
| 46 | #define SPI_PRINTF(cond, format, args...) do { if(cond) zOss_Printf(SUBMDL_TEST, PRINT_LEVEL_NORMAL, format, ##args);}while(0)
|
| 47 | /****************************************************************************
|
| 48 | * Types
|
| 49 | ****************************************************************************/
|
| 50 |
|
| 51 |
|
| 52 | //define ssp num --zhangpei add
|
| 53 | typedef enum _T_SspDevNum
|
| 54 | {
|
| 55 | SSP_DEV_0 = 0,
|
| 56 | SSP_DEV_1 = 1,
|
| 57 | SSP_DEV_NUM
|
| 58 | }
|
| 59 | T_SspDevNum;
|
| 60 | typedef enum _T_SspMSMode
|
| 61 | {
|
| 62 | SSP_MS_MASTER = 0x0,
|
| 63 | SSP_MS_SLAVE = 0x1,
|
| 64 | }
|
| 65 | T_SspMSMode;
|
| 66 | //define ssp mode
|
| 67 | typedef enum _T_SspMode
|
| 68 | {
|
| 69 | SSP_AS_SPI = 0x0,
|
| 70 | SSP_AS_TISS = 0x1,
|
| 71 | }
|
| 72 | T_SspMode;
|
| 73 |
|
| 74 | //define ssp mode
|
| 75 | typedef enum _T_SspXferWidth
|
| 76 | {
|
| 77 | SSP_8_BIT = 7,
|
| 78 | SSP_9_BIT = 8,
|
| 79 | SSP_16_BIT = 15,
|
| 80 | SSP_32_BIT = 31
|
| 81 | }
|
| 82 | T_SspXferWidth;
|
| 83 |
|
| 84 | //define ssp mode
|
| 85 | typedef enum _T_SspPolarity
|
| 86 | {
|
| 87 | SPH_SPO_00 = 0x0,
|
| 88 | SPH_SPO_01 = 0x1,
|
| 89 | SPH_SPO_10 = 0x2,
|
| 90 | SPH_SPO_11 = 0x3
|
| 91 | }
|
| 92 | T_SspPolarity;
|
| 93 |
|
| 94 |
|
| 95 | //defined for ssp frequency changing
|
| 96 | typedef enum _T_SspFrequency
|
| 97 | {
|
| 98 | SSP_FREQ_52M,
|
| 99 | SSP_FREQ_39M,
|
| 100 | SSP_FREQ_26M,
|
| 101 | SSP_FREQ_13M,
|
| 102 | SSP_FREQ_6M5,
|
| 103 | SSP_FREQ_3M2,
|
| 104 | SSP_FREQ_1M6,
|
| 105 | SSP_FREQ_812K5,
|
| 106 | SSP_FREQ_NUM,
|
| 107 | }
|
| 108 | T_SspFrequency;
|
| 109 |
|
| 110 | typedef enum _T_SspCamMode
|
| 111 | {
|
| 112 | SSP_NORMAL_MODE = 0x0,
|
| 113 | SSP_CAMERA_MODE = 0x1,
|
| 114 | }
|
| 115 | T_SspCamMode;
|
| 116 |
|
| 117 |
|
| 118 | //define ssp cs level
|
| 119 | typedef enum _T_SspCsLevel
|
| 120 | {
|
| 121 | SSP_CS_LOW = 0,
|
| 122 | SSP_CS_HIGH = 1
|
| 123 | }
|
| 124 | T_SspCsLevel;
|
| 125 |
|
| 126 |
|
| 127 | //define the status
|
| 128 | #define RXFIFOFULL 1
|
| 129 | #define RXFIFONOTFULL 0
|
| 130 | #define RXFIFOEMPT 0
|
| 131 | #define RXFIFONOTEMPT 1
|
| 132 | #define TXFIFOFULL 0
|
| 133 | #define TXFIFONOTFULL 1
|
| 134 | #define TXFIFOEMPTY 1
|
| 135 | #define TXFIFONOTEMPTY 0
|
| 136 |
|
| 137 | //define register bit field segment
|
| 138 | typedef volatile struct
|
| 139 | {
|
| 140 | /*0x00*/
|
| 141 | UINT32 SSP_VER_REG;
|
| 142 | /*0x04*/
|
| 143 | UINT32 SSP_COM_CTRL;
|
| 144 | /*0x08*/
|
| 145 | UINT32 SSP_FMT_CTRL;
|
| 146 | /*0x0c*/
|
| 147 | UINT32 SSP_DR;
|
| 148 | /*0x10*/
|
| 149 | UINT32 SSP_FIFO_CTRL;
|
| 150 | /*0x14*/
|
| 151 | UINT32 SSP_FIFO_SR;
|
| 152 | /*0x18*/
|
| 153 | UINT32 SSP_INTR_EN;
|
| 154 | //0x1c
|
| 155 | UINT32 SSP_ISR_OR_ICR;
|
| 156 | //0x20
|
| 157 | UINT32 SSP_TIMING;
|
| 158 |
|
| 159 | }
|
| 160 | T_SspReg;
|
| 161 |
|
| 162 |
|
| 163 | typedef enum _T_SspStatus
|
| 164 | {
|
| 165 | SSP_STA_INIT = 0,
|
| 166 | SSP_STA_OPENED,
|
| 167 | SSP_STA_XFER,
|
| 168 | SSP_STA_DMA_ERR,
|
| 169 | SSP_STA_DONE,
|
| 170 | }
|
| 171 | T_SspStatus;
|
| 172 |
|
| 173 | typedef struct _T_SspDmaInfo
|
| 174 | {
|
| 175 | UINT32 rxDmaChl; // ssp rx Dma channel number
|
| 176 | UINT32 txDmaChl;
|
| 177 | T_ZDrvDma_ChannelDef rxDmaChlDef;
|
| 178 | T_ZDrvDma_ChannelDef txDmaChlDef;
|
| 179 | zDrvDma_CallbackFunc rxDmaCbFunc; // ssp rx callback function
|
| 180 | zDrvDma_CallbackFunc txDmaCbFunc;
|
| 181 | ZOSS_SEMAPHORE_ID TxDmaSema;
|
| 182 | ZOSS_SEMAPHORE_ID RxDmaSema;
|
| 183 | } T_SspDmaInfo;
|
| 184 |
|
| 185 |
|
| 186 | typedef union _T_SspData
|
| 187 | {
|
| 188 | UINT8 *Buf_8;
|
| 189 | UINT16 *Buf_16;
|
| 190 | UINT32 *Buf_32;
|
| 191 | VOID *Buf;
|
| 192 | } T_SspData;
|
| 193 |
|
| 194 |
|
| 195 | typedef struct
|
| 196 | {
|
| 197 | T_SspDevNum devNum; //indicate the ssp device num
|
| 198 | T_SspReg* regPtr;
|
| 199 | T_SspDmaInfo SspDmaInfo;
|
| 200 | T_SspStatus status;
|
| 201 | T_SspMSMode msMode;
|
| 202 | T_SspMode mode;
|
| 203 | T_SspPolarity polarity;
|
| 204 | T_SspXferWidth xferWidth;
|
| 205 |
|
| 206 | //NT32 SspWorkClock; //the wanted freq
|
| 207 | //NT32 RealSspWorkClock; //the actral freq
|
| 208 | UINT32 SspWorkClock; //the wanted freq
|
| 209 |
|
| 210 | UINT32 tx_thres;
|
| 211 | UINT32 rx_thres;
|
| 212 |
|
| 213 | UINT32 Len_tx_remin;
|
| 214 | VOID* txBuf;
|
| 215 | UINT32 Len_rx_remin;
|
| 216 | VOID* rxBuf;
|
| 217 |
|
| 218 | UINT32 bPrint;
|
| 219 |
|
| 220 | //ZOSS_SEMAPHORE_ID txSem;
|
| 221 | // ZOSS_SEMAPHORE_ID rxSem;
|
| 222 |
|
| 223 | }
|
| 224 | T_SspDevHnd;
|
| 225 |
|
| 226 |
|
| 227 | /****************************************************************************
|
| 228 | * Constants
|
| 229 | ****************************************************************************/
|
| 230 |
|
| 231 | /****************************************************************************
|
| 232 | * Global Variables
|
| 233 | ****************************************************************************/
|
| 234 |
|
| 235 | /****************************************************************************
|
| 236 | * Function Prototypes
|
| 237 | ****************************************************************************/
|
| 238 | SINT32 zDrvSsp_Transfer(VOID* hnd, VOID* txBuf ,VOID* rxBuf,UINT32 Len);
|
| 239 | //VOID* zDrvSsp_Open(T_SspDevNum devNum, T_SspMSMode msMode);
|
| 240 | VOID* zDrvSsp_Open(T_SspDevNum devNum);
|
| 241 | //VOID zDrvSsp_Reset(T_SspDevNum devNum);
|
| 242 | SINT32 zDrvSsp_Set_XferWidth(VOID* hnd,T_SspXferWidth length);
|
| 243 |
|
| 244 | SINT32 zDrvSsp_Xfer(VOID* hnd, VOID* txBuf ,VOID* rxBuf,UINT32 Len);
|
| 245 |
|
| 246 | SINT32 zDrvSsp_DmaXfer(VOID* hnd, VOID* txBuf ,VOID* rxBuf,UINT32 Len);
|
| 247 | //SINT32 zDrvSsp_DmaEnable(T_SspDevNum devNum);
|
| 248 | //SINT32 zDrvSsp_DmaDisable(T_SspDevNum devNum);
|
| 249 | //NT32 zDrvSsp_ChangeFreq(VOID *hnd, T_SspFrequency Freq);
|
| 250 | SINT32 zDrvSsp_SetMSMode(VOID *hnd, T_SspMSMode msMode);
|
| 251 | SINT32 zDrvSsp_Initiate(VOID);
|
| 252 | SINT32 zDrvSsp_Ioctl(VOID *hnd, T_DRVIO_CTRL_KEY function, VOID *arg);
|
| 253 |
|
| 254 | #endif/*_FILENAME_H*/
|
| 255 |
|