aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/platform_data/modem.h
blob: d66af9f1eef5d129da35dcf809df548098e6ecea (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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*
 * 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.
 *
 */

#ifndef __MODEM_IF_H__
#define __MODEM_IF_H__

enum modem_t {
	IMC_XMM6260,
	IMC_XMM6262,
	VIA_CBP71,
	VIA_CBP72,
	SEC_CMC221,
	QC_MDM6600,
	DUMMY,
};

enum dev_format {
	IPC_FMT,
	IPC_RAW,
	IPC_RFS,
	IPC_CMD,
	IPC_BOOT,
	IPC_MULTI_RAW,
	IPC_RAMDUMP,
	MAX_DEV_FORMAT,
};
#define MAX_IPC_DEV	(IPC_RFS + 1)

enum modem_io {
	IODEV_MISC,
	IODEV_NET,
	IODEV_DUMMY,
};

enum modem_link {
	LINKDEV_UNDEFINED,
	LINKDEV_MIPI,
	LINKDEV_DPRAM,
	LINKDEV_SPI,
	LINKDEV_USB,
	LINKDEV_HSIC,
	LINKDEV_C2C,
	LINKDEV_MAX,
};
#define LINKTYPE(modem_link) (1u << (modem_link))

enum modem_network {
	UMTS_NETWORK,
	CDMA_NETWORK,
	LTE_NETWORK,
};

enum sipc_ver {
	NO_SIPC_VER = 0,
	SIPC_VER_40 = 40,
	SIPC_VER_41 = 41,
	SIPC_VER_42 = 42,
	SIPC_VER_50 = 50,
	MAX_SIPC_VER,
};

/**
 * struct modem_io_t - declaration for io_device
 * @name:	device name
 * @id:		contain format & channel information
 *		(id & 11100000b)>>5 = format  (eg, 0=FMT, 1=RAW, 2=RFS)
 *		(id & 00011111b)    = channel (valid only if format is RAW)
 * @format:	device format
 * @io_type:	type of this io_device
 * @links:	list of link_devices to use this io_device
 *		for example, if you want to use DPRAM and USB in an io_device.
 *		.links = LINKTYPE(LINKDEV_DPRAM) | LINKTYPE(LINKDEV_USB)
 * @tx_link:	when you use 2+ link_devices, set the link for TX.
 *		If define multiple link_devices in @links,
 *		you can receive data from them. But, cannot send data to all.
 *		TX is only one link_device.
 *
 * This structure is used in board-*-modem.c
 */
struct modem_io_t {
	char *name;
	int   id;
	enum dev_format format;
	enum modem_io io_type;
	enum modem_link links;
	enum modem_link tx_link;
	bool rx_gather;
};

struct modemlink_pm_data {
	char *name;
	/* link power contol 2 types : pin & regulator control */
	int (*link_ldo_enable)(bool);
	unsigned gpio_link_enable;
	unsigned gpio_link_active;
	unsigned gpio_link_hostwake;
	unsigned gpio_link_slavewake;
	int (*link_reconnect)(void);
	int (*port_enable)(int, int);
	int *p_hub_status;
	bool has_usbhub;

	atomic_t freqlock;
	int (*cpufreq_lock)(void);
	int (*cpufreq_unlock)(void);

	int autosuspend_delay_ms; /* if zero, the default value is used */
};

struct modemlink_pm_link_activectl {
	int gpio_initialized;
	int gpio_request_host_active;
};

enum dpram_type {
	EXT_DPRAM,
	CP_IDPRAM,
	AP_IDPRAM,
	C2C_DPRAM,
	MAX_DPRAM_TYPE
};

enum dpram_speed {
	DPRAM_SPEED_LOW,
	DPRAM_SPEED_MID,
	DPRAM_SPEED_HIGH,
	MAX_DPRAM_SPEED
};

struct dpram_circ {
	u16 __iomem *head;
	u16 __iomem *tail;
	u8  __iomem *buff;
	u32          size;
};

struct dpram_ipc_device {
	char name[16];
	int  id;

	struct dpram_circ txq;
	struct dpram_circ rxq;

	u16 mask_req_ack;
	u16 mask_res_ack;
	u16 mask_send;
};

struct dpram_ipc_map {
	u16 __iomem *magic;
	u16 __iomem *access;

	struct dpram_ipc_device dev[MAX_IPC_DEV];

	u16 __iomem *mbx_cp2ap;
	u16 __iomem *mbx_ap2cp;
};

struct modemlink_dpram_control {
	void (*reset)(void);
	void (*setup_speed)(enum dpram_speed);
	int  (*wakeup)(void);
	void (*sleep)(void);

	void (*clear_intr)(void);
	u16  (*recv_intr)(void);
	void (*send_intr)(u16);
	u16  (*recv_msg)(void);
	void (*send_msg)(u16);

	u16  (*get_magic)(void);
	void  (*set_magic)(u16);

	u16  (*get_access)(void);
	void  (*set_access)(u16);

	u32  (*get_tx_head)(int);
	u32  (*get_tx_tail)(int);
	void (*set_tx_head)(int, u32);
	void (*set_tx_tail)(int, u32);
	u8 __iomem * (*get_tx_buff)(int);
	u32  (*get_tx_buff_size)(int);
	u16  (*get_mask_req_ack)(int);
	u16  (*get_mask_res_ack)(int);
	u16  (*get_mask_send)(int);

	u32  (*get_rx_head)(int);
	u32  (*get_rx_tail)(int);
	void (*set_rx_head)(int, u32);
	void (*set_rx_tail)(int, u32);
	u8 __iomem * (*get_rx_buff)(int);
	u32  (*get_rx_buff_size)(int);

	void (*log_disp)(struct modemlink_dpram_control *dpctl);
	int (*cpupload_step1)(struct modemlink_dpram_control *dpctl);
	int (*cpupload_step2)(void *arg, struct modemlink_dpram_control *dpctl);
	int (*cpimage_load_prepare)(struct modemlink_dpram_control *dpctl);
	int (*cpimage_load)(void *arg, struct modemlink_dpram_control *dpctl);
	int (*nvdata_load)(void *arg, struct modemlink_dpram_control *dpctl);
	int (*phone_boot_start)(struct modemlink_dpram_control *dpctl);
	int (*phone_boot_start_post_process)(void);
	void (*phone_boot_start_handler)(struct modemlink_dpram_control *dpctl);
	void (*dload_cmd_hdlr)(
		struct modemlink_dpram_control *dpctl, u16 cmd);
	void (*bt_map_init)(struct modemlink_dpram_control *dpctl);
	void (*load_init)(struct modemlink_dpram_control *dpctl);
#if defined(CONFIG_MACH_M0_CTC)
	void (*terminate_link)(struct modemlink_dpram_control *dpctl);
#endif
	u8 __iomem      *dp_base;
	u32              dp_size;
	enum dpram_type  dp_type;	/* DPRAM type */
	int		 aligned;	/* If aligned access is required, ... */

	int              dpram_irq;
	unsigned long    dpram_irq_flags;
	char            *dpram_irq_name;
	char            *dpram_wlock_name;

	int              max_ipc_dev;

	struct dpram_ipc_map *ipc_map;
};

#define DPRAM_MAGIC_CODE	0xAA

/* platform data */
struct modem_data {
	char *name;

	unsigned gpio_cp_on;
	unsigned gpio_cp_off;
	unsigned gpio_reset_req_n;
	unsigned gpio_cp_reset;
	unsigned gpio_pda_active;
	unsigned gpio_phone_active;
	unsigned gpio_cp_dump_int;
	unsigned gpio_ap_dump_int;
	unsigned gpio_flm_uart_sel;
#if defined(CONFIG_MACH_M0_CTC)
	unsigned gpio_flm_uart_sel_rev06;
	unsigned gpio_host_wakeup;
#endif
	unsigned gpio_cp_warm_reset;
	unsigned gpio_sim_detect;
#ifdef CONFIG_LINK_DEVICE_DPRAM
	unsigned gpio_dpram_int;
#endif

#ifdef CONFIG_LTE_MODEM_CMC221
	unsigned gpio_dpram_status;
	unsigned gpio_dpram_wakeup;
	unsigned gpio_slave_wakeup;
	unsigned gpio_host_active;
	unsigned gpio_host_wakeup;
	int      irq_host_wakeup;
#endif
#ifdef CONFIG_MACH_U1_KOR_LGT
	unsigned gpio_cp_reset_msm;
	unsigned gpio_boot_sw_sel;
	void (*vbus_on)(void);
	void (*vbus_off)(void);
	struct regulator *cp_vbus;
#endif

	/* Switch with 2 links in a modem */
	unsigned gpio_dynamic_switching;

	/* Modem component */
	enum modem_network  modem_net;
	enum modem_t        modem_type;
	enum modem_link     link_types;
	char               *link_name;
#ifdef CONFIG_LINK_DEVICE_DPRAM
	/* Link to DPRAM control functions dependent on each platform */
	struct modemlink_dpram_control *dpram_ctl;
#endif

	/* SIPC version */
	enum sipc_ver ipc_version;

	/* Information of IO devices */
	unsigned            num_iodevs;
	struct modem_io_t  *iodevs;

	/* Modem link PM support */
	struct modemlink_pm_data *link_pm_data;

	void (*gpio_revers_bias_clear)(void);
	void (*gpio_revers_bias_restore)(void);

	/* Handover with 2+ modems */
	bool use_handover;

	/* Debugging option */
	bool use_mif_log;
};

#define LOG_TAG "mif: "

#define mif_err(fmt, ...) \
	pr_err(LOG_TAG "%s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
#define mif_debug(fmt, ...) \
	pr_debug(LOG_TAG "%s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
#define mif_info(fmt, ...) \
	pr_info(LOG_TAG "%s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
#define mif_trace(fmt, ...) \
	printk(KERN_DEBUG "mif: %s: %d: called(%pF): " fmt, \
		__func__, __LINE__, __builtin_return_address(0), ##__VA_ARGS__)

#endif