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