1 | /* |
---|
2 | * Generic UART Serial driver for Motorola Coldfire processors definitions |
---|
3 | * |
---|
4 | * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russian Fed. |
---|
5 | * Author: Victor V. Vengerov <vvv@oktet.ru> |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.org/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef __MCFUART_H__ |
---|
13 | #define __MCFUART_H__ |
---|
14 | |
---|
15 | #include <termios.h> |
---|
16 | #include "bsp.h" |
---|
17 | #include "mcf5206e.h" |
---|
18 | |
---|
19 | /* |
---|
20 | * The MCF5206e System Clock Frequency; 54MHz default |
---|
21 | */ |
---|
22 | #ifndef SYSTEM_CLOCK_FREQUENCY |
---|
23 | #define SYSTEM_CLOCK_FREQUENCY BSP_SYSTEM_FREQUENCY |
---|
24 | #endif |
---|
25 | |
---|
26 | /* |
---|
27 | * The following structure is a descriptor of single UART channel. |
---|
28 | * It contains the initialization information about channel and |
---|
29 | * current operating values |
---|
30 | */ |
---|
31 | typedef struct mcfuart { |
---|
32 | uint32_t chn; /* UART channel number */ |
---|
33 | uint8_t intvec; /* UART interrupt vector number, or |
---|
34 | 0 if polled I/O */ |
---|
35 | void *tty; /* termios channel descriptor */ |
---|
36 | |
---|
37 | volatile const char *tx_buf; /* Transmit buffer from termios */ |
---|
38 | volatile uint32_t tx_buf_len; /* Transmit buffer length */ |
---|
39 | volatile uint32_t tx_ptr; /* Index of next char to transmit*/ |
---|
40 | rtems_isr_entry old_handler; /* Saved interrupt handler */ |
---|
41 | |
---|
42 | tcflag_t c_iflag; /* termios input mode flags */ |
---|
43 | bool parerr_mark_flag; /* Parity error processing |
---|
44 | state */ |
---|
45 | } mcfuart; |
---|
46 | |
---|
47 | /* mcfuart_init -- |
---|
48 | * This function verifies the input parameters and perform initialization |
---|
49 | * of the Motorola Coldfire on-chip UART descriptor structure. |
---|
50 | * |
---|
51 | */ |
---|
52 | rtems_status_code |
---|
53 | mcfuart_init(mcfuart *uart, void *tty, uint8_t intvec, |
---|
54 | uint32_t chn); |
---|
55 | |
---|
56 | /* mcfuart_reset -- |
---|
57 | * This function perform the hardware initialization of Motorola |
---|
58 | * Coldfire processor on-chip UART controller using parameters |
---|
59 | * filled by the mcfuart_init function. |
---|
60 | */ |
---|
61 | rtems_status_code |
---|
62 | mcfuart_reset(mcfuart *uart); |
---|
63 | |
---|
64 | /* mcfuart_disable -- |
---|
65 | * This function disable the operations on Motorola Coldfire UART |
---|
66 | * controller |
---|
67 | */ |
---|
68 | rtems_status_code |
---|
69 | mcfuart_disable(mcfuart *uart); |
---|
70 | |
---|
71 | /* mcfuart_set_attributes -- |
---|
72 | * This function parse the termios attributes structure and perform |
---|
73 | * the appropriate settings in hardware. |
---|
74 | */ |
---|
75 | int |
---|
76 | mcfuart_set_attributes(mcfuart *mcf, const struct termios *t); |
---|
77 | |
---|
78 | /* mcfuart_poll_read -- |
---|
79 | * This function tried to read character from MCF UART and perform |
---|
80 | * error handling. |
---|
81 | */ |
---|
82 | int |
---|
83 | mcfuart_poll_read(mcfuart *uart); |
---|
84 | |
---|
85 | /* mcfuart_interrupt_write -- |
---|
86 | * This function initiate transmitting of the buffer in interrupt mode. |
---|
87 | */ |
---|
88 | ssize_t |
---|
89 | mcfuart_interrupt_write(mcfuart *uart, const char *buf, size_t len); |
---|
90 | |
---|
91 | /* mcfuart_poll_write -- |
---|
92 | * This function transmit buffer byte-by-byte in polling mode. |
---|
93 | */ |
---|
94 | ssize_t |
---|
95 | mcfuart_poll_write(mcfuart *uart, const char *buf, size_t len); |
---|
96 | |
---|
97 | /* mcfuart_stop_remote_tx -- |
---|
98 | * This function stop data flow from remote device. |
---|
99 | */ |
---|
100 | int |
---|
101 | mcfuart_stop_remote_tx(mcfuart *uart); |
---|
102 | |
---|
103 | /* mcfuart_start_remote_tx -- |
---|
104 | * This function resume data flow from remote device. |
---|
105 | */ |
---|
106 | int |
---|
107 | mcfuart_start_remote_tx(mcfuart *uart); |
---|
108 | |
---|
109 | #endif |
---|