aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/eemcs/eemcs_rpc.h
blob: cce495bef29348adfab9dcc4d063e832b4b46dca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*****************************************************************************
 *
 * Filename:
 * ---------
 *   eemcs_rpc.h
 *
 * Project:
 * --------
 *   
 *
 * Description:
 * ------------
 *   
 *
 * Author:
 * -------
 *   
 *
 ****************************************************************************/

#ifndef __EEMCS_RPC_H
#define __EEMCS_RPC_H


//#include <crypto_engine_export.h>
//#include <sec_error.h>
#include <linux/skbuff.h>

#include "eemcs_ccci.h"
#include "eemcs_kal.h"
#ifdef _EEMCS_RPC_UT 
#include "eemcs_rpc_ut.h"
#endif

#define CCCI_SED_LEN_BYTES   16 
typedef struct {unsigned char sed[CCCI_SED_LEN_BYTES]; }sed_t;
#define SED_INITIALIZER { {[0 ... CCCI_SED_LEN_BYTES-1]=0}}
/*******************************************************************************
 * Define marco or constant.
 *******************************************************************************/
#define IPC_RPC_EXCEPT_MAX_RETRY     7
#define IPC_RPC_MAX_RETRY            (0xFFFF)
#define IPC_RPC_REQ_BUFFER_NUM       2 /* support 2 concurrently request*/
#define IPC_RPC_MAX_ARG_NUM          6 /* parameter number */
#define IPC_RPC_MAX_BUF_SIZE         2048 

#define IPC_RPC_USE_DEFAULT_INDEX    -1
#define IPC_RPC_API_RESP_ID          0xFFFF0000
#define IPC_RPC_INC_BUF_INDEX(x)     (x = (x + 1) % IPC_RPC_REQ_BUFFER_NUM)

/*******************************************************************************
 * Define data structure.
 *******************************************************************************/
typedef enum
{
    IPC_RPC_CPSVC_SECURE_ALGO_OP = 0x2001,
    IPC_RPC_GET_SECRO_OP        = 0x2002,
    IPC_RPC_GET_TDD_EINT_NUM_OP = 0x4001,
    IPC_RPC_GET_TDD_GPIO_NUM_OP = 0x4002,
    IPC_RPC_GET_TDD_ADC_NUM_OP  = 0x4003,
    IPC_RPC_GET_EMI_CLK_TYPE_OP = 0x4004,
    IPC_RPC_GET_EINT_ATTR_OP    = 0x4005,

    IPC_RPC_UT_OP               = 0x1234,  
    IPC_RPC_IT_OP               = 0x4321,  
}RPC_OP_ID;

typedef struct
{
   unsigned int len;
   void *buf;
}RPC_PKT;

typedef struct
{
    unsigned int     op_id;
    unsigned char    buf[IPC_RPC_MAX_BUF_SIZE];
}RPC_BUF;

typedef struct IPC_RPC_StreamBuffer_STRUCT
{
    CCCI_BUFF_T   ccci_header;
    kal_uint32    rpc_opid;
	kal_uint32	  num_para;
	kal_uint8     buffer[IPC_RPC_MAX_BUF_SIZE];
	
} IPC_RPC_StreamBuffer_T;
typedef IPC_RPC_StreamBuffer_T* pIPC_RPC_StreamBuffer_T;

#if 0 
/* Struct to define the control channel of RPC service */
typedef struct CCCI_RPC_STRUCT
{
    kal_uint32 send_channel;            /* RPC channel for TX */
    kal_uint32 receive_channel;         /* RPC channel for RX */
    /* <CCCI released APIs> */
    kal_int32  (*ccci_write_gpd)(CCCI_CHANNEL_T channel, ccci_io_request_t *p_ccci_DL_ior, ccci_io_ext_info_t* pextinfo);

    kal_int32  (*ccci_init_gpdior)(CCCI_CHANNEL_T channel, CCCI_IORCALLBACK ior_funp);
    kal_int32  (*ccci_deinit)(CCCI_CHANNEL_T channel);
	kal_int32  (*ccci_rpc_polling_io)(CCCI_CHANNEL_T channel,qbm_gpd * p_gpd,kal_bool is_tx);

	kal_bool   (*check_kal_systemInit)(void);

    kal_uint32 ut_flag;

    qbm_gpd *p_polling_gpd;             /* polling mode GPD */
    kal_uint32 allocated_gpd_number;

} CCCI_RPC_T;

