aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/max3107.h
blob: 7ab6323925026920c1e30e17d49f68100da33490 (plain) (blame)
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/*
 * max3107.h - spi uart protocol driver header for Maxim 3107
 *
 * Copyright (C) Aavamobile 2009
 * Based on serial_max3100.h by Christian Pellegrin
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef _MAX3107_H
#define _MAX3107_H

/* Serial error status definitions */
#define MAX3107_PARITY_ERROR	1
#define MAX3107_FRAME_ERROR	2
#define MAX3107_OVERRUN_ERROR	4
#define MAX3107_ALL_ERRORS	(MAX3107_PARITY_ERROR | \
				 MAX3107_FRAME_ERROR | \
				 MAX3107_OVERRUN_ERROR)

/* GPIO definitions */
#define MAX3107_GPIO_BASE	88
#define MAX3107_GPIO_COUNT	4


/* GPIO connected to chip's reset pin */
#define MAX3107_RESET_GPIO	87


/* Chip reset delay */
#define MAX3107_RESET_DELAY	10

/* Chip wakeup delay */
#define MAX3107_WAKEUP_DELAY	50


/* Sleep mode definitions */
#define MAX3107_DISABLE_FORCED_SLEEP	0
#define MAX3107_ENABLE_FORCED_SLEEP	1
#define MAX3107_DISABLE_AUTOSLEEP	2
#define MAX3107_ENABLE_AUTOSLEEP	3


/* Definitions for register access with SPI transfers
 *
 * SPI transfer format:
 *
 * Master to slave bits xzzzzzzzyyyyyyyy
 * Slave to master bits aaaaaaaabbbbbbbb
 *
 * where:
 * x = 0 for reads, 1 for writes
 * z = register address
 * y = new register value if write, 0 if read
 * a = unspecified
 * b = register value if read, unspecified if write
 */

/* SPI speed */
#define MAX3107_SPI_SPEED	(3125000 * 2)

/* Write bit */
#define MAX3107_WRITE_BIT	(1 << 15)

/* SPI TX data mask */
#define MAX3107_SPI_RX_DATA_MASK	(0x00ff)

/* SPI RX data mask */
#define MAX3107_SPI_TX_DATA_MASK	(0x00ff)

/* Register access masks */
#define MAX3107_RHR_REG			(0x0000) /* RX FIFO */
#define MAX3107_THR_REG			(0x0000) /* TX FIFO */
#define MAX3107_IRQEN_REG		(0x0100) /* IRQ enable */
#define MAX3107_IRQSTS_REG		(0x0200) /* IRQ status */
#define MAX3107_LSR_IRQEN_REG		(0x0300) /* LSR IRQ enable */
#define MAX3107_LSR_IRQSTS_REG		(0x0400) /* LSR IRQ status */
#define MAX3107_SPCHR_IRQEN_REG		(0x0500) /* Special char IRQ enable */
#define MAX3107_SPCHR_IRQSTS_REG	(0x0600) /* Special char IRQ status */
#define MAX3107_STS_IRQEN_REG		(0x0700) /* Status IRQ enable */
#define MAX3107_STS_IRQSTS_REG		(0x0800) /* Status IRQ status */
#define MAX3107_MODE1_REG		(0x0900) /* MODE1 */
#define MAX3107_MODE2_REG		(0x0a00) /* MODE2 */
#define MAX3107_LCR_REG			(0x0b00) /* LCR */
#define MAX3107_RXTO_REG		(0x0c00) /* RX timeout */
#define MAX3107_HDPIXDELAY_REG		(0x0d00) /* Auto transceiver delays */
#define MAX3107_IRDA_REG		(0x0e00) /* IRDA settings */
#define MAX3107_FLOWLVL_REG		(0x0f00) /* Flow control levels */
#define MAX3107_FIFOTRIGLVL_REG		(0x1000) /* FIFO IRQ trigger levels */
#define MAX3107_TXFIFOLVL_REG		(0x1100) /* TX FIFO level */
#define MAX3107_RXFIFOLVL_REG		(0x1200) /* RX FIFO level */
#define MAX3107_FLOWCTRL_REG		(0x1300) /* Flow control */
#define MAX3107_XON1_REG		(0x1400) /* XON1 character */
#define MAX3107_XON2_REG		(0x1500) /* XON2 character */
#define MAX3107_XOFF1_REG		(0x1600) /* XOFF1 character */
#define MAX3107_XOFF2_REG		(0x1700) /* XOFF2 character */
#define MAX3107_GPIOCFG_REG		(0x1800) /* GPIO config */
#define MAX3107_GPIODATA_REG		(0x1900) /* GPIO data */
#define MAX3107_PLLCFG_REG		(0x1a00) /* PLL config */
#define MAX3107_BRGCFG_REG		(0x1b00) /* Baud rate generator conf */
#define MAX3107_BRGDIVLSB_REG		(0x1c00) /* Baud rate divisor LSB */
#define MAX3107_BRGDIVMSB_REG		(0x1d00) /* Baud rate divisor MSB */
#define MAX3107_CLKSRC_REG		(0x1e00) /* Clock source */
#define MAX3107_REVID_REG		(0x1f00) /* Revision identification */

