8253x.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:31k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* -*- linux-c -*- */
  2. /* $Id: 8253x.h,v 1.14 2002/02/10 22:17:25 martillo Exp $
  3.  * sab82532.h: Register Definitions for the Siemens SAB82532 DUSCC
  4.  *
  5.  * Copyright (C) 1997  Eddie C. Dost  (ecd@skynet.be)
  6.  *
  7.  * Modified Aug 1, 2000 Francois Wautier  
  8.  * Modified for complete driver Joachim Martillo
  9.  */
  10. /* Modifications:
  11.  * Copyright (C) 2001 By Joachim Martillo, Telford Tools, Inc.
  12.  *
  13.  * This program is free software; you can redistribute it and/or
  14.  * modify it under the terms of the GNU General Public License
  15.  * as published by the Free Software Foundation; either version
  16.  * 2 of the License, or (at your option) any later version.
  17.  *
  18.  **/
  19. #ifndef _SAB82532_H
  20. #define _SAB82532_H
  21. #include <linux/types.h>
  22. #include <linux/delay.h>
  23. #include <linux/serial.h> /* need struct async_icount for ioctl */
  24. #include <linux/netdevice.h>
  25. #include "8253xioc.h"
  26. #include "ring.h"
  27. #define SAB8253X_MAX_TEC_DELAY 200000 /* 1 character time (at 50 baud) */
  28. #define SAB8253X_MAX_CEC_DELAY  50000 /* 2.5 TX CLKs (at 50 baud) */
  29. #define SERIAL_TYPE_SYNCTTY 3 /* check tty driver to make sure okay */
  30. /* SERIAL_TYPE_NORMAL and SERIAL_TYPE_CALLOUT */
  31. /* seem to be used by the tty driver */
  32. /* only to print out a warning not to */
  33. /* use callout devices - next version of */
  34. /* the code, for now want to be able to */
  35. /* maintain some of the structure of */
  36. /* a 2.2.* driver for those that are */
  37. /* running old kernels. */
  38. #define READB(port, rreg) (*port->readbyte)(port,
  39. (unsigned char *)&(port->regs->async_read.rreg))
  40. #define WRITEB(port, rreg, val) (*port->writebyte)(port,
  41. (unsigned char *)&(port->regs->async_write.rreg), val)
  42. #ifdef DEFINE_VARIABLE
  43. static unsigned char tmpval; 
  44. #endif
  45. /* Used in the macro below -- don't create a variable called tmpval*/
  46. #define SET_REG_BIT(port,rreg,bit)
  47. tmpval=(*port->readbyte)(port,
  48. (unsigned char *)&(port->regs->async_read.rreg));
  49. tmpval |= bit;
  50. (*port->writebyte)(port,
  51. (unsigned char *)&(port->regs->async_write.rreg), tmpval);
  52. #define CLEAR_REG_BIT(port,rreg,bit)
  53. tmpval=(*port->readbyte)(port,
  54. (unsigned char *)&(port->regs->async_read.rreg));
  55. tmpval &= ~(bit);
  56. (*port->writebyte)(port,
  57. (unsigned char *)&(port->regs->async_write.rreg), tmpval);
  58. #define MASK_REG_BIT(port,rreg,bit)
  59. tmpval=(*port->readbyte)(port,
  60. (unsigned char *)&(port->regs->async_read.rreg));
  61. tmpval &= bit;
  62. (*port->writebyte)(port,
  63. (unsigned char *)&(port->regs->async_write.rreg), tmpval);
  64. #define READ_X_WRITEB(port,rreg,op,val)
  65. tmpval=(*port->readbyte)(port,
  66. (unsigned char *)&(port->regs->async_read.rreg));
  67. tmpval op= val;
  68. (*port->writebyte)(port,
  69. (unsigned char *)&(port->regs->async_write.rreg), tmpval);
  70. struct sab82532_async_rd_regs 
  71. {
  72. volatile unsigned char rfifo[0x20]; /* Receive FIFO */
  73. volatile unsigned char star; /* Status Register */
  74. volatile unsigned char rsta; /* actually an HDLC register */
  75. volatile unsigned char mode; /* Mode Register */
  76. volatile unsigned char timr; /* Timer Register */
  77. volatile unsigned char xon; /* XON Character */
  78. volatile unsigned char xoff; /* XOFF Character */
  79. volatile unsigned char tcr; /* Termination Character Register */
  80. volatile unsigned char dafo; /* Data Format */
  81. volatile unsigned char rfc; /* RFIFO Control Register */
  82. volatile unsigned char __pad2;
  83. volatile unsigned char rbcl; /* Receive Byte Count Low */
  84. volatile unsigned char rbch; /* Receive Byte Count High */
  85. volatile unsigned char ccr0; /* Channel Configuration Register 0 */
  86. volatile unsigned char ccr1; /* Channel Configuration Register 1 */
  87. volatile unsigned char ccr2; /* Channel Configuration Register 2 */
  88. volatile unsigned char ccr3; /* Channel Configuration Register 3 */
  89. volatile unsigned char __pad3[4];
  90. volatile unsigned char vstr; /* Version Status Register */
  91. volatile unsigned char __pad4[3];
  92. volatile unsigned char gis; /* Global Interrupt Status */
  93. volatile unsigned char ipc; /* Interrupt Port Configuration */
  94. volatile unsigned char isr0; /* Interrupt Status 0 */
  95. volatile unsigned char isr1; /* Interrupt Status 1 */
  96. volatile unsigned char pvr; /* Port Value Register */
  97. volatile unsigned char pis; /* Port Interrupt Status */
  98. volatile unsigned char pcr; /* Port Configuration Register */
  99. volatile unsigned char ccr4; /* Channel Configuration Register 4 */
  100. };
  101. struct sab82532_async_wr_regs 
  102. {
  103. unsigned char xfifo[0x20]; /* Transmit FIFO */
  104. unsigned char cmdr; /* Command Register */
  105. unsigned char __pad1;
  106. unsigned char mode;
  107. unsigned char timr;
  108. unsigned char xon;
  109. unsigned char xoff;
  110. unsigned char tcr;
  111. unsigned char dafo;
  112. unsigned char rfc;
  113. unsigned char __pad2;
  114. unsigned char xbcl; /* Transmit Byte Count Low */
  115. unsigned char xbch; /* Transmit Byte Count High */
  116. unsigned char ccr0;
  117. unsigned char ccr1;
  118. unsigned char ccr2;
  119. unsigned char ccr3;
  120. unsigned char tsax; /* Time-Slot Assignment Reg. Transmit */
  121. unsigned char tsar; /* Time-Slot Assignment Reg. Receive */
  122. unsigned char xccr; /* Transmit Channel Capacity Register */
  123. unsigned char rccr; /* Receive Channel Capacity Register */
  124. unsigned char bgr; /* Baud Rate Generator Register */
  125. unsigned char tic; /* Transmit Immediate Character */
  126. unsigned char mxn; /* Mask XON Character */
  127. unsigned char mxf; /* Mask XOFF Character */
  128. unsigned char iva; /* Interrupt Vector Address */
  129. unsigned char ipc;
  130. unsigned char imr0; /* Interrupt Mask Register 0 */
  131. unsigned char imr1; /* Interrupt Mask Register 1 */
  132. unsigned char pvr;
  133. unsigned char pim; /* Port Interrupt Mask */
  134. unsigned char pcr;
  135. unsigned char ccr4;
  136. };
  137. struct sab82532_async_rw_regs 
  138. { /* Read/Write registers */
  139. volatile unsigned char __pad1[0x20];
  140. volatile unsigned char __pad2;
  141. volatile unsigned char __pad3;
  142. volatile unsigned char mode;
  143. volatile unsigned char timr;
  144. volatile unsigned char xon;
  145. volatile unsigned char xoff;
  146. volatile unsigned char tcr;
  147. volatile unsigned char dafo;
  148. volatile unsigned char rfc;
  149. volatile unsigned char __pad4;
  150. volatile unsigned char __pad5;
  151. volatile unsigned char __pad6;
  152. volatile unsigned char ccr0;
  153. volatile unsigned char ccr1;
  154. volatile unsigned char ccr2;
  155. volatile unsigned char ccr3;
  156. volatile unsigned char __pad7;
  157. volatile unsigned char __pad8;
  158. volatile unsigned char __pad9;
  159. volatile unsigned char __pad10;
  160. volatile unsigned char __pad11;
  161. volatile unsigned char __pad12;
  162. volatile unsigned char __pad13;
  163. volatile unsigned char __pad14;
  164. volatile unsigned char __pad15;
  165. volatile unsigned char ipc;
  166. volatile unsigned char __pad16;
  167. volatile unsigned char __pad17;
  168. volatile unsigned char pvr;
  169. volatile unsigned char __pad18;
  170. volatile unsigned char pcr;
  171. volatile unsigned char ccr4;
  172. };
  173. union sab82532_async_regs 
  174. {
  175. __volatile__ struct sab82532_async_rd_regs r;
  176. __volatile__ struct sab82532_async_wr_regs w;
  177. __volatile__ struct sab82532_async_rw_regs rw;
  178. };
  179. /* not really used yet */
  180. struct sab82532_hdlc_rd_regs 
  181. {
  182. volatile unsigned char rfifo[0x20]; /* Receive FIFO */
  183. volatile unsigned char star; /* Status Register */
  184. volatile unsigned char rsta;
  185. volatile unsigned char mode; /* Mode Register */
  186. volatile unsigned char timr; /* Timer Register */
  187. volatile unsigned char xad1; /* Tx Address High 1   */
  188. volatile unsigned char xad2; /* Tx Address High 2 */
  189. volatile unsigned char __pad1[2];
  190. volatile unsigned char ral1; /* Rx Address Low 1 */
  191. volatile unsigned char rhcr; /* Received HDLC Control */
  192. volatile unsigned char rbcl; /* Receive Byte Count Low */
  193. volatile unsigned char rbch; /* Receive Byte Count High */
  194. volatile unsigned char ccr0; /* Channel Configuration Register 0 */
  195. volatile unsigned char ccr1; /* Channel Configuration Register 1 */
  196. volatile unsigned char ccr2; /* Channel Configuration Register 2 */
  197. volatile unsigned char ccr3; /* Channel Configuration Register 3 */
  198. volatile unsigned char __pad2[4];
  199. volatile unsigned char vstr; /* Version Status Register */
  200. volatile unsigned char __pad3[3];
  201. volatile unsigned char gis; /* Global Interrupt Status */
  202. volatile unsigned char ipc; /* Interrupt Port Configuration */
  203. volatile unsigned char isr0; /* Interrupt Status 0 */
  204. volatile unsigned char isr1; /* Interrupt Status 1 */
  205. volatile unsigned char pvr; /* Port Value Register */
  206. volatile unsigned char pis; /* Port Interrupt Status */
  207. volatile unsigned char pcr; /* Port Configuration Register */
  208. volatile unsigned char ccr4; /* Channel Configuration Register 4 */
  209. };
  210. struct sab82532_hdlc_wr_regs 
  211. {
  212. unsigned char xfifo[0x20]; /* Transmit FIFO */
  213. unsigned char cmdr; /* Command Register */
  214. unsigned char pre; /* Preamble                             */
  215. unsigned char mode;
  216. unsigned char timr;
  217. unsigned char xad1; /* Tx Address High 1   */
  218. unsigned char xad2; /* Tx Address High 2   */
  219. unsigned char rah1; /* Rx Address High 1   */
  220. unsigned char rah2; /* Rx Address High 2   */
  221. unsigned char ral1; /* Rx Address Low 1 */
  222. unsigned char ral2; /* Rx Address Low 2 */
  223. unsigned char xbcl; /* Transmit Byte Count Low */
  224. unsigned char xbch; /* Transmit Byte Count High */
  225. unsigned char ccr0;
  226. unsigned char ccr1;
  227. unsigned char ccr2;
  228. unsigned char ccr3;
  229. unsigned char tsax; /* Time-Slot Assignment Reg. Transmit */
  230. unsigned char tsar; /* Time-Slot Assignment Reg. Receive */
  231. unsigned char xccr; /* Transmit Channel Capacity Register */
  232. unsigned char rccr; /* Receive Channel Capacity Register */
  233. unsigned char bgr; /* Baud Rate Generator Register */
  234. unsigned char rlcr; /* Rx Frame Length Check */
  235. unsigned char aml; /* Address Mask Low */
  236. unsigned char amh; /* Address Mask High */
  237. unsigned char iva; /* Interrupt Vector Address */
  238. unsigned char ipc;
  239. unsigned char imr0; /* Interrupt Mask Register 0 */
  240. unsigned char imr1; /* Interrupt Mask Register 1 */
  241. unsigned char pvr;
  242. unsigned char pim; /* Port Interrupt Mask */
  243. unsigned char pcr;
  244. unsigned char ccr4;
  245. };
  246. union sab82532_regs 
  247. {
  248. __volatile__ struct sab82532_async_rd_regs async_read;
  249. __volatile__ struct sab82532_async_wr_regs async_write;
  250. __volatile__ struct sab82532_hdlc_rd_regs hdlc_read;
  251. __volatile__ struct sab82532_hdlc_wr_regs hdlc_write;
  252. };
  253. /*
  254.  * Modem signal definition
  255.  */
  256. typedef struct mctlsig 
  257. {
  258. unsigned char *reg; /* chip register offset */
  259. unsigned char inverted; /* interpret the results as inverted */
  260. unsigned char mask; /* bit within that register */
  261. unsigned char val; /* cached value */
  262. unsigned int irq; /* address of correct isr register */
  263. unsigned char irqmask; /*  */
  264. unsigned char cnst; /* A value that should always be set for
  265.  * this signal register */ 
  266. } mctlsig_t, MCTLSIG;
  267. union sab8253x_irq_status 
  268. {
  269. unsigned int stat;
  270. unsigned char images[4];
  271. struct
  272. {
  273. unsigned char isr0;
  274. unsigned char isr1;
  275. unsigned char pis;
  276. } sreg;
  277. };
  278. /* the following are deprecated */
  279. /* older version of structure above */
  280. /* used array*/
  281. #define      ISR0_IDX 0
  282. #define      ISR1_IDX 1
  283. #define       PIS_IDX 2
  284. /*
  285.  * Each port has a structure like this associated to it.
  286.  * All the port are linked with the  next fields
  287.  * All the port of one chip are linked with the  next_by_chip
  288.  */
  289. #define FUNCTION_NR 0
  290. #define FUNCTION_AO 1
  291. #define FUNCTION_NA 2
  292. #define FUNCTION_UN 3
  293. typedef struct sab_port 
  294. {
  295. int magic;
  296. union sab82532_regs *regs;
  297. struct sab_chip *chip;
  298. struct sab_board *board;
  299. struct tty_struct *tty;
  300. unsigned char *xmit_buf;
  301. int  xmit_head; /* put characters on write */
  302. int  xmit_tail; /* read from here -- in writeb or writefifo */
  303. int  xmit_cnt;
  304. /*
  305.  * Various linked list pertinent to this link 
  306.  */
  307. struct sab_port * next;
  308. struct sab_port * next_by_chip;
  309. struct sab_port * next_by_board;
  310. struct sab_port * next_by_cim;
  311. struct net_device *dev;
  312. struct net_device *next_dev;
  313. struct fasync_struct * async_queue;
  314. struct sk_buff_head *sab8253xbuflist; /* need to keep */
  315. /* a list of all */
  316. /* skbuffs so that */
  317. /* we can guarantee */
  318. /* freeing all when */
  319. /* the PPC is stopped */
  320. /* on close*/
  321. struct sk_buff_head *sab8253xc_rcvbuflist; /* used for passing */
  322. /* buffers from interrupt */
  323. /* receive process*/
  324. DCONTROL2 dcontrol2;
  325. DCONTROL2 active2;
  326. DCONTROL2 sabnext2;
  327. int DoingInterrupt;
  328. int irq;
  329. int flags;        /* suggested by serial.h
  330. * but this driver is
  331. * more general */
  332. int syncflags;
  333. int type;        /* SAB82532/8 version */
  334. unsigned int function;
  335. int read_status_mask;
  336. int ignore_status_mask;
  337. int timeout;
  338. int xmit_fifo_size;
  339. int recv_fifo_size;
  340. int custom_divisor;
  341. unsigned long baud;
  342. unsigned int ebrg;
  343. unsigned int cec_timeout;
  344. unsigned int tec_timeout;
  345. int x_char;
  346. int close_delay;
  347. unsigned short closing_wait;
  348. unsigned short closing_wait2;
  349. int all_sent;
  350. int is_console;
  351. #define OPEN_NOT 0
  352. #define OPEN_ASYNC 1
  353. #define OPEN_SYNC 2
  354. #define OPEN_BSC 3
  355. #define OPEN_RAW 4
  356. #define OPEN_SYNC_NET 5
  357. #define OPEN_SYNC_CHAR 6
  358. unsigned int open_type; /* Sync? Async?, int better for hw bps */
  359. unsigned char         interrupt_mask0;
  360. unsigned char interrupt_mask1;
  361. /* Modem signals */
  362. mctlsig_t dtr;
  363. mctlsig_t dsr;
  364. mctlsig_t dcd;
  365. mctlsig_t cts;
  366. mctlsig_t rts;
  367. mctlsig_t txclkdir; /* Direction of TxClk */
  368. unsigned long           custspeed; /* Custom speed */
  369. unsigned long event;
  370. unsigned long last_active;
  371. int line;
  372. int count;
  373. int blocked_open;
  374. long session;
  375. long pgrp;
  376. struct tq_struct tqueue;
  377. struct tq_struct tqueue_hangup;
  378. struct async_icount icount;
  379. struct termios normal_termios;
  380. struct termios callout_termios;
  381. wait_queue_head_t open_wait;
  382. wait_queue_head_t close_wait;
  383. wait_queue_head_t delta_msr_wait;
  384. wait_queue_head_t read_wait;
  385. wait_queue_head_t write_wait;
  386.   
  387.   /*
  388.    * Pointer to FIFO access routines.  These are individualized
  389.    *  by hardware because different hardware may have different
  390.    *  ways to get to the FIFOs.
  391.    */
  392.   
  393. void (*readfifo)(struct sab_port *port, 
  394.     unsigned char *buf,
  395.     u32 nbytes);
  396. void (*writefifo)(struct sab_port *port);
  397.   
  398.   /*
  399.    * Pointer to register access routines.  These are individualized
  400.    *  by hardware because different hardware may have different
  401.    *  ways to get to the register.
  402.    */
  403. unsigned char (*readbyte)(struct sab_port *port, 
  404.     unsigned char *reg);
  405. void          (*writebyte)(struct sab_port *port, 
  406.      unsigned char *reg,
  407.      unsigned char val);
  408. u16 (*readword)(struct sab_port *port, 
  409.     u16 *reg);
  410. void          (*writeword)(struct sab_port *port, 
  411.      u16 *reg,
  412.      u16 val);
  413.   
  414.   /*
  415.    * Pointer to protocol functions
  416.    *
  417.    */
  418.   
  419. unsigned int portno;
  420. void (*receive_chars)(struct sab_port *port, 
  421.       union sab8253x_irq_status *stat);
  422. void (*transmit_chars)(struct sab_port *port,
  423.        union sab8253x_irq_status *stat);
  424. void (*check_status)(struct sab_port *port,
  425.      union sab8253x_irq_status *stat);
  426. unsigned int receive_test;
  427. unsigned int transmit_test;
  428. unsigned int check_status_test;
  429. struct channelcontrol ccontrol;
  430. unsigned int tx_full;
  431. unsigned int rx_empty;
  432. struct counters Counters;
  433. struct net_device_stats stats;
  434. /* collect statistics for netstat */
  435. /* etc.  those programs don't know */
  436. /* about priorities*/
  437. int msgbufindex;
  438. char msgbuf[RXSIZE];
  439. unsigned int buffergreedy;
  440. unsigned int sigmode;
  441. } sab_port_t, SAB_PORT;
  442. /*
  443.  * per-parallel port structure
  444.  */
  445. /* SAB82538 4 8-bits parallel ports
  446.  * To summarize the use of the parallel port:
  447.  *                    RS-232
  448.  * Parallel port A -- TxClkdir control (output) ports 0 - 7
  449.  * Parallel port B -- DTR (output) ports 0 - 7
  450.  * Parallel port C -- DSR (input)  ports 0 - 7
  451.  * Parallel port D -- driver power down (output) drivers 0 - 3
  452.  *
  453.  * SAB82532 (Aurora) 1 8-bit parallel port
  454.  * To summarize the use of the parallel port:
  455.  *                    RS-232
  456.  *  A       B        I/O     descr
  457.  * P0      P4      output  TxClk ctrl
  458.  * P1      P5      output  DTR
  459.  * P2      P6      input   DSR
  460.  * P3      P7      output  485 control
  461.  *
  462.  * Note that this new version of the driver
  463.  * does not support the SPARC motherboard ESCC2
  464.  *
  465.  * SAB82532 (Sun) 1 8-bit parallel port
  466.  * To summarize the use of the parallel port:
  467.  *                    RS-232
  468.  *  A       B        I/O     descr
  469.  * P0      P3      input    DSR
  470.  * P1      P2      output    DTR
  471.  * P5      P6      input     ?
  472.  * P4      P7      output    ?
  473.  *
  474.  */
  475. /* not sure how usefule */
  476. typedef struct sabparport 
  477. {
  478.   /* cached values: */
  479. unsigned char  pp_pcr;
  480. unsigned char  pp_pim;
  481. unsigned char  pp_pvr;
  482. /* register offsets: */
  483. unsigned int  pp_pcrreg;
  484. unsigned int  pp_pimreg;
  485. unsigned int  pp_pisreg;
  486. unsigned int  pp_pvrreg;
  487. } sabparport_t, SABPARPORT;
  488. #define ESCC2 2
  489. #define ESCC8 8
  490. /*
  491.  * Per-chip structure
  492.  */
  493. typedef struct sab_chip 
  494. {
  495. unsigned int chip_type;
  496. struct sab_board *c_board; /* Parent board */
  497. struct aura_cim *c_cim; /* if present */
  498. unsigned char c_chipno; /* chip number */
  499. unsigned char   c_revision; /* the revision code from the VSTR */
  500. unsigned char          c_nports; /* number of ports per chip */
  501. void  *c_regs; /* base address for chip registers */
  502. struct sab_port *c_portbase;
  503. struct sab_chip        *next;          /* the next chip in the chip chain */
  504. struct sab_chip        *next_by_board;    /* the next chip on the board */
  505. struct sab_chip *next_by_cim;
  506. void  (*int_disable)(struct sab_chip* chip);
  507. } sab_chip_t, SAB_CHIP;
  508. /* Some useful facts */
  509. #define SAB82532_REG_SIZE               0x40
  510. #define SAB82538_REG_SIZE               0x40
  511. /* RFIFO Status Byte */
  512. #define SAB82532_RSTAT_PE 0x80
  513. #define SAB82532_RSTAT_FE 0x40
  514. #define SAB82532_RSTAT_PARITY 0x01
  515. /* Status Register (STAR) */
  516. #define SAB82532_STAR_XDOV 0x80
  517. #define SAB82532_STAR_XFW 0x40
  518. #define SAB82532_STAR_RFNE 0x20
  519. #define SAB82532_STAR_FCS 0x10
  520. #define SAB82532_STAR_TEC 0x08
  521. #define SAB82532_STAR_RLI 0x08
  522. #define SAB82532_STAR_CEC 0x04
  523. #define SAB82532_STAR_CTS 0x02
  524. /* Command Register (CMDR) */
  525. #define SAB82532_CMDR_RMC 0x80
  526. #define SAB82532_CMDR_RRES 0x40
  527. #define SAB82532_CMDR_RHR 0x40
  528. #define SAB82532_CMDR_RFRD 0x20
  529. #define SAB82532_CMDR_STI 0x10
  530. #define SAB82532_CMDR_XF 0x08
  531. #define SAB82532_CMDR_XTF 0x08
  532. #define SAB82532_CMDR_XME 0x02
  533. #define SAB82532_CMDR_XRES 0x01
  534. /* leaving them for reference */
  535. /* they are now defined in 8253xioc.h*/
  536. #if 0
  537. /* Mode Register (MODE) */
  538. #define SAB82532_MODE_TM0 0x80
  539. #define SAB82532_MODE_FRTS 0x40
  540. #define SAB82532_MODE_FCTS 0x20
  541. #define SAB82532_MODE_FLON 0x10
  542. #define SAB82532_MODE_TCPU 0x10
  543. #define SAB82532_MODE_RAC 0x08
  544. #define SAB82532_MODE_RTS 0x04
  545. #define SAB82532_MODE_TRS 0x02
  546. #define SAB82532_MODE_TLP 0x01
  547. #endif
  548. /* Receive Status Register (READ)  */
  549. #define SAB82532_RSTA_VFR 0x80
  550. #define SAB82532_RSTA_RDO 0x40
  551. #define SAB82532_RSTA_CRC 0x20
  552. #define SAB82532_RSTA_RAB 0x10
  553. /* Timer Register (TIMR) */
  554. #define SAB82532_TIMR_CNT_MASK 0xe0
  555. #define SAB82532_TIMR_VALUE_MASK 0x1f
  556. /* Data Format (DAFO) */
  557. #define SAB82532_DAFO_XBRK 0x40
  558. #define SAB82532_DAFO_STOP 0x20
  559. #define SAB82532_DAFO_PAR_SPACE 0x00
  560. #define SAB82532_DAFO_PAR_ODD 0x08
  561. #define SAB82532_DAFO_PAR_EVEN 0x10
  562. #define SAB82532_DAFO_PAR_MARK 0x18
  563. #define SAB82532_DAFO_PARE 0x04
  564. #define SAB82532_DAFO_CHL8 0x00
  565. #define SAB82532_DAFO_CHL7 0x01
  566. #define SAB82532_DAFO_CHL6 0x02
  567. #define SAB82532_DAFO_CHL5 0x03
  568. /* RFIFO Control Register (RFC) */
  569. #define SAB82532_RFC_DPS 0x40
  570. #define SAB82532_RFC_DXS 0x20
  571. #define SAB82532_RFC_RFDF 0x10
  572. #define SAB82532_RFC_RFTH_1 0x00
  573. #define SAB82532_RFC_RFTH_4 0x04
  574. #define SAB82532_RFC_RFTH_16 0x08
  575. #define SAB82532_RFC_RFTH_32 0x0c
  576. #define SAB82532_RFC_TCDE 0x01
  577. /* Received Byte Count High (RBCH) */
  578. #define SAB82532_RBCH_DMA 0x80
  579. #define SAB82532_RBCH_CAS 0x20
  580. #define SAB82532_RBCH_OV 0x10
  581. #define SAB82532_RBCH_HMSK 0x0F
  582. /* Transmit Byte Count High (XBCH) */
  583. #define SAB82532_XBCH_DMA 0x80
  584. #define SAB82532_XBCH_CAS 0x20
  585. #define SAB82532_XBCH_XC 0x10
  586. /* leaving them for reference */
  587. /* they are now defined in 8253xioc.h*/
  588. #if 0
  589. /* Channel Configuration Register 0 (CCR0) */
  590. #define SAB82532_CCR0_PU 0x80
  591. #define SAB82532_CCR0_MCE 0x40
  592. #define SAB82532_CCR0_SC_NRZ 0x00
  593. #define SAB82532_CCR0_SC_NRZI 0x08
  594. #define SAB82532_CCR0_SC_FM0 0x10
  595. #define SAB82532_CCR0_SC_FM1 0x14
  596. #define SAB82532_CCR0_SC_MANCH 0x18
  597. #define SAB82532_CCR0_SM_HDLC 0x00
  598. #define SAB82532_CCR0_SM_SDLC_LOOP 0x01
  599. #define SAB82532_CCR0_SM_BISYNC 0x02
  600. #define SAB82532_CCR0_SM_ASYNC 0x03
  601. /* Channel Configuration Register 1 (CCR1) */
  602. #define SAB82532_CCR1_SFLG 0x80
  603. #define SAB82532_CCR1_ODS 0x10
  604. #define SAB82532_CCR1_BCR 0x08
  605. #define SAB82532_CCR1_IFF 0x08
  606. #define SAB82532_CCR1_ITF 0x00
  607. #define SAB82532_CCR1_CM_MASK 0x07
  608. /* Channel Configuration Register 2 (CCR2) */
  609. #define SAB82532_CCR2_SOC1 0x80
  610. #define SAB82532_CCR2_SOC0 0x40
  611. #define SAB82532_CCR2_BR9 0x80
  612. #define SAB82532_CCR2_BR8 0x40
  613. #define SAB82532_CCR2_BDF 0x20
  614. #define SAB82532_CCR2_SSEL 0x10
  615. #define SAB82532_CCR2_XCS0 0x20
  616. #define SAB82532_CCR2_RCS0 0x10
  617. #define SAB82532_CCR2_TOE 0x08
  618. #define SAB82532_CCR2_RWX 0x04
  619. #define SAB82532_CCR2_C32 0x02
  620. #define SAB82532_CCR2_DIV 0x01
  621. /* Channel Configuration Register 3 (CCR3) */
  622. #define SAB82532_CCR3_PSD 0x01
  623. #define SAB82532_CCR3_RCRC 0x04
  624. #endif
  625. /* Time Slot Assignment Register Transmit (TSAX) */
  626. #define SAB82532_TSAX_TSNX_MASK 0xfc
  627. #define SAB82532_TSAX_XCS2 0x02 /* see also CCR2 */
  628. #define SAB82532_TSAX_XCS1 0x01
  629. /* Time Slot Assignment Register Receive (TSAR) */
  630. #define SAB82532_TSAR_TSNR_MASK 0xfc
  631. #define SAB82532_TSAR_RCS2 0x02 /* see also CCR2 */
  632. #define SAB82532_TSAR_RCS1 0x01
  633. /* Version Status Register (VSTR) */
  634. #define SAB85232_REG_VSTR               0x34
  635. #define SAB82532_VSTR_CD 0x80
  636. #define SAB82532_VSTR_DPLA 0x40
  637. #define SAB82532_VSTR_VN_MASK 0x0f
  638. #define SAB82532_VSTR_VN_1 0x00
  639. #define SAB82532_VSTR_VN_2 0x01
  640. #define SAB82532_VSTR_VN_3_2 0x02
  641. /* Global Interrupt Status Register (GIS) */
  642. #define SAB82532_GIS_PI 0x80
  643. #define SAB82532_GIS_ISA1 0x08
  644. #define SAB82532_GIS_ISA0 0x04
  645. #define SAB82532_GIS_ISB1 0x02
  646. #define SAB82532_GIS_ISB0 0x01
  647. #define SAB82532_GIS_MASK 0x8f 
  648. #define SAB82538_GIS_PIA 0x80
  649. #define SAB82538_GIS_PIB 0x40
  650. #define SAB82538_GIS_PIC 0x20
  651. #define SAB82538_GIS_PID 0x10
  652. #define SAB82538_GIS_CII 0x08
  653. #define SAB82538_GIS_CHNL_MASK          0x07
  654. #define SAB82538_GIS_MASK 0x28  /* Port C and CII ! */ 
  655. /* Interrupt Vector Address (IVA) */
  656. #define SAB82532_REG_IVA                0x38
  657. #define SAB82532_IVA_MASK 0xf1
  658. #define SAB82538_IVA_ROT                0x02
  659. /* Interrupt Port Configuration (IPC) */
  660. #define SAB82532_REG_IPC                0x39
  661. #define SAB82532_IPC_VIS 0x80
  662. #define SAB82532_IPC_SLA1 0x10
  663. #define SAB82532_IPC_SLA0 0x08
  664. #define SAB82532_IPC_CASM 0x04
  665. #define SAB82532_IPC_IC_OPEN_DRAIN 0x00
  666. #define SAB82532_IPC_IC_ACT_LOW 0x01
  667. #define SAB82532_IPC_IC_ACT_HIGH 0x03
  668. /* Interrupt Status Register 0 (ISR0) */
  669. #define SAB82532_ISR0_TCD 0x80
  670. #define SAB82532_ISR0_RME 0x80
  671. #define SAB82532_ISR0_TIME 0x40
  672. #define SAB82532_ISR0_RFS 0x40
  673. #define SAB82532_ISR0_PERR 0x20
  674. #define SAB82532_ISR0_FERR 0x10
  675. #define SAB82532_ISR0_PLLA 0x08
  676. #define SAB82532_ISR0_CDSC 0x04
  677. #define SAB82532_ISR0_RFO 0x02
  678. #define SAB82532_ISR0_RPF 0x01
  679. /* Interrupt Status Register 1 (ISR1) */
  680. #define SAB82532_ISR1_BRK 0x80
  681. #define SAB82532_ISR1_BRKT 0x40
  682. #define SAB82532_ISR1_RDO 0x40
  683. #define SAB82532_ISR1_ALLS 0x20
  684. #define SAB82532_ISR1_XOFF 0x10
  685. #define SAB82532_ISR1_XDU 0x10
  686. #define SAB82532_ISR1_TIN 0x08
  687. #define SAB82532_ISR1_CSC 0x04
  688. #define SAB82532_ISR1_XON 0x02
  689. #define SAB82532_ISR1_XPR 0x01
  690. /* Interrupt Mask Register 0 (IMR0) */
  691. #define SAB82532_IMR0_TCD 0x80
  692. #define SAB82532_IMR0_RME 0x80
  693. #define SAB82532_IMR0_TIME 0x40
  694. #define SAB82532_IMR0_RFS 0x40
  695. #define SAB82532_IMR0_PERR 0x20
  696. #define SAB82532_IMR0_RSC 0x20
  697. #define SAB82532_IMR0_FERR 0x10
  698. #define SAB82532_IMR0_PCE 0x10
  699. #define SAB82532_IMR0_PLLA 0x08
  700. #define SAB82532_IMR0_CDSC 0x04
  701. #define SAB82532_IMR0_RFO 0x02
  702. #define SAB82532_IMR0_RPF 0x01
  703. /* Interrupt Mask Register 1 (IMR1) */
  704. #define SAB82532_IMR1_BRK 0x80
  705. #define SAB82532_IMR1_EOP 0x80
  706. #define SAB82532_IMR1_BRKT 0x40
  707. #define SAB82532_IMR1_RDO 0x40
  708. #define SAB82532_IMR1_ALLS 0x20
  709. #define SAB82532_IMR1_XOFF 0x10
  710. #define SAB82532_IMR1_EXE 0x10
  711. #define SAB82532_IMR1_TIN 0x08
  712. #define SAB82532_IMR1_CSC 0x04
  713. #define SAB82532_IMR1_XON 0x02
  714. #define SAB82532_IMR1_XMR 0x02
  715. #define SAB82532_IMR1_XPR 0x01
  716. /* Port Value Register (PVR) */
  717. #define SAB82532_REG_PVR                 0x3c
  718. #define SAB82538_REG_PVR_A               0x3c
  719. #define SAB82538_REG_PVR_B               0xbc
  720. #define SAB82538_REG_PVR_C               0x13c
  721. #define SAB82538_REG_PVR_D               0x1bc
  722. /* Port Value Register (PIM) */
  723. #define SAB82532_REG_PIM                 0x3d
  724. #define SAB82538_REG_PIM_A               0x3d
  725. #define SAB82538_REG_PIM_B               0xbd
  726. #define SAB82538_REG_PIM_C               0x13d
  727. #define SAB82538_REG_PIM_D               0x1bd
  728. /* Port Value Register (PIS) */
  729. #define SAB82532_REG_PIS                 0x3d
  730. #define SAB82538_REG_PIS_A               0x3d
  731. #define SAB82538_REG_PIS_B               0xbd
  732. #define SAB82538_REG_PIS_C               0x13d
  733. #define SAB82538_REG_PIS_D               0x1bd
  734. /* Port Value Register (PCR) */
  735. #define SAB82532_REG_PCR                 0x3e
  736. #define SAB82538_REG_PCR_A               0x3e
  737. #define SAB82538_REG_PCR_B               0xbe
  738. #define SAB82538_REG_PCR_C               0x13e
  739. #define SAB82538_REG_PCR_D               0x1be
  740. /* leaving them for reference */
  741. /* they are now defined in 8253xioc.h*/
  742. #if 0
  743. /* Channel Configuration Register 4 (CCR4) */
  744. #define SAB82532_CCR4_MCK4 0x80/* needs to be set when board clock */
  745.     /* over 10 Mhz (?)*/
  746. #define SAB82532_CCR4_EBRG 0x40
  747. #define SAB82532_CCR4_TST1 0x20
  748. #define SAB82532_CCR4_ICD 0x10
  749. #endif
  750. /* Port Interrupt Status Register (PIS) */
  751. #define SAB82532_PIS_SYNC_B 0x08
  752. #define SAB82532_PIS_DTR_B 0x04
  753. #define SAB82532_PIS_DTR_A 0x02
  754. #define SAB82532_PIS_SYNC_A 0x01
  755. /* More things useful */
  756. #define SAB_MAGIC 5977
  757. /* When computing the baudrate, we "encode" it by multiplying
  758.  * the actual baudrate by 2. This way we can use 134.5
  759.  */
  760. #define ENCODEBR(x)  ((x)<<1)
  761. /*
  762.  * Raise a modem signal y on port x, tmpval must exist! */
  763. #define RAISE(xx,y) 
  764.   unsigned char __tmpval__; 
  765.   __tmpval__= (xx)->readbyte((xx),(xx)->y.reg);
  766.   if((xx)->y.inverted)
  767.     __tmpval__ &= ~((xx)->y.mask);
  768.   else
  769.     __tmpval__ |= (xx)->y.mask;
  770.   __tmpval__ |= (xx)->y.cnst;
  771.   (xx)->y.val=1;
  772.   (xx)->writebyte((xx),(xx)->y.reg,__tmpval__);
  773. }
  774. /*
  775.  * Lower a modem signal y on port x, __tmpval__ must exist! */
  776. #define LOWER(xx,y) 
  777. {
  778.   unsigned char __tmpval__; 
  779.   __tmpval__= (xx)->readbyte((xx),(xx)->y.reg);
  780.   if((xx)->y.inverted)
  781.     __tmpval__ |= (xx)->y.mask;
  782.   else
  783.     __tmpval__ &= ~((xx)->y.mask);
  784.   __tmpval__ |= (xx)->y.cnst;
  785.   (xx)->y.val=0;
  786.   (xx)->writebyte((xx),(xx)->y.reg,__tmpval__);
  787. }
  788. #define ISON(xx,y) 
  789.           ((xx)->y.inverted != (((xx)->readbyte((xx),(xx)->y.reg)&(xx)->y.mask) ==(xx)->y.mask) )
  790. /*
  791.  * Now let's define all those functions we need else where.
  792.  *
  793.  * This should probably be reorganized
  794.  */
  795. extern void sab8253x_setup_ttydriver(void);
  796. extern int finish_sab8253x_setup_ttydriver(void);
  797. extern void sab8253x_setup_ttyport(struct sab_port *port);
  798. extern void sab8253x_cleanup_ttydriver(void);
  799. extern void sab8253x_start_txS(struct sab_port *port);
  800. static int inline sab8253x_serial_paranoia_check(struct sab_port *port,
  801.  kdev_t device, const char *routine)
  802. {
  803. #ifdef SERIAL_PARANOIA_CHECK
  804. static const char *badmagic =
  805. "Warning: bad magic number for serial struct (%s) in %sn";
  806. static const char *badinfo =
  807. "Warning: null sab8253x for (%s) in %sn";
  808. if (!port) 
  809. {
  810. printk(badinfo, kdevname(device), routine);
  811. return 1;
  812. }
  813. if (port->magic != SAB_MAGIC) 
  814. {
  815. printk(badmagic, kdevname(device), routine);
  816. return 1;
  817. }
  818. #endif
  819. return 0;
  820. }
  821. static void inline sab8253x_cec_wait(struct sab_port *port)
  822. {
  823. int timeout = port->cec_timeout;
  824. #if 1 /* seems to work for 82532s */
  825. while ((READB(port, star) & SAB82532_STAR_CEC) && --timeout)
  826. {
  827. udelay(1);
  828. }
  829. #else
  830. if (READB(port,star) & SAB82532_STAR_CEC)
  831. {
  832. udelay(1);
  833. }
  834. #endif
  835. }
  836. extern void sab8253x_transmit_charsS(struct sab_port *port, union sab8253x_irq_status *stat);
  837. extern void sab8253x_flush_charsS(struct tty_struct *tty);
  838. extern void sab8253x_set_termiosS(struct tty_struct *tty, struct termios *old_termios);
  839. extern void sab8253x_stopS(struct tty_struct *tty);
  840. extern void sab8253x_startS(struct tty_struct *tty);
  841. extern void sab8253x_send_xcharS(struct tty_struct *tty, char ch);
  842. extern void sab8253x_transmit_charsN(struct sab_port *port,
  843.      union sab8253x_irq_status *stat);
  844. extern SAB_PORT  *AuraPortRoot;
  845. #define MAX_SAB8253X_RCV_QUEUE_LEN 50
  846. struct ebrg_struct 
  847. {
  848. int baud;
  849. int n;
  850. int m;
  851. };
  852. extern task_queue tq_8253x_serial;
  853. extern int sab8253x_openS(struct tty_struct *tty, struct file * filp);
  854. extern void sab8253x_closeS(struct tty_struct *tty, struct file * filp);
  855. extern int sab8253x_writeS(struct tty_struct * tty, int from_user,
  856.    const unsigned char *buf, int count);
  857. extern void sab8253x_throttleS(struct tty_struct * tty);
  858. extern void sab8253x_unthrottleS(struct tty_struct * tty);
  859. extern void sab8253x_hangupS(struct tty_struct *tty);
  860. extern void sab8253x_breakS(struct tty_struct *tty, int break_state);
  861. extern void Sab8253xCleanUpTransceiveN(SAB_PORT* priv);
  862. /* used for running routines in the */
  863. /* soft int part of the driver */
  864. /* at one time the flip buffer routines */
  865. /* seem to have been too time consuming */
  866. /* to invoke in the hardware interrupt */
  867. /* routing -- I am not so sure there is */
  868. /* a problem with modern processor and */
  869. /* memory speeds, but maybe there is a */
  870. /* requirement that certain tty routines */
  871. /* not be executed with ints turned off.*/
  872. static void inline sab8253x_sched_event(struct sab_port *port, int event)
  873. {
  874. port->event |= 1 << event;
  875. queue_task(&port->tqueue, &tq_8253x_serial);
  876. mark_bh(AURORA_BH);
  877. }
  878. extern unsigned int 
  879. sab8253x_baud(sab_port_t *port, unsigned long encbaud,
  880.       unsigned char *bgr, unsigned char *ccr2,
  881.       unsigned char *ccr4, unsigned long *truebaudp);
  882. extern void Sab8253xFreeAllReceiveListSKBUFFS(SAB_PORT* priv);
  883. extern int Sab8253xSetUpLists(SAB_PORT *priv);
  884. extern int Sab8253xCountTransmitDescriptors(SAB_PORT *port);
  885. extern int Sab8253xCountTransmit(SAB_PORT *port);
  886. extern void sab8253x_init_lineS(struct sab_port *port);
  887. extern void sab8253x_init_lineS(struct sab_port *port);
  888. extern int getccr2configS(struct sab_port *port);
  889. extern void sab8253x_change_speedN(struct sab_port *port);
  890. extern void sab8253x_shutdownN(struct sab_port *port);
  891. extern int sab8253x_startupN(struct sab_port *port);
  892. extern int sab8253x_block_til_ready(struct tty_struct *tty, struct file * filp,
  893.     struct sab_port *port);
  894. extern void sab8253x_wait_until_sent(struct tty_struct *tty, int timeout);
  895. extern void sab8253x_flush_buffer(struct tty_struct *tty);
  896. extern void aura_sp502_program(SAB_PORT *port, unsigned int index);
  897. #endif