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