blob: 4d410b7502b851bbec5af24e8a6ea7ce1fd5a70e [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2 * Copyright by ZTE Corporation.
3 *
4 * File Name:
5 * File Mark:
6 * Description:
7 * Others:
8 * Version: v0.1
9 * Author: wuhui
10 * Date: 2017-1-13
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ********************************************************************************/
18
19#ifndef _DRVS_SPICC_H
20#define _DRVS_SPICC_H
21
22/****************************************************************************
23* Include files
24****************************************************************************/
25#include "drvs_chip_cfg.h"
26#include "drvs_dma.h"
27#include "drvs_sys.h"
28
29/****************************************************************************
30* Macros
31****************************************************************************/
32 //BASE ADDRESSS
33#define SSP1_FORCAM_BASE (SPI1_REG_BASE+0x0000)
34
35#define SSP1_COMCTRL_MS_OFFSET (2)
36#define SSP1_COMCTRL_SSPE_OFFSET (1)
37#define SSP1_FMTCTRL_LaneNum_OFFSET (13)
38#define SSP1_FMTCTRL_LaneNum_SIZE (2)
39#define SSP1_FMTCTRL_CAMMode_OFFSET (12)
40#define SSP1_FIFOCTRL_RXFIFOTHRED_OFFSET (4)
41#define SSP1_FIFOCTRL_RXFIFOTHRED_SIZE (4)
42#define SSP1_FIFOCTRL_RXFIFOCNTR_OFFSET (5)
43#define SSP1_FIFOCTRL_RXFIFOCNTR_SIZE (7)
44#define SSP1_FIFOCTRL_RXDMAEN_OFFSET (2)
45#define SSP1_SYNC_CODE_OFFSET (0)
46#define SSP1_CAMFIFO_RST_OFFSET (1)
47#define SSP1_SAMPLE_MODE_OFFSET (2)
48#define SSP1_ID_SOL_OFFSET (24)
49#define SSP1_ID_EOF_OFFSET (16)
50#define SSP1_ID_SOF_OFFSET (8)
51#define SSP1_ID_SYNC_SIZE (8)
52#define SSP1_PACKETSIZE_OFFSET (0)
53#define SSP1_PACKETSIZE_SIZE (16)
54
55//²»Í¬´«Êä¸ñʽʱµÄID ¶¨Òå
56#define MTK_START (0x01)
57#define MTK_DATA_PACKET (0x40)
58#define MTK_END (0x00)
59#define BT656_START (0xab)
60#define BT656_LINE_START (0x80)
61#define BT656_END (0xb6)
62
63
64#define set_reg_bit(regName, bitAddr, bitValue) \
65do{ \
66 if(bitValue == TRUE) \
67 reg32(regName) |= (0x1<<bitAddr); \
68 else \
69 reg32(regName) &= ~(0x1<<bitAddr); \
70}while(0)
71
72#define set_reg_bits(regName, bitsAddr, bitsLen, bitsValue) \
73do{ \
74 reg32(regName) = (reg32(regName)&(~(((0x1<<bitsLen)-0x1)<<bitsAddr)))|(bitsValue<<bitsAddr);\
75}while(0)
76
77#define read_reg_bits(regName, bitsAddr, bitsLen) ((reg32(regName)>>bitsAddr)&((0x1<<bitsLen)-0x1))
78#define read_reg_bit(regName, bitsAddr) ((reg32(regName)>>bitsAddr)&0x1)
79
80
81/****************************************************************************
82* Types
83****************************************************************************/
84typedef volatile struct _T_SPICC_Regs
85{
86 UINT32 SSP1_VER; //0x00
87 UINT32 SSP1_COM_CTRL; //0x04
88 UINT32 SSP1_FMT_CTRL; //0x08
89 UINT32 SSP1_DATA_REG; //0x0C
90 UINT32 SSP1_FIFO_CTRL; //0x10
91 UINT32 SSP1_FIFO_STA; //0x14
92 UINT32 SSP1_INT_EN; //0x18
93 UINT32 SSP1_INT_STACLR; //0x1C
94 UINT32 SSP1_TIMING; //0x20
95 UINT32 Reserved[3]; //0x24~0x2C
96 UINT32 SSP1_SYNC_CODE; //0x30
97 UINT32 SSP1_DEBUG; //0x34
98 UINT32 SSP1_PACKET_SIZE; //0x38
99}T_SPICC_Regs;
100
101typedef enum _T_SSP1_MSMode
102{
103 SSP1_AS_MASTER = 0x0,
104 SSP1_AS_SLAVE = 0x1,
105 MAX_MS_MODE = 0X02
106}T_SPICC_MSMode;
107
108typedef enum
109{
110 DISABLE = 0,
111 ENABLE =1,
112 MAX_ENABLE_TYPE =2
113}T_SPICC_ENABLE_TYPE;
114
115typedef enum _T_SPICC_LaneNum
116{
117 LANE_1_CAM = 0,
118 LANE_2_CAM = 1,
119 LANE_4_CAM = 2,
120 LANE_MAX_CAM = 3
121}T_SPICC_LaneNum;
122
123typedef enum _T_SPICC_CamMode
124{
125 SSP1_AS_NORMAL = 0,
126 SSP1_AS_CAMERA = 1,
127 MAX_SSP1_CAMMODE = 2
128}T_SPICC_CamMode;
129
130typedef enum
131{
132 RAW_DATA =0,
133 PURE_DATA = 1,
134 MAX_SAMPLE_MODE =2
135}T_SPICC_ImageSampleMode;
136
137typedef enum
138{
139 BT656_MODE = 0,
140 MTK_MODE = 1,
141 MAX_TRANSFER_MODE =2
142}T_SPICC_ImageTransferMode;
143
144typedef enum
145{
146 RX_OVERRUN_IE = 0,
147 RX_FULL_IE = 2,
148 RX_THRED_IE = 4,
149 CAM_SOF_IE = 7,
150 CAM_EOF_IE = 8,
151 MAX_SSP1_INT_EN = 9
152}T_SPICC_IntEn;
153
154typedef enum
155{
156 eRESET =0,
157 eRELEASE = 1,
158 MAX_FIFOCtrl_TYPE =2
159}T_SPICC_CamFIFORst;
160
161typedef struct _T_zDrvSPICC_Device
162{
163 T_SPICC_ImageTransferMode transMode;
164 T_SPICC_ImageSampleMode samMode;
165 T_SPICC_LaneNum laneNum;
166 UINT32 packetSize;
167}T_zDrvSPICC_Device;
168
169typedef struct _T_SPICC_DevCtrl
170{
171 T_SPICC_Regs* regPtr;
172 UINT32 rxDmaChl; // ssp rx Dma channel number
173
174}T_SPICC_DevCtrl;
175
176/****************************************************************************
177* Constants
178****************************************************************************/
179
180/****************************************************************************
181* Global Variables
182****************************************************************************/
183
184/****************************************************************************
185* Function Prototypes
186****************************************************************************/
187SINT32 zDrvSPICC_Initiate(VOID);
188SINT32 zDrvSPICC_Open(T_zDrvSPICC_Device *spicc_Dev);
189SINT32 zDrvSPICC_Close(void);
190SINT32 zDrvSPICC_DmaRxloop(zDrvDma_CallbackFunc CallBack,T_ZDrvDma_ChannelDef *rxRegDmaChl,UINT32 transferListNum);
191SINT32 zDrvSPICC_DisableDmaRxloop(VOID);
192SINT32 zDrvSPICC_DeAllocDmaRxCh(VOID);
193VOID zDrvSPICC_ClkGateCtrl(T_ZDrvSysClk_Gate ClkCtrl);
194
195
196
197#endif/*_FILENAME_H*/
198