/* IRQ register bits */
#define MAX3107_IRQ_LSR_BIT	(1 << 0) /* LSR interrupt */
#define MAX3107_IRQ_SPCHR_BIT	(1 << 1) /* Special char interrupt */
#define MAX3107_IRQ_STS_BIT	(1 << 2) /* Status interrupt */
#define MAX3107_IRQ_RXFIFO_BIT	(1 << 3) /* RX FIFO interrupt */
#define MAX3107_IRQ_TXFIFO_BIT	(1 << 4) /* TX FIFO interrupt */
#define MAX3107_IRQ_TXEMPTY_BIT	(1 << 5) /* TX FIFO empty interrupt */
#define MAX3107_IRQ_RXEMPTY_BIT	(1 << 6) /* RX FIFO empty interrupt */
#define MAX3107_IRQ_CTS_BIT	(1 << 7) /* CTS interrupt */

/* LSR register bits */
#define MAX3107_LSR_RXTO_BIT	(1 << 0) /* RX timeout */
#define MAX3107_LSR_RXOVR_BIT	(1 << 1) /* RX overrun */
#define MAX3107_LSR_RXPAR_BIT	(1 << 2) /* RX parity error */
#define MAX3107_LSR_FRERR_BIT	(1 << 3) /* Frame error */
#define MAX3107_LSR_RXBRK_BIT	(1 << 4) /* RX break */
#define MAX3107_LSR_RXNOISE_BIT	(1 << 5) /* RX noise */
#define MAX3107_LSR_UNDEF6_BIT	(1 << 6) /* Undefined/not used */
#define MAX3107_LSR_CTS_BIT	(1 << 7) /* CTS pin state */

/* Special character register bits */
#define MAX3107_SPCHR_XON1_BIT		(1 << 0) /* XON1 character */
#define MAX3107_SPCHR_XON2_BIT		(1 << 1) /* XON2 character */
#define MAX3107_SPCHR_XOFF1_BIT		(1 << 2) /* XOFF1 character */
#define MAX3107_SPCHR_XOFF2_BIT		(1 << 3) /* XOFF2 character */
#define MAX3107_SPCHR_BREAK_BIT		(1 << 4) /* RX break */
#define MAX3107_SPCHR_MULTIDROP_BIT	(1 << 5) /* 9-bit multidrop addr char */
#define MAX3107_SPCHR_UNDEF6_BIT	(1 << 6) /* Undefined/not used */
#define MAX3107_SPCHR_UNDEF7_BIT	(1 << 7) /* Undefined/not used */

/* Status register bits */
#define MAX3107_STS_GPIO0_BIT		(1 << 0) /* GPIO 0 interrupt */
#define MAX3107_STS_GPIO1_BIT		(1 << 1) /* GPIO 1 interrupt */
#define MAX3107_STS_GPIO2_BIT		(1 << 2) /* GPIO 2 interrupt */
#define MAX3107_STS_GPIO3_BIT		(1 << 3) /* GPIO 3 interrupt */
#define MAX3107_STS_UNDEF4_BIT		(1 << 4) /* Undefined/not used */
#define MAX3107_STS_CLKREADY_BIT	(1 << 5) /* Clock ready */
#define MAX3107_STS_SLEEP_BIT		(1 << 6) /* Sleep interrupt */
#define MAX3107_STS_UNDEF7_BIT		(1 << 7) /* Undefined/not used */

