aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/modem_if_u1/modem_link_device_c2c.h
blob: 7ec9aa635aa4b1dafffc9781c32a3ea69768fe36 (plain)
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
 * Copyright (C) 2010 Google, Inc.
 * Copyright (C) 2010 Samsung Electronics.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 */
#include <linux/wakelock.h>

#ifndef __MODEM_LINK_DEVICE_C2C_H__
#define __MODEM_LINK_DEVICE_C2C_H__

#define DPRAM_ERR_MSG_LEN		128
#define DPRAM_ERR_DEVICE		"c2cerr"

#define MAX_IDX				2

#define DPRAM_BASE_PTR			0x4000000

#define DPRAM_START_ADDRESS		0
#define DPRAM_MAGIC_CODE_ADDRESS	DPRAM_START_ADDRESS
#define DPRAM_GOTA_MAGIC_CODE_SIZE		0x4
#define DPRAM_PDA2PHONE_FORMATTED_START_ADDRESS	\
	(DPRAM_START_ADDRESS + DPRAM_GOTA_MAGIC_CODE_SIZE)
#define BSP_DPRAM_BASE_SIZE		0x1ff8
#define DPRAM_END_OF_ADDRESS		(BSP_DPRAM_BASE_SIZE - 1)
#define DPRAM_INTERRUPT_SIZE		0x2
#define DPRAM_PDA2PHONE_INTERRUPT_ADDRESS	\
	(DPRAM_START_ADDRESS + BSP_DPRAM_BASE_SIZE -  DPRAM_INTERRUPT_SIZE*2)
#define DPRAM_PHONE2PDA_INTERRUPT_ADDRESS	\
	(DPRAM_START_ADDRESS + BSP_DPRAM_BASE_SIZE)
#define DPRAM_BUFFER_SIZE			\
	(DPRAM_PHONE2PDA_INTERRUPT_ADDRESS -\
	DPRAM_PDA2PHONE_FORMATTED_START_ADDRESS)
#define DPRAM_INDEX_SIZE		0x2

#define MAGIC_DMDL			0x4445444C
#define MAGIC_UMDL			0x4445444D

#define DPRAM_PACKET_DATA_SIZE		0x3f00
#define DPRAM_PACKET_HEADER_SIZE	0x7

#define INT_GOTA_MASK_VALID		0xA000
#define INT_DPRAM_DUMP_MASK_VALID		0xA000
#define MASK_CMD_RECEIVE_READY_NOTIFICATION	0xA100
#define MASK_CMD_DOWNLOAD_START_REQUEST		0xA200
#define MASK_CMD_DOWNLOAD_START_RESPONSE	0xA301
#define MASK_CMD_IMAGE_SEND_REQUEST		0xA400
#define MASK_CMD_IMAGE_SEND_RESPONSE		0xA500
#define MASK_CMD_SEND_DONE_REQUEST		0xA600
#define MASK_CMD_SEND_DONE_RESPONSE		0xA701
#define MASK_CMD_STATUS_UPDATE_NOTIFICATION	0xA800
#define MASK_CMD_UPDATE_DONE_NOTIFICATION	0xA900
#define MASK_CMD_EFS_CLEAR_RESPONSE		0xAB00
#define MASK_CMD_ALARM_BOOT_OK			0xAC00
#define MASK_CMD_ALARM_BOOT_FAIL		0xAD00

#define WRITEIMG_HEADER_SIZE			8
#define WRITEIMG_TAIL_SIZE			4
#define WRITEIMG_BODY_SIZE			\
	(DPRAM_BUFFER_SIZE - WRITEIMG_HEADER_SIZE - WRITEIMG_TAIL_SIZE)

#define DPDN_DEFAULT_WRITE_LEN			WRITEIMG_BODY_SIZE
#define CMD_DL_START_REQ			0x9200
#define CMD_IMG_SEND_REQ			0x9400
#define CMD_DL_SEND_DONE_REQ			0x9600

