summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libcpu/m68k/mcf5206/include/mcfuart.h
blob: 74b3d46e46086e336c275a4fe69e613552a49584 (plain) (blame)
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
/*
 * Generic UART Serial driver for Motorola Coldfire processors definitions
 *
 * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russian Fed.
 * Author: Victor V. Vengerov <vvv@oktet.ru>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 *
 * http://www.rtems.com/license/LICENSE.
 *
 * @(#) $Id$
 *
 */

#ifndef __MCFUART_H__
#define __MCFUART_H__

#include <termios.h>
#include "bsp.h"
#include "mcf5206e.h"

/*
 * The MCF5206e System Clock Frequency; 54MHz default
 */
#ifndef SYSTEM_CLOCK_FREQUENCY
#define SYSTEM_CLOCK_FREQUENCY BSP_SYSTEM_FREQUENCY
#endif

/* 
 * The following structure is a descriptor of single UART channel.
 * It contains the initialization information about channel and
 * current operating values
 */
typedef struct mcfuart {
   uint32_t            chn;      /* UART channel number */
   uint8_t             intvec;   /* UART interrupt vector number, or
                                          0 if polled I/O */
   void                     *tty;      /* termios channel descriptor */
   
   volatile const char      *tx_buf;    /* Transmit buffer from termios */
   volatile uint32_t   tx_buf_len;/* Transmit buffer length */
   volatile uint32_t   tx_ptr;    /* Index of next char to transmit*/
   rtems_isr_entry           old_handler;/* Saved interrupt handler */
   
   tcflag_t                  c_iflag;  /* termios input mode flags */
   rtems_boolean             parerr_mark_flag; /* Parity error processing
                                                  state */
} mcfuart;

/* mcfuart_init --
 *     This function verifies the input parameters and perform initialization
 *     of the Motorola Coldfire on-chip UART descriptor structure.
 *
 */
rtems_status_code
mcfuart_init(mcfuart *uart, void *tty, uint8_t   intvec,
             uint32_t   chn);

/* mcfuart_reset --
 *     This function perform the hardware initialization of Motorola
 *     Coldfire processor on-chip UART controller using parameters
 *     filled by the mcfuart_init function.
 */
rtems_status_code
mcfuart_reset(mcfuart *uart);

/* mcfuart_disable --
 *     This function disable the operations on Motorola Coldfire UART
 *     controller
 */
rtems_status_code
mcfuart_disable(mcfuart *uart);

/* mcfuart_set_attributes --
 *     This function parse the termios attributes structure and perform
 *     the appropriate settings in hardware.
 */
int
mcfuart_set_attributes(mcfuart *mcf, const struct termios *t);

/* mcfuart_poll_read --
 *     This function tried to read character from MCF UART and perform
 *     error handling.
 */
int
mcfuart_poll_read(mcfuart *uart);

/* mcfuart_interrupt_write --
 *     This function initiate transmitting of the buffer in interrupt mode.
 */
int
mcfuart_interrupt_write(mcfuart *uart, const char *buf, int len);

/* mcfuart_poll_write --
 *     This function transmit buffer byte-by-byte in polling mode.
 */
int
mcfuart_poll_write(mcfuart *uart, const char *buf, int len);

/* mcfuart_stop_remote_tx --
 *     This function stop data flow from remote device.
 */
int
mcfuart_stop_remote_tx(mcfuart *uart);

/* mcfuart_start_remote_tx --
 *     This function resume data flow from remote device.
 */
int
mcfuart_start_remote_tx(mcfuart *uart);

#endif