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