2 * Copyright (C) 2010 Google, Inc.
3 * Copyright (C) 2010 Samsung Electronics.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #ifndef __MODEM_IF_H__
17 #define __MODEM_IF_H__
40 #define MAX_IPC_DEV (IPC_RFS + 1) /* BYPASS, PDP0, PDP1, PDP2 */
41 #define MAX_SIPC5_DEV (IPC_PDP0 + 1) /* FMT, RAW */
59 #define LINKTYPE(modem_link) (1u << (modem_link))
77 * struct modem_io_t - declaration for io_device
79 * @id: contain format & channel information
80 * (id & 11100000b)>>5 = format (eg, 0=FMT, 1=RAW, 2=RFS)
81 * (id & 00011111b) = channel (valid only if format is RAW)
82 * @format: device format
83 * @io_type: type of this io_device
84 * @links: list of link_devices to use this io_device
85 * for example, if you want to use DPRAM and USB in an io_device.
86 * .links = LINKTYPE(LINKDEV_DPRAM) | LINKTYPE(LINKDEV_USB)
87 * @tx_link: when you use 2+ link_devices, set the link for TX.
88 * If define multiple link_devices in @links,
89 * you can receive data from them. But, cannot send data to all.
90 * TX is only one link_device.
92 * This structure is used in board-*-modem.c
97 enum dev_format format;
98 enum modem_io io_type;
99 enum modem_link links;
100 enum modem_link tx_link;
104 struct modemlink_pm_data {
106 /* link power contol 2 types : pin & regulator control */
107 int (*link_ldo_enable)(bool);
108 unsigned gpio_link_enable;
109 unsigned gpio_link_active;
110 unsigned gpio_link_hostwake;
111 unsigned gpio_link_slavewake;
112 int (*link_reconnect)(void);
115 int (*port_enable)(int, int);
116 int (*hub_standby)(void *);
120 /* cpu/bus frequency lock */
122 int (*freq_lock)(struct device *dev);
123 int (*freq_unlock)(struct device *dev);
125 int autosuspend_delay_ms; /* if zero, the default value is used */
128 struct modemlink_pm_link_activectl {
129 int gpio_initialized;
130 int gpio_request_host_active;
141 #define DPRAM_SIZE_8KB 0x02000
142 #define DPRAM_SIZE_16KB 0x04000
143 #define DPRAM_SIZE_32KB 0x08000
144 #define DPRAM_SIZE_64KB 0x10000
145 #define DPRAM_SIZE_128KB 0x20000
161 struct dpram_ipc_device {
165 struct dpram_circ txq;
166 struct dpram_circ rxq;
173 struct dpram_ipc_map {
177 struct dpram_ipc_device dev[MAX_IPC_DEV];
179 u16 __iomem *mbx_cp2ap;
180 u16 __iomem *mbx_ap2cp;
183 struct modemlink_dpram_control {
185 void (*clear_intr)(void);
186 u16 (*recv_intr)(void);
187 void (*send_intr)(u16);
188 u16 (*recv_msg)(void);
189 void (*send_msg)(u16);
194 void (*setup_speed)(enum dpram_speed);
196 enum dpram_type dp_type; /* DPRAM type */
197 int aligned; /* aligned access is required */
202 unsigned long dpram_irq_flags;
205 struct dpram_ipc_map *ipc_map;
207 unsigned boot_size_offset;
208 unsigned boot_tag_offset;
209 unsigned boot_count_offset;
210 unsigned max_boot_frame_size;
218 unsigned gpio_cp_off;
219 unsigned gpio_reset_req_n;
220 unsigned gpio_cp_reset;
221 unsigned gpio_pda_active;
222 unsigned gpio_phone_active;
223 unsigned gpio_cp_dump_int;
224 unsigned gpio_ap_dump_int;
225 unsigned gpio_flm_uart_sel;
226 #if defined(CONFIG_MACH_M0_CTC)
227 unsigned gpio_flm_uart_sel_rev06;
228 unsigned gpio_host_wakeup;
230 unsigned gpio_cp_warm_reset;
231 unsigned gpio_sim_detect;
232 #ifdef CONFIG_LINK_DEVICE_DPRAM
233 unsigned gpio_dpram_int;
236 #ifdef CONFIG_LTE_MODEM_CMC221
237 unsigned gpio_dpram_status;
238 unsigned gpio_dpram_wakeup;
239 unsigned gpio_slave_wakeup;
240 unsigned gpio_host_active;
241 unsigned gpio_host_wakeup;
244 #ifdef CONFIG_MACH_U1_KOR_LGT
245 unsigned gpio_cp_reset_msm;
246 unsigned gpio_boot_sw_sel;
247 void (*vbus_on)(void);
248 void (*vbus_off)(void);
249 struct regulator *cp_vbus;
252 /* Switch with 2 links in a modem */
253 unsigned gpio_dynamic_switching;
255 /* Modem component */
256 enum modem_network modem_net;
257 enum modem_t modem_type;
258 enum modem_link link_types;
260 #ifdef CONFIG_LINK_DEVICE_DPRAM
261 /* Link to DPRAM control functions dependent on each platform */
262 struct modemlink_dpram_control *dpram_ctl;
266 enum sipc_ver ipc_version;
268 /* Information of IO devices */
270 struct modem_io_t *iodevs;
272 /* Modem link PM support */
273 struct modemlink_pm_data *link_pm_data;
275 void (*gpio_revers_bias_clear)(void);
276 void (*gpio_revers_bias_restore)(void);
278 /* Handover with 2+ modems */
281 /* Debugging option */
285 #define LOG_TAG "mif: "
287 #define mif_err(fmt, ...) \
288 pr_err(LOG_TAG "%s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
289 #define mif_debug(fmt, ...) \
290 pr_debug(LOG_TAG "%s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
291 #define mif_info(fmt, ...) \
292 pr_info(LOG_TAG "%s: " pr_fmt(fmt), __func__, ##__VA_ARGS__)
293 #define mif_trace(fmt, ...) \
294 printk(KERN_DEBUG "mif: %s: %d: called(%pF): " fmt, \
295 __func__, __LINE__, __builtin_return_address(0), ##__VA_ARGS__)