#define CMD_UL_START_REQ		0x9200
#define CMD_UL_START_READY		0x9400
#define CMD_UL_SEND_RESP		0x9601
#define CMD_UL_SEND_DONE_RESP		0x9801
#define CMD_UL_SEND_REQ			0xA500
#define CMD_UL_START_RESPONSE		0xA301
#define CMD_UL_SEND_DONE_REQ		0xA700
#define CMD_RECEIVE_READY_NOTIFICATION	0xA100

#define MASK_CMD_RESULT_FAIL		0x0002
#define MASK_CMD_RESULT_SUCCESS		0x0001

#define START_INDEX			0x007F
#define END_INDEX			0x007E

#define CMD_IMG_SEND_REQ		0x9400

#define CRC_TAB_SIZE			256
#define CRC_16_L_SEED			0xFFFF

struct c2c_device {
	/* DPRAM memory addresses */
	u16		*in_head_addr;
	u16		*in_tail_addr;
	u8		*in_buff_addr;
	unsigned long	in_buff_size;

	u16		*out_head_addr;
	u16		*out_tail_addr;
	u8		*out_buff_addr;
	unsigned long	out_buff_size;

	unsigned long	in_head_saved;
	unsigned long	in_tail_saved;
	unsigned long	out_head_saved;
	unsigned long	out_tail_saved;

	u16		mask_req_ack;
	u16		mask_res_ack;
	u16		mask_send;
};

struct memory_region {
	u8 *control;
	u8 *fmt_out;
	u8 *raw_out;
	u8 *fmt_in;
	u8 *raw_in;
	u8 *mbx;
};

struct UldDataHeader {
	u8 bop;
	u16 total_frame;
	u16 curr_frame;
	u16 len;
};

struct c2c_link_device {
	struct link_device ld;

	struct modem_data *pdata;

	/*only c2c*/
	struct wake_lock c2c_wake_lock;
	atomic_t raw_txq_req_ack_rcvd;
	atomic_t fmt_txq_req_ack_rcvd;
	u8 net_stop_flag;
	int phone_sync;
	u8 phone_status;

	 struct work_struct xmit_work_struct;

	struct workqueue_struct *gota_wq;
	struct work_struct gota_cmd_work;

	struct c2c_device dev_map[MAX_IDX];

	struct wake_lock dumplock;

	u8 c2c_read_data[131072];

	int c2c_init_cmd_wait_condition;
	wait_queue_head_t c2c_init_cmd_wait_q;

	int modem_pif_init_wait_condition;
	wait_queue_head_t modem_pif_init_done_wait_q;

	struct completion gota_download_start_complete;

	int gota_send_done_cmd_wait_condition;
	wait_queue_head_t gota_send_done_cmd_wait_q;

	int gota_update_done_cmd_wait_condition;
	wait_queue_head_t gota_update_done_cmd_wait_q;

	int upload_send_req_wait_condition;
	wait_queue_head_t upload_send_req_wait_q;

	int upload_send_done_wait_condition;
	wait_queue_head_t upload_send_done_wait_q;

	int upload_start_req_wait_condition;
	wait_queue_head_t upload_start_req_wait_q;

	int upload_packet_start_condition;
	wait_queue_head_t upload_packet_start_wait_q;

	u16 gota_irq_handler_cmd;

	u16 c2c_dump_handler_cmd;

	int dump_region_number;

	unsigned int is_c2c_err ;

	int c2c_dump_start;
	int gota_start;

	char c2c_err_buf[DPRAM_ERR_MSG_LEN];

	struct fasync_struct *c2c_err_async_q;

	void (*clear_interrupt)(struct c2c_link_device *);

	struct memory_region m_region;

	unsigned long  fmt_out_buff_size;
	unsigned long  raw_out_buff_size;
	unsigned long  fmt_in_buff_size;
	unsigned long  raw_in_buff_size;

	struct delayed_work delayed_tx;
	struct sk_buff *delayed_skb;
	u8 delayed_count;
};

/* converts from struct link_device* to struct xxx_link_device* */
#define to_c2c_link_device(linkdev) \
			container_of(linkdev, struct c2c_link_device, ld)

#endif