/* MODE1 register bits */
#define MAX3107_MODE1_RXDIS_BIT		(1 << 0) /* RX disable */
#define MAX3107_MODE1_TXDIS_BIT		(1 << 1) /* TX disable */
#define MAX3107_MODE1_TXHIZ_BIT		(1 << 2) /* TX pin three-state */
#define MAX3107_MODE1_RTSHIZ_BIT	(1 << 3) /* RTS pin three-state */
#define MAX3107_MODE1_TRNSCVCTRL_BIT	(1 << 4) /* Transceiver ctrl enable */
#define MAX3107_MODE1_FORCESLEEP_BIT	(1 << 5) /* Force sleep mode */
#define MAX3107_MODE1_AUTOSLEEP_BIT	(1 << 6) /* Auto sleep enable */
#define MAX3107_MODE1_IRQSEL_BIT	(1 << 7) /* IRQ pin enable */

/* MODE2 register bits */
#define MAX3107_MODE2_RST_BIT		(1 << 0) /* Chip reset */
#define MAX3107_MODE2_FIFORST_BIT	(1 << 1) /* FIFO reset */
#define MAX3107_MODE2_RXTRIGINV_BIT	(1 << 2) /* RX FIFO INT invert */
#define MAX3107_MODE2_RXEMPTINV_BIT	(1 << 3) /* RX FIFO empty INT invert */
#define MAX3107_MODE2_SPCHR_BIT		(1 << 4) /* Special chr detect enable */
#define MAX3107_MODE2_LOOPBACK_BIT	(1 << 5) /* Internal loopback enable */
#define MAX3107_MODE2_MULTIDROP_BIT	(1 << 6) /* 9-bit multidrop enable */
#define MAX3107_MODE2_ECHOSUPR_BIT	(1 << 7) /* ECHO suppression enable */

/* LCR register bits */
#define MAX3107_LCR_LENGTH0_BIT		(1 << 0) /* Word length bit 0 */
#define MAX3107_LCR_LENGTH1_BIT		(1 << 1) /* Word length bit 1
						  *
						  * Word length bits table:
						  * 00 -> 5 bit words
						  * 01 -> 6 bit words
						  * 10 -> 7 bit words
						  * 11 -> 8 bit words
						  */
#define MAX3107_LCR_STOPLEN_BIT		(1 << 2) /* STOP length bit
						  *
						  * STOP length bit table:
						  * 0 -> 1 stop bit
						  * 1 -> 1-1.5 stop bits if
						  *      word length is 5,
						  *      2 stop bits otherwise
						  */
#define MAX3107_LCR_PARITY_BIT		(1 << 3) /* Parity bit enable */
#define MAX3107_LCR_EVENPARITY_BIT	(1 << 4) /* Even parity bit enable */
#define MAX3107_LCR_FORCEPARITY_BIT	(1 << 5) /* 9-bit multidrop parity */
#define MAX3107_LCR_TXBREAK_BIT		(1 << 6) /* TX break enable */
#define MAX3107_LCR_RTS_BIT		(1 << 7) /* RTS pin control */
#define MAX3107_LCR_WORD_LEN_5		(0x0000)
#define MAX3107_LCR_WORD_LEN_6		(0x0001)
#define MAX3107_LCR_WORD_LEN_7		(0x0002)
#define MAX3107_LCR_WORD_LEN_8		(0x0003)


/* IRDA register bits */
#define MAX3107_IRDA_IRDAEN_BIT		(1 << 0) /* IRDA mode enable */
#define MAX3107_IRDA_SIR_BIT		(1 << 1) /* SIR mode enable */
#define MAX3107_IRDA_SHORTIR_BIT	(1 << 2) /* Short SIR mode enable */
#define MAX3107_IRDA_MIR_BIT		(1 << 3) /* MIR mode enable */
#define MAX3107_IRDA_RXINV_BIT		(1 << 4) /* RX logic inversion enable */
#define MAX3107_IRDA_TXINV_BIT		(1 << 5) /* TX logic inversion enable */
#define MAX3107_IRDA_UNDEF6_BIT		(1 << 6) /* Undefined/not used */
#define MAX3107_IRDA_UNDEF7_BIT		(1 << 7) /* Undefined/not used */

