crisv10.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * serial.h: Arch-dep definitions for the Etrax100 serial driver.
  3. *
  4. * Copyright (C) 1998-2007 Axis Communications AB
  5. */
  6. #ifndef _ETRAX_SERIAL_H
  7. #define _ETRAX_SERIAL_H
  8. #include <linux/circ_buf.h>
  9. #include <asm/termios.h>
  10. #include <asm/dma.h>
  11. #include <arch/io_interface_mux.h>
  12. /* Software state per channel */
  13. #ifdef __KERNEL__
  14. /*
  15. * This is our internal structure for each serial port's state.
  16. *
  17. * Many fields are paralleled by the structure used by the serial_struct
  18. * structure.
  19. *
  20. * For definitions of the flags field, see tty.h
  21. */
  22. #define SERIAL_RECV_DESCRIPTORS 8
  23. struct etrax_recv_buffer {
  24. struct etrax_recv_buffer *next;
  25. unsigned short length;
  26. unsigned char error;
  27. unsigned char pad;
  28. unsigned char buffer[0];
  29. };
  30. struct e100_serial {
  31. struct tty_port port;
  32. int baud;
  33. volatile u8 *ioport; /* R_SERIALx_CTRL */
  34. u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */
  35. /* Output registers */
  36. volatile u8 *oclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
  37. volatile u32 *ofirstadr; /* adr to R_DMA_CHx_FIRST */
  38. volatile u8 *ocmdadr; /* adr to R_DMA_CHx_CMD */
  39. const volatile u8 *ostatusadr; /* adr to R_DMA_CHx_STATUS */
  40. /* Input registers */
  41. volatile u8 *iclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
  42. volatile u32 *ifirstadr; /* adr to R_DMA_CHx_FIRST */
  43. volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */
  44. volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */
  45. int flags; /* defined in tty.h */
  46. u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */
  47. u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */
  48. u8 iseteop; /* bit number for R_SET_EOP for the input dma */
  49. int enabled; /* Set to 1 if the port is enabled in HW config */
  50. u8 dma_out_enabled; /* Set to 1 if DMA should be used */
  51. u8 dma_in_enabled; /* Set to 1 if DMA should be used */
  52. /* end of fields defined in rs_table[] in .c-file */
  53. int dma_owner;
  54. unsigned int dma_in_nbr;
  55. unsigned int dma_out_nbr;
  56. unsigned int dma_in_irq_nbr;
  57. unsigned int dma_out_irq_nbr;
  58. unsigned long dma_in_irq_flags;
  59. unsigned long dma_out_irq_flags;
  60. char *dma_in_irq_description;
  61. char *dma_out_irq_description;
  62. enum cris_io_interface io_if;
  63. char *io_if_description;
  64. u8 uses_dma_in; /* Set to 1 if DMA is used */
  65. u8 uses_dma_out; /* Set to 1 if DMA is used */
  66. u8 forced_eop; /* a fifo eop has been forced */
  67. int baud_base; /* For special baudrates */
  68. int custom_divisor; /* For special baudrates */
  69. struct etrax_dma_descr tr_descr;
  70. struct etrax_dma_descr rec_descr[SERIAL_RECV_DESCRIPTORS];
  71. int cur_rec_descr;
  72. volatile int tr_running; /* 1 if output is running */
  73. struct tty_struct *tty;
  74. int read_status_mask;
  75. int ignore_status_mask;
  76. int x_char; /* xon/xoff character */
  77. int close_delay;
  78. unsigned short closing_wait;
  79. unsigned short closing_wait2;
  80. unsigned long event;
  81. unsigned long last_active;
  82. int line;
  83. int type; /* PORT_ETRAX */
  84. int count; /* # of fd on device */
  85. int blocked_open; /* # of blocked opens */
  86. struct circ_buf xmit;
  87. struct etrax_recv_buffer *first_recv_buffer;
  88. struct etrax_recv_buffer *last_recv_buffer;
  89. unsigned int recv_cnt;
  90. unsigned int max_recv_cnt;
  91. struct work_struct work;
  92. struct async_icount icount; /* error-statistics etc.*/
  93. struct ktermios normal_termios;
  94. struct ktermios callout_termios;
  95. wait_queue_head_t open_wait;
  96. wait_queue_head_t close_wait;
  97. unsigned long char_time_usec; /* The time for 1 char, in usecs */
  98. unsigned long flush_time_usec; /* How often we should flush */
  99. unsigned long last_tx_active_usec; /* Last tx usec in the jiffies */
  100. unsigned long last_tx_active; /* Last tx time in jiffies */
  101. unsigned long last_rx_active_usec; /* Last rx usec in the jiffies */
  102. unsigned long last_rx_active; /* Last rx time in jiffies */
  103. int break_detected_cnt;
  104. int errorcode;
  105. #ifdef CONFIG_ETRAX_RS485
  106. struct serial_rs485 rs485; /* RS-485 support */
  107. #endif
  108. };
  109. /* this PORT is not in the standard serial.h. it's not actually used for
  110. * anything since we only have one type of async serial-port anyway in this
  111. * system.
  112. */
  113. #define PORT_ETRAX 1
  114. /*
  115. * Events are used to schedule things to happen at timer-interrupt
  116. * time, instead of at rs interrupt time.
  117. */
  118. #define RS_EVENT_WRITE_WAKEUP 0
  119. #endif /* __KERNEL__ */
  120. #endif /* !_ETRAX_SERIAL_H */