Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:40

0001 /*
0002  *  RTEMS driver for Blackfin UARTs
0003  *
0004  *  COPYRIGHT (c) 2008 Kallisti Labs, Los Gatos, CA, USA
0005  *            written by Allan Hessenflow <allanh@kallisti.com>
0006  *
0007  *  The license and distribution terms for this file may be
0008  *  found in the file LICENSE in this distribution or at
0009  *  http://www.rtems.org/license/LICENSE.
0010  */
0011  
0012 
0013 #ifndef _UART_H_
0014 #define _UART_H_
0015 
0016 
0017 #ifdef __cplusplus
0018 extern "C" {
0019 #endif
0020 
0021 /** bfin_uart_channel object
0022  */
0023 typedef struct {
0024   const char        *name;                 /** Holds name of the device */
0025   uint32_t          uart_baseAddress;           /** UART base address */
0026   uint32_t          uart_rxDmaBaseAddress;      /** RX DMA base address */
0027   uint32_t          uart_txDmaBaseAddress;      /** TX DMA base address */
0028   bool              uart_useInterrupts;         /** are interrupts used */
0029   bool              uart_useDma;                /** is dma used */
0030   int               uart_baud;                  /** baud rate, 0 for default */
0031 
0032   void              *termios;                   /** termios associated */
0033   uint8_t volatile  flags;                      /** flags for internal use */
0034   uint16_t          length;                     /** length for internal use */
0035 } bfin_uart_channel_t;
0036 
0037 
0038 typedef struct {
0039   uint32_t freq;
0040   int num_channels;
0041   bfin_uart_channel_t *channels;
0042 } bfin_uart_config_t;
0043 
0044 /**
0045  * @param base_address defines the UART base address
0046  * @param source defines the source that caused the interrupt. This argument
0047  * will help us in identifying if Rx or TX caused the interrupt.
0048  */
0049 typedef struct {
0050   uint32_t base_address;
0051   int source;
0052 } bfin_uart_arg_t;
0053 
0054 
0055 
0056 char bfin_uart_poll_read(rtems_device_minor_number minor);
0057 
0058 void bfin_uart_poll_write(int minor, char c);
0059 
0060 
0061 /**
0062 * Uart initialization function.
0063 * @param major major number of the device
0064 * @param config configuration parameters
0065 * @return rtems status code
0066 */
0067 rtems_status_code bfin_uart_initialize(rtems_device_major_number major,
0068     bfin_uart_config_t *config);
0069 
0070 
0071 
0072 /**
0073  * Opens the device in different modes. The supported modes are
0074  * 1. Polling
0075  * 2. Interrupt
0076  * 3. DMA
0077  * At exit the uart_Exit function will be called to flush the device.
0078  *
0079  * @param major Major number of the device
0080  * @param minor Minor number of the device
0081  * @param arg
0082  * @return
0083  */
0084 rtems_device_driver bfin_uart_open(rtems_device_major_number major,
0085     rtems_device_minor_number minor, void *arg);
0086 
0087 
0088 
0089 /**
0090  * This function implements TX dma ISR. It clears the IRQ and dequeues a char
0091  * The channel argument will have the base address. Since there are two uart
0092  * and both the uarts can use the same tx dma isr.
0093  *
0094  * TODO: 1. Error checking 2. sending correct length ie after looking at the
0095  * number of elements the uart transmitted.
0096  *
0097  * @param _arg argument passed to the interrupt handler. It contains the
0098  * channel argument.
0099  */
0100 void bfinUart_txDmaIsr(void *_arg);
0101 
0102 
0103 
0104 /**
0105  * RX DMA ISR.
0106  * The polling route is used for receiving the characters. This is a place
0107  * holder for future implementation.
0108  * @param _arg
0109  */
0110 void bfinUart_rxDmaIsr(void *_arg);
0111 
0112 
0113 /**
0114  * This function implements TX ISR. The function gets called when the TX FIFO is
0115  * empty. It clears the interrupt and dequeues the character. It only tx one
0116  * character at a time.
0117  *
0118  * TODO: error handling.
0119  * @param _arg gets the channel information.
0120  */
0121 void bfinUart_txIsr(void *_arg);
0122 
0123 
0124 /**
0125 * This function implements RX ISR
0126 */
0127 void bfinUart_rxIsr(void *_arg);
0128 
0129 
0130 #ifdef __cplusplus
0131 }
0132 #endif
0133 
0134 #endif /* _UART_H_ */
0135