/* Flow control trigger level register masks */
#define MAX3107_FLOWLVL_HALT_MASK	(0x000f) /* Flow control halt level */
#define MAX3107_FLOWLVL_RES_MASK	(0x00f0) /* Flow control resume level */
#define MAX3107_FLOWLVL_HALT(words)	((words/8) & 0x000f)
#define MAX3107_FLOWLVL_RES(words)	(((words/8) & 0x000f) << 4)

/* FIFO interrupt trigger level register masks */
#define MAX3107_FIFOTRIGLVL_TX_MASK	(0x000f) /* TX FIFO trigger level */
#define MAX3107_FIFOTRIGLVL_RX_MASK	(0x00f0) /* RX FIFO trigger level */
#define MAX3107_FIFOTRIGLVL_TX(words)	((words/8) & 0x000f)
#define MAX3107_FIFOTRIGLVL_RX(words)	(((words/8) & 0x000f) << 4)

/* Flow control register bits */
#define MAX3107_FLOWCTRL_AUTORTS_BIT	(1 << 0) /* Auto RTS flow ctrl enable */
#define MAX3107_FLOWCTRL_AUTOCTS_BIT	(1 << 1) /* Auto CTS flow ctrl enable */
#define MAX3107_FLOWCTRL_GPIADDR_BIT	(1 << 2) /* Enables that GPIO inputs
						  * are used in conjunction with
						  * XOFF2 for definition of
						  * special character */
#define MAX3107_FLOWCTRL_SWFLOWEN_BIT	(1 << 3) /* Auto SW flow ctrl enable */
#define MAX3107_FLOWCTRL_SWFLOW0_BIT	(1 << 4) /* SWFLOW bit 0 */
#define MAX3107_FLOWCTRL_SWFLOW1_BIT	(1 << 5) /* SWFLOW bit 1
						  *
						  * SWFLOW bits 1 & 0 table:
						  * 00 -> no transmitter flow
						  *       control
						  * 01 -> receiver compares
						  *       XON2 and XOFF2
						  *       and controls
						  *       transmitter
						  * 10 -> receiver compares
						  *       XON1 and XOFF1
						  *       and controls
						  *       transmitter
						  * 11 -> receiver compares
						  *       XON1, XON2, XOFF1 and
						  *       XOFF2 and controls
						  *       transmitter
						  */
#define MAX3107_FLOWCTRL_SWFLOW2_BIT	(1 << 6) /* SWFLOW bit 2 */
#define MAX3107_FLOWCTRL_SWFLOW3_BIT	(1 << 7) /* SWFLOW bit 3
						  *
						  * SWFLOW bits 3 & 2 table:
						  * 00 -> no received flow
						  *       control
						  * 01 -> transmitter generates
						  *       XON2 and XOFF2
						  * 10 -> transmitter generates
						  *       XON1 and XOFF1
						  * 11 -> transmitter generates
						  *       XON1, XON2, XOFF1 and
						  *       XOFF2
						  */

/* GPIO configuration register bits */
#define MAX3107_GPIOCFG_GP0OUT_BIT	(1 << 0) /* GPIO 0 output enable */
#define MAX3107_GPIOCFG_GP1OUT_BIT	(1 << 1) /* GPIO 1 output enable */
#define MAX3107_GPIOCFG_GP2OUT_BIT	(1 << 2) /* GPIO 2 output enable */
#define MAX3107_GPIOCFG_GP3OUT_BIT	(1 << 3) /* GPIO 3 output enable */
#define MAX3107_GPIOCFG_GP0OD_BIT	(1 << 4) /* GPIO 0 open-drain enable */
#define MAX3107_GPIOCFG_GP1OD_BIT	(1 << 5) /* GPIO 1 open-drain enable */
#define MAX3107_GPIOCFG_GP2OD_BIT	(1 << 6) /* GPIO 2 open-drain enable */
#define MAX3107_GPIOCFG_GP3OD_BIT	(1 << 7) /* GPIO 3 open-drain enable */

