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