#endif

#define FS_NO_ERROR                                      0
#define FS_NO_OP                                        -1
#define FS_PARAM_ERROR                                  -2
#define FS_NO_FEATURE                                   -3
#define FS_NO_MATCH                                     -4
#define FS_FUNC_FAIL                                    -5
#define FS_ERROR_RESERVED                               -6
#define FS_MEM_OVERFLOW                                 -7

/* EMCS opeartion Error. */
//  I for Internal use, O for device status, should cover by error handling..
#define EMCS_ERR_NONE           0
#define EMCS_ERR_TIMEOUT        20 /*[O] wait Interrupt or device read fail*/
#define EMCS_ERR_BT_STATUS      21 /*[I] invalid MD Status.*/
#define EMCS_ERR_CMDCRC         22 /*[O] invalid command*/
#define EMCS_ERR_LOAD_BIN       23 /*[O] MD BIN file open fail*/
#define EMCS_ERR_MSG_OVERFLOW   24 /*[O] receive message to long*/
#define EMCS_ERR_PKT_OVERFLOW   25 /*[I] send package big the tx limitaion*/
#define EMCS_ERR_INVALID_PARA   26 /*[I] emcs driver parameter check fail*/
#define EMCS_ERR_GET_OWNER      27 /*[O] get device ownership fail*/     
#define EMCS_ERR_NOMEM          28
#define EMCS_ERR_NOINIT         29
#define EMCS_ERR_INVAL_PARA     30
#define EMCS_ERR_TX_FAIL        31
#define EMCS_ERR_RX_FAIL        32
#define EMCS_ERROR_BUSY         33
#define EMCS_ERROR_NODEV        34


/* IPC Instance structure define */
typedef struct _eemcs_rpc_inst_t
{
    ccci_ch_set         ccci_ch;
}eemcs_rpc_inst_t;

#ifdef CCCI_SDIO_HEAD
#define CCCI_RPC_HEADER_ROOM                          (sizeof(SDIO_H)+sizeof(CCCI_BUFF_T))
#else
#define CCCI_RPC_HEADER_ROOM                          (sizeof(CCCI_BUFF_T))
#endif

#define RPC_UT_SUCCESS									1
#define RPC_UT_FAIL                                    -1 
#define RPC_IT_SUCCESS									1
#define RPC_IT_FAIL                                    -1 

#define ut_ret_val                                     0xa5a5
#define it_ret_val                                     0xa5a5

#ifdef _EEMCS_RPC_UT
  #define ccci_rpc_ch_write_desc_to_q(ch_num,desc_p)     eemcs_rpc_ut_UL_write_skb_to_swq(ch_num, desc_p) 
#else
  #define ccci_rpc_ch_write_desc_to_q(ch_num,desc_p)     eemcs_ccci_UL_write_skb_to_swq(ch_num, desc_p)
#endif
#define ccci_ch_register(ch_num,cb,para)		   eemcs_ccci_register_callback(ch_num,cb,para) 
#define ccci_ch_unregister(ch_num)				   eemcs_ccci_unregister_callback(ch_num) 
#define ccci_ch_write_space_alloc(ch_num)		   eemcs_ccci_UL_write_room_alloc(ch_num)

#define ccci_rpc_mem_alloc(sz, flag)               __dev_alloc_skb(sz, flag)


extern KAL_INT32 eemcs_rpc_callback(struct sk_buff *skb, KAL_UINT32 private_data);
extern int eemcs_rpc_mod_init(void);
extern void eemcs_rpc_exit(void);

#endif