/* GPIO DATA register bits */
#define MAX3107_GPIODATA_GP0OUT_BIT	(1 << 0) /* GPIO 0 output value */
#define MAX3107_GPIODATA_GP1OUT_BIT	(1 << 1) /* GPIO 1 output value */
#define MAX3107_GPIODATA_GP2OUT_BIT	(1 << 2) /* GPIO 2 output value */
#define MAX3107_GPIODATA_GP3OUT_BIT	(1 << 3) /* GPIO 3 output value */
#define MAX3107_GPIODATA_GP0IN_BIT	(1 << 4) /* GPIO 0 input value */
#define MAX3107_GPIODATA_GP1IN_BIT	(1 << 5) /* GPIO 1 input value */
#define MAX3107_GPIODATA_GP2IN_BIT	(1 << 6) /* GPIO 2 input value */
#define MAX3107_GPIODATA_GP3IN_BIT	(1 << 7) /* GPIO 3 input value */

/* PLL configuration register masks */
#define MAX3107_PLLCFG_PREDIV_MASK	(0x003f) /* PLL predivision value */
#define MAX3107_PLLCFG_PLLFACTOR_MASK	(0x00c0) /* PLL multiplication factor */

/* Baud rate generator configuration register masks and bits */
#define MAX3107_BRGCFG_FRACT_MASK	(0x000f) /* Fractional portion of
						  * Baud rate generator divisor
						  */
#define MAX3107_BRGCFG_2XMODE_BIT	(1 << 4) /* Double baud rate */
#define MAX3107_BRGCFG_4XMODE_BIT	(1 << 5) /* Quadruple baud rate */
#define MAX3107_BRGCFG_UNDEF6_BIT	(1 << 6) /* Undefined/not used */
#define MAX3107_BRGCFG_UNDEF7_BIT	(1 << 7) /* Undefined/not used */

/* Clock source register bits */
#define MAX3107_CLKSRC_INTOSC_BIT	(1 << 0) /* Internal osc enable */
#define MAX3107_CLKSRC_CRYST_BIT	(1 << 1) /* Crystal osc enable */
#define MAX3107_CLKSRC_PLL_BIT		(1 << 2) /* PLL enable */
#define MAX3107_CLKSRC_PLLBYP_BIT	(1 << 3) /* PLL bypass */
#define MAX3107_CLKSRC_EXTCLK_BIT	(1 << 4) /* External clock enable */
#define MAX3107_CLKSRC_UNDEF5_BIT	(1 << 5) /* Undefined/not used */
#define MAX3107_CLKSRC_UNDEF6_BIT	(1 << 6) /* Undefined/not used */
#define MAX3107_CLKSRC_CLK2RTS_BIT	(1 << 7) /* Baud clk to RTS pin */


/* HW definitions */
#define MAX3107_RX_FIFO_SIZE	128
#define MAX3107_TX_FIFO_SIZE	128
#define MAX3107_REVID1		0x00a0
#define MAX3107_REVID2		0x00a1


/* Baud rate generator configuration values for external clock 13MHz */
#define MAX3107_BRG13_B300	(0x0A9400 | 0x05)
#define MAX3107_BRG13_B600	(0x054A00 | 0x03)
#define MAX3107_BRG13_B1200	(0x02A500 | 0x01)
#define MAX3107_BRG13_B2400	(0x015200 | 0x09)
#define MAX3107_BRG13_B4800	(0x00A900 | 0x04)
#define MAX3107_BRG13_B9600	(0x005400 | 0x0A)
#define MAX3107_BRG13_B19200	(0x002A00 | 0x05)
#define MAX3107_BRG13_B38400	(0x001500 | 0x03)
#define MAX3107_BRG13_B57600	(0x000E00 | 0x02)
#define MAX3107_BRG13_B115200	(0x000700 | 0x01)
#define MAX3107_BRG13_B230400	(0x000300 | 0x08)
#define MAX3107_BRG13_B460800	(0x000100 | 0x0c)
#define MAX3107_BRG13_B921600	(0x000100 | 0x1c)

/* Baud rate generator configuration values for external clock 26MHz */
#define MAX3107_BRG26_B300	(0x152800 | 0x0A)
#define MAX3107_BRG26_B600	(0x0A9400 | 0x05)
#define MAX3107_BRG26_B1200	(0x054A00 | 0x03)
#define MAX3107_BRG26_B2400	(0x02A500 | 0x01)
#define MAX3107_BRG26_B4800	(0x015200 | 0x09)
#define MAX3107_BRG26_B9600	(0x00A900 | 0x04)
#define MAX3107_BRG26_B19200	(0x005400 | 0x0A)
#define MAX3107_BRG26_B38400	(0x002A00 | 0x05)
#define MAX3107_BRG26_B57600	(0x001C00 | 0x03)
#define MAX3107_BRG26_B115200	(0x000E00 | 0x02)
#define MAX3107_BRG26_B230400	(0x000700 | 0x01)
#define MAX3107_BRG26_B460800	(0x000300 | 0x08)
#define MAX3107_BRG26_B921600	(0x000100 | 0x0C)

