1#ifndef __PMAC_ZILOG_H__
2#define __PMAC_ZILOG_H__
3
4#define pmz_debug(fmt,arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg)
5
6
7
8
9#define MAX_ZS_PORTS 4
10
11
12
13
14#define NUM_ZSREGS 17
15
16struct uart_pmac_port {
17 struct uart_port port;
18 struct uart_pmac_port *mate;
19
20
21
22
23 struct macio_dev *dev;
24
25
26
27 struct device_node *node;
28
29
30 int port_type;
31 u8 curregs[NUM_ZSREGS];
32
33 unsigned int flags;
34#define PMACZILOG_FLAG_IS_CONS 0x00000001
35#define PMACZILOG_FLAG_IS_KGDB 0x00000002
36#define PMACZILOG_FLAG_MODEM_STATUS 0x00000004
37#define PMACZILOG_FLAG_IS_CHANNEL_A 0x00000008
38#define PMACZILOG_FLAG_REGS_HELD 0x00000010
39#define PMACZILOG_FLAG_TX_STOPPED 0x00000020
40#define PMACZILOG_FLAG_TX_ACTIVE 0x00000040
41#define PMACZILOG_FLAG_ENABLED 0x00000080
42#define PMACZILOG_FLAG_IS_IRDA 0x00000100
43#define PMACZILOG_FLAG_IS_INTMODEM 0x00000200
44#define PMACZILOG_FLAG_HAS_DMA 0x00000400
45#define PMACZILOG_FLAG_RSRC_REQUESTED 0x00000800
46#define PMACZILOG_FLAG_IS_ASLEEP 0x00001000
47#define PMACZILOG_FLAG_IS_OPEN 0x00002000
48#define PMACZILOG_FLAG_IS_IRQ_ON 0x00004000
49#define PMACZILOG_FLAG_IS_EXTCLK 0x00008000
50#define PMACZILOG_FLAG_BREAK 0x00010000
51
52 unsigned char parity_mask;
53 unsigned char prev_status;
54
55 volatile u8 __iomem *control_reg;
56 volatile u8 __iomem *data_reg;
57
58 unsigned int tx_dma_irq;
59 unsigned int rx_dma_irq;
60 volatile struct dbdma_regs __iomem *tx_dma_regs;
61 volatile struct dbdma_regs __iomem *rx_dma_regs;
62
63 struct ktermios termios_cache;
64};
65
66#define to_pmz(p) ((struct uart_pmac_port *)(p))
67
68static inline struct uart_pmac_port *pmz_get_port_A(struct uart_pmac_port *uap)
69{
70 if (uap->flags & PMACZILOG_FLAG_IS_CHANNEL_A)
71 return uap;
72 return uap->mate;
73}
74
75
76
77
78
79
80
81static inline u8 read_zsreg(struct uart_pmac_port *port, u8 reg)
82{
83 if (reg != 0)
84 writeb(reg, port->control_reg);
85 return readb(port->control_reg);
86}
87
88static inline void write_zsreg(struct uart_pmac_port *port, u8 reg, u8 value)
89{
90 if (reg != 0)
91 writeb(reg, port->control_reg);
92 writeb(value, port->control_reg);
93}
94
95static inline u8 read_zsdata(struct uart_pmac_port *port)
96{
97 return readb(port->data_reg);
98}
99
100static inline void write_zsdata(struct uart_pmac_port *port, u8 data)
101{
102 writeb(data, port->data_reg);
103}
104
105static inline void zssync(struct uart_pmac_port *port)
106{
107 (void)readb(port->control_reg);
108}
109
110
111
112
113#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
114#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
115
116#define ZS_CLOCK 3686400
117
118
119
120#define FLAG 0x7e
121
122
123#define R0 0
124#define R1 1
125#define R2 2
126#define R3 3
127#define R4 4
128#define R5 5
129#define R6 6
130#define R7 7
131#define R8 8
132#define R9 9
133#define R10 10
134#define R11 11
135#define R12 12
136#define R13 13
137#define R14 14
138#define R15 15
139#define R7P 16
140
141#define NULLCODE 0
142#define POINT_HIGH 0x8
143#define RES_EXT_INT 0x10
144#define SEND_ABORT 0x18
145#define RES_RxINT_FC 0x20
146#define RES_Tx_P 0x28
147#define ERR_RES 0x30
148#define RES_H_IUS 0x38
149
150#define RES_Rx_CRC 0x40
151#define RES_Tx_CRC 0x80
152#define RES_EOM_L 0xC0
153
154
155
156#define EXT_INT_ENAB 0x1
157#define TxINT_ENAB 0x2
158#define PAR_SPEC 0x4
159
160#define RxINT_DISAB 0
161#define RxINT_FCERR 0x8
162#define INT_ALL_Rx 0x10
163#define INT_ERR_Rx 0x18
164#define RxINT_MASK 0x18
165
166#define WT_RDY_RT 0x20
167#define WT_FN_RDYFN 0x40
168#define WT_RDY_ENAB 0x80
169
170
171
172
173
174#define RxENABLE 0x1
175#define SYNC_L_INH 0x2
176#define ADD_SM 0x4
177#define RxCRC_ENAB 0x8
178#define ENT_HM 0x10
179#define AUTO_ENAB 0x20
180#define Rx5 0x0
181#define Rx7 0x40
182#define Rx6 0x80
183#define Rx8 0xc0
184#define RxN_MASK 0xc0
185
186
187
188#define PAR_ENAB 0x1
189#define PAR_EVEN 0x2
190
191#define SYNC_ENAB 0
192#define SB1 0x4
193#define SB15 0x8
194#define SB2 0xc
195#define SB_MASK 0xc
196
197#define MONSYNC 0
198#define BISYNC 0x10
199#define SDLC 0x20
200#define EXTSYNC 0x30
201
202#define X1CLK 0x0
203#define X16CLK 0x40
204#define X32CLK 0x80
205#define X64CLK 0xC0
206#define XCLK_MASK 0xC0
207
208
209
210#define TxCRC_ENAB 0x1
211#define RTS 0x2
212#define SDLC_CRC 0x4
213#define TxENABLE 0x8
214#define SND_BRK 0x10
215#define Tx5 0x0
216#define Tx7 0x20
217#define Tx6 0x40
218#define Tx8 0x60
219#define TxN_MASK 0x60
220#define DTR 0x80
221
222
223
224
225
226
227#define ENEXREAD 0x40
228
229
230
231
232#define VIS 1
233#define NV 2
234#define DLC 4
235#define MIE 8
236#define STATHI 0x10
237#define NORESET 0
238#define CHRB 0x40
239#define CHRA 0x80
240#define FHWRES 0xc0
241
242
243#define BIT6 1
244#define LOOPMODE 2
245#define ABUNDER 4
246#define MARKIDLE 8
247#define GAOP 0x10
248#define NRZ 0
249#define NRZI 0x20
250#define FM1 0x40
251#define FM0 0x60
252#define CRCPS 0x80
253
254
255#define TRxCXT 0
256#define TRxCTC 1
257#define TRxCBR 2
258#define TRxCDP 3
259#define TRxCOI 4
260#define TCRTxCP 0
261#define TCTRxCP 8
262#define TCBR 0x10
263#define TCDPLL 0x18
264#define RCRTxCP 0
265#define RCTRxCP 0x20
266#define RCBR 0x40
267#define RCDPLL 0x60
268#define RTxCX 0x80
269
270
271
272
273
274
275#define BRENAB 1
276#define BRSRC 2
277#define DTRREQ 4
278#define AUTOECHO 8
279#define LOOPBAK 0x10
280#define SEARCH 0x20
281#define RMC 0x40
282#define DISDPLL 0x60
283#define SSBR 0x80
284#define SSRTxC 0xa0
285#define SFMM 0xc0
286#define SNRZI 0xe0
287
288
289#define EN85C30 1
290#define ZCIE 2
291#define ENSTFIFO 4
292#define DCDIE 8
293#define SYNCIE 0x10
294#define CTSIE 0x20
295#define TxUIE 0x40
296#define BRKIE 0x80
297
298
299
300#define Rx_CH_AV 0x1
301#define ZCOUNT 0x2
302#define Tx_BUF_EMP 0x4
303#define DCD 0x8
304#define SYNC_HUNT 0x10
305#define CTS 0x20
306#define TxEOM 0x40
307#define BRK_ABRT 0x80
308
309
310#define ALL_SNT 0x1
311
312#define RES3 0x8
313#define RES4 0x4
314#define RES5 0xc
315#define RES6 0x2
316#define RES7 0xa
317#define RES8 0x6
318#define RES18 0xe
319#define RES28 0x0
320
321#define PAR_ERR 0x10
322#define Rx_OVR 0x20
323#define CRC_ERR 0x40
324#define END_FR 0x80
325
326
327#define CHB_Tx_EMPTY 0x00
328#define CHB_EXT_STAT 0x02
329#define CHB_Rx_AVAIL 0x04
330#define CHB_SPECIAL 0x06
331#define CHA_Tx_EMPTY 0x08
332#define CHA_EXT_STAT 0x0a
333#define CHA_Rx_AVAIL 0x0c
334#define CHA_SPECIAL 0x0e
335#define STATUS_MASK 0x06
336
337
338#define CHBEXT 0x1
339#define CHBTxIP 0x2
340#define CHBRxIP 0x4
341#define CHAEXT 0x8
342#define CHATxIP 0x10
343#define CHARxIP 0x20
344
345
346
347
348#define ONLOOP 2
349#define LOOPSEND 0x10
350#define CLK2MIS 0x40
351#define CLK1MIS 0x80
352
353
354
355
356
357
358
359
360#define ZS_CLEARERR(port) (write_zsreg(port, 0, ERR_RES))
361#define ZS_CLEARFIFO(port) do { volatile unsigned char garbage; \
362 garbage = read_zsdata(port); \
363 garbage = read_zsdata(port); \
364 garbage = read_zsdata(port); \
365 } while(0)
366
367#define ZS_IS_CONS(UP) ((UP)->flags & PMACZILOG_FLAG_IS_CONS)
368#define ZS_IS_KGDB(UP) ((UP)->flags & PMACZILOG_FLAG_IS_KGDB)
369#define ZS_IS_CHANNEL_A(UP) ((UP)->flags & PMACZILOG_FLAG_IS_CHANNEL_A)
370#define ZS_REGS_HELD(UP) ((UP)->flags & PMACZILOG_FLAG_REGS_HELD)
371#define ZS_TX_STOPPED(UP) ((UP)->flags & PMACZILOG_FLAG_TX_STOPPED)
372#define ZS_TX_ACTIVE(UP) ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE)
373#define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS)
374#define ZS_IS_IRDA(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRDA)
375#define ZS_IS_INTMODEM(UP) ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM)
376#define ZS_HAS_DMA(UP) ((UP)->flags & PMACZILOG_FLAG_HAS_DMA)
377#define ZS_IS_ASLEEP(UP) ((UP)->flags & PMACZILOG_FLAG_IS_ASLEEP)
378#define ZS_IS_OPEN(UP) ((UP)->flags & PMACZILOG_FLAG_IS_OPEN)
379#define ZS_IS_IRQ_ON(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRQ_ON)
380#define ZS_IS_EXTCLK(UP) ((UP)->flags & PMACZILOG_FLAG_IS_EXTCLK)
381
382#endif
383