import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / misc_via / modem_sdio.h
1 /*
2 * drivers/mmc/card/modem_sdio.h
3 *
4 * VIA CBP SDIO driver for Linux
5 *
6 * Copyright (C) 2009 VIA TELECOM Corporation, Inc.
7 * Author: VIA TELECOM Corporation, Inc.
8 *
9 * This package is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17 #ifndef MODEM_SDIO_H
18 #define MODEM_SDIO_H
19
20 #define SDIO_TTY_NR 6 /* Number of UARTs this driver can handle */
21 #include "cbp_sdio.h"
22
23 /*SDIO buffer in lens*/
24 #define SDIO_PPP_BUF_IN_MAX_NUM 100
25 #define SDIO_ETS_BUF_IN_MAX_NUM 500
26 #define SDIO_IFS_BUF_IN_MAX_NUM 100
27 #define SDIO_AT_BUF_IN_MAX_NUM 100
28 #define SDIO_PCV_BUF_IN_MAX_NUM 100
29 #define SDIO_DEF_BUF_IN_MAX_NUM 100
30 #define SDIO_BUF_IN_MAX_SIZE 64512 /*max buffer in size = 63K*/
31
32 #define MODEM_FC_PRINT_MAX 3
33 #define SDIO_FUNC_1 2
34 struct sdio_msg_head
35 {
36 unsigned char start_flag; /*start flag(1), little endian*/
37 unsigned char chanInfo; /*channel id*/
38 unsigned char tranHi; /*len High byte, little endian*/
39 unsigned char tranLow; /*len low byte, little endian*/
40 };
41
42 struct sdio_msg
43 {
44 struct sdio_msg_head head;
45 unsigned char buffer[4096];
46 };
47
48 typedef enum{
49 SFLOW_CTRL_DISABLE = 0,
50 SFLOW_CTRL_ENABLE
51 }Sflow_ctrl_state;
52
53 struct sdio_modem_port;
54 struct sdio_modem_port {
55 struct sdio_modem *modem;
56 struct sdio_func *func;
57 struct tty_port port;
58 struct kref kref;
59 spinlock_t write_lock;
60 struct tty_struct *tty;
61 unsigned int index;
62
63 struct kfifo transmit_fifo;
64 const char *name;
65 char work_name[64];
66 struct workqueue_struct *write_q;
67 struct work_struct write_work;
68 struct device dev;
69
70 struct mutex sdio_buf_in_mutex;
71 struct list_head sdio_buf_in_list;
72 unsigned char sdio_buf_in;
73 unsigned int sdio_buf_in_num; /*buffer in list num*/
74 unsigned int sdio_buf_in_max_num; /*buffer in list max num*/
75 unsigned int sdio_buf_in_size; /*buffer in size*/
76
77 wait_queue_head_t sflow_ctrl_wait_q;
78 atomic_t sflow_ctrl_state;
79 struct semaphore write_sem;
80
81 /* Settings for the port */
82 int rts_state; /* Handshaking pins (outputs) */
83 int dtr_state;
84 int cts_state; /* Handshaking pins (inputs) */
85 int dsr_state;
86 spinlock_t inception_lock;
87 int inception;
88 };
89
90 struct sdio_buf_in_packet{
91 struct list_head node;
92 unsigned int size;
93 unsigned char *buffer;
94 };
95
96 struct ctrl_port_msg{
97 struct sdio_msg_head head;
98 unsigned char id_hi;
99 unsigned char id_low;
100 unsigned char chan_num;
101 unsigned char option;
102 };
103
104 struct sdio_modem_ctrl_port{
105 struct ctrl_port_msg chan_ctrl_msg;
106 unsigned int chan_state;
107 unsigned int msg_id;
108 wait_queue_head_t sflow_ctrl_wait_q;
109 atomic_t sflow_ctrl_state;
110 };
111
112 struct sdio_modem{
113 struct sdio_modem_port *port[SDIO_TTY_NR];
114 struct sdio_modem_ctrl_port *ctrl_port;
115 struct sdio_func *func;
116 struct sdio_msg *msg;
117 unsigned char *trans_buffer;
118 struct cbp_platform_data *cbp_data;
119 struct semaphore sem;
120 unsigned int data_length;
121 };
122
123 extern int sdio_log_level;
124
125 #define LOG_ERR 0
126 #define LOG_INFO 1
127 #define LOG_NOTICE 2
128 #define LOG_NOTICE2 3
129 #define LOG_DEBUG 4
130
131 #define LOGPRT(lvl,x...) do{ \
132 if(lvl < (sdio_log_level + 1)) \
133 printk("[SDIO MODEM] " x); \
134 }while(0)
135
136 extern int modem_sdio_init(struct cbp_platform_data *pdata);
137 extern void modem_sdio_exit(void);
138 extern int modem_err_indication_usr(int revocery);
139 extern int modem_ipoh_indication_usr(void);
140
141 #endif