Initial commit
[kernel/linux-3.0.git] / include / linux / platform_data / modem_tizen.h
1 /*
2  * Copyright (C) 2010 Google, Inc.
3  * Copyright (C) 2010 Samsung Electronics.
4  *
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.
8  *
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.
13  *
14  */
15
16 #ifndef __MODEM_IF_H__
17 #define __MODEM_IF_H__
18
19 enum modem_t {
20         IMC_XMM6260,
21         IMC_XMM6262,
22         VIA_CBP71,
23         VIA_CBP72,
24         SEC_CMC221,
25         QC_MDM6600,
26         QC_ESC6270,
27         DUMMY,
28         MAX_MODEM_TYPE
29 };
30
31 enum dev_format {
32         IPC_BYPASS,
33         IPC_PDP0,
34         IPC_PDP1,
35         IPC_RFS,
36         IPC_BOOT,
37         IPC_RAMDUMP,
38         MAX_DEV_FORMAT,
39 };
40 #define MAX_IPC_DEV     (IPC_RFS + 1)   /* BYPASS, PDP0, PDP1, PDP2 */
41 #define MAX_SIPC5_DEV   (IPC_PDP0 + 1)  /* FMT, RAW */
42
43 enum modem_io {
44         IODEV_MISC,
45         IODEV_NET,
46         IODEV_DUMMY,
47 };
48
49 enum modem_link {
50         LINKDEV_UNDEFINED,
51         LINKDEV_MIPI,
52         LINKDEV_DPRAM,
53         LINKDEV_SPI,
54         LINKDEV_USB,
55         LINKDEV_HSIC,
56         LINKDEV_C2C,
57         LINKDEV_MAX,
58 };
59 #define LINKTYPE(modem_link) (1u << (modem_link))
60
61 enum modem_network {
62         UMTS_NETWORK,
63         CDMA_NETWORK,
64         LTE_NETWORK,
65 };
66
67 enum sipc_ver {
68         NO_SIPC_VER = 0,
69         SIPC_VER_40 = 40,
70         SIPC_VER_41 = 41,
71         SIPC_VER_42 = 42,
72         SIPC_VER_50 = 50,
73         MAX_SIPC_VER,
74 };
75
76 /**
77  * struct modem_io_t - declaration for io_device
78  * @name:       device name
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.
91  *
92  * This structure is used in board-*-modem.c
93  */
94 struct modem_io_t {
95         char *name;
96         int   id;
97         enum dev_format format;
98         enum modem_io io_type;
99         enum modem_link links;
100         enum modem_link tx_link;
101         bool rx_gather;
102 };
103
104 struct modemlink_pm_data {
105         char *name;
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);
113
114         /* usb hub only */
115         int (*port_enable)(int, int);
116         int (*hub_standby)(void *);
117         void *hub_pm_data;
118         bool has_usbhub;
119
120         /* cpu/bus frequency lock */
121         atomic_t freqlock;
122         int (*freq_lock)(struct device *dev);
123         int (*freq_unlock)(struct device *dev);
124
125         int autosuspend_delay_ms; /* if zero, the default value is used */
126 };
127
128 struct modemlink_pm_link_activectl {
129         int gpio_initialized;
130         int gpio_request_host_active;
131 };
132
133 enum dpram_type {
134         EXT_DPRAM,
135         AP_IDPRAM,
136         CP_IDPRAM,
137         SHM_DPRAM,
138         MAX_DPRAM_TYPE
139 };
140
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
146
147 enum dpram_speed {
148         DPRAM_SPEED_LOW,
149         DPRAM_SPEED_MID,
150         DPRAM_SPEED_HIGH,
151         MAX_DPRAM_SPEED
152 };
153
154 struct dpram_circ {
155         u16 __iomem *head;
156         u16 __iomem *tail;
157         u8  __iomem *buff;
158         u32          size;
159 };
160
161 struct dpram_ipc_device {
162         char name[16];
163         int  id;
164
165         struct dpram_circ txq;
166         struct dpram_circ rxq;
167
168         u16 mask_req_ack;
169         u16 mask_res_ack;
170         u16 mask_send;
171 };
172
173 struct dpram_ipc_map {
174         u16 __iomem *magic;
175         u16 __iomem *access;
176
177         struct dpram_ipc_device dev[MAX_IPC_DEV];
178
179         u16 __iomem *mbx_cp2ap;
180         u16 __iomem *mbx_ap2cp;
181 };
182
183 struct modemlink_dpram_control {
184         void (*reset)(void);
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);
190
191         int (*wakeup)(void);
192         void (*sleep)(void);
193
194         void (*setup_speed)(enum dpram_speed);
195
196         enum dpram_type dp_type;        /* DPRAM type */
197         int aligned;                    /* aligned access is required */
198         u8 __iomem *dp_base;
199         u32 dp_size;
200
201         int dpram_irq;
202         unsigned long dpram_irq_flags;
203
204         int max_ipc_dev;
205         struct dpram_ipc_map *ipc_map;
206
207         unsigned boot_size_offset;
208         unsigned boot_tag_offset;
209         unsigned boot_count_offset;
210         unsigned max_boot_frame_size;
211 };
212
213 /* platform data */
214 struct modem_data {
215         char *name;
216
217         unsigned gpio_cp_on;
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;
229 #endif
230         unsigned gpio_cp_warm_reset;
231         unsigned gpio_sim_detect;
232 #ifdef CONFIG_LINK_DEVICE_DPRAM
233         unsigned gpio_dpram_int;
234 #endif
235
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;
242         int      irq_host_wakeup;
243 #endif
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;
250 #endif
251
252         /* Switch with 2 links in a modem */
253         unsigned gpio_dynamic_switching;
254
255         /* Modem component */
256         enum modem_network  modem_net;
257         enum modem_t        modem_type;
258         enum modem_link     link_types;
259         char               *link_name;
260 #ifdef CONFIG_LINK_DEVICE_DPRAM
261         /* Link to DPRAM control functions dependent on each platform */
262         struct modemlink_dpram_control *dpram_ctl;
263 #endif
264
265         /* SIPC version */
266         enum sipc_ver ipc_version;
267
268         /* Information of IO devices */
269         unsigned            num_iodevs;
270         struct modem_io_t  *iodevs;
271
272         /* Modem link PM support */
273         struct modemlink_pm_data *link_pm_data;
274
275         void (*gpio_revers_bias_clear)(void);
276         void (*gpio_revers_bias_restore)(void);
277
278         /* Handover with 2+ modems */
279         bool use_handover;
280
281         /* Debugging option */
282         bool use_mif_log;
283 };
284
285 #define LOG_TAG "mif: "
286
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__)
296
297 #endif