move new files out from platform support patch
[lede.git] / target / linux / ubicom32 / files / arch / ubicom32 / include / asm / uart_tio.h
1 /*
2  * arch/ubicom32/include/asm/uart_tio.h
3  *   Ubicom32 architecture UART TIO definitions.
4  *
5  * (C) Copyright 2009, Ubicom, Inc.
6  *
7  * This file is part of the Ubicom32 Linux Kernel Port.
8  *
9  * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10  * it and/or modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation, either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
17  * the GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with the Ubicom32 Linux Kernel Port.  If not,
21  * see <http://www.gnu.org/licenses/>.
22  */
23 #ifndef _ASM_UBICOM32_UART_TIO_H
24 #define _ASM_UBICOM32_UART_TIO_H
25
26 #include <asm/devtree.h>
27
28 #define UARTTIO_RX_FIFO_SIZE            16
29 #define UARTTIO_TX_FIFO_SIZE            16
30
31 /*
32  * Interrupt flags
33  */
34 #define UARTTIO_UART_INT_RX             0x00000001      // set when a character has been recevied (TODO: add watermark)
35 #define UARTTIO_UART_INT_RXOVF          0x00000002      // set when the receive buffer has overflowed
36 #define UARTTIO_UART_INT_RXFRAME        0x00000004      // set when there has been a framing error
37
38 #define UARTTIO_UART_INT_TX             0x00000100      // set every time a character is transmitted
39 #define UARTTIO_UART_INT_TXBE           0x00000200      // set when the transmit buffer is empty (TODO: add watermark)
40
41 #define UARTTIO_UART_FLAG_ENABLED       0x80000000
42 #define UARTTIO_UART_FLAG_SET_RATE      0x00000001      // set to update baud rate
43 #define UARTTIO_UART_FLAG_RESET         0x00000002      // set to reset the port
44 struct uarttio_uart {
45         volatile u32_t                  flags;
46
47         volatile u32_t                  baud_rate;
48         volatile u32_t                  current_baud_rate;
49         u32_t                           bit_time;
50
51         /*
52          * Modem status register
53          */
54         volatile u32_t                  status;
55
56         /*
57          * Interrupt registers
58          */
59         volatile u32_t                  int_mask;
60         volatile u32_t                  int_flags;
61
62         /*
63          * Ports and pins
64          */
65         u32_t                           rx_port;
66         u32_t                           tx_port;
67
68         u8_t                            rx_pin;
69         u8_t                            tx_pin;
70
71         /*
72          * Configuration Data
73          */
74         u8_t                            rx_bits;
75         u8_t                            rx_stop_bits;
76         u8_t                            tx_bits;
77         u8_t                            tx_stop_bits;
78
79         /*
80          * RX state machine data
81          */
82         u32_t                           rx_timer;
83         u32_t                           rx_bit_pos;
84         u32_t                           rx_byte;
85         u32_t                           rx_fifo_head;
86         u32_t                           rx_fifo_tail;
87         u32_t                           rx_fifo_size;
88
89         /*
90          * TX state machine data
91          */
92         u32_t                           tx_timer;
93         u32_t                           tx_bit_pos;
94         u32_t                           tx_byte;
95         u32_t                           tx_fifo_head;
96         u32_t                           tx_fifo_tail;
97         u32_t                           tx_fifo_size;
98
99         /*
100          * FIFOs
101          */
102         u8_t                            rx_fifo[UARTTIO_RX_FIFO_SIZE];
103         u8_t                            tx_fifo[UARTTIO_TX_FIFO_SIZE];
104 };
105
106 #define UARTTIO_VP_VERSION              1
107 struct uarttio_regs {
108         u32_t                           version;
109
110         u32_t                           thread;
111
112         u32_t                           max_uarts;
113
114         struct uarttio_uart             uarts[0];
115 };
116
117 #define UARTTIO_NODE_VERSION            1
118 struct uarttio_node {
119         struct devtree_node             dn;
120
121         u32_t                           version;
122         struct uarttio_regs             *regs;
123         u32_t                           regs_sz;
124 };
125
126 #endif /* _ASM_UBICOM32_UART_TIO_H */