aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ubicom32/files/arch/ubicom32/include/asm/uart_tio.h
blob: 19ef82efa62eaf132949c43bd0d80eb5d9af5dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * arch/ubicom32/include/asm/uart_tio.h
 *   Ubicom32 architecture UART TIO definitions.
 *
 * (C) Copyright 2009, Ubicom, Inc.
 *
 * This file is part of the Ubicom32 Linux Kernel Port.
 *
 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, either version 2 of the
 * License, or (at your option) any later version.
 *
 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 * the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Ubicom32 Linux Kernel Port.  If not,
 * see <http://www.gnu.org/licenses/>.
 */
#ifndef _ASM_UBICOM32_UART_TIO_H
#define _ASM_UBICOM32_UART_TIO_H

#include <asm/devtree.h>

#define UARTTIO_RX_FIFO_SIZE		16
#define UARTTIO_TX_FIFO_SIZE		16

/*
 * Interrupt flags
 */
#define UARTTIO_UART_INT_RX		0x00000001	// set when a character has been recevied (TODO: add watermark)
#define UARTTIO_UART_INT_RXOVF		0x00000002	// set when the receive buffer has overflowed
#define UARTTIO_UART_INT_RXFRAME	0x00000004	// set when there has been a framing error

#define UARTTIO_UART_INT_TX		0x00000100	// set every time a character is transmitted
#define UARTTIO_UART_INT_TXBE		0x00000200	// set when the transmit buffer is empty (TODO: add watermark)

#define UARTTIO_UART_FLAG_ENABLED	0x80000000
#define UARTTIO_UART_FLAG_SET_RATE      0x00000001      // set to update baud rate
#define UARTTIO_UART_FLAG_RESET         0x00000002      // set to reset the port
struct uarttio_uart {
	volatile u32_t			flags;

	volatile u32_t			baud_rate;
	volatile u32_t			current_baud_rate;
	u32_t				bit_time;

	/*
	 * Modem status register
	 */
	volatile u32_t			status;

	/*
	 * Interrupt registers
	 */
	volatile u32_t			int_mask;
	volatile u32_t			int_flags;

	/*
	 * Ports and pins
	 */
	u32_t				rx_port;
	u32_t				tx_port;

	u8_t				rx_pin;
	u8_t				tx_pin;

	/*
	 * Configuration Data
	 */
	u8_t				rx_bits;
	u8_t				rx_stop_bits;
	u8_t				tx_bits;
	u8_t				tx_stop_bits;

	/*
	 * RX state machine data
	 */
	u32_t				rx_timer;
	u32_t				rx_bit_pos;
	u32_t				rx_byte;
	u32_t				rx_fifo_head;
	u32_t				rx_fifo_tail;
	u32_t				rx_fifo_size;

	/*
	 * TX state machine data
	 */
	u32_t				tx_timer;
	u32_t				tx_bit_pos;
	u32_t				tx_byte;
	u32_t				tx_fifo_head;
	u32_t				tx_fifo_tail;
	u32_t				tx_fifo_size;

	/*
	 * FIFOs
	 */
	u8_t				rx_fifo[UARTTIO_RX_FIFO_SIZE];
	u8_t				tx_fifo[UARTTIO_TX_FIFO_SIZE];
};

#define UARTTIO_VP_VERSION		1
struct uarttio_regs {
	u32_t				version;

	u32_t				thread;

	u32_t				max_uarts;

	struct uarttio_uart		uarts[0];
};

#define UARTTIO_NODE_VERSION		1
struct uarttio_node {
	struct devtree_node		dn;

	u32_t				version;
	struct uarttio_regs		*regs;
	u32_t				regs_sz;
};

#endif /* _ASM_UBICOM32_UART_TIO_H */