[00717a3] | 1 | /* |
---|
[78dea6ce] | 2 | * Generic UART Serial driver for Motorola Coldfire processors definitions |
---|
[00717a3] | 3 | * |
---|
[78dea6ce] | 4 | * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russian Fed. |
---|
| 5 | * Author: Victor V. Vengerov <vvv@oktet.ru> |
---|
[00717a3] | 6 | * |
---|
[78dea6ce] | 7 | * The license and distribution terms for this file may be |
---|
| 8 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 9 | * http://www.rtems.org/license/LICENSE. |
---|
[00717a3] | 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 | |
---|
[023f1dd9] | 26 | /* |
---|
[00717a3] | 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 { |
---|
[b0e6c06] | 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 */ |
---|
[023f1dd9] | 36 | |
---|
[a94fb39] | 37 | volatile const char *tx_buf; /* Transmit buffer from termios */ |
---|
[b0e6c06] | 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 */ |
---|
[023f1dd9] | 41 | |
---|
[9a73f421] | 42 | tcflag_t c_iflag; /* termios input mode flags */ |
---|
| 43 | bool parerr_mark_flag; /* Parity error processing |
---|
[00717a3] | 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 |
---|
[8bc4430b] | 53 | mcfuart_init(mcfuart *uart, void *tty, uint8_t intvec, |
---|
| 54 | uint32_t chn); |
---|
[00717a3] | 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 | */ |
---|
[39a9f8e] | 88 | ssize_t |
---|
| 89 | mcfuart_interrupt_write(mcfuart *uart, const char *buf, size_t len); |
---|
[00717a3] | 90 | |
---|
| 91 | /* mcfuart_poll_write -- |
---|
| 92 | * This function transmit buffer byte-by-byte in polling mode. |
---|
| 93 | */ |
---|
[39a9f8e] | 94 | ssize_t |
---|
| 95 | mcfuart_poll_write(mcfuart *uart, const char *buf, size_t len); |
---|
[00717a3] | 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 |
---|