/* Baud rate generator configuration values for internal clock */
#define MAX3107_BRG13_IB300	(0x008000 | 0x00)
#define MAX3107_BRG13_IB600	(0x004000 | 0x00)
#define MAX3107_BRG13_IB1200	(0x002000 | 0x00)
#define MAX3107_BRG13_IB2400	(0x001000 | 0x00)
#define MAX3107_BRG13_IB4800	(0x000800 | 0x00)
#define MAX3107_BRG13_IB9600	(0x000400 | 0x00)
#define MAX3107_BRG13_IB19200	(0x000200 | 0x00)
#define MAX3107_BRG13_IB38400	(0x000100 | 0x00)
#define MAX3107_BRG13_IB57600	(0x000000 | 0x0B)
#define MAX3107_BRG13_IB115200	(0x000000 | 0x05)
#define MAX3107_BRG13_IB230400	(0x000000 | 0x03)
#define MAX3107_BRG13_IB460800	(0x000000 | 0x00)
#define MAX3107_BRG13_IB921600	(0x000000 | 0x00)


struct baud_table {
	int baud;
	u32 new_brg;
};

struct max3107_port {
	/* UART port structure */
	struct uart_port port;

	/* SPI device structure */
	struct spi_device *spi;

#if defined(CONFIG_GPIOLIB)
	/* GPIO chip stucture */
	struct gpio_chip chip;
#endif

	/* Workqueue that does all the magic */
	struct workqueue_struct *workqueue;
	struct work_struct work;

	/* Lock for shared data */
	spinlock_t data_lock;

	/* Device configuration */
	int ext_clk;		/* 1 if external clock used */
	int loopback;		/* Current loopback mode state */
	int baud;			/* Current baud rate */

	/* State flags */
	int suspended;		/* Indicates suspend mode */
	int tx_fifo_empty;	/* Flag for TX FIFO state */
	int rx_enabled;		/* Flag for receiver state */
	int tx_enabled;		/* Flag for transmitter state */

	u16 irqen_reg;		/* Current IRQ enable register value */
	/* Shared data */
	u16 mode1_reg;		/* Current mode1 register value*/
	int mode1_commit;	/* Flag for setting new mode1 register value */
	u16 lcr_reg;		/* Current LCR register value */
	int lcr_commit;		/* Flag for setting new LCR register value */
	u32 brg_cfg;		/* Current Baud rate generator config  */
	int brg_commit;		/* Flag for setting new baud rate generator
				 * config
				 */
	struct baud_table *baud_tbl;
	int handle_irq;		/* Indicates that IRQ should be handled */

	/* Rx buffer and str*/
	u16 *rxbuf;
	u8  *rxstr;
	/* Tx buffer*/
	u16 *txbuf;

	struct max3107_plat *pdata;	/* Platform data */
};

/* Platform data structure */
struct max3107_plat {
	/* Loopback mode enable */
	int loopback;
	/* External clock enable */
	int ext_clk;
	/* Called during the register initialisation */
	void (*init)(struct max3107_port *s);
	/* Called when the port is found and configured */
	int (*configure)(struct max3107_port *s);
	/* HW suspend function */
	void (*hw_suspend) (struct max3107_port *s, int suspend);
	/* Polling mode enable */
	int polled_mode;
	/* Polling period if polling mode enabled */
	int poll_time;
};

extern int max3107_rw(struct max3107_port *s, u8 *tx, u8 *rx, int len);
extern void max3107_hw_susp(struct max3107_port *s, int suspend);
extern int max3107_probe(struct spi_device *spi, struct max3107_plat *pdata);
extern int max3107_remove(struct spi_device *spi);
extern int max3107_suspend(struct spi_device *spi, pm_message_t state);
extern int max3107_resume(struct spi_device *spi);

#endif /* _LINUX_SERIAL_MAX3107_H */
1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
ÐÏࡱá