source: rtems/c/src/lib/libcpu/bfin/serial/uart.h @ 4667b4d

4.10
Last change on this file since 4667b4d was 4667b4d, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/25/11 at 11:23:30

Merge with CVS-HEAD.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 *  RTEMS driver for Blackfin UARTs
3 *
4 *  COPYRIGHT (c) 2008 Kallisti Labs, Los Gatos, CA, USA
5 *            written by Allan Hessenflow <allanh@kallisti.com>
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.com/license/LICENSE.
10 */
11 
12/*
13 *  $Id$
14 */
15
16#ifndef _UART_H_
17#define _UART_H_
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/** bfin_uart_channel object
25 */
26typedef struct {
27  const char        *name;                 /** Holds name of the device */
28  uint32_t          uart_baseAddress;           /** UART base address */
29  uint32_t          uart_rxDmaBaseAddress;      /** RX DMA base address */
30  uint32_t          uart_txDmaBaseAddress;      /** TX DMA base address */
31  bool              uart_useInterrupts;         /** are interrupts used */
32  bool              uart_useDma;                /** is dma used */
33  int               uart_baud;                  /** baud rate, 0 for default */
34
35  void              *termios;                   /** termios associated */
36  uint8_t volatile  flags;                      /** flags for internal use */
37  uint16_t          length;                     /** length for internal use */
38} bfin_uart_channel_t;
39
40
41typedef struct {
42  uint32_t freq;
43  int num_channels;
44  bfin_uart_channel_t *channels;
45} bfin_uart_config_t;
46
47/**
48 * @param base_address defines the UART base address
49 * @param source defines the source that caused the interrupt. This argument
50 * will help us in identifying if Rx or TX caused the interrupt.
51 */
52typedef struct {
53  uint32_t base_address;
54  int source;
55} bfin_uart_arg_t;
56
57
58
59char bfin_uart_poll_read(rtems_device_minor_number minor);
60
61void bfin_uart_poll_write(int minor, char c);
62
63
64/**
65* Uart initialization function.
66* @param major major number of the device
67* @param config configuration parameters
68* @return rtems status code
69*/
70rtems_status_code bfin_uart_initialize(rtems_device_major_number major,
71    bfin_uart_config_t *config);
72
73
74
75/**
76 * Opens the device in different modes. The supported modes are
77 * 1. Polling
78 * 2. Interrupt
79 * 3. DMA
80 * At exit the uart_Exit function will be called to flush the device.
81 *
82 * @param major Major number of the device
83 * @param minor Minor number of the device
84 * @param arg
85 * @return
86 */
87rtems_device_driver bfin_uart_open(rtems_device_major_number major,
88    rtems_device_minor_number minor, void *arg);
89
90
91
92/**
93 * This function implements TX dma ISR. It clears the IRQ and dequeues a char
94 * The channel argument will have the base address. Since there are two uart
95 * and both the uarts can use the same tx dma isr.
96 *
97 * TODO: 1. Error checking 2. sending correct length ie after looking at the
98 * number of elements the uart transmitted.
99 *
100 * @param _arg argument passed to the interrupt handler. It contains the
101 * channel argument.
102 */
103void bfinUart_txDmaIsr(void *_arg);
104
105
106
107/**
108 * RX DMA ISR.
109 * The polling route is used for receiving the characters. This is a place
110 * holder for future implementation.
111 * @param _arg
112 */
113void bfinUart_rxDmaIsr(void *_arg);
114
115
116/**
117 * This function implements TX ISR. The function gets called when the TX FIFO is
118 * empty. It clears the interrupt and dequeues the character. It only tx one
119 * character at a time.
120 *
121 * TODO: error handling.
122 * @param _arg gets the channel information.
123 */
124void bfinUart_txIsr(void *_arg);
125
126
127/**
128* This function implements RX ISR
129*/
130void bfinUart_rxIsr(void *_arg);
131
132
133#ifdef __cplusplus
134}
135#endif
136
137#endif /* _UART_H_ */
138
Note: See TracBrowser for help on